refactor: remove ExternalType from CustomerIdentity and related structures
This commit is contained in:
@@ -19,20 +19,19 @@ func (c *ChannelController) AnyConfig() *web.JsonResult {
|
||||
if channel == nil {
|
||||
return web.JsonErrorMsg("接入渠道未初始化")
|
||||
}
|
||||
cfg, externalSource, err := resolveWidgetConfig(channel.ChannelType, channel.ConfigJSON)
|
||||
cfg, err := resolveWidgetConfig(channel.ChannelType, channel.ConfigJSON)
|
||||
if err != nil {
|
||||
return web.JsonError(err)
|
||||
}
|
||||
|
||||
ret := response.WidgetConfigResponse{
|
||||
ChannelID: channel.ChannelID,
|
||||
ChannelType: channel.ChannelType,
|
||||
ExternalSource: externalSource,
|
||||
Title: cfg.Title,
|
||||
Subtitle: cfg.Subtitle,
|
||||
ThemeColor: cfg.ThemeColor,
|
||||
Position: cfg.Position,
|
||||
Width: cfg.Width,
|
||||
ChannelID: channel.ChannelID,
|
||||
ChannelType: channel.ChannelType,
|
||||
Title: cfg.Title,
|
||||
Subtitle: cfg.Subtitle,
|
||||
ThemeColor: cfg.ThemeColor,
|
||||
Position: cfg.Position,
|
||||
Width: cfg.Width,
|
||||
}
|
||||
return web.JsonData(ret)
|
||||
}
|
||||
@@ -45,12 +44,12 @@ type webLikeWidgetConfig struct {
|
||||
Width string
|
||||
}
|
||||
|
||||
func resolveWidgetConfig(channelType, rawConfig string) (*webLikeWidgetConfig, string, error) {
|
||||
func resolveWidgetConfig(channelType, rawConfig string) (*webLikeWidgetConfig, error) {
|
||||
switch channelType {
|
||||
case enums.ChannelTypeWeb:
|
||||
cfg, err := services.ChannelService.ParseWebChannelConfig(rawConfig)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
return nil, err
|
||||
}
|
||||
return &webLikeWidgetConfig{
|
||||
Title: cfg.Title,
|
||||
@@ -58,11 +57,11 @@ func resolveWidgetConfig(channelType, rawConfig string) (*webLikeWidgetConfig, s
|
||||
ThemeColor: cfg.ThemeColor,
|
||||
Position: cfg.Position,
|
||||
Width: cfg.Width,
|
||||
}, string(enums.ExternalSourceWebChat), nil
|
||||
}, nil
|
||||
case enums.ChannelTypeWechatMP:
|
||||
cfg, err := services.ChannelService.ParseWechatMPChannelConfig(rawConfig)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
return nil, err
|
||||
}
|
||||
return &webLikeWidgetConfig{
|
||||
Title: cfg.Title,
|
||||
@@ -70,8 +69,8 @@ func resolveWidgetConfig(channelType, rawConfig string) (*webLikeWidgetConfig, s
|
||||
ThemeColor: cfg.ThemeColor,
|
||||
Position: "right",
|
||||
Width: "100%",
|
||||
}, string(enums.ExternalSourceWechatMP), nil
|
||||
}, nil
|
||||
default:
|
||||
return nil, "", errorsx.InvalidParam("该渠道不支持开放客服配置")
|
||||
return nil, errorsx.InvalidParam("该渠道不支持开放客服配置")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +188,6 @@ type Customer struct {
|
||||
type CustomerIdentity struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement"`
|
||||
CustomerID int64 `gorm:"type:bigint;not null;uniqueIndex:uk_customer_external"` // 为所属客户ID。
|
||||
ExternalType enums.ExternalType `gorm:"type:varchar(30);not null;default:'guest';index"` // ExternalType 为外部身份类型:guest访客,user主动设置的用户信息。
|
||||
ExternalSource enums.ExternalSource `gorm:"type:varchar(30);uniqueIndex:uk_customer_external"` // 为外部身份来源
|
||||
ExternalID string `gorm:"type:varchar(128);index:idx_external_id;uniqueIndex:uk_customer_external"` // 为平台侧用户唯一ID,与访客 ExternalID 对齐。
|
||||
RawProfile string `gorm:"type:text"` // 为第三方原始资料JSON。
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package response
|
||||
|
||||
type WidgetConfigResponse struct {
|
||||
ChannelID string `json:"channelId"`
|
||||
ChannelType string `json:"channelType"`
|
||||
ExternalSource string `json:"externalSource"`
|
||||
Title string `json:"title"`
|
||||
Subtitle string `json:"subtitle"`
|
||||
ThemeColor string `json:"themeColor"`
|
||||
Position string `json:"position"`
|
||||
Width string `json:"width"`
|
||||
ChannelID string `json:"channelId"`
|
||||
ChannelType string `json:"channelType"`
|
||||
Title string `json:"title"`
|
||||
Subtitle string `json:"subtitle"`
|
||||
ThemeColor string `json:"themeColor"`
|
||||
Position string `json:"position"`
|
||||
Width string `json:"width"`
|
||||
}
|
||||
|
||||
@@ -6,26 +6,6 @@ func GetCustomerSourceTypeLabel(sourceType ExternalSource) string {
|
||||
return GetExternalSourceLabel(ExternalSource(sourceType))
|
||||
}
|
||||
|
||||
// ExternalType 客户外部身份类型。
|
||||
type ExternalType string
|
||||
|
||||
const (
|
||||
ExternalTypeGuest ExternalType = "guest"
|
||||
ExternalTypeUser ExternalType = "user"
|
||||
)
|
||||
|
||||
var externalTypeLabelMap = map[ExternalType]string{
|
||||
ExternalTypeGuest: "访客",
|
||||
ExternalTypeUser: "用户",
|
||||
}
|
||||
|
||||
func GetExternalTypeLabel(externalType ExternalType) string {
|
||||
if s, ok := externalTypeLabelMap[externalType]; ok {
|
||||
return s
|
||||
}
|
||||
return string(externalType)
|
||||
}
|
||||
|
||||
// 联系方式类型
|
||||
type ContactType string
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ package enums
|
||||
type ExternalSource string
|
||||
|
||||
const (
|
||||
ExternalSourceWebChat ExternalSource = "web_chat"
|
||||
ExternalSourceWebChat ExternalSource = "guest"
|
||||
ExternalSourceWechatMP ExternalSource = "wechat_mp"
|
||||
ExternalSourceWxWorkKF ExternalSource = "wxwork_kf"
|
||||
)
|
||||
|
||||
var externalSourceLabelMap = map[ExternalSource]string{
|
||||
ExternalSourceWebChat: "网页客服",
|
||||
ExternalSourceWebChat: "访客",
|
||||
ExternalSourceWechatMP: "微信公众号",
|
||||
ExternalSourceWxWorkKF: "企业微信客服",
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import (
|
||||
// ExternalInfo 外部访客身份(IM 客户),与站内 AuthPrincipal 区分。
|
||||
type ExternalInfo struct {
|
||||
ExternalSource enums.ExternalSource `json:"externalSource"`
|
||||
ExternalType enums.ExternalType `json:"externalType"`
|
||||
ExternalID string `json:"externalId"`
|
||||
ExternalName string `json:"externalName"`
|
||||
}
|
||||
@@ -36,7 +35,6 @@ func GetExternalInfo(ctx iris.Context) (*ExternalInfo, error) {
|
||||
return &ExternalInfo{
|
||||
ExternalSource: externalSource,
|
||||
// TODO: 对接业务系统后,根据业务系统用户信息识别 user;未对接时统一按访客处理。
|
||||
ExternalType: enums.ExternalTypeGuest,
|
||||
ExternalID: externalID,
|
||||
ExternalName: parseExternalName(ctx),
|
||||
}, nil
|
||||
|
||||
@@ -744,7 +744,6 @@ func (s *conversationService) LinkConversationCustomer(conversationID, customerI
|
||||
} else {
|
||||
idRow := &models.CustomerIdentity{
|
||||
CustomerID: customerID,
|
||||
ExternalType: enums.ExternalTypeGuest,
|
||||
ExternalSource: enums.ExternalSource(extSrc),
|
||||
ExternalID: extID,
|
||||
Status: enums.StatusOk,
|
||||
|
||||
@@ -82,15 +82,6 @@ export const ExternalSourceLabels: Record<ExternalSource, string> = {
|
||||
[ExternalSource.WxWorkKF]: "企业微信客服",
|
||||
}
|
||||
|
||||
export enum ExternalType {
|
||||
Guest = "guest",
|
||||
User = "user",
|
||||
}
|
||||
export const ExternalTypeLabels: Record<ExternalType, string> = {
|
||||
[ExternalType.Guest]: "访客",
|
||||
[ExternalType.User]: "用户",
|
||||
}
|
||||
|
||||
export enum Gender {
|
||||
Unknown = 0,
|
||||
Male = 1,
|
||||
|
||||
Reference in New Issue
Block a user