|
...
|
...
|
@@ -4,40 +4,44 @@ import "time" |
|
|
|
|
|
|
|
// 用户类型
|
|
|
|
const (
|
|
|
|
UsersTypeEmployee = 1
|
|
|
|
UsersTypeCooperation = 2
|
|
|
|
UsersTypeCompanyAdmin = 1024
|
|
|
|
UserTypeEmployee = 1
|
|
|
|
UserTypeCooperation = 2
|
|
|
|
UserTypeCompanyAdmin = 1024
|
|
|
|
)
|
|
|
|
|
|
|
|
// 用户状态
|
|
|
|
const (
|
|
|
|
UserStatusEnable UsersStatus = 1
|
|
|
|
UserStatusDisable UsersStatus = 2
|
|
|
|
UserStatusDestroy UsersStatus = 3
|
|
|
|
UserStatusEnable UserStatus = 1
|
|
|
|
UserStatusDisable UserStatus = 2
|
|
|
|
UserStatusDestroy UserStatus = 3
|
|
|
|
)
|
|
|
|
|
|
|
|
// 用户
|
|
|
|
type Users struct {
|
|
|
|
type User struct {
|
|
|
|
// 用户Id 用户唯一标识
|
|
|
|
UsersId int64 `json:"usersId,omitempty"`
|
|
|
|
UserId int64 `json:"userId,omitempty"`
|
|
|
|
// 企业id
|
|
|
|
CompanyId int64 `json:"companyId,omitempty"`
|
|
|
|
// 用户基础数据id
|
|
|
|
UsersBaseId int64 `json:"usersBaseId,omitempty"`
|
|
|
|
UserBaseId int64 `json:"userBaseId,omitempty"`
|
|
|
|
// 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加)
|
|
|
|
UsersType int `json:"usersType,omitempty"`
|
|
|
|
UserType int `json:"userType,omitempty"`
|
|
|
|
// 用户编号 企业内标识
|
|
|
|
UsersCode string `json:"usersCode,omitempty"`
|
|
|
|
UserCode string `json:"userCode,omitempty"`
|
|
|
|
// 组织机构
|
|
|
|
OrganizationId int64 `json:"organizationId,omitempty"`
|
|
|
|
// 组织机构
|
|
|
|
Organization *Org `json:"org,omitempty"`
|
|
|
|
// 所属部门
|
|
|
|
DepartmentId int64 `json:"departmentId,omitempty"`
|
|
|
|
// 用户信息 (冗余,数据存在usersBase里面)
|
|
|
|
UsersInfo *UsersInfo `json:"usersInfo,omitempty"`
|
|
|
|
// 部门
|
|
|
|
Department *Department `json:"department,omitempty"`
|
|
|
|
// 用户信息 (冗余,数据存在userBase里面)
|
|
|
|
UserInfo *UserInfo `json:"userInfo,omitempty"`
|
|
|
|
// 用户关联的组织
|
|
|
|
UsersOrg []*Org `json:"usersOrg,omitempty"`
|
|
|
|
UserOrg []*Org `json:"userOrg,omitempty"`
|
|
|
|
// 用户关联的角色
|
|
|
|
UsersRole []*Role `json:"usersRole,omitempty"`
|
|
|
|
UserRole []*Role `json:"userRole,omitempty"`
|
|
|
|
// 收藏的菜单(工作台)(菜单编码列表)
|
|
|
|
FavoriteMenus []string `json:"favoriteMenus,omitempty"`
|
|
|
|
// 共创信息 (共创用户有效)
|
|
...
|
...
|
@@ -52,94 +56,94 @@ type Users struct { |
|
|
|
UpdatedAt time.Time `json:"updatedAt,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type UsersRepository interface {
|
|
|
|
Save(users *Users) (*Users, error)
|
|
|
|
Remove(users *Users) (*Users, error)
|
|
|
|
FindOne(queryOptions map[string]interface{}) (*Users, error)
|
|
|
|
Find(queryOptions map[string]interface{}) (int64, []*Users, error)
|
|
|
|
type UserRepository interface {
|
|
|
|
Save(user *User) (*User, error)
|
|
|
|
Remove(user *User) (*User, error)
|
|
|
|
FindOne(queryOptions map[string]interface{}) (*User, error)
|
|
|
|
Find(queryOptions map[string]interface{}) (int64, []*User, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (users *Users) Identify() interface{} {
|
|
|
|
if users.UsersId == 0 {
|
|
|
|
func (user *User) Identify() interface{} {
|
|
|
|
if user.UserId == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return users.UsersId
|
|
|
|
return user.UserId
|
|
|
|
}
|
|
|
|
|
|
|
|
func (users *Users) Update(data map[string]interface{}) error {
|
|
|
|
if usersId, ok := data["usersId"]; ok {
|
|
|
|
users.UsersId = usersId.(int64)
|
|
|
|
func (user *User) Update(data map[string]interface{}) error {
|
|
|
|
if userId, ok := data["userId"]; ok {
|
|
|
|
user.UserId = userId.(int64)
|
|
|
|
}
|
|
|
|
if companyId, ok := data["companyId"]; ok {
|
|
|
|
users.CompanyId = companyId.(int64)
|
|
|
|
user.CompanyId = companyId.(int64)
|
|
|
|
}
|
|
|
|
if usersBaseId, ok := data["usersBaseId"]; ok {
|
|
|
|
users.UsersBaseId = usersBaseId.(int64)
|
|
|
|
if userBaseId, ok := data["userBaseId"]; ok {
|
|
|
|
user.UserBaseId = userBaseId.(int64)
|
|
|
|
}
|
|
|
|
if usersType, ok := data["usersType"]; ok {
|
|
|
|
users.UsersType = usersType.(int)
|
|
|
|
if userType, ok := data["userType"]; ok {
|
|
|
|
user.UserType = userType.(int)
|
|
|
|
}
|
|
|
|
if usersCode, ok := data["usersCode"]; ok {
|
|
|
|
users.UsersCode = usersCode.(string)
|
|
|
|
if userCode, ok := data["userCode"]; ok {
|
|
|
|
user.UserCode = userCode.(string)
|
|
|
|
}
|
|
|
|
if organizationId, ok := data["organizationId"]; ok {
|
|
|
|
users.OrganizationId = organizationId.(int64)
|
|
|
|
user.OrganizationId = organizationId.(int64)
|
|
|
|
}
|
|
|
|
if departmentId, ok := data["departmentId"]; ok {
|
|
|
|
users.DepartmentId = departmentId.(int64)
|
|
|
|
user.DepartmentId = departmentId.(int64)
|
|
|
|
}
|
|
|
|
if usersName, ok := data["usersName"]; ok {
|
|
|
|
users.UsersInfo.UsersName = usersName.(string)
|
|
|
|
if userName, ok := data["userName"]; ok {
|
|
|
|
user.UserInfo.UserName = userName.(string)
|
|
|
|
}
|
|
|
|
if phone, ok := data["phone"]; ok {
|
|
|
|
users.UsersInfo.Phone = phone.(string)
|
|
|
|
user.UserInfo.Phone = phone.(string)
|
|
|
|
}
|
|
|
|
if avatar, ok := data["avatar"]; ok {
|
|
|
|
users.UsersInfo.Avatar = avatar.(string)
|
|
|
|
user.UserInfo.Avatar = avatar.(string)
|
|
|
|
}
|
|
|
|
if email, ok := data["email"]; ok {
|
|
|
|
users.UsersInfo.Email = email.(string)
|
|
|
|
user.UserInfo.Email = email.(string)
|
|
|
|
}
|
|
|
|
if usersOrg, ok := data["usersOrg"]; ok {
|
|
|
|
users.UsersOrg = usersOrg.([]*Org)
|
|
|
|
if userOrg, ok := data["userOrg"]; ok {
|
|
|
|
user.UserOrg = userOrg.([]*Org)
|
|
|
|
}
|
|
|
|
if usersRole, ok := data["usersRole"]; ok {
|
|
|
|
users.UsersRole = usersRole.([]*Role)
|
|
|
|
if userRole, ok := data["userRole"]; ok {
|
|
|
|
user.UserRole = userRole.([]*Role)
|
|
|
|
}
|
|
|
|
if favoriteMenus, ok := data["favoriteMenus"]; ok {
|
|
|
|
users.FavoriteMenus = favoriteMenus.([]string)
|
|
|
|
user.FavoriteMenus = favoriteMenus.([]string)
|
|
|
|
}
|
|
|
|
if cooperationCompany, ok := data["cooperationCompany"]; ok {
|
|
|
|
users.CooperationInfo.CooperationCompany = cooperationCompany.(string)
|
|
|
|
user.CooperationInfo.CooperationCompany = cooperationCompany.(string)
|
|
|
|
}
|
|
|
|
if cooperationDeadline, ok := data["cooperationDeadline"]; ok {
|
|
|
|
users.CooperationInfo.CooperationDeadline = cooperationDeadline.(time.Time)
|
|
|
|
user.CooperationInfo.CooperationDeadline = cooperationDeadline.(time.Time)
|
|
|
|
}
|
|
|
|
if enableStatus, ok := data["enableStatus"]; ok {
|
|
|
|
users.EnableStatus = enableStatus.(int)
|
|
|
|
user.EnableStatus = enableStatus.(int)
|
|
|
|
}
|
|
|
|
if usersName, ok := data["usersName"]; ok {
|
|
|
|
users.Ext.UsersName = usersName.(string)
|
|
|
|
if userName, ok := data["userName"]; ok {
|
|
|
|
user.Ext.UserName = userName.(string)
|
|
|
|
}
|
|
|
|
if orgName, ok := data["orgName"]; ok {
|
|
|
|
users.Ext.OrgName = orgName.(string)
|
|
|
|
user.Ext.OrgName = orgName.(string)
|
|
|
|
}
|
|
|
|
if phone, ok := data["phone"]; ok {
|
|
|
|
users.Ext.Phone = phone.(string)
|
|
|
|
user.Ext.Phone = phone.(string)
|
|
|
|
}
|
|
|
|
if depName, ok := data["depName"]; ok {
|
|
|
|
users.Ext.DepName = depName.(string)
|
|
|
|
user.Ext.DepName = depName.(string)
|
|
|
|
}
|
|
|
|
if parentDepName, ok := data["parentDepName"]; ok {
|
|
|
|
users.Ext.ParentDepName = parentDepName.(string)
|
|
|
|
user.Ext.ParentDepName = parentDepName.(string)
|
|
|
|
}
|
|
|
|
if createdAt, ok := data["createdAt"]; ok {
|
|
|
|
users.CreatedAt = createdAt.(time.Time)
|
|
|
|
user.CreatedAt = createdAt.(time.Time)
|
|
|
|
}
|
|
|
|
if updatedAt, ok := data["updatedAt"]; ok {
|
|
|
|
users.UpdatedAt = updatedAt.(time.Time)
|
|
|
|
user.UpdatedAt = updatedAt.(time.Time)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type UsersStatus int |
|
|
|
type UserStatus int |
...
|
...
|
|