🤔 need to update Animal & like way
This commit is contained in:
parent
f263ead51d
commit
c1c6ed5d00
@ -158,9 +158,9 @@ func getPreferCats(userId, num int, attrs string, redis *model_redis.SelectedAni
|
||||
|
||||
func (a *Animals) Detail(context *gin.Context) {
|
||||
// 1. Get Params
|
||||
anmId := context.Param("anm_id")
|
||||
anmId := context.GetFloat64(consts.ValidatorPrefix + "anm_id")
|
||||
|
||||
animal := curd.CreateAnimalsCurdFactory().Detail(anmId)
|
||||
animal := curd.CreateAnimalsCurdFactory().Detail(int64(anmId))
|
||||
if animal != nil {
|
||||
response.Success(context, consts.CurdStatusOkMsg, animal)
|
||||
} else {
|
||||
|
@ -10,8 +10,8 @@ import (
|
||||
)
|
||||
|
||||
type Detail struct {
|
||||
AnmId int64 `form:"anm_id" json:"anm_id"`
|
||||
// TODO 暂时没有用到这个模块,GinSK 的架构对于 Path 的处理方式我还不确定,先用临时方案。
|
||||
AnmId int64 `form:"anm_id" json:"anm_id" binding:"required"`
|
||||
UserId int64 `form:"user_id" json:"user_id" binding:"required"`
|
||||
}
|
||||
|
||||
func (d Detail) CheckParams(context *gin.Context) {
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
type Release struct {
|
||||
Token string `form:"token" json:"token"`
|
||||
Token string `form:"token" json:"token" binding:"required"`
|
||||
}
|
||||
|
||||
func (r Release) CheckParams(context *gin.Context) {
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"catface/app/utils/model_handler"
|
||||
"catface/app/utils/query_handler"
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func CreateAnimalsCurdFactory() *AnimalsCurd {
|
||||
@ -113,15 +112,9 @@ func (a *AnimalsCurd) ShowByName(attrs string, name string) (temp []model.Animal
|
||||
return
|
||||
}
|
||||
|
||||
func (a *AnimalsCurd) Detail(id string) *model.Animal {
|
||||
idInt, err := strconv.Atoi(id)
|
||||
if err != nil {
|
||||
// TODO LOG
|
||||
fmt.Println("Detail id error:", err)
|
||||
return nil
|
||||
}
|
||||
func (a *AnimalsCurd) Detail(id int64) *model.Animal {
|
||||
|
||||
return model.CreateAnimalFactory("mysql").ShowByID(int64(idInt))
|
||||
return model.CreateAnimalFactory("mysql").ShowByID(id)
|
||||
}
|
||||
|
||||
func (a *AnimalsCurd) MatchAll(query string, num int) (tmp []model.Animal) {
|
||||
|
@ -122,7 +122,7 @@ func InitWebRouter() *gin.Engine {
|
||||
animal := backend.Group("animal")
|
||||
{
|
||||
animal.GET("", validatorFactory.Create(consts.ValidatorPrefix+"AnimalList"))
|
||||
animal.GET(":anm_id", validatorFactory.Create(consts.ValidatorPrefix+"AnimalDetail"))
|
||||
animal.GET("detail", validatorFactory.Create(consts.ValidatorPrefix+"AnimalDetail"))
|
||||
animal.POST("", validatorFactory.Create(consts.ValidatorPrefix+"AnimalCreate"))
|
||||
animal.GET("name", validatorFactory.Create(consts.ValidatorPrefix+"AnimalName"))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user