style: 错误信息英文返回-system 模块路由
This commit is contained in:
@@ -48,7 +48,7 @@ func (s *SysDictDataController) List(c *gin.Context) {
|
||||
func (s *SysDictDataController) Info(c *gin.Context) {
|
||||
dictCode := c.Param("dictCode")
|
||||
if dictCode == "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
data := s.sysDictDataService.SelectDictDataByCode(dictCode)
|
||||
@@ -66,21 +66,23 @@ func (s *SysDictDataController) Add(c *gin.Context) {
|
||||
var body model.SysDictData
|
||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||
if err != nil || body.DictCode != "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查字典类型是否存在
|
||||
sysDictType := s.sysDictTypeService.SelectDictTypeByType(body.DictType)
|
||||
if sysDictType.DictType != body.DictType {
|
||||
c.JSON(200, result.ErrMsg("没有权限访问字典类型数据!"))
|
||||
// 没有可访问字典类型数据!
|
||||
c.JSON(200, result.ErrMsg("There is no accessible dictionary type data!"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查字典标签唯一
|
||||
uniqueDictLabel := s.sysDictDataService.CheckUniqueDictLabel(body.DictType, body.DictLabel, "")
|
||||
if !uniqueDictLabel {
|
||||
msg := fmt.Sprintf("数据新增【%s】失败,该字典类型下标签名已存在", body.DictLabel)
|
||||
// 数据新增【%s】失败,该字典类型下标签名已存在
|
||||
msg := fmt.Sprintf("Data addition [%s] failed, tag name already exists under this dictionary type", body.DictLabel)
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -88,7 +90,8 @@ func (s *SysDictDataController) Add(c *gin.Context) {
|
||||
// 检查字典键值唯一
|
||||
uniqueDictValue := s.sysDictDataService.CheckUniqueDictValue(body.DictType, body.DictValue, "")
|
||||
if !uniqueDictValue {
|
||||
msg := fmt.Sprintf("数据新增【%s】失败,该字典类型下标签值已存在", body.DictValue)
|
||||
// 数据新增【%s】失败,该字典类型下标签值已存在
|
||||
msg := fmt.Sprintf("Data addition [%s] failed, tagged value already exists under this dictionary type", body.DictValue)
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -109,28 +112,31 @@ func (s *SysDictDataController) Edit(c *gin.Context) {
|
||||
var body model.SysDictData
|
||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||
if err != nil || body.DictCode == "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查字典类型是否存在
|
||||
sysDictType := s.sysDictTypeService.SelectDictTypeByType(body.DictType)
|
||||
if sysDictType.DictType != body.DictType {
|
||||
c.JSON(200, result.ErrMsg("没有权限访问字典类型数据!"))
|
||||
// 没有可访问字典类型数据!
|
||||
c.JSON(200, result.ErrMsg("There is no accessible dictionary type data!"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查字典编码是否存在
|
||||
SysDictDataController := s.sysDictDataService.SelectDictDataByCode(body.DictCode)
|
||||
if SysDictDataController.DictCode != body.DictCode {
|
||||
c.JSON(200, result.ErrMsg("没有权限访问字典编码数据!"))
|
||||
// 没有可访问字典编码数据!
|
||||
c.JSON(200, result.ErrMsg("There is no accessible dictionary-encoded data!"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查字典标签唯一
|
||||
uniqueDictLabel := s.sysDictDataService.CheckUniqueDictLabel(body.DictType, body.DictLabel, body.DictCode)
|
||||
if !uniqueDictLabel {
|
||||
msg := fmt.Sprintf("数据修改【%s】失败,该字典类型下标签名已存在", body.DictLabel)
|
||||
// 数据修改【%s】失败,该字典类型下标签名已存在
|
||||
msg := fmt.Sprintf("Data modification [%s] failed, tag name already exists under this dictionary type", body.DictLabel)
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -138,7 +144,8 @@ func (s *SysDictDataController) Edit(c *gin.Context) {
|
||||
// 检查字典键值唯一
|
||||
uniqueDictValue := s.sysDictDataService.CheckUniqueDictValue(body.DictType, body.DictValue, body.DictCode)
|
||||
if !uniqueDictValue {
|
||||
msg := fmt.Sprintf("数据修改【%s】失败,该字典类型下标签值已存在", body.DictValue)
|
||||
// 数据修改【%s】失败,该字典类型下标签值已存在
|
||||
msg := fmt.Sprintf("Data modification [%s] failed, tagged value already exists under this dictionary type", body.DictValue)
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -158,7 +165,7 @@ func (s *SysDictDataController) Edit(c *gin.Context) {
|
||||
func (s *SysDictDataController) Remove(c *gin.Context) {
|
||||
dictCodes := c.Param("dictCodes")
|
||||
if dictCodes == "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
// 处理字符转id数组后去重
|
||||
@@ -173,7 +180,8 @@ func (s *SysDictDataController) Remove(c *gin.Context) {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
||||
// 删除成功:%d
|
||||
msg := fmt.Sprintf("Deleted successfully: %d", rows)
|
||||
c.JSON(200, result.OkMsg(msg))
|
||||
}
|
||||
|
||||
@@ -183,7 +191,7 @@ func (s *SysDictDataController) Remove(c *gin.Context) {
|
||||
func (s *SysDictDataController) DictType(c *gin.Context) {
|
||||
dictType := c.Param("dictType")
|
||||
if dictType == "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -199,7 +207,8 @@ func (s *SysDictDataController) Export(c *gin.Context) {
|
||||
querys := ctx.BodyJSONMap(c)
|
||||
data := s.sysDictDataService.SelectDictDataPage(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.SysDictData)
|
||||
@@ -208,20 +217,20 @@ func (s *SysDictDataController) Export(c *gin.Context) {
|
||||
fileName := fmt.Sprintf("dict_data_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
|
||||
// 第一行表头标题
|
||||
headerCells := map[string]string{
|
||||
"A1": "字典编码",
|
||||
"B1": "字典排序",
|
||||
"C1": "字典标签",
|
||||
"D1": "字典键值",
|
||||
"E1": "字典类型",
|
||||
"F1": "状态",
|
||||
"A1": "DictCode",
|
||||
"B1": "DictSort",
|
||||
"C1": "DictLabel",
|
||||
"D1": "DictValue",
|
||||
"E1": "DictType",
|
||||
"F1": "Status",
|
||||
}
|
||||
// 从第二行开始的数据
|
||||
dataCells := make([]map[string]any, 0)
|
||||
for i, row := range rows {
|
||||
idx := strconv.Itoa(i + 2)
|
||||
statusValue := "停用"
|
||||
statusValue := "deactivate"
|
||||
if row.Status == "1" {
|
||||
statusValue = "正常"
|
||||
statusValue = "normalcy"
|
||||
}
|
||||
dataCells = append(dataCells, map[string]any{
|
||||
"A" + idx: row.DictCode,
|
||||
|
||||
Reference in New Issue
Block a user