qryWrstandard.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. Status *int32 `form:"status" binding:"required"` //状态
  19. }
  20. //查询现货商品响应
  21. type QryWrStandardRsp models.ErmcpWrstandard
  22. // QueryWrStandard 企业风险管理查询现货商品
  23. // @Summary 查询现货商品
  24. // @Produce json
  25. // @Security ApiKeyAuth
  26. // @Param userid query int true "所属机构ID"
  27. // @Param status query int true "状态 0-停用 1-正常"
  28. // @Success 200 {array} QryWrStandardRsp
  29. // @Failure 500 {object} app.Response
  30. // @Router /Ermcp/QueryWrStandard [get]
  31. // @Tags 企业风险管理(app)
  32. func QueryWrStandard(c *gin.Context) {
  33. appG := app.Gin{C: c}
  34. var req QryWrStandardReq
  35. if err := c.ShouldBind(&req); err != nil {
  36. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  37. return
  38. }
  39. m := models.ErmcpWrstandard{AREAUSERID: req.UserId, ISVALID: *req.Status}
  40. if d, err := m.GetData(); err == nil {
  41. for i := range d {
  42. d[i].EnumdicName = mtpcache.GetEnumDicitemName(d[i].UNITID)
  43. }
  44. appG.Response(http.StatusOK, e.SUCCESS, d)
  45. } else {
  46. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  47. }
  48. }
  49. ///////////////////////////////
  50. //查询现货商品请求
  51. type QryWrStandardDetailReq struct {
  52. UserId int `form:"userid" binding:"required"` //用户ID
  53. Wrstandardid int `form:"wrstandardid" binding:"required"` // 现货商品ID
  54. }
  55. //查询现货商品响应
  56. type QryWrStandardDetailRsp models.ErmcpWrstandDetail
  57. // @Summary 查询现货商品详情(菜单:现货品种/现货品种详情)
  58. // @Produce json
  59. // @Security ApiKeyAuth
  60. // @Param userid query int true "所属机构ID"
  61. // @Param wrstandardid query int true "现货商品ID"
  62. // @Success 200 {array} QryWrStandardDetailRsp
  63. // @Failure 500 {object} app.Response
  64. // @Router /Ermcp/QueryWrStandardDetail [get]
  65. // @Tags 企业风险管理(app)
  66. func QueryWrStandardDetail(c *gin.Context) {
  67. appG := app.Gin{C: c}
  68. var req QryWrStandardDetailReq
  69. if err := c.ShouldBind(&req); err != nil {
  70. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  71. return
  72. }
  73. m := models.ErmcpWrstandDetail{Wrd: models.ErmcpWrstandard{AREAUSERID: req.UserId,
  74. WRSTANDARDID: int64(req.Wrstandardid)}}
  75. if d, err := m.GetData(); err == nil {
  76. appG.Response(http.StatusOK, e.SUCCESS, d)
  77. } else {
  78. //appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  79. appG.Response(http.StatusOK, e.SUCCESS, nil)
  80. }
  81. }