package sys import ( "pure-admin/global" "pure-admin/model" "pure-admin/model/request" "pure-admin/model/response" "pure-admin/service" "pure-admin/utils" "github.com/gin-gonic/gin" "go.uber.org/zap" ) func CreateSysDictionary(c *gin.Context) { var dictionary model.SysDictionary _ = c.ShouldBindJSON(&dictionary) if err := service.CreateSysDictionary(dictionary); err != nil { global.MG_LOG.Error("创建失败!", zap.Any("err", err)) response.FailWithMessage("创建失败", c) } else { response.OkWithMessage("创建成功", c) } } func DeleteSysDictionary(c *gin.Context) { var dictionary model.SysDictionary _ = c.ShouldBindJSON(&dictionary) if err := service.DeleteSysDictionary(dictionary); err != nil { global.MG_LOG.Error("删除失败!", zap.Any("err", err)) response.FailWithMessage("删除失败", c) } else { response.OkWithMessage("删除成功", c) } } func UpdateSysDictionary(c *gin.Context) { var dictionary model.SysDictionary _ = c.ShouldBindJSON(&dictionary) if err := service.UpdateSysDictionary(&dictionary); err != nil { global.MG_LOG.Error("更新失败!", zap.Any("err", err)) response.FailWithMessage("更新失败", c) } else { response.OkWithMessage("更新成功", c) } } func FindSysDictionary(c *gin.Context) { var dictionary model.SysDictionary _ = c.ShouldBindQuery(&dictionary) if err, sysDictionary := service.GetSysDictionary(dictionary.Type, dictionary.ID); err != nil { global.MG_LOG.Error("查询失败!", zap.Any("err", err)) response.FailWithMessage("查询失败", c) } else { response.OkWithDetailed(gin.H{"resysDictionary": sysDictionary}, "查询成功", c) } } func GetSysDictionaryList(c *gin.Context) { var pageInfo request.SysDictionarySearch _ = c.ShouldBindQuery(&pageInfo) if err := utils.Verify(pageInfo.PageInfo, utils.PageInfoVerify); err != nil { response.FailWithMessage(err.Error(), c) return } if err, list, total := service.GetSysDictionaryInfoList(pageInfo); err != nil { global.MG_LOG.Error("获取失败!", zap.Any("err", err)) response.FailWithMessage("获取失败", c) } else { response.OkWithDetailed(response.PageResult{ List: list, Total: total, Page: pageInfo.Page, PageSize: pageInfo.PageSize, }, "获取成功", c) } }