package application import ( "finclip-app-manager/domain/entity/proto/apiproto" "finclip-app-manager/domain/service" "finclip-app-manager/infrastructure/utility" "github.com/gin-gonic/gin" "gitlab.finogeeks.club/finclip-backend/apm" "net/http" ) /** * @api {POST} * @apiGroup Finclip App Manager * @apiParam (RequestBody) {string} name * @apiParam (RequestBody) {string} id * @apiParam (RequestBody) {string} image * @apiParamExample {json} Request-Example: * { * "name":"111", * "id":"1112", * "image":"11" * } * @apiSuccessExample {json} Success Status: * HTTP/1.1 200 OK * { * "errcode": "OK", * "error": "成功", * "data":{ * * } * } * @apiErrorExample Error Status: * HTTP/1.1 !=200 服务端异常 */ func AddMenuHand(c *gin.Context) { var ( traceCtx = apm.ApmClient().TraceContextFromGin(c) req = apiproto.AddMenuReq{} ) if err := c.BindJSON(&req); err != nil { log.Errorf("AddMenuHand bind err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_BAD_JSON, gin.H{}) return } if req.Name == "" || req.ID == "" || req.Image == "" { log.Errorf("AddMenuHand param err:[empty],req:%+v", req) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_BAD_JSON, gin.H{}) return } svr := service.NewMenuInfoService() svr.AddMenu(traceCtx, c, &req) return } /** * @api {GET} * @apiGroup Finclip App Manager * @apiSuccessExample {json} Success Status: * HTTP/1.1 200 OK * { * "data": {}, * "errcode": "OK", * "error": "" * } * @apiErrorExample Error Status: * HTTP/1.1 !=200 服务端异常 */ func DelMenuHand(c *gin.Context) { var ( traceCtx = apm.ApmClient().TraceContextFromGin(c) ) traceId := c.Param("traceId") if traceId == "" { log.Errorf("trace id empty ...") utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_BAD_JSON, gin.H{}) return } svr := service.NewMenuInfoService() svr.DelMenu(traceCtx, c, traceId) return } /** * @api {PUT} * @apiGroup Finclip App Manager * @apiParam (RequestBody) {string} traceId * @apiParam (RequestBody) {string} name * @apiParam (RequestBody) {string} id * @apiParam (RequestBody) {string} image * @apiParamExample {json} Request-Example: * { * "name":"111", * "id":"1112", * "image":"11" * } * @apiSuccessExample {json} Success Status: * HTTP/1.1 200 OK * { * "data": {}, * "errcode": "OK", * "error": "" * } * @apiErrorExample Error Status: * HTTP/1.1 !=200 服务端异常 */ func UpdateMenuHand(c *gin.Context) { var ( traceCtx = apm.ApmClient().TraceContextFromGin(c) ) traceId := c.Param("traceId") if traceId == "" { log.Errorf("trace id empty ...") utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_BAD_JSON, gin.H{}) return } req := apiproto.UpdateMenuReq{} if err := c.BindJSON(&req); err != nil { log.Errorf("UpdateMenuHand bind err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_BAD_JSON, gin.H{}) return } svr := service.NewMenuInfoService() svr.UpdateMenu(traceCtx, c, traceId, &req) return } /** * @api {GET} * @apiGroup Finclip App Manager * @apiSuccessExample {json} Success Status: * HTTP/1.1 200 OK * { * { * "data": { * "total": 1, * "list": [ * { * "traceId": "6049d56024c81800015698cc", * "name": "12", * "id": "12", * "image": "/api/v1/mop/netdisk/download/6049d55f264ec50001706a4c", * "sortNum": 0, * "createTime": 1615451488106, * "updateTime": 1615451488106, * "updateOperator": "叼叼叼kk" * } * ] * }, * "errcode": "OK", * "error": "" * } * @apiErrorExample Error Status: * HTTP/1.1 !=200 服务端异常 */ func GetAllMenuHand(c *gin.Context) { var ( traceCtx = apm.ApmClient().TraceContextFromGin(c) ) svr := service.NewMenuInfoService() svr.GetAllMenu(traceCtx, c) return } /** * @api {POST} * @apiGroup Finclip App Manager * @apiParam (RequestBody) {string} traceId * @apiParam (RequestBody) {string} sortNum * @apiParamExample {json} Request-Example: * { * "list": [ * { * "traceId": "61f2658437236900015ad666", * "sortNum": 5 * }, * { * "traceId": "61f266ea37236900015ad667", * "sortNum": 4 * } * ] * } * @apiSuccessExample {json} Success Status: * HTTP/1.1 200 OK * { * "data": {}, * "errcode": "OK", * "error": "" * } * @apiErrorExample Error Status: * HTTP/1.1 !=200 服务端异常 */ func SortMenuHand(c *gin.Context) { var ( traceCtx = apm.ApmClient().TraceContextFromGin(c) ) req := apiproto.MenuSortReq{} if err := c.BindJSON(&req); err != nil { log.Errorf("AddMenuHand bind err:%s", err.Error()) utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_BAD_JSON, gin.H{}) return } svr := service.NewMenuInfoService() svr.SortMenu(traceCtx, c, &req) return }