v1.1
This commit is contained in:
42
app/main/api/internal/logic/app/getappconfiglogic.go
Normal file
42
app/main/api/internal/logic/app/getappconfiglogic.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/app/main/model"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetAppConfigLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetAppConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAppConfigLogic {
|
||||
return &GetAppConfigLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetAppConfigLogic) GetAppConfig() (resp *types.GetAppConfigResp, err error) {
|
||||
retentionDays := int64(0)
|
||||
cfg, cfgErr := l.svcCtx.QueryCleanupConfigModel.FindOneByConfigKey(l.ctx, "retention_days")
|
||||
if cfgErr == nil && cfg.Status == 1 {
|
||||
if v, parseErr := strconv.ParseInt(cfg.ConfigValue, 10, 64); parseErr == nil && v >= 0 {
|
||||
retentionDays = v
|
||||
}
|
||||
} else if cfgErr != nil && cfgErr != model.ErrNotFound {
|
||||
l.Errorf("获取清理配置失败: %v", cfgErr)
|
||||
}
|
||||
|
||||
return &types.GetAppConfigResp{
|
||||
QueryRetentionDays: retentionDays,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user