feat: add customer service IM bindings

This commit is contained in:
richjohnrambo
2026-10-14 16:46:20 +08:00
parent ad6d0bbe01
commit 131168c700
9 changed files with 87 additions and 12 deletions
@@ -23,6 +23,9 @@ type CustomerService struct {
ServiceUrl any // 客服跳转URL
BackupContact any // 备用联系方式
SessionMapping *gjson.Json // 第三方会话映射
ImTenantCode any // IM租户代码
ImUserId any // IM客服用户ID
ImUsername any // IM客服登录名
Status any // 状态
Sort any // 排序
Remark any // 备注
@@ -21,6 +21,9 @@ type CustomerService struct {
ServiceUrl string `json:"serviceUrl" orm:"service_url" description:"客服跳转URL"`
BackupContact string `json:"backupContact" orm:"backup_contact" description:"备用联系方式"`
SessionMapping *gjson.Json `json:"sessionMapping" orm:"session_mapping" description:"第三方会话映射"`
ImTenantCode string `json:"imTenantCode" orm:"im_tenant_code" description:"IM租户代码"`
ImUserId string `json:"imUserId" orm:"im_user_id" description:"IM客服用户ID"`
ImUsername string `json:"imUsername" orm:"im_username" description:"IM客服登录名"`
Status int `json:"status" orm:"status" description:"状态"`
Sort int `json:"sort" orm:"sort" description:"排序"`
Remark string `json:"remark" orm:"remark" description:"备注"`
+12 -4
View File
@@ -302,19 +302,27 @@ type CustomerServiceEditInp struct {
AvatarUrl string `json:"avatarUrl" v:"max-length:1000#头像地址不能超过1000个字符"`
WorkTime string `json:"workTime" v:"required|max-length:200#工作时间不能为空|工作时间不能超过200个字符"`
OnlineStatus int `json:"onlineStatus" v:"required|in:1,2#在线状态不能为空|在线状态不合法"`
ServiceUrl string `json:"serviceUrl" v:"required|max-length:1000#客服链接不能为空|客服链接不能超过1000个字符"`
ServiceUrl string `json:"serviceUrl" v:"max-length:1000#客服链接不能超过1000个字符"`
BackupContact string `json:"backupContact" v:"required|max-length:500#备用联系方式不能为空|备用联系方式不能超过500个字符"`
SessionMapping *gjson.Json `json:"sessionMapping"`
ImTenantCode string `json:"imTenantCode" v:"required|max-length:64#IM租户代码不能为空|IM租户代码不能超过64个字符"`
ImUserId string `json:"imUserId" v:"max-length:64#IM用户ID不能超过64个字符"`
ImUsername string `json:"imUsername" v:"max-length:64#IM登录名不能超过64个字符"`
Status int `json:"status" d:"1" v:"required|in:1,2#状态不能为空|状态不合法"`
Sort int `json:"sort"`
Remark string `json:"remark" v:"max-length:500#备注不能超过500个字符"`
}
func (in *CustomerServiceEditInp) Filter(ctx context.Context) error {
u, err := url.Parse(in.ServiceUrl)
if err != nil || !strings.EqualFold(u.Scheme, "https") || u.Host == "" {
return gerror.New("客服链接必须是有效的 HTTPS 地址")
if strings.TrimSpace(in.ServiceUrl) != "" {
u, err := url.Parse(in.ServiceUrl)
if err != nil || !strings.EqualFold(u.Scheme, "https") || u.Host == "" {
return gerror.New("客服链接必须是有效的 HTTPS 地址")
}
}
in.ImTenantCode = strings.ToLower(strings.TrimSpace(in.ImTenantCode))
in.ImUserId = strings.TrimSpace(in.ImUserId)
in.ImUsername = strings.ToLower(strings.TrimSpace(in.ImUsername))
if in.OnlineStatus != consts.CustomerServiceOnline && in.OnlineStatus != consts.CustomerServiceOffline {
return gerror.New("客服在线状态不合法")
}