作者 tangxuhui

web端 用户管理模块 应用层实现

... ... @@ -4,9 +4,13 @@ import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type CompanyUserEnableCommand struct {
//操作人
Operator domain.Operator `json:"-"`
//用户id
UsersIds []int64 `json:"usersIds,omitempty"`
// 启用状态(启用:1 禁用:2)
EnableStatus int `json:"enableStatus,omitempty"`
... ...
... ... @@ -4,10 +4,13 @@ import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type CompanyUserResetPasswordCommand struct {
UsersIds []int64 `json:"usersIds" valid:"Required"`
//操作人
Operator domain.Operator `json:"-"`
UsersIds []int64 `json:"usersIds" valid:"Required"`
}
func (companyUserResetPasswordCommand *CompanyUserResetPasswordCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -4,11 +4,12 @@ import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type CooperationUserAddCommand struct {
// 用户编号
UsersId int64 `json:"usersId" valid:"Required"`
//操作人
Operator domain.Operator `json:"-"`
// 用户编号
UsersCode string `json:"usersCode" valid:"Required"`
// 用户姓名
... ... @@ -16,15 +17,18 @@ type CooperationUserAddCommand struct {
// 共创公司
CooperationCompany string `json:"cooperationCompany" valid:"Required"`
// 共创公司到期时间
CooperationDeadline string `json:"cooperationDeadline" valid:"Required"`
CooperationDeadline int64 `json:"cooperationDeadline" valid:"Required"`
// 启用状态(启用:1 禁用:2)
EnableStatus int `json:"enableStatus" valid:"Required"`
// 邮箱
Email string `json:"email" valid:"Required"`
//头像
Avatar string `json:"avatar"`
Phone string `json:"phone" valid:"Required"`
}
func (cooperationUserAddCommand *CooperationUserAddCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (cooperationUserAddCommand *CooperationUserAddCommand) ValidateCommand() error {
... ...
... ... @@ -4,16 +4,20 @@ import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type CooperationUserEnableCommand struct {
//操作人
Operator domain.Operator `json:"-"`
//用户id
UsersIds []int64 `json:"usersIds,omitempty"`
// 启用状态(启用:1 禁用:2)
EnableStatus int `json:"enableStatus,omitempty"`
}
func (cooperationUserEnableCommand *CooperationUserEnableCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (cooperationUserEnableCommand *CooperationUserEnableCommand) ValidateCommand() error {
... ...
... ... @@ -4,14 +4,16 @@ import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type CooperationUserResetPasswordCommand struct {
UsersIds []int64 `json:"usersIds" valid:"Required"`
//操作人
Operator domain.Operator `json:"-"`
UsersIds []int64 `json:"usersIds" valid:"Required"`
}
func (cooperationUserResetPasswordCommand *CooperationUserResetPasswordCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (cooperationUserResetPasswordCommand *CooperationUserResetPasswordCommand) ValidateCommand() error {
... ...
... ... @@ -4,9 +4,12 @@ import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type CooperationUserUpdateCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 用户编号
UsersId int64 `json:"usersId" valid:"Required"`
// 用户编号
... ... @@ -16,15 +19,19 @@ type CooperationUserUpdateCommand struct {
// 共创公司
CooperationCompany string `json:"cooperationCompany" valid:"Required"`
// 共创公司到期时间
CooperationDeadline string `json:"cooperationDeadline" valid:"Required"`
CooperationDeadline int64 `json:"cooperationDeadline" valid:"Required"`
// 启用状态(启用:1 禁用:2)
EnableStatus int `json:"enableStatus" valid:"Required"`
// 邮箱
Email string `json:"email" valid:"Required"`
//头像
Avatar string `json:"avatar"`
Phone string `json:"phone" valid:"Required"`
}
func (cooperationUserUpdateCommand *CooperationUserUpdateCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (cooperationUserUpdateCommand *CooperationUserUpdateCommand) ValidateCommand() error {
... ...
... ... @@ -9,3 +9,23 @@ type UserListItem struct {
UserId int64
UserName string
}
type CooperationUserInfo struct {
UserId string `json:"userId"`
//用户编号
UserCode string `json:"userCode"`
// 用户状态,1启用,2禁用
EnableStatus int32 `json:"enableStatus"`
// 共创公司
CooperationCompany string `json:"cooperationCompany"`
// 共创公司到期时间
CooperationDeadline int64 `json:"cooperationDeadline"`
// 用户姓名
UserName string `json:"userName"`
// 邮箱
Email string `json:"email"`
// 手机号码
Phone string `json:"phone"`
//头像
Avatar string `json:"avatar"`
}
... ...
... ... @@ -4,9 +4,12 @@ import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type CooperationUserGetQuery struct {
//操作人
Operator domain.Operator `json:"-"`
// 用户编号
UsersId int64 `json:"usersId" valid:"Required"`
}
... ...
package service
import (
"strconv"
"time"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/dto"
... ... @@ -27,8 +30,15 @@ func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command.
// 启用禁用公司用户信息
func (usersService *UsersService) CompanyUserEnable(companyUserEnableCommand *command.CompanyUserEnableCommand) (interface{}, error) {
return nil, nil
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
companyUserEnableCommand.Operator.CompanyId,
companyUserEnableCommand.Operator.OrgId,
companyUserEnableCommand.Operator.UserId)
result, err := creationUserGateway.UserBatchEnable(allied_creation_user.ReqBatchEnableUser{
UserIds: companyUserEnableCommand.UsersIds,
EnableStatus: companyUserEnableCommand.EnableStatus,
})
return result, err
}
// 返回公司用户信息列表
... ... @@ -71,8 +81,15 @@ func (usersService *UsersService) CompanyUserList(companyUserListQuery *query.Co
// 批量重置密码
func (usersService *UsersService) CompanyUserResetPassword(companyUserResetPasswordCommand *command.CompanyUserResetPasswordCommand) (interface{}, error) {
return nil, nil
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
companyUserResetPasswordCommand.Operator.CompanyId,
companyUserResetPasswordCommand.Operator.OrgId,
companyUserResetPasswordCommand.Operator.UserId)
result, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
Password: "",
UserIds: companyUserResetPasswordCommand.UsersIds,
})
return result, err
}
// 更新公司用户信息
... ... @@ -83,19 +100,63 @@ func (usersService *UsersService) CompanyUserUpdate(companyUserUpdateCommand *co
// 创建共创用户信息
func (usersService *UsersService) CooperationUserAdd(cooperationUserAddCommand *command.CooperationUserAddCommand) (interface{}, error) {
return nil, nil
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
cooperationUserAddCommand.Operator.CompanyId,
cooperationUserAddCommand.Operator.OrgId,
cooperationUserAddCommand.Operator.UserId)
result, err := creationUserGateway.CooperatorUserCreate(allied_creation_user.ReqCreateCooperatorUser{
CooperationCompany: cooperationUserAddCommand.CooperationCompany,
CooperationDeadline: time.Unix(cooperationUserAddCommand.CooperationDeadline, 0),
Email: cooperationUserAddCommand.Email,
EnableStatus: cooperationUserAddCommand.EnableStatus,
UserCode: cooperationUserAddCommand.UsersCode,
UserName: cooperationUserAddCommand.UsersName,
Avatar: cooperationUserAddCommand.Avatar,
OrgId: cooperationUserAddCommand.Operator.OrgId,
Phone: cooperationUserAddCommand.Phone,
Password: "",
})
return result, err
}
// 启用禁用共创用户信息
func (usersService *UsersService) CooperationUserEnable(cooperationUserEnableCommand *command.CooperationUserEnableCommand) (interface{}, error) {
return nil, nil
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
cooperationUserEnableCommand.Operator.CompanyId,
cooperationUserEnableCommand.Operator.OrgId,
cooperationUserEnableCommand.Operator.UserId)
result, err := creationUserGateway.UserBatchEnable(allied_creation_user.ReqBatchEnableUser{
UserIds: cooperationUserEnableCommand.UsersIds,
EnableStatus: cooperationUserEnableCommand.EnableStatus,
})
return result, err
}
// 获取共创用户信息
func (usersService *UsersService) CooperationUserGet(cooperationUserGetQuery *query.CooperationUserGetQuery) (interface{}, error) {
return nil, nil
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
cooperationUserGetQuery.Operator.CompanyId,
cooperationUserGetQuery.Operator.OrgId,
cooperationUserGetQuery.Operator.UserId)
result, err := creationUserGateway.UserGet(allied_creation_user.ReqGateUser{
UserId: cooperationUserGetQuery.UsersId,
})
if err != nil {
return nil, err
}
deadline := result.CooperationInfo.CooperationDeadline.Unix()
userInfo := dto.CooperationUserInfo{
UserId: strconv.FormatInt(result.UserId, 10),
UserCode: result.UserCode,
EnableStatus: int32(result.EnableStatus),
CooperationCompany: result.CooperationInfo.CooperationCompany,
CooperationDeadline: deadline,
UserName: result.UserInfo.UserName,
Email: result.UserInfo.Email,
Phone: result.UserInfo.Phone,
Avatar: result.UserInfo.Avatar,
}
return userInfo, nil
}
// 返回共创用户信息列表
... ... @@ -106,14 +167,36 @@ func (usersService *UsersService) CooperationUserList(cooperationUserListQuery *
// 批量重置密码
func (usersService *UsersService) CooperationUserResetPassword(cooperationUserResetPasswordCommand *command.CooperationUserResetPasswordCommand) (interface{}, error) {
return nil, nil
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
cooperationUserResetPasswordCommand.Operator.CompanyId,
cooperationUserResetPasswordCommand.Operator.OrgId,
cooperationUserResetPasswordCommand.Operator.UserId)
result, err := creationUserGateway.UserBatchResetPassword(allied_creation_user.ReqBatchResetPasswordUser{
Password: "",
UserIds: cooperationUserResetPasswordCommand.UsersIds,
})
return result, err
}
// 编辑共创用户信息
func (usersService *UsersService) CooperationUserUpdate(cooperationUserUpdateCommand *command.CooperationUserUpdateCommand) (interface{}, error) {
return nil, nil
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
cooperationUserUpdateCommand.Operator.CompanyId,
cooperationUserUpdateCommand.Operator.OrgId,
cooperationUserUpdateCommand.Operator.UserId)
result, err := creationUserGateway.CooperatorUserUpdate(allied_creation_user.ReqUpdateCooperatorUser{
UserId: cooperationUserUpdateCommand.UsersId,
CooperationCompany: cooperationUserUpdateCommand.CooperationCompany,
CooperationDeadline: time.Unix(cooperationUserUpdateCommand.CooperationDeadline, 0),
Email: cooperationUserUpdateCommand.Email,
EnableStatus: cooperationUserUpdateCommand.EnableStatus,
UserCode: cooperationUserUpdateCommand.UsersCode,
UserName: cooperationUserUpdateCommand.UsersName,
Avatar: cooperationUserUpdateCommand.Avatar,
OrgId: cooperationUserUpdateCommand.Operator.OrgId,
Phone: cooperationUserUpdateCommand.Phone,
})
return result, err
}
func NewUsersService(options map[string]interface{}) *UsersService {
... ...
... ... @@ -17,7 +17,7 @@ type CompanyInfo struct {
// 联系人
Contacts string `json:"contacts"`
// 注册时间
RegistTime time.Time `json:"registTime"`
RegisteredTime time.Time `json:"registeredTime"`
// 注册状态 1:已注册 2:待认证 3:已认证
RegistStatus int `json:"registStatus"`
}
... ...
package domain
import "time"
const (
loginTokenSecret string = "bbe35ad433dd8e67"
)
type LoginToken struct {
UserId int64 `json:"userId"`
UserBaseId int64 `json:"userBaseId"`
// 账号
Account string `json:"account"`
// 对应平台
... ... @@ -14,19 +14,6 @@ type LoginToken struct {
// 公司id
CompanyId int64 `json:"companyId"`
// 组织id
OrganizationId int64 `json:"organizationId"`
// 登录凭证存储
AccessToken string `json:"accessToken"`
// 刷新登录凭证
RefreshToken string `json:"refreshToken"`
// 登录凭证过期时间,时间戳精度秒
AccessExpired int64 `json:"accessExpired"`
// 刷新登录凭证过期时间,时间戳精度秒
RefreshExpired int64 `json:"refreshExpired"`
// 创建时间
CreatedTime time.Time `json:"createdTime"`
// 更新时间
UpdatedTime time.Time `json:"updatedTime"`
}
func (t *LoginToken) GenerateAccessToken() error {
... ...
package domain
// 登录系统的操作人员 可以从toke中获取数据
type Operator struct {
UserId int64 `json:"userId"`
CompanyId int64 `json:"companyId"`
OrgId int64 `json:"orgId"`
UserBaseId int64 `json:"userBaseId"`
}
... ...
package domain
const (
UsersStatusEnable int = 1
UsersStatusDisable int = 2
)
// 用户基础信息
type Users struct {
// 用户id
... ...
... ... @@ -146,6 +146,39 @@ type (
}
DataGateUser struct {
UserId int64 `json:"userId"`
UserBaseId int64 `json:"userBaseId"`
UserType int64 `json:"userType"`
UserCode string `json:"userCode"`
EnableStatus int64 `json:"enableStatus"`
CooperationInfo struct {
CooperationCompany string `json:"cooperationCompany"`
CooperationDeadline time.Time `json:"cooperationDeadline"`
} `json:"cooperationInfo"`
UserInfo struct {
Phone string `json:"phone"`
UserCode string `json:"userCode"`
Email string `json:"email"`
UserName string `json:"userName"`
Avatar string `json:"avatar"`
} `json:"userInfo"`
Company struct {
CompanyId int64 `json:"companyId"`
CompanyName string `json:"companyName"`
Scale string `json:"scale"`
IndustryCategory string `json:"industryCategory"`
RegisteredTime time.Time `json:"registeredTime"`
Status int64 `json:"status"`
} `json:"company"`
Org struct {
OrgId int64 `json:"orgId"`
OrgCode string `json:"orgCode"`
OrgName string `json:"orgName"`
} `json:"org"`
Department struct {
DepartmentId int64 `json:"departmentId"`
DepartmentName string `json:"departmentName"`
} `json:"department"`
}
)
... ... @@ -162,8 +195,8 @@ type (
//批量修改用户启用状态
type (
ReqBatchEnableUser struct {
UserId int64 `json:"userId"`
EnableStatus int `json:"enableStatus"`
UserIds []int64 `json:"userIds"`
EnableStatus int `json:"enableStatus"` //启用状态(启用:1 禁用:2 注销:3)
}
DataBatchEnableUser struct {
... ... @@ -173,8 +206,8 @@ type (
//批量重置密码
type (
ReqBatchResetPasswordUser struct {
Password string
UserIds []int64
Password string `json:"password"`
UserIds []int64 `json:"userIds"`
}
DataBatchResetPasswordUser struct {
}
... ... @@ -183,6 +216,26 @@ type (
//创建共创用户
type (
ReqCreateCooperatorUser struct {
// 共创公司
CooperationCompany string ` json:"cooperationCompany"`
// 共创到期时间
CooperationDeadline time.Time `json:"cooperationDeadline"`
// 邮箱
Email string `json:"email"`
// 启用状态(启用:1 禁用:2 注销:3)
EnableStatus int `json:"enableStatus" `
// 用户编号 企业内标识
UserCode string `json:"userCode"`
// 用户姓名
UserName string ` json:"userName"`
// 头像
Avatar string ` json:"avatar"`
// 组织ID
OrgId int64 `json:"orgId"`
// 手机号码
Phone string `json:"phone"`
//密码
Password string `json:"password"`
}
DataCreateCooperatorUser struct {
}
... ... @@ -192,6 +245,24 @@ type (
type (
ReqUpdateCooperatorUser struct {
UserId int64 `json:"userId"`
// 共创公司
CooperationCompany string ` json:"cooperationCompany"`
// 共创到期时间
CooperationDeadline time.Time `json:"cooperationDeadline"`
// 邮箱
Email string `json:"email"`
// 启用状态(启用:1 禁用:2 注销:3)
EnableStatus int `json:"enableStatus" `
// 用户编号 企业内标识
UserCode string `json:"userCode" `
// 用户姓名
UserName string ` json:"userName"`
// 头像
Avatar string ` json:"avatar"`
// 组织ID
OrgId int64 `json:"orgId" `
// 手机号码
Phone string `json:"phone" `
}
DataUpdateCooperatorUser struct {
}
... ...