package sysconfctrl import ( "encoding/json" "91porn-server/common" "91porn-server/common/stderr" "91porn-server/models/l/operatorlgmod" "91porn-server/web/service/sysconfser" "github.com/gin-gonic/gin" ) // All doc // @Summary 获取系统通用配置列表 // @Description 获取系统通用配置列表 // @Tags 后台-系统通用配置 // @Accept mpfd,json // @Produce json // @Param q query sysconfser.WebListReq false "请求参数" // @Success 200 object sysconfser.WebListRes "成功" // @Failure 400 {string} json "{"msg": "操作失败"}" // @Router /api/web/admin/sysconf/all [get] func All(ctx *gin.Context) { var req = &sysconfser.WebListReq{} if err := ctx.ShouldBind(&req); err != nil { common.ServeJSON(ctx, stderr.ErrParamError, err.Error()) return } res, err := req.GetAll() if err != nil { common.ServeJSON(ctx, stderr.ErrDbQueryError, "") return } common.ServeJSON(ctx, stderr.Success, res) } // Create doc // @Summary 新增系统通用配置 // @Description 新增系统通用配置 // @Tags 后台-系统通用配置 // @Accept mpfd,json // @Produce json // @Param q body sysconfser.WebCreateReq false "请求参数" // @Success 200 {string} json "{"msg": "操作成功"}" // @Failure 400 {string} json "{"msg": "操作失败"}" // @Router /api/web/admin/sysconf/create [post] func Create(ctx *gin.Context) { manager, err := common.GetAdminAct(ctx) if err != nil { common.ServeJSON(ctx, stderr.AdminIDErr, err.Error()) return } p := &sysconfser.WebCreateReq{} err = ctx.ShouldBindJSON(&p) if err != nil { common.ServeJSON(ctx, stderr.ErrParamError, err.Error()) return } // 创建 err = p.Create() if err != nil { common.ServeJSON(ctx, stderr.Failure, err.Error()) return } log, _ := json.Marshal(p) _ = operatorlgmod.RecordOperation(manager, "系统通用配置管理", "创建", string(log), ctx.Request.URL.RequestURI()) common.ServeJSON(ctx, stderr.Success, "") } // Update doc // @Summary 更新系统通用配置 // @Description 更新系统通用配置 // @Tags 后台-系统通用配置 // @Accept mpfd,json // @Produce json // @Param q body sysconfser.WebUpdateReq false "请求参数" // @Success 200 {string} json "{"msg": "操作成功"}" // @Failure 400 {string} json "{"msg": "操作失败"}" // @Router /api/web/admin/sysconf/update [post] func Update(ctx *gin.Context) { manager, err := common.GetAdminAct(ctx) if err != nil { common.ServeJSON(ctx, stderr.AdminIDErr, err.Error()) return } p := &sysconfser.WebUpdateReq{} err = ctx.ShouldBindJSON(&p) if err != nil { common.ServeJSON(ctx, stderr.ErrParamError, err.Error()) return } // 更新 err = p.Update() if err != nil { common.ServeJSON(ctx, stderr.Failure, err.Error()) return } log, _ := json.Marshal(p) _ = operatorlgmod.RecordOperation(manager, "系统通用配置管理", "更新", string(log), ctx.Request.URL.RequestURI()) common.ServeJSON(ctx, stderr.Success, "") } // Delete doc // @Summary 删除系统通用配置 // @Description 删除系统通用配置 // @Tags 后台-系统通用配置 // @Accept mpfd,json // @Produce json // @Param q body sysconfser.WebDeleteReq false "请求参数" // @Success 200 {string} json "{"msg": "操作成功"}" // @Failure 400 {string} json "{"msg": "操作失败"}" // @Router /api/web/admin/sysconf/delete [post] func Delete(ctx *gin.Context) { manager, err := common.GetAdminAct(ctx) if err != nil { common.ServeJSON(ctx, stderr.AdminIDErr, err.Error()) return } p := &sysconfser.WebDeleteReq{} err = ctx.ShouldBindJSON(&p) if err != nil { common.ServeJSON(ctx, stderr.ErrParamError, err.Error()) return } // 删除 err = p.Delete() if err != nil { common.ServeJSON(ctx, stderr.Failure, err.Error()) return } log, _ := json.Marshal(p) _ = operatorlgmod.RecordOperation(manager, "系统通用配置管理", "删除", string(log), ctx.Request.URL.RequestURI()) common.ServeJSON(ctx, stderr.Success, "") } // UpdateSelect doc // @Summary 更新系统配置下拉框选项 // @Description 更新系统配置下拉框选项 // @Tags 后台-系统通用配置 // @Accept mpfd,json // @Produce json // @Param q body sysconfser.WebUpdateSelectReq false "请求参数" // @Success 200 {string} json "{"msg": "操作成功"}" // @Failure 400 {string} json "{"msg": "操作失败"}" // @Router /api/web/admin/sysconf/update/select [post] func UpdateSelect(ctx *gin.Context) { manager, err := common.GetAdminAct(ctx) if err != nil { common.ServeJSON(ctx, stderr.AdminIDErr, err.Error()) return } p := &sysconfser.WebUpdateSelectReq{} err = ctx.ShouldBindJSON(&p) if err != nil { common.ServeJSON(ctx, stderr.ErrParamError, err.Error()) return } // 更新 err = p.Update() if err != nil { common.ServeJSON(ctx, stderr.Failure, err.Error()) return } log, _ := json.Marshal(p) _ = operatorlgmod.RecordOperation(manager, "系统通用配置管理", "更新", string(log), ctx.Request.URL.RequestURI()) common.ServeJSON(ctx, stderr.Success, "") }