小程序一些功能更新
This commit is contained in:
@@ -58,7 +58,7 @@ func AdminQuotaPackList(ctx context.Context) (*v1.QuotaPackListRes, error) {
|
||||
|
||||
func AdminQuotaPackSave(ctx context.Context, req *v1.QuotaPackSaveReq) (*v1.QuotaPackSaveRes, error) {
|
||||
if req.ToolKey != "" {
|
||||
count, err := g.Model(consts.TableTools).Where("tool_key", req.ToolKey).Count()
|
||||
count, err := g.Model(consts.TableTools).Where("tool_key", req.ToolKey).WhereNull("deleted_at").Count()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -200,11 +200,11 @@ func AdminPlanSave(ctx context.Context, req *v1.PlanSaveReq) (*v1.PlanSaveRes, e
|
||||
// ===== 用户额度周期 =====
|
||||
|
||||
func AdminUserQuotaPeriod(ctx context.Context, userId int64, periodDays int) (*v1.UserQuotaPeriodRes, error) {
|
||||
count, err := g.Model(consts.TableUsers).Where("id", userId).Count()
|
||||
before, err := g.Model(consts.TableUsers).Where("id", userId).WhereNull("deleted_at").One()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if count == 0 {
|
||||
if before.IsEmpty() {
|
||||
return nil, gerror.New("用户不存在")
|
||||
}
|
||||
if _, err = g.Model(consts.TableUsers).Where("id", userId).Data(g.Map{
|
||||
@@ -213,5 +213,13 @@ func AdminUserQuotaPeriod(ctx context.Context, userId int64, periodDays int) (*v
|
||||
}).Update(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
WriteAudit(ctx, AuditEntry{
|
||||
Action: "user.set_quota_period",
|
||||
TargetType: "user",
|
||||
TargetId: auditId(userId),
|
||||
Before: g.Map{"quota_period_days": before["quota_period_days"].Int()},
|
||||
After: g.Map{"quota_period_days": periodDays},
|
||||
Result: consts.AuditResultSuccess,
|
||||
})
|
||||
return &v1.UserQuotaPeriodRes{}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user