Browse Source

解决冲突

gitlink
Sydonian 5 months ago
parent
commit
0bd01ca12a
3 changed files with 42 additions and 9 deletions
  1. +21
    -9
      client/internal/http/v1/mount.go
  2. +1
    -0
      client/internal/http/v1/server.go
  3. +20
    -0
      client/sdk/api/v1/mount.go

+ 21
- 9
client/internal/http/v1/mount.go View File

@@ -4,8 +4,6 @@ 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"
)

@@ -20,14 +18,14 @@ func (s *Server) Mount() *MountService {
}

func (m *MountService) DumpStatus(ctx *gin.Context) {
log := logger.WithField("HTTP", "Mount.DumpStatus")
// 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
}
// 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{
@@ -35,6 +33,20 @@ func (m *MountService) DumpStatus(ctx *gin.Context) {
}))
}

func (m *MountService) ReloadFilter(ctx *gin.Context) {
// log := logger.WithField("HTTP", "Mount.ReloadFilter")

// var req cliapi.MountReloadFilter
// 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
// }

m.svc.Mount.ReloadSyncFilter()
ctx.JSON(http.StatusOK, OK(cliapi.MountReloadFilterResp{}))
}

func (m *MountService) StartReclaimSpace(ctx *gin.Context) {
// log := logger.WithField("HTTP", "Mount.ReclaimSpace")
// var req cliapi.MountReclaimSpace


+ 1
- 0
client/internal/http/v1/server.go View File

@@ -71,5 +71,6 @@ func (s *Server) InitRouters(rt gin.IRoutes) {
rt.POST(cliapi.PresignedObjectCompleteMultipartUploadPath, awsAuth.PresignedAuth, s.Presigned().ObjectCompleteMultipartUpload)

rt.GET(cliapi.MountDumpStatusPath, awsAuth.Auth, s.Mount().DumpStatus)
rt.POST(cliapi.MountReloadFilterPath, s.Mount().ReloadFilter)
rt.POST(cliapi.MountStartReclaimSpacePath, awsAuth.Auth, s.Mount().StartReclaimSpace)
}

+ 20
- 0
client/sdk/api/v1/mount.go View File

@@ -37,6 +37,26 @@ func (c *MountService) DumpStatus(req MountDumpStatus) (*MountDumpStatusResp, er
return JSONAPI(c.cfg, http.DefaultClient, &req, &MountDumpStatusResp{})
}

const MountReloadFilterPath = "/mount/reloadFilter"

type MountReloadFilter struct {
}

func (r *MountReloadFilter) MakeParam() *sdks.RequestParam {
return sdks.MakeQueryParam(http.MethodPost, MountReloadFilterPath, r)
}

type MountReloadFilterResp struct {
}

func (r *MountReloadFilterResp) ParseResponse(resp *http.Response) error {
return sdks.ParseCodeDataJSONResponse(resp, r)
}

func (c *MountService) ReloadFilter(req MountReloadFilter) (*MountReloadFilterResp, error) {
return JSONAPI(c.cfg, http.DefaultClient, &req, &MountReloadFilterResp{})
}

const MountStartReclaimSpacePath = "/mount/startReclaimSpace"

type StartMountReclaimSpace struct{}


Loading…
Cancel
Save