param_user.go 8.8 KB
package allied_creation_user

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 {
		// 查询偏离量
		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 int64        `json:"count"`
		Users []UserDetail `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 {
		UserDetail
	}
)

//更新用户
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 {
		UserDetail
	}
)

//删除用户
type (
	ReqDeleteUser struct {
		UserId int64 `json:"userId"`
	}

	DataDeleteUser struct {
	}
)

//批量修改用户启用状态
type (
	ReqBatchEnableUser struct {
		UserIds      []int64 `json:"userIds"`
		EnableStatus int     `json:"enableStatus"` //启用状态(启用:1 禁用:2 注销:3)
	}

	DataBatchEnableUser struct {
	}
)

//批量重置密码
type (
	ReqBatchResetPasswordUser struct {
		Password string  `json:"password"`
		UserIds  []int64 `json:"userIds"`
	}
	DataBatchResetPasswordUser struct {
	}
)

//创建共创用户
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 {
	}
)

//更新共创用户
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 {
	}
)

//获取用户概要数据
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 {
	}
)