新增一系列接口

This commit is contained in:
yan.y
2024-03-29 00:24:07 +08:00
parent 0884384e91
commit c799107d6c
17 changed files with 511 additions and 315 deletions
+23
View File
@@ -157,3 +157,26 @@ func (p DefParty) petTypeList() web_iris.Party {
})
}}
}
type DelPetRequest struct {
Id int64
}
func (p DefParty) delPet() web_iris.Party {
return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) {
index.Post(PetBase+"/delPet", func(ctx *context.Context) {
headerBaseInfo := GetHeaderBaseInfo(ctx)
body, _ := io.ReadAll(ctx.Request().Body)
var delPetRequest DelPetRequest
json.Unmarshal(body, &delPetRequest)
var userPetInfo models.Pet
database.Instance().Model(&models.Pet{}).Where("id = ? and uid = ?", delPetRequest.Id, headerBaseInfo.Uid).Find(&userPetInfo)
if userPetInfo.Id == 0 {
PetNotExistError.Fail(ctx, delPetRequest)
return
}
database.Instance().Where("id = ?", userPetInfo.PetId).Delete(&models.Pet{})
Success(ctx, nil, nil)
})
}}
}