Some checks failed
Build docker and publish / linux (1.24.5) (push) Failing after 39s
refactor(service): 修改banner和guild删除逻辑为软删除 fix(service): 修复删除操作使用软删除而非物理删除 build: 添加SQLite测试仓库实现 docs: 新增奖励管理字段拆分和批量抽奖UI改造文档 ci: 更新CI忽略文件 style: 清理无用资源文件
60 lines
2.5 KiB
Go
60 lines
2.5 KiB
Go
package activity
|
|
|
|
import (
|
|
"context"
|
|
"bindbox-game/internal/repository/mysql/dao"
|
|
)
|
|
|
|
// DeleteIssue 删除活动期
|
|
// 参数: issueID 期ID
|
|
// 返回: 错误信息
|
|
func (s *service) DeleteIssue(ctx context.Context, issueID int64) error {
|
|
return s.writeDB.Transaction(func(tx *dao.Query) error {
|
|
logs, err := tx.ActivityDrawLogs.WithContext(ctx).Where(tx.ActivityDrawLogs.IssueID.Eq(issueID)).Find()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
var drawLogIDs []int64
|
|
for _, lg := range logs {
|
|
drawLogIDs = append(drawLogIDs, lg.ID)
|
|
}
|
|
|
|
if _, err = tx.ActivityRewardSettings.WithContext(ctx).Where(tx.ActivityRewardSettings.IssueID.Eq(issueID)).Delete(); err != nil {
|
|
return err
|
|
}
|
|
if _, err = tx.IssueRandomCommitments.WithContext(ctx).Where(tx.IssueRandomCommitments.IssueID.Eq(issueID)).Delete(); err != nil {
|
|
return err
|
|
}
|
|
if _, err = tx.ActivityDrawEffects.WithContext(ctx).Where(tx.ActivityDrawEffects.IssueID.Eq(issueID)).Delete(); err != nil {
|
|
return err
|
|
}
|
|
if len(drawLogIDs) > 0 {
|
|
if _, err = tx.ActivityDrawEffects.WithContext(ctx).Where(tx.ActivityDrawEffects.DrawLogID.In(drawLogIDs...)).Delete(); err != nil {
|
|
return err
|
|
}
|
|
if _, err = tx.ActivityDrawReceipts.WithContext(ctx).Where(tx.ActivityDrawReceipts.DrawLogID.In(drawLogIDs...)).Delete(); err != nil {
|
|
return err
|
|
}
|
|
if _, err = tx.UserItemCards.WithContext(ctx).Where(tx.UserItemCards.UsedDrawLogID.In(drawLogIDs...)).Delete(); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
if _, err = tx.UserItemCards.WithContext(ctx).Where(tx.UserItemCards.UsedIssueID.Eq(issueID)).Delete(); err != nil {
|
|
return err
|
|
}
|
|
if _, err = tx.GuildContributeLogs.WithContext(ctx).Where(tx.GuildContributeLogs.IssuesID.Eq(issueID)).Delete(); err != nil {
|
|
return err
|
|
}
|
|
if _, err = tx.SystemItemCards.WithContext(ctx).Where(tx.SystemItemCards.IssueID.Eq(issueID)).Delete(); err != nil {
|
|
return err
|
|
}
|
|
if _, err = tx.ActivityDrawLogs.WithContext(ctx).Where(tx.ActivityDrawLogs.IssueID.Eq(issueID)).Delete(); err != nil {
|
|
return err
|
|
}
|
|
if _, err = tx.ActivityIssues.WithContext(ctx).Where(tx.ActivityIssues.ID.Eq(issueID)).Delete(); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
})
|
|
}
|