作者 郑周

1. 用户搜索 增加 状态过滤条件

... ... @@ -5,6 +5,7 @@ import (
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/user/query"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
type UserService struct{}
... ... @@ -26,6 +27,7 @@ func (service *UserService) ListUsers(listUserQuery *query.ListUserQuery) (inter
count, list, err := userRepo.Find(map[string]interface{}{
"companyId": listUserQuery.CompanyId,
"name": listUserQuery.Name,
"status": domain.UserStatusEnable,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -24,7 +24,7 @@ const (
UserTypeCommon int = 1
UserTypeManager int = 2
UserStatusEnable int = 1
UserStatusEnable int = 1 // 正常用户 2禁用用户
)
type UserRepository interface {
... ...
... ... @@ -119,6 +119,9 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d
if v, ok := queryOptions["account"]; ok {
query.Where("account like ?", v)
}
if v, ok := queryOptions["status"]; ok {
query.Where("status=?", v)
}
if v, ok := queryOptions["name"].(string); ok && len(v) > 0 {
query.Where("name like ?", fmt.Sprintf("%%%v%%", v))
}
... ...