Add quick reply, skill definition, and tag seeds for multilingual support
- Implemented QuickReplySeed structure and seeds for both English and Chinese languages. - Created SkillDefinitionSeed structure with detailed instructions and examples for the "After-sales Escalation" skill in both languages. - Added TagSeed structure and corresponding seeds for categorizing inquiries in English and Chinese. - Refactored skill and tag initialization to utilize the new seed structures, ensuring proper data handling and multilingual support. - Updated tests to verify that English seeds do not contain Chinese text, ensuring data integrity.
This commit is contained in:
Vendored
+11
-44
@@ -2,6 +2,7 @@ package tag
|
||||
|
||||
import (
|
||||
"agent-desk/cmd/testdata/seedlang"
|
||||
"agent-desk/cmd/testdata/seeds"
|
||||
"agent-desk/internal/models"
|
||||
"agent-desk/internal/pkg/enums"
|
||||
"agent-desk/internal/repositories"
|
||||
@@ -11,18 +12,18 @@ import (
|
||||
)
|
||||
|
||||
func Init(lang seedlang.Language) error {
|
||||
seed := seedItems(lang)
|
||||
seed := seeds.TagSeeds(lang)
|
||||
return sqls.WithTransaction(func(ctx *sqls.TxContext) error {
|
||||
now := time.Now()
|
||||
for _, row := range seed {
|
||||
existing := repositories.TagRepository.Get(ctx.Tx, row.id)
|
||||
existing := repositories.TagRepository.Get(ctx.Tx, row.ID)
|
||||
if existing == nil {
|
||||
tag := &models.Tag{
|
||||
ID: row.id,
|
||||
ParentID: row.parentID,
|
||||
Name: row.name,
|
||||
ID: row.ID,
|
||||
ParentID: row.ParentID,
|
||||
Name: row.Name,
|
||||
Remark: "",
|
||||
SortNo: row.sortNo,
|
||||
SortNo: row.SortNo,
|
||||
Status: enums.StatusOk,
|
||||
AuditFields: models.AuditFields{
|
||||
CreatedAt: now,
|
||||
@@ -38,11 +39,11 @@ func Init(lang seedlang.Language) error {
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err := repositories.TagRepository.Updates(ctx.Tx, row.id, map[string]any{
|
||||
"parent_id": row.parentID,
|
||||
"name": row.name,
|
||||
if err := repositories.TagRepository.Updates(ctx.Tx, row.ID, map[string]any{
|
||||
"parent_id": row.ParentID,
|
||||
"name": row.Name,
|
||||
"remark": "",
|
||||
"sort_no": row.sortNo,
|
||||
"sort_no": row.SortNo,
|
||||
"status": enums.StatusOk,
|
||||
"updated_at": now,
|
||||
"update_user_id": 0,
|
||||
@@ -54,37 +55,3 @@ func Init(lang seedlang.Language) error {
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
type seedItem struct {
|
||||
id int64
|
||||
parentID int64
|
||||
name string
|
||||
sortNo int
|
||||
}
|
||||
|
||||
func seedItems(lang seedlang.Language) []seedItem {
|
||||
if lang == seedlang.English {
|
||||
return []seedItem{
|
||||
{1, 0, "Pre-sales", 1},
|
||||
{2, 1, "AgentDesk", 1},
|
||||
{3, 2, "Product Inquiry", 1},
|
||||
{4, 2, "Purchase Intent", 1},
|
||||
{5, 0, "After-sales", 2},
|
||||
{6, 5, "AgentDesk", 1},
|
||||
{7, 6, "Issue Feedback", 1},
|
||||
{8, 6, "Product Deployment", 2},
|
||||
{9, 6, "Feature Request", 3},
|
||||
}
|
||||
}
|
||||
return []seedItem{
|
||||
{1, 0, "售前", 1},
|
||||
{2, 1, "AgentDesk", 1},
|
||||
{3, 2, "产品咨询", 1},
|
||||
{4, 2, "购买意向", 1},
|
||||
{5, 0, "售后", 2},
|
||||
{6, 5, "AgentDesk", 1},
|
||||
{7, 6, "问题反馈", 1},
|
||||
{8, 6, "产品部署", 2},
|
||||
{9, 6, "需求工单", 3},
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+4
-3
@@ -2,6 +2,7 @@ package tag
|
||||
|
||||
import (
|
||||
"agent-desk/cmd/testdata/seedlang"
|
||||
"agent-desk/cmd/testdata/seeds"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
@@ -9,9 +10,9 @@ import (
|
||||
var hanTextPattern = regexp.MustCompile(`\p{Han}`)
|
||||
|
||||
func TestEnglishTagSeedsDoNotContainChineseText(t *testing.T) {
|
||||
for _, item := range seedItems(seedlang.English) {
|
||||
if hanTextPattern.MatchString(item.name) {
|
||||
t.Fatalf("english tag seed contains Chinese text: %q", item.name)
|
||||
for _, item := range seeds.TagSeeds(seedlang.English) {
|
||||
if hanTextPattern.MatchString(item.Name) {
|
||||
t.Fatalf("english tag seed contains Chinese text: %q", item.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user