195 lines
7.2 KiB
Go
195 lines
7.2 KiB
Go
// Package sysin
|
|
// @Link https://github.com/bufanyun/hotgo
|
|
// @Copyright Copyright (c) 2026 HotGo
|
|
// @Author Ms <133814250@qq.com>
|
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
|
package sysin
|
|
|
|
import (
|
|
"context"
|
|
"hotgo/internal/model/input/form"
|
|
|
|
"github.com/gogf/gf/v2/errors/gerror"
|
|
"github.com/gogf/gf/v2/os/gtime"
|
|
)
|
|
|
|
// ImUserListInp 获取IM用户列表
|
|
type ImUserListInp struct {
|
|
form.PageReq
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
UserId string `json:"userId" dc:"用户ID"`
|
|
Nickname string `json:"nickname" dc:"昵称"`
|
|
AuthName string `json:"authName" dc:"登录标识"`
|
|
State *int `json:"state" dc:"账号状态"`
|
|
CreatedAt []*gtime.Time `json:"createdAt" dc:"创建时间"`
|
|
LastSeen []*gtime.Time `json:"lastSeen" dc:"最后在线时间"`
|
|
}
|
|
|
|
func (in *ImUserListInp) Filter(ctx context.Context) (err error) {
|
|
if in.UserId != "" {
|
|
if _, err = ParseOptionalInt64(in.UserId); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
type ImUserListModel struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
TenantName string `json:"tenantName" dc:"租户名称"`
|
|
UserId string `json:"userId" dc:"用户ID"`
|
|
Username string `json:"username" dc:"登录账号"`
|
|
Phone string `json:"phone" dc:"手机号"`
|
|
Nickname string `json:"nickname" dc:"昵称"`
|
|
PublicAccount string `json:"publicAccount" dc:"公开账号"`
|
|
Gender string `json:"gender" dc:"性别"`
|
|
Region string `json:"region" dc:"地区"`
|
|
State int `json:"state" dc:"账号状态"`
|
|
AuthVersion int `json:"authVersion" dc:"认证版本"`
|
|
PasswordUpdatedAt *gtime.Time `json:"passwordUpdatedAt" dc:"密码更新时间"`
|
|
AuthNames string `json:"authNames" dc:"登录标识"`
|
|
Credentials string `json:"credentials" dc:"凭证"`
|
|
LastSeen *gtime.Time `json:"lastSeen" dc:"最后在线时间"`
|
|
UserAgent string `json:"userAgent" dc:"客户端"`
|
|
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
|
UpdatedAt *gtime.Time `json:"updatedAt" dc:"修改时间"`
|
|
}
|
|
|
|
// ImUserViewInp 获取指定IM用户信息
|
|
type ImUserViewInp struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
UserId string `json:"userId" v:"required#用户ID不能为空" dc:"用户ID"`
|
|
}
|
|
|
|
func (in *ImUserViewInp) Filter(ctx context.Context) (err error) {
|
|
if _, err = ParseOptionalInt64(in.UserId); err != nil {
|
|
return gerror.New("用户ID不能为空")
|
|
}
|
|
return
|
|
}
|
|
|
|
type ImUserPasswordResetInp struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
UserId string `json:"userId" v:"required#用户ID不能为空" dc:"用户ID"`
|
|
NewPassword string `json:"newPassword" v:"required#新密码不能为空" dc:"新密码"`
|
|
}
|
|
|
|
func (in *ImUserPasswordResetInp) Filter(ctx context.Context) error {
|
|
if _, err := ParseOptionalInt64(in.UserId); err != nil {
|
|
return err
|
|
}
|
|
if len([]rune(in.NewPassword)) < 3 {
|
|
return gerror.New("新密码长度不能少于3位")
|
|
}
|
|
if len([]byte(in.NewPassword)) > 72 {
|
|
return gerror.New("新密码长度不能超过72字节")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type ImUserRevokeSessionsInp struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
UserId string `json:"userId" v:"required#用户ID不能为空" dc:"用户ID"`
|
|
}
|
|
|
|
func (in *ImUserRevokeSessionsInp) Filter(ctx context.Context) error {
|
|
if _, err := ParseOptionalInt64(in.UserId); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type ImUserStatusInp struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
UserId string `json:"userId" v:"required#用户ID不能为空" dc:"用户ID"`
|
|
State int `json:"state" dc:"账号状态"`
|
|
}
|
|
|
|
func (in *ImUserStatusInp) Filter(ctx context.Context) error {
|
|
if _, err := ParseOptionalInt64(in.UserId); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type ImUserViewModel struct {
|
|
ImUserListModel
|
|
Signature string `json:"signature" dc:"个性签名"`
|
|
AvatarFileId string `json:"avatarFileId" dc:"头像文件ID"`
|
|
BirthDate string `json:"birthDate" dc:"出生日期"`
|
|
ProfileJson string `json:"profileJson" dc:"Tinode Public资料"`
|
|
TrustedJson string `json:"trustedJson" dc:"Tinode Trusted资料"`
|
|
AccessJson string `json:"accessJson" dc:"访问权限"`
|
|
ProfileVersion int `json:"profileVersion" dc:"资料版本"`
|
|
}
|
|
|
|
type ImUserDeviceListInp struct {
|
|
form.PageReq
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
UserId string `json:"userId" v:"required#用户ID不能为空" dc:"用户ID"`
|
|
}
|
|
|
|
func (in *ImUserDeviceListInp) Filter(ctx context.Context) (err error) {
|
|
if _, err = ParseOptionalInt64(in.UserId); err != nil {
|
|
return gerror.New("用户ID不能为空")
|
|
}
|
|
return
|
|
}
|
|
|
|
type ImUserDeviceListModel struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
TenantName string `json:"tenantName" dc:"租户名称"`
|
|
UserId int64 `json:"userId" dc:"用户ID"`
|
|
DeviceId string `json:"deviceId" dc:"设备ID"`
|
|
Platform string `json:"platform" dc:"平台"`
|
|
Lang string `json:"lang" dc:"语言"`
|
|
LastSeen *gtime.Time `json:"lastSeen" dc:"最后活跃时间"`
|
|
PushProvider string `json:"pushProvider" dc:"Push服务商"`
|
|
PushPlatform string `json:"pushPlatform" dc:"Push平台"`
|
|
PushAppVersion string `json:"pushAppVersion" dc:"App版本"`
|
|
PushTokenConfigured bool `json:"pushTokenConfigured" dc:"是否配置Push Token"`
|
|
PushUpdatedAt *gtime.Time `json:"pushUpdatedAt" dc:"Push更新时间"`
|
|
}
|
|
|
|
type ImUserGovernanceInp struct {
|
|
TenantId int64 `json:"tenantId" dc:"租户ID"`
|
|
UserId int64 `json:"userId" dc:"目标用户ID"`
|
|
ActorUserId int64 `json:"actorUserId" dc:"操作IM用户ID"`
|
|
DeviceId string `json:"deviceId" dc:"设备ID"`
|
|
Reason string `json:"reason" dc:"原因"`
|
|
Hard bool `json:"hard" dc:"硬删除"`
|
|
}
|
|
|
|
func (in *ImUserGovernanceInp) Filter(ctx context.Context) (err error) {
|
|
if in.TenantId <= 0 {
|
|
return gerror.New("请选择租户")
|
|
}
|
|
if in.UserId <= 0 {
|
|
return gerror.New("用户ID不能为空")
|
|
}
|
|
if in.ActorUserId <= 0 {
|
|
return gerror.New("操作IM用户ID不能为空")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (in *ImUserGovernanceInp) FilterDevice(ctx context.Context) (err error) {
|
|
if err = in.Filter(ctx); err != nil {
|
|
return err
|
|
}
|
|
if in.DeviceId == "" {
|
|
return gerror.New("设备ID不能为空")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type ImUserCommandModel struct {
|
|
CommandID string `json:"commandId" dc:"命令ID"`
|
|
EventID string `json:"eventId" dc:"Kafka事件ID"`
|
|
Status string `json:"status" dc:"状态"`
|
|
TenantID int64 `json:"tenantId" dc:"租户ID"`
|
|
TenantCode string `json:"tenantCode" dc:"租户编码"`
|
|
EventType string `json:"eventType" dc:"事件类型"`
|
|
IdempotencyKey string `json:"idempotencyKey" dc:"幂等键"`
|
|
}
|