feat: P1 合盘/星座/问答与测测完整设计包及模拟器取证工具

落地 synastry/star/ask API 与 H5 页面,补齐 cece-frontend-re complete-design 证据文档,并加入 Android 模拟器截图抓取脚本。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-03 11:37:53 +08:00
co-authored by Cursor
parent 15a9db374a
commit bd22d9dddd
248 changed files with 26309 additions and 842 deletions
+72 -1
View File
@@ -5,6 +5,7 @@ import (
"time"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"github.com/yuxingu/digital-psychology/apps/api/internal/middleware"
"github.com/yuxingu/digital-psychology/apps/api/internal/service/profile"
@@ -20,6 +21,8 @@ type ProfileHandler struct {
func (h *ProfileHandler) Register(rg *gin.RouterGroup) {
rg.GET("/profiles", h.List)
rg.POST("/profiles", h.Create)
rg.PATCH("/profiles/:id", h.Update)
rg.DELETE("/profiles/:id", h.Delete)
}
type createProfileReq struct {
@@ -27,6 +30,8 @@ type createProfileReq struct {
DisplayName string `json:"display_name"`
BirthDate string `json:"birth_date" binding:"required"`
RelationType *string `json:"relation_type"`
BirthTime *string `json:"birth_time"`
BirthPlace *string `json:"birth_place"`
}
// Create handles POST /profiles.
@@ -47,7 +52,8 @@ func (h *ProfileHandler) Create(c *gin.Context) {
return
}
p, err := h.Svc.Create(c.Request.Context(), userID, profile.CreateInput{
Relation: req.Relation, DisplayName: req.DisplayName, BirthDate: birth, RelationType: req.RelationType,
Relation: req.Relation, DisplayName: req.DisplayName, BirthDate: birth,
RelationType: req.RelationType, BirthTime: req.BirthTime, BirthPlace: req.BirthPlace,
})
if err != nil {
response.Fail(c, http.StatusBadRequest, 30001, err.Error())
@@ -70,3 +76,68 @@ func (h *ProfileHandler) List(c *gin.Context) {
}
response.OK(c, gin.H{"items": list})
}
// Update handles PATCH /profiles/:id.
func (h *ProfileHandler) Update(c *gin.Context) {
userID, ok := middleware.UserIDFromContext(c)
if !ok {
response.Fail(c, http.StatusUnauthorized, 40100, "unauthorized")
return
}
pid, err := uuid.Parse(c.Param("id"))
if err != nil {
response.Fail(c, http.StatusBadRequest, 10000, "invalid id")
return
}
var req struct {
DisplayName string `json:"display_name"`
BirthDate string `json:"birth_date"`
RelationType *string `json:"relation_type"`
BirthTime *string `json:"birth_time"`
BirthPlace *string `json:"birth_place"`
GeoLat *float64 `json:"geo_lat"`
GeoLng *float64 `json:"geo_lng"`
GeoVisible *bool `json:"geo_visible"`
}
if err := c.ShouldBindJSON(&req); err != nil {
response.Fail(c, http.StatusBadRequest, 10000, "invalid request")
return
}
var birth time.Time
if req.BirthDate != "" {
birth, err = time.Parse("2006-01-02", req.BirthDate)
if err != nil {
response.Fail(c, http.StatusBadRequest, 10000, "birth_date must be YYYY-MM-DD")
return
}
}
p, err := h.Svc.Update(c.Request.Context(), userID, pid, profile.UpdateInput{
DisplayName: req.DisplayName, BirthDate: birth, RelationType: req.RelationType,
BirthTime: req.BirthTime, BirthPlace: req.BirthPlace,
GeoLat: req.GeoLat, GeoLng: req.GeoLng, GeoVisible: req.GeoVisible,
})
if err != nil {
response.Fail(c, http.StatusNotFound, 40401, err.Error())
return
}
response.OK(c, p)
}
// Delete handles DELETE /profiles/:id.
func (h *ProfileHandler) Delete(c *gin.Context) {
userID, ok := middleware.UserIDFromContext(c)
if !ok {
response.Fail(c, http.StatusUnauthorized, 40100, "unauthorized")
return
}
pid, err := uuid.Parse(c.Param("id"))
if err != nil {
response.Fail(c, http.StatusBadRequest, 10000, "invalid id")
return
}
if err := h.Svc.Delete(c.Request.Context(), userID, pid); err != nil {
response.Fail(c, http.StatusNotFound, 40401, err.Error())
return
}
response.OK(c, gin.H{"deleted": true})
}