diff --git a/internal/controller/lost.go b/internal/controller/lost.go index 6968597..ba0b090 100644 --- a/internal/controller/lost.go +++ b/internal/controller/lost.go @@ -31,6 +31,7 @@ func (c LostController) Routes() chi.Router { r := chi.NewRouter() r.Get("/", c.List) + r.Post("/create", c.Create) r.Get("/{lost_id}", c.Show) r.Get("/{lost_id}/share/{share_key}/callback", c.ShareCallback) r.Get("/{lost_id}/"+aggregate.LOST_WXMP_CODE_FILENAME, c.GetMpCode) @@ -120,6 +121,34 @@ func (c LostController) Show(w http.ResponseWriter, r *http.Request) { render.JSON(w, r, resp) } +// LostCreate +// @Summary 新建失踪信息 +// @Description 失踪信息 详情。 +// @Tags lost +// @Accept json +// @Produce json +// @Param schema.LostCreateReq body schema.LostCreateReq true "body" +// @Success 200 {object} schema.LostGetResponse +// @Router /v1/lost/create [post] +func (c LostController) Create(w http.ResponseWriter, r *http.Request) { + resp := schema.LostGetResponse{ + Success: false, + } + + // Todo: 保存失踪信息。 + item, err := c.aggr.Losts().GetByID(r.Context(), uint(5)) + if err != nil { + log.Println(err) + + return + } + + resp.Success = true + resp.Data = item + + render.JSON(w, r, resp) +} + // [TODO] LostShareCallback // @Summary 失踪信息 分享后回传 // @Description 分享后回传,通过缓存+IP+Key来去重。share_key为详情页中 wx_more 里的 share_key. diff --git a/pkg/schema/vo_lost.go b/pkg/schema/vo_lost.go index 258ed4c..193be7f 100644 --- a/pkg/schema/vo_lost.go +++ b/pkg/schema/vo_lost.go @@ -27,6 +27,25 @@ type LostGetResponse struct { Success bool `json:"success"` } +type LostCreateReq struct { + Name string `json:"name"` + Sex uint `json:"sex"` + Age int `json:"age"` + AddressDetails string `json:"address_details"` + MissedProvince string `json:"missed_province"` + MissedCity string `json:"missed_city"` + BirthedAt uint `json:"birthed_at"` + MissedAt uint `json:"missed_at"` + Character uint `json:"character"` + Height uint `json:"height"` + DataFrom string `json:"data_from"` + Follower string `json:"follower"` + Imgs []string `json:"imgs"` +} + +type LostCreateResp struct { +} + type LostMpCode struct { }