sync: 对齐小程序 v1.0.2 生产代码并脱敏
This commit is contained in:
@@ -87,15 +87,37 @@ func (s *sAppWarning) ConfigMeta(ctx context.Context) (res *model.AppWarningConf
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var summary appWarningNotifySummary
|
||||
if err = appWarningNotifySummaryModel(s.configModel(ctx), user).Scan(&summary); err != nil {
|
||||
return nil, gerror.Wrap(err, "查询当前账号预警提醒配置失败")
|
||||
}
|
||||
return &model.AppWarningConfigMetaModel{
|
||||
TemplateId: appWarningWechatTemplateId(ctx),
|
||||
TemplateReady: appWarningTemplateReady(ctx),
|
||||
WechatBound: wechatBound,
|
||||
WechatBindText: wechatBindText,
|
||||
AppNotifyEnabled: appWarningNotifyEnabledValue(nil),
|
||||
TemplateId: appWarningWechatTemplateId(ctx),
|
||||
TemplateReady: appWarningTemplateReady(ctx),
|
||||
WechatBound: wechatBound,
|
||||
WechatBindText: wechatBindText,
|
||||
AppNotifyEnabled: appWarningNotifyEnabledValue(nil),
|
||||
ActiveConfigCount: summary.ActiveConfigCount,
|
||||
NotifyConfigCount: summary.NotifyConfigCount,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type appWarningNotifySummary struct {
|
||||
ActiveConfigCount int `orm:"active_config_count"`
|
||||
NotifyConfigCount int `orm:"notify_config_count"`
|
||||
}
|
||||
|
||||
func appWarningNotifySummaryModel(mod *gdb.Model, user *entity.SysUser) *gdb.Model {
|
||||
columns := dao.TWarnConfig.Columns()
|
||||
return mod.
|
||||
Where(columns.TenantId, user.TenantId).
|
||||
Where(columns.CreatedBy, user.UserId).
|
||||
Where(columns.ItemType, appWarningItemTypeCard).
|
||||
Where(columns.WarnUnit, appWarningUnitMb).
|
||||
Where(columns.IsEnabled, 1).
|
||||
Fields("COUNT(*) AS active_config_count, COALESCE(SUM(CASE WHEN " + columns.AppNotifyEnabled + " = 1 THEN 1 ELSE 0 END), 0) AS notify_config_count")
|
||||
}
|
||||
|
||||
func (s *sAppWarning) ConfigSave(ctx context.Context, param *model.AppWarningConfigSaveParam) (res *model.AppWarningConfigSaveModel, err error) {
|
||||
if err = normalizeAppWarningSaveParam(param); err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user