animal with like #2
This commit is contained in:
parent
babd68def0
commit
c863331243
@ -17,7 +17,7 @@ type List struct {
|
||||
Status string `form:"status" json:"status"`
|
||||
Num int `form:"num" json:"num"`
|
||||
Skip int `form:"skip" json:"skip"`
|
||||
UserId int `form:"user_id" json:"user_id" binding:"required,min=1"`
|
||||
UserId int `form:"user_id" json:"user_id"`
|
||||
}
|
||||
|
||||
func (l List) CheckParams(context *gin.Context) {
|
||||
|
@ -2,5 +2,5 @@ package model
|
||||
|
||||
type AnimalWithLikeList struct {
|
||||
Animal Animal `json:"animal"`
|
||||
Like bool `json:"like"`
|
||||
Like bool `json:"like,omitempty"`
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ func (a *AnimalsCurd) List(attrs string, gender string, breed string, sterilzati
|
||||
|
||||
animals := model.CreateAnimalFactory("").Show(validSelectedFields, genderArray, breedArray, sterilzationArray, statusArray, num, skip)
|
||||
|
||||
if userId > 0 {
|
||||
for i := range animals {
|
||||
animalWithLike := model.AnimalWithLikeList{
|
||||
Animal: animals[i],
|
||||
@ -68,6 +69,15 @@ func (a *AnimalsCurd) List(attrs string, gender string, breed string, sterilzati
|
||||
}
|
||||
temp = append(temp, animalWithLike)
|
||||
}
|
||||
} else {
|
||||
for i := range animals {
|
||||
animalWithLike := model.AnimalWithLikeList{
|
||||
Animal: animals[i],
|
||||
}
|
||||
temp = append(temp, animalWithLike)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user