qryWrstandard.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. func QueryWrStandard(c *gin.Context) {
  24. appG := app.Gin{C: c}
  25. var req QryWrStandardReq
  26. if err := c.ShouldBind(&req); err != nil {
  27. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  28. return
  29. }
  30. m := models.ErmcpWrstandard{AREAUSERID: req.UserId, ISVALID: *req.Status}
  31. if d, err := m.GetData(); err == nil {
  32. for i := range d {
  33. d[i].EnumdicName = mtpcache.GetEnumDicitemName(d[i].UNITID)
  34. }
  35. appG.Response(http.StatusOK, e.SUCCESS, d)
  36. } else {
  37. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  38. }
  39. }
  40. ///////////////////////////////
  41. //查询现货商品请求
  42. type QryWrStandardDetailReq struct {
  43. UserId int `form:"userid" binding:"required"` // 用户ID
  44. Wrstandardid int `form:"wrstandardid"` // 现货商品ID
  45. Goods int `form:"goods"` // 是否查关联交易商品 1-查询
  46. }
  47. //查询现货商品响应
  48. type QryWrStandardDetailRsp models.ErmcpWrstandDetail
  49. // QueryWrStandardDetail 查询现货商品详情(菜单:现货品种/现货品种详情)
  50. func QueryWrStandardDetail(c *gin.Context) {
  51. appG := app.Gin{C: c}
  52. var req QryWrStandardDetailReq
  53. if err := c.ShouldBind(&req); err != nil {
  54. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  55. return
  56. }
  57. m := models.ErmcpWrstandDetail{Wrd: models.ErmcpWrstandard{AREAUSERID: req.UserId,
  58. WRSTANDARDID: int64(req.Wrstandardid)}, QueryGoods: req.Goods == 1}
  59. if d, err := m.GetData(); err == nil {
  60. appG.Response(http.StatusOK, e.SUCCESS, d)
  61. } else {
  62. //appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  63. appG.Response(http.StatusOK, e.SUCCESS, nil)
  64. }
  65. }