|
|
package service
|
|
|
|
|
|
import (
|
|
|
"crypto/sha1"
|
|
|
"fmt"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_basic"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
|
...
|
...
|
@@ -102,6 +106,10 @@ func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command. |
|
|
orgId, _ := strconv.Atoi(companyUserAddCommand.OrgId)
|
|
|
userOrg := []int64{}
|
|
|
userRole := []int64{}
|
|
|
initPassword, _, err := usersService.GetInitPassword()
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
for _, v := range companyUserAddCommand.UserOrg {
|
|
|
id, err := strconv.Atoi(v.OrgId)
|
|
|
if err == nil {
|
...
|
...
|
@@ -129,7 +137,7 @@ func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command. |
|
|
Phone: companyUserAddCommand.Phone,
|
|
|
Avatar: companyUserAddCommand.Avatar,
|
|
|
Email: companyUserAddCommand.Email,
|
|
|
Password: "123456", //TODO 填充密码
|
|
|
Password: initPassword,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
...
|
...
|
@@ -213,14 +221,18 @@ func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPassw |
|
|
id, _ := strconv.Atoi(companyUserResetPasswordCommand.UserIds[i])
|
|
|
userIds = append(userIds, int64(id))
|
|
|
}
|
|
|
_, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
|
|
|
Password: "123456", //TODO 填充密码
|
|
|
initPassword, primitivePassword, err := usersService.GetInitPassword()
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
_, err = creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
|
|
|
Password: initPassword,
|
|
|
UserIds: userIds,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
return "123456", err
|
|
|
return primitivePassword, err
|
|
|
}
|
|
|
|
|
|
// 更新公司用户信息
|
...
|
...
|
@@ -268,6 +280,10 @@ func (usersService *UsersService) CompanyUserUpdate(companyUserUpdateCommand *co |
|
|
func (usersService *UsersService) CooperationUserAdd(cooperationUserAddCommand *command.CooperationUserAddCommand) (interface{}, error) {
|
|
|
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
|
|
|
cooperationUserAddCommand.Operator)
|
|
|
initPassword, _, err := usersService.GetInitPassword()
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
result, err := creationUserGateway.CooperatorUserCreate(allied_creation_user.ReqCreateCooperatorUser{
|
|
|
CompanyId: cooperationUserAddCommand.Operator.CompanyId,
|
|
|
CooperationCompany: cooperationUserAddCommand.CooperationCompany,
|
...
|
...
|
@@ -279,7 +295,7 @@ func (usersService *UsersService) CooperationUserAdd(cooperationUserAddCommand * |
|
|
Avatar: cooperationUserAddCommand.Avatar,
|
|
|
OrgId: cooperationUserAddCommand.Operator.OrgId,
|
|
|
Phone: cooperationUserAddCommand.Phone,
|
|
|
Password: "123456", //TODO 填充默认密码
|
|
|
Password: initPassword,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
...
|
...
|
@@ -380,20 +396,23 @@ func (usersService *UsersService) CooperationUserList(cooperationUserListQuery * |
|
|
func (usersService *UsersService) CooperationUserResetPassword(cooperationUserResetPasswordCommand *command.CooperationUserResetPasswordCommand) (interface{}, error) {
|
|
|
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
|
|
|
cooperationUserResetPasswordCommand.Operator)
|
|
|
initPassword, primitivePassword, err := usersService.GetInitPassword()
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
var userIds []int64
|
|
|
for i := range cooperationUserResetPasswordCommand.UserIds {
|
|
|
id, _ := strconv.Atoi(cooperationUserResetPasswordCommand.UserIds[i])
|
|
|
userIds = append(userIds, int64(id))
|
|
|
}
|
|
|
_, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
|
|
|
Password: "123456", //TODO 填充密码
|
|
|
_, err = creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
|
|
|
Password: initPassword, //TODO 填充密码
|
|
|
UserIds: userIds,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
// TODO:返回消息提示 密码重置成功,初始密码为TL123456!
|
|
|
return "123456", err
|
|
|
return primitivePassword, err
|
|
|
}
|
|
|
|
|
|
// 编辑共创用户信息
|
...
|
...
|
@@ -509,3 +528,21 @@ func (usersService *UsersService) SelectorCompanyOrgAll(selectorQuery *query.Com |
|
|
}
|
|
|
return int64(result.Count), dataList, nil
|
|
|
}
|
|
|
|
|
|
//GetInitPassword 获取公司初始化密码
|
|
|
func (usersService *UsersService) GetInitPassword() (string, string, error) {
|
|
|
var password string
|
|
|
alliedCreationBasic := allied_creation_basic.NewHttplibAlliedCreationBasic(domain.Operator{})
|
|
|
reqResult, err := alliedCreationBasic.SystemSettingGet(allied_creation_basic.ReqSystemSettingGet{
|
|
|
domain.InitPasswordSettingKey,
|
|
|
})
|
|
|
if err != nil {
|
|
|
log.Logger.Error(err.Error())
|
|
|
return "", "", err
|
|
|
}
|
|
|
if len(reqResult.Value) == 0 {
|
|
|
return "", "", fmt.Errorf("初始化密码不能为空 ")
|
|
|
}
|
|
|
password = fmt.Sprintf("%x", sha1.Sum([]byte(reqResult.Value)))
|
|
|
return password, reqResult.Value, err
|
|
|
} |
...
|
...
|
|