根据md5查看文件
This commit is contained in:
parent
80cafbc839
commit
d601fcd210
|
|
@ -26,6 +26,11 @@ type SetDeviceStatusReq struct {
|
||||||
Status string `json:"status" form:"status"` //设备状态
|
Status string `json:"status" form:"status"` //设备状态
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetFileListReq struct {
|
||||||
|
Type string `json:"type" form:"type"` //请求类型,1:按md5查询,2:按文件名查询;3:查询待删除文件
|
||||||
|
Md5 string `json:"md5" form:"md5"`
|
||||||
|
}
|
||||||
|
|
||||||
func SetUpToolGroup(router *gin.Engine) {
|
func SetUpToolGroup(router *gin.Engine) {
|
||||||
toolGroup := router.Group("/tool")
|
toolGroup := router.Group("/tool")
|
||||||
toolGroup.POST("/set_redis", SetRedis)
|
toolGroup.POST("/set_redis", SetRedis)
|
||||||
|
|
@ -35,6 +40,7 @@ func SetUpToolGroup(router *gin.Engine) {
|
||||||
toolGroup.POST("/upload", UploadFile)
|
toolGroup.POST("/upload", UploadFile)
|
||||||
toolGroup.GET("/download", DownloadFile)
|
toolGroup.GET("/download", DownloadFile)
|
||||||
toolGroup.GET("/file/:filename", GetFile)
|
toolGroup.GET("/file/:filename", GetFile)
|
||||||
|
toolGroup.POST("/file_list", GetFileList)
|
||||||
//文件管理
|
//文件管理
|
||||||
toolGroup.POST("/file_del", DelFile)
|
toolGroup.POST("/file_del", DelFile)
|
||||||
//服务器、设备状态接口
|
//服务器、设备状态接口
|
||||||
|
|
@ -71,6 +77,29 @@ func SetDeviceStatusV2(c *gin.Context) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetFileList(c *gin.Context) {
|
||||||
|
//解析请求参数
|
||||||
|
var req GetFileListReq
|
||||||
|
if err := c.ShouldBind(&req); err == nil {
|
||||||
|
if req.Type == "1" {
|
||||||
|
//按md5查询
|
||||||
|
if req.Md5 == "" {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"error": "md5 is empty", "code": proto.ParameterError, "message": "failed"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
file := dao.FindFileByMd5(req.Md5)
|
||||||
|
if file.ID == 0 {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"error": "file not found", "code": proto.FileNotFound, "message": "failed"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success", "data": file})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"error": "parameter error", "code": proto.ParameterError, "message": "failed"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func DelFile(c *gin.Context) {
|
func DelFile(c *gin.Context) {
|
||||||
//先查看是否有权限
|
//先查看是否有权限
|
||||||
id, _ := c.Get("id")
|
id, _ := c.Get("id")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue