qryWrstandard.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. }
  47. ///////////////////////////////
  48. //查询现货商品请求
  49. type QryWrStandardDetailReq struct {
  50. UserId int `form:"userid" binding:"required"` //用户ID
  51. Wrstandardid int `form:"wrstandardid" binding:"required"` // 现货商品ID
  52. }
  53. //查询现货商品响应
  54. type QryWrStandardDetailRsp models.ErmcpWrstandDetail
  55. // @Summary 查询现货商品详情(菜单:现货品种/现货品种详情)
  56. // @Produce json
  57. // @Security ApiKeyAuth
  58. // @Param userid query int true "所属机构ID"
  59. // @Param wrstandardid query int true "现货商品ID"
  60. // @Success 200 {array} QryWrStandardDetailRsp
  61. // @Failure 500 {object} app.Response
  62. // @Router /Ermcp/QueryWrStandardDetail [get]
  63. // @Tags 企业风险管理(app)
  64. func QueryWrStandardDetail(c *gin.Context) {
  65. appG := app.Gin{C: c}
  66. var req QryWrStandardDetailReq
  67. if err := c.ShouldBind(&req); err != nil {
  68. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  69. return
  70. }
  71. m := models.ErmcpWrstandDetail{Wrd: models.ErmcpWrstandard{AREAUSERID: req.UserId,
  72. WRSTANDARDID: int64(req.Wrstandardid)}}
  73. if d, err := m.GetData(); err == nil {
  74. appG.Response(http.StatusOK, e.SUCCESS, d)
  75. } else {
  76. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  77. }
  78. }