作者 yangfu

用户服务修改

{"F:\\go\\src\\allied-creation\\allied-creation-gateway\\pkg\\port\\beego\\routers":1627694567421282600}
\ No newline at end of file
{"F:\\go\\src\\allied-creation\\allied-creation-gateway\\pkg\\port\\beego\\routers":1627702781113454000}
\ No newline at end of file
... ...
... ... @@ -11,7 +11,7 @@ type OrgEnableCommand struct {
//操作人
Operator domain.Operator `json:"-"`
OrgId string `json:"orgId,omitempty"`
Status int `json:"status,omitempty"`
Status int `json:"orgStatus,omitempty"`
}
func (orgEnableCommand *OrgEnableCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -7,5 +7,5 @@ type OrgItem struct {
IsOrg int `json:"isOrg"`
OrgCode string `json:"orgCode"`
ParentDepName string `json:"parentDepName"`
OrgStatus int `json:"orgStatus"`
}
... ...
... ... @@ -12,7 +12,7 @@ type OrgListQuery struct {
Operator domain.Operator `json:"-"`
OrgCode string `json:"OrgCode"`
DepName string `json:"depName"`
ParentId int `json:"parentId"`
ParentId string `json:"parentId"`
}
func (orgListQuery *OrgListQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -88,6 +88,7 @@ func (orgsService *OrgsService) OrgList(orgListQuery *query.OrgListQuery) (inter
orgListQuery.Operator.CompanyId,
orgListQuery.Operator.OrgId,
orgListQuery.Operator.UserId)
parentOrgId, _ := strconv.Atoi(orgListQuery.ParentId)
result, err := creationUserGateway.OrgSearch(allied_creation_user.ReqOrgSearch{
CompanyId: int(orgListQuery.Operator.CompanyId),
DepName: orgListQuery.DepName,
... ... @@ -95,7 +96,7 @@ func (orgsService *OrgsService) OrgList(orgListQuery *query.OrgListQuery) (inter
Limit: 0,
Offset: 0,
OrgCode: orgListQuery.OrgCode,
ParentId: orgListQuery.ParentId,
ParentId: parentOrgId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -112,6 +113,7 @@ func (orgsService *OrgsService) OrgList(orgListQuery *query.OrgListQuery) (inter
IsOrg: v.IsOrg,
OrgCode: v.OrgCode,
ParentDepName: v.Ext.ParentDepName,
OrgStatus: v.OrgStatus,
}
dataList = append(dataList, item)
}
... ...
... ... @@ -11,7 +11,7 @@ type CompanyUserEnableCommand struct {
//操作人
Operator domain.Operator `json:"-"`
//用户id
UsersIds []int64 `json:"usersIds,omitempty"`
UsersIds []string `json:"usersIds,omitempty"`
// 启用状态(启用:1 禁用:2)
EnableStatus int `json:"enableStatus,omitempty"`
}
... ...
... ... @@ -10,7 +10,7 @@ import (
type CompanyUserResetPasswordCommand struct {
//操作人
Operator domain.Operator `json:"-"`
UsersIds []int64 `json:"usersIds" valid:"Required"`
UsersIds []string `json:"usersIds" valid:"Required"`
}
func (companyUserResetPasswordCommand *CompanyUserResetPasswordCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -11,7 +11,7 @@ type CooperationUserEnableCommand struct {
//操作人
Operator domain.Operator `json:"-"`
//用户id
UsersIds []int64 `json:"usersIds,omitempty"`
UsersIds []string `json:"usersIds,omitempty"`
// 启用状态(启用:1 禁用:2)
EnableStatus int `json:"enableStatus,omitempty"`
}
... ...
... ... @@ -11,7 +11,7 @@ type CooperationUserGetQuery struct {
//操作人
Operator domain.Operator `json:"-"`
// 用户编号
UsersId string `json:"usersId" valid:"Required"`
UserId string `json:"userId" valid:"Required"`
}
func (cooperationUserGetQuery *CooperationUserGetQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -130,7 +130,7 @@ func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command.
Phone: companyUserAddCommand.Phone,
Avatar: companyUserAddCommand.Avator,
Email: companyUserAddCommand.Avator,
Password: "", //TODO 填充密码
Password: "123456", //TODO 填充密码
})
data := struct {
... ... @@ -149,10 +149,19 @@ func (usersService *UsersService) CompanyUserEnable(companyUserEnableCommand *co
companyUserEnableCommand.Operator.CompanyId,
companyUserEnableCommand.Operator.OrgId,
companyUserEnableCommand.Operator.UserId)
var userIds []int64
for i := range companyUserEnableCommand.UsersIds {
id, _ := strconv.Atoi(companyUserEnableCommand.UsersIds[i])
userIds = append(userIds, int64(id))
}
_, err := creationUserGateway.UserBatchEnable(allied_creation_user.ReqBatchEnableUser{
UserIds: companyUserEnableCommand.UsersIds,
UserIds: userIds,
EnableStatus: companyUserEnableCommand.EnableStatus,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return companyUserEnableCommand, err
}
... ... @@ -171,7 +180,7 @@ func (usersService *UsersService) CompanyUserList(companyUserListQuery *query.Co
})
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
//数据转换
cnt := int64(result.Count)
... ... @@ -200,10 +209,18 @@ func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPassw
companyUserResetPasswordCommand.Operator.CompanyId,
companyUserResetPasswordCommand.Operator.OrgId,
companyUserResetPasswordCommand.Operator.UserId)
var userIds []int64
for i := range companyUserResetPasswordCommand.UsersIds {
id, _ := strconv.Atoi(companyUserResetPasswordCommand.UsersIds[i])
userIds = append(userIds, int64(id))
}
_, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
Password: "", //TODO 填充密码
UserIds: companyUserResetPasswordCommand.UsersIds,
Password: "123456", //TODO 填充密码
UserIds: userIds,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return companyUserResetPasswordCommand, err
}
... ... @@ -244,6 +261,9 @@ func (usersService *UsersService) CompanyUserUpdate(companyUserUpdateCommand *co
Avatar: companyUserUpdateCommand.Avator,
Email: companyUserUpdateCommand.Avator,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return companyUserUpdateCommand, err
}
... ... @@ -265,6 +285,9 @@ func (usersService *UsersService) CooperationUserAdd(cooperationUserAddCommand *
Phone: cooperationUserAddCommand.Phone,
Password: "123456", //TODO 填充默认密码
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
data := struct {
UserId string `json:"userId"`
command.CooperationUserAddCommand
... ... @@ -281,10 +304,18 @@ func (usersService *UsersService) CooperationUserEnable(cooperationUserEnableCom
cooperationUserEnableCommand.Operator.CompanyId,
cooperationUserEnableCommand.Operator.OrgId,
cooperationUserEnableCommand.Operator.UserId)
var userIds []int64
for i := range cooperationUserEnableCommand.UsersIds {
id, _ := strconv.Atoi(cooperationUserEnableCommand.UsersIds[i])
userIds = append(userIds, int64(id))
}
_, err := creationUserGateway.UserBatchEnable(allied_creation_user.ReqBatchEnableUser{
UserIds: cooperationUserEnableCommand.UsersIds,
UserIds: userIds,
EnableStatus: cooperationUserEnableCommand.EnableStatus,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return cooperationUserEnableCommand, err
}
... ... @@ -294,12 +325,12 @@ func (usersService *UsersService) CooperationUserGet(cooperationUserGetQuery *qu
cooperationUserGetQuery.Operator.CompanyId,
cooperationUserGetQuery.Operator.OrgId,
cooperationUserGetQuery.Operator.UserId)
userId, _ := strconv.Atoi(cooperationUserGetQuery.UsersId)
userId, _ := strconv.Atoi(cooperationUserGetQuery.UserId)
result, err := creationUserGateway.UserGet(allied_creation_user.ReqGateUser{
UserId: userId,
})
if err != nil {
return nil, err
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
deadline := result.CooperationInfo.CooperationDeadline.Unix()
userInfo := dto.CooperationUserInfo{
... ... @@ -320,14 +351,15 @@ func (usersService *UsersService) CooperationUserGet(cooperationUserGetQuery *qu
func (usersService *UsersService) CooperationUserList(cooperationUserListQuery *query.CooperationUserListQuery) (int64, interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(0, 0, 0)
result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
Offset: (cooperationUserListQuery.PageNumber - 1) * cooperationUserListQuery.PageSize,
Limit: cooperationUserListQuery.PageSize,
CompanyId: cooperationUserListQuery.Operator.CompanyId,
OrganizationId: cooperationUserListQuery.Operator.OrgId,
DepartmentId: 0,
UserName: cooperationUserListQuery.UserName,
DepName: "",
Phone: "",
Offset: (cooperationUserListQuery.PageNumber - 1) * cooperationUserListQuery.PageSize,
Limit: cooperationUserListQuery.PageSize,
CompanyId: cooperationUserListQuery.Operator.CompanyId,
OrganizationId: cooperationUserListQuery.Operator.OrgId,
DepartmentId: 0,
UserName: cooperationUserListQuery.UserName,
CooperationCompany: cooperationUserListQuery.CooperationCompany,
DepName: "",
Phone: "",
})
var (
listData []dto.CooperationUserItem
... ... @@ -361,6 +393,9 @@ func (usersService *UsersService) CooperationUserResetPassword(cooperationUserRe
Password: "", //TODO 填充密码
UserIds: cooperationUserResetPasswordCommand.UsersIds,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return cooperationUserResetPasswordCommand, err
}
... ... @@ -382,6 +417,9 @@ func (usersService *UsersService) CooperationUserUpdate(cooperationUserUpdateCom
OrgId: cooperationUserUpdateCommand.Operator.OrgId,
Phone: cooperationUserUpdateCommand.Phone,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return cooperationUserUpdateCommand, err
}
... ... @@ -401,7 +439,7 @@ func (usersService *UsersService) SelectorCompanyOrg(selectorQuery *query.Compan
ParentId: 0,
})
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var (
dataList []dto.UserOrg
... ... @@ -431,7 +469,7 @@ func (usersService *UsersService) SelectorCompanyRole(selectorQuery *query.Compa
RoleName: selectorQuery.RoleName,
})
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return 0, nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
var (
dataList []dto.UserRole
... ...
... ... @@ -38,10 +38,10 @@ type (
DataRoleSearch struct {
Count int64
Roles []struct {
AccessMenus []int `json:"accessMenus"`
CompanyID Int64String `json:"companyId"`
CreatedAt string `json:"createdAt"`
Desc string `json:"desc"`
AccessMenus []Int64String `json:"accessMenus"`
CompanyID Int64String `json:"companyId"`
CreatedAt string `json:"createdAt"`
Desc string `json:"desc"`
Ext struct {
DepName string `json:"depName"`
OrgName string `json:"orgName"`
... ...
... ... @@ -72,10 +72,16 @@ type (
DepartmentId int64 `json:"departmentId"`
// 用户姓名
UserName string `json:"userName"`
// 共创公司
CooperationCompany string `cname:"共创公司" json:"cooperationCompany,omitempty"`
// 部门名称
DepName string `json:"depName"`
// 手机号码
Phone string `json:"phone"`
// 用户类型
UserType int `cname:"用户类型 1:普通用户 2:共创用户 1024:企业注册用户" json:"userType,omitempty"`
// 实时拉取数据 (获取最新的)
PullRealTime bool `cname:"拉取最新数据" json:"pullRealTime,omitempty"`
}
//DataUserSearch 搜索用户列表
... ...
... ... @@ -48,3 +48,12 @@ func (controller *OrgsController) OrgGet() {
data, err := orgsService.OrgGet(orgGetQuery)
controller.Response(data, err)
}
func (controller *OrgsController) OrgEnable() {
orgsService := service.NewOrgsService(nil)
orgEnableCommand := &command.OrgEnableCommand{}
controller.Unmarshal(orgEnableCommand)
orgEnableCommand.Operator = controller.GetOperator()
data, err := orgsService.OrgEnable(orgEnableCommand)
controller.Response(data, err)
}
... ...
... ... @@ -96,7 +96,7 @@ func (controller *UsersController) CooperationUserGet() {
usersService := service.NewUsersService(nil)
cooperationUserGetQuery := &query.CooperationUserGetQuery{}
userId := controller.GetString(":userId")
cooperationUserGetQuery.UsersId = userId
cooperationUserGetQuery.UserId = userId
cooperationUserGetQuery.Operator = controller.GetOperator()
data, err := usersService.CooperationUserGet(cooperationUserGetQuery)
controller.Response(data, err)
... ...
... ... @@ -10,4 +10,5 @@ func init() {
web.Router("/v1/web/orgs/:orgId", &web_client.OrgsController{}, "Put:OrgUpdate")
web.Router("/v1/web/orgs/search", &web_client.OrgsController{}, "Post:OrgList")
web.Router("/v1/web/orgs/:orgId", &web_client.OrgsController{}, "Get:OrgGet")
web.Router("/v1/web/orgs/enable", &web_client.OrgsController{}, "Post:OrgEnable")
}
... ...