作者 yangfu

用户服务修改

1 -{"F:\\go\\src\\allied-creation\\allied-creation-gateway\\pkg\\port\\beego\\routers":1627694567421282600}  
  1 +{"F:\\go\\src\\allied-creation\\allied-creation-gateway\\pkg\\port\\beego\\routers":1627702781113454000}
@@ -11,7 +11,7 @@ type OrgEnableCommand struct { @@ -11,7 +11,7 @@ type OrgEnableCommand struct {
11 //操作人 11 //操作人
12 Operator domain.Operator `json:"-"` 12 Operator domain.Operator `json:"-"`
13 OrgId string `json:"orgId,omitempty"` 13 OrgId string `json:"orgId,omitempty"`
14 - Status int `json:"status,omitempty"` 14 + Status int `json:"orgStatus,omitempty"`
15 } 15 }
16 16
17 func (orgEnableCommand *OrgEnableCommand) Valid(validation *validation.Validation) { 17 func (orgEnableCommand *OrgEnableCommand) Valid(validation *validation.Validation) {
@@ -7,5 +7,5 @@ type OrgItem struct { @@ -7,5 +7,5 @@ type OrgItem struct {
7 IsOrg int `json:"isOrg"` 7 IsOrg int `json:"isOrg"`
8 OrgCode string `json:"orgCode"` 8 OrgCode string `json:"orgCode"`
9 ParentDepName string `json:"parentDepName"` 9 ParentDepName string `json:"parentDepName"`
  10 + OrgStatus int `json:"orgStatus"`
10 } 11 }
11 -  
@@ -12,7 +12,7 @@ type OrgListQuery struct { @@ -12,7 +12,7 @@ type OrgListQuery struct {
12 Operator domain.Operator `json:"-"` 12 Operator domain.Operator `json:"-"`
13 OrgCode string `json:"OrgCode"` 13 OrgCode string `json:"OrgCode"`
14 DepName string `json:"depName"` 14 DepName string `json:"depName"`
15 - ParentId int `json:"parentId"` 15 + ParentId string `json:"parentId"`
16 } 16 }
17 17
18 func (orgListQuery *OrgListQuery) Valid(validation *validation.Validation) { 18 func (orgListQuery *OrgListQuery) Valid(validation *validation.Validation) {
@@ -88,6 +88,7 @@ func (orgsService *OrgsService) OrgList(orgListQuery *query.OrgListQuery) (inter @@ -88,6 +88,7 @@ func (orgsService *OrgsService) OrgList(orgListQuery *query.OrgListQuery) (inter
88 orgListQuery.Operator.CompanyId, 88 orgListQuery.Operator.CompanyId,
89 orgListQuery.Operator.OrgId, 89 orgListQuery.Operator.OrgId,
90 orgListQuery.Operator.UserId) 90 orgListQuery.Operator.UserId)
  91 + parentOrgId, _ := strconv.Atoi(orgListQuery.ParentId)
91 result, err := creationUserGateway.OrgSearch(allied_creation_user.ReqOrgSearch{ 92 result, err := creationUserGateway.OrgSearch(allied_creation_user.ReqOrgSearch{
92 CompanyId: int(orgListQuery.Operator.CompanyId), 93 CompanyId: int(orgListQuery.Operator.CompanyId),
93 DepName: orgListQuery.DepName, 94 DepName: orgListQuery.DepName,
@@ -95,7 +96,7 @@ func (orgsService *OrgsService) OrgList(orgListQuery *query.OrgListQuery) (inter @@ -95,7 +96,7 @@ func (orgsService *OrgsService) OrgList(orgListQuery *query.OrgListQuery) (inter
95 Limit: 0, 96 Limit: 0,
96 Offset: 0, 97 Offset: 0,
97 OrgCode: orgListQuery.OrgCode, 98 OrgCode: orgListQuery.OrgCode,
98 - ParentId: orgListQuery.ParentId, 99 + ParentId: parentOrgId,
99 }) 100 })
100 if err != nil { 101 if err != nil {
101 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 102 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -112,6 +113,7 @@ func (orgsService *OrgsService) OrgList(orgListQuery *query.OrgListQuery) (inter @@ -112,6 +113,7 @@ func (orgsService *OrgsService) OrgList(orgListQuery *query.OrgListQuery) (inter
112 IsOrg: v.IsOrg, 113 IsOrg: v.IsOrg,
113 OrgCode: v.OrgCode, 114 OrgCode: v.OrgCode,
114 ParentDepName: v.Ext.ParentDepName, 115 ParentDepName: v.Ext.ParentDepName,
  116 + OrgStatus: v.OrgStatus,
115 } 117 }
116 dataList = append(dataList, item) 118 dataList = append(dataList, item)
117 } 119 }
@@ -11,7 +11,7 @@ type CompanyUserEnableCommand struct { @@ -11,7 +11,7 @@ type CompanyUserEnableCommand struct {
11 //操作人 11 //操作人
12 Operator domain.Operator `json:"-"` 12 Operator domain.Operator `json:"-"`
13 //用户id 13 //用户id
14 - UsersIds []int64 `json:"usersIds,omitempty"` 14 + UsersIds []string `json:"usersIds,omitempty"`
15 // 启用状态(启用:1 禁用:2) 15 // 启用状态(启用:1 禁用:2)
16 EnableStatus int `json:"enableStatus,omitempty"` 16 EnableStatus int `json:"enableStatus,omitempty"`
17 } 17 }
@@ -10,7 +10,7 @@ import ( @@ -10,7 +10,7 @@ import (
10 type CompanyUserResetPasswordCommand struct { 10 type CompanyUserResetPasswordCommand struct {
11 //操作人 11 //操作人
12 Operator domain.Operator `json:"-"` 12 Operator domain.Operator `json:"-"`
13 - UsersIds []int64 `json:"usersIds" valid:"Required"` 13 + UsersIds []string `json:"usersIds" valid:"Required"`
14 } 14 }
15 15
16 func (companyUserResetPasswordCommand *CompanyUserResetPasswordCommand) Valid(validation *validation.Validation) { 16 func (companyUserResetPasswordCommand *CompanyUserResetPasswordCommand) Valid(validation *validation.Validation) {
@@ -11,7 +11,7 @@ type CooperationUserEnableCommand struct { @@ -11,7 +11,7 @@ type CooperationUserEnableCommand struct {
11 //操作人 11 //操作人
12 Operator domain.Operator `json:"-"` 12 Operator domain.Operator `json:"-"`
13 //用户id 13 //用户id
14 - UsersIds []int64 `json:"usersIds,omitempty"` 14 + UsersIds []string `json:"usersIds,omitempty"`
15 // 启用状态(启用:1 禁用:2) 15 // 启用状态(启用:1 禁用:2)
16 EnableStatus int `json:"enableStatus,omitempty"` 16 EnableStatus int `json:"enableStatus,omitempty"`
17 } 17 }
@@ -11,7 +11,7 @@ type CooperationUserGetQuery struct { @@ -11,7 +11,7 @@ type CooperationUserGetQuery struct {
11 //操作人 11 //操作人
12 Operator domain.Operator `json:"-"` 12 Operator domain.Operator `json:"-"`
13 // 用户编号 13 // 用户编号
14 - UsersId string `json:"usersId" valid:"Required"` 14 + UserId string `json:"userId" valid:"Required"`
15 } 15 }
16 16
17 func (cooperationUserGetQuery *CooperationUserGetQuery) Valid(validation *validation.Validation) { 17 func (cooperationUserGetQuery *CooperationUserGetQuery) Valid(validation *validation.Validation) {
@@ -130,7 +130,7 @@ func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command. @@ -130,7 +130,7 @@ func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command.
130 Phone: companyUserAddCommand.Phone, 130 Phone: companyUserAddCommand.Phone,
131 Avatar: companyUserAddCommand.Avator, 131 Avatar: companyUserAddCommand.Avator,
132 Email: companyUserAddCommand.Avator, 132 Email: companyUserAddCommand.Avator,
133 - Password: "", //TODO 填充密码 133 + Password: "123456", //TODO 填充密码
134 }) 134 })
135 135
136 data := struct { 136 data := struct {
@@ -149,10 +149,19 @@ func (usersService *UsersService) CompanyUserEnable(companyUserEnableCommand *co @@ -149,10 +149,19 @@ func (usersService *UsersService) CompanyUserEnable(companyUserEnableCommand *co
149 companyUserEnableCommand.Operator.CompanyId, 149 companyUserEnableCommand.Operator.CompanyId,
150 companyUserEnableCommand.Operator.OrgId, 150 companyUserEnableCommand.Operator.OrgId,
151 companyUserEnableCommand.Operator.UserId) 151 companyUserEnableCommand.Operator.UserId)
  152 +
  153 + var userIds []int64
  154 + for i := range companyUserEnableCommand.UsersIds {
  155 + id, _ := strconv.Atoi(companyUserEnableCommand.UsersIds[i])
  156 + userIds = append(userIds, int64(id))
  157 + }
152 _, err := creationUserGateway.UserBatchEnable(allied_creation_user.ReqBatchEnableUser{ 158 _, err := creationUserGateway.UserBatchEnable(allied_creation_user.ReqBatchEnableUser{
153 - UserIds: companyUserEnableCommand.UsersIds, 159 + UserIds: userIds,
154 EnableStatus: companyUserEnableCommand.EnableStatus, 160 EnableStatus: companyUserEnableCommand.EnableStatus,
155 }) 161 })
  162 + if err != nil {
  163 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  164 + }
156 return companyUserEnableCommand, err 165 return companyUserEnableCommand, err
157 } 166 }
158 167
@@ -171,7 +180,7 @@ func (usersService *UsersService) CompanyUserList(companyUserListQuery *query.Co @@ -171,7 +180,7 @@ func (usersService *UsersService) CompanyUserList(companyUserListQuery *query.Co
171 }) 180 })
172 181
173 if err != nil { 182 if err != nil {
174 - return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 183 + return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
175 } 184 }
176 //数据转换 185 //数据转换
177 cnt := int64(result.Count) 186 cnt := int64(result.Count)
@@ -200,10 +209,18 @@ func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPassw @@ -200,10 +209,18 @@ func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPassw
200 companyUserResetPasswordCommand.Operator.CompanyId, 209 companyUserResetPasswordCommand.Operator.CompanyId,
201 companyUserResetPasswordCommand.Operator.OrgId, 210 companyUserResetPasswordCommand.Operator.OrgId,
202 companyUserResetPasswordCommand.Operator.UserId) 211 companyUserResetPasswordCommand.Operator.UserId)
  212 + var userIds []int64
  213 + for i := range companyUserResetPasswordCommand.UsersIds {
  214 + id, _ := strconv.Atoi(companyUserResetPasswordCommand.UsersIds[i])
  215 + userIds = append(userIds, int64(id))
  216 + }
203 _, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{ 217 _, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
204 - Password: "", //TODO 填充密码  
205 - UserIds: companyUserResetPasswordCommand.UsersIds, 218 + Password: "123456", //TODO 填充密码
  219 + UserIds: userIds,
206 }) 220 })
  221 + if err != nil {
  222 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  223 + }
207 return companyUserResetPasswordCommand, err 224 return companyUserResetPasswordCommand, err
208 } 225 }
209 226
@@ -244,6 +261,9 @@ func (usersService *UsersService) CompanyUserUpdate(companyUserUpdateCommand *co @@ -244,6 +261,9 @@ func (usersService *UsersService) CompanyUserUpdate(companyUserUpdateCommand *co
244 Avatar: companyUserUpdateCommand.Avator, 261 Avatar: companyUserUpdateCommand.Avator,
245 Email: companyUserUpdateCommand.Avator, 262 Email: companyUserUpdateCommand.Avator,
246 }) 263 })
  264 + if err != nil {
  265 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  266 + }
247 return companyUserUpdateCommand, err 267 return companyUserUpdateCommand, err
248 } 268 }
249 269
@@ -265,6 +285,9 @@ func (usersService *UsersService) CooperationUserAdd(cooperationUserAddCommand * @@ -265,6 +285,9 @@ func (usersService *UsersService) CooperationUserAdd(cooperationUserAddCommand *
265 Phone: cooperationUserAddCommand.Phone, 285 Phone: cooperationUserAddCommand.Phone,
266 Password: "123456", //TODO 填充默认密码 286 Password: "123456", //TODO 填充默认密码
267 }) 287 })
  288 + if err != nil {
  289 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  290 + }
268 data := struct { 291 data := struct {
269 UserId string `json:"userId"` 292 UserId string `json:"userId"`
270 command.CooperationUserAddCommand 293 command.CooperationUserAddCommand
@@ -281,10 +304,18 @@ func (usersService *UsersService) CooperationUserEnable(cooperationUserEnableCom @@ -281,10 +304,18 @@ func (usersService *UsersService) CooperationUserEnable(cooperationUserEnableCom
281 cooperationUserEnableCommand.Operator.CompanyId, 304 cooperationUserEnableCommand.Operator.CompanyId,
282 cooperationUserEnableCommand.Operator.OrgId, 305 cooperationUserEnableCommand.Operator.OrgId,
283 cooperationUserEnableCommand.Operator.UserId) 306 cooperationUserEnableCommand.Operator.UserId)
  307 + var userIds []int64
  308 + for i := range cooperationUserEnableCommand.UsersIds {
  309 + id, _ := strconv.Atoi(cooperationUserEnableCommand.UsersIds[i])
  310 + userIds = append(userIds, int64(id))
  311 + }
284 _, err := creationUserGateway.UserBatchEnable(allied_creation_user.ReqBatchEnableUser{ 312 _, err := creationUserGateway.UserBatchEnable(allied_creation_user.ReqBatchEnableUser{
285 - UserIds: cooperationUserEnableCommand.UsersIds, 313 + UserIds: userIds,
286 EnableStatus: cooperationUserEnableCommand.EnableStatus, 314 EnableStatus: cooperationUserEnableCommand.EnableStatus,
287 }) 315 })
  316 + if err != nil {
  317 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  318 + }
288 return cooperationUserEnableCommand, err 319 return cooperationUserEnableCommand, err
289 } 320 }
290 321
@@ -294,12 +325,12 @@ func (usersService *UsersService) CooperationUserGet(cooperationUserGetQuery *qu @@ -294,12 +325,12 @@ func (usersService *UsersService) CooperationUserGet(cooperationUserGetQuery *qu
294 cooperationUserGetQuery.Operator.CompanyId, 325 cooperationUserGetQuery.Operator.CompanyId,
295 cooperationUserGetQuery.Operator.OrgId, 326 cooperationUserGetQuery.Operator.OrgId,
296 cooperationUserGetQuery.Operator.UserId) 327 cooperationUserGetQuery.Operator.UserId)
297 - userId, _ := strconv.Atoi(cooperationUserGetQuery.UsersId) 328 + userId, _ := strconv.Atoi(cooperationUserGetQuery.UserId)
298 result, err := creationUserGateway.UserGet(allied_creation_user.ReqGateUser{ 329 result, err := creationUserGateway.UserGet(allied_creation_user.ReqGateUser{
299 UserId: userId, 330 UserId: userId,
300 }) 331 })
301 if err != nil { 332 if err != nil {
302 - return nil, err 333 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
303 } 334 }
304 deadline := result.CooperationInfo.CooperationDeadline.Unix() 335 deadline := result.CooperationInfo.CooperationDeadline.Unix()
305 userInfo := dto.CooperationUserInfo{ 336 userInfo := dto.CooperationUserInfo{
@@ -326,6 +357,7 @@ func (usersService *UsersService) CooperationUserList(cooperationUserListQuery * @@ -326,6 +357,7 @@ func (usersService *UsersService) CooperationUserList(cooperationUserListQuery *
326 OrganizationId: cooperationUserListQuery.Operator.OrgId, 357 OrganizationId: cooperationUserListQuery.Operator.OrgId,
327 DepartmentId: 0, 358 DepartmentId: 0,
328 UserName: cooperationUserListQuery.UserName, 359 UserName: cooperationUserListQuery.UserName,
  360 + CooperationCompany: cooperationUserListQuery.CooperationCompany,
329 DepName: "", 361 DepName: "",
330 Phone: "", 362 Phone: "",
331 }) 363 })
@@ -361,6 +393,9 @@ func (usersService *UsersService) CooperationUserResetPassword(cooperationUserRe @@ -361,6 +393,9 @@ func (usersService *UsersService) CooperationUserResetPassword(cooperationUserRe
361 Password: "", //TODO 填充密码 393 Password: "", //TODO 填充密码
362 UserIds: cooperationUserResetPasswordCommand.UsersIds, 394 UserIds: cooperationUserResetPasswordCommand.UsersIds,
363 }) 395 })
  396 + if err != nil {
  397 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  398 + }
364 return cooperationUserResetPasswordCommand, err 399 return cooperationUserResetPasswordCommand, err
365 } 400 }
366 401
@@ -382,6 +417,9 @@ func (usersService *UsersService) CooperationUserUpdate(cooperationUserUpdateCom @@ -382,6 +417,9 @@ func (usersService *UsersService) CooperationUserUpdate(cooperationUserUpdateCom
382 OrgId: cooperationUserUpdateCommand.Operator.OrgId, 417 OrgId: cooperationUserUpdateCommand.Operator.OrgId,
383 Phone: cooperationUserUpdateCommand.Phone, 418 Phone: cooperationUserUpdateCommand.Phone,
384 }) 419 })
  420 + if err != nil {
  421 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  422 + }
385 return cooperationUserUpdateCommand, err 423 return cooperationUserUpdateCommand, err
386 } 424 }
387 425
@@ -401,7 +439,7 @@ func (usersService *UsersService) SelectorCompanyOrg(selectorQuery *query.Compan @@ -401,7 +439,7 @@ func (usersService *UsersService) SelectorCompanyOrg(selectorQuery *query.Compan
401 ParentId: 0, 439 ParentId: 0,
402 }) 440 })
403 if err != nil { 441 if err != nil {
404 - return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 442 + return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
405 } 443 }
406 var ( 444 var (
407 dataList []dto.UserOrg 445 dataList []dto.UserOrg
@@ -431,7 +469,7 @@ func (usersService *UsersService) SelectorCompanyRole(selectorQuery *query.Compa @@ -431,7 +469,7 @@ func (usersService *UsersService) SelectorCompanyRole(selectorQuery *query.Compa
431 RoleName: selectorQuery.RoleName, 469 RoleName: selectorQuery.RoleName,
432 }) 470 })
433 if err != nil { 471 if err != nil {
434 - return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 472 + return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
435 } 473 }
436 var ( 474 var (
437 dataList []dto.UserRole 475 dataList []dto.UserRole
@@ -38,7 +38,7 @@ type ( @@ -38,7 +38,7 @@ type (
38 DataRoleSearch struct { 38 DataRoleSearch struct {
39 Count int64 39 Count int64
40 Roles []struct { 40 Roles []struct {
41 - AccessMenus []int `json:"accessMenus"` 41 + AccessMenus []Int64String `json:"accessMenus"`
42 CompanyID Int64String `json:"companyId"` 42 CompanyID Int64String `json:"companyId"`
43 CreatedAt string `json:"createdAt"` 43 CreatedAt string `json:"createdAt"`
44 Desc string `json:"desc"` 44 Desc string `json:"desc"`
@@ -72,10 +72,16 @@ type ( @@ -72,10 +72,16 @@ type (
72 DepartmentId int64 `json:"departmentId"` 72 DepartmentId int64 `json:"departmentId"`
73 // 用户姓名 73 // 用户姓名
74 UserName string `json:"userName"` 74 UserName string `json:"userName"`
  75 + // 共创公司
  76 + CooperationCompany string `cname:"共创公司" json:"cooperationCompany,omitempty"`
75 // 部门名称 77 // 部门名称
76 DepName string `json:"depName"` 78 DepName string `json:"depName"`
77 // 手机号码 79 // 手机号码
78 Phone string `json:"phone"` 80 Phone string `json:"phone"`
  81 + // 用户类型
  82 + UserType int `cname:"用户类型 1:普通用户 2:共创用户 1024:企业注册用户" json:"userType,omitempty"`
  83 + // 实时拉取数据 (获取最新的)
  84 + PullRealTime bool `cname:"拉取最新数据" json:"pullRealTime,omitempty"`
79 } 85 }
80 86
81 //DataUserSearch 搜索用户列表 87 //DataUserSearch 搜索用户列表
@@ -48,3 +48,12 @@ func (controller *OrgsController) OrgGet() { @@ -48,3 +48,12 @@ func (controller *OrgsController) OrgGet() {
48 data, err := orgsService.OrgGet(orgGetQuery) 48 data, err := orgsService.OrgGet(orgGetQuery)
49 controller.Response(data, err) 49 controller.Response(data, err)
50 } 50 }
  51 +
  52 +func (controller *OrgsController) OrgEnable() {
  53 + orgsService := service.NewOrgsService(nil)
  54 + orgEnableCommand := &command.OrgEnableCommand{}
  55 + controller.Unmarshal(orgEnableCommand)
  56 + orgEnableCommand.Operator = controller.GetOperator()
  57 + data, err := orgsService.OrgEnable(orgEnableCommand)
  58 + controller.Response(data, err)
  59 +}
@@ -96,7 +96,7 @@ func (controller *UsersController) CooperationUserGet() { @@ -96,7 +96,7 @@ func (controller *UsersController) CooperationUserGet() {
96 usersService := service.NewUsersService(nil) 96 usersService := service.NewUsersService(nil)
97 cooperationUserGetQuery := &query.CooperationUserGetQuery{} 97 cooperationUserGetQuery := &query.CooperationUserGetQuery{}
98 userId := controller.GetString(":userId") 98 userId := controller.GetString(":userId")
99 - cooperationUserGetQuery.UsersId = userId 99 + cooperationUserGetQuery.UserId = userId
100 cooperationUserGetQuery.Operator = controller.GetOperator() 100 cooperationUserGetQuery.Operator = controller.GetOperator()
101 data, err := usersService.CooperationUserGet(cooperationUserGetQuery) 101 data, err := usersService.CooperationUserGet(cooperationUserGetQuery)
102 controller.Response(data, err) 102 controller.Response(data, err)
@@ -10,4 +10,5 @@ func init() { @@ -10,4 +10,5 @@ func init() {
10 web.Router("/v1/web/orgs/:orgId", &web_client.OrgsController{}, "Put:OrgUpdate") 10 web.Router("/v1/web/orgs/:orgId", &web_client.OrgsController{}, "Put:OrgUpdate")
11 web.Router("/v1/web/orgs/search", &web_client.OrgsController{}, "Post:OrgList") 11 web.Router("/v1/web/orgs/search", &web_client.OrgsController{}, "Post:OrgList")
12 web.Router("/v1/web/orgs/:orgId", &web_client.OrgsController{}, "Get:OrgGet") 12 web.Router("/v1/web/orgs/:orgId", &web_client.OrgsController{}, "Get:OrgGet")
  13 + web.Router("/v1/web/orgs/enable", &web_client.OrgsController{}, "Post:OrgEnable")
13 } 14 }