feat(encounter): 添加路遇模块没有查询到数据的错误处理
- 在 errcode/encounter.go 中新增 ErrEncounterNoData 错误码 - 在 EnocunterMsgInit 和 EncounterMsgUserInit 函数中添加相应的错误消息 - 修改 encounter_controller.go 中的 List 方法,使用新增的错误码处理没有查询到数据的情况
This commit is contained in:
parent
2fc1e2d8da
commit
e33f9a1801
@ -2,12 +2,15 @@ package errcode
|
||||
|
||||
const (
|
||||
ErrEaLinkInstert = ErrEncounter + iota
|
||||
ErrEncounterNoData
|
||||
)
|
||||
|
||||
func EnocunterMsgInit(m msg) {
|
||||
m[ErrEaLinkInstert] = "路遇添加成功,但关联毛茸茸失败"
|
||||
m[ErrEncounterNoData] = "没有查询到数据"
|
||||
}
|
||||
|
||||
func EncounterMsgUserInit(m msg) {
|
||||
m[ErrEaLinkInstert] = "路遇上传成功啦。但是不小心让毛茸茸跑丢了 /(ㄒoㄒ)/~~"
|
||||
m[ErrEaLinkInstert] = "路遇上传成功啦。但是不小心让毛茸茸跑丢了。/(ㄒoㄒ)/~~"
|
||||
m[ErrEncounterNoData] = "没有查询到你喜欢的猫猫路遇,为他们添加吧。"
|
||||
}
|
||||
|
@ -96,7 +96,8 @@ func (e *Encounters) List(context *gin.Context) {
|
||||
if encounters != nil {
|
||||
response.Success(context, consts.CurdStatusOkMsg, encounters)
|
||||
} else {
|
||||
response.Fail(context, errcode.ErrDataNoFound, errcode.ErrMsg[errcode.ErrDataNoFound], "")
|
||||
code := errcode.ErrEncounterNoData
|
||||
response.Fail(context, code, errcode.ErrMsg[code], errcode.ErrMsgForUser[code])
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user