feat: live module and jenkins pipeline to harbor deploy
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"kra/internal/service/dto"
|
||||
service "kra/internal/service/recharge"
|
||||
)
|
||||
|
||||
type Recharge struct{ s *service.Service }
|
||||
|
||||
func NewRecharge(s *service.Service) *Recharge { return &Recharge{s: s} }
|
||||
func (h *Recharge) Plans(c *gin.Context) {
|
||||
v, e := h.s.Plans(c.Request.Context())
|
||||
if e != nil {
|
||||
businessFail(c, e)
|
||||
return
|
||||
}
|
||||
OKWithData(c, gin.H{"list": v})
|
||||
}
|
||||
func (h *Recharge) SavePlans(c *gin.Context) {
|
||||
in, ok := bindJSON[dto.RechargePlansRequest](c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if e := h.s.SavePlans(c.Request.Context(), in); e != nil {
|
||||
businessFail(c, e)
|
||||
return
|
||||
}
|
||||
OK(c)
|
||||
}
|
||||
func (h *Recharge) List(c *gin.Context) {
|
||||
in, ok := bindQuery[dto.RechargeOrderListRequest](c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
v, total, sum, e := h.s.List(c.Request.Context(), in)
|
||||
if e != nil {
|
||||
businessFail(c, e)
|
||||
return
|
||||
}
|
||||
OKWithData(c, gin.H{"list": v, "total": total, "summary": sum})
|
||||
}
|
||||
func (h *Recharge) Get(c *gin.Context) {
|
||||
v, e := h.s.Get(c.Request.Context(), c.Param("orderNo"))
|
||||
if e != nil {
|
||||
businessFail(c, e)
|
||||
return
|
||||
}
|
||||
OKWithData(c, v)
|
||||
}
|
||||
func (h *Recharge) Create(c *gin.Context) {
|
||||
in, ok := bindJSON[dto.RechargeOrderRequest](c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
claims := Claims(c)
|
||||
if claims == nil {
|
||||
NoAuth(c, "请登录")
|
||||
return
|
||||
}
|
||||
in.ClientIP = c.ClientIP()
|
||||
in.UserAgent = c.Request.UserAgent()
|
||||
in.DeviceID = c.GetHeader("X-Device-Id")
|
||||
v, e := h.s.Create(c.Request.Context(), claims.ID, in)
|
||||
if e != nil {
|
||||
businessFail(c, e)
|
||||
return
|
||||
}
|
||||
OKWithData(c, v)
|
||||
}
|
||||
Reference in New Issue
Block a user