You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
2.0 KiB
56 lines
2.0 KiB
package memory
|
|
|
|
import (
|
|
"time"
|
|
|
|
"yunyan/comm"
|
|
"yunyan/pb"
|
|
)
|
|
|
|
// Today 当天全部事项(每日弹窗直接用)
|
|
//
|
|
// 单独开一个接口而不是复用 memory_list:弹窗要一次拿全(含待确认报告标记),
|
|
// 且便于单独做降级——它在启动路径附近被调用,出问题不能拖住别的东西。
|
|
//
|
|
// @Summary 当天事项
|
|
// @Description 拉取用户某一天的全部拾忆条目,并带出待确认的周报/月报标记
|
|
// @Tags Memory
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security BearerAuth
|
|
// @Param data body pb.MemoryTodayReq true "请求数据"
|
|
// @Success 200 {object} comm.HttpResult{data=pb.MemoryTodayResp} "响应数据"
|
|
// @Router /api/home/memory_today [post]
|
|
func (this *apiComp) Today(session comm.IUserSession, req *pb.MemoryTodayReq) (resp *pb.MemoryTodayResp, errdata *pb.ErrorData) {
|
|
uid, errdata := requireUID(session)
|
|
if errdata != nil {
|
|
return
|
|
}
|
|
|
|
// 日期以客户端本地日期为准,服务端不做时区推断:用户「今天」的定义应该跟着人走。
|
|
// 客户端没报就按它给的时区算,时区也没给才退到容器时区。
|
|
date := req.Date
|
|
if _, ok := comm.ParseMemoryDate(date); !ok {
|
|
loc := comm.LoadMemoryLocation(req.Tz)
|
|
date = comm.FormatMemoryDate(time.Now().In(loc))
|
|
}
|
|
|
|
items, _, err := this.module.model.listItems(&itemQuery{
|
|
uid: uid, startDate: date, endDate: date, size: maxListSize,
|
|
})
|
|
if err != nil {
|
|
this.module.Errorf("memory_today uid:%s err:%v", uid, err)
|
|
errdata = &pb.ErrorData{Code: pb.ErrorCode_DBError, Message: "查询失败"}
|
|
return
|
|
}
|
|
resp = &pb.MemoryTodayResp{Items: items}
|
|
|
|
// 待确认报告:查失败不算错误,弹窗还是要能出来(少一个角标 << 整个弹窗不出)
|
|
if rep, e := this.module.model.latestUnconfirmedReport(uid); e != nil {
|
|
this.module.Warnf("memory_today uid:%s 查待确认报告失败已忽略: %v", uid, e)
|
|
} else if rep != nil {
|
|
resp.PendingReportId = rep.Id
|
|
resp.PendingReportType = rep.PeriodType
|
|
}
|
|
return
|
|
}
|
|
|