作者 郑周

1. 通讯录增加搜索条件(用户名称或手机号码)

@@ -6,8 +6,9 @@ type ListUserQuery struct { @@ -6,8 +6,9 @@ type ListUserQuery struct {
6 } 6 }
7 7
8 type ListByDepartmentQuery struct { 8 type ListByDepartmentQuery struct {
9 - CompanyId int64 `cname:"公司ID" json:"companyId"`  
10 - DepartmentId int64 `cname:"部门ID" json:"departmentId"`  
11 - PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"`  
12 - PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"` 9 + Search string `cname:"用户名称或手机号码" json:"search"`
  10 + CompanyId int64 `cname:"公司ID" json:"companyId"`
  11 + DepartmentId int64 `cname:"部门ID" json:"departmentId"`
  12 + PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"`
  13 + PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"`
13 } 14 }
@@ -133,9 +133,14 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d @@ -133,9 +133,14 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d
133 if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { 133 if v, ok := queryOptions["name"].(string); ok && len(v) > 0 {
134 query.Where("name like ?", fmt.Sprintf("%%%v%%", v)) 134 query.Where("name like ?", fmt.Sprintf("%%%v%%", v))
135 } 135 }
  136 + // 模糊搜索条名称 + 账号
  137 + if v, ok := queryOptions["search"].(string); ok && len(v) > 0 {
  138 + query.Where("name like ? or account like ?", fmt.Sprintf("%%%v%%", v), fmt.Sprintf("%%%v%%", v))
  139 + }
136 if v, ok := queryOptions["names"]; ok { 140 if v, ok := queryOptions["names"]; ok {
137 query.Where("name in(?)", pg.In(v)) 141 query.Where("name in(?)", pg.In(v))
138 } 142 }
  143 +
139 if v, ok := queryOptions["offset"]; ok { 144 if v, ok := queryOptions["offset"]; ok {
140 if value, ok := v.(int); ok { 145 if value, ok := v.(int); ok {
141 query.Offset(value) 146 query.Offset(value)
@@ -13,7 +13,6 @@ func init() { @@ -13,7 +13,6 @@ func init() {
13 web.NSRouter("/search", &controllers.UserController{}, "Post:ListUsers"), 13 web.NSRouter("/search", &controllers.UserController{}, "Post:ListUsers"),
14 web.NSRouter("/list-dep", &controllers.UserController{}, "Post:ListByDepartment"), 14 web.NSRouter("/list-dep", &controllers.UserController{}, "Post:ListByDepartment"),
15 web.NSRouter("/edit-parent", &controllers.UserController{}, "Put:EditParentUser"), 15 web.NSRouter("/edit-parent", &controllers.UserController{}, "Put:EditParentUser"),
16 - web.NSRouter("/edit-parent", &controllers.UserController{}, "Put:EditParentUser"),  
17 web.NSRouter("/import-parent", &controllers.UserController{}, "Post:ImportParentUser"), // 直接上级导入 16 web.NSRouter("/import-parent", &controllers.UserController{}, "Post:ImportParentUser"), // 直接上级导入
18 ) 17 )
19 web.AddNamespace(ns) 18 web.AddNamespace(ns)