作者 tangxuhui

更新

... ... @@ -4,17 +4,20 @@ import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type CompanyUserAddCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 用户编号
UsersCode string `json:"usersCode" valid:"Required"`
// 用户姓名
UsersName string `json:"usersName" valid:"Required"`
// 组织ID
OrgId int64 `json:"orgId" valid:"Required"`
OrgId string `json:"orgId" valid:"Required"`
// 部门id
DepartmentId int64 `json:"departmentId" valid:"Required"`
DepartmentId string `json:"departmentId" valid:"Required"`
// 启用状态(启用:1 禁用:2)
EnableStatus int `json:"enableStatus" valid:"Required"`
// 手机号码
... ... @@ -22,9 +25,9 @@ type CompanyUserAddCommand struct {
// 邮箱
Email string `json:"email" valid:"Required"`
// 关联的组织机构
UsersOrg []int64 `json:"usersOrg,omitempty"`
UsersOrg []string `json:"usersOrg"`
// 关联的用户
UsersRole []int64 `json:"usersRole,omitempty"`
UsersRole []string `json:"usersRole"`
// 头像
Avator string `json:"avator" valid:"Required"`
}
... ...
package dto
type UserListItem struct {
DepName string
OrgName string
Phone string
EnableStatus int
UserCode string
UserId int64
UserName string
type CompanyUserItem struct {
DepName string `json:"depName"`
OrgName string `json:"orgName"`
Phone string `json:"phone"`
EnableStatus int `json:"enableStatus"`
UserCode string `json:"userCode"`
UserId string `json:"userId"`
UserName string `json:"userName"`
}
type CooperationUserInfo struct {
... ... @@ -29,3 +29,15 @@ type CooperationUserInfo struct {
//头像
Avatar string `json:"avatar"`
}
type CooperationUserItem struct {
CooperationCompany string `json:"cooperationCompany"`
UserId string `json:"userId"`
CooperationDeadline int64 `json:"cooperationDeadline"`
Phone string `json:"phone"`
EnableStatus int `json:"enableStatus"`
UserCode string `json:"userCode"`
UserName string `json:"userName"`
OrgName string `json:"orgName"`
OrgId string `json:"orgId"`
}
... ...
... ... @@ -4,9 +4,12 @@ import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type CompanyUserGetQuery struct {
//操作人
Operator domain.Operator `json:"-"`
// 用户编号
UsersId int64 `json:"usersId" valid:"Required"`
}
... ...
... ... @@ -4,9 +4,11 @@ import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type CompanyUserListQuery struct {
// 页码
PageNumber int `json:"pageNumber"`
// 每页数量
... ... @@ -15,7 +17,8 @@ type CompanyUserListQuery struct {
UserName string `json:"userName"`
//所属部门
DepartmentName string `json:"departmentName"`
CompanyId int64 `json:"companyId" valid:"Required"`
//操作人
Operator domain.Operator `json:"-"`
}
func (companyUserListQuery *CompanyUserListQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -4,13 +4,20 @@ import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type CooperationUserListQuery struct {
//操作人
Operator domain.Operator `json:"-"`
//用户名称
UserName string `json:"userName"`
//共创公司
CooperationCompany string `json:"cooperationCompany"`
// 查询偏离量
Offset int `json:"offset" valid:"Required"`
PageNumber int `json:"pageNumber"`
// 查询限制
Limit int `json:"limit" valid:"Required"`
PageSize int `json:"pageSize" valid:"Required"`
}
func (cooperationUserListQuery *CooperationUserListQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -8,6 +8,7 @@ import (
"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"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
... ... @@ -18,14 +19,67 @@ type UsersService struct {
// 获取公司用户信息
func (usersService *UsersService) CompanyUserGet(companyUserGetQuery *query.CompanyUserGetQuery) (interface{}, error) {
return nil, nil
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
companyUserGetQuery.Operator.CompanyId,
companyUserGetQuery.Operator.OrgId,
companyUserGetQuery.Operator.UserId)
result, err := creationUserGateway.UserGet(allied_creation_user.ReqGateUser{
UserId: companyUserGetQuery.UsersId,
})
if err != nil {
return nil, err
}
//TODO 数据拼接
userInfo := domain.Users{
UserId: "",
UserInfo: result.GetUserBase(),
Org: result.GetOrg(),
Department: result.GetDepartment(),
Company: nil,
}
return userInfo, err
}
// 创建公司用户信息
func (usersService *UsersService) CompanyUserAdd(companyUserAddCommand *command.CompanyUserAddCommand) (interface{}, error) {
return nil, nil
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
companyUserAddCommand.Operator.CompanyId,
companyUserAddCommand.Operator.OrgId,
companyUserAddCommand.Operator.UserId)
departmentId, _ := strconv.Atoi(companyUserAddCommand.OrgId)
orgId, _ := strconv.Atoi(companyUserAddCommand.OrgId)
userOrg := []int64{}
userRole := []int64{}
for _, v := range companyUserAddCommand.UsersOrg {
id, err := strconv.Atoi(v)
if err == nil {
userOrg = append(userOrg, int64(id))
}
}
for _, v := range companyUserAddCommand.UsersRole {
id, err := strconv.Atoi(v)
if err == nil {
userRole = append(userRole, int64(id))
}
}
result, err := creationUserGateway.UserCreate(allied_creation_user.ReqCreateUser{
CompanyId: companyUserAddCommand.Operator.CompanyId,
// 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加)
UserType: 1,
UserCode: companyUserAddCommand.UsersCode,
OrganizationId: int64(orgId),
DepartmentId: int64(departmentId),
UserOrg: userOrg,
UserRole: userRole,
// 启用状态(启用:1 禁用:2)
EnableStatus: companyUserAddCommand.EnableStatus,
Password: "",
UserName: companyUserAddCommand.UsersName,
Phone: companyUserAddCommand.Phone,
Avatar: companyUserAddCommand.Avator,
Email: companyUserAddCommand.Avator,
})
return result, err
}
// 启用禁用公司用户信息
... ... @@ -47,8 +101,8 @@ func (usersService *UsersService) CompanyUserList(companyUserListQuery *query.Co
result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
Offset: (companyUserListQuery.PageNumber - 1) * companyUserListQuery.PageSize,
Limit: companyUserListQuery.PageSize,
CompanyId: companyUserListQuery.CompanyId,
OrganizationId: 0,
CompanyId: companyUserListQuery.Operator.CompanyId,
OrganizationId: companyUserListQuery.Operator.OrgId,
DepartmentId: 0,
UserName: companyUserListQuery.UserName,
DepName: companyUserListQuery.DepartmentName,
... ... @@ -61,18 +115,18 @@ func (usersService *UsersService) CompanyUserList(companyUserListQuery *query.Co
//数据转换
cnt := int64(result.Count)
var (
listData []dto.UserListItem
item dto.UserListItem
listData []dto.CompanyUserItem
item dto.CompanyUserItem
)
for _, v := range result.Users {
item = dto.UserListItem{
DepName: v.Ext.DepName,
OrgName: v.Ext.OrgName,
Phone: v.Ext.Phone,
item = dto.CompanyUserItem{
DepName: v.Department.DepartmentName,
OrgName: v.Org.OrgName,
Phone: v.UserInfo.Phone,
EnableStatus: v.EnableStatus,
UserCode: v.UserCode,
UserId: int64(v.UserID),
UserName: v.UserName,
UserId: strconv.FormatInt(v.UserId, 10),
UserName: v.UserInfo.UserName,
}
listData = append(listData, item)
}
... ... @@ -160,9 +214,38 @@ func (usersService *UsersService) CooperationUserGet(cooperationUserGetQuery *qu
}
// 返回共创用户信息列表
func (usersService *UsersService) CooperationUserList(cooperationUserListQuery *query.CooperationUserListQuery) (interface{}, error) {
return nil, nil
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: "",
})
var (
listData []dto.CooperationUserItem
item dto.CooperationUserItem
)
cnt := result.Count
for _, v := range result.Users {
item = dto.CooperationUserItem{
CooperationCompany: v.CooperationInfo.CooperationCompany,
UserId: strconv.FormatInt(v.UserId, 10),
CooperationDeadline: v.CooperationInfo.CooperationDeadline.Unix(),
Phone: v.UserInfo.Phone,
EnableStatus: v.EnableStatus,
UserCode: v.UserCode,
UserName: v.UserInfo.UserName,
OrgName: v.Org.OrgName,
OrgId: strconv.FormatInt(v.Org.OrgId, 10),
}
listData = append(listData, item)
}
return cnt, listData, err
}
// 批量重置密码
... ...
... ... @@ -4,6 +4,7 @@ import "time"
// 公司信息
type CompanyInfo struct {
CompanyId string `json:"companyId"`
// 企业名称
CompanyName string `json:"companyName"`
// 规模
... ... @@ -19,5 +20,5 @@ type CompanyInfo struct {
// 注册时间
RegisteredTime time.Time `json:"registeredTime"`
// 注册状态 1:已注册 2:待认证 3:已认证
RegistStatus int `json:"registStatus"`
RegistStatus int64 `json:"registStatus"`
}
... ...
... ... @@ -3,9 +3,9 @@ package domain
// 组织organization
type Orgs struct {
// 组织ID
OrgId int64 `json:"orgId"`
OrgId string `json:"orgId"`
// 企业id
CompanyId int64 `json:"companyId"`
CompanyId string `json:"companyId"`
// 组织编码
OrgCode string `json:"orgCode"`
// 组织名称
... ...
package domain
// 角色 (base)
type Roles struct {
// 角色ID
RoleId string `json:"roleId"`
// 角色名称
RoleName string `json:"roleName"`
// 描述
Desc string `json:"desc"`
// 用户的组织
Org *Orgs `json:"org,omitempty,"`
// 用户的部门
Department *Department `json:"department,omitempty,"`
}
... ...
... ... @@ -8,14 +8,7 @@ const (
// 用户基础信息
type Users struct {
// 用户id
UserId string `json:"userId"`
UserBaseId int64 `json:"userBaseId"`
UserType int `json:"userType"`
UserCode string `json:"userCode"`
// 用户状态,1启用,2禁用
EnableStatus int32 `json:"enableStatus"`
//共创信息
CooperationInfo *CooperationInfo `json:"cooperationInfo,omitempty,"`
UserId string `json:"userId"`
// 用户基础信息
UserInfo *UsersBase `json:"userInfo,omitempty,"`
// 用户的组织
... ... @@ -23,5 +16,8 @@ type Users struct {
// 用户的部门
Department *Department `json:"department,omitempty,"`
Company *CompanyInfo `json:"company"`
Company *CompanyInfo `json:"company,omitempty,"`
UserOrg []Orgs `json:"userOrg"`
UserRole []Roles `json:"userRole"`
}
... ...
package domain
import "time"
// 用户基础信息
type UsersBase struct {
UserId string `json:"userId"`
UserBaseId string `json:"userBaseId"`
UserType int `json:"userType"`
// 用户状态,1启用,2禁用
EnableStatus int `json:"enableStatus"`
// 手机号码
Phone string `json:"phone"`
// 用户编号
UserCode string `json:"userCode"`
// 用户编号
UserId int64 `json:"userId"`
// 用户姓名
UserName string `json:"userName"`
// 邮箱
Email string `json:"email"`
//头像
Avatar string `json:"avatar"`
// 共创公司
CooperationCompany string `json:"cooperationCompany"`
// 共创公司到期时间
CooperationDeadline time.Time `json:"cooperationDeadline"`
}
... ...
package allied_creation_user
import "time"
import (
"strconv"
"time"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
//################用户模块##################
//单体用户详情数据
type UserDetail struct {
UserId int64 `json:"userId"`
UserBaseId int64 `json:"userBaseId"`
UserType int `json:"userType"`
UserCode string `json:"userCode"`
EnableStatus int `json:"enableStatus"`
CooperationInfo struct {
CooperationCompany string `json:"cooperationCompany"`
CooperationDeadline time.Time `json:"cooperationDeadline"`
} `json:"cooperationInfo,omitempty"`
UserInfo struct {
Phone string `json:"phone"`
UserCode string `json:"userCode"`
Email string `json:"email"`
UserName string `json:"userName"`
Avatar string `json:"avatar"`
} `json:"userInfo,omitempty"`
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,omitempty"`
Org *struct {
OrgId int64 `json:"orgId"`
OrgCode string `json:"orgCode"`
OrgName string `json:"orgName"`
} `json:"org,omitempty"`
Department *struct {
DepartmentId int64 `json:"departmentId"`
DepartmentName string `json:"departmentName"`
} `json:"department,omitempty"`
UserRole []struct {
RoleID int `json:"roleId"`
RoleName string `json:"roleName"`
Ext struct {
OrgName string `json:"orgName"`
} `json:"ext,omitempty"`
} `json:"userRole"`
UserOrg []struct {
OrgID int `json:"orgId"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt time.Time `json:"deletedAt"`
OrgName string `json:"orgName"`
} `json:"userOrg"`
}
func (info *UserDetail) GetUserBase() *domain.UsersBase {
return &domain.UsersBase{
UserId: strconv.Itoa(int(info.UserId)),
UserBaseId: strconv.Itoa(int(info.UserBaseId)),
UserType: info.UserType,
// 用户状态,1启用,2禁用
EnableStatus: info.EnableStatus,
// 手机号码
Phone: info.UserInfo.Phone,
// 用户编号
UserCode: info.UserCode,
// 用户姓名
UserName: info.UserInfo.UserName,
// 邮箱
Email: info.UserInfo.Email,
//头像
Avatar: info.UserInfo.Avatar,
// 共创公司
CooperationCompany: info.CooperationInfo.CooperationCompany,
// 共创公司到期时间
CooperationDeadline: info.CooperationInfo.CooperationDeadline,
}
}
func (info *UserDetail) GetCompanyInfo() *domain.CompanyInfo {
if info.Company == nil {
return nil
}
return &domain.CompanyInfo{
CompanyId: strconv.Itoa(int(info.Company.CompanyId)),
CompanyName: info.Company.CompanyName,
Scale: info.Company.Scale,
Logo: "",
Address: "",
IndustryCategory: info.Company.IndustryCategory,
Contacts: "",
RegisteredTime: info.Company.RegisteredTime,
RegistStatus: info.Company.Status,
}
}
func (info *UserDetail) GetDepartment() *domain.Department {
if info.Department == nil {
return nil
}
return &domain.Department{
OrgId: info.Department.DepartmentId,
OrgName: info.Org.OrgName,
OrgCode: "",
ParentId: 0,
}
}
func (info *UserDetail) GetOrg() *domain.Orgs {
if info.Org == nil {
return nil
}
return &domain.Orgs{
OrgId: strconv.Itoa(int(info.Department.DepartmentId)),
OrgName: info.Org.OrgName,
OrgCode: "",
ParentId: 0,
}
}
//搜索用户列表
type (
ReqUserSearch struct {
... ... @@ -25,40 +146,10 @@ type (
Phone string `json:"phone"`
}
// //DataUserSearch 搜索用户列表
//DataUserSearch 搜索用户列表
DataUserSearch struct {
Count int `json:"count"`
Users []struct {
UserID int `json:"userId"`
CompanyID int `json:"companyId"`
UserBaseID int `json:"userBaseId"`
UserType int `json:"userType"`
UserName string `json:"userName"`
UserCode string `json:"userCode"`
OrganizationID int `json:"organizationId"`
DepartmentID int `json:"departmentId"`
UserOrg []struct {
OrgID int `json:"orgId"`
OrgName string `json:"orgName"`
} `json:"userOrg"`
UserRole []struct {
RoleID int `json:"roleId"`
RoleName string `json:"roleName"`
Ext struct {
OrgName string `json:"orgName"`
} `json:"ext"`
} `json:"userRole"`
CooperationInfo struct {
CooperationCompany string `json:"cooperationCompany"`
CooperationDeadline time.Time `json:"cooperationDeadline"`
} `json:"cooperationInfo"`
EnableStatus int `json:"enableStatus"`
Ext struct {
OrgName string `json:"orgName"`
Phone string `json:"phone"`
DepName string `json:"depName"`
} `json:"ext"`
} `json:"users"`
Count int64 `json:"count"`
Users []UserDetail `json:"users"`
}
)
... ... @@ -97,6 +188,7 @@ type (
Email string `json:"email"`
}
DataCreateUser struct {
UserDetail
}
)
... ... @@ -146,39 +238,7 @@ 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"`
UserDetail
}
)
... ...