CreateFields create a customized field @Summary create a customized field @Description create a customized field @Tags plugins/customize @Param table path string true "the table name" @Param request body Field true "request body" @Success 200 {object} fieldResponse "Success" @Failure 400 {object}
(input *plugin.ApiResourceInput)
| 114 | // @Failure 500 {object} shared.ApiBody "Internal Error" |
| 115 | // @Router /plugins/customize/{table}/fields [POST] |
| 116 | func (h *Handlers) CreateFields(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput, errors.Error) { |
| 117 | table := input.Params["table"] |
| 118 | fld := &Field{} |
| 119 | err := helper.Decode(input.Body, fld, nil) |
| 120 | if err != nil { |
| 121 | return &plugin.ApiResourceOutput{Status: http.StatusBadRequest}, err |
| 122 | } |
| 123 | customizedField, err := fld.toDBModel(table) |
| 124 | if err != nil { |
| 125 | return &plugin.ApiResourceOutput{Status: http.StatusBadRequest}, err |
| 126 | } |
| 127 | err = h.svc.CreateField(customizedField) |
| 128 | if err != nil { |
| 129 | return nil, errors.Default.Wrap(err, "CreateField error") |
| 130 | } |
| 131 | return &plugin.ApiResourceOutput{Body: fieldResponse{*fld, true}, Status: http.StatusOK}, nil |
| 132 | } |
| 133 | |
| 134 | // DeleteField delete a customized fields |
| 135 | // @Summary return all customized fields |
nothing calls this directly
no test coverage detected