finclip-app-manager/application/app_config.go

79 lines
2.0 KiB
Go
Raw Normal View History

2023-10-31 14:07:26 +08:00
package application
import (
"finclip-app-manager/domain/service"
"finclip-app-manager/infrastructure/logger"
"finclip-app-manager/infrastructure/utility"
"net/http"
"github.com/gin-gonic/gin"
"gitlab.finogeeks.club/finclip-backend/apm"
)
/**
* @api {GET} /api/v1/mop/finstore/admin/app-oper-conifg/info [C/S]
* @apiGroup Finclip App Manager
* @apiVersion __API_VERSION__
* @apiSuccessExample {json} Success Status:
* HTTP/1.1 200 OK
* {
* "errcode": "OK",
* "error": "",
* "data":{
* "autoReviewApp":1 //1代表打开0代表关闭
* }
* }
* @apiErrorExample Error Status:
* HTTP/1.1 !=200
*/
func QueryAppOperConfig(c *gin.Context) {
traceCtx := apm.ApmClient().TraceContextFromGin(c)
s := service.NewAppConfigService()
rsp, errStr := s.GetOperConfig(traceCtx)
if errStr != utility.OK {
utility.MakeLocRsp(c, http.StatusOK, errStr, nil)
return
} else {
utility.MakeLocRsp(c, http.StatusOK, errStr, rsp)
return
}
}
/**
* @api {POST} /api/v1/mop/finstore/admin/app-oper-conifg/update [C/S]
* @apiGroup Finclip App Manager
* @apiVersion __API_VERSION__
* @apiParam (RequestBody) {int} autoReviewApp
* @apiParamExample {json} Request-Example:
* {
* "autoReviewApp": 1
* }
* @apiSuccessExample {json} Success Status:
* HTTP/1.1 200 OK
* {
* "errcode": "OK",
* "error": "",
* "data":{}
* }
* @apiErrorExample Error Status:
* HTTP/1.1 !=200
*/
func UpdateAppOperConfig(c *gin.Context) {
traceCtx := apm.ApmClient().TraceContextFromGin(c)
var req service.UpdateAppOperCofigReq
if err := c.BindJSON(&req); err != nil {
logger.GetLogger().Errorf("UpdateAppOperConfig bind err:%s", err.Error())
utility.MakeLocRsp(c, http.StatusBadRequest, utility.FS_BAD_JSON, nil)
return
}
s := service.NewAppConfigService()
errStr, errCode := s.UpdateAppOperCofig(traceCtx, req)
utility.MakeLocRsp(c, errCode, errStr, nil)
return
}