Jelajahi Sumber

Digital相关接口添加分页查询

deng.yinping 1 bulan lalu
induk
melakukan
b90433c6cd
5 mengubah file dengan 174 tambahan dan 15 penghapusan
  1. 12 4
      controllers/digital/queryDigital.go
  2. 48 0
      docs/docs.go
  3. 48 0
      docs/swagger.json
  4. 32 0
      docs/swagger.yaml
  5. 34 11
      models/taaccountdigital.go

+ 12 - 4
controllers/digital/queryDigital.go

@@ -34,6 +34,8 @@ func QueryTaaccountDigitals(c *gin.Context) {
 // @Param   digitalaccountid 	query    string true 	"数字账户ID"
 // @Param   applydate 			query    string false 	"申请日期(yyyyMMdd)"
 // @Param   transfertypes 		query    string 	false 	"划转类型(多个逗号分隔) - 枚举digitaltransfertype(1:充值 2:提现 3:转入 4:转出)"
+// @Param    page        query    int    false "页码"
+// @Param    pagesize    query    int    false "每页条数"
 // @Success 200    {array}  models.Taaccountdigitalchangeapply
 // @Failure 500    {object} app.Response
 // @Router  /Digital/QueryTaaccountDigitalChangeApplys [post]
@@ -42,7 +44,7 @@ func QueryTaaccountDigitalChangeApplys(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
 	m := models.Taaccountdigitalchangeapply{}
 	a.DoBindReq(&m)
-	a.DoGetDataI(&m)
+	a.DoGetDataByPage(&m)
 }
 
 // QueryTaaccountDigitalLogs
@@ -53,6 +55,8 @@ func QueryTaaccountDigitalChangeApplys(c *gin.Context) {
 // @Param   digitalaccountid 	query    string true 	"数字账户ID"
 // @Param   tradedate 			query    string false 	"交易日(yyyyMMdd)"
 // @Param   businesscodes 		query    string false 	"业务类型(多个逗号分隔) - 枚举digitalbusinesscode(1:充值 2:提现 3:转入 4:转出 5:现货交易 6:现货交易手续费 7:提现手续费...)"
+// @Param    page        query    int    false "页码"
+// @Param    pagesize    query    int    false "每页条数"
 // @Success 200    {array}  models.Taaccountdigitallog
 // @Failure 500    {object} app.Response
 // @Router  /Digital/QueryTaaccountDigitalLogs [post]
@@ -61,7 +65,7 @@ func QueryTaaccountDigitalLogs(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
 	m := models.Taaccountdigitallog{}
 	a.DoBindReq(&m)
-	a.DoGetDataI(&m)
+	a.DoGetDataByPage(&m)
 }
 
 // QueryDigitalTradeOrderDetails
@@ -74,6 +78,8 @@ func QueryTaaccountDigitalLogs(c *gin.Context) {
 // @Param   goodsid 			query    int	false 	"商品ID"
 // @Param   tradedate 			query    string false 	"交易日(yyyyMMdd)"
 // @Param   orderstatuses 		query    string false 	"委托状态(多个逗号分隔) 参考枚举orderstatus"
+// @Param    page        query    int    false "页码"
+// @Param    pagesize    query    int    false "每页条数"
 // @Success 200    {array}  models.DigitaltradeOrderdetail
 // @Failure 500    {object} app.Response
 // @Router  /Digital/QueryDigitalTradeOrderDetails [post]
@@ -82,7 +88,7 @@ func QueryDigitalTradeOrderDetails(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
 	m := models.DigitaltradeOrderdetail{}
 	a.DoBindReq(&m)
-	a.DoGetDataI(&m)
+	a.DoGetDataByPage(&m)
 }
 
 // QueryDigitalTradeTradeDetails
@@ -94,6 +100,8 @@ func QueryDigitalTradeOrderDetails(c *gin.Context) {
 // @Param   digitalaccountid 	query    string false 	"数字账户ID"
 // @Param   goodsid 			query    int	false 	"商品ID"
 // @Param   tradedate 			query    string false 	"交易日(yyyyMMdd)"
+// @Param    page        query    int    false "页码"
+// @Param    pagesize    query    int    false "每页条数"
 // @Success 200    {array}  models.DigitaltradeTradedetail
 // @Failure 500    {object} app.Response
 // @Router  /Digital/QueryDigitalTradeTradeDetails [post]
@@ -102,5 +110,5 @@ func QueryDigitalTradeTradeDetails(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
 	m := models.DigitaltradeTradedetail{}
 	a.DoBindReq(&m)
-	a.DoGetDataI(&m)
+	a.DoGetDataByPage(&m)
 }

+ 48 - 0
docs/docs.go

@@ -2483,6 +2483,18 @@ const docTemplate = `{
                         "description": "委托状态(多个逗号分隔) 参考枚举orderstatus",
                         "name": "orderstatuses",
                         "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -2546,6 +2558,18 @@ const docTemplate = `{
                         "description": "交易日(yyyyMMdd)",
                         "name": "tradedate",
                         "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -2603,6 +2627,18 @@ const docTemplate = `{
                         "description": "划转类型(多个逗号分隔) - 枚举digitaltransfertype(1:充值 2:提现 3:转入 4:转出)",
                         "name": "transfertypes",
                         "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -2660,6 +2696,18 @@ const docTemplate = `{
                         "description": "业务类型(多个逗号分隔) - 枚举digitalbusinesscode(1:充值 2:提现 3:转入 4:转出 5:现货交易 6:现货交易手续费 7:提现手续费...)",
                         "name": "businesscodes",
                         "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
                     }
                 ],
                 "responses": {

+ 48 - 0
docs/swagger.json

@@ -2475,6 +2475,18 @@
                         "description": "委托状态(多个逗号分隔) 参考枚举orderstatus",
                         "name": "orderstatuses",
                         "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -2538,6 +2550,18 @@
                         "description": "交易日(yyyyMMdd)",
                         "name": "tradedate",
                         "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -2595,6 +2619,18 @@
                         "description": "划转类型(多个逗号分隔) - 枚举digitaltransfertype(1:充值 2:提现 3:转入 4:转出)",
                         "name": "transfertypes",
                         "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -2652,6 +2688,18 @@
                         "description": "业务类型(多个逗号分隔) - 枚举digitalbusinesscode(1:充值 2:提现 3:转入 4:转出 5:现货交易 6:现货交易手续费 7:提现手续费...)",
                         "name": "businesscodes",
                         "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
                     }
                 ],
                 "responses": {

+ 32 - 0
docs/swagger.yaml

@@ -34431,6 +34431,14 @@ paths:
         in: query
         name: orderstatuses
         type: string
+      - description: 页码
+        in: query
+        name: page
+        type: integer
+      - description: 每页条数
+        in: query
+        name: pagesize
+        type: integer
       produces:
       - application/json
       responses:
@@ -34471,6 +34479,14 @@ paths:
         in: query
         name: tradedate
         type: string
+      - description: 页码
+        in: query
+        name: page
+        type: integer
+      - description: 每页条数
+        in: query
+        name: pagesize
+        type: integer
       produces:
       - application/json
       responses:
@@ -34507,6 +34523,14 @@ paths:
         in: query
         name: transfertypes
         type: string
+      - description: 页码
+        in: query
+        name: page
+        type: integer
+      - description: 每页条数
+        in: query
+        name: pagesize
+        type: integer
       produces:
       - application/json
       responses:
@@ -34544,6 +34568,14 @@ paths:
         in: query
         name: businesscodes
         type: string
+      - description: 页码
+        in: query
+        name: page
+        type: integer
+      - description: 每页条数
+        in: query
+        name: pagesize
+        type: integer
       produces:
       - application/json
       responses:

+ 34 - 11
models/taaccountdigital.go

@@ -120,6 +120,7 @@ type Taaccountdigitalchangeapply struct {
 	APPLYDATE     string `json:"-" xorm:"-" form:"applydate"`     // 申请日期(yyyyMMdd)
 	TRANSFERTYPES string `json:"-" xorm:"-" form:"transfertypes"` // 划转类型(多个逗号分隔) - 枚举"digitaltransfertype"(1:充值 2:提现 3:转入 4:转出)
 
+	PageEx `xorm:"extends"` // 页码信息
 }
 
 func (r *Taaccountdigitalchangeapply) calc() {
@@ -137,17 +138,21 @@ func (r *Taaccountdigitalchangeapply) buildSql() string {
 	}
 	sqlId.FormatParam(r.DIGITALACCOUNTID)
 	sqlId.Join(" ORDER BY t.APPLYTIME DESC")
+
+	sqlId.Page(r.Page, r.PageSize)
 	return sqlId.String()
 }
 
-// GetDataEx 从数据库中查询数据
-func (r *Taaccountdigitalchangeapply) GetDataEx() (interface{}, error) {
+// GetDataByPage 从数据库中查询分页数据
+func (r *Taaccountdigitalchangeapply) GetDataByPage() (interface{}, error, int, int, int) {
 	sData := make([]Taaccountdigitalchangeapply, 0)
 	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	total := 0
 	for i := range sData {
 		sData[i].calc()
+		total = sData[i].Total
 	}
-	return sData, err
+	return sData, err, r.Page, r.PageSize, total
 }
 
 // Taaccountdigitallog  数字账户流水表
@@ -168,6 +173,8 @@ type Taaccountdigitallog struct {
 	REMARK              string    `json:"remark" xorm:"REMARK"`                                                                // 备注
 
 	BUSINESSCODES string `json:"-" xorm:"-" form:"businesscodes"` // 业务类型(多个逗号分隔) - 枚举digitalbusinesscode(1:充值 2:提现 3:转入 4:转出 5:现货交易 6:现货交易手续费 7:提现手续费...)
+
+	PageEx `xorm:"extends"` // 页码信息
 }
 
 func (r *Taaccountdigitallog) calc() {
@@ -185,17 +192,21 @@ func (r *Taaccountdigitallog) buildSql() string {
 	}
 	sqlId.FormatParam(r.DIGITALACCOUNTID)
 	sqlId.Join(" ORDER BY t.CREATETIME DESC")
+
+	sqlId.Page(r.Page, r.PageSize)
 	return sqlId.String()
 }
 
-// GetDataEx 从数据库中查询数据
-func (r *Taaccountdigitallog) GetDataEx() (interface{}, error) {
+// GetDataByPage 从数据库中查询分页数据
+func (r *Taaccountdigitallog) GetDataByPage() (interface{}, error, int, int, int) {
 	sData := make([]Taaccountdigitallog, 0)
 	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	total := 0
 	for i := range sData {
 		sData[i].calc()
+		total = sData[i].Total
 	}
-	return sData, err
+	return sData, err, r.Page, r.PageSize, total
 }
 
 // DigitaltradeOrderdetail  数字货币交易委托表
@@ -244,6 +255,8 @@ type DigitaltradeOrderdetail struct {
 
 	ORDERSTATUSES    string `json:"-" xorm:"-" form:"orderstatuses"`    // 委托状态(多个逗号分隔) 参考枚举orderstatus
 	DIGITALACCOUNTID string `json:"-" xorm:"-" form:"digitalaccountid"` // 数字账户ID
+
+	PageEx `xorm:"extends"` // 页码信息
 }
 
 func (r *DigitaltradeOrderdetail) calc() {
@@ -265,17 +278,21 @@ func (r *DigitaltradeOrderdetail) buildSql() string {
 	}
 	sqlId.FormatParam(r.USERID)
 	sqlId.Join(" ORDER BY t.ORDERID DESC")
+
+	sqlId.Page(r.Page, r.PageSize)
 	return sqlId.String()
 }
 
-// GetDataEx 从数据库中查询数据
-func (r *DigitaltradeOrderdetail) GetDataEx() (interface{}, error) {
+// GetDataByPage 从数据库中查询分页数据
+func (r *DigitaltradeOrderdetail) GetDataByPage() (interface{}, error, int, int, int) {
 	sData := make([]DigitaltradeOrderdetail, 0)
 	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	total := 0
 	for i := range sData {
 		sData[i].calc()
+		total = sData[i].Total
 	}
-	return sData, err
+	return sData, err, r.Page, r.PageSize, total
 }
 
 // DigitaltradeTradedetail  数字货币交易成交单表
@@ -310,6 +327,8 @@ type DigitaltradeTradedetail struct {
 	TRADEPROPERTY          uint32    `json:"tradeproperty" xorm:"TRADEPROPERTY"`                    // 交易属性
 
 	DIGITALACCOUNTID string `json:"-" xorm:"-" form:"digitalaccountid"` // 数字账户ID
+
+	PageEx `xorm:"extends"` // 页码信息
 }
 
 func (r *DigitaltradeTradedetail) calc() {
@@ -328,15 +347,19 @@ func (r *DigitaltradeTradedetail) buildSql() string {
 	sqlId.AndEx("t.tradedate", r.TRADEDATE, strings.TrimSpace(r.TRADEDATE) != "")
 	sqlId.FormatParam(r.USERID)
 	sqlId.Join(" ORDER BY t.TRADEID DESC")
+
+	sqlId.Page(r.Page, r.PageSize)
 	return sqlId.String()
 }
 
 // GetDataEx 从数据库中查询数据
-func (r *DigitaltradeTradedetail) GetDataEx() (interface{}, error) {
+func (r *DigitaltradeTradedetail) GetDataByPage() (interface{}, error, int, int, int) {
 	sData := make([]DigitaltradeTradedetail, 0)
 	err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
+	total := 0
 	for i := range sData {
 		sData[i].calc()
+		total = sData[i].Total
 	}
-	return sData, err
+	return sData, err, r.Page, r.PageSize, total
 }