Browse Source

fix:pdf编辑添加字段

zqbao 8 months ago
parent
commit
5773e1165b
2 changed files with 8 additions and 2 deletions
  1. 7 2
      controllers/report_pdf.go
  2. 1 0
      models/request/report_pdf.go

+ 7 - 2
controllers/report_pdf.go

@@ -381,6 +381,10 @@ func (this *ReportPdfController) Edit() {
 		br.Msg = "请上传研报文件"
 		return
 	}
+	if req.PdfName == "" {
+		br.Msg = "请填写研报名称"
+		return
+	}
 	reportPdf, err := models.GetReportPdfById(req.ReportPdfId)
 	if err != nil {
 		if err.Error() == utils.ErrNoRow() {
@@ -404,8 +408,9 @@ func (this *ReportPdfController) Edit() {
 		br.ErrMsg = "二级类名获取失败,Err:" + err.Error()
 		return
 	}
-	if reportPdf.Title != req.Title || reportPdf.ClassifyIdFirst != req.ClassifyIdFirst || reportPdf.ClassifyIdSecond != req.ClassifyIdSecond || reportPdf.Author != req.Author || reportPdf.Abstract != req.Abstract || reportPdf.PdfUrl != req.PdfUrl {
+	if reportPdf.PdfName != req.PdfName || reportPdf.Title != req.Title || reportPdf.ClassifyIdFirst != req.ClassifyIdFirst || reportPdf.ClassifyIdSecond != req.ClassifyIdSecond || reportPdf.Author != req.Author || reportPdf.Abstract != req.Abstract || reportPdf.PdfUrl != req.PdfUrl {
 		reportPdf.Title = req.Title
+		reportPdf.PdfName = req.PdfName + ".pdf"
 		reportPdf.ClassifyIdFirst = req.ClassifyIdFirst
 		reportPdf.ClassifyIdSecond = req.ClassifyIdSecond
 		reportPdf.ClassifyNameFirst = nameFirst.ClassifyName
@@ -414,7 +419,7 @@ func (this *ReportPdfController) Edit() {
 		reportPdf.Abstract = req.Abstract
 		reportPdf.PdfUrl = req.PdfUrl
 		reportPdf.ModifyTime = time.Now()
-		err = reportPdf.Update([]string{"title", "classify_id_first", "classify_id_second", "classify_name_first", "classify_name_second", "author", "abstract", "pdf_url", "modify_time"})
+		err = reportPdf.Update([]string{"pdf_name", "title", "classify_id_first", "classify_id_second", "classify_name_first", "classify_name_second", "author", "abstract", "pdf_url", "modify_time"})
 		if err != nil {
 			br.Msg = "文件更新失败"
 			br.ErrMsg = "文件更新失败,Err:" + err.Error()

+ 1 - 0
models/request/report_pdf.go

@@ -12,6 +12,7 @@ type ReportPdfAddReq struct {
 
 type ReportPdfEditReq struct {
 	ReportPdfId      int    `description:"id"`
+	PdfName          string `description:"pdf文件名称"`
 	PdfUrl           string `description:"pdf文件URL"`
 	Title            string `description:"标题"`
 	Author           string `description:"作者"`