新增:获取系统优惠卷列表-分页

This commit is contained in:
2024-05-28 09:53:55 +08:00
parent 0bae6f821f
commit 061c91c686
6 changed files with 301 additions and 2 deletions
+6
View File
@@ -16,6 +16,7 @@ type Api struct {
financeManage // 财务管理
exportManage // 导出管理
productManage // 商品管理
couponManage // 优惠卷管理
}
// SysSetting 系统设置
@@ -91,3 +92,8 @@ type exportManage struct {
type productManage struct {
Product
}
// 优惠卷管理
type couponManage struct {
Coupon
}
+58
View File
@@ -0,0 +1,58 @@
package controller
import (
"github.com/gin-gonic/gin"
"hospital-admin-api/api/dao"
"hospital-admin-api/api/dto"
"hospital-admin-api/api/requests"
"hospital-admin-api/api/responses"
"hospital-admin-api/global"
"hospital-admin-api/utils"
)
type Coupon struct{}
// GetSystemCouponPage 获取系统优惠卷列表-分页
func (r *Coupon) GetSystemCouponPage(c *gin.Context) {
couponRequest := requests.CouponRequest{}
req := couponRequest.GetSystemCouponPage
if err := c.ShouldBindJSON(&req); err != nil {
responses.FailWithMessage(err.Error(), c)
return
}
// 参数验证
if err := global.Validate.Struct(req); err != nil {
responses.FailWithMessage(utils.Translate(err), c)
return
}
if req.Page == 0 {
req.Page = 1
}
if req.PageSize == 0 {
req.PageSize = 20
}
couponDao := dao.CouponDao{}
coupon, total, err := couponDao.GetCouponPageSearch(req, req.Page, req.PageSize)
if err != nil {
responses.FailWithMessage(err.Error(), c)
return
}
// 处理返回值
GetProductPlatformPageResponses := dto.GetCouponListDto(coupon)
if err != nil {
responses.FailWithMessage(err.Error(), c)
return
}
result := make(map[string]interface{})
result["page"] = req.Page
result["page_size"] = req.PageSize
result["total"] = total
result["data"] = GetProductPlatformPageResponses
responses.OkWithData(result, c)
}