作者 郑周

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

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