|
|
|
@ -8,7 +8,9 @@ import (
|
|
|
|
|
"github.com/bluesky335/IDCheck/IdNumber"
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
"net/http"
|
|
|
|
|
"net/url"
|
|
|
|
|
"os"
|
|
|
|
|
"strings"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
//模块的路由配置
|
|
|
|
@ -27,7 +29,7 @@ func Routers(r *gin.RouterGroup) {
|
|
|
|
|
|
|
|
|
|
rr.POST("/ImportTeacherExcel", ImportTeacherExcel)
|
|
|
|
|
|
|
|
|
|
rr.GET("/DownLoadExcel", DownLoadExcel)
|
|
|
|
|
rr.GET("/DownLoadErrorExcel", DownLoadErrorExcel)
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
@ -579,20 +581,38 @@ func ImportTeacherExcel(c *gin.Context) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !r.Success {
|
|
|
|
|
r.Message = c.Request.Host + "/dsBaseWeb/ExcelTemp/" + fileId + ".xlsx"
|
|
|
|
|
message := ""
|
|
|
|
|
errorCode := ""
|
|
|
|
|
if r.Message == "01" {
|
|
|
|
|
errorCode = r.Message
|
|
|
|
|
message = "上传的模板不是系统提供的,请重新下载系统提供的模板进行上传!"
|
|
|
|
|
} else if r.Message == "02" {
|
|
|
|
|
errorCode = r.Message
|
|
|
|
|
message = c.Request.Host + "/base/teacher/DownLoadErrorExcel?fileId=" + fileId + "&fileName=" + url.QueryEscape(strings.Split(header.Filename, ".xlsx")[0])
|
|
|
|
|
} else {
|
|
|
|
|
errorCode = "03"
|
|
|
|
|
message = "上传文件未找到!"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
c.JSON(http.StatusOK, Model.Res{
|
|
|
|
|
Success: r.Success,
|
|
|
|
|
Message: r.Message,
|
|
|
|
|
Success: r.Success,
|
|
|
|
|
ErrorCode: errorCode,
|
|
|
|
|
Message: message,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func DownLoadExcel(c *gin.Context) {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
功能:下载教师错误的EXCEL模板
|
|
|
|
|
作者:吴缤
|
|
|
|
|
日期:2020-07-20
|
|
|
|
|
*/
|
|
|
|
|
func DownLoadErrorExcel(c *gin.Context) {
|
|
|
|
|
fileId := c.Query("fileId")
|
|
|
|
|
fileName := c.Query("fileName")
|
|
|
|
|
|
|
|
|
|
c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", fileName+".xlsx"))
|
|
|
|
|
c.Writer.Header().Set("Content-Type", "application/octet-stream")
|
|
|
|
|
c.File(r.ExcelPath)
|
|
|
|
|
rootPath, _ := os.Getwd()
|
|
|
|
|
fileDir := rootPath + "/Html/ExcelTemp/" + fileId + ".xlsx"
|
|
|
|
|
c.File(fileDir)
|
|
|
|
|
}
|
|
|
|
|