正在显示
11 个修改的文件
包含
708 行增加
和
87 行删除
pkg/application/web/users/dto/dto.go
0 → 100644
@@ -11,10 +11,15 @@ type CompanyUserListQuery struct { | @@ -11,10 +11,15 @@ type CompanyUserListQuery struct { | ||
11 | PageNumber int `json:"pageNumber"` | 11 | PageNumber int `json:"pageNumber"` |
12 | // 每页数量 | 12 | // 每页数量 |
13 | PageSize int `json:"pageSize" valid:"Required"` | 13 | PageSize int `json:"pageSize" valid:"Required"` |
14 | + //用户姓名 | ||
15 | + UserName string `json:"userName"` | ||
16 | + //所属部门 | ||
17 | + DepartmentName string `json:"departmentName"` | ||
18 | + CompanyId int64 `json:"companyId" valid:"Required"` | ||
14 | } | 19 | } |
15 | 20 | ||
16 | func (companyUserListQuery *CompanyUserListQuery) Valid(validation *validation.Validation) { | 21 | func (companyUserListQuery *CompanyUserListQuery) Valid(validation *validation.Validation) { |
17 | - validation.SetError("CustomValid", "未实现的自定义认证") | 22 | + |
18 | } | 23 | } |
19 | 24 | ||
20 | func (companyUserListQuery *CompanyUserListQuery) ValidateQuery() error { | 25 | func (companyUserListQuery *CompanyUserListQuery) ValidateQuery() error { |
1 | package service | 1 | package service |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "github.com/linmadan/egglib-go/core/application" | ||
4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/command" | 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/command" |
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/dto" | ||
5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/query" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/query" |
8 | + | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" | ||
6 | ) | 10 | ) |
7 | 11 | ||
8 | // 用户信息 | 12 | // 用户信息 |
@@ -28,9 +32,41 @@ func (usersService *UsersService) CompanyUserEnable(companyUserEnableCommand *co | @@ -28,9 +32,41 @@ func (usersService *UsersService) CompanyUserEnable(companyUserEnableCommand *co | ||
28 | } | 32 | } |
29 | 33 | ||
30 | // 返回公司用户信息列表 | 34 | // 返回公司用户信息列表 |
31 | -func (usersService *UsersService) CompanyUserList(companyUserListQuery *query.CompanyUserListQuery) (interface{}, error) { | ||
32 | - | ||
33 | - return nil, nil | 35 | +func (usersService *UsersService) CompanyUserList(companyUserListQuery *query.CompanyUserListQuery) (int64, interface{}, error) { |
36 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser() | ||
37 | + result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{ | ||
38 | + Offset: (companyUserListQuery.PageNumber - 1) * companyUserListQuery.PageSize, | ||
39 | + Limit: companyUserListQuery.PageSize, | ||
40 | + CompanyId: companyUserListQuery.CompanyId, | ||
41 | + OrganizationId: 0, | ||
42 | + DepartmentId: 0, | ||
43 | + UserName: companyUserListQuery.UserName, | ||
44 | + DepName: companyUserListQuery.DepartmentName, | ||
45 | + Phone: "", | ||
46 | + }) | ||
47 | + | ||
48 | + if err != nil { | ||
49 | + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
50 | + } | ||
51 | + //数据转换 | ||
52 | + cnt := int64(result.Count) | ||
53 | + var ( | ||
54 | + listData []dto.UserListItem | ||
55 | + item dto.UserListItem | ||
56 | + ) | ||
57 | + for _, v := range result.Users { | ||
58 | + item = dto.UserListItem{ | ||
59 | + DepName: v.Ext.DepName, | ||
60 | + OrgName: v.Ext.OrgName, | ||
61 | + Phone: v.Ext.Phone, | ||
62 | + EnableStatus: v.EnableStatus, | ||
63 | + UserCode: v.UserCode, | ||
64 | + UserId: int64(v.UserID), | ||
65 | + UserName: v.UserName, | ||
66 | + } | ||
67 | + listData = append(listData, item) | ||
68 | + } | ||
69 | + return cnt, listData, nil | ||
34 | } | 70 | } |
35 | 71 | ||
36 | // 批量重置密码 | 72 | // 批量重置密码 |
@@ -4,14 +4,14 @@ package domain | @@ -4,14 +4,14 @@ package domain | ||
4 | type UsersBase struct { | 4 | type UsersBase struct { |
5 | // 手机号码 | 5 | // 手机号码 |
6 | Phone string `json:"phone"` | 6 | Phone string `json:"phone"` |
7 | - // 共创模式状态,1启用,2禁用 | ||
8 | - Status int32 `json:"status"` | 7 | + // 用户状态,1启用,2禁用 |
8 | + EnableStatus int32 `json:"enableStatus"` | ||
9 | // 用户编号 | 9 | // 用户编号 |
10 | - UsersCode string `json:"usersCode"` | 10 | + UserCode string `json:"userCode"` |
11 | // 用户编号 | 11 | // 用户编号 |
12 | - UsersId int64 `json:"usersId"` | 12 | + UserId int64 `json:"userId"` |
13 | // 用户姓名 | 13 | // 用户姓名 |
14 | - UsersName string `json:"usersName"` | 14 | + UserName string `json:"userName"` |
15 | // 邮箱 | 15 | // 邮箱 |
16 | Email string `json:"email"` | 16 | Email string `json:"email"` |
17 | // 共创公司 | 17 | // 共创公司 |
1 | package allied_creation_basic | 1 | package allied_creation_basic |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | - "encoding/json" | ||
5 | - "fmt" | ||
6 | "time" | 4 | "time" |
7 | 5 | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway" |
9 | 7 | ||
10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant" |
11 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log" | ||
12 | ) | 9 | ) |
13 | 10 | ||
14 | type HttplibAlliedCreationBasic struct { | 11 | type HttplibAlliedCreationBasic struct { |
@@ -27,35 +24,3 @@ var alliedCreationBasicClient = &HttplibAlliedCreationBasic{ | @@ -27,35 +24,3 @@ var alliedCreationBasicClient = &HttplibAlliedCreationBasic{ | ||
27 | func NewHttplibAlliedCreationBasic() *HttplibAlliedCreationBasic { | 24 | func NewHttplibAlliedCreationBasic() *HttplibAlliedCreationBasic { |
28 | return alliedCreationBasicClient | 25 | return alliedCreationBasicClient |
29 | } | 26 | } |
30 | - | ||
31 | -//GetDictionarysByCode 根据code获取字典数据 | ||
32 | -func (gateway HttplibAlliedCreationBasic) GetDictionarysByCode(param ReqGetDictionaryByCode) (*DataGetDictionaryByCode, error) { | ||
33 | - url := gateway.baseUrL + "/dictionarys/dictionary-code" | ||
34 | - method := "post" | ||
35 | - req := gateway.CreateRequest(url, method) | ||
36 | - //TODO traceID | ||
37 | - log.Logger.Debug("向基础模块请求数据:根据code获取字典数据。", map[string]interface{}{ | ||
38 | - "api": method + ":" + url, | ||
39 | - "param": param, | ||
40 | - }) | ||
41 | - req, err := req.JSONBody(param) | ||
42 | - if err != nil { | ||
43 | - return nil, fmt.Errorf("请求字典数据失败:%w", err) | ||
44 | - } | ||
45 | - | ||
46 | - byteResult, err := req.Bytes() | ||
47 | - if err != nil { | ||
48 | - return nil, fmt.Errorf("获取字典数据失败:%w", err) | ||
49 | - } | ||
50 | - log.Logger.Debug("获取基础模块响应数据:根据code获取字典数据。", map[string]interface{}{ | ||
51 | - "result": string(byteResult), | ||
52 | - }) | ||
53 | - var result service_gateway.GatewayResponse | ||
54 | - err = json.Unmarshal(byteResult, &result) | ||
55 | - if err != nil { | ||
56 | - return nil, fmt.Errorf("解析字典数据失败:%w", err) | ||
57 | - } | ||
58 | - var data DataGetDictionaryByCode | ||
59 | - err = gateway.GetResponseData(result, &data) | ||
60 | - return &data, err | ||
61 | -} |
1 | +package allied_creation_basic | ||
2 | + | ||
3 | +import ( | ||
4 | + "encoding/json" | ||
5 | + "fmt" | ||
6 | + | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log" | ||
8 | + | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway" | ||
10 | +) | ||
11 | + | ||
12 | +//GetDictionarysByCode 根据code获取字典数据 | ||
13 | +func (gateway HttplibAlliedCreationBasic) GetDictionarysByCode(param ReqGetDictionaryByCode) (*DataGetDictionaryByCode, error) { | ||
14 | + url := gateway.baseUrL + "/dictionarys/dictionary-code" | ||
15 | + method := "post" | ||
16 | + req := gateway.CreateRequest(url, method) | ||
17 | + //TODO traceID | ||
18 | + log.Logger.Debug("向基础模块请求数据:根据code获取字典数据。", map[string]interface{}{ | ||
19 | + "api": method + ":" + url, | ||
20 | + "param": param, | ||
21 | + }) | ||
22 | + req, err := req.JSONBody(param) | ||
23 | + if err != nil { | ||
24 | + return nil, fmt.Errorf("请求字典数据失败:%w", err) | ||
25 | + } | ||
26 | + | ||
27 | + byteResult, err := req.Bytes() | ||
28 | + if err != nil { | ||
29 | + return nil, fmt.Errorf("获取字典数据失败:%w", err) | ||
30 | + } | ||
31 | + log.Logger.Debug("获取基础模块响应数据:根据code获取字典数据。", map[string]interface{}{ | ||
32 | + "result": string(byteResult), | ||
33 | + }) | ||
34 | + var result service_gateway.GatewayResponse | ||
35 | + err = json.Unmarshal(byteResult, &result) | ||
36 | + if err != nil { | ||
37 | + return nil, fmt.Errorf("解析字典数据失败:%w", err) | ||
38 | + } | ||
39 | + var data DataGetDictionaryByCode | ||
40 | + err = gateway.GetResponseData(result, &data) | ||
41 | + return &data, err | ||
42 | +} |
1 | package allied_creation_user | 1 | package allied_creation_user |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | - "encoding/json" | ||
5 | - "fmt" | ||
6 | "time" | 4 | "time" |
7 | 5 | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant" |
9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway" |
10 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log" | ||
11 | ) | 8 | ) |
12 | 9 | ||
13 | //HttplibAlliedCreationUser 用户模块 | 10 | //HttplibAlliedCreationUser 用户模块 |
@@ -27,35 +24,3 @@ var alliedCreationUserClient = &HttplibAlliedCreationUser{ | @@ -27,35 +24,3 @@ var alliedCreationUserClient = &HttplibAlliedCreationUser{ | ||
27 | func NewHttplibAlliedCreationUser() *HttplibAlliedCreationUser { | 24 | func NewHttplibAlliedCreationUser() *HttplibAlliedCreationUser { |
28 | return alliedCreationUserClient | 25 | return alliedCreationUserClient |
29 | } | 26 | } |
30 | - | ||
31 | -//UserSearch 搜索用户列表 | ||
32 | -func (gateway HttplibAlliedCreationUser) UserSearch(param ReqUserSearch) (*DataUserSearch, error) { | ||
33 | - url := gateway.baseUrL + "/dictionarys/dictionary-code" | ||
34 | - method := "post" | ||
35 | - req := gateway.CreateRequest(url, method) | ||
36 | - //TODO traceID | ||
37 | - log.Logger.Debug("向用户模块请求数据:搜索用户列表。", map[string]interface{}{ | ||
38 | - "api": method + ":" + url, | ||
39 | - "param": param, | ||
40 | - }) | ||
41 | - req, err := req.JSONBody(param) | ||
42 | - if err != nil { | ||
43 | - return nil, fmt.Errorf("搜索用户列表失败:%w", err) | ||
44 | - } | ||
45 | - | ||
46 | - byteResult, err := req.Bytes() | ||
47 | - if err != nil { | ||
48 | - return nil, fmt.Errorf("获取搜索用户列表失败:%w", err) | ||
49 | - } | ||
50 | - log.Logger.Debug("获取用户模块请求数据:搜索用户列表。", map[string]interface{}{ | ||
51 | - "result": string(byteResult), | ||
52 | - }) | ||
53 | - var result service_gateway.GatewayResponse | ||
54 | - err = json.Unmarshal(byteResult, &result) | ||
55 | - if err != nil { | ||
56 | - return nil, fmt.Errorf("解析搜索用户列表:%w", err) | ||
57 | - } | ||
58 | - var data DataUserSearch | ||
59 | - err = gateway.GetResponseData(result, &data) | ||
60 | - return &data, err | ||
61 | -} |
1 | +package allied_creation_user |
1 | +package allied_creation_user | ||
2 | + | ||
3 | +import ( | ||
4 | + "encoding/json" | ||
5 | + "fmt" | ||
6 | + | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log" | ||
9 | +) | ||
10 | + | ||
11 | +//UserSearch 搜索用户列表 | ||
12 | +func (gateway HttplibAlliedCreationUser) UserSearch(param ReqUserSearch) (*DataUserSearch, error) { | ||
13 | + url := gateway.baseUrL + "/user/search" | ||
14 | + method := "post" | ||
15 | + req := gateway.CreateRequest(url, method) | ||
16 | + //TODO traceID | ||
17 | + log.Logger.Debug("向用户模块请求数据:搜索用户列表。", map[string]interface{}{ | ||
18 | + "api": method + ":" + url, | ||
19 | + "param": param, | ||
20 | + }) | ||
21 | + req, err := req.JSONBody(param) | ||
22 | + if err != nil { | ||
23 | + return nil, fmt.Errorf("搜索用户列表失败:%w", err) | ||
24 | + } | ||
25 | + | ||
26 | + byteResult, err := req.Bytes() | ||
27 | + if err != nil { | ||
28 | + return nil, fmt.Errorf("获取搜索用户列表失败:%w", err) | ||
29 | + } | ||
30 | + log.Logger.Debug("获取用户模块请求数据:搜索用户列表。", map[string]interface{}{ | ||
31 | + "result": string(byteResult), | ||
32 | + }) | ||
33 | + var result service_gateway.GatewayResponse | ||
34 | + err = json.Unmarshal(byteResult, &result) | ||
35 | + if err != nil { | ||
36 | + return nil, fmt.Errorf("解析搜索用户列表:%w", err) | ||
37 | + } | ||
38 | + var data DataUserSearch | ||
39 | + err = gateway.GetResponseData(result, &data) | ||
40 | + return &data, err | ||
41 | +} | ||
42 | + | ||
43 | +//UserCreate 创建用户 | ||
44 | +func (gateway HttplibAlliedCreationUser) UserCreate(param ReqCreateUser) (*DataCreateUser, error) { | ||
45 | + url := gateway.baseUrL + "/user" | ||
46 | + method := "post" | ||
47 | + req := gateway.CreateRequest(url, method) | ||
48 | + //TODO traceID | ||
49 | + log.Logger.Debug("向用户模块请求数据:创建用户。", map[string]interface{}{ | ||
50 | + "api": method + ":" + url, | ||
51 | + "param": param, | ||
52 | + }) | ||
53 | + req, err := req.JSONBody(param) | ||
54 | + if err != nil { | ||
55 | + return nil, fmt.Errorf("创建用户失败:%w", err) | ||
56 | + } | ||
57 | + | ||
58 | + byteResult, err := req.Bytes() | ||
59 | + if err != nil { | ||
60 | + return nil, fmt.Errorf("获取创建用户失败:%w", err) | ||
61 | + } | ||
62 | + log.Logger.Debug("获取用户模块请求数据:创建用户。", map[string]interface{}{ | ||
63 | + "result": string(byteResult), | ||
64 | + }) | ||
65 | + var result service_gateway.GatewayResponse | ||
66 | + err = json.Unmarshal(byteResult, &result) | ||
67 | + if err != nil { | ||
68 | + return nil, fmt.Errorf("解析创建用户:%w", err) | ||
69 | + } | ||
70 | + var data DataCreateUser | ||
71 | + err = gateway.GetResponseData(result, &data) | ||
72 | + return &data, err | ||
73 | +} | ||
74 | + | ||
75 | +//UserUpdate 更新用户 | ||
76 | +func (gateway HttplibAlliedCreationUser) UserUpdate(param ReqUpdateUser) (*DataUpdateUser, error) { | ||
77 | + url := gateway.baseUrL + "/user" | ||
78 | + method := "put" | ||
79 | + req := gateway.CreateRequest(url, method) | ||
80 | + //TODO traceID | ||
81 | + log.Logger.Debug("向用户模块请求数据:更新用户。", map[string]interface{}{ | ||
82 | + "api": method + ":" + url, | ||
83 | + "param": param, | ||
84 | + }) | ||
85 | + req, err := req.JSONBody(param) | ||
86 | + if err != nil { | ||
87 | + return nil, fmt.Errorf("请求更新用户失败:%w", err) | ||
88 | + } | ||
89 | + | ||
90 | + byteResult, err := req.Bytes() | ||
91 | + if err != nil { | ||
92 | + return nil, fmt.Errorf("获取更新用户失败:%w", err) | ||
93 | + } | ||
94 | + log.Logger.Debug("获取用户模块请求数据:更新用户。", map[string]interface{}{ | ||
95 | + "result": string(byteResult), | ||
96 | + }) | ||
97 | + var result service_gateway.GatewayResponse | ||
98 | + err = json.Unmarshal(byteResult, &result) | ||
99 | + if err != nil { | ||
100 | + return nil, fmt.Errorf("解析更新用户:%w", err) | ||
101 | + } | ||
102 | + var data DataUpdateUser | ||
103 | + err = gateway.GetResponseData(result, &data) | ||
104 | + return &data, err | ||
105 | +} | ||
106 | + | ||
107 | +//UserGet 获取用户 | ||
108 | +func (gateway HttplibAlliedCreationUser) UserGet(param ReqGateUser) (*DataGateUser, error) { | ||
109 | + url := fmt.Sprintf("%s%s%d", gateway.baseUrL, "/user/", param.UserId) | ||
110 | + method := "get" | ||
111 | + req := gateway.CreateRequest(url, method) | ||
112 | + //TODO traceID | ||
113 | + log.Logger.Debug("向用户模块请求数据:获取用户。", map[string]interface{}{ | ||
114 | + "api": method + ":" + url, | ||
115 | + "param": param, | ||
116 | + }) | ||
117 | + req, err := req.JSONBody(param) | ||
118 | + if err != nil { | ||
119 | + return nil, fmt.Errorf("请求获取用户失败:%w", err) | ||
120 | + } | ||
121 | + | ||
122 | + byteResult, err := req.Bytes() | ||
123 | + if err != nil { | ||
124 | + return nil, fmt.Errorf("获取获取用户失败:%w", err) | ||
125 | + } | ||
126 | + log.Logger.Debug("获取用户模块请求数据:获取用户。", map[string]interface{}{ | ||
127 | + "result": string(byteResult), | ||
128 | + }) | ||
129 | + var result service_gateway.GatewayResponse | ||
130 | + err = json.Unmarshal(byteResult, &result) | ||
131 | + if err != nil { | ||
132 | + return nil, fmt.Errorf("解析获取用户:%w", err) | ||
133 | + } | ||
134 | + var data DataGateUser | ||
135 | + err = gateway.GetResponseData(result, &data) | ||
136 | + return &data, err | ||
137 | +} | ||
138 | + | ||
139 | +//UserDelete 删除用户 | ||
140 | +func (gateway HttplibAlliedCreationUser) UserDelete(param ReqDeleteUser) (*DataDeleteUser, error) { | ||
141 | + url := fmt.Sprintf("%s%s%d", gateway.baseUrL, "/user/", param.UserId) | ||
142 | + method := "delete" | ||
143 | + req := gateway.CreateRequest(url, method) | ||
144 | + //TODO traceID | ||
145 | + log.Logger.Debug("向用户模块请求数据:删除用户。", map[string]interface{}{ | ||
146 | + "api": method + ":" + url, | ||
147 | + "param": param, | ||
148 | + }) | ||
149 | + req, err := req.JSONBody(param) | ||
150 | + if err != nil { | ||
151 | + return nil, fmt.Errorf("请求删除用户失败:%w", err) | ||
152 | + } | ||
153 | + | ||
154 | + byteResult, err := req.Bytes() | ||
155 | + if err != nil { | ||
156 | + return nil, fmt.Errorf("获取删除用户失败:%w", err) | ||
157 | + } | ||
158 | + log.Logger.Debug("获取用户模块请求数据:删除用户。", map[string]interface{}{ | ||
159 | + "result": string(byteResult), | ||
160 | + }) | ||
161 | + var result service_gateway.GatewayResponse | ||
162 | + err = json.Unmarshal(byteResult, &result) | ||
163 | + if err != nil { | ||
164 | + return nil, fmt.Errorf("解析删除用户:%w", err) | ||
165 | + } | ||
166 | + var data DataDeleteUser | ||
167 | + err = gateway.GetResponseData(result, &data) | ||
168 | + return &data, err | ||
169 | +} | ||
170 | + | ||
171 | +//UserBatchEnable 批量修改用户启用状态 | ||
172 | +func (gateway HttplibAlliedCreationUser) UserBatchEnable(param ReqBatchEnableUser) (*DataBatchEnableUser, error) { | ||
173 | + url := fmt.Sprintf("%s%s", gateway.baseUrL, "/user/batch-enable") | ||
174 | + method := "post" | ||
175 | + req := gateway.CreateRequest(url, method) | ||
176 | + //TODO traceID | ||
177 | + log.Logger.Debug("向用户模块请求数据:批量修改用户启用状态。", map[string]interface{}{ | ||
178 | + "api": method + ":" + url, | ||
179 | + "param": param, | ||
180 | + }) | ||
181 | + req, err := req.JSONBody(param) | ||
182 | + if err != nil { | ||
183 | + return nil, fmt.Errorf("请求批量修改用户启用状态失败:%w", err) | ||
184 | + } | ||
185 | + | ||
186 | + byteResult, err := req.Bytes() | ||
187 | + if err != nil { | ||
188 | + return nil, fmt.Errorf("获取批量修改用户启用状态失败:%w", err) | ||
189 | + } | ||
190 | + log.Logger.Debug("获取用户模块请求数据:批量修改用户启用状态。", map[string]interface{}{ | ||
191 | + "result": string(byteResult), | ||
192 | + }) | ||
193 | + var result service_gateway.GatewayResponse | ||
194 | + err = json.Unmarshal(byteResult, &result) | ||
195 | + if err != nil { | ||
196 | + return nil, fmt.Errorf("解析批量修改用户启用状态:%w", err) | ||
197 | + } | ||
198 | + var data DataBatchEnableUser | ||
199 | + err = gateway.GetResponseData(result, &data) | ||
200 | + return &data, err | ||
201 | +} | ||
202 | + | ||
203 | +//UserBatchResetPassword 批量重置密码 | ||
204 | +func (gateway HttplibAlliedCreationUser) UserBatchResetPassword(param ReqBatchResetPasswordUser) (*DataBatchResetPasswordUser, error) { | ||
205 | + url := fmt.Sprintf("%s%s", gateway.baseUrL, "/user/batch-reset-password") | ||
206 | + method := "post" | ||
207 | + req := gateway.CreateRequest(url, method) | ||
208 | + //TODO traceID | ||
209 | + log.Logger.Debug("向用户模块请求数据:批量重置密码。", map[string]interface{}{ | ||
210 | + "api": method + ":" + url, | ||
211 | + "param": param, | ||
212 | + }) | ||
213 | + req, err := req.JSONBody(param) | ||
214 | + if err != nil { | ||
215 | + return nil, fmt.Errorf("请求批量重置密码失败:%w", err) | ||
216 | + } | ||
217 | + | ||
218 | + byteResult, err := req.Bytes() | ||
219 | + if err != nil { | ||
220 | + return nil, fmt.Errorf("获取批量重置密码失败:%w", err) | ||
221 | + } | ||
222 | + log.Logger.Debug("获取用户模块请求数据:批量重置密码。", map[string]interface{}{ | ||
223 | + "result": string(byteResult), | ||
224 | + }) | ||
225 | + var result service_gateway.GatewayResponse | ||
226 | + err = json.Unmarshal(byteResult, &result) | ||
227 | + if err != nil { | ||
228 | + return nil, fmt.Errorf("解析批量重置密码:%w", err) | ||
229 | + } | ||
230 | + var data DataBatchResetPasswordUser | ||
231 | + err = gateway.GetResponseData(result, &data) | ||
232 | + return &data, err | ||
233 | +} | ||
234 | + | ||
235 | +//CooperatorUserCreate 创建共创用户 | ||
236 | +func (gateway HttplibAlliedCreationUser) CooperatorUserCreate(param ReqCreateCooperatorUser) (*DataCreateCooperatorUser, error) { | ||
237 | + url := fmt.Sprintf("%s%s", gateway.baseUrL, "/user/cooperator") | ||
238 | + method := "post" | ||
239 | + req := gateway.CreateRequest(url, method) | ||
240 | + //TODO traceID | ||
241 | + log.Logger.Debug("向用户模块请求数据:创建共创用户。", map[string]interface{}{ | ||
242 | + "api": method + ":" + url, | ||
243 | + "param": param, | ||
244 | + }) | ||
245 | + req, err := req.JSONBody(param) | ||
246 | + if err != nil { | ||
247 | + return nil, fmt.Errorf("请求创建共创用户失败:%w", err) | ||
248 | + } | ||
249 | + | ||
250 | + byteResult, err := req.Bytes() | ||
251 | + if err != nil { | ||
252 | + return nil, fmt.Errorf("获取创建共创用户失败:%w", err) | ||
253 | + } | ||
254 | + log.Logger.Debug("获取用户模块请求数据:创建共创用户。", map[string]interface{}{ | ||
255 | + "result": string(byteResult), | ||
256 | + }) | ||
257 | + var result service_gateway.GatewayResponse | ||
258 | + err = json.Unmarshal(byteResult, &result) | ||
259 | + if err != nil { | ||
260 | + return nil, fmt.Errorf("解析创建共创用户:%w", err) | ||
261 | + } | ||
262 | + var data DataCreateCooperatorUser | ||
263 | + err = gateway.GetResponseData(result, &data) | ||
264 | + return &data, err | ||
265 | +} | ||
266 | + | ||
267 | +//CooperatorUserUpdate 更新共创用户 | ||
268 | +func (gateway HttplibAlliedCreationUser) CooperatorUserUpdate(param ReqUpdateCooperatorUser) (*DataUpdateCooperatorUser, error) { | ||
269 | + url := fmt.Sprintf("%s%s%d", gateway.baseUrL, "/user/cooperator/", param.UserId) | ||
270 | + method := "put" | ||
271 | + req := gateway.CreateRequest(url, method) | ||
272 | + //TODO traceID | ||
273 | + log.Logger.Debug("向用户模块请求数据:更新共创用户。", map[string]interface{}{ | ||
274 | + "api": method + ":" + url, | ||
275 | + "param": param, | ||
276 | + }) | ||
277 | + req, err := req.JSONBody(param) | ||
278 | + if err != nil { | ||
279 | + return nil, fmt.Errorf("请求更新共创用户失败:%w", err) | ||
280 | + } | ||
281 | + | ||
282 | + byteResult, err := req.Bytes() | ||
283 | + if err != nil { | ||
284 | + return nil, fmt.Errorf("获取更新共创用户失败:%w", err) | ||
285 | + } | ||
286 | + log.Logger.Debug("获取用户模块请求数据:更新共创用户。", map[string]interface{}{ | ||
287 | + "result": string(byteResult), | ||
288 | + }) | ||
289 | + var result service_gateway.GatewayResponse | ||
290 | + err = json.Unmarshal(byteResult, &result) | ||
291 | + if err != nil { | ||
292 | + return nil, fmt.Errorf("解析更新共创用户:%w", err) | ||
293 | + } | ||
294 | + var data DataUpdateCooperatorUser | ||
295 | + err = gateway.GetResponseData(result, &data) | ||
296 | + return &data, err | ||
297 | +} | ||
298 | + | ||
299 | +//UserProfile 获取用户概要数据 | ||
300 | +func (gateway HttplibAlliedCreationUser) UserProfile(param ReqUserProfile) (*DataUserProfile, error) { | ||
301 | + url := fmt.Sprintf("%s%s%d%s", gateway.baseUrL, "/user/", param.UserId, "/profile") | ||
302 | + method := "get" | ||
303 | + req := gateway.CreateRequest(url, method) | ||
304 | + //TODO traceID | ||
305 | + log.Logger.Debug("向用户模块请求数据:获取用户概要数据。", map[string]interface{}{ | ||
306 | + "api": method + ":" + url, | ||
307 | + "param": param, | ||
308 | + }) | ||
309 | + req, err := req.JSONBody(param) | ||
310 | + if err != nil { | ||
311 | + return nil, fmt.Errorf("请求获取用户概要数据失败:%w", err) | ||
312 | + } | ||
313 | + | ||
314 | + byteResult, err := req.Bytes() | ||
315 | + if err != nil { | ||
316 | + return nil, fmt.Errorf("获取用户概要数据失败:%w", err) | ||
317 | + } | ||
318 | + log.Logger.Debug("获取用户模块请求数据:获取用户概要数据。", map[string]interface{}{ | ||
319 | + "result": string(byteResult), | ||
320 | + }) | ||
321 | + var result service_gateway.GatewayResponse | ||
322 | + err = json.Unmarshal(byteResult, &result) | ||
323 | + if err != nil { | ||
324 | + return nil, fmt.Errorf("解析获取用户概要数据:%w", err) | ||
325 | + } | ||
326 | + var data DataUserProfile | ||
327 | + err = gateway.GetResponseData(result, &data) | ||
328 | + return &data, err | ||
329 | +} | ||
330 | + | ||
331 | +//UserUpdateBaseInfo 更新用户基础数据 | ||
332 | +func (gateway HttplibAlliedCreationUser) UserUpdateBaseInfo(param ReqUserUpdateBaseInfo) (*DataUserUpdateBaseInfo, error) { | ||
333 | + url := fmt.Sprintf("%s%s%d%s", gateway.baseUrL, "/user/", param.UserId, "/base-info") | ||
334 | + method := "get" | ||
335 | + req := gateway.CreateRequest(url, method) | ||
336 | + //TODO traceID | ||
337 | + log.Logger.Debug("向用户模块请求数据:更新用户基础数据。", map[string]interface{}{ | ||
338 | + "api": method + ":" + url, | ||
339 | + "param": param, | ||
340 | + }) | ||
341 | + req, err := req.JSONBody(param) | ||
342 | + if err != nil { | ||
343 | + return nil, fmt.Errorf("请求更新用户基础数据失败:%w", err) | ||
344 | + } | ||
345 | + | ||
346 | + byteResult, err := req.Bytes() | ||
347 | + if err != nil { | ||
348 | + return nil, fmt.Errorf("获取更新用户基础数据失败:%w", err) | ||
349 | + } | ||
350 | + log.Logger.Debug("获取用户模块请求数据:更新用户基础数据。", map[string]interface{}{ | ||
351 | + "result": string(byteResult), | ||
352 | + }) | ||
353 | + var result service_gateway.GatewayResponse | ||
354 | + err = json.Unmarshal(byteResult, &result) | ||
355 | + if err != nil { | ||
356 | + return nil, fmt.Errorf("解析更新用户基础数据:%w", err) | ||
357 | + } | ||
358 | + var data DataUserUpdateBaseInfo | ||
359 | + err = gateway.GetResponseData(result, &data) | ||
360 | + return &data, err | ||
361 | +} | ||
362 | + | ||
363 | +//UserUpdateBaseInfo 返回用户有权限的菜单 | ||
364 | +func (gateway HttplibAlliedCreationUser) UserAccessMenus(param ReqUserAccessMenus) (*DataUserAccessMenus, error) { | ||
365 | + url := fmt.Sprintf("%s%s%d%s", gateway.baseUrL, "/user/", param.UserId, "/base-info") | ||
366 | + method := "get" | ||
367 | + req := gateway.CreateRequest(url, method) | ||
368 | + //TODO traceID | ||
369 | + log.Logger.Debug("向用户模块请求数据:返回用户有权限的菜单。", map[string]interface{}{ | ||
370 | + "api": method + ":" + url, | ||
371 | + "param": param, | ||
372 | + }) | ||
373 | + req, err := req.JSONBody(param) | ||
374 | + if err != nil { | ||
375 | + return nil, fmt.Errorf("请求返回用户有权限的菜单失败:%w", err) | ||
376 | + } | ||
377 | + | ||
378 | + byteResult, err := req.Bytes() | ||
379 | + if err != nil { | ||
380 | + return nil, fmt.Errorf("获取返回用户有权限的菜单失败:%w", err) | ||
381 | + } | ||
382 | + log.Logger.Debug("获取用户模块请求数据:返回用户有权限的菜单。", map[string]interface{}{ | ||
383 | + "result": string(byteResult), | ||
384 | + }) | ||
385 | + var result service_gateway.GatewayResponse | ||
386 | + err = json.Unmarshal(byteResult, &result) | ||
387 | + if err != nil { | ||
388 | + return nil, fmt.Errorf("解析返回用户有权限的菜单:%w", err) | ||
389 | + } | ||
390 | + var data DataUserAccessMenus | ||
391 | + err = gateway.GetResponseData(result, &data) | ||
392 | + return &data, err | ||
393 | +} |
@@ -2,16 +2,29 @@ package allied_creation_user | @@ -2,16 +2,29 @@ package allied_creation_user | ||
2 | 2 | ||
3 | import "time" | 3 | import "time" |
4 | 4 | ||
5 | -//ReqUserSearch 搜索用户列表 | ||
6 | -type ReqUserSearch struct { | 5 | +//搜索用户列表 |
6 | +type ( | ||
7 | + ReqUserSearch struct { | ||
7 | // 查询偏离量 | 8 | // 查询偏离量 |
8 | - Offset int `json:"offset" valid:"Required"` | 9 | + Offset int `json:"offset"` |
9 | // 查询限制 | 10 | // 查询限制 |
10 | - Limit int `json:"limit" valid:"Required"` | ||
11 | -} | 11 | + Limit int `json:"limit"` |
12 | + // 企业id | ||
13 | + CompanyId int64 ` json:"companyId"` | ||
14 | + // 组织ID | ||
15 | + OrganizationId int64 `json:"organizationId"` | ||
16 | + // 部门编号 | ||
17 | + DepartmentId int64 `json:"departmentId"` | ||
18 | + // 用户姓名 | ||
19 | + UserName string `json:"userName"` | ||
20 | + // 部门名称 | ||
21 | + DepName string `json:"depName"` | ||
22 | + // 手机号码 | ||
23 | + Phone string `json:"phone"` | ||
24 | + } | ||
12 | 25 | ||
13 | -// //DataUserSearch 搜索用户列表 | ||
14 | -type DataUserSearch struct { | 26 | + // //DataUserSearch 搜索用户列表 |
27 | + DataUserSearch struct { | ||
15 | Count int `json:"count"` | 28 | Count int `json:"count"` |
16 | Users []struct { | 29 | Users []struct { |
17 | UserID int `json:"userId"` | 30 | UserID int `json:"userId"` |
@@ -19,6 +32,7 @@ type DataUserSearch struct { | @@ -19,6 +32,7 @@ type DataUserSearch struct { | ||
19 | UserBaseID int `json:"userBaseId"` | 32 | UserBaseID int `json:"userBaseId"` |
20 | UserType int `json:"userType"` | 33 | UserType int `json:"userType"` |
21 | UserCode string `json:"userCode"` | 34 | UserCode string `json:"userCode"` |
35 | + UserName string `json:"userName"` | ||
22 | OrganizationID int `json:"organizationId"` | 36 | OrganizationID int `json:"organizationId"` |
23 | DepartmentID int `json:"departmentId"` | 37 | DepartmentID int `json:"departmentId"` |
24 | UserOrg []struct { | 38 | UserOrg []struct { |
@@ -43,4 +57,167 @@ type DataUserSearch struct { | @@ -43,4 +57,167 @@ type DataUserSearch struct { | ||
43 | DepName string `json:"depName"` | 57 | DepName string `json:"depName"` |
44 | } `json:"ext"` | 58 | } `json:"ext"` |
45 | } `json:"users"` | 59 | } `json:"users"` |
46 | -} | 60 | + } |
61 | +) | ||
62 | + | ||
63 | +//创建用户 | ||
64 | +type ( | ||
65 | + ReqCreateUser struct { | ||
66 | + // 企业id | ||
67 | + CompanyId int64 `json:"companyId"` | ||
68 | + // 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加) | ||
69 | + UserType int `json:"userType"` | ||
70 | + // 用户编号 企业内标识 | ||
71 | + UserCode string ` json:"userCode" ` | ||
72 | + // 组织机构 | ||
73 | + OrganizationId int64 `json:"organizationId,omitempty" ` | ||
74 | + // 所属部门 | ||
75 | + DepartmentId int64 `json:"departmentId,omitempty" ` | ||
76 | + // 用户关联的组织 | ||
77 | + UserOrg []int64 `json:"userOrg,omitempty"` | ||
78 | + // 用户关联的角色 | ||
79 | + UserRole []int64 `json:"userRole,omitempty"` | ||
80 | + // 共创公司 | ||
81 | + CooperationCompany string `json:"cooperationCompany,omitempty"` | ||
82 | + // 共创到期时间 (yyyy-MM-dd) | ||
83 | + CooperationDeadline time.Time ` json:"cooperationDeadline,omitempty"` | ||
84 | + // 启用状态(启用:1 禁用:2) | ||
85 | + EnableStatus int ` json:"enableStatus,omitempty"` | ||
86 | + // 密码 | ||
87 | + Password string ` json:"password" ` | ||
88 | + // 用户姓名 | ||
89 | + UserName string `json:"userName"` | ||
90 | + // 手机号码 | ||
91 | + Phone string `json:"phone" ` | ||
92 | + // 头像 | ||
93 | + Avatar string `json:"avatar"` | ||
94 | + // 邮箱 | ||
95 | + Email string `json:"email"` | ||
96 | + } | ||
97 | + DataCreateUser struct { | ||
98 | + } | ||
99 | +) | ||
100 | + | ||
101 | +//更新用户 | ||
102 | +type ( | ||
103 | + ReqUpdateUser struct { | ||
104 | + // 企业id | ||
105 | + CompanyId int64 `json:"companyId"` | ||
106 | + // 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加) | ||
107 | + UserType int `json:"userType"` | ||
108 | + // 用户编号 企业内标识 | ||
109 | + UserCode string ` json:"userCode" ` | ||
110 | + // 组织机构 | ||
111 | + OrganizationId int64 `json:"organizationId,omitempty" ` | ||
112 | + // 所属部门 | ||
113 | + DepartmentId int64 `json:"departmentId,omitempty" ` | ||
114 | + // 用户关联的组织 | ||
115 | + UserOrg []int64 `json:"userOrg,omitempty"` | ||
116 | + // 用户关联的角色 | ||
117 | + UserRole []int64 `json:"userRole,omitempty"` | ||
118 | + // 共创公司 | ||
119 | + CooperationCompany string `json:"cooperationCompany,omitempty"` | ||
120 | + // 共创到期时间 (yyyy-MM-dd) | ||
121 | + CooperationDeadline time.Time ` json:"cooperationDeadline,omitempty"` | ||
122 | + // 启用状态(启用:1 禁用:2) | ||
123 | + EnableStatus int ` json:"enableStatus,omitempty"` | ||
124 | + // 密码 | ||
125 | + Password string ` json:"password" ` | ||
126 | + // 用户姓名 | ||
127 | + UserName string `json:"userName"` | ||
128 | + // 手机号码 | ||
129 | + Phone string `json:"phone" ` | ||
130 | + // 头像 | ||
131 | + Avatar string `json:"avatar"` | ||
132 | + // 邮箱 | ||
133 | + Email string `json:"email"` | ||
134 | + } | ||
135 | + | ||
136 | + DataUpdateUser struct { | ||
137 | + } | ||
138 | +) | ||
139 | + | ||
140 | +//获取用户 | ||
141 | +type ( | ||
142 | + ReqGateUser struct { | ||
143 | + UserId int64 `json:"userId"` | ||
144 | + } | ||
145 | + | ||
146 | + DataGateUser struct { | ||
147 | + } | ||
148 | +) | ||
149 | + | ||
150 | +//删除用户 | ||
151 | +type ( | ||
152 | + ReqDeleteUser struct { | ||
153 | + UserId int64 `json:"userId"` | ||
154 | + } | ||
155 | + | ||
156 | + DataDeleteUser struct { | ||
157 | + } | ||
158 | +) | ||
159 | + | ||
160 | +//批量修改用户启用状态 | ||
161 | +type ( | ||
162 | + ReqBatchEnableUser struct { | ||
163 | + UserId int64 `json:"userId"` | ||
164 | + EnableStatus int `json:"enableStatus"` | ||
165 | + } | ||
166 | + | ||
167 | + DataBatchEnableUser struct { | ||
168 | + } | ||
169 | +) | ||
170 | + | ||
171 | +//批量重置密码 | ||
172 | +type ( | ||
173 | + ReqBatchResetPasswordUser struct { | ||
174 | + Password string | ||
175 | + UserIds []int64 | ||
176 | + } | ||
177 | + DataBatchResetPasswordUser struct { | ||
178 | + } | ||
179 | +) | ||
180 | + | ||
181 | +//创建共创用户 | ||
182 | +type ( | ||
183 | + ReqCreateCooperatorUser struct { | ||
184 | + } | ||
185 | + DataCreateCooperatorUser struct { | ||
186 | + } | ||
187 | +) | ||
188 | + | ||
189 | +//更新共创用户 | ||
190 | +type ( | ||
191 | + ReqUpdateCooperatorUser struct { | ||
192 | + UserId int64 `json:"userId"` | ||
193 | + } | ||
194 | + DataUpdateCooperatorUser struct { | ||
195 | + } | ||
196 | +) | ||
197 | + | ||
198 | +//获取用户概要数据 | ||
199 | +type ( | ||
200 | + ReqUserProfile struct { | ||
201 | + UserId int64 `json:"userId"` | ||
202 | + } | ||
203 | + DataUserProfile struct { | ||
204 | + } | ||
205 | +) | ||
206 | + | ||
207 | +//更新用户基础信息数据 | ||
208 | +type ( | ||
209 | + ReqUserUpdateBaseInfo struct { | ||
210 | + UserId int64 `json:"userId"` | ||
211 | + } | ||
212 | + DataUserUpdateBaseInfo struct { | ||
213 | + } | ||
214 | +) | ||
215 | + | ||
216 | +//返回用户有权限的菜单 | ||
217 | +type ( | ||
218 | + ReqUserAccessMenus struct { | ||
219 | + UserId int64 `json:"userId"` | ||
220 | + } | ||
221 | + DataUserAccessMenus struct { | ||
222 | + } | ||
223 | +) |
pkg/util/jtime/unix_time.go
0 → 100644
1 | +package jtime | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "strconv" | ||
6 | + "time" | ||
7 | +) | ||
8 | + | ||
9 | +type UnixTimeSecond time.Time | ||
10 | + | ||
11 | +// MarshalJSON implements json.Marshaler. | ||
12 | +func (t UnixTimeSecond) MarshalJSON() ([]byte, error) { | ||
13 | + stamp := fmt.Sprintf("%d", time.Time(t).Unix()) | ||
14 | + return []byte(stamp), nil | ||
15 | +} | ||
16 | + | ||
17 | +// MarshalJSON implements json.Unmarshaler. | ||
18 | +func (t UnixTimeSecond) UnmarshalJSON(v []byte) error { | ||
19 | + str := string(v) | ||
20 | + number, err := strconv.Atoi(str) | ||
21 | + if err != nil { | ||
22 | + return fmt.Errorf("时间类型需要使用时间戳传参:%w", err) | ||
23 | + } | ||
24 | + t = UnixTimeSecond(time.Unix(int64(number), 0)) | ||
25 | + return nil | ||
26 | +} |
-
请 注册 或 登录 后发表评论