style: 错误信息英文返回-system 模块路由
This commit is contained in:
@@ -45,7 +45,7 @@ func (s *SysConfigController) List(c *gin.Context) {
|
||||
func (s *SysConfigController) Info(c *gin.Context) {
|
||||
configId := c.Param("configId")
|
||||
if configId == "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
data := s.sysConfigService.SelectConfigById(configId)
|
||||
@@ -63,14 +63,15 @@ func (s *SysConfigController) Add(c *gin.Context) {
|
||||
var body model.SysConfig
|
||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||
if err != nil || body.ConfigID != "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查属性值唯一
|
||||
uniqueConfigKey := s.sysConfigService.CheckUniqueConfigKey(body.ConfigKey, "")
|
||||
if !uniqueConfigKey {
|
||||
msg := fmt.Sprintf("参数配置新增【%s】失败,参数键名已存在", body.ConfigKey)
|
||||
// 参数配置新增【%s】失败,参数键名已存在
|
||||
msg := fmt.Sprintf("Parameter configuration add [%s] failed, parameter key name already exists", body.ConfigKey)
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -91,14 +92,15 @@ func (s *SysConfigController) Edit(c *gin.Context) {
|
||||
var body model.SysConfig
|
||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||
if err != nil || body.ConfigID == "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查属性值唯一
|
||||
uniqueConfigKey := s.sysConfigService.CheckUniqueConfigKey(body.ConfigKey, body.ConfigID)
|
||||
if !uniqueConfigKey {
|
||||
msg := fmt.Sprintf("参数配置修改【%s】失败,参数键名已存在", body.ConfigKey)
|
||||
// 参数配置修改【%s】失败,参数键名已存在
|
||||
msg := fmt.Sprintf("Parameter configuration modification [%s] failed, parameter key name already exists", body.ConfigKey)
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -106,7 +108,8 @@ func (s *SysConfigController) Edit(c *gin.Context) {
|
||||
// 检查是否存在
|
||||
config := s.sysConfigService.SelectConfigById(body.ConfigID)
|
||||
if config.ConfigID != body.ConfigID {
|
||||
c.JSON(200, result.ErrMsg("没有权限访问参数配置数据!"))
|
||||
// 没有可访问参数配置数据!
|
||||
c.JSON(200, result.ErrMsg("There is no accessible parameter configuration data!"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -125,7 +128,7 @@ func (s *SysConfigController) Edit(c *gin.Context) {
|
||||
func (s *SysConfigController) Remove(c *gin.Context) {
|
||||
configIds := c.Param("configIds")
|
||||
if configIds == "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
// 处理字符转id数组后去重
|
||||
@@ -140,7 +143,7 @@ func (s *SysConfigController) Remove(c *gin.Context) {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
||||
msg := fmt.Sprintf("Deleted successfully: %d", rows)
|
||||
c.JSON(200, result.OkMsg(msg))
|
||||
}
|
||||
|
||||
@@ -158,7 +161,7 @@ func (s *SysConfigController) RefreshCache(c *gin.Context) {
|
||||
func (s *SysConfigController) ConfigKey(c *gin.Context) {
|
||||
configKey := c.Param("configKey")
|
||||
if configKey == "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
key := s.sysConfigService.SelectConfigValueByKey(configKey)
|
||||
@@ -177,7 +180,8 @@ func (s *SysConfigController) Export(c *gin.Context) {
|
||||
querys := ctx.BodyJSONMap(c)
|
||||
data := s.sysConfigService.SelectConfigPage(querys)
|
||||
if data["total"].(int64) == 0 {
|
||||
c.JSON(200, result.ErrMsg("导出数据记录为空"))
|
||||
// 导出数据记录为空
|
||||
c.JSON(200, result.ErrMsg("Export data record is empty"))
|
||||
return
|
||||
}
|
||||
rows := data["rows"].([]model.SysConfig)
|
||||
@@ -186,19 +190,19 @@ func (s *SysConfigController) Export(c *gin.Context) {
|
||||
fileName := fmt.Sprintf("config_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
|
||||
// 第一行表头标题
|
||||
headerCells := map[string]string{
|
||||
"A1": "参数编号",
|
||||
"B1": "参数名称",
|
||||
"C1": "参数键名",
|
||||
"D1": "参数键值",
|
||||
"E1": "系统内置",
|
||||
"A1": "ConfigID",
|
||||
"B1": "ConfigName",
|
||||
"C1": "ConfigKey",
|
||||
"D1": "ConfigValue",
|
||||
"E1": "Type",
|
||||
}
|
||||
// 从第二行开始的数据
|
||||
dataCells := make([]map[string]any, 0)
|
||||
for i, row := range rows {
|
||||
idx := strconv.Itoa(i + 2)
|
||||
typeValue := "否"
|
||||
typeValue := "clogged"
|
||||
if row.ConfigType == "Y" {
|
||||
typeValue = "是"
|
||||
typeValue = "be"
|
||||
}
|
||||
dataCells = append(dataCells, map[string]any{
|
||||
"A" + idx: row.ConfigID,
|
||||
@@ -228,20 +232,22 @@ func (s *SysConfigController) ConfigValue(c *gin.Context) {
|
||||
Value string `json:"value" binding:"required"`
|
||||
}
|
||||
if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否存在
|
||||
info := s.sysConfigService.SelectConfigByKey(body.Key)
|
||||
if info.ConfigKey != body.Key {
|
||||
c.JSON(200, result.ErrMsg("无效 key"))
|
||||
// 无效 key
|
||||
c.JSON(200, result.ErrMsg("Invalid key"))
|
||||
return
|
||||
}
|
||||
|
||||
// 与旧值相等不变更
|
||||
if info.ConfigValue == body.Value {
|
||||
c.JSON(200, result.ErrMsg("变更状态与旧值相等!"))
|
||||
// 变更状态与旧值相等!
|
||||
c.JSON(200, result.ErrMsg("The change status is equal to the old value!"))
|
||||
return
|
||||
}
|
||||
info.ConfigValue = body.Value
|
||||
|
||||
Reference in New Issue
Block a user