作者 tangxuhui

用户模块gateway 实现

package dto
type UserListItem struct {
DepName string
OrgName string
Phone string
EnableStatus int
UserCode string
UserId int64
UserName string
}
... ...
... ... @@ -11,10 +11,15 @@ type CompanyUserListQuery struct {
PageNumber int `json:"pageNumber"`
// 每页数量
PageSize int `json:"pageSize" valid:"Required"`
//用户姓名
UserName string `json:"userName"`
//所属部门
DepartmentName string `json:"departmentName"`
CompanyId int64 `json:"companyId" valid:"Required"`
}
func (companyUserListQuery *CompanyUserListQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (companyUserListQuery *CompanyUserListQuery) ValidateQuery() error {
... ...
package service
import (
"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"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/users/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
// 用户信息
... ... @@ -28,9 +32,41 @@ func (usersService *UsersService) CompanyUserEnable(companyUserEnableCommand *co
}
// 返回公司用户信息列表
func (usersService *UsersService) CompanyUserList(companyUserListQuery *query.CompanyUserListQuery) (interface{}, error) {
return nil, nil
func (usersService *UsersService) CompanyUserList(companyUserListQuery *query.CompanyUserListQuery) (int64, interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser()
result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
Offset: (companyUserListQuery.PageNumber - 1) * companyUserListQuery.PageSize,
Limit: companyUserListQuery.PageSize,
CompanyId: companyUserListQuery.CompanyId,
OrganizationId: 0,
DepartmentId: 0,
UserName: companyUserListQuery.UserName,
DepName: companyUserListQuery.DepartmentName,
Phone: "",
})
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//数据转换
cnt := int64(result.Count)
var (
listData []dto.UserListItem
item dto.UserListItem
)
for _, v := range result.Users {
item = dto.UserListItem{
DepName: v.Ext.DepName,
OrgName: v.Ext.OrgName,
Phone: v.Ext.Phone,
EnableStatus: v.EnableStatus,
UserCode: v.UserCode,
UserId: int64(v.UserID),
UserName: v.UserName,
}
listData = append(listData, item)
}
return cnt, listData, nil
}
// 批量重置密码
... ...
... ... @@ -4,14 +4,14 @@ package domain
type UsersBase struct {
// 手机号码
Phone string `json:"phone"`
// 共创模式状态,1启用,2禁用
Status int32 `json:"status"`
// 用户状态,1启用,2禁用
EnableStatus int32 `json:"enableStatus"`
// 用户编号
UsersCode string `json:"usersCode"`
UserCode string `json:"userCode"`
// 用户编号
UsersId int64 `json:"usersId"`
UserId int64 `json:"userId"`
// 用户姓名
UsersName string `json:"usersName"`
UserName string `json:"userName"`
// 邮箱
Email string `json:"email"`
// 共创公司
... ...
package allied_creation_basic
import (
"encoding/json"
"fmt"
"time"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)
type HttplibAlliedCreationBasic struct {
... ... @@ -27,35 +24,3 @@ var alliedCreationBasicClient = &HttplibAlliedCreationBasic{
func NewHttplibAlliedCreationBasic() *HttplibAlliedCreationBasic {
return alliedCreationBasicClient
}
//GetDictionarysByCode 根据code获取字典数据
func (gateway HttplibAlliedCreationBasic) GetDictionarysByCode(param ReqGetDictionaryByCode) (*DataGetDictionaryByCode, error) {
url := gateway.baseUrL + "/dictionarys/dictionary-code"
method := "post"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向基础模块请求数据:根据code获取字典数据。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求字典数据失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取字典数据失败:%w", err)
}
log.Logger.Debug("获取基础模块响应数据:根据code获取字典数据。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析字典数据失败:%w", err)
}
var data DataGetDictionaryByCode
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
package allied_creation_basic
import (
"encoding/json"
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
)
//GetDictionarysByCode 根据code获取字典数据
func (gateway HttplibAlliedCreationBasic) GetDictionarysByCode(param ReqGetDictionaryByCode) (*DataGetDictionaryByCode, error) {
url := gateway.baseUrL + "/dictionarys/dictionary-code"
method := "post"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向基础模块请求数据:根据code获取字典数据。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求字典数据失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取字典数据失败:%w", err)
}
log.Logger.Debug("获取基础模块响应数据:根据code获取字典数据。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析字典数据失败:%w", err)
}
var data DataGetDictionaryByCode
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
package allied_creation_user
import (
"encoding/json"
"fmt"
"time"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)
//HttplibAlliedCreationUser 用户模块
... ... @@ -27,35 +24,3 @@ var alliedCreationUserClient = &HttplibAlliedCreationUser{
func NewHttplibAlliedCreationUser() *HttplibAlliedCreationUser {
return alliedCreationUserClient
}
//UserSearch 搜索用户列表
func (gateway HttplibAlliedCreationUser) UserSearch(param ReqUserSearch) (*DataUserSearch, error) {
url := gateway.baseUrL + "/dictionarys/dictionary-code"
method := "post"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向用户模块请求数据:搜索用户列表。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("搜索用户列表失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取搜索用户列表失败:%w", err)
}
log.Logger.Debug("获取用户模块请求数据:搜索用户列表。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析搜索用户列表:%w", err)
}
var data DataUserSearch
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
package allied_creation_user
import (
"encoding/json"
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)
//UserSearch 搜索用户列表
func (gateway HttplibAlliedCreationUser) UserSearch(param ReqUserSearch) (*DataUserSearch, error) {
url := gateway.baseUrL + "/user/search"
method := "post"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向用户模块请求数据:搜索用户列表。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("搜索用户列表失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取搜索用户列表失败:%w", err)
}
log.Logger.Debug("获取用户模块请求数据:搜索用户列表。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析搜索用户列表:%w", err)
}
var data DataUserSearch
err = gateway.GetResponseData(result, &data)
return &data, err
}
//UserCreate 创建用户
func (gateway HttplibAlliedCreationUser) UserCreate(param ReqCreateUser) (*DataCreateUser, error) {
url := gateway.baseUrL + "/user"
method := "post"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向用户模块请求数据:创建用户。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("创建用户失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取创建用户失败:%w", err)
}
log.Logger.Debug("获取用户模块请求数据:创建用户。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析创建用户:%w", err)
}
var data DataCreateUser
err = gateway.GetResponseData(result, &data)
return &data, err
}
//UserUpdate 更新用户
func (gateway HttplibAlliedCreationUser) UserUpdate(param ReqUpdateUser) (*DataUpdateUser, error) {
url := gateway.baseUrL + "/user"
method := "put"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向用户模块请求数据:更新用户。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求更新用户失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取更新用户失败:%w", err)
}
log.Logger.Debug("获取用户模块请求数据:更新用户。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析更新用户:%w", err)
}
var data DataUpdateUser
err = gateway.GetResponseData(result, &data)
return &data, err
}
//UserGet 获取用户
func (gateway HttplibAlliedCreationUser) UserGet(param ReqGateUser) (*DataGateUser, error) {
url := fmt.Sprintf("%s%s%d", gateway.baseUrL, "/user/", param.UserId)
method := "get"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向用户模块请求数据:获取用户。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求获取用户失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取获取用户失败:%w", err)
}
log.Logger.Debug("获取用户模块请求数据:获取用户。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析获取用户:%w", err)
}
var data DataGateUser
err = gateway.GetResponseData(result, &data)
return &data, err
}
//UserDelete 删除用户
func (gateway HttplibAlliedCreationUser) UserDelete(param ReqDeleteUser) (*DataDeleteUser, error) {
url := fmt.Sprintf("%s%s%d", gateway.baseUrL, "/user/", param.UserId)
method := "delete"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向用户模块请求数据:删除用户。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求删除用户失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取删除用户失败:%w", err)
}
log.Logger.Debug("获取用户模块请求数据:删除用户。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析删除用户:%w", err)
}
var data DataDeleteUser
err = gateway.GetResponseData(result, &data)
return &data, err
}
//UserBatchEnable 批量修改用户启用状态
func (gateway HttplibAlliedCreationUser) UserBatchEnable(param ReqBatchEnableUser) (*DataBatchEnableUser, error) {
url := fmt.Sprintf("%s%s", gateway.baseUrL, "/user/batch-enable")
method := "post"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向用户模块请求数据:批量修改用户启用状态。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求批量修改用户启用状态失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取批量修改用户启用状态失败:%w", err)
}
log.Logger.Debug("获取用户模块请求数据:批量修改用户启用状态。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析批量修改用户启用状态:%w", err)
}
var data DataBatchEnableUser
err = gateway.GetResponseData(result, &data)
return &data, err
}
//UserBatchResetPassword 批量重置密码
func (gateway HttplibAlliedCreationUser) UserBatchResetPassword(param ReqBatchResetPasswordUser) (*DataBatchResetPasswordUser, error) {
url := fmt.Sprintf("%s%s", gateway.baseUrL, "/user/batch-reset-password")
method := "post"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向用户模块请求数据:批量重置密码。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求批量重置密码失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取批量重置密码失败:%w", err)
}
log.Logger.Debug("获取用户模块请求数据:批量重置密码。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析批量重置密码:%w", err)
}
var data DataBatchResetPasswordUser
err = gateway.GetResponseData(result, &data)
return &data, err
}
//CooperatorUserCreate 创建共创用户
func (gateway HttplibAlliedCreationUser) CooperatorUserCreate(param ReqCreateCooperatorUser) (*DataCreateCooperatorUser, error) {
url := fmt.Sprintf("%s%s", gateway.baseUrL, "/user/cooperator")
method := "post"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向用户模块请求数据:创建共创用户。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求创建共创用户失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取创建共创用户失败:%w", err)
}
log.Logger.Debug("获取用户模块请求数据:创建共创用户。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析创建共创用户:%w", err)
}
var data DataCreateCooperatorUser
err = gateway.GetResponseData(result, &data)
return &data, err
}
//CooperatorUserUpdate 更新共创用户
func (gateway HttplibAlliedCreationUser) CooperatorUserUpdate(param ReqUpdateCooperatorUser) (*DataUpdateCooperatorUser, error) {
url := fmt.Sprintf("%s%s%d", gateway.baseUrL, "/user/cooperator/", param.UserId)
method := "put"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向用户模块请求数据:更新共创用户。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求更新共创用户失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取更新共创用户失败:%w", err)
}
log.Logger.Debug("获取用户模块请求数据:更新共创用户。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析更新共创用户:%w", err)
}
var data DataUpdateCooperatorUser
err = gateway.GetResponseData(result, &data)
return &data, err
}
//UserProfile 获取用户概要数据
func (gateway HttplibAlliedCreationUser) UserProfile(param ReqUserProfile) (*DataUserProfile, error) {
url := fmt.Sprintf("%s%s%d%s", gateway.baseUrL, "/user/", param.UserId, "/profile")
method := "get"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向用户模块请求数据:获取用户概要数据。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求获取用户概要数据失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取用户概要数据失败:%w", err)
}
log.Logger.Debug("获取用户模块请求数据:获取用户概要数据。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析获取用户概要数据:%w", err)
}
var data DataUserProfile
err = gateway.GetResponseData(result, &data)
return &data, err
}
//UserUpdateBaseInfo 更新用户基础数据
func (gateway HttplibAlliedCreationUser) UserUpdateBaseInfo(param ReqUserUpdateBaseInfo) (*DataUserUpdateBaseInfo, error) {
url := fmt.Sprintf("%s%s%d%s", gateway.baseUrL, "/user/", param.UserId, "/base-info")
method := "get"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向用户模块请求数据:更新用户基础数据。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求更新用户基础数据失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取更新用户基础数据失败:%w", err)
}
log.Logger.Debug("获取用户模块请求数据:更新用户基础数据。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析更新用户基础数据:%w", err)
}
var data DataUserUpdateBaseInfo
err = gateway.GetResponseData(result, &data)
return &data, err
}
//UserUpdateBaseInfo 返回用户有权限的菜单
func (gateway HttplibAlliedCreationUser) UserAccessMenus(param ReqUserAccessMenus) (*DataUserAccessMenus, error) {
url := fmt.Sprintf("%s%s%d%s", gateway.baseUrL, "/user/", param.UserId, "/base-info")
method := "get"
req := gateway.CreateRequest(url, method)
//TODO traceID
log.Logger.Debug("向用户模块请求数据:返回用户有权限的菜单。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求返回用户有权限的菜单失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取返回用户有权限的菜单失败:%w", err)
}
log.Logger.Debug("获取用户模块请求数据:返回用户有权限的菜单。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析返回用户有权限的菜单:%w", err)
}
var data DataUserAccessMenus
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
... ... @@ -2,45 +2,222 @@ package allied_creation_user
import "time"
//ReqUserSearch 搜索用户列表
type ReqUserSearch struct {
// 查询偏离量
Offset int `json:"offset" valid:"Required"`
// 查询限制
Limit int `json:"limit" valid:"Required"`
}
// //DataUserSearch 搜索用户列表
type DataUserSearch struct {
Count int `json:"count"`
Users []struct {
UserID int `json:"userId"`
CompanyID int `json:"companyId"`
UserBaseID int `json:"userBaseId"`
UserType int `json:"userType"`
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 {
//搜索用户列表
type (
ReqUserSearch struct {
// 查询偏离量
Offset int `json:"offset"`
// 查询限制
Limit int `json:"limit"`
// 企业id
CompanyId int64 ` json:"companyId"`
// 组织ID
OrganizationId int64 `json:"organizationId"`
// 部门编号
DepartmentId int64 `json:"departmentId"`
// 用户姓名
UserName string `json:"userName"`
// 部门名称
DepName string `json:"depName"`
// 手机号码
Phone string `json:"phone"`
}
// //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"`
UserCode string `json:"userCode"`
UserName string `json:"userName"`
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:"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"`
}
} `json:"users"`
}
)
//创建用户
type (
ReqCreateUser struct {
// 企业id
CompanyId int64 `json:"companyId"`
// 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加)
UserType int `json:"userType"`
// 用户编号 企业内标识
UserCode string ` json:"userCode" `
// 组织机构
OrganizationId int64 `json:"organizationId,omitempty" `
// 所属部门
DepartmentId int64 `json:"departmentId,omitempty" `
// 用户关联的组织
UserOrg []int64 `json:"userOrg,omitempty"`
// 用户关联的角色
UserRole []int64 `json:"userRole,omitempty"`
// 共创公司
CooperationCompany string `json:"cooperationCompany,omitempty"`
// 共创到期时间 (yyyy-MM-dd)
CooperationDeadline time.Time ` json:"cooperationDeadline,omitempty"`
// 启用状态(启用:1 禁用:2)
EnableStatus int ` json:"enableStatus,omitempty"`
// 密码
Password string ` json:"password" `
// 用户姓名
UserName string `json:"userName"`
// 手机号码
Phone string `json:"phone" `
// 头像
Avatar string `json:"avatar"`
// 邮箱
Email string `json:"email"`
}
DataCreateUser struct {
}
)
//更新用户
type (
ReqUpdateUser struct {
// 企业id
CompanyId int64 `json:"companyId"`
// 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加)
UserType int `json:"userType"`
// 用户编号 企业内标识
UserCode string ` json:"userCode" `
// 组织机构
OrganizationId int64 `json:"organizationId,omitempty" `
// 所属部门
DepartmentId int64 `json:"departmentId,omitempty" `
// 用户关联的组织
UserOrg []int64 `json:"userOrg,omitempty"`
// 用户关联的角色
UserRole []int64 `json:"userRole,omitempty"`
// 共创公司
CooperationCompany string `json:"cooperationCompany,omitempty"`
// 共创到期时间 (yyyy-MM-dd)
CooperationDeadline time.Time ` json:"cooperationDeadline,omitempty"`
// 启用状态(启用:1 禁用:2)
EnableStatus int ` json:"enableStatus,omitempty"`
// 密码
Password string ` json:"password" `
// 用户姓名
UserName string `json:"userName"`
// 手机号码
Phone string `json:"phone" `
// 头像
Avatar string `json:"avatar"`
// 邮箱
Email string `json:"email"`
}
DataUpdateUser struct {
}
)
//获取用户
type (
ReqGateUser struct {
UserId int64 `json:"userId"`
}
DataGateUser struct {
}
)
//删除用户
type (
ReqDeleteUser struct {
UserId int64 `json:"userId"`
}
DataDeleteUser struct {
}
)
//批量修改用户启用状态
type (
ReqBatchEnableUser struct {
UserId int64 `json:"userId"`
EnableStatus int `json:"enableStatus"`
}
DataBatchEnableUser struct {
}
)
//批量重置密码
type (
ReqBatchResetPasswordUser struct {
Password string
UserIds []int64
}
DataBatchResetPasswordUser struct {
}
)
//创建共创用户
type (
ReqCreateCooperatorUser struct {
}
DataCreateCooperatorUser struct {
}
)
//更新共创用户
type (
ReqUpdateCooperatorUser struct {
UserId int64 `json:"userId"`
}
DataUpdateCooperatorUser struct {
}
)
//获取用户概要数据
type (
ReqUserProfile struct {
UserId int64 `json:"userId"`
}
DataUserProfile struct {
}
)
//更新用户基础信息数据
type (
ReqUserUpdateBaseInfo struct {
UserId int64 `json:"userId"`
}
DataUserUpdateBaseInfo struct {
}
)
//返回用户有权限的菜单
type (
ReqUserAccessMenus struct {
UserId int64 `json:"userId"`
}
DataUserAccessMenus struct {
}
)
... ...
package jtime
import (
"fmt"
"strconv"
"time"
)
type UnixTimeSecond time.Time
// MarshalJSON implements json.Marshaler.
func (t UnixTimeSecond) MarshalJSON() ([]byte, error) {
stamp := fmt.Sprintf("%d", time.Time(t).Unix())
return []byte(stamp), nil
}
// MarshalJSON implements json.Unmarshaler.
func (t UnixTimeSecond) UnmarshalJSON(v []byte) error {
str := string(v)
number, err := strconv.Atoi(str)
if err != nil {
return fmt.Errorf("时间类型需要使用时间戳传参:%w", err)
}
t = UnixTimeSecond(time.Unix(int64(number), 0))
return nil
}
... ...