feat: live module and jenkins pipeline to harbor deploy
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
service "kra/internal/service/asset"
|
||||
"kra/internal/service/dto"
|
||||
)
|
||||
|
||||
type Asset struct{ s *service.Service }
|
||||
|
||||
func NewAsset(s *service.Service) *Asset { return &Asset{s: s} }
|
||||
func (h *Asset) List(c *gin.Context) {
|
||||
in, ok := bindQuery[dto.AssetUserListRequest](c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
v, total, e := h.s.List(c.Request.Context(), in)
|
||||
if e != nil {
|
||||
businessFail(c, e)
|
||||
return
|
||||
}
|
||||
OKWithData(c, gin.H{"list": v, "total": total})
|
||||
}
|
||||
func (h *Asset) Get(c *gin.Context) {
|
||||
id, ok := businessID(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
v, e := h.s.Get(c.Request.Context(), id)
|
||||
if e != nil {
|
||||
businessFail(c, e)
|
||||
return
|
||||
}
|
||||
OKWithData(c, v)
|
||||
}
|
||||
func (h *Asset) Status(c *gin.Context) {
|
||||
id, ok := businessID(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
in, ok := bindJSON[dto.LiveStatusRequest](c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
claims := Claims(c)
|
||||
actor := uint(0)
|
||||
if claims != nil {
|
||||
actor = claims.ID
|
||||
}
|
||||
if e := h.s.SetEnabled(c.Request.Context(), actor, id, in.Enabled); e != nil {
|
||||
businessFail(c, e)
|
||||
return
|
||||
}
|
||||
OK(c)
|
||||
}
|
||||
func (h *Asset) Adjust(c *gin.Context) {
|
||||
id, ok := businessID(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
in, ok := bindJSON[dto.AssetAdjustmentRequest](c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
claims := Claims(c)
|
||||
actor := uint(0)
|
||||
if claims != nil {
|
||||
actor = claims.ID
|
||||
}
|
||||
v, e := h.s.Adjust(c.Request.Context(), actor, id, in)
|
||||
if e != nil {
|
||||
businessFail(c, e)
|
||||
return
|
||||
}
|
||||
OKWithData(c, v)
|
||||
}
|
||||
Reference in New Issue
Block a user