feat: file manage

This commit is contained in:
zhangwenjian committed 2020-08-23 20:49:06 +08:00
1 parent b9d3483ba3
commit 128e34ab04
11 files changed
+544 -44

No files matched your search

+61
View File
@@ -0,0 +1,61 @@
package sysfiledir
import (
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"go-admin/models"
"go-admin/tools"
"go-admin/tools/app"
"go-admin/tools/app/msg"
)
func GetSysFileDirList(c *gin.Context) {
var SysFileDir models.SysFileDir
SysFileDir.Lable = c.Request.FormValue("lable")
SysFileDir.PId, _ = tools.StringToInt(c.Request.FormValue("pid"))
SysFileDir.Id, _ = tools.StringToInt(c.Request.FormValue("id"))
SysFileDir.DataScope = tools.GetUserIdStr(c)
result, err := SysFileDir.SetSysFileDir()
tools.HasError(err, "抱歉未找到相关信息", -1)
app.OK(c, result, "")
}
func GetSysFileDir(c *gin.Context) {
var data models.SysFileDir
data.Id, _ = tools.StringToInt(c.Param("id"))
result, err := data.Get()
tools.HasError(err, "抱歉未找到相关信息", -1)
app.OK(c, result, "")
}
func InsertSysFileDir(c *gin.Context) {
var data models.SysFileDir
err := c.ShouldBindJSON(&data)
data.CreateBy = tools.GetUserIdStr(c)
tools.HasError(err, "", 500)
result, err := data.Create()
tools.HasError(err, "", -1)
app.OK(c, result, "")
}
func UpdateSysFileDir(c *gin.Context) {
var data models.SysFileDir
err := c.BindWith(&data, binding.JSON)
tools.HasError(err, "数据解析失败", -1)
data.UpdateBy = tools.GetUserIdStr(c)
result, err := data.Update(data.Id)
tools.HasError(err, "", -1)
app.OK(c, result, "")
}
func DeleteSysFileDir(c *gin.Context) {
var data models.SysFileDir
data.UpdateBy = tools.GetUserIdStr(c)
IDS := tools.IdsStrToIdsIntGroup("id", c)
_, err := data.BatchDelete(IDS)
tools.HasError(err, msg.DeletedFail, 500)
app.OK(c, nil, msg.DeletedSuccess)
}