|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package http
-
- import (
- "net/http"
-
- "github.com/gin-gonic/gin"
- "gitlink.org.cn/cloudream/common/consts/errorcode"
- "gitlink.org.cn/cloudream/common/pkgs/logger"
- cliapi "gitlink.org.cn/cloudream/jcs-pub/client/sdk/api/v1"
- )
-
- type MountService struct {
- *Server
- }
-
- func (s *Server) Mount() *MountService {
- return &MountService{
- Server: s,
- }
- }
-
- func (m *MountService) DumpStatus(ctx *gin.Context) {
- log := logger.WithField("HTTP", "Mount.DumpStatus")
-
- var req cliapi.MountDumpStatus
- if err := ctx.ShouldBindQuery(&req); err != nil {
- log.Warnf("binding body: %s", err.Error())
- ctx.JSON(http.StatusBadRequest, Failed(errorcode.BadArgument, "missing argument or invalid argument"))
- return
- }
-
- dumpStatus := m.svc.Mount.Dump()
- ctx.JSON(http.StatusOK, OK(cliapi.MountDumpStatusResp{
- MountStatus: dumpStatus,
- }))
- }
-
- func (m *MountService) StartReclaimSpace(ctx *gin.Context) {
- // log := logger.WithField("HTTP", "Mount.ReclaimSpace")
- // var req cliapi.MountReclaimSpace
- // if err := ctx.ShouldBindJSON(&req); err != nil {
- // log.Warnf("binding body: %s", err.Error())
- // ctx.JSON(http.StatusBadRequest, Failed(errorcode.BadArgument, "missing argument or invalid argument"))
- // return
- // }
-
- m.svc.Mount.StartReclaimSpace()
- ctx.JSON(http.StatusOK, OK(cliapi.StartMountReclaimSpaceResp{}))
- }
|