feat 导出查询去除最大记录数限制,查询分页检查
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"be.ems/src/framework/resp"
|
||||
"be.ems/src/framework/utils/date"
|
||||
"be.ems/src/framework/utils/file"
|
||||
"be.ems/src/framework/utils/parse"
|
||||
authService "be.ems/src/modules/auth/service"
|
||||
"be.ems/src/modules/system/model"
|
||||
"be.ems/src/modules/system/service"
|
||||
@@ -48,6 +49,13 @@ type SysLogLoginController struct {
|
||||
// @Router /system/log/login/list [get]
|
||||
func (s *SysLogLoginController) List(c *gin.Context) {
|
||||
query := reqctx.QueryMap(c)
|
||||
// 分页检查
|
||||
pageNum := parse.Number(query["pageNum"])
|
||||
pageSize := parse.Number(query["pageSize"])
|
||||
if pageNum == 0 || pageSize == 0 {
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: pageNum or pageSize not is empty"))
|
||||
return
|
||||
}
|
||||
dataScopeSQL := reqctx.LoginUserToDataScopeSQL(c, "sys_user", "sys_user")
|
||||
rows, total := s.sysLogLoginService.FindByPage(query, dataScopeSQL)
|
||||
|
||||
@@ -99,6 +107,13 @@ func (s SysLogLoginController) Export(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
// 查询结果,根据查询条件结果,单页最大值限制
|
||||
query := reqctx.QueryMap(c)
|
||||
// 分页检查
|
||||
pageNum := parse.Number(query["pageNum"])
|
||||
pageSize := parse.Number(query["pageSize"])
|
||||
if pageNum == 0 || pageSize == 0 {
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: pageNum or pageSize not is empty"))
|
||||
return
|
||||
}
|
||||
dataScopeSQL := reqctx.LoginUserToDataScopeSQL(c, "sys_user", "sys_user")
|
||||
rows, total := s.sysLogLoginService.FindByPage(query, dataScopeSQL)
|
||||
if total == 0 {
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"be.ems/src/framework/resp"
|
||||
"be.ems/src/framework/utils/date"
|
||||
"be.ems/src/framework/utils/file"
|
||||
"be.ems/src/framework/utils/parse"
|
||||
"be.ems/src/modules/system/model"
|
||||
"be.ems/src/modules/system/service"
|
||||
|
||||
@@ -50,6 +51,13 @@ func (s *SysLogOperateController) List(c *gin.Context) {
|
||||
if v, ok := query["title"]; ok && v != "" {
|
||||
query["title"] = i18n.TFindKeyPrefix(language, "log.operate.title", v)
|
||||
}
|
||||
// 分页检查
|
||||
pageNum := parse.Number(query["pageNum"])
|
||||
pageSize := parse.Number(query["pageSize"])
|
||||
if pageNum == 0 || pageSize == 0 {
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: pageNum or pageSize not is empty"))
|
||||
return
|
||||
}
|
||||
|
||||
dataScopeSQL := reqctx.LoginUserToDataScopeSQL(c, "sys_user", "sys_user")
|
||||
rows, total := s.sysLogOperateService.FindByPage(query, dataScopeSQL)
|
||||
@@ -81,6 +89,13 @@ func (s SysLogOperateController) Export(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
// 查询结果,根据查询条件结果,单页最大值限制
|
||||
query := reqctx.QueryMap(c)
|
||||
// 分页检查
|
||||
pageNum := parse.Number(query["pageNum"])
|
||||
pageSize := parse.Number(query["pageSize"])
|
||||
if pageNum == 0 || pageSize == 0 {
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: pageNum or pageSize not is empty"))
|
||||
return
|
||||
}
|
||||
dataScopeSQL := reqctx.LoginUserToDataScopeSQL(c, "sys_user", "sys_user")
|
||||
rows, total := s.sysLogOperateService.FindByPage(query, dataScopeSQL)
|
||||
if total == 0 {
|
||||
|
||||
@@ -29,20 +29,10 @@ func (r SysLogLogin) SelectByPage(query map[string]string, dataScopeSQL string)
|
||||
tx = tx.Where("status_flag = ?", v)
|
||||
}
|
||||
if v, ok := query["beginTime"]; ok && v != "" {
|
||||
if len(v) == 10 {
|
||||
v = fmt.Sprintf("%s000", v)
|
||||
tx = tx.Where("login_time >= ?", v)
|
||||
} else if len(v) == 13 {
|
||||
tx = tx.Where("login_time >= ?", v)
|
||||
}
|
||||
tx = tx.Where("login_time >= ?", v)
|
||||
}
|
||||
if v, ok := query["endTime"]; ok && v != "" {
|
||||
if len(v) == 10 {
|
||||
v = fmt.Sprintf("%s999", v)
|
||||
tx = tx.Where("login_time <= ?", v)
|
||||
} else if len(v) == 13 {
|
||||
tx = tx.Where("login_time <= ?", v)
|
||||
}
|
||||
tx = tx.Where("login_time <= ?", v)
|
||||
}
|
||||
if dataScopeSQL != "" {
|
||||
dataScopeSQL = fmt.Sprintf("select distinct user_name from sys_user where %s", dataScopeSQL)
|
||||
@@ -59,8 +49,11 @@ func (r SysLogLogin) SelectByPage(query map[string]string, dataScopeSQL string)
|
||||
}
|
||||
|
||||
// 查询数据分页
|
||||
pageNum, pageSize := db.PageNumSize(query["pageNum"], query["pageSize"])
|
||||
tx = tx.Limit(pageSize).Offset(pageSize * pageNum)
|
||||
if query["pageNum"] != "" && query["pageSize"] != "" {
|
||||
pageNum, pageSize := db.PageNumSize(query["pageNum"], query["pageSize"])
|
||||
tx = tx.Limit(pageSize).Offset(pageSize * pageNum)
|
||||
}
|
||||
|
||||
err := tx.Order("id desc").Find(&rows).Error
|
||||
if err != nil {
|
||||
logger.Errorf("query find err => %v", err.Error())
|
||||
|
||||
@@ -35,20 +35,10 @@ func (r SysLogOperate) SelectByPage(query map[string]string, dataScopeSQL string
|
||||
tx = tx.Where("status_flag = ?", v)
|
||||
}
|
||||
if v, ok := query["beginTime"]; ok && v != "" {
|
||||
if len(v) == 10 {
|
||||
v = fmt.Sprintf("%s000", v)
|
||||
tx = tx.Where("opera_time >= ?", v)
|
||||
} else if len(v) == 13 {
|
||||
tx = tx.Where("opera_time >= ?", v)
|
||||
}
|
||||
tx = tx.Where("opera_time <= ?", v)
|
||||
}
|
||||
if v, ok := query["endTime"]; ok && v != "" {
|
||||
if len(v) == 10 {
|
||||
v = fmt.Sprintf("%s999", v)
|
||||
tx = tx.Where("opera_time <= ?", v)
|
||||
} else if len(v) == 13 {
|
||||
tx = tx.Where("opera_time <= ?", v)
|
||||
}
|
||||
tx = tx.Where("opera_time <= ?", v)
|
||||
}
|
||||
if dataScopeSQL != "" {
|
||||
dataScopeSQL = fmt.Sprintf("select distinct user_name from sys_user where %s", dataScopeSQL)
|
||||
@@ -65,8 +55,11 @@ func (r SysLogOperate) SelectByPage(query map[string]string, dataScopeSQL string
|
||||
}
|
||||
|
||||
// 查询数据分页
|
||||
pageNum, pageSize := db.PageNumSize(query["pageNum"], query["pageSize"])
|
||||
tx = tx.Limit(pageSize).Offset(pageSize * pageNum)
|
||||
if query["pageNum"] != "" && query["pageSize"] != "" {
|
||||
pageNum, pageSize := db.PageNumSize(query["pageNum"], query["pageSize"])
|
||||
tx = tx.Limit(pageSize).Offset(pageSize * pageNum)
|
||||
}
|
||||
|
||||
err := tx.Order("id desc").Find(&rows).Error
|
||||
if err != nil {
|
||||
logger.Errorf("query find err => %v", err.Error())
|
||||
|
||||
Reference in New Issue
Block a user