- service/dto/controller 各拆 18 文件,一表一文件;跨表编排留在 outfit_generation_task_service - controller 共享 struct(outfit/member)保 /outfit/*、/member/* 前缀,路由零漂移(28 路径 diff 为空) - 修复 4 个缺失 g.Meta handler:/user/profile、/avatar/get、/body-measurement/get、/hairstyle/list 从 ALL 收敛为 GET - 工具包并入 agent/ 单包(weather/imagegen/avatar/scoring),NewCache 泛化 NewTTLCache - 虎皮椒支付适配器内联 service/payment_order_service.go,member 服务拆 4 表文件 - 冒烟 21 路径全绿 + 客户端 dart analyze 零 error
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
package service
|
||
|
||
import (
|
||
"context"
|
||
"encoding/json"
|
||
|
||
"slogan-agent/styleagent/consts"
|
||
"slogan-agent/styleagent/dao"
|
||
)
|
||
|
||
type scoringRuleService struct{}
|
||
|
||
var ScoringRuleService = new(scoringRuleService)
|
||
|
||
// Threshold 方案及格分(scoring_rule.dimension=threshold)
|
||
func (s *scoringRuleService) Threshold(ctx context.Context) int {
|
||
threshold := consts.DefaultScoreThreshold
|
||
rules, err := dao.ScoringRule.ListEnabled(ctx)
|
||
if err != nil {
|
||
return threshold
|
||
}
|
||
for _, r := range rules {
|
||
if r.Dimension == "threshold" {
|
||
var v struct {
|
||
Pass int `json:"pass"`
|
||
}
|
||
if json.Unmarshal([]byte(r.RulesJson), &v) == nil && v.Pass > 0 {
|
||
return v.Pass
|
||
}
|
||
}
|
||
}
|
||
return threshold
|
||
}
|
||
|
||
// EffectLimit 每日效果图基础额度(scoring_rule.dimension=effect_limit)
|
||
func (s *scoringRuleService) EffectLimit(ctx context.Context) int {
|
||
limit := consts.DefaultDailyEffectLimit
|
||
rules, err := dao.ScoringRule.ListEnabled(ctx)
|
||
if err != nil {
|
||
return limit
|
||
}
|
||
for _, r := range rules {
|
||
if r.Dimension == "effect_limit" {
|
||
var v struct {
|
||
Daily int `json:"daily"`
|
||
}
|
||
if json.Unmarshal([]byte(r.RulesJson), &v) == nil && v.Daily > 0 {
|
||
return v.Daily
|
||
}
|
||
}
|
||
}
|
||
return limit
|
||
}
|