docs(website): 添加简记memo产品原型和UI设计规范文档
- 新增「简记memo」一体化小程序产品原型设计文档 - 新增简记memo完整版UI视觉设计规范和界面细节 - 添加IDEA项目配置文件.gitignore - 创建404页面HTML文件,包含响应式布局和错误提示 - 添加关于页面HTML文件,展示品牌介绍和团队信息 - 实现AES加解密工具函数,支持请求体加密 - 添加用户协议页面基础框架
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"simple-memo/global"
|
||||
"simple-memo/models"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func InitCron() {
|
||||
go func() {
|
||||
for {
|
||||
now := time.Now()
|
||||
next := getNextRunTime(10, 0)
|
||||
duration := next.Sub(now)
|
||||
|
||||
time.Sleep(duration)
|
||||
|
||||
checkPerfectDay()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func getNextRunTime(hour, minute int) time.Time {
|
||||
now := time.Now()
|
||||
today := time.Date(now.Year(), now.Month(), now.Day(), hour, minute, 0, 0, now.Location())
|
||||
|
||||
if now.Before(today) {
|
||||
return today
|
||||
}
|
||||
return today.AddDate(0, 0, 1)
|
||||
}
|
||||
|
||||
func checkPerfectDay() {
|
||||
yesterday := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
|
||||
|
||||
var progressList []models.DailyProgress
|
||||
err := global.DB.Where("record_date = ?", yesterday).Find(&progressList).Error
|
||||
if err != nil {
|
||||
global.Logger.Error("查询每日进度失败", zap.Error(err))
|
||||
return
|
||||
}
|
||||
|
||||
for _, progress := range progressList {
|
||||
if progress.TotalTasks > 0 && progress.TaskCount >= progress.TotalTasks && !progress.PerfectDay {
|
||||
err := global.DB.Model(&models.DailyProgress{}).
|
||||
Where("id = ?", progress.ID).
|
||||
Update("perfect_day", true).Error
|
||||
if err != nil {
|
||||
global.Logger.Error("更新PerfectDay失败", zap.Error(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
global.Logger.Info("PerfectDay check completed", zap.String("date", yesterday))
|
||||
}
|
||||
Reference in New Issue
Block a user