185 lines
7.0 KiB
Go
185 lines
7.0 KiB
Go
package sysin
|
|
|
|
import (
|
|
"context"
|
|
"hotgo/internal/consts"
|
|
"hotgo/internal/library/dict"
|
|
"hotgo/internal/model/input/form"
|
|
"strings"
|
|
|
|
"github.com/gogf/gf/v2/errors/gerror"
|
|
"github.com/gogf/gf/v2/os/gtime"
|
|
)
|
|
|
|
type ImOrgDepartmentListInp struct {
|
|
form.PageReq
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
DepartmentId string `json:"departmentId" dc:"部门ID"`
|
|
ParentId string `json:"parentId" dc:"上级部门ID"`
|
|
Name string `json:"name" dc:"部门名称"`
|
|
State string `json:"state" dc:"状态"`
|
|
}
|
|
|
|
func (in *ImOrgDepartmentListInp) Filter(ctx context.Context) (err error) { return }
|
|
|
|
type ImOrgDepartmentModel struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
TenantName string `json:"tenantName" dc:"租户名称"`
|
|
Id int64 `json:"id" dc:"ID"`
|
|
DepartmentId string `json:"departmentId" dc:"部门ID"`
|
|
Name string `json:"name" dc:"部门名称"`
|
|
ParentId string `json:"parentId" dc:"上级部门ID"`
|
|
SortOrder int `json:"sortOrder" dc:"排序"`
|
|
Version int `json:"version" dc:"版本"`
|
|
State string `json:"state" dc:"状态"`
|
|
ChildCount int `json:"childCount" dc:"子部门数"`
|
|
MemberCount int `json:"memberCount" dc:"成员数"`
|
|
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
|
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
|
}
|
|
|
|
type ImOrgDepartmentEditInp struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
Id int64 `json:"id" dc:"ID"`
|
|
DepartmentId string `json:"departmentId" dc:"部门ID"`
|
|
Name string `json:"name" dc:"部门名称"`
|
|
ParentId string `json:"parentId" dc:"上级部门ID"`
|
|
SortOrder int `json:"sortOrder" dc:"排序"`
|
|
State string `json:"state" dc:"状态"`
|
|
}
|
|
|
|
func (in *ImOrgDepartmentEditInp) Filter(ctx context.Context) (err error) {
|
|
in.Name = strings.TrimSpace(in.Name)
|
|
in.DepartmentId = strings.TrimSpace(in.DepartmentId)
|
|
in.ParentId = strings.TrimSpace(in.ParentId)
|
|
in.State = strings.TrimSpace(in.State)
|
|
if in.Name == "" {
|
|
return gerror.New("部门名称不能为空")
|
|
}
|
|
if in.ParentId == "" {
|
|
in.ParentId = "root"
|
|
}
|
|
if in.State == "" {
|
|
in.State = consts.ImOrgDepartmentStateActive
|
|
}
|
|
if !dict.HasOptionKey(consts.ImOrgDepartmentStateOptions, in.State) {
|
|
return gerror.New("部门状态不合法")
|
|
}
|
|
return
|
|
}
|
|
|
|
type ImOrgDepartmentDeleteInp struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
DepartmentId string `json:"departmentId" v:"required#部门ID不能为空" dc:"部门ID"`
|
|
}
|
|
|
|
func (in *ImOrgDepartmentDeleteInp) Filter(ctx context.Context) (err error) {
|
|
in.DepartmentId = strings.TrimSpace(in.DepartmentId)
|
|
if in.DepartmentId == "" {
|
|
return gerror.New("部门ID不能为空")
|
|
}
|
|
return
|
|
}
|
|
|
|
type ImOrgMemberListInp struct {
|
|
form.PageReq
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
DepartmentId string `json:"departmentId" dc:"部门ID"`
|
|
UserId int64 `json:"userId" dc:"用户ID"`
|
|
Query string `json:"query" dc:"关键词"`
|
|
EmploymentState string `json:"employmentState" dc:"在职状态"`
|
|
}
|
|
|
|
func (in *ImOrgMemberListInp) Filter(ctx context.Context) (err error) { return }
|
|
|
|
type ImOrgMemberModel struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
TenantName string `json:"tenantName" dc:"租户名称"`
|
|
Id int64 `json:"id" dc:"ID"`
|
|
DepartmentId string `json:"departmentId" dc:"部门ID"`
|
|
DepartmentName string `json:"departmentName" dc:"部门名称"`
|
|
UserId int64 `json:"userId" dc:"用户ID"`
|
|
DisplayName string `json:"displayName" dc:"展示名称"`
|
|
Position string `json:"position" dc:"岗位"`
|
|
AvatarFileId string `json:"avatarFileId" dc:"头像文件ID"`
|
|
Mobile string `json:"mobile" dc:"手机号"`
|
|
Email string `json:"email" dc:"邮箱"`
|
|
EmploymentState string `json:"employmentState" dc:"在职状态"`
|
|
Contactable int `json:"contactable" dc:"是否可联系"`
|
|
SortOrder int `json:"sortOrder" dc:"排序"`
|
|
Version int `json:"version" dc:"版本"`
|
|
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
|
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
|
}
|
|
|
|
type ImOrgMemberEditInp struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
Id int64 `json:"id" dc:"ID"`
|
|
DepartmentId string `json:"departmentId" dc:"部门ID"`
|
|
UserId int64 `json:"userId" dc:"用户ID"`
|
|
DisplayName string `json:"displayName" dc:"展示名称"`
|
|
Position string `json:"position" dc:"岗位"`
|
|
AvatarFileId string `json:"avatarFileId" dc:"头像文件ID"`
|
|
Mobile string `json:"mobile" dc:"手机号"`
|
|
Email string `json:"email" dc:"邮箱"`
|
|
EmploymentState string `json:"employmentState" dc:"在职状态"`
|
|
Contactable int `json:"contactable" dc:"是否可联系"`
|
|
SortOrder int `json:"sortOrder" dc:"排序"`
|
|
}
|
|
|
|
func (in *ImOrgMemberEditInp) Filter(ctx context.Context) (err error) {
|
|
in.DepartmentId = strings.TrimSpace(in.DepartmentId)
|
|
in.DisplayName = strings.TrimSpace(in.DisplayName)
|
|
in.Position = strings.TrimSpace(in.Position)
|
|
in.AvatarFileId = strings.TrimSpace(in.AvatarFileId)
|
|
in.Mobile = strings.TrimSpace(in.Mobile)
|
|
in.Email = strings.TrimSpace(in.Email)
|
|
in.EmploymentState = strings.TrimSpace(in.EmploymentState)
|
|
if in.DepartmentId == "" {
|
|
return gerror.New("部门ID不能为空")
|
|
}
|
|
if in.UserId <= 0 {
|
|
return gerror.New("用户ID不能为空")
|
|
}
|
|
if in.EmploymentState == "" {
|
|
in.EmploymentState = consts.ImOrgEmploymentStateActive
|
|
}
|
|
if !dict.HasOptionKey(consts.ImOrgEmploymentStateOptions, in.EmploymentState) {
|
|
return gerror.New("在职状态不合法")
|
|
}
|
|
if !dict.HasOptionKey(consts.ImOrgContactableOptions, in.Contactable) {
|
|
return gerror.New("可联系状态不合法")
|
|
}
|
|
return
|
|
}
|
|
|
|
type ImOrgMemberDeleteInp struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
Id int64 `json:"id" v:"required#成员关系ID不能为空" dc:"ID"`
|
|
}
|
|
|
|
func (in *ImOrgMemberDeleteInp) Filter(ctx context.Context) (err error) {
|
|
if in.Id <= 0 {
|
|
return gerror.New("成员关系ID不能为空")
|
|
}
|
|
return
|
|
}
|
|
|
|
type ImOrgSearchInp struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
Query string `json:"query" v:"required#关键词不能为空" dc:"关键词"`
|
|
}
|
|
|
|
func (in *ImOrgSearchInp) Filter(ctx context.Context) (err error) {
|
|
in.Query = strings.TrimSpace(in.Query)
|
|
if in.Query == "" {
|
|
return gerror.New("关键词不能为空")
|
|
}
|
|
return
|
|
}
|
|
|
|
type ImOrgSearchModel struct {
|
|
Departments []*ImOrgDepartmentModel `json:"departments" dc:"部门"`
|
|
Members []*ImOrgMemberModel `json:"members" dc:"成员"`
|
|
}
|