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.
36 lines
1.3 KiB
36 lines
1.3 KiB
package allhelp
|
|
|
|
import (
|
|
"yunyan/comm"
|
|
"yunyan/pb"
|
|
)
|
|
|
|
// GetChatSummary 按日期查询总结(客户端轮询)
|
|
// @Summary 查询每日聊天总结
|
|
// @Description 按日期查询当前用户的每日聊天总结记录,未提交则返回 record.id=0
|
|
// @Tags Allhelp
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security BearerAuth
|
|
// @Param user body pb.AllhelpGetChatSummaryReq true "请求数据"
|
|
// @Success 200 {object} comm.HttpResult{data=pb.AllhelpGetChatSummaryResp} "响应数据"
|
|
// @Router /api/home/allhelp_getchatsummary [post]
|
|
func (this *apiComp) GetChatSummary(session comm.IUserSession, req *pb.AllhelpGetChatSummaryReq) (resp *pb.AllhelpGetChatSummaryResp, errdata *pb.ErrorData) {
|
|
uid := session.GetUserId()
|
|
if uid == "" {
|
|
errdata = &pb.ErrorData{Code: pb.ErrorCode_ReqParameterError, Message: "用户未登录"}
|
|
return
|
|
}
|
|
if !isValidDate(req.SummaryDate) {
|
|
errdata = &pb.ErrorData{Code: pb.ErrorCode_ReqParameterError, Message: "summary_date 必须为 YYYY-MM-DD"}
|
|
return
|
|
}
|
|
rec, err := this.module.model.getChatSummary(uid, req.SummaryDate)
|
|
if err != nil {
|
|
// 未找到:返回空记录(id=0),不报错
|
|
resp = &pb.AllhelpGetChatSummaryResp{Record: &pb.DBChatSummary{Uid: uid, SummaryDate: req.SummaryDate}}
|
|
return
|
|
}
|
|
resp = &pb.AllhelpGetChatSummaryResp{Record: rec}
|
|
return
|
|
}
|
|
|