正在显示
24 个修改的文件
包含
226 行增加
和
314 行删除
1 | -package query | ||
2 | - | ||
3 | -import ( | ||
4 | - "fmt" | ||
5 | - | ||
6 | - "github.com/beego/beego/v2/core/validation" | ||
7 | -) | ||
8 | - | ||
9 | -type GetQrcodeForLoginQuery struct { | ||
10 | -} | ||
11 | - | ||
12 | -func (getQrcodeForLoginQuery *GetQrcodeForLoginQuery) Valid(validation *validation.Validation) { | ||
13 | - validation.SetError("CustomValid", "未实现的自定义认证") | ||
14 | -} | ||
15 | - | ||
16 | -func (getQrcodeForLoginQuery *GetQrcodeForLoginQuery) ValidateQuery() error { | ||
17 | - valid := validation.Validation{} | ||
18 | - b, err := valid.Valid(getQrcodeForLoginQuery) | ||
19 | - if err != nil { | ||
20 | - return err | ||
21 | - } | ||
22 | - if !b { | ||
23 | - for _, validErr := range valid.Errors { | ||
24 | - return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
25 | - } | ||
26 | - } | ||
27 | - return nil | ||
28 | -} |
1 | -package query | ||
2 | - | ||
3 | -import ( | ||
4 | - "fmt" | ||
5 | - | ||
6 | - "github.com/beego/beego/v2/core/validation" | ||
7 | -) | ||
8 | - | ||
9 | -type LoginByAccountQuery struct { | ||
10 | - // 账号 | ||
11 | - Account string `json:"account,omitempty"` | ||
12 | - // 密码 | ||
13 | - Passwd string `json:"passwd,omitempty"` | ||
14 | -} | ||
15 | - | ||
16 | -func (loginByAccountQuery *LoginByAccountQuery) Valid(validation *validation.Validation) { | ||
17 | - validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | -} | ||
19 | - | ||
20 | -func (loginByAccountQuery *LoginByAccountQuery) ValidateQuery() error { | ||
21 | - valid := validation.Validation{} | ||
22 | - b, err := valid.Valid(loginByAccountQuery) | ||
23 | - if err != nil { | ||
24 | - return err | ||
25 | - } | ||
26 | - if !b { | ||
27 | - for _, validErr := range valid.Errors { | ||
28 | - return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
29 | - } | ||
30 | - } | ||
31 | - return nil | ||
32 | -} |
1 | -package query | ||
2 | - | ||
3 | -import ( | ||
4 | - "fmt" | ||
5 | - | ||
6 | - "github.com/beego/beego/v2/core/validation" | ||
7 | -) | ||
8 | - | ||
9 | -type LoginByScanQrcodeQuery struct { | ||
10 | - // 登录认证的凭证 | ||
11 | - AuthCode string `json:"authCode,omitempty"` | ||
12 | -} | ||
13 | - | ||
14 | -func (loginByScanQrcodeQuery *LoginByScanQrcodeQuery) Valid(validation *validation.Validation) { | ||
15 | - validation.SetError("CustomValid", "未实现的自定义认证") | ||
16 | -} | ||
17 | - | ||
18 | -func (loginByScanQrcodeQuery *LoginByScanQrcodeQuery) ValidateQuery() error { | ||
19 | - valid := validation.Validation{} | ||
20 | - b, err := valid.Valid(loginByScanQrcodeQuery) | ||
21 | - if err != nil { | ||
22 | - return err | ||
23 | - } | ||
24 | - if !b { | ||
25 | - for _, validErr := range valid.Errors { | ||
26 | - return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
27 | - } | ||
28 | - } | ||
29 | - return nil | ||
30 | -} |
1 | -package query | ||
2 | - | ||
3 | -import ( | ||
4 | - "fmt" | ||
5 | - | ||
6 | - "github.com/beego/beego/v2/core/validation" | ||
7 | -) | ||
8 | - | ||
9 | -type LoginBySmsCodeQuery struct { | ||
10 | - // 手机号 | ||
11 | - Phone string `json:"phone,omitempty"` | ||
12 | - // 短信验证码 | ||
13 | - SmsCode string `json:"smsCode,omitempty"` | ||
14 | -} | ||
15 | - | ||
16 | -func (loginBySmsCodeQuery *LoginBySmsCodeQuery) Valid(validation *validation.Validation) { | ||
17 | - validation.SetError("CustomValid", "未实现的自定义认证") | ||
18 | -} | ||
19 | - | ||
20 | -func (loginBySmsCodeQuery *LoginBySmsCodeQuery) ValidateQuery() error { | ||
21 | - valid := validation.Validation{} | ||
22 | - b, err := valid.Valid(loginBySmsCodeQuery) | ||
23 | - if err != nil { | ||
24 | - return err | ||
25 | - } | ||
26 | - if !b { | ||
27 | - for _, validErr := range valid.Errors { | ||
28 | - return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
29 | - } | ||
30 | - } | ||
31 | - return nil | ||
32 | -} |
1 | -package query | ||
2 | - | ||
3 | -import ( | ||
4 | - "fmt" | ||
5 | - | ||
6 | - "github.com/beego/beego/v2/core/validation" | ||
7 | -) | ||
8 | - | ||
9 | -type LoginInfoByAuthCodeQuery struct { | ||
10 | - // 登录认证的凭证 | ||
11 | - AuthCode string `json:"authCode,omitempty"` | ||
12 | - // 公司id | ||
13 | - CompanyId string `json:"companyId,omitempty"` | ||
14 | - // 组织id | ||
15 | - OrganizationId string `json:"organizationId,omitempty"` | ||
16 | -} | ||
17 | - | ||
18 | -func (loginInfoByAuthCodeQuery *LoginInfoByAuthCodeQuery) Valid(validation *validation.Validation) { | ||
19 | - validation.SetError("CustomValid", "未实现的自定义认证") | ||
20 | -} | ||
21 | - | ||
22 | -func (loginInfoByAuthCodeQuery *LoginInfoByAuthCodeQuery) ValidateQuery() error { | ||
23 | - valid := validation.Validation{} | ||
24 | - b, err := valid.Valid(loginInfoByAuthCodeQuery) | ||
25 | - if err != nil { | ||
26 | - return err | ||
27 | - } | ||
28 | - if !b { | ||
29 | - for _, validErr := range valid.Errors { | ||
30 | - return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
31 | - } | ||
32 | - } | ||
33 | - return nil | ||
34 | -} |
1 | -package service | ||
2 | - | ||
3 | -import ( | ||
4 | - "github.com/linmadan/egglib-go/core/application" | ||
5 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/factory" | ||
6 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/loginAccess/query" | ||
7 | -) | ||
8 | - | ||
9 | -// 登录访问 | ||
10 | -type LoginAccessService struct { | ||
11 | -} | ||
12 | - | ||
13 | -// 获取扫码登录用的二维码信息 | ||
14 | -func (loginAccessService *LoginAccessService) GetQrcodeForLogin(getQrcodeForLoginQuery *query.GetQrcodeForLoginQuery) (interface{}, error) { | ||
15 | - if err := getQrcodeForLoginQuery.ValidateQuery(); err != nil { | ||
16 | - return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
17 | - } | ||
18 | - transactionContext, err := factory.CreateTransactionContext(nil) | ||
19 | - if err != nil { | ||
20 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
21 | - } | ||
22 | - if err := transactionContext.StartTransaction(); err != nil { | ||
23 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
24 | - } | ||
25 | - defer func() { | ||
26 | - transactionContext.RollbackTransaction() | ||
27 | - }() | ||
28 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
29 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
30 | - } | ||
31 | - return nil, nil | ||
32 | -} | ||
33 | - | ||
34 | -// 使用手机号和密码登录系统 | ||
35 | -func (loginAccessService *LoginAccessService) LoginByAccount(loginByAccountQuery *query.LoginByAccountQuery) (interface{}, error) { | ||
36 | - if err := loginByAccountQuery.ValidateQuery(); err != nil { | ||
37 | - return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
38 | - } | ||
39 | - transactionContext, err := factory.CreateTransactionContext(nil) | ||
40 | - if err != nil { | ||
41 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
42 | - } | ||
43 | - if err := transactionContext.StartTransaction(); err != nil { | ||
44 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
45 | - } | ||
46 | - defer func() { | ||
47 | - transactionContext.RollbackTransaction() | ||
48 | - }() | ||
49 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
50 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
51 | - } | ||
52 | - return nil, nil | ||
53 | -} | ||
54 | - | ||
55 | -// 询问扫二维码方式登录的状态 | ||
56 | -func (loginAccessService *LoginAccessService) LoginByScanQrcode(loginByScanQrcodeQuery *query.LoginByScanQrcodeQuery) (interface{}, error) { | ||
57 | - if err := loginByScanQrcodeQuery.ValidateQuery(); err != nil { | ||
58 | - return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
59 | - } | ||
60 | - transactionContext, err := factory.CreateTransactionContext(nil) | ||
61 | - if err != nil { | ||
62 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
63 | - } | ||
64 | - if err := transactionContext.StartTransaction(); err != nil { | ||
65 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
66 | - } | ||
67 | - defer func() { | ||
68 | - transactionContext.RollbackTransaction() | ||
69 | - }() | ||
70 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
71 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
72 | - } | ||
73 | - return nil, nil | ||
74 | -} | ||
75 | - | ||
76 | -// 使用手机号和短信验证码登录系统 | ||
77 | -func (loginAccessService *LoginAccessService) LoginBySmsCode(loginBySmsCodeQuery *query.LoginBySmsCodeQuery) (interface{}, error) { | ||
78 | - if err := loginBySmsCodeQuery.ValidateQuery(); err != nil { | ||
79 | - return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
80 | - } | ||
81 | - transactionContext, err := factory.CreateTransactionContext(nil) | ||
82 | - if err != nil { | ||
83 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
84 | - } | ||
85 | - if err := transactionContext.StartTransaction(); err != nil { | ||
86 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
87 | - } | ||
88 | - defer func() { | ||
89 | - transactionContext.RollbackTransaction() | ||
90 | - }() | ||
91 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
92 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
93 | - } | ||
94 | - return nil, nil | ||
95 | -} | ||
96 | - | ||
97 | -// 获取具体的进入系统的凭证 | ||
98 | -func (loginAccessService *LoginAccessService) LoginInfoByAuthCode(loginInfoByAuthCodeQuery *query.LoginInfoByAuthCodeQuery) (interface{}, error) { | ||
99 | - if err := loginInfoByAuthCodeQuery.ValidateQuery(); err != nil { | ||
100 | - return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
101 | - } | ||
102 | - transactionContext, err := factory.CreateTransactionContext(nil) | ||
103 | - if err != nil { | ||
104 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
105 | - } | ||
106 | - if err := transactionContext.StartTransaction(); err != nil { | ||
107 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
108 | - } | ||
109 | - defer func() { | ||
110 | - transactionContext.RollbackTransaction() | ||
111 | - }() | ||
112 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
113 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
114 | - } | ||
115 | - return nil, nil | ||
116 | -} | ||
117 | - | ||
118 | -func NewLoginAccessService(options map[string]interface{}) *LoginAccessService { | ||
119 | - newLoginAccessService := &LoginAccessService{} | ||
120 | - return newLoginAccessService | ||
121 | -} |
@@ -4,18 +4,21 @@ import ( | @@ -4,18 +4,21 @@ import ( | ||
4 | "fmt" | 4 | "fmt" |
5 | 5 | ||
6 | "github.com/beego/beego/v2/core/validation" | 6 | "github.com/beego/beego/v2/core/validation" |
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
7 | ) | 8 | ) |
8 | 9 | ||
9 | type CompanyUserUpdateCommand struct { | 10 | type CompanyUserUpdateCommand struct { |
10 | - UsersId int64 `json:"usersId" valid:"Required"` | 11 | + //操作人 |
12 | + Operator domain.Operator `json:"-"` | ||
13 | + UsersId string `json:"usersId" valid:"Required"` | ||
11 | // 用户编号 | 14 | // 用户编号 |
12 | UsersCode string `json:"usersCode,omitempty"` | 15 | UsersCode string `json:"usersCode,omitempty"` |
13 | // 用户名称 | 16 | // 用户名称 |
14 | UsersName string `json:"usersName,omitempty"` | 17 | UsersName string `json:"usersName,omitempty"` |
15 | // 组织机构id | 18 | // 组织机构id |
16 | - OrganizationId int64 `json:"organizationId,omitempty"` | 19 | + OrganizationId string `json:"organizationId,omitempty"` |
17 | // 部门id | 20 | // 部门id |
18 | - DepartmentId int64 `json:"departmentId,omitempty"` | 21 | + DepartmentId string `json:"departmentId,omitempty"` |
19 | // 启用状态(启用:1 禁用:2) | 22 | // 启用状态(启用:1 禁用:2) |
20 | EnableStatus int `json:"enableStatus,omitempty"` | 23 | EnableStatus int `json:"enableStatus,omitempty"` |
21 | // 手机号 | 24 | // 手机号 |
@@ -23,9 +26,9 @@ type CompanyUserUpdateCommand struct { | @@ -23,9 +26,9 @@ type CompanyUserUpdateCommand struct { | ||
23 | // 邮箱 | 26 | // 邮箱 |
24 | Email string `json:"email,omitempty"` | 27 | Email string `json:"email,omitempty"` |
25 | // 关联的组织机构 | 28 | // 关联的组织机构 |
26 | - UsersOrg []int64 `json:"usersOrg,omitempty"` | 29 | + UsersOrg []string `json:"usersOrg,omitempty"` |
27 | // 关联的组织结构 | 30 | // 关联的组织结构 |
28 | - UsersRole []int64 `json:"usersRole,omitempty"` | 31 | + UsersRole []string `json:"usersRole,omitempty"` |
29 | // 头像 | 32 | // 头像 |
30 | Avator string `json:"avator,omitempty"` | 33 | Avator string `json:"avator,omitempty"` |
31 | } | 34 | } |
@@ -5,9 +5,9 @@ import ( | @@ -5,9 +5,9 @@ import ( | ||
5 | "time" | 5 | "time" |
6 | 6 | ||
7 | "github.com/linmadan/egglib-go/core/application" | 7 | "github.com/linmadan/egglib-go/core/application" |
8 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/command" | ||
9 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/dto" | ||
10 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/query" | 8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/users/command" |
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/users/dto" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/users/query" | ||
11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" |
12 | 12 | ||
13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" | 13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" |
@@ -29,15 +29,20 @@ func (usersService *UsersService) CompanyUserGet(companyUserGetQuery *query.Comp | @@ -29,15 +29,20 @@ func (usersService *UsersService) CompanyUserGet(companyUserGetQuery *query.Comp | ||
29 | if err != nil { | 29 | if err != nil { |
30 | return nil, err | 30 | return nil, err |
31 | } | 31 | } |
32 | - //TODO 数据拼接 | ||
33 | - userInfo := domain.Users{ | ||
34 | - UserId: "", | 32 | + user := domain.Users{ |
33 | + UserId: strconv.FormatInt(result.UserId, 10), | ||
35 | UserInfo: result.GetUserBase(), | 34 | UserInfo: result.GetUserBase(), |
36 | Org: result.GetOrg(), | 35 | Org: result.GetOrg(), |
37 | Department: result.GetDepartment(), | 36 | Department: result.GetDepartment(), |
38 | Company: nil, | 37 | Company: nil, |
38 | + UserOrg: result.GetUserOrg(), | ||
39 | + UserRole: result.GetUserRole(), | ||
40 | + } | ||
41 | + datas := map[string]interface{}{ | ||
42 | + "user": user, | ||
43 | + "userMenu": "", | ||
39 | } | 44 | } |
40 | - return userInfo, err | 45 | + return datas, err |
41 | } | 46 | } |
42 | 47 | ||
43 | // 创建公司用户信息 | 48 | // 创建公司用户信息 |
@@ -148,8 +153,42 @@ func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPassw | @@ -148,8 +153,42 @@ func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPassw | ||
148 | 153 | ||
149 | // 更新公司用户信息 | 154 | // 更新公司用户信息 |
150 | func (usersService *UsersService) CompanyUserUpdate(companyUserUpdateCommand *command.CompanyUserUpdateCommand) (interface{}, error) { | 155 | func (usersService *UsersService) CompanyUserUpdate(companyUserUpdateCommand *command.CompanyUserUpdateCommand) (interface{}, error) { |
151 | - | ||
152 | - return nil, nil | 156 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( |
157 | + companyUserUpdateCommand.Operator.CompanyId, | ||
158 | + companyUserUpdateCommand.Operator.OrgId, | ||
159 | + companyUserUpdateCommand.Operator.UserId) | ||
160 | + departmentId, _ := strconv.Atoi(companyUserUpdateCommand.OrganizationId) | ||
161 | + orgId, _ := strconv.Atoi(companyUserUpdateCommand.OrganizationId) | ||
162 | + userOrg := []int64{} | ||
163 | + userRole := []int64{} | ||
164 | + for _, v := range companyUserUpdateCommand.UsersOrg { | ||
165 | + id, err := strconv.Atoi(v) | ||
166 | + if err == nil { | ||
167 | + userOrg = append(userOrg, int64(id)) | ||
168 | + } | ||
169 | + } | ||
170 | + for _, v := range companyUserUpdateCommand.UsersRole { | ||
171 | + id, err := strconv.Atoi(v) | ||
172 | + if err == nil { | ||
173 | + userRole = append(userRole, int64(id)) | ||
174 | + } | ||
175 | + } | ||
176 | + userId, _ := strconv.Atoi(companyUserUpdateCommand.UsersId) | ||
177 | + result, err := creationUserGateway.UserUpdate(allied_creation_user.ReqUpdateUser{ | ||
178 | + UserId: int64(userId), | ||
179 | + CompanyId: companyUserUpdateCommand.Operator.CompanyId, | ||
180 | + UserCode: companyUserUpdateCommand.UsersCode, | ||
181 | + OrganizationId: int64(orgId), | ||
182 | + DepartmentId: int64(departmentId), | ||
183 | + UserOrg: userOrg, | ||
184 | + UserRole: userRole, | ||
185 | + EnableStatus: companyUserUpdateCommand.EnableStatus, | ||
186 | + UserName: companyUserUpdateCommand.UsersName, | ||
187 | + Phone: companyUserUpdateCommand.Phone, | ||
188 | + Avatar: companyUserUpdateCommand.Avator, | ||
189 | + Email: companyUserUpdateCommand.Avator, | ||
190 | + }) | ||
191 | + return result, err | ||
153 | } | 192 | } |
154 | 193 | ||
155 | // 创建共创用户信息 | 194 | // 创建共创用户信息 |
@@ -45,14 +45,14 @@ type UserDetail struct { | @@ -45,14 +45,14 @@ type UserDetail struct { | ||
45 | DepartmentName string `json:"departmentName"` | 45 | DepartmentName string `json:"departmentName"` |
46 | } `json:"department,omitempty"` | 46 | } `json:"department,omitempty"` |
47 | UserRole []struct { | 47 | UserRole []struct { |
48 | - RoleID int `json:"roleId"` | 48 | + RoleID int64 `json:"roleId"` |
49 | RoleName string `json:"roleName"` | 49 | RoleName string `json:"roleName"` |
50 | Ext struct { | 50 | Ext struct { |
51 | OrgName string `json:"orgName"` | 51 | OrgName string `json:"orgName"` |
52 | } `json:"ext,omitempty"` | 52 | } `json:"ext,omitempty"` |
53 | } `json:"userRole"` | 53 | } `json:"userRole"` |
54 | UserOrg []struct { | 54 | UserOrg []struct { |
55 | - OrgID int `json:"orgId"` | 55 | + OrgID int64 `json:"orgId"` |
56 | CreatedAt time.Time `json:"createdAt"` | 56 | CreatedAt time.Time `json:"createdAt"` |
57 | UpdatedAt time.Time `json:"updatedAt"` | 57 | UpdatedAt time.Time `json:"updatedAt"` |
58 | DeletedAt time.Time `json:"deletedAt"` | 58 | DeletedAt time.Time `json:"deletedAt"` |
@@ -65,21 +65,13 @@ func (info *UserDetail) GetUserBase() *domain.UsersBase { | @@ -65,21 +65,13 @@ func (info *UserDetail) GetUserBase() *domain.UsersBase { | ||
65 | UserId: strconv.Itoa(int(info.UserId)), | 65 | UserId: strconv.Itoa(int(info.UserId)), |
66 | UserBaseId: strconv.Itoa(int(info.UserBaseId)), | 66 | UserBaseId: strconv.Itoa(int(info.UserBaseId)), |
67 | UserType: info.UserType, | 67 | UserType: info.UserType, |
68 | - // 用户状态,1启用,2禁用 | ||
69 | EnableStatus: info.EnableStatus, | 68 | EnableStatus: info.EnableStatus, |
70 | - // 手机号码 | ||
71 | Phone: info.UserInfo.Phone, | 69 | Phone: info.UserInfo.Phone, |
72 | - // 用户编号 | ||
73 | UserCode: info.UserCode, | 70 | UserCode: info.UserCode, |
74 | - // 用户姓名 | ||
75 | UserName: info.UserInfo.UserName, | 71 | UserName: info.UserInfo.UserName, |
76 | - // 邮箱 | ||
77 | Email: info.UserInfo.Email, | 72 | Email: info.UserInfo.Email, |
78 | - //头像 | ||
79 | Avatar: info.UserInfo.Avatar, | 73 | Avatar: info.UserInfo.Avatar, |
80 | - // 共创公司 | ||
81 | CooperationCompany: info.CooperationInfo.CooperationCompany, | 74 | CooperationCompany: info.CooperationInfo.CooperationCompany, |
82 | - // 共创公司到期时间 | ||
83 | CooperationDeadline: info.CooperationInfo.CooperationDeadline, | 75 | CooperationDeadline: info.CooperationInfo.CooperationDeadline, |
84 | } | 76 | } |
85 | } | 77 | } |
@@ -125,6 +117,42 @@ func (info *UserDetail) GetOrg() *domain.Orgs { | @@ -125,6 +117,42 @@ func (info *UserDetail) GetOrg() *domain.Orgs { | ||
125 | } | 117 | } |
126 | } | 118 | } |
127 | 119 | ||
120 | +func (info *UserDetail) GetUserOrg() []domain.Orgs { | ||
121 | + var ( | ||
122 | + userOrgs []domain.Orgs | ||
123 | + userOrg domain.Orgs | ||
124 | + ) | ||
125 | + for _, v := range info.UserOrg { | ||
126 | + userOrg = domain.Orgs{ | ||
127 | + OrgId: strconv.FormatInt(v.OrgID, 10), | ||
128 | + OrgName: v.OrgName, | ||
129 | + OrgCode: "", | ||
130 | + ParentId: 0, | ||
131 | + } | ||
132 | + userOrgs = append(userOrgs, userOrg) | ||
133 | + } | ||
134 | + return userOrgs | ||
135 | +} | ||
136 | + | ||
137 | +func (info *UserDetail) GetUserRole() []domain.Roles { | ||
138 | + var ( | ||
139 | + roles []domain.Roles | ||
140 | + role domain.Roles | ||
141 | + ) | ||
142 | + for _, v := range info.UserRole { | ||
143 | + role = domain.Roles{ | ||
144 | + RoleId: strconv.FormatInt(v.RoleID, 10), | ||
145 | + RoleName: v.RoleName, | ||
146 | + // 用户的组织 | ||
147 | + Org: &domain.Orgs{ | ||
148 | + OrgName: v.RoleName, | ||
149 | + }, | ||
150 | + } | ||
151 | + roles = append(roles, role) | ||
152 | + } | ||
153 | + return roles | ||
154 | +} | ||
155 | + | ||
128 | //搜索用户列表 | 156 | //搜索用户列表 |
129 | type ( | 157 | type ( |
130 | ReqUserSearch struct { | 158 | ReqUserSearch struct { |
@@ -195,10 +223,9 @@ type ( | @@ -195,10 +223,9 @@ type ( | ||
195 | //更新用户 | 223 | //更新用户 |
196 | type ( | 224 | type ( |
197 | ReqUpdateUser struct { | 225 | ReqUpdateUser struct { |
226 | + UserId int64 | ||
198 | // 企业id | 227 | // 企业id |
199 | CompanyId int64 `json:"companyId"` | 228 | CompanyId int64 `json:"companyId"` |
200 | - // 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加) | ||
201 | - UserType int `json:"userType"` | ||
202 | // 用户编号 企业内标识 | 229 | // 用户编号 企业内标识 |
203 | UserCode string ` json:"userCode" ` | 230 | UserCode string ` json:"userCode" ` |
204 | // 组织机构 | 231 | // 组织机构 |
@@ -215,8 +242,6 @@ type ( | @@ -215,8 +242,6 @@ type ( | ||
215 | CooperationDeadline time.Time ` json:"cooperationDeadline,omitempty"` | 242 | CooperationDeadline time.Time ` json:"cooperationDeadline,omitempty"` |
216 | // 启用状态(启用:1 禁用:2) | 243 | // 启用状态(启用:1 禁用:2) |
217 | EnableStatus int ` json:"enableStatus,omitempty"` | 244 | EnableStatus int ` json:"enableStatus,omitempty"` |
218 | - // 密码 | ||
219 | - Password string ` json:"password" ` | ||
220 | // 用户姓名 | 245 | // 用户姓名 |
221 | UserName string `json:"userName"` | 246 | UserName string `json:"userName"` |
222 | // 手机号码 | 247 | // 手机号码 |
1 | +package web_client | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/web/beego" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/users/command" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/users/query" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/users/service" | ||
8 | +) | ||
9 | + | ||
10 | +type UsersController struct { | ||
11 | + beego.BaseController | ||
12 | +} | ||
13 | + | ||
14 | +func (controller *UsersController) CompanyUserAdd() { | ||
15 | + usersService := service.NewUsersService(nil) | ||
16 | + companyUserAddCommand := &command.CompanyUserAddCommand{} | ||
17 | + controller.Unmarshal(companyUserAddCommand) | ||
18 | + data, err := usersService.CompanyUserAdd(companyUserAddCommand) | ||
19 | + controller.Response(data, err) | ||
20 | +} | ||
21 | + | ||
22 | +func (controller *UsersController) CompanyUserUpdate() { | ||
23 | + usersService := service.NewUsersService(nil) | ||
24 | + companyUserUpdateCommand := &command.CompanyUserUpdateCommand{} | ||
25 | + controller.Unmarshal(companyUserUpdateCommand) | ||
26 | + data, err := usersService.CompanyUserUpdate(companyUserUpdateCommand) | ||
27 | + controller.Response(data, err) | ||
28 | +} | ||
29 | + | ||
30 | +func (controller *UsersController) CompanyUserList() { | ||
31 | + usersService := service.NewUsersService(nil) | ||
32 | + companyUserListQuery := &query.CompanyUserListQuery{} | ||
33 | + cnt, data, err := usersService.CompanyUserList(companyUserListQuery) | ||
34 | + _ = cnt | ||
35 | + controller.Response(data, err) | ||
36 | +} | ||
37 | + | ||
38 | +func (controller *UsersController) CompanyUserGet() { | ||
39 | + usersService := service.NewUsersService(nil) | ||
40 | + companyUserGetQuery := &query.CompanyUserGetQuery{} | ||
41 | + userId, _ := controller.GetInt64(":userId") | ||
42 | + companyUserGetQuery.UsersId = userId | ||
43 | + data, err := usersService.CompanyUserGet(companyUserGetQuery) | ||
44 | + controller.Response(data, err) | ||
45 | +} | ||
46 | + | ||
47 | +func (controller *UsersController) CompanyUserEnable() { | ||
48 | + usersService := service.NewUsersService(nil) | ||
49 | + companyUserEnableCommand := &command.CompanyUserEnableCommand{} | ||
50 | + controller.Unmarshal(companyUserEnableCommand) | ||
51 | + data, err := usersService.CompanyUserEnable(companyUserEnableCommand) | ||
52 | + controller.Response(data, err) | ||
53 | +} | ||
54 | + | ||
55 | +func (controller *UsersController) CompanyUserResetPassword() { | ||
56 | + usersService := service.NewUsersService(nil) | ||
57 | + companyUserResetPasswordCommand := &command.CompanyUserResetPasswordCommand{} | ||
58 | + controller.Unmarshal(companyUserResetPasswordCommand) | ||
59 | + data, err := usersService.CompanyUserResetPassword(companyUserResetPasswordCommand) | ||
60 | + controller.Response(data, err) | ||
61 | +} | ||
62 | + | ||
63 | +func (controller *UsersController) CooperationUserAdd() { | ||
64 | + usersService := service.NewUsersService(nil) | ||
65 | + cooperationUserAddCommand := &command.CooperationUserAddCommand{} | ||
66 | + controller.Unmarshal(cooperationUserAddCommand) | ||
67 | + data, err := usersService.CooperationUserAdd(cooperationUserAddCommand) | ||
68 | + controller.Response(data, err) | ||
69 | +} | ||
70 | + | ||
71 | +func (controller *UsersController) CooperationUserUpdate() { | ||
72 | + usersService := service.NewUsersService(nil) | ||
73 | + cooperationUserUpdateCommand := &command.CooperationUserUpdateCommand{} | ||
74 | + controller.Unmarshal(cooperationUserUpdateCommand) | ||
75 | + data, err := usersService.CooperationUserUpdate(cooperationUserUpdateCommand) | ||
76 | + controller.Response(data, err) | ||
77 | +} | ||
78 | + | ||
79 | +func (controller *UsersController) CooperationUserList() { | ||
80 | + usersService := service.NewUsersService(nil) | ||
81 | + cooperationUserListQuery := &query.CooperationUserListQuery{} | ||
82 | + cnt, data, err := usersService.CooperationUserList(cooperationUserListQuery) | ||
83 | + _ = cnt | ||
84 | + controller.Response(data, err) | ||
85 | +} | ||
86 | + | ||
87 | +func (controller *UsersController) CooperationUserGet() { | ||
88 | + usersService := service.NewUsersService(nil) | ||
89 | + cooperationUserGetQuery := &query.CooperationUserGetQuery{} | ||
90 | + userId, _ := controller.GetInt64(":userId") | ||
91 | + cooperationUserGetQuery.UsersId = userId | ||
92 | + data, err := usersService.CooperationUserGet(cooperationUserGetQuery) | ||
93 | + controller.Response(data, err) | ||
94 | +} | ||
95 | + | ||
96 | +func (controller *UsersController) CooperationUserEnable() { | ||
97 | + usersService := service.NewUsersService(nil) | ||
98 | + cooperationUserEnableCommand := &command.CooperationUserEnableCommand{} | ||
99 | + controller.Unmarshal(cooperationUserEnableCommand) | ||
100 | + data, err := usersService.CooperationUserEnable(cooperationUserEnableCommand) | ||
101 | + controller.Response(data, err) | ||
102 | +} | ||
103 | + | ||
104 | +func (controller *UsersController) CooperationUserResetPassword() { | ||
105 | + usersService := service.NewUsersService(nil) | ||
106 | + cooperationUserResetPasswordCommand := &command.CooperationUserResetPasswordCommand{} | ||
107 | + controller.Unmarshal(cooperationUserResetPasswordCommand) | ||
108 | + data, err := usersService.CooperationUserResetPassword(cooperationUserResetPasswordCommand) | ||
109 | + controller.Response(data, err) | ||
110 | +} |
pkg/port/beego/routers/web_users_router.go
0 → 100644
1 | +package routers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/beego/beego/v2/server/web" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/web_client" | ||
6 | +) | ||
7 | + | ||
8 | +func init() { | ||
9 | + web.Router("/v1/web/users/company-user", &web_client.UsersController{}, "Post:CompanyUserAdd") | ||
10 | + web.Router("/v1/web/users/company-user", &web_client.UsersController{}, "Put:CompanyUserUpdate") | ||
11 | + web.Router("/v1/web/users/company-user/search", &web_client.UsersController{}, "Post:CompanyUserList") | ||
12 | + web.Router("/v1/web/users/company-user/:userId", &web_client.UsersController{}, "Get:CompanyUserGet") | ||
13 | + web.Router("/v1/web/users/company-user/enable", &web_client.UsersController{}, "Put:CompanyUserEnable") | ||
14 | + web.Router("/v1/web/users/company-user/reset-password", &web_client.UsersController{}, "Put:CompanyUserResetPassword") | ||
15 | + web.Router("/v1/web/users/cooperation-user", &web_client.UsersController{}, "Post:CooperationUserAdd") | ||
16 | + web.Router("/v1/web/users/cooperation-user", &web_client.UsersController{}, "Put:CooperationUserUpdate") | ||
17 | + web.Router("/v1/web/users/cooperation-user/search", &web_client.UsersController{}, "Post:CooperationUserList") | ||
18 | + web.Router("/v1/web/users/cooperation-user/:userId", &web_client.UsersController{}, "Get:CooperationUserGet") | ||
19 | + web.Router("/v1/web/users/cooperation-user/enable", &web_client.UsersController{}, "Put:CooperationUserEnable") | ||
20 | + web.Router("/v1/web/users/cooperation-user/reset-password", &web_client.UsersController{}, "Put:CooperationUserResetPassword") | ||
21 | +} |
-
请 注册 或 登录 后发表评论