refactor: 重构签到系统和战斗特效逻辑

This commit is contained in:
xinian
2026-04-06 02:51:13 +08:00
committed by cnb
parent 5b37d9493b
commit a16a06e389
9 changed files with 358 additions and 530 deletions

View File

@@ -8,14 +8,13 @@ import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/grand"
"github.com/google/uuid"
) // 1. 扩展字符集:数字+大小写字母+安全符号避开URL/输入易冲突的符号,如/、?、&
)
const charsetWithSymbol = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz"
func Generate16CharSecure() string {
result := make([]byte, 16)
for i := 0; i < 16; i++ {
result[i] = charsetWithSymbol[grand.N(0, len(charsetWithSymbol)-1)]
}
return string(result)
@@ -38,22 +37,30 @@ func NewCdkService() *CdkService {
},
}
}
func (s *CdkService) Get(id string) *model.CDKConfig {
var item *model.CDKConfig
dbm_notenable(s.Model).Where("cdk_code", id).WhereNot("exchange_remain_count", 0).Scan(&item)
return item
}
func (s *CdkService) GetByID(id uint32) *model.CDKConfig {
if id == 0 {
return nil
}
var item *model.CDKConfig
dbm_notenable(s.Model).Where("id", id).Scan(&item)
return item
}
func (s *CdkService) All() []model.CDKConfig {
var item []model.CDKConfig
dbm_notenable(s.Model).WhereLT("exchange_remain_count", 0).Scan(&item)
return item
}
func (s *CdkService) Set(id string) bool {
func (s *CdkService) Set(id string) bool {
res, err := cool.DBM(s.Model).Where("cdk_code", id).WhereNot("exchange_remain_count", 0).Decrement("exchange_remain_count", 1)
if err != nil {
return false
@@ -62,7 +69,5 @@ func (s *CdkService) Set(id string) bool {
if rows == 0 {
return false
}
return true
}