正在显示
6 个修改的文件
包含
86 行增加
和
0 行删除
@@ -142,6 +142,8 @@ func (srv SyncDataDepartmentService) editDepartment(param *command.EditDepartmen | @@ -142,6 +142,8 @@ func (srv SyncDataDepartmentService) editDepartment(param *command.EditDepartmen | ||
142 | } | 142 | } |
143 | if len(param.ChargeUserIds) > 0 { | 143 | if len(param.ChargeUserIds) > 0 { |
144 | departmentList[i].ChargeUserIds = param.ChargeUserIds | 144 | departmentList[i].ChargeUserIds = param.ChargeUserIds |
145 | + } else { | ||
146 | + departmentList[i].ChargeUserIds = make([]int64, 0) | ||
145 | } | 147 | } |
146 | continue | 148 | continue |
147 | } | 149 | } |
pkg/application/user/user.go
0 → 100644
1 | +package user | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | + "github.com/linmadan/egglib-go/utils/tool_funs" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/user/query" | ||
8 | +) | ||
9 | + | ||
10 | +type UserService struct{} | ||
11 | + | ||
12 | +func (service *UserService) ListUsers(listUserQuery *query.ListUserQuery) (interface{}, error) { | ||
13 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
14 | + if err != nil { | ||
15 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
16 | + } | ||
17 | + if err := transactionContext.StartTransaction(); err != nil { | ||
18 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
19 | + } | ||
20 | + defer func() { | ||
21 | + _ = transactionContext.RollbackTransaction() | ||
22 | + }() | ||
23 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
24 | + "transactionContext": transactionContext, | ||
25 | + }) | ||
26 | + count, list, err := userRepo.Find(map[string]interface{}{ | ||
27 | + "companyId": listUserQuery.CompanyId, | ||
28 | + "name": listUserQuery.Name, | ||
29 | + }) | ||
30 | + if err != nil { | ||
31 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
32 | + } | ||
33 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
34 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
35 | + } | ||
36 | + return tool_funs.SimpleWrapGridMap(int64(count), list), nil | ||
37 | +} |
@@ -114,6 +114,9 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d | @@ -114,6 +114,9 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d | ||
114 | if v, ok := queryOptions["account"]; ok { | 114 | if v, ok := queryOptions["account"]; ok { |
115 | query.Where("account like ?", v) | 115 | query.Where("account like ?", v) |
116 | } | 116 | } |
117 | + if v, ok := queryOptions["name"]; ok && v.(string) != "" { | ||
118 | + query.Where("name like ?", "%"+v.(string)+"%") | ||
119 | + } | ||
117 | if v, ok := queryOptions["offset"]; ok { | 120 | if v, ok := queryOptions["offset"]; ok { |
118 | query.Offset(v.(int)) | 121 | query.Offset(v.(int)) |
119 | } | 122 | } |
1 | +package controllers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/web/beego" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/user" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/user/query" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
8 | +) | ||
9 | + | ||
10 | +type UserController struct { | ||
11 | + beego.BaseController | ||
12 | +} | ||
13 | + | ||
14 | +// ListUsers 搜索用户 | ||
15 | +func (controller *UserController) ListUsers() { | ||
16 | + listUserQuery := &query.ListUserQuery{} | ||
17 | + _ = controller.Unmarshal(listUserQuery) | ||
18 | + userAuth := controller.Ctx.Input.GetData(domain.UserAuth{}).(*domain.UserAuth) | ||
19 | + listUserQuery.CompanyId = userAuth.CompanyId | ||
20 | + resp, err := (&user.UserService{}).ListUsers(listUserQuery) | ||
21 | + controller.Response(resp, err) | ||
22 | +} |
pkg/port/beego/routers/user_router.go
0 → 100644
1 | +package routers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/beego/beego/v2/server/web" | ||
5 | + "github.com/linmadan/egglib-go/web/beego/filters" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" | ||
8 | +) | ||
9 | + | ||
10 | +func init() { | ||
11 | + ns := web.NewNamespace("/v1/user", | ||
12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), | ||
13 | + web.NSRouter("/search", &controllers.UserController{}, "Post:ListUsers"), | ||
14 | + ) | ||
15 | + web.AddNamespace(ns) | ||
16 | +} |
-
请 注册 或 登录 后发表评论