fix: 根据查询条件导出Excel

This commit is contained in:
TsMask
2024-08-31 14:31:21 +08:00
parent 318fe9772f
commit bf0dc1a1e9
8 changed files with 59 additions and 55 deletions

View File

@@ -228,7 +228,7 @@ func (s *SysConfigController) Export(c *gin.Context) {
// 查询结果,根据查询条件结果,单页最大值限制 // 查询结果,根据查询条件结果,单页最大值限制
querys := ctx.BodyJSONMap(c) querys := ctx.BodyJSONMap(c)
querys["pageNum"] = 1 querys["pageNum"] = 1
querys["pageSize"] = 1000 querys["pageSize"] = 10000
data := s.sysConfigService.SelectConfigPage(querys) data := s.sysConfigService.SelectConfigPage(querys)
if parse.Number(data["total"]) == 0 { if parse.Number(data["total"]) == 0 {
// 导出数据记录为空 // 导出数据记录为空

View File

@@ -241,16 +241,18 @@ func (s *SysDictDataController) DictType(c *gin.Context) {
func (s *SysDictDataController) Export(c *gin.Context) { func (s *SysDictDataController) Export(c *gin.Context) {
language := ctx.AcceptLanguage(c) language := ctx.AcceptLanguage(c)
// 查询结果,根据查询条件结果,单页最大值限制 // 查询结果,根据查询条件结果,单页最大值限制
// querys := ctx.BodyJSONMap(c) querys := ctx.BodyJSONMap(c)
// data := s.sysDictDataService.SelectDictDataPage(querys) querys["pageNum"] = 1
// if data["total"].(int64) == 0 { querys["pageSize"] = 10000
// // 导出数据记录为空 data := s.sysDictDataService.SelectDictDataPage(querys)
// c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty"))) if parse.Number(data["total"]) == 0 {
// return // 导出数据记录为空
// } c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
// rows := data["rows"].([]model.SysDictData) return
}
rows := data["rows"].([]model.SysDictData)
rows := s.sysDictDataService.SelectDictDataList(model.SysDictData{}) // rows := s.sysDictDataService.SelectDictDataList(model.SysDictData{})
if len(rows) <= 0 { if len(rows) <= 0 {
// 导出数据记录为空 // 导出数据记录为空
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty"))) c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))

View File

@@ -244,16 +244,18 @@ func (s *SysDictTypeController) DictOptionselect(c *gin.Context) {
func (s *SysDictTypeController) Export(c *gin.Context) { func (s *SysDictTypeController) Export(c *gin.Context) {
language := ctx.AcceptLanguage(c) language := ctx.AcceptLanguage(c)
// 查询结果,根据查询条件结果,单页最大值限制 // 查询结果,根据查询条件结果,单页最大值限制
// querys := ctx.BodyJSONMap(c) querys := ctx.BodyJSONMap(c)
// data := s.sysDictTypeService.SelectDictTypePage(querys) querys["pageNum"] = 1
// if data["total"].(int64) == 0 { querys["pageSize"] = 10000
// // 导出数据记录为空 data := s.sysDictTypeService.SelectDictTypePage(querys)
// c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty"))) if parse.Number(data["total"]) == 0 {
// return // 导出数据记录为空
// } c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
// rows := data["rows"].([]model.SysDictType) return
}
rows := data["rows"].([]model.SysDictType)
rows := s.sysDictTypeService.SelectDictTypeList(model.SysDictType{}) // rows := s.sysDictTypeService.SelectDictTypeList(model.SysDictType{})
if len(rows) <= 0 { if len(rows) <= 0 {
// 导出数据记录为空 // 导出数据记录为空
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty"))) c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))

View File

@@ -122,16 +122,19 @@ func (s *SysLogLoginController) Unlock(c *gin.Context) {
func (s *SysLogLoginController) Export(c *gin.Context) { func (s *SysLogLoginController) Export(c *gin.Context) {
language := ctx.AcceptLanguage(c) language := ctx.AcceptLanguage(c)
// 查询结果,根据查询条件结果,单页最大值限制 // 查询结果,根据查询条件结果,单页最大值限制
// querys := ctx.BodyJSONMap(c) querys := ctx.BodyJSONMap(c)
// data := s.sysLogLoginService.SelectSysLogLoginPage(querys) querys["pageNum"] = 1
// if data["total"].(int64) == 0 { querys["pageSize"] = 10000
// // 导出数据记录为空 dataScopeSQL := ctx.LoginUserToDataScopeSQL(c, "d", "u")
// c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty"))) data := s.sysLogLoginService.SelectSysLogLoginPage(querys, dataScopeSQL)
// return if parse.Number(data["total"]) == 0 {
// } // 导出数据记录为空
// rows := data["rows"].([]model.SysLogLogin) c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
return
}
rows := data["rows"].([]model.SysLogLogin)
rows := s.sysLogLoginService.SelectSysLogLoginList(model.SysLogLogin{}) // rows := s.sysLogLoginService.SelectSysLogLoginList(model.SysLogLogin{})
if len(rows) <= 0 { if len(rows) <= 0 {
// 导出数据记录为空 // 导出数据记录为空
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty"))) c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))

View File

@@ -103,16 +103,19 @@ func (s *SysLogOperateController) Clean(c *gin.Context) {
func (s *SysLogOperateController) Export(c *gin.Context) { func (s *SysLogOperateController) Export(c *gin.Context) {
language := ctx.AcceptLanguage(c) language := ctx.AcceptLanguage(c)
// 查询结果,根据查询条件结果,单页最大值限制 // 查询结果,根据查询条件结果,单页最大值限制
// querys := ctx.BodyJSONMap(c) querys := ctx.BodyJSONMap(c)
// data := s.SysLogOperateService.SelectSysLogOperatePage(querys) querys["pageNum"] = 1
// if data["total"].(int64) == 0 { querys["pageSize"] = 10000
// // 导出数据记录为空 dataScopeSQL := ctx.LoginUserToDataScopeSQL(c, "d", "u")
// c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty"))) data := s.SysLogOperateService.SelectSysLogOperatePage(querys, dataScopeSQL)
// return if parse.Number(data["total"]) == 0 {
// } // 导出数据记录为空
// rows := data["rows"].([]model.SysLogOperate) c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
return
}
rows := data["rows"].([]model.SysLogOperate)
rows := s.SysLogOperateService.SelectSysLogOperateList(model.SysLogOperate{}) // rows := s.SysLogOperateService.SelectSysLogOperateList(model.SysLogOperate{})
if len(rows) <= 0 { if len(rows) <= 0 {
// 导出数据记录为空 // 导出数据记录为空
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty"))) c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))

View File

@@ -210,13 +210,11 @@ func (s *SysPostController) Remove(c *gin.Context) {
func (s *SysPostController) Export(c *gin.Context) { func (s *SysPostController) Export(c *gin.Context) {
language := ctx.AcceptLanguage(c) language := ctx.AcceptLanguage(c)
// 查询结果,根据查询条件结果,单页最大值限制 // 查询结果,根据查询条件结果,单页最大值限制
// querys := ctx.BodyJSONMap(c) querys := ctx.BodyJSONMap(c)
querys := map[string]any{ querys["pageNum"] = 1
"pageNum": 1, querys["pageSize"] = 10000
"pageSize": 1000,
}
data := s.sysPostService.SelectPostPage(querys) data := s.sysPostService.SelectPostPage(querys)
if data["total"].(int64) == 0 { if parse.Number(data["total"]) == 0 {
// 导出数据记录为空 // 导出数据记录为空
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty"))) c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
return return

View File

@@ -413,14 +413,12 @@ func (s *SysRoleController) AuthUserChecked(c *gin.Context) {
func (s *SysRoleController) Export(c *gin.Context) { func (s *SysRoleController) Export(c *gin.Context) {
language := ctx.AcceptLanguage(c) language := ctx.AcceptLanguage(c)
// 查询结果,根据查询条件结果,单页最大值限制 // 查询结果,根据查询条件结果,单页最大值限制
// querys := ctx.BodyJSONMap(c) querys := ctx.BodyJSONMap(c)
querys := map[string]any{ querys["pageNum"] = 1
"pageNum": 1, querys["pageSize"] = 10000
"pageSize": 1000,
}
dataScopeSQL := ctx.LoginUserToDataScopeSQL(c, "d", "") dataScopeSQL := ctx.LoginUserToDataScopeSQL(c, "d", "")
data := s.sysRoleService.SelectRolePage(querys, dataScopeSQL) data := s.sysRoleService.SelectRolePage(querys, dataScopeSQL)
if data["total"].(int64) == 0 { if parse.Number(data["total"]) == 0 {
// 导出数据记录为空 // 导出数据记录为空
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty"))) c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
return return

View File

@@ -473,14 +473,12 @@ func (s *SysUserController) Status(c *gin.Context) {
func (s *SysUserController) Export(c *gin.Context) { func (s *SysUserController) Export(c *gin.Context) {
language := ctx.AcceptLanguage(c) language := ctx.AcceptLanguage(c)
// 查询结果,根据查询条件结果,单页最大值限制 // 查询结果,根据查询条件结果,单页最大值限制
// querys := ctx.BodyJSONMap(c) querys := ctx.BodyJSONMap(c)
querys := map[string]any{ querys["pageNum"] = 1
"pageNum": 1, querys["pageSize"] = 10000
"pageSize": 1000,
}
dataScopeSQL := ctx.LoginUserToDataScopeSQL(c, "d", "u") dataScopeSQL := ctx.LoginUserToDataScopeSQL(c, "d", "u")
data := s.sysUserService.SelectUserPage(querys, dataScopeSQL) data := s.sysUserService.SelectUserPage(querys, dataScopeSQL)
if data["total"].(int64) == 0 { if parse.Number(data["total"]) == 0 {
// 导出数据记录为空 // 导出数据记录为空
c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty"))) c.JSON(200, result.ErrMsg(i18n.TKey(language, "app.common.exportEmpty")))
return return