|
@@ -6,7 +6,6 @@ import (
|
|
|
"gin-vue-admin/model/request"
|
|
|
"gin-vue-admin/model/response"
|
|
|
"gin-vue-admin/service"
|
|
|
- "gin-vue-admin/utils"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"go.uber.org/zap"
|
|
|
)
|
|
@@ -76,89 +75,6 @@ func GetFileList(c *gin.Context) {
|
|
|
Total: total,
|
|
|
Page: pageInfo.Page,
|
|
|
PageSize: pageInfo.PageSize,
|
|
|
- },"获取成功", c)
|
|
|
+ }, "获取成功", c)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func ExportExcel(c *gin.Context) {
|
|
|
- var excelInfo request.ExcelInfo
|
|
|
- c.ShouldBindJSON(&excelInfo)
|
|
|
- filePath := global.GVA_CONFIG.Excel.Dir+excelInfo.FileName
|
|
|
- err := service.ParseInfoList2Excel(excelInfo.InfoList, filePath)
|
|
|
- if err != nil {
|
|
|
- global.GVA_LOG.Error("转换Excel失败!", zap.Any("err", err))
|
|
|
- response.FailWithMessage("转换Excel失败", c)
|
|
|
- return
|
|
|
- }
|
|
|
- c.Writer.Header().Add("success", "true")
|
|
|
- c.File(filePath)
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func ImportExcel(c *gin.Context) {
|
|
|
- _, header, err := c.Request.FormFile("file")
|
|
|
- if err != nil {
|
|
|
- global.GVA_LOG.Error("接收文件失败!", zap.Any("err", err))
|
|
|
- response.FailWithMessage("接收文件失败", c)
|
|
|
- return
|
|
|
- }
|
|
|
- c.SaveUploadedFile(header, global.GVA_CONFIG.Excel.Dir+"ExcelImport.xlsx")
|
|
|
- response.OkWithMessage("导入成功", c)
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func LoadExcel(c *gin.Context) {
|
|
|
- menus, err := service.ParseExcel2InfoList()
|
|
|
- if err != nil {
|
|
|
- global.GVA_LOG.Error("加载数据失败", zap.Any("err", err))
|
|
|
- response.FailWithMessage("加载数据失败", c)
|
|
|
- return
|
|
|
- }
|
|
|
- response.OkWithDetailed(response.PageResult{
|
|
|
- List: menus,
|
|
|
- Total: int64(len(menus)),
|
|
|
- Page: 1,
|
|
|
- PageSize: 999,
|
|
|
- },"加载数据成功", c)
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func DownloadTemplate(c *gin.Context) {
|
|
|
- fileName := c.Query("fileName")
|
|
|
- filePath := global.GVA_CONFIG.Excel.Dir+fileName
|
|
|
- ok, err := utils.PathExists(filePath)
|
|
|
- if !ok || err != nil {
|
|
|
- global.GVA_LOG.Error("文件不存在", zap.Any("err", err))
|
|
|
- response.FailWithMessage("文件不存在", c)
|
|
|
- return
|
|
|
- }
|
|
|
- c.Writer.Header().Add("success", "true")
|
|
|
- c.File(filePath)
|
|
|
-}
|