Explorar el Código

套保计划允许多个状态一起查

zou.yingbin hace 4 años
padre
commit
7b75ba1831
Se han modificado 2 ficheros con 6 adiciones y 6 borrados
  1. 4 4
      controllers/ermcp/qryHedgePlan.go
  2. 2 2
      models/ermcpHedgePlan.go

+ 4 - 4
controllers/ermcp/qryHedgePlan.go

@@ -17,8 +17,8 @@ import (
 
 // 查套保计划请求
 type QryHedgePlanReq struct {
-	UserId    int64   `form:"userId" binding:"required"`   //用户ID
-	HedgePlanStatus *int `form:"HedgePlanStatus" binding:"required"` // 套保计划状态
+	UserId          int64  `form:"userId" binding:"required"`          //用户ID
+	HedgePlanStatus string `form:"HedgePlanStatus" binding:"required"` // 套保计划状态(允许多个,逗号隔开)
 }
 
 // 查套保计划应答
@@ -29,7 +29,7 @@ type QryHedgePlanRsp models.ErmcpHedgePlan
 // @Produce json
 // @Security ApiKeyAuth
 // @Param userId query int true "用户ID"
-// @Param HedgePlanStatus query int true "套保计划状态 -  0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回"
+// @Param HedgePlanStatus query string true "套保计划状态(允许多个,逗号隔开) - 0:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回"
 // @Success 200 {array} QryHedgePlanRsp
 // @Failure 500 {object} app.Response
 // @Router /Ermcp/QueryHedgePlan [get]
@@ -44,7 +44,7 @@ func QueryHedgePlan(c *gin.Context) {
 	}
 
 	var m = models.ErmcpHedgePlan{Areauserid: req.UserId}
-	if d, err := m.GetData(*req.HedgePlanStatus); err == nil {
+	if d, err := m.GetData(req.HedgePlanStatus); err == nil {
 		appG.Response(http.StatusOK, e.SUCCESS, d)
 	} else {
 		logger.GetLogger().Errorf("query fail, %v", err)

+ 2 - 2
models/ermcpHedgePlan.go

@@ -31,7 +31,7 @@ type ErmcpHedgePlan struct {
 	Remark            string  `json:"remark"  xorm:"'Remark'"`                       //备注
 }
 
-func (r *ErmcpHedgePlan) buildSql(status int) string {
+func (r *ErmcpHedgePlan) buildSql(status string) string {
 	str := "select to_char(t.Hedgeplanid) Hedgeplanid," +
 		"       t.Hedgeplanno," +
 		"       t.Contracttype," +
@@ -57,7 +57,7 @@ func (r *ErmcpHedgePlan) buildSql(status int) string {
 }
 
 // 从数据库中查询套保计划数据
-func (r *ErmcpHedgePlan) GetData(status int) ([]ErmcpHedgePlan, error) {
+func (r *ErmcpHedgePlan) GetData(status string) ([]ErmcpHedgePlan, error) {
 	e := db.GetEngine()
 	sData := make([]ErmcpHedgePlan, 0)
 	if err := e.SQL(r.buildSql(status)).Find(&sData); err != nil {