Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
WorldEpcho
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ford
WorldEpcho
Commits
03e12793
Commit
03e12793
authored
Oct 18, 2024
by
Ford
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了WorldChat支持高并发,加了协程。
parent
53068b6a
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
505 additions
and
21 deletions
+505
-21
config.json
+36
-0
src/config/config.go
+17
-3
src/controllers/WorldController.go
+290
-4
src/gin_test/jsonChineseTranslate.go
+140
-0
src/models/WorldInfo.go
+9
-0
src/service/WorldChat.go
+10
-14
src/service/WorldWebSocketStart.go
+3
-0
src/worldEpcho
+0
-0
No files found.
config.json
View file @
03e12793
...
...
@@ -172,7 +172,43 @@
"cn_name"
:
"郭德纲"
}
},
"business_manager_assessment_config_translations"
:
{
"SceneInformation"
:
"场景信息"
,
"location"
:
"地点"
,
"name"
:
"名称"
,
"security"
:
"有保安"
,
"client"
:
"客户"
,
"appearance"
:
"外观"
,
"attitude"
:
"对用户的态度"
,
"personality"
:
"性格"
,
"introduction"
:
"简介"
,
"roleName"
:
"角色名"
,
"opener"
:
"开场白"
,
"promotion"
:
"推介项目"
,
"projectDescription"
:
"项目介绍"
,
"projectName"
:
"项目名"
,
"username"
:
"用户名"
,
"userBackground"
:
"用户背景信息"
,
"CustomTraining"
:
"定制训练"
,
"sceneRulesCustom"
:
"场景规则定制"
,
"ruleOne"
:
"规则一"
,
"ruleTwo"
:
"规则二"
,
"ruleThree"
:
"规则三"
,
"outcomeSet"
:
"结局集"
,
"date"
:
"date"
,
"id"
:
"id"
,
"result"
:
"result"
,
"difficulty"
:
"难易程度"
,
"AssessmentWeights"
:
"考核权重"
,
"professionalism"
:
"专业程度"
,
"adaptability"
:
"应变能力"
,
"communicationSkills"
:
"沟通能力"
,
"socialEtiquette"
:
"社交礼仪"
}
}
src/config/config.go
View file @
03e12793
...
...
@@ -62,6 +62,10 @@ type AppConfig struct {
JwtSecret
string
`json:"jwt_secret"`
MiGuAuthId
string
`json:"miGuAuthId"`
// 增加 BusinessManagerAssessmentConfigTranslations 字段
BusinessManagerAssessmentConfigTranslations
map
[
string
]
string
`json:"business_manager_assessment_config_translations"`
//英文转中文
ReverseTranslations
map
[
string
]
string
// 反向映射,中文转英文,不需要从JSON解码
SoulUrl
string
`json:"soul_url"`
SoulAuth
string
`json:"soul_auth"`
TranscribeUrl
string
`json:"transcribe_url"`
...
...
@@ -129,8 +133,10 @@ func InitConfig() *AppConfig {
}
*/
if
err
!=
nil
{
println
(
"error is :"
,
err
.
Error
())
fmt
.
Println
(
"Error opening config file:"
,
err
)
return
nil
}
defer
file
.
Close
()
decoder
:=
json
.
NewDecoder
(
file
)
...
...
@@ -138,10 +144,18 @@ func InitConfig() *AppConfig {
err
=
decoder
.
Decode
(
&
conf
)
if
err
!=
nil
{
fmt
.
Println
(
"Error decoding config:"
,
err
)
return
nil
}
println
(
"error is :"
,
err
.
Error
())
// 创建世界配置信息json反向映射字典
reverseTranslations
:=
make
(
map
[
string
]
string
)
for
k
,
v
:=
range
conf
.
BusinessManagerAssessmentConfigTranslations
{
reverseTranslations
[
v
]
=
k
}
// 将反向映射存储为全局变量,或添加到配置结构中
conf
.
ReverseTranslations
=
reverseTranslations
// 假设你在AppConfig中添加了这个字段
Conf
=
&
conf
return
&
conf
...
...
src/controllers/WorldController.go
View file @
03e12793
...
...
@@ -18,6 +18,101 @@ import (
"time"
)
// Business manager assessment translations 是英文到中文的键名映射
/*
var BusinessManagerAssessmentTranslations = map[string]string{
"SceneInformation": "场景信息",
"location": "地点",
"name": "名称",
"security": "有保安",
"client": "客户",
"appearance": "外观",
"attitude": "对用户的态度",
"personality": "性格",
"introduction": "简介",
"roleName": "角色名",
"opener": "开场白",
"promotion": "推介项目",
"projectDescription": "项目介绍",
"projectName": "项目名",
"username": "用户名",
"userBackground": "用户背景信息",
"CustomTraining": "定制训练",
"sceneRulesCustom": "场景规则定制",
"ruleOne": "规则一",
"ruleTwo": "规则二",
"ruleThree": "规则三",
"outcomeSet": "结局集",
"date": "date",
"id": "id",
"result": "result",
"difficulty": "难易程度",
"AssessmentWeights": "考核权重",
"professionalism": "专业程度",
"adaptability": "应变能力",
"communicationSkills": "沟通能力",
"socialEtiquette": "社交礼仪",
}
*/
/*
// 创建中文到英文的逆映射
var reverseTranslations map[string]string
func init() {
BusinessManagerAssessmentTranslations := config.Conf.BusinessManagerAssessmentConfigTranslations
reverseTranslations = make(map[string]string)
for k, v := range BusinessManagerAssessmentTranslations {
reverseTranslations[v] = k
}
}*/
// translateKeys 是递归函数,用于转换JSON对象的键从中文到英文
// 中文到英文
func
TranslateKeysChineseToEnglish
(
data
interface
{})
interface
{}
{
ReverseTranslations
:=
config
.
Conf
.
ReverseTranslations
switch
obj
:=
data
.
(
type
)
{
case
map
[
string
]
interface
{}
:
newMap
:=
make
(
map
[
string
]
interface
{})
for
k
,
v
:=
range
obj
{
newKey
:=
k
if
val
,
ok
:=
ReverseTranslations
[
k
];
ok
{
newKey
=
val
}
newMap
[
newKey
]
=
TranslateKeysChineseToEnglish
(
v
)
}
return
newMap
case
[]
interface
{}
:
for
i
,
v
:=
range
obj
{
obj
[
i
]
=
TranslateKeysChineseToEnglish
(
v
)
}
}
return
data
}
// translateKeys 是递归函数,用于转换JSON对象的键
// 英文转中文
func
TranslateKeysEnglishToChinese
(
data
interface
{})
interface
{}
{
BusinessManagerAssessmentTranslations
:=
config
.
Conf
.
BusinessManagerAssessmentConfigTranslations
switch
obj
:=
data
.
(
type
)
{
case
map
[
string
]
interface
{}
:
newMap
:=
make
(
map
[
string
]
interface
{})
for
k
,
v
:=
range
obj
{
newKey
:=
k
if
val
,
ok
:=
BusinessManagerAssessmentTranslations
[
k
];
ok
{
newKey
=
val
}
newMap
[
newKey
]
=
TranslateKeysEnglishToChinese
(
v
)
}
return
newMap
case
[]
interface
{}
:
for
i
,
v
:=
range
obj
{
obj
[
i
]
=
TranslateKeysEnglishToChinese
(
v
)
}
}
return
data
}
//查询用户与那些世界进行过聊天会话
func
QueryUserToWorldConversation
(
ctx
*
gin
.
Context
)
{
/*
...
...
@@ -781,8 +876,20 @@ func CreateBusinessManagerAssessmentSystem(ctx *gin.Context) {
}
//创建考核系统-世界请求参数结构体
type
CreateWorldRequest
struct
{
WorldName
string
`json:"worldName"`
Description
string
`json:"description"`
Background
string
`json:"background,omitempty"`
ShowHome
string
`json:"showHome,omitempty"`
WorldHeader
string
`json:"worldHeader,omitempty"`
ServiceProviderId
string
`json:"authId"`
Tags
string
`json:"tags"`
ConfigData
string
`json:"configData"`
}
//咪咕 业务经理考核系统创建
func
MiGuCreateBusinessManagerAssessmentSystem
(
ctx
*
gin
.
Context
)
{
func
MiGuCreateBusinessManagerAssessmentSystem
1
(
ctx
*
gin
.
Context
)
{
//鉴权
/*
判断用户是否登录
...
...
@@ -872,7 +979,25 @@ func MiGuCreateBusinessManagerAssessmentSystem(ctx *gin.Context) {
fmt
.
Println
(
"业务经理考核系统配置信息不能为空"
)
return
}
fmt
.
Println
(
"configData => "
,
configData
)
/* configData 英文键转换为中文 */
var
data
map
[
string
]
interface
{}
err
=
json
.
Unmarshal
([]
byte
(
configData
),
&
data
)
if
err
!=
nil
{
fmt
.
Println
(
"Error parsing JSON:"
,
err
)
return
}
// 转换键名
translatedData
:=
TranslateKeysEnglishToChinese
(
data
)
translatedJSON
,
err
:=
json
.
MarshalIndent
(
translatedData
,
""
,
" "
)
if
err
!=
nil
{
fmt
.
Println
(
"Error marshalling JSON:"
,
err
)
return
}
fmt
.
Println
(
" configData translatedJSON ==> "
,
string
(
translatedJSON
))
//fmt.Println("configData => ", configData)
if
background
==
""
{
background
=
"AI智能推演系统"
}
...
...
@@ -966,6 +1091,146 @@ func MiGuCreateBusinessManagerAssessmentSystem(ctx *gin.Context) {
}
//咪咕 业务经理考核系统创建
func
MiGuCreateBusinessManagerAssessmentSystem
(
ctx
*
gin
.
Context
)
{
var
request
CreateWorldRequest
if
err
:=
ctx
.
ShouldBindJSON
(
&
request
);
err
!=
nil
{
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
InvalidParams
,
"data"
:
nil
,
"message"
:
"请求数据不正确"
})
return
}
// 从请求头 Authorization 中提取令牌
tokenString
:=
ctx
.
GetHeader
(
"Token"
)
if
tokenString
!=
""
{
// 解析并验证 JWT 令牌
isValid
,
err
:=
service
.
IsValidMiGuToken
(
tokenString
)
if
err
!=
nil
||
!
isValid
{
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
InvalidToken
,
"data"
:
nil
,
"message"
:
"无效或已过期的令牌"
})
return
}
}
else
{
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
UnauthorizedStatus
,
"data"
:
nil
,
"message"
:
"请求头中无token,或未授权的token访问"
})
return
}
if
request
.
WorldName
==
""
||
request
.
Description
==
""
{
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
EmptyParamsError
,
"data"
:
nil
,
"message"
:
"世界名称和描述信息不能为空"
})
return
}
if
request
.
ServiceProviderId
==
""
{
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
EmptyParamsError
,
"data"
:
nil
,
"message"
:
"服务商id不能为空"
})
return
}
sp
,
err
:=
models
.
GetServiceProviderById
(
request
.
ServiceProviderId
)
if
err
!=
nil
||
sp
==
nil
{
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
NotFound
,
"data"
:
nil
,
"message"
:
"根据服务商id查询服务商出错或服务商不存在"
,
"error"
:
err
.
Error
()})
return
}
//可以访问的标签
// 创建一个空切片存储匹配的标签
matchingTags
:=
[]
string
{}
// 分割字符串,得到单独的字符串
tagsSplit
:=
strings
.
Split
(
request
.
Tags
,
","
)
for
_
,
tagStr
:=
range
tagsSplit
{
/*TagsArr = append(TagsArr, tagStr)
if !ContainsString(TagsArr, SP.AccessibleTags) {
ctx.JSON(http.StatusOK, gin.H{"code": 0, "message": "不包含该服务商可访问的世界标签!"})
fmt.Println("不包含该服务商可访问的世界标签")
return
}*/
//如果包含服务商可访问的世界标签,则遍历将包含的标签放入数组
// 检查每个用户标签是否被服务商允许
if
ContainsString
(
sp
.
AccessibleTags
,
tagStr
)
{
matchingTags
=
append
(
matchingTags
,
tagStr
)
}
}
// 如果没有任何匹配的标签,则返回错误信息
if
len
(
matchingTags
)
==
0
{
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
NotFound
,
"data"
:
nil
,
"message"
:
"不包含该服务商可访问的世界标签!"
})
fmt
.
Println
(
"不包含该服务商可访问的世界标签"
)
return
}
if
request
.
ConfigData
==
""
{
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
EmptyParamsError
,
"data"
:
nil
,
"message"
:
"业务经理考核系统配置信息不能为空"
})
return
}
/* configData 英文键转换为中文 */
var
data
map
[
string
]
interface
{}
if
err
:=
json
.
Unmarshal
([]
byte
(
request
.
ConfigData
),
&
data
);
err
!=
nil
{
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
ParamParseError
,
"data"
:
nil
,
"message"
:
"解析配置数据出错"
})
return
}
// 转换键名
translatedData
:=
TranslateKeysEnglishToChinese
(
data
)
translatedJSON
,
err
:=
json
.
MarshalIndent
(
translatedData
,
""
,
" "
)
if
err
!=
nil
{
fmt
.
Println
(
"Error marshalling JSON:"
,
err
)
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
ParamParseError
,
"data"
:
nil
,
"message"
:
"解析配置数据出错"
})
return
}
fmt
.
Println
(
" configData translatedJSON ==> "
,
string
(
translatedJSON
))
// 设置默认值
if
request
.
Background
==
""
{
request
.
Background
=
"AI智能推演系统"
}
if
request
.
ShowHome
==
""
{
request
.
ShowHome
=
"false"
}
if
request
.
WorldHeader
==
""
{
request
.
WorldHeader
=
"AI智能考核系统"
}
session
:=
database
.
Engine
.
NewSession
()
defer
session
.
Close
()
if
err
:=
session
.
Begin
();
err
!=
nil
{
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
InternalError
,
"data"
:
nil
,
"message"
:
"开启事务失败"
})
return
}
_
,
exist
,
err
:=
models
.
GetWorldInfoByName_Tx
(
session
,
request
.
WorldName
)
if
err
!=
nil
{
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
ErrorDatabase
,
"data"
:
nil
,
"message"
:
"根据世界名称查询世界信息出错"
})
return
}
if
exist
{
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
ErrorDatabase
,
"data"
:
nil
,
"message"
:
"世界名称已存在,请更换世界名称"
})
return
}
worldInfo
:=
&
models
.
WorldInfo
{
Name
:
request
.
WorldName
,
Description
:
request
.
Description
,
Background
:
request
.
Background
,
Tags
:
matchingTags
,
ShowHome
:
request
.
ShowHome
,
WorldHeader
:
request
.
WorldHeader
,
ConfigData
:
string
(
translatedJSON
),
}
var
newWorldInfo
*
models
.
WorldInfo
if
newWorldInfo
,
err
=
models
.
CreateWorldInfo
(
session
,
worldInfo
);
err
!=
nil
{
session
.
Rollback
()
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
ErrorDatabase
,
"data"
:
nil
,
"message"
:
"创建业务经理考核系统世界出错"
})
return
}
if
err
:=
session
.
Commit
();
err
!=
nil
{
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
InternalError
,
"data"
:
nil
,
"message"
:
"事务提交失败"
})
return
}
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
SUCCESS
,
"data"
:
gin
.
H
{
"newWorldInfo"
:
newWorldInfo
},
"message"
:
"创建业务经理考核系统世界推演成功"
})
}
//创建世界信息
func
CreateWorldInfo
(
ctx
*
gin
.
Context
)
{
/*
...
...
@@ -1424,6 +1689,27 @@ func MiGuQueryBusinessManagerWorldInfo(ctx *gin.Context) {
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
ErrorDatabase
,
"data"
:
nil
,
"message"
:
"查询世界信息失败"
})
return
}
/*
转换世界配置信息中的英文字段
*/
var
data
map
[
string
]
interface
{}
for
i
,
world_info
:=
range
worldInfo
{
if
err
:=
json
.
Unmarshal
([]
byte
(
world_info
.
ConfigData
),
&
data
);
err
!=
nil
{
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
ParamParseError
,
"data"
:
nil
,
"message"
:
"解析配置数据出错"
})
return
}
// 转换键名
translatedData
:=
TranslateKeysChineseToEnglish
(
data
)
translatedJSON
,
err
:=
json
.
MarshalIndent
(
translatedData
,
""
,
" "
)
if
err
!=
nil
{
fmt
.
Println
(
"Error marshalling JSON:"
,
err
)
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"code"
:
e
.
ParamParseError
,
"data"
:
nil
,
"message"
:
"解析配置数据出错"
})
return
}
worldInfo
[
i
]
.
ConfigData
=
string
(
translatedJSON
)
fmt
.
Println
(
" configData translatedJSON ==> "
,
string
(
translatedJSON
))
}
if
worldInfo
!=
nil
{
ctx
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
...
...
@@ -1532,11 +1818,11 @@ func MiGuWorldResetNeuralFile(c *gin.Context) {
var
req
Request
if
err
:=
c
.
ShouldBindJSON
(
&
req
);
err
!=
nil
{
c
.
JSON
(
http
.
Status
BadRequest
,
gin
.
H
{
"code"
:
e
.
ParamParseError
,
"data"
:
nil
,
"message"
:
"请求参数错误: "
+
err
.
Error
()})
c
.
JSON
(
http
.
Status
OK
,
gin
.
H
{
"code"
:
e
.
ParamParseError
,
"data"
:
nil
,
"message"
:
"请求参数错误: "
+
err
.
Error
()})
return
}
if
req
.
Uid
==
""
||
req
.
WorldId
==
""
{
c
.
JSON
(
http
.
Status
BadRequest
,
gin
.
H
{
"code"
:
e
.
EmptyParamsError
,
"data"
:
nil
,
"message"
:
"必需的参数 uid 或 worldId 缺失"
})
c
.
JSON
(
http
.
Status
OK
,
gin
.
H
{
"code"
:
e
.
EmptyParamsError
,
"data"
:
nil
,
"message"
:
"必需的参数 uid 或 worldId 缺失"
})
return
}
...
...
src/gin_test/jsonChineseTranslate.go
0 → 100644
View file @
03e12793
package
main
import
(
"encoding/json"
"fmt"
)
// translations 是英文到中文的键名映射
var
translations
=
map
[
string
]
string
{
"SceneInformation"
:
"场景信息"
,
"location"
:
"地点"
,
"name"
:
"名称"
,
"security"
:
"有保安"
,
"client"
:
"客户"
,
"appearance"
:
"外观"
,
"attitude"
:
"对用户的态度"
,
"personality"
:
"性格"
,
"introduction"
:
"简介"
,
"roleName"
:
"角色名"
,
"opener"
:
"开场白"
,
"promotion"
:
"推介项目"
,
"projectDescription"
:
"项目介绍"
,
"projectName"
:
"项目名"
,
"username"
:
"用户名"
,
"userBackground"
:
"用户背景信息"
,
"CustomTraining"
:
"定制训练"
,
"sceneRulesCustom"
:
"场景规则定制"
,
"ruleOne"
:
"规则一"
,
"ruleTwo"
:
"规则二"
,
"ruleThree"
:
"规则三"
,
"outcomeSet"
:
"结局集"
,
"date"
:
"date"
,
"id"
:
"id"
,
"result"
:
"result"
,
"difficulty"
:
"难易程度"
,
"AssessmentWeights"
:
"考核权重"
,
"professionalism"
:
"专业程度"
,
"adaptability"
:
"应变能力"
,
"communicationSkills"
:
"沟通能力"
,
"socialEtiquette"
:
"社交礼仪"
,
}
// translateKeys 是递归函数,用于转换JSON对象的键
func
translateKeys
(
data
interface
{})
interface
{}
{
switch
obj
:=
data
.
(
type
)
{
case
map
[
string
]
interface
{}
:
newMap
:=
make
(
map
[
string
]
interface
{})
for
k
,
v
:=
range
obj
{
newKey
:=
k
if
val
,
ok
:=
translations
[
k
];
ok
{
newKey
=
val
}
newMap
[
newKey
]
=
translateKeys
(
v
)
}
return
newMap
case
[]
interface
{}
:
for
i
,
v
:=
range
obj
{
obj
[
i
]
=
translateKeys
(
v
)
}
}
return
data
}
func
main
()
{
jsonStr
:=
`{
"ConfigData": {
"SceneInformation": {
"location": {
"name": "南京市移动办公大楼",
"security": false
},
"client": [
{
"appearance": "和蔼可亲,穿着朴素",
"attitude": "温和、耐心",
"personality": "温和、耐心",
"introduction": "来移动想要给家里办宽带的客户,赵文生,教育水平:中专,职业背景:退休\n - 目的性:家里要办宽带,来移动大厅想看看为家庭提供稳定的网络环境。\n已知信息:对宽带费用没概念,只知道自己要手机刷短视频快的,最好可以有话费套餐方便联系子女的,但是每个月预算不超过100元,在这个区间都是可以考虑的预算,对态度好的服务别有青睐。 \n知识库背景:\no对宽带的了解较少,主要用于观看电视、视频通话等。\no可能需要子女或工作人员的帮助来了解和使用宽带。\n3.消费心理预期:\no希望宽带费用不高,操作简单易懂。主要想依赖宽带,对通话和流量的要求不高,可有可无\no对网络速度的要求相对较低,主要关注稳定性。\n4.心理特征:\no目的性:与家人保持联系,丰富退休生活。\no心理活动预期:担心操作复杂,遇到问题时希望能得到及时的帮助。\n5.性格特征:\no决策风格:依赖他人的建议,比较保守。\no风险偏好:极低风险,追求稳定和安心。\no个性:节俭,注重实用性。\n6.服务偏好:\no偏好上门服务和面对面的指导。\no对客服的耐心和细心程度青睐程度较高。",
"roleName": "赵文生"
}
],
"opener": "您的身份是南京移动的宽带业务经理,请以您专业的知识和热情的服务,开始您的营销任务,为他带来更加便捷和快速的互联网生活体验。坐在柜台对面的,是一位和蔼可亲,穿着朴素的南京市民,您正准备向他展开宽带业务的推广",
"promotion": {
"projectDescription": "面向个人或者企业提供高质量的宽带业务",
"projectName": "南京移动宽带活动"
},
"username": "经理",
"userBackground": "中国移动南京宽带业务经理"
},
"CustomTraining": {
"sceneRulesCustom": {
"ruleOne": "客户服务对所有客户的提问和反馈要及时响应,确保在24小时内回复,处理客户投诉时保持礼貌和耐心,积极解决问题并记录每个案例。提供清晰准确的信息,避免引起客户的混淆",
"ruleThree": "数据保护:严格保密客户和公司的敏感信息,防止未经授权的访问和泄露。所有的电子数据必须备份,并采取适当的安全措施保护。遵守相关的数据保护法律和法规,例如GDPR。",
"ruleTwo": "财务管理,所有的财务交易必须记录在案,确保账目清晰透明。严格遵守预算,不得擅自超支或改变用途。定期进行财务审计,确保没有违规行为。"
},
"outcomeSet": [
{
"date": "所有项目目标按时完成,超出预期表现",
"id": 0,
"result": "达成协议"
},
{
"date": "项目目标基本达成,存在小幅度延迟",
"id": 1,
"result": "下次再议"
},
{
"date": "项目目标未达成,表现不佳",
"id": 2,
"result": "遗憾收场"
}
],
"difficulty": "简单"
},
"AssessmentWeights": {
"professionalism": "20",
"adaptability": "40",
"communicationSkills": "90",
"socialEtiquette": "80"
}
}
}
`
var
data
map
[
string
]
interface
{}
err
:=
json
.
Unmarshal
([]
byte
(
jsonStr
),
&
data
)
if
err
!=
nil
{
fmt
.
Println
(
"Error parsing JSON:"
,
err
)
return
}
// 转换键名
translatedData
:=
translateKeys
(
data
)
translatedJSON
,
err
:=
json
.
MarshalIndent
(
translatedData
,
""
,
" "
)
if
err
!=
nil
{
fmt
.
Println
(
"Error marshalling JSON:"
,
err
)
return
}
fmt
.
Println
(
string
(
translatedJSON
))
}
src/models/WorldInfo.go
View file @
03e12793
...
...
@@ -43,6 +43,15 @@ func AddWorldInfo(session *xorm.Session, worldInfo *WorldInfo) (int64, error) {
}
func
CreateWorldInfo
(
session
*
xorm
.
Session
,
worldInfo
*
WorldInfo
)
(
*
WorldInfo
,
error
)
{
_
,
err
:=
session
.
Insert
(
worldInfo
)
if
err
!=
nil
{
return
nil
,
err
// Return 0 if there's an error since ID cannot be negative
}
return
worldInfo
,
nil
// Return the new world's ID
}
//根据世界id查询世界信息
func
GetWorld
(
session
*
xorm
.
Session
,
id
int64
)
(
*
WorldInfo
,
error
)
{
world
:=
&
WorldInfo
{}
...
...
src/service/WorldChat.go
View file @
03e12793
...
...
@@ -6,24 +6,17 @@ import (
"WorldEpcho/src/datasource"
"WorldEpcho/src/models"
"WorldEpcho/src/utils"
"github.com/gin-contrib/sessions"
"os"
"strconv"
"strings"
"time"
//"time"
//"chat/cache"
//"chat/conf"
"encoding/json"
"fmt"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
"log"
"net/http"
//"strconv"
//"time"
"os"
"strconv"
"strings"
"time"
)
//const month = 60 * 60 * 24 * 30 // 按照30天算一个月
...
...
@@ -1052,7 +1045,7 @@ func ParseEndStrAndReformat(response *WorldSoulReplyMsg) *WorldSoulReplyMsg {
// 解析 "EndStr" 中的详细字段
title
:=
strings
.
Split
(
endStr
,
"@"
)[
0
]
// 提取 '@' 前的标题
overallScore
:=
extractBetween
(
endStr
,
"【整体评分】:"
,
"
\n
"
)
// 提取整体评分
objectiveEvaluation
:=
extract
ToEnd
(
endStr
,
"【客观评价】:"
)
// 提取客观评价至字符串末尾
objectiveEvaluation
:=
extract
Between
(
endStr
,
"【客观评价】:"
,
"## 【整体评分】"
)
// 提取客观评价至字符串末尾
// 将 "EndStr" 结构化为 JSON 对象
endStrObj
:=
map
[
string
]
interface
{}{
...
...
@@ -1077,7 +1070,10 @@ func ParseEndStrAndReformat(response *WorldSoulReplyMsg) *WorldSoulReplyMsg {
newResponse
.
WObj
[
"emotion"
]
=
emotion
delete
(
newResponse
.
WObj
,
"表情"
)
}
if
chatTime
,
exists
:=
newResponse
.
WObj
[
"时间"
];
exists
{
newResponse
.
WObj
[
"time"
]
=
chatTime
delete
(
newResponse
.
WObj
,
"时间"
)
}
return
&
newResponse
// 返回修改后的新响应体
}
...
...
src/service/WorldWebSocketStart.go
View file @
03e12793
...
...
@@ -62,6 +62,9 @@ func (manager *WorldClientManager) WorldWebSocketStart() {
log
.
Printf
(
"消息发送失败: %v"
,
err
)
continue
}
if
conn
.
Send
!=
nil
{
close
(
conn
.
Send
)
}
delete
(
WorldManager
.
Client
,
utils
.
Strval
(
conn
.
WorldConversations
.
Uid
))
}
}
...
...
src/worldEpcho
View file @
03e12793
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment