refactor: replace skill code with skill ID across the application

- Updated skill handling to use skill IDs instead of skill codes in various components, services, and models.
- Modified tests to reflect changes in skill identification.
- Removed references to skill codes in favor of skill IDs for consistency and clarity.
- Updated localization files to remove skill code references and adjust error messages accordingly.
This commit is contained in:
mlogclub
2026-06-20 20:42:07 +08:00
parent 39c648f3c1
commit 541e4c5874
49 changed files with 258 additions and 341 deletions
+3 -5
View File
@@ -142,14 +142,12 @@ func getDefaultTeamIDs() string {
}
func getDefaultSkillIDs() (string, error) {
skillItem := repositories.SkillDefinitionRepository.Take(
skillItem := repositories.SkillDefinitionRepository.FindOne(
sqls.DB(),
"code = ? AND status = ?",
skill.AfterSalesEscalationSkillCode,
enums.StatusOk,
sqls.NewCnd().Where("status = ?", enums.StatusOk).Desc("id"),
)
if skillItem == nil {
return "", fmt.Errorf("default test skill not found: %s", skill.AfterSalesEscalationSkillCode)
return "", fmt.Errorf("default test skill not found")
}
return utils.JoinInt64s([]int64{skillItem.ID}), nil
}
-5
View File
@@ -5,10 +5,7 @@ import (
"agent-desk/internal/pkg/enums"
)
const AfterSalesEscalationSkillCode = "after_sales_escalation_skill"
type SkillDefinitionSeed struct {
Code string
Name string
Description string
Instruction string
@@ -22,7 +19,6 @@ func SkillDefinitionSeeds(lang seedlang.Language) []SkillDefinitionSeed {
if lang == seedlang.English {
return []SkillDefinitionSeed{
{
Code: AfterSalesEscalationSkillCode,
Name: "After-sales Escalation",
Description: "Handles incidents, complaints, after-sales follow-up, ticket creation, and human handoff requests. Match only when the user clearly needs after-sales intervention or escalation; do not match ordinary greetings, product introductions, or general inquiries.",
Instruction: `You are the dedicated "After-sales Escalation" skill responsible for customer support requests that require escalation.
@@ -65,7 +61,6 @@ Response requirements:
}
return []SkillDefinitionSeed{
{
Code: AfterSalesEscalationSkillCode,
Name: "售后升级处理",
Description: "处理报障、投诉、售后跟进、建单、转人工等升级诉求。只在用户明确需要售后介入或问题升级处理时命中,不处理普通问候、产品介绍或泛咨询。",
Instruction: `你是“售后升级处理”专项 Skill,负责承接需要升级处理的客服诉求。
+2 -4
View File
@@ -6,13 +6,12 @@ import (
"agent-desk/internal/models"
"agent-desk/internal/repositories"
"fmt"
"strings"
"time"
"github.com/mlogclub/simple/sqls"
)
const AfterSalesEscalationSkillCode = seeds.AfterSalesEscalationSkillCode
type InitResult struct {
Created int
Updated int
@@ -24,7 +23,7 @@ func Init(lang seedlang.Language) (*InitResult, error) {
for _, item := range seedItems {
itemCopy := item
if err := sqls.WithTransaction(func(ctx *sqls.TxContext) error {
existing := repositories.SkillDefinitionRepository.Take(ctx.Tx, "code = ?", itemCopy.Code)
existing := repositories.SkillDefinitionRepository.Take(ctx.Tx, "name = ?", strings.TrimSpace(itemCopy.Name))
if existing != nil {
if err := ctx.Tx.Model(existing).Updates(&itemCopy).Error; err != nil {
return err
@@ -50,7 +49,6 @@ func buildModels(lang seedlang.Language) []models.SkillDefinition {
items := make([]models.SkillDefinition, 0, len(seedItems))
for _, seed := range seedItems {
items = append(items, models.SkillDefinition{
Code: seed.Code,
Name: seed.Name,
Description: seed.Description,
Instruction: seed.Instruction,