@@ -14,6 +14,7 @@ const (
1414 Update = "update"
1515 Patch = "patch"
1616)
17+
1718func CreatePatchAndParams (modelType reflect.Type , logError func (context.Context , string , ... map [string ]interface {}), patch func (context.Context , map [string ]interface {}) (int64 , error ), validate func (context.Context , interface {}) ([]sv.ErrorMessage , error ), build func (context.Context , interface {}) (interface {}, error ), action * sv.ActionConfig , options ... func (context.Context , string , string , bool , string ) error ) (* PatchHandler , * sv.Params ) {
1819 var writeLog func (context.Context , string , string , bool , string ) error
1920 if len (options ) > 0 {
@@ -48,6 +49,7 @@ type PatchHandler struct {
4849 ResourceType string
4950 Activity string
5051}
52+
5153func (h * PatchHandler ) Patch (ctx echo.Context ) error {
5254 r := ctx .Request ()
5355 r = r .WithContext (context .WithValue (r .Context (), Method , Patch ))
@@ -355,37 +357,7 @@ func Respond(ctx echo.Context, code int, result interface{}, err error, logError
355357 return Succeed (ctx , code , result , writeLog , resource , action )
356358 }
357359}
358- /*
359- func Return222(ctx echo.Context, code int, result sv.ResultInfo, status sv.StatusConfig, err error, logError func(context.Context, string, ...map[string]interface{}), writeLog func(context.Context, string, string, bool, string) error, options ...string) {
360- var resource, action string
361- if len(options) > 0 && len(options[0]) > 0 {
362- resource = options[0]
363- }
364- if len(options) > 1 && len(options[1]) > 0 {
365- action = options[1]
366- }
367- if err != nil {
368- RespondAndLog(ctx, http.StatusInternalServerError, sv.InternalServerError, err, logError, writeLog, resource, action)
369- } else {
370- if code == http.StatusCreated {
371- if result.Status == status.DuplicateKey {
372- Succeed(ctx, http.StatusConflict, result, writeLog, resource, action)
373- } else {
374- Succeed(ctx, code, result, writeLog, resource, action)
375- }
376- } else {
377- if result.Status == status.NotFound {
378- Succeed(ctx, http.StatusNotFound, result, writeLog, resource, action)
379- } else if result.Status == status.VersionError {
380- Succeed(ctx, http.StatusConflict, result, writeLog, resource, action)
381- } else {
382- Succeed(ctx, code, result, writeLog, resource, action)
383- }
384- }
385- }
386- }
387- */
388- func Result (ctx echo.Context , code int , result interface {}, err error , logError func (context.Context , string , ... map [string ]interface {}), opts ... interface {}) error {
360+ func Result (ctx echo.Context , code int , result interface {}, err error , logError func (context.Context , string , ... map [string ]interface {}), opts ... interface {}) error {
389361 if err != nil {
390362 if len (opts ) > 0 && opts [0 ] != nil {
391363 b , er2 := json .Marshal (opts [0 ])
0 commit comments