id_card.go 902 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package card
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "go.uber.org/zap"
  5. "log-server/global"
  6. cardReq "log-server/model/card/request"
  7. "log-server/model/common/response"
  8. "strconv"
  9. )
  10. type IdCardApi struct {
  11. }
  12. func (a *IdCardApi) GetIdCard(c *gin.Context) {
  13. var idCard cardReq.IdCardRequest
  14. _ = c.ShouldBind(&idCard)
  15. //rows转型为整型
  16. rows, _ := strconv.Atoi(c.Query("rows"))
  17. idCard.Rows = rows
  18. if idCard.Channel != "tencent" && idCard.Channel != "xmy" && idCard.Channel != "mz" {
  19. response.FailWithMessage("请传入正确的渠道", c)
  20. return
  21. }
  22. if idCard.Rows == 0 {
  23. idCard.Rows = 1
  24. }
  25. if idCard.Flag != "realuser" {
  26. idCard.Flag = ""
  27. }
  28. if idCardList, err := idCardService.GetIdCard(idCard); err != nil{
  29. global.GVA_LOG.Error("获取失败!", zap.Error(err))
  30. response.FailWithMessage("获取失败", c)
  31. } else {
  32. response.OkWithDetailed(idCardList, "success", c)
  33. }
  34. }