123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- package data
- import (
- "eta/eta_mobile/models/data_manage"
- "eta/eta_mobile/models/system"
- "eta/eta_mobile/utils"
- "fmt"
- )
- func GetManualSysUser(keyWord string) (list []*data_manage.ManualSysUser, err error) {
- //departmentId := 1
- list = make([]*data_manage.ManualSysUser, 0)
- departmentItems, err := system.GetSysDepartmentAll()
- if err != nil {
- return list, err
- }
- for _, dv := range departmentItems {
- department := new(data_manage.ManualSysUser)
- department.ItemId = dv.DepartmentId * 10000
- department.ItemName = dv.DepartmentName
- fmt.Println(department.ItemId, department.ItemName)
- //GetSysuserList
- var condition string
- var pars []interface{}
- if keyWord != "" {
- condition += ` AND (real_name LIKE ? OR admin_name LIKE ? OR mobile LIKE ? ) `
- pars = utils.GetLikeKeywordPars(pars, keyWord, 3)
- }
- sysUsers, err := system.GetSysUserItems(condition, pars)
- if err != nil {
- return list, err
- }
- groups, err := system.GetSysGroupByDepartmentId(dv.DepartmentId)
- if err != nil {
- return list, err
- }
- dg := make([]*data_manage.ManualSysUser, 0)
- for _, v := range groups {
- group := new(data_manage.ManualSysUser)
- group.ItemId = v.DepartmentId * 100000
- group.ItemName = v.GroupName
- for _, sv := range sysUsers {
- user := new(data_manage.ManualSysUser)
- user.ItemId = sv.AdminId
- user.ItemName = sv.RealName
- if sv.GroupId == v.GroupId {
- group.Children = append(group.Children, user)
- }
- }
- if len(group.Children) > 0 {
- dg = append(dg, group)
- }
- }
- if len(groups) <= 0 {
- group := new(data_manage.ManualSysUser)
- group.ItemId = dv.DepartmentId * 100000
- group.ItemName = "无分组"
- for _, sv := range sysUsers {
- user := new(data_manage.ManualSysUser)
- user.ItemId = sv.AdminId
- user.ItemName = sv.RealName
- if sv.DepartmentId == dv.DepartmentId && sv.GroupId == 0 {
- group.Children = append(group.Children, user)
- }
- }
- if len(group.Children) > 0 {
- dg = append(dg, group)
- }
- }
- if len(dg) > 0 {
- department.Children = dg
- list = append(list, department)
- }
- }
- return
- }
|