| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- /**
- * @Author: zou.yingbin
- * @Create : 2021/1/6 10:12
- * @Modify : 2021/1/6 10:12
- */
- package ermcp
- import (
- "github.com/gin-gonic/gin"
- "mtp2_if/global/app"
- "mtp2_if/global/e"
- "mtp2_if/logger"
- "mtp2_if/models"
- "net/http"
- )
- // 查询现货合同
- type QrySpotContractReq struct {
- UserId int64 `form:"userId" binding:"required"` //用户ID
- QueryType int32 `form:"QueryType" binding:"required"` // 查询类型 1-未提交 2-待审核 3-履约中 4-已完成
- }
- // 查询现货合同应答
- type QrySpotContractRsp models.ErmcpSpotContractModel
- // QuerySpotContract 企业风险管理合同查询
- // @Summary 查询现货合同(对应现货合同菜单)
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userId query int true "用户ID"
- // @Param QueryType query int true "查询类型 1-未提交 2-待审核 3-履约中 4-已完成"
- // @Success 200 {array} QrySpotContractRsp
- // @Failure 500 {object} app.Response
- // @Router /Ermcp/QuerySpotContract [get]
- // @Tags 企业风险管理(app)
- func QuerySpotContract(c *gin.Context) {
- appG := app.Gin{C: c}
- var req QrySpotContractReq
- if err := c.ShouldBind(&req); err != nil {
- logger.GetLogger().Errorf("parse query req: %v", err)
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- var m = models.ErmcpSpotContractModel{USERID: req.UserId}
- if d, err := m.GetData(req.QueryType); err == nil {
- appG.Response(http.StatusOK, e.SUCCESS, d)
- } else {
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- }
- }
- // 查询合同请求结构
- type QryErmcpReq struct {
- UserId int64 `form:"userId" binding:"required"` //用户ID
- ContractType int32 `form:"contracttype" binding:"required"` // 合同类型
- QueryType int32 `form:"querytype" binding:"required"` // 查询类型 1-全部 2-待点价 3-履约结算
- ContractId string `form:"contractid"` // 合同id(SpotContractId)
- }
- // 查询合同应答
- type QryErmcpRsp models.ErmcpModel
- // QueryContract 企业风险管理合同查询
- // @Summary 查询合同(采购和销售)
- // @Produce json
- // @Security ApiKeyAuth
- // @Param userId query int true "用户ID"
- // @Param contracttype query int true "合同类型 1-采购, -1-销售"
- // @Param querytype query int true "查询类型 1-全部 2-待点价 3-履约结算"
- // @Param contractid query string false "合同ID(SpotContractId)"
- // @Success 200 {array} QryErmcpRsp
- // @Failure 500 {object} app.Response
- // @Router /Ermcp/QueryContract [get]
- // @Tags 企业风险管理(app)
- func QueryContract(c *gin.Context) {
- appG := app.Gin{C: c}
- var req QryErmcpReq
- if err := c.ShouldBind(&req); err != nil {
- logger.GetLogger().Errorf("parse query req: %v", err)
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- // 参数检查
- if req.ContractType != 1 && req.ContractType != -1 {
- logger.GetLogger().Errorf("ContractType should in(1, -1)")
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- if req.QueryType != 1 && req.QueryType != 2 && req.QueryType != 3 {
- logger.GetLogger().Errorf("QueryType should in(1, 2, 3)")
- appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
- return
- }
- var m = models.ErmcpModel{UserID: req.UserId, SpotContractId: req.ContractId}
- if d, err := m.GetData(req.ContractType, req.QueryType); err == nil {
- appG.Response(http.StatusOK, e.SUCCESS, d)
- } else {
- appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
- }
- }
- // QueryTradeConfigTMP
- // @Summary 查询交易模板配置
- // @Produce json
- // @Security ApiKeyAuth
- // @Param areauserid query int false "所属机构id"
- // @Success 200 {array} models.ErmcpTradeConfigTMP
- // @Failure 500 {object} app.Response
- // @Router /Ermcp/QueryTradeConfigTMP [get]
- // @Tags 企业风险管理(app)
- func QueryTradeConfigTMP(c *gin.Context) {
- a := app.GinUtils{Gin: app.Gin{C: c}}
- req := struct {
- Areauserid int64 `form:"areauserid"` // 机构id
- }{}
- a.DoBindReq(&req)
- // 现在表里id都为1, 改为固定查arearuserid=1的
- req.Areauserid = 1
- m := models.ErmcpTradeConfigTMP{AREAUSERID: req.Areauserid}
- a.DoGetDataI(&m)
- }
|