|
@@ -8,6 +8,7 @@ import (
|
|
|
"eta_gn/eta_api/services"
|
|
|
knowledgeServ "eta_gn/eta_api/services/knowledge"
|
|
|
"eta_gn/eta_api/utils"
|
|
|
+ "fmt"
|
|
|
"github.com/h2non/filetype"
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"github.com/tealeg/xlsx"
|
|
@@ -1127,3 +1128,46 @@ func (this *ResourceController) GetAdminList() {
|
|
|
br.Msg = "获取成功"
|
|
|
br.Data = resp
|
|
|
}
|
|
|
+
|
|
|
+// TemplateDownload
|
|
|
+// @Title 下载模板
|
|
|
+// @Description 下载模板
|
|
|
+// @Success 200 {object} models.EdbdataClassifyResp
|
|
|
+// @Param ResourceType query int false "来源:1:模板1;2:模板2"
|
|
|
+// @router /resource/template [get]
|
|
|
+func (this *ResourceController) TemplateDownload() {
|
|
|
+ br := new(models.BaseResponse).Init()
|
|
|
+ defer func() {
|
|
|
+ this.Data["json"] = br
|
|
|
+ this.ServeJSON()
|
|
|
+ }()
|
|
|
+ resourceType, _ := this.GetInt("ResourceType")
|
|
|
+ downUrl := ""
|
|
|
+ fileName := ""
|
|
|
+ switch resourceType {
|
|
|
+ case 1:
|
|
|
+ downUrl = "./static/template/政策库上传模板.xlsx"
|
|
|
+ fileName = "政策库上传模板.xlsx"
|
|
|
+ case 2:
|
|
|
+ downUrl = "./static/template/观点库上传模板.xlsx"
|
|
|
+ fileName = "观点库上传模板.xlsx"
|
|
|
+ case 3:
|
|
|
+ downUrl = "./static/template/知识库上传模板.xlsx"
|
|
|
+ fileName = "知识库上传模板.xlsx"
|
|
|
+ default:
|
|
|
+ downUrl = "./static/template/事件库上传模板.xlsx"
|
|
|
+ fileName = "事件库上传模板.xlsx"
|
|
|
+ }
|
|
|
+ // 判断文件是否存在
|
|
|
+ if _, err := os.Stat(downUrl); os.IsNotExist(err) {
|
|
|
+ br.Msg = "文件不存在"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Println(downUrl, fileName)
|
|
|
+ this.Ctx.Output.Download(downUrl, fileName)
|
|
|
+ //this.Ctx.Output.Download("./static/数据导入模板.xlsx", "数据导入模板.xlsx")
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "下载成功"
|
|
|
+}
|