qryWrstandard.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * @Author: zou.yingbin
  3. * @Create : 2021/1/13 11:15
  4. * @Modify : 2021/1/13 11:15
  5. */
  6. package ermcp
  7. import (
  8. "github.com/gin-gonic/gin"
  9. "mtp2_if/global/app"
  10. "mtp2_if/global/e"
  11. "mtp2_if/models"
  12. "mtp2_if/mtpcache"
  13. "net/http"
  14. )
  15. //查询现货商品请求
  16. type QryWrStandardReq struct {
  17. UserId int `form:"userid" binding:"required"` //用户ID
  18. }
  19. //查询现货商品响应
  20. type QryWrStandardRsp models.ErmcpWrstandard
  21. // QueryWrStandard 企业风险管理查询现货商品
  22. // @Summary 查询现货商品
  23. // @Produce json
  24. // @Security ApiKeyAuth
  25. // @Param userid query int true "所属机构ID"
  26. // @Success 200 {array} QryWrStandardRsp
  27. // @Failure 500 {object} app.Response
  28. // @Router /Ermcp/QueryWrStandard [get]
  29. // @Tags 企业风险管理(app)
  30. func QueryWrStandard(c *gin.Context) {
  31. appG := app.Gin{C: c}
  32. var req QryWrStandardReq
  33. if err := c.ShouldBind(&req); err != nil{
  34. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  35. return
  36. }
  37. m := models.ErmcpWrstandard{AREAUSERID: req.UserId}
  38. if d, err := m.GetData(); err == nil {
  39. for i := range d {
  40. d[i].EnumdicName = mtpcache.GetEnumDicitemName(d[i].UNITID)
  41. }
  42. appG.Response(http.StatusOK, e.SUCCESS, d)
  43. } else {
  44. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  45. }
  46. }