feat: add IM org and notification admin
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
package sysin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model/input/form"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
type ImNotificationTemplateListInp struct {
|
||||
form.PageReq
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Scene string `json:"scene" dc:"通知场景"`
|
||||
Status *int `json:"status" dc:"状态"`
|
||||
}
|
||||
|
||||
func (in *ImNotificationTemplateListInp) Filter(ctx context.Context) (err error) { return }
|
||||
|
||||
type ImNotificationTemplateListModel struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
TenantName string `json:"tenantName" dc:"租户名称"`
|
||||
Id int64 `json:"id" dc:"ID"`
|
||||
Scene string `json:"scene" dc:"通知场景"`
|
||||
Name string `json:"name" dc:"场景名称"`
|
||||
InAppEnabled int `json:"inAppEnabled" dc:"站内通知"`
|
||||
PushEnabled int `json:"pushEnabled" dc:"Push通知"`
|
||||
SmsEnabled int `json:"smsEnabled" dc:"短信通知"`
|
||||
Status int `json:"status" dc:"状态"`
|
||||
TitleTemplate string `json:"titleTemplate" dc:"标题模板"`
|
||||
ContentTemplate string `json:"contentTemplate" dc:"内容模板"`
|
||||
PayloadJson string `json:"payloadJson" dc:"扩展JSON"`
|
||||
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
||||
}
|
||||
|
||||
type ImNotificationTemplateUpdateInp struct {
|
||||
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
||||
Scene string `json:"scene" v:"required#通知场景不能为空" dc:"通知场景"`
|
||||
InAppEnabled int `json:"inAppEnabled" dc:"站内通知"`
|
||||
PushEnabled int `json:"pushEnabled" dc:"Push通知"`
|
||||
SmsEnabled int `json:"smsEnabled" dc:"短信通知"`
|
||||
Status int `json:"status" dc:"状态"`
|
||||
TitleTemplate string `json:"titleTemplate" dc:"标题模板"`
|
||||
ContentTemplate string `json:"contentTemplate" dc:"内容模板"`
|
||||
PayloadJson *gjson.Json `json:"payloadJson" dc:"扩展JSON"`
|
||||
}
|
||||
|
||||
func (in *ImNotificationTemplateUpdateInp) Filter(ctx context.Context) (err error) {
|
||||
in.Scene = strings.TrimSpace(in.Scene)
|
||||
in.TitleTemplate = strings.TrimSpace(in.TitleTemplate)
|
||||
in.ContentTemplate = strings.TrimSpace(in.ContentTemplate)
|
||||
if !dict.HasOptionKey(consts.ImNotificationSceneOptions, in.Scene) {
|
||||
return gerror.New("通知场景不合法")
|
||||
}
|
||||
if !dict.HasOptionKey(consts.ImNotificationTemplateStatusOptions, in.Status) {
|
||||
return gerror.New("通知模板状态不合法")
|
||||
}
|
||||
if in.TitleTemplate == "" {
|
||||
return gerror.New("标题模板不能为空")
|
||||
}
|
||||
if in.ContentTemplate == "" {
|
||||
return gerror.New("内容模板不能为空")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
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:"成员"`
|
||||
}
|
||||
Reference in New Issue
Block a user