docs(website): 添加简记memo产品原型和UI设计规范文档

- 新增「简记memo」一体化小程序产品原型设计文档
- 新增简记memo完整版UI视觉设计规范和界面细节
- 添加IDEA项目配置文件.gitignore
- 创建404页面HTML文件,包含响应式布局和错误提示
- 添加关于页面HTML文件,展示品牌介绍和团队信息
- 实现AES加解密工具函数,支持请求体加密
- 添加用户协议页面基础框架
This commit is contained in:
sunct
2026-07-31 14:12:32 +08:00
commit 3c3bf53ae4
115 changed files with 21304 additions and 0 deletions
+122
View File
@@ -0,0 +1,122 @@
// api/app/calendar.go
// 日历数据聚合接口
package app
import (
"fmt"
"simple-memo/global"
"simple-memo/models"
"simple-memo/utils"
"time"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
type CalendarHandler struct {
db *gorm.DB
}
func NewCalendarHandler() *CalendarHandler {
return &CalendarHandler{db: global.DB}
}
// CalendarDayData 单日数据
type CalendarDayData struct {
Todo bool `json:"todo"` // 有待办
TodoDone bool `json:"todo_done"` // 待办全部完成
TodoUndone bool `json:"todo_undone"` // 有待办未完成
Mood bool `json:"mood"` // 有心情
Bill bool `json:"bill"` // 有账单
}
// GetCalendarData 获取日历数据(按日期聚合)
func (h *CalendarHandler) GetCalendarData(c *gin.Context) {
year := time.Now().Year()
month := int(time.Now().Month())
// 尝试从请求体获取年月
var req struct {
Year int `json:"year"`
Month int `json:"month"`
}
c.ShouldBindJSON(&req)
if req.Year > 0 {
year = req.Year
}
if req.Month > 0 && req.Month <= 12 {
month = req.Month
}
userID := c.GetUint("userID")
// 计算月份范围
startDate := fmt.Sprintf("%d-%02d-01", year, month)
_, lastDay := utils.GetMonthLastDay(year, month)
endDate := fmt.Sprintf("%d-%02d-%02d", year, month, lastDay)
// 初始化结果
calendarData := make(map[string]*CalendarDayData)
// 1. 查询待办数据(按日期分组,检查是否有未完成)
var todos []models.Todo
h.db.Where("user_id = ? AND date BETWEEN ? AND ?", userID, startDate, endDate).
Find(&todos)
// 按日期聚合待办状态
todoByDate := make(map[string]struct {
HasTodo bool
AllDone bool
HasUndone bool
})
for _, todo := range todos {
date := todo.Date
status := todoByDate[date]
status.HasTodo = true
if todo.Done == 1 {
if !status.HasUndone {
status.AllDone = true
}
} else {
status.HasUndone = true
status.AllDone = false
}
todoByDate[date] = status
}
for date, status := range todoByDate {
if calendarData[date] == nil {
calendarData[date] = &CalendarDayData{}
}
calendarData[date].Todo = status.HasTodo
calendarData[date].TodoDone = status.AllDone
calendarData[date].TodoUndone = status.HasUndone
}
// 2. 查询心情数据
var moodDates []string
h.db.Model(&models.Mood{}).
Where("user_id = ? AND date BETWEEN ? AND ?", userID, startDate, endDate).
Pluck("DISTINCT date", &moodDates).Find(&moodDates)
for _, date := range moodDates {
if calendarData[date] == nil {
calendarData[date] = &CalendarDayData{}
}
calendarData[date].Mood = true
}
// 3. 查询账单数据
var billDates []string
h.db.Model(&models.Bill{}).
Where("user_id = ? AND date BETWEEN ? AND ?", userID, startDate, endDate).
Pluck("DISTINCT date", &moodDates).Find(&billDates)
for _, date := range billDates {
if calendarData[date] == nil {
calendarData[date] = &CalendarDayData{}
}
calendarData[date].Bill = true
}
utils.Ok(c, calendarData)
}