style: 错误信息英文返回-system 模块路由
This commit is contained in:
@@ -45,7 +45,7 @@ func (s *SysPostController) List(c *gin.Context) {
|
||||
func (s *SysPostController) Info(c *gin.Context) {
|
||||
postId := c.Param("postId")
|
||||
if postId == "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
data := s.sysPostService.SelectPostById(postId)
|
||||
@@ -63,14 +63,15 @@ func (s *SysPostController) Add(c *gin.Context) {
|
||||
var body model.SysPost
|
||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||
if err != nil || body.PostID != "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查名称唯一
|
||||
uniqueuPostName := s.sysPostService.CheckUniquePostName(body.PostName, "")
|
||||
if !uniqueuPostName {
|
||||
msg := fmt.Sprintf("岗位新增【%s】失败,岗位名称已存在", body.PostName)
|
||||
// 岗位新增【%s】失败,岗位名称已存在
|
||||
msg := fmt.Sprintf("Job addition [%s] failed, job name already exists", body.PostName)
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -78,7 +79,8 @@ func (s *SysPostController) Add(c *gin.Context) {
|
||||
// 检查编码属性值唯一
|
||||
uniquePostCode := s.sysPostService.CheckUniquePostCode(body.PostCode, "")
|
||||
if !uniquePostCode {
|
||||
msg := fmt.Sprintf("岗位新增【%s】失败,岗位编码已存在", body.PostCode)
|
||||
// 岗位新增【%s】失败,岗位编码已存在
|
||||
msg := fmt.Sprintf("Job addition [%s] failed, job code already exists", body.PostCode)
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -99,21 +101,23 @@ func (s *SysPostController) Edit(c *gin.Context) {
|
||||
var body model.SysPost
|
||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||
if err != nil || body.PostID == "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否存在
|
||||
post := s.sysPostService.SelectPostById(body.PostID)
|
||||
if post.PostID != body.PostID {
|
||||
c.JSON(200, result.ErrMsg("没有权限访问岗位数据!"))
|
||||
// 没有可访问岗位数据!
|
||||
c.JSON(200, result.ErrMsg("There is no accessible post data!"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查名称唯一
|
||||
uniqueuPostName := s.sysPostService.CheckUniquePostName(body.PostName, body.PostID)
|
||||
if !uniqueuPostName {
|
||||
msg := fmt.Sprintf("岗位修改【%s】失败,岗位名称已存在", body.PostName)
|
||||
// 岗位修改【%s】失败,岗位名称已存在
|
||||
msg := fmt.Sprintf("Post modification [%s] failed, post name already exists", body.PostName)
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -121,7 +125,8 @@ func (s *SysPostController) Edit(c *gin.Context) {
|
||||
// 检查编码属性值唯一
|
||||
uniquePostCode := s.sysPostService.CheckUniquePostCode(body.PostCode, body.PostID)
|
||||
if !uniquePostCode {
|
||||
msg := fmt.Sprintf("岗位修改【%s】失败,岗位编码已存在", body.PostCode)
|
||||
// 岗位修改【%s】失败,岗位编码已存在
|
||||
msg := fmt.Sprintf("Post modification [%s] failed, post code already exists", body.PostCode)
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -141,7 +146,7 @@ func (s *SysPostController) Edit(c *gin.Context) {
|
||||
func (s *SysPostController) Remove(c *gin.Context) {
|
||||
postIds := c.Param("postIds")
|
||||
if postIds == "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
// 处理字符转id数组后去重
|
||||
@@ -156,7 +161,7 @@ func (s *SysPostController) 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))
|
||||
}
|
||||
|
||||
@@ -168,7 +173,8 @@ func (s *SysPostController) Export(c *gin.Context) {
|
||||
querys := ctx.BodyJSONMap(c)
|
||||
data := s.sysPostService.SelectPostPage(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.SysPost)
|
||||
@@ -177,19 +183,19 @@ func (s *SysPostController) Export(c *gin.Context) {
|
||||
fileName := fmt.Sprintf("post_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
|
||||
// 第一行表头标题
|
||||
headerCells := map[string]string{
|
||||
"A1": "岗位编号",
|
||||
"B1": "岗位编码",
|
||||
"C1": "岗位名称",
|
||||
"D1": "岗位排序",
|
||||
"E1": "状态",
|
||||
"A1": "PostID",
|
||||
"B1": "PostCode",
|
||||
"C1": "PostName",
|
||||
"D1": "PostSort",
|
||||
"E1": "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.PostID,
|
||||
|
||||
Reference in New Issue
Block a user