|
@@ -3,9 +3,9 @@ package controllers
|
|
|
import (
|
|
import (
|
|
|
"encoding/json"
|
|
"encoding/json"
|
|
|
"fmt"
|
|
"fmt"
|
|
|
- "strings"
|
|
|
|
|
-
|
|
|
|
|
"github.com/nsqio/go-nsq"
|
|
"github.com/nsqio/go-nsq"
|
|
|
|
|
+ "github.com/tealeg/xlsx"
|
|
|
|
|
+ "strings"
|
|
|
|
|
|
|
|
"dashoo.cn/base_common/business/auth"
|
|
"dashoo.cn/base_common/business/auth"
|
|
|
"dashoo.cn/base_common/business/permission"
|
|
"dashoo.cn/base_common/business/permission"
|
|
@@ -751,3 +751,83 @@ func sendFaceLockCheckMsg(userId, action string) {
|
|
|
fmt.Println("发送NSQ消息失败:", err)
|
|
fmt.Println("发送NSQ消息失败:", err)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+// @Title 获取下载文件
|
|
|
|
|
+// @Description 获取下载文件
|
|
|
|
|
+// @Success 200 {object} ErrorInfo
|
|
|
|
|
+// @router /downfile [get]
|
|
|
|
|
+func (this *UserController) GetDownFile() {
|
|
|
|
|
+ keyword := this.GetString("keyword")
|
|
|
|
|
+ svc := permission.GetPermissionService(utils.DBE)
|
|
|
|
|
+ var users []userRole.Base_User
|
|
|
|
|
+
|
|
|
|
|
+ where := "IsVisible=1 and CreateUserId='" + utils.ToStr(this.User.Id) + "' "
|
|
|
|
|
+ if keyword != "" {
|
|
|
|
|
+ where = where + " and Realname like '%" + keyword + "%'"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //svc.GetEntities(&users, where)
|
|
|
|
|
+ svc.GetEntitiesByWhereOrder(&users, "ID desc", where)
|
|
|
|
|
+ xlsx.PagePrintheadContant = "用户列表"
|
|
|
|
|
+ f := xlsx.NewFile()
|
|
|
|
|
+ this.SaveXlsx(users, f)
|
|
|
|
|
+ SaveDirectory("static/file/excel/u/" + this.GetAccode())
|
|
|
|
|
+ f.Save("static/file/excel/u/" + this.GetAccode() + "/users.xlsx")
|
|
|
|
|
+
|
|
|
|
|
+ var errinfo ErrorInfo
|
|
|
|
|
+ errinfo.Message = this.Ctx.Request.Host + "/static/file/excel/u/" + this.GetAccode() + "/users.xlsx"
|
|
|
|
|
+ errinfo.Code = 0
|
|
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
|
|
+ this.ServeJSON()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (this *UserController) SaveXlsx(list []userRole.Base_User, f *xlsx.File) {
|
|
|
|
|
+ sheet, _ := f.AddSheet("users")
|
|
|
|
|
+ rowhead := sheet.AddRow()
|
|
|
|
|
+ cell := rowhead.AddCell()
|
|
|
|
|
+ cell.Value = "序号"
|
|
|
|
|
+ cell = rowhead.AddCell()
|
|
|
|
|
+ cell.Value = "账号"
|
|
|
|
|
+ cell = rowhead.AddCell()
|
|
|
|
|
+ cell.Value = "用户名"
|
|
|
|
|
+ cell = rowhead.AddCell()
|
|
|
|
|
+ cell.Value = "手机"
|
|
|
|
|
+ cell = rowhead.AddCell()
|
|
|
|
|
+ cell.Value = "角色"
|
|
|
|
|
+ cell = rowhead.AddCell()
|
|
|
|
|
+ cell.Value = "备注"
|
|
|
|
|
+ cell = rowhead.AddCell()
|
|
|
|
|
+ cell.Value = "所属组织"
|
|
|
|
|
+
|
|
|
|
|
+ for i, v := range list {
|
|
|
|
|
+ row := sheet.AddRow()
|
|
|
|
|
+ cell = row.AddCell()
|
|
|
|
|
+ cell.Value = utils.ToStr(i + 1)
|
|
|
|
|
+ cell = row.AddCell()
|
|
|
|
|
+ cell.Value = v.Username
|
|
|
|
|
+ cell = row.AddCell()
|
|
|
|
|
+ cell.Value = v.Realname
|
|
|
|
|
+ cell = row.AddCell()
|
|
|
|
|
+ cell.Value = v.Telephone
|
|
|
|
|
+ cell = row.AddCell()
|
|
|
|
|
+ switch v.Roleid {
|
|
|
|
|
+ case 10000123:
|
|
|
|
|
+ cell.Value = "普通用户"
|
|
|
|
|
+ case 10000119:
|
|
|
|
|
+ cell.Value = "管理用户"
|
|
|
|
|
+ default:
|
|
|
|
|
+ cell.Value = "其他"
|
|
|
|
|
+ }
|
|
|
|
|
+ cell = row.AddCell()
|
|
|
|
|
+ cell.Value = v.Description
|
|
|
|
|
+ cell = row.AddCell()
|
|
|
|
|
+ cell.Value = v.Departmentname
|
|
|
|
|
+ }
|
|
|
|
|
+ sheet.Cols[0].Width = 8 //设置时间单元格的宽度
|
|
|
|
|
+ sheet.Cols[1].Width = 20
|
|
|
|
|
+ sheet.Cols[2].Width = 20
|
|
|
|
|
+ sheet.Cols[3].Width = 20
|
|
|
|
|
+ sheet.Cols[4].Width = 16
|
|
|
|
|
+ sheet.Cols[5].Width = 25
|
|
|
|
|
+ sheet.Cols[6].Width = 25
|
|
|
|
|
+}
|