Statistics on the number of files added (#951)
This commit is contained in:
parent
c995750312
commit
dc8ee89c85
2 changed files with 13 additions and 0 deletions
|
@ -106,6 +106,7 @@ func InitV1Router() *gin.Engine {
|
||||||
v1FolderGroup.GET("", v1.DirPath) ///file/dirpath
|
v1FolderGroup.GET("", v1.DirPath) ///file/dirpath
|
||||||
v1FolderGroup.POST("", v1.MkdirAll) ///file/mkdir
|
v1FolderGroup.POST("", v1.MkdirAll) ///file/mkdir
|
||||||
v1FolderGroup.GET("/size", v1.GetSize)
|
v1FolderGroup.GET("/size", v1.GetSize)
|
||||||
|
v1FolderGroup.GET("/count", v1.GetFileCount)
|
||||||
}
|
}
|
||||||
v1BatchGroup := v1Group.Group("/batch")
|
v1BatchGroup := v1Group.Group("/batch")
|
||||||
v1BatchGroup.Use()
|
v1BatchGroup.Use()
|
||||||
|
|
|
@ -807,6 +807,18 @@ func GetSize(c *gin.Context) {
|
||||||
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: size})
|
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: size})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetFileCount(c *gin.Context) {
|
||||||
|
json := make(map[string]string)
|
||||||
|
c.ShouldBind(&json)
|
||||||
|
path := json["path"]
|
||||||
|
list, err := ioutil.ReadDir(path)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.SERVICE_ERROR, Message: common_err.GetMsg(common_err.SERVICE_ERROR), Data: err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.SERVICE_ERROR, Message: common_err.GetMsg(common_err.SERVICE_ERROR), Data: len(list)})
|
||||||
|
}
|
||||||
|
|
||||||
type CenterHandler struct {
|
type CenterHandler struct {
|
||||||
// 广播通道,有数据则循环每个用户广播出去
|
// 广播通道,有数据则循环每个用户广播出去
|
||||||
broadcast chan []byte
|
broadcast chan []byte
|
||||||
|
|
Loading…
Reference in a new issue