fix: 导出功能为全量,行头文字多语言翻译
This commit is contained in:
@@ -121,14 +121,21 @@ func (s *SysLogLoginController) Unlock(c *gin.Context) {
|
||||
func (s *SysLogLoginController) Export(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
// 查询结果,根据查询条件结果,单页最大值限制
|
||||
querys := ctx.BodyJSONMap(c)
|
||||
data := s.sysLogLoginService.SelectSysLogLoginPage(querys)
|
||||
if data["total"].(int64) == 0 {
|
||||
// querys := ctx.BodyJSONMap(c)
|
||||
// data := s.sysLogLoginService.SelectSysLogLoginPage(querys)
|
||||
// if data["total"].(int64) == 0 {
|
||||
// // 导出数据记录为空
|
||||
// c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
|
||||
// return
|
||||
// }
|
||||
// rows := data["rows"].([]model.SysLogLogin)
|
||||
|
||||
rows := s.sysLogLoginService.SelectSysLogLoginList(model.SysLogLogin{})
|
||||
if len(rows) <= 0 {
|
||||
// 导出数据记录为空
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
|
||||
return
|
||||
}
|
||||
rows := data["rows"].([]model.SysLogLogin)
|
||||
|
||||
// 闭包函数处理多语言
|
||||
converI18n := func(language string, arr *[]model.SysLogLogin) {
|
||||
@@ -147,13 +154,13 @@ func (s *SysLogLoginController) Export(c *gin.Context) {
|
||||
headerCells := map[string]string{
|
||||
"A1": i18n.TKey(language, "log.login.export.id"),
|
||||
"B1": i18n.TKey(language, "log.login.export.userName"),
|
||||
"C1": i18n.TKey(language, "log.login.export.status"),
|
||||
"D1": i18n.TKey(language, "log.login.export.ip"),
|
||||
"E1": i18n.TKey(language, "log.login.export.location"),
|
||||
"C1": i18n.TKey(language, "log.login.export.ip"),
|
||||
"D1": i18n.TKey(language, "log.login.export.location"),
|
||||
"E1": i18n.TKey(language, "log.login.export.os"),
|
||||
"F1": i18n.TKey(language, "log.login.export.browser"),
|
||||
"G1": i18n.TKey(language, "log.login.export.os"),
|
||||
"H1": i18n.TKey(language, "log.login.export.msg"),
|
||||
"I1": i18n.TKey(language, "log.login.export.time"),
|
||||
"G1": i18n.TKey(language, "log.login.export.status"),
|
||||
"H1": i18n.TKey(language, "log.login.export.time"),
|
||||
"I1": i18n.TKey(language, "log.login.export.msg"),
|
||||
}
|
||||
// 从第二行开始的数据
|
||||
dataCells := make([]map[string]any, 0)
|
||||
@@ -167,13 +174,13 @@ func (s *SysLogLoginController) Export(c *gin.Context) {
|
||||
dataCells = append(dataCells, map[string]any{
|
||||
"A" + idx: row.LoginID,
|
||||
"B" + idx: row.UserName,
|
||||
"C" + idx: statusValue,
|
||||
"D" + idx: row.IPAddr,
|
||||
"E" + idx: row.LoginLocation,
|
||||
"C" + idx: row.IPAddr,
|
||||
"D" + idx: row.LoginLocation,
|
||||
"E" + idx: row.OS,
|
||||
"F" + idx: row.Browser,
|
||||
"G" + idx: row.OS,
|
||||
"H" + idx: row.Msg,
|
||||
"I" + idx: date.ParseDateToStr(row.LoginTime, date.YYYY_MM_DD_HH_MM_SS),
|
||||
"G" + idx: statusValue,
|
||||
"H" + idx: date.ParseDateToStr(row.LoginTime, date.YYYY_MM_DD_HH_MM_SS),
|
||||
"I" + idx: row.Msg,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user