Commit ea41fc6e authored by mlogclub's avatar mlogclub
Browse files

观察期时长单位修改为秒

Showing with 60 additions and 59 deletions
+60 -59
......@@ -2,18 +2,18 @@ package constants
// 系统配置
const (
SysConfigSiteTitle = "siteTitle" // 站点标题
SysConfigSiteDescription = "siteDescription" // 站点描述
SysConfigSiteKeywords = "siteKeywords" // 站点关键字
SysConfigSiteNavs = "siteNavs" // 站点导航
SysConfigSiteNotification = "siteNotification" // 站点公告
SysConfigRecommendTags = "recommendTags" // 推荐标签
SysConfigUrlRedirect = "urlRedirect" // 是否开启链接跳转
SysConfigScoreConfig = "scoreConfig" // 分数配置
SysConfigDefaultNodeId = "defaultNodeId" // 发帖默认节点
SysConfigArticlePending = "articlePending" // 是否开启文章审核
SysConfigTopicCaptcha = "topicCaptcha" // 是否开启发帖验证码
SysConfigUserObserveHour = "userObserveHour" // 新用户观察期
SysConfigSiteTitle = "siteTitle" // 站点标题
SysConfigSiteDescription = "siteDescription" // 站点描述
SysConfigSiteKeywords = "siteKeywords" // 站点关键字
SysConfigSiteNavs = "siteNavs" // 站点导航
SysConfigSiteNotification = "siteNotification" // 站点公告
SysConfigRecommendTags = "recommendTags" // 推荐标签
SysConfigUrlRedirect = "urlRedirect" // 是否开启链接跳转
SysConfigScoreConfig = "scoreConfig" // 分数配置
SysConfigDefaultNodeId = "defaultNodeId" // 发帖默认节点
SysConfigArticlePending = "articlePending" // 是否开启文章审核
SysConfigTopicCaptcha = "topicCaptcha" // 是否开启发帖验证码
SysConfigUserObserveSeconds = "userObserveSeconds" // 新用户观察期
)
// EntityType
......
......@@ -14,16 +14,16 @@ type ScoreConfig struct {
// 配置返回结构体
type ConfigData struct {
SiteTitle string `json:"siteTitle"`
SiteDescription string `json:"siteDescription"`
SiteKeywords []string `json:"siteKeywords"`
SiteNavs []ActionLink `json:"siteNavs"`
SiteNotification string `json:"siteNotification"`
RecommendTags []string `json:"recommendTags"`
UrlRedirect bool `json:"urlRedirect"`
ScoreConfig ScoreConfig `json:"scoreConfig"`
DefaultNodeId int64 `json:"defaultNodeId"`
ArticlePending bool `json:"articlePending"`
TopicCaptcha bool `json:"topicCaptcha"`
UserObserveHour int `json:"userObserveHour"`
SiteTitle string `json:"siteTitle"`
SiteDescription string `json:"siteDescription"`
SiteKeywords []string `json:"siteKeywords"`
SiteNavs []ActionLink `json:"siteNavs"`
SiteNotification string `json:"siteNotification"`
RecommendTags []string `json:"recommendTags"`
UrlRedirect bool `json:"urlRedirect"`
ScoreConfig ScoreConfig `json:"scoreConfig"`
DefaultNodeId int64 `json:"defaultNodeId"`
ArticlePending bool `json:"articlePending"`
TopicCaptcha bool `json:"topicCaptcha"`
UserObserveSeconds int `json:"userObserveSeconds"`
}
......@@ -60,10 +60,11 @@ func (u *User) GetRoles() []string {
return roles
}
// InObservationPeriod 是否在观察期,observeHour观察时长
func (u *User) InObservationPeriod(observeHour int) bool {
if observeHour <= 0 {
// InObservationPeriod 是否在观察期
// observeSeconds 观察时长
func (u *User) InObservationPeriod(observeSeconds int) bool {
if observeSeconds <= 0 {
return false
}
return simple.TimeFromTimestamp(u.CreateTime).Add(time.Hour * time.Duration(observeHour)).After(time.Now())
return simple.TimeFromTimestamp(u.CreateTime).Add(time.Second * time.Duration(observeSeconds)).After(time.Now())
}
......@@ -117,18 +117,18 @@ func (s *sysConfigService) setSingle(db *gorm.DB, key, value, name, description
func (s *sysConfigService) GetConfig() *model.ConfigData {
var (
siteTitle = cache.SysConfigCache.GetValue(constants.SysConfigSiteTitle)
siteDescription = cache.SysConfigCache.GetValue(constants.SysConfigSiteDescription)
siteKeywords = cache.SysConfigCache.GetValue(constants.SysConfigSiteKeywords)
siteNavs = cache.SysConfigCache.GetValue(constants.SysConfigSiteNavs)
siteNotification = cache.SysConfigCache.GetValue(constants.SysConfigSiteNotification)
recommendTags = cache.SysConfigCache.GetValue(constants.SysConfigRecommendTags)
urlRedirect = cache.SysConfigCache.GetValue(constants.SysConfigUrlRedirect)
scoreConfigStr = cache.SysConfigCache.GetValue(constants.SysConfigScoreConfig)
defaultNodeIdStr = cache.SysConfigCache.GetValue(constants.SysConfigDefaultNodeId)
articlePending = cache.SysConfigCache.GetValue(constants.SysConfigArticlePending)
topicCaptcha = cache.SysConfigCache.GetValue(constants.SysConfigTopicCaptcha)
userObserveHourStr = cache.SysConfigCache.GetValue(constants.SysConfigUserObserveHour)
siteTitle = cache.SysConfigCache.GetValue(constants.SysConfigSiteTitle)
siteDescription = cache.SysConfigCache.GetValue(constants.SysConfigSiteDescription)
siteKeywords = cache.SysConfigCache.GetValue(constants.SysConfigSiteKeywords)
siteNavs = cache.SysConfigCache.GetValue(constants.SysConfigSiteNavs)
siteNotification = cache.SysConfigCache.GetValue(constants.SysConfigSiteNotification)
recommendTags = cache.SysConfigCache.GetValue(constants.SysConfigRecommendTags)
urlRedirect = cache.SysConfigCache.GetValue(constants.SysConfigUrlRedirect)
scoreConfigStr = cache.SysConfigCache.GetValue(constants.SysConfigScoreConfig)
defaultNodeIdStr = cache.SysConfigCache.GetValue(constants.SysConfigDefaultNodeId)
articlePending = cache.SysConfigCache.GetValue(constants.SysConfigArticlePending)
topicCaptcha = cache.SysConfigCache.GetValue(constants.SysConfigTopicCaptcha)
userObserveSecondsStr = cache.SysConfigCache.GetValue(constants.SysConfigUserObserveSeconds)
)
var siteKeywordsArr []string
......@@ -160,23 +160,23 @@ func (s *sysConfigService) GetConfig() *model.ConfigData {
}
var (
defaultNodeId, _ = strconv.ParseInt(defaultNodeIdStr, 10, 64)
userObserveHour, _ = strconv.Atoi(userObserveHourStr)
defaultNodeId, _ = strconv.ParseInt(defaultNodeIdStr, 10, 64)
userObserveSeconds, _ = strconv.Atoi(userObserveSecondsStr)
)
return &model.ConfigData{
SiteTitle: siteTitle,
SiteDescription: siteDescription,
SiteKeywords: siteKeywordsArr,
SiteNavs: siteNavsArr,
SiteNotification: siteNotification,
RecommendTags: recommendTagsArr,
UrlRedirect: strings.ToLower(urlRedirect) == "true",
ScoreConfig: scoreConfig,
DefaultNodeId: defaultNodeId,
ArticlePending: strings.ToLower(articlePending) == "true",
TopicCaptcha: strings.ToLower(topicCaptcha) == "true",
UserObserveHour: userObserveHour,
SiteTitle: siteTitle,
SiteDescription: siteDescription,
SiteKeywords: siteKeywordsArr,
SiteNavs: siteNavsArr,
SiteNotification: siteNotification,
RecommendTags: recommendTagsArr,
UrlRedirect: strings.ToLower(urlRedirect) == "true",
ScoreConfig: scoreConfig,
DefaultNodeId: defaultNodeId,
ArticlePending: strings.ToLower(articlePending) == "true",
TopicCaptcha: strings.ToLower(topicCaptcha) == "true",
UserObserveSeconds: userObserveSeconds,
}
}
......
......@@ -508,9 +508,9 @@ func (s *userService) CheckPostStatus(user *model.User) *simple.CodeError {
if user.IsForbidden() {
return common.ForbiddenError
}
observeHour := SysConfigService.GetInt(constants.SysConfigUserObserveHour)
if user.InObservationPeriod(observeHour) {
return simple.NewError(common.InObservationPeriod.Code, "账号尚在观察期,观察期时长:"+strconv.Itoa(observeHour)+"小时,请稍后再试")
observeSeconds := SysConfigService.GetInt(constants.SysConfigUserObserveSeconds)
if user.InObservationPeriod(observeSeconds) {
return simple.NewError(common.InObservationPeriod.Code, "账号尚在观察期,观察期时长:"+strconv.Itoa(observeSeconds)+",请稍后再试")
}
return nil
}
......@@ -98,10 +98,10 @@
placement="top"
>
<el-input-number
v-model="config.userObserveHour"
v-model="config.userObserveSeconds"
:min="0"
:max="720"
label="用户观察期(小时)"
label="用户观察期()"
></el-input-number>
</el-tooltip>
</el-form-item>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment