prepare for animal mode
This commit is contained in:
parent
1247e39a2e
commit
33ef39c849
@ -72,4 +72,7 @@ const (
|
|||||||
CaptchaCheckOkMsg string = "验证码校验通过"
|
CaptchaCheckOkMsg string = "验证码校验通过"
|
||||||
CaptchaCheckFailCode int = -400355
|
CaptchaCheckFailCode int = -400355
|
||||||
CaptchaCheckFailMsg string = "验证码校验失败"
|
CaptchaCheckFailMsg string = "验证码校验失败"
|
||||||
|
|
||||||
|
// TAG animal/ 接口模式
|
||||||
|
AnimalPreferMode string = "prefer"
|
||||||
)
|
)
|
||||||
|
@ -31,12 +31,22 @@ func (a *Animals) List(context *gin.Context) {
|
|||||||
skip := context.GetFloat64(consts.ValidatorPrefix + "skip")
|
skip := context.GetFloat64(consts.ValidatorPrefix + "skip")
|
||||||
userId := context.GetFloat64(consts.ValidatorPrefix + "user_id")
|
userId := context.GetFloat64(consts.ValidatorPrefix + "user_id")
|
||||||
|
|
||||||
|
mode := context.GetString(consts.ValidatorPrefix + "mode")
|
||||||
|
|
||||||
|
if mode == consts.AnimalPreferMode {
|
||||||
|
preferList(context)
|
||||||
|
} else { // 其余都是 默认模式。
|
||||||
animals := curd.CreateAnimalsCurdFactory().List(attrs, gender, breed, sterilization, status, department, int(num), int(skip), int(userId))
|
animals := curd.CreateAnimalsCurdFactory().List(attrs, gender, breed, sterilization, status, department, int(num), int(skip), int(userId))
|
||||||
if animals != nil {
|
if animals != nil {
|
||||||
response.Success(context, consts.CurdStatusOkMsg, animals)
|
response.Success(context, consts.CurdStatusOkMsg, animals)
|
||||||
} else {
|
} else {
|
||||||
response.Fail(context, errcode.AnimalNoFind, errcode.ErrMsg[errcode.AnimalNoFind], "")
|
response.Fail(context, errcode.AnimalNoFind, errcode.ErrMsg[errcode.AnimalNoFind], "")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func preferList(context *gin.Context) {
|
||||||
|
// TODO 先去考虑一下前端筛选的实现方式。
|
||||||
}
|
}
|
||||||
|
|
||||||
// v0.1
|
// v0.1
|
||||||
|
@ -19,10 +19,12 @@ type List struct {
|
|||||||
Num int `form:"num" json:"num"`
|
Num int `form:"num" json:"num"`
|
||||||
Skip int `form:"skip" json:"skip"`
|
Skip int `form:"skip" json:"skip"`
|
||||||
UserId int `form:"user_id" json:"user_id"`
|
UserId int `form:"user_id" json:"user_id"`
|
||||||
|
|
||||||
|
Mode string `form:"mode" json:"mode"` // INFO 控制 animal_ctl 的查询模式。 // default: 简单调用 List 函数 || prefer: 优先返回和用户关联度更高的目标。
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l List) CheckParams(context *gin.Context) {
|
func (l List) CheckParams(context *gin.Context) {
|
||||||
if err := context.ShouldBind(&l); err != nil { // INFO 这一条是必要的,看来对数据的解析页在其中。
|
if err := context.ShouldBind(&l); err != nil {
|
||||||
// 将表单参数验证器出现的错误直接交给错误翻译器统一处理即可
|
// 将表单参数验证器出现的错误直接交给错误翻译器统一处理即可
|
||||||
response.ValidatorError(context, err)
|
response.ValidatorError(context, err)
|
||||||
return
|
return
|
||||||
|
@ -3,12 +3,10 @@ package routers
|
|||||||
import (
|
import (
|
||||||
"catface/app/global/consts"
|
"catface/app/global/consts"
|
||||||
"catface/app/global/variable"
|
"catface/app/global/variable"
|
||||||
|
|
||||||
// "catface/app/http/controller/captcha" // 验证码组件
|
// "catface/app/http/controller/captcha" // 验证码组件
|
||||||
// "catface/app/http/middleware/authorization"
|
// "catface/app/http/middleware/authorization"
|
||||||
"catface/app/http/middleware/cors"
|
"catface/app/http/middleware/cors"
|
||||||
validatorFactory "catface/app/http/validator/core/factory"
|
validatorFactory "catface/app/http/validator/core/factory"
|
||||||
|
|
||||||
// TODO validatorFactory "catface/app/http/validator/core/factory"
|
// TODO validatorFactory "catface/app/http/validator/core/factory"
|
||||||
"catface/app/utils/gin_release"
|
"catface/app/utils/gin_release"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user