feat: 徽章api

This commit is contained in:
Blizzard
2026-02-12 14:34:31 +08:00
parent 01e13e736c
commit 0405968597
22 changed files with 1150 additions and 62 deletions
+25 -8
View File
@@ -1,18 +1,35 @@
package plant
import (
"sundynix-go/config"
"sundynix-go/global"
"sundynix-go/model/system"
)
// BadgeConfig 徽章配置
type BadgeConfig struct {
global.BaseModel
GroupId string `json:"group_id"` // 徽章组 (用于系列徽章,如浇水铜/银/金)
Name string `json:"name"` // 徽章名称
Description string `json:"description"` // 描述
Tier config.BadgeTier `json:"tier"` // 稀有度
TargetAction config.ActionType `json:"target_action"` // 关联的行为
TargetCount int `json:"target_count"` // 需要完成该行为的次数
IconURL string `json:"icon_url"` // 徽章图标地址
Name string `gorm:"type:varchar(64);not null;comment:徽章名称" json:"name"`
Description string `gorm:"type:varchar(255);comment:徽章描述" json:"description"`
IconId string `gorm:"type:varchar(50);comment:图标资源id" json:"iconId"`
// --- 核心维度与分组 ---
// 维度: EXPERTISE(专家), PERSISTENCE(勤勉), JOURNAL(记录)
Dimension string `gorm:"type:varchar(32);index;not null;column:dimension;comment:维度分类" json:"dimension"`
// 组ID: 用于前端聚合显示 (e.g. "fertilizerMaster")
GroupId string `gorm:"type:varchar(64);index;not null;column:group_id;comment:系列组Id" json:"groupId"`
// 等级: 1=铜, 2=银, 3=金
Tier int `gorm:"type:tinyint;default:1;column:tier;comment:等级权重" json:"tier"`
// --- 触发条件逻辑 ---
// 触发动作: ACT_FERTILIZE, ACT_WATER...
TargetAction string `gorm:"type:varchar(32);index;not null;column:target_action;comment:触发动作代码" json:"targetAction"`
// 目标阈值
Threshold int64 `gorm:"not null;column:threshold;comment:所需次数或数值" json:"threshold"`
// 比较操作符: ">=", "="
Comparator string `gorm:"type:varchar(10);default:'>=';column:comparator;comment:比较条件" json:"comparator"`
// --- 奖励 ---
RewardSunlight int64 `gorm:"not null;column:reward_sunlight;comment:奖励阳光值" json:"rewardSunlight"`
// --- 显示控制 ---
Sort int `gorm:"default:1;column:sort;comment:排序优先级" json:"sort"`
IsHidden bool `gorm:"-" json:"isHidden"`
//图标
Icon *system.Oss `json:"icon" gorm:"foreignKey:IconId"`
}