Browse Source

fix:增加回显编辑回显字段

zqbao 8 months ago
parent
commit
05c9a3d357
3 changed files with 11 additions and 0 deletions
  1. 9 0
      controllers/report_pdf.go
  2. 1 0
      models/report_pdf.go
  3. 1 0
      models/request/report_pdf.go

+ 9 - 0
controllers/report_pdf.go

@@ -70,6 +70,10 @@ func (this *ReportPdfController) Add() {
 		br.Msg = "请选择研报所属的二级分类"
 		return
 	}
+	if req.PdfName == "" {
+		br.Msg = "pdf名称为空"
+		return
+	}
 
 	nameFirst, err := models.GetClassifyById(req.ClassifyIdFirst)
 	if err != nil {
@@ -86,6 +90,7 @@ func (this *ReportPdfController) Add() {
 
 	pdf := &models.ReportPdf{
 		PdfUrl:             req.PdfUrl,
+		PdfName:            req.PdfName + ".pdf",
 		Title:              req.Title,
 		Author:             req.Author,
 		Abstract:           req.Abstract,
@@ -132,6 +137,10 @@ func (this *ReportPdfController) UploadPdf() {
 	defer f.Close()
 
 	ext := path.Ext(h.Filename)
+	if ext != ".pdf" {
+		br.Msg = "文件格式不正确"
+		return
+	}
 	dateDir := time.Now().Format("20060102")
 	uploadDir := utils.STATIC_DIR + "dongwu/" + dateDir
 	err = os.MkdirAll(uploadDir, utils.DIR_MOD)

+ 1 - 0
models/report_pdf.go

@@ -9,6 +9,7 @@ import (
 type ReportPdf struct {
 	ReportPdfId        int       `orm:"pk" description:"id"`
 	PdfUrl             string    `description:"pdf文件URL"`
+	PdfName            string    `description:"pdf文件名称"`
 	Title              string    `description:"pdf文件标题"`
 	Author             string    `description:"作者"`
 	Abstract           string    `description:"摘要"`

+ 1 - 0
models/request/report_pdf.go

@@ -2,6 +2,7 @@ package request
 
 type ReportPdfAddReq struct {
 	PdfUrl           string `description:"pdf文件URL"`
+	PdfName          string `description:"pdf文件名称"`
 	Title            string `description:"标题"`
 	Author           string `description:"作者"`
 	Abstract         string `description:"摘要"`