feat: 实现每日签到功能并优化战斗和道具逻辑

This commit is contained in:
xinian
2026-04-06 02:06:11 +08:00
committed by cnb
parent f433a26a6d
commit 5b37d9493b
17 changed files with 1066 additions and 86 deletions

View File

@@ -0,0 +1,20 @@
package admin
import (
"blazing/cool"
"blazing/modules/config/service"
)
type SignController struct {
*cool.Controller
}
func init() {
cool.RegisterController(&SignController{
&cool.Controller{
Prefix: "/admin/config/sign",
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"},
Service: service.NewSignInService(),
},
})
}

View File

@@ -0,0 +1,31 @@
package model
import (
"blazing/cool"
)
const TableNameSignIn = "config_sign_in"
// SignIn 签到活动配置表。
type SignIn struct {
*cool.Model
SignInID uint32 `gorm:"not null;index:idx_sign_in_id;comment:'签到活动ID'" json:"sign_in_id"`
Status uint32 `gorm:"not null;default:0;comment:'签到状态0-未启用 1-启用)'" json:"status"`
RewardScript string `gorm:"type:varchar(2048);default:'';comment:'签到奖励配置(JSON)'" json:"reward_script"`
}
func (*SignIn) TableName() string {
return TableNameSignIn
}
func (*SignIn) GroupName() string {
return "default"
}
func NewSignIn() *SignIn {
return &SignIn{Model: cool.NewModel()}
}
func init() {
cool.CreateTable(&SignIn{})
}

View File

@@ -0,0 +1,37 @@
package service
import (
"blazing/cool"
"blazing/modules/config/model"
)
type SignInService struct {
*cool.Service
}
func (s *SignInService) GetActive(signInID uint32) *model.SignIn {
m := cool.DBM(s.Model)
if signInID != 0 {
m.Where("sign_in_id", signInID)
}
m.Where("status", 1)
m.Order("sign_in_id", "asc")
var out *model.SignIn
m.Scan(&out)
return out
}
func NewSignInService() *SignInService {
return &SignInService{
&cool.Service{
Model: model.NewSignIn(),
ListQueryOp: &cool.QueryOp{
FieldEQ: []string{"sign_in_id", "status"},
},
PageQueryOp: &cool.QueryOp{
FieldEQ: []string{"sign_in_id", "status"},
},
},
}
}