609f7d06cf
- pets-fe: 微信原生小程序(首页/计划/记录/报告/社区/引导), 服务端驱动、无假数据;弹层改用 scroll-view,打开时隐藏自定义 tabBar - pets-be: Gin + GORM(MySQL, sundynix_ 前缀) + MinIO,统一响应/分页, 微信 code2session 登录,provider-neutral AI(DeepSeek),go:embed React 后台 - 修复:分段选择类型不匹配(字符串 vs 数字)导致选不中 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package handler
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/sundynix/pets-be/internal/middleware"
|
|
"github.com/sundynix/pets-be/pkg/response"
|
|
)
|
|
|
|
// WeeklyReport GET /api/pets/:id/report/weekly
|
|
func (h *Handler) WeeklyReport(c *gin.Context) {
|
|
rep, err := h.svc.GetWeeklyReport(middleware.UserID(c), uintParam(c, "id"))
|
|
if err != nil {
|
|
respondErr(c, err)
|
|
return
|
|
}
|
|
response.OK(c, rep)
|
|
}
|
|
|
|
// Bill GET /api/pets/:id/bill?period=month
|
|
func (h *Handler) Bill(c *gin.Context) {
|
|
period := c.DefaultQuery("period", "month")
|
|
bill, err := h.svc.GetBill(middleware.UserID(c), uintParam(c, "id"), period)
|
|
if err != nil {
|
|
respondErr(c, err)
|
|
return
|
|
}
|
|
response.OK(c, bill)
|
|
}
|
|
|
|
// HealthSummary GET /api/pets/:id/health-summary
|
|
func (h *Handler) HealthSummary(c *gin.Context) {
|
|
sum, err := h.svc.GetHealthSummary(middleware.UserID(c), uintParam(c, "id"))
|
|
if err != nil {
|
|
respondErr(c, err)
|
|
return
|
|
}
|
|
response.OK(c, sum)
|
|
}
|
|
|
|
// Poster GET /api/pets/:id/poster
|
|
func (h *Handler) Poster(c *gin.Context) {
|
|
poster, err := h.svc.GetPoster(middleware.UserID(c), uintParam(c, "id"))
|
|
if err != nil {
|
|
respondErr(c, err)
|
|
return
|
|
}
|
|
response.OK(c, poster)
|
|
}
|