修复运行边界条件问题

This commit is contained in:
2026-04-22 17:11:55 +08:00
parent 6e14ea65d0
commit d26106eb00
3 changed files with 11 additions and 2 deletions

View File

@@ -147,7 +147,7 @@ type ResourceView struct {
}
// 检查用户是否可提取
func ensure(now time.Time, source netip.Addr, resourceId int32, count int) (*ResourceView, []string, error) {
func ensure(now time.Time, source netip.Addr, resourceId int32, authWhitelist bool, count int) (*ResourceView, []string, error) {
if count > 400 {
return nil, nil, core.NewBizErr("单次最多提取 400 个")
}
@@ -172,6 +172,10 @@ func ensure(now time.Time, source netip.Addr, resourceId int32, count int) (*Res
return nil, nil, err
}
if authWhitelist && len(whitelists) == 0 {
return nil, nil, core.NewBizErr("当前白名单为空,请先添加白名单")
}
ips := make([]string, len(whitelists))
pass := false
for i, item := range whitelists {