Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dean/dev #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions internal/controller/lost.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
19 changes: 19 additions & 0 deletions pkg/schema/vo_lost.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}

Expand Down