fix: 导出功能为全量,行头文字多语言翻译
This commit is contained in:
@@ -209,14 +209,21 @@ func (s *SysPostController) Remove(c *gin.Context) {
|
||||
func (s *SysPostController) Export(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
// 查询结果,根据查询条件结果,单页最大值限制
|
||||
querys := ctx.BodyJSONMap(c)
|
||||
data := s.sysPostService.SelectPostPage(querys)
|
||||
if data["total"].(int64) == 0 {
|
||||
// querys := ctx.BodyJSONMap(c)
|
||||
// data := s.sysPostService.SelectPostPage(querys)
|
||||
// if data["total"].(int64) == 0 {
|
||||
// // 导出数据记录为空
|
||||
// c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
|
||||
// return
|
||||
// }
|
||||
// rows := data["rows"].([]model.SysPost)
|
||||
|
||||
rows := s.sysPostService.SelectPostList(model.SysPost{})
|
||||
if len(rows) <= 0 {
|
||||
// 导出数据记录为空
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
|
||||
return
|
||||
}
|
||||
rows := data["rows"].([]model.SysPost)
|
||||
|
||||
// 闭包函数处理多语言
|
||||
converI18n := func(language string, arr *[]model.SysPost) {
|
||||
@@ -232,8 +239,8 @@ func (s *SysPostController) Export(c *gin.Context) {
|
||||
// 第一行表头标题
|
||||
headerCells := map[string]string{
|
||||
"A1": i18n.TKey(language, "post.export.id"),
|
||||
"B1": i18n.TKey(language, "post.export.code"),
|
||||
"C1": i18n.TKey(language, "post.export.name"),
|
||||
"B1": i18n.TKey(language, "post.export.name"),
|
||||
"C1": i18n.TKey(language, "post.export.code"),
|
||||
"D1": i18n.TKey(language, "post.export.sort"),
|
||||
"E1": i18n.TKey(language, "post.export.status"),
|
||||
}
|
||||
@@ -247,8 +254,8 @@ func (s *SysPostController) Export(c *gin.Context) {
|
||||
}
|
||||
dataCells = append(dataCells, map[string]any{
|
||||
"A" + idx: row.PostID,
|
||||
"B" + idx: row.PostCode,
|
||||
"C" + idx: row.PostName,
|
||||
"B" + idx: row.PostName,
|
||||
"C" + idx: row.PostCode,
|
||||
"D" + idx: row.PostSort,
|
||||
"E" + idx: statusValue,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user