123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package petsLy
- import (
- "duoduo/models/mysqlLy"
- "duoduo/models/petsLy"
- "duoduo/tools"
- "duoduo/tools/app"
- "fmt"
- "github.com/gin-gonic/gin"
- )
- func PetsDetails(c *gin.Context) {
- var inData petsLy.PetsDetailsRequest
- var pets mysqlLy.Pets
- var outData petsLy.PetsDetailsResponse
- var user mysqlLy.User
- err := c.ShouldBindJSON(&inData)
- if err != nil {
- app.Error(c, 400, err, err.Error())
- return
- }
- pets.ID = inData.PetsId
- petsInfo, err := pets.Get()
- if err != nil {
- app.Error(c, 500, err, "查询数据失败")
- return
- }
- user.OpenID = petsInfo.OpenId
- userInfo,err := user.Get()
- if err != nil{
- app.Error(c,500,err,"获取用户信息失败")
- return
- }
- if petsInfo.Status == 2{
- userInfo.Phone = "***********"
- userInfo.WxCode = "***********"
- }
- outData.PetsInfo = petsInfo
- outData.Phone = userInfo.Phone
- outData.WxCode = userInfo.WxCode
- outData.DepositDate = outData.PetsInfo.DepositDate.Format("2006-01-02")
- err = tools.JsonUnmarshal(outData.PetsInfo.Pictures,&outData.Pictures)
- if err != nil{
- fmt.Println(err.Error())
- app.Error(c,500,err,"解析图片失败")
- return
- }
- app.OK(c, outData, app.Success)
- }
|