kobe6258 преди 8 месеца
родител
ревизия
69d3a63c87
променени са 11 файла, в които са добавени 1237 реда и са изтрити 619 реда
  1. 1 1
      controllers/audio.go
  2. 110 608
      controllers/image.go
  3. 749 0
      controllers/image_back.go
  4. 163 0
      controllers/message.go
  5. 2 0
      models/db.go
  6. 38 0
      models/image_sources.go
  7. 91 0
      models/report.go
  8. 7 0
      models/request/media.go
  9. 11 0
      models/response/report.go
  10. 54 9
      routers/commentsRouter.go
  11. 11 1
      routers/router.go

+ 1 - 1
controllers/audio.go

@@ -311,7 +311,7 @@ func (this *AudioController) DeleteAudio() {
 	err = models.DeleteMedia(audioDelete)
 	if err != nil {
 		br.Msg = "删除失败"
-		br.ErrMsg = "音频更新失败,Err:" + err.Error()
+		br.ErrMsg = "音频删除失败,Err:" + err.Error()
 		return
 	}
 	// 添加es

+ 110 - 608
controllers/image.go

@@ -6,15 +6,11 @@ import (
 	"eta/eta_mini_crm_ht/models/request"
 	"eta/eta_mini_crm_ht/models/response"
 	"eta/eta_mini_crm_ht/services"
-	"eta/eta_mini_crm_ht/services/elastic"
 	"eta/eta_mini_crm_ht/utils"
 	"fmt"
-	"github.com/rdlucklib/rdluck_tools/paging"
-
 	"os"
 	"path"
 	"strconv"
-	"strings"
 	"time"
 )
 
@@ -22,145 +18,17 @@ type ImageController struct {
 	BaseAuthController
 }
 
-// Author
-// @Title 获取报告作者接口
-// @Description 获取报告作者
-// @Success 200 {object} models.ReportAuthorResp
-// @router /author [get]
-func (this *ImageController) Author() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-
-	items, err := models.GetReportAuthorList()
-	if err != nil {
-		br.Msg = "获取失败!"
-		br.ErrMsg = "获取失败,Err:" + err.Error()
-		return
-	}
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "获取成功"
-	br.Data = items
-}
-
-// Add
-// @Title 添加研报
-// @Description 添加研报
-// @Param	request	body request.ReportPdfAddReq true "type json string"
-// @Success 200 {object} models.ReportAuthorResp
-// @router /add [post]
-func (this *ImageController) Add() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-
-	var req request.ReportPdfAddReq
-	if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
-		br.Msg = "参数解析失败"
-		br.ErrMsg = "参数解析失败,Err:" + err.Error()
-		return
-	}
-	if req.ClassifyIdFirst <= 0 && req.ClassifyIdSecond <= 0 && req.ClassifyIdThird <= 0 {
-		br.Msg = "请选择研报所属分类"
-		return
-	}
-	if req.PdfName == "" {
-		br.Msg = "pdf名称为空"
-		return
-	}
-	var nameFirst, nameSecond, nameThird *models.ClassifyView
-	var err error
-	if req.ClassifyIdFirst > 0 {
-		nameFirst, err = models.GetClassifyById(req.ClassifyIdFirst)
-		if err != nil {
-			br.Msg = "添加失败"
-			br.ErrMsg = "一级类名获取失败,Err:" + err.Error()
-			return
-		}
-	} else {
-		br.Msg = "该分类不存在或已删除,请刷新重试"
-		return
-	}
-	if req.ClassifyIdSecond > 0 {
-		nameSecond, err = models.GetClassifyById(req.ClassifyIdSecond)
-		if err != nil {
-			br.Msg = "添加失败"
-			br.ErrMsg = "二级类名获取失败,Err:" + err.Error()
-			return
-		}
-	}
-	if req.ClassifyIdThird > 0 {
-		nameThird, err = models.GetClassifyById(req.ClassifyIdThird)
-		if err != nil {
-			br.Msg = "添加失败"
-			br.ErrMsg = "三级类名获取失败,Err:" + err.Error()
-			return
-		}
-	}
-
-	pdf := &models.ReportPdf{
-		PdfUrl:            req.PdfUrl,
-		PdfName:           req.PdfName,
-		Title:             req.Title,
-		Author:            req.Author,
-		Abstract:          req.Abstract,
-		ClassifyIdFirst:   req.ClassifyIdFirst,
-		ClassifyNameFirst: nameFirst.ClassifyName,
-		PublishTime:       time.Now(),
-		ModifyTime:        time.Now(),
-		SysUserId:         this.SysUser.SysUserId,
-		SysRealName:       this.SysUser.SysRealName,
-		State:             utils.ReportStatusUp,
-	}
-	if nameSecond != nil {
-		pdf.ClassifyIdSecond = nameSecond.Id
-		pdf.ClassifyNameSecond = nameSecond.ClassifyName
-	}
-	if nameThird != nil {
-		pdf.ClassifyIdThird = nameThird.Id
-		pdf.ClassifyNameThird = nameThird.ClassifyName
-	}
-	insertId, err := pdf.Insert()
-	if err != nil {
-		br.Msg = "添加失败"
-		br.ErrMsg = "pdf研报新增失败,Err:" + err.Error()
-		return
-	}
-	pdf.ReportPdfId = int(insertId)
-	// 添加es
-	go func(reportPdf *models.ReportPdf) {
-		reportpdfView := reportPdf.ToView()
-		docId := strconv.Itoa(reportpdfView.ReportPdfId)
-		err = elastic.EsAddOrEditReportPdf(utils.MINI_REPORT_INDEX_NAME, docId, reportpdfView)
-		if err != nil {
-			utils.FileLog.Info("pdf研报es新增失败,Err:" + err.Error())
-			return
-		}
-		utils.FileLog.Info("pdf研报es新增成功, pdfId:" + docId)
-	}(pdf)
-
-	br.Msg = "添加成功"
-	br.Ret = 200
-	br.Success = true
-}
-
-// @Title 上传pdf研报
-// @Description 上传pdf研报
+// UploadImage @Title 上传图片
+// @Description 上传视频
 // @Param   File   query   file  true       "文件"
 // @Success 200 {object} models.ReportAuthorResp
-// @router /uploadPdf [post]
-func (this *ImageController) UploadPdf() {
+// @router /uploadImage [post]
+func (this *ImageController) UploadImage() {
 	br := new(models.BaseResponse).Init()
 	defer func() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-
 	f, h, err := this.GetFile("File")
 	if err != nil {
 		br.Msg = "获取资源信息失败"
@@ -168,22 +36,23 @@ func (this *ImageController) UploadPdf() {
 		return
 	}
 	defer f.Close()
-
-	ext := path.Ext(h.Filename)
-	if ext != ".pdf" {
-		br.Msg = "文件格式不正确"
-		return
-	}
-	size, err := strconv.Atoi(utils.UPLOAD_PDF_SIZE)
+	size, err := strconv.Atoi(utils.UPLOAD_IMG_SIZE)
 	if err != nil {
-		size = 15
+		size = 100
 	}
 	if h.Size > 1024*1024*int64(size) {
-		br.Msg = "文件大小不能超过15M"
+		br.Msg = fmt.Sprintf("图片大小不能超过%dK", size)
+		br.ErrMsg = "图片上传失败,Err:" + err.Error()
 		return
 	}
+	ext := path.Ext(h.Filename)
+	//if ext != ".mp3" {
+	//	br.Msg = "音频格式不正确"
+	//	br.ErrMsg = "音频上传失败,Err:" + err.Error()
+	//	return
+	//}
 	dateDir := time.Now().Format("20060102")
-	uploadDir := utils.STATIC_DIR + "dongwu/" + dateDir
+	uploadDir := utils.STATIC_DIR + "ht/audio" + dateDir
 	err = os.MkdirAll(uploadDir, utils.DIR_MOD)
 	if err != nil {
 		br.Msg = "存储目录创建失败"
@@ -195,555 +64,188 @@ func (this *ImageController) UploadPdf() {
 	fpath := uploadDir + "/" + fileName
 	err = this.SaveToFile("File", fpath)
 	if err != nil {
-		br.Msg = "文件上传失败"
-		br.ErrMsg = "文件上传失败,Err:" + err.Error()
+		br.Msg = "图片上传失败"
+		br.ErrMsg = "图片上传失败,Err:" + err.Error()
 		return
 	}
-	pdfUploadDir := utils.RESOURCE_DIR + "pdf/"
-	savePdfToOssPath := pdfUploadDir + time.Now().Format("200601/20060102/")
-	pptName := utils.GetRandStringNoSpecialChar(28)
-	savePdfToOssPath += pptName + ".pdf"
+	audioUploadDir := utils.RESOURCE_DIR + "img/"
+	savePdfToOssPath := audioUploadDir + time.Now().Format("200601/20060102/")
+	audioName := utils.GetRandStringNoSpecialChar(28)
+	savePdfToOssPath += audioName + ext
 
 	defer func() {
-		_ = os.Remove(fpath)
+		err = os.Remove(fpath)
+		fmt.Sprintf("删除文件失败:%v", err)
 	}()
-
 	ossClient := services.NewOssClient()
 	if ossClient == nil {
-		br.Msg = "文件上传失败"
+		br.Msg = "图片上传失败"
 		br.ErrMsg = "初始化OSS服务失败"
 		return
 	}
-	pdfUrl, err := ossClient.UploadFile("", fpath, savePdfToOssPath)
+	mp3Url, err := ossClient.UploadFile("", fpath, savePdfToOssPath)
 	if err != nil {
-		br.Msg = "文件上传失败"
-		br.ErrMsg = "文件上传失败,Err:" + err.Error()
+		br.Msg = "图片上传失败"
+		br.ErrMsg = "图片上传失败,Err:" + err.Error()
 		return
 	}
-
 	base := path.Base(h.Filename)
-	resp := new(response.ReportPdfUploadResp)
-	resp.Url = pdfUrl
+	resp := new(response.MediaUploadResp)
+	resp.Url = mp3Url
 	resp.FileName = base
-
 	br.Data = resp
 	br.Msg = "上传成功"
 	br.Ret = 200
 	br.Success = true
 }
 
-// List
-// @Title pdf研报列表
-// @Description pdf研报列表
-// @Param   PageSize   query   int  true       "每页数据条数"
-// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
-// @Param   ClassifyIds   query   string  true       "二级分类id,可多选用英文,隔开"
-// @Param   State   query   int  true       "研报状态, 1:已发布 2:未发布"
-// @Param   PublishStartDate   query   string  true       "发布开始时间"
-// @Param   PublishEndDate   query   string  true       "发布结束时间"
-// @Param   ModifyStartDate   query   string  true       "更新开始时间"
-// @Param   ModifyEndDate   query   string  true       "更新结束时间"
-// @Param   KeyWord   query   string  true       "报告标题/创建人"
-// @Param   SortParam   query   string  true       "排序字段"
-// @Param   SortType   query   string  true       "排序方式"
-// @Success 200 {object} models.ReportAuthorResp
-// @router /list [get]
-func (this *ImageController) List() {
+// AddImage @Title 新增图片
+// @Description 新增图片
+// @Param   File   query   file  true       "文件"
+// @router /addImage [post]
+func (this *ImageController) AddImage() {
 	br := new(models.BaseResponse).Init()
 	defer func() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
 
-	pageSize, _ := this.GetInt("PageSize")
-	currentIndex, _ := this.GetInt("CurrentIndex")
-	classifyIds := this.GetString("ClassifyIds")
-	state, _ := this.GetInt("State")
-	publishStartDate := this.GetString("PublishStartDate")
-	publishEndDate := this.GetString("PublishEndDate")
-	modifyStartDate := this.GetString("ModifyStartDate")
-	modifyEndDate := this.GetString("ModifyEndDate")
-	keyWord := this.GetString("KeyWord")
-	sortParam := this.GetString("SortParam")
-	sortType := this.GetString("SortType")
-
-	var condition string
-	var pars []interface{}
-
-	if pageSize <= 0 {
-		pageSize = utils.PageSize20
-	}
-	if currentIndex <= 0 {
-		currentIndex = 1
-	}
-	if classifyIds != "" {
-		classifyArr := strings.Split(classifyIds, ",")
-		condition += " AND classify_id_second in (" + utils.GetOrmReplaceHolder(len(classifyArr)) + ")"
-		pars = append(pars, classifyArr)
-	}
-
-	switch state {
-	case utils.ReportStatusUp:
-		condition += " AND state = ?"
-		pars = append(pars, state)
-	case utils.ReportStatusDown:
-		condition += " AND state = ?"
-		pars = append(pars, state)
-	}
-
-	if publishStartDate != "" && publishEndDate != "" {
-		condition += " AND publish_time >= ?"
-		publishStartTime, err := time.Parse(utils.FormatDate, publishStartDate)
-		if err != nil {
-			br.Msg = "日期格式有误"
-			br.ErrMsg = "日期格式有误,Err:" + err.Error()
-			return
-		}
-		publishStartDateStr := publishStartTime.Format(utils.FormatDateTime)
-		pars = append(pars, publishStartDateStr)
-
-		condition += " AND publish_time <= ?"
-		publishEndTime, err := time.Parse(utils.FormatDate, publishEndDate)
-		if err != nil {
-			br.Msg = "日期格式有误"
-			br.ErrMsg = "日期格式有误,Err:" + err.Error()
-			return
-		}
-		publishEndTime = publishEndTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
-		publishEndDateStr := publishEndTime.Format(utils.FormatDateTime)
-		pars = append(pars, publishEndDateStr)
-	}
-	if modifyStartDate != "" && modifyEndDate != "" {
-		condition += " AND modify_time >= ?"
-		modifyStartTime, err := time.Parse(utils.FormatDate, modifyStartDate)
-		if err != nil {
-			br.Msg = "日期格式有误"
-			br.ErrMsg = "日期格式有误,Err:" + err.Error()
-			return
-		}
-		modifyStartDateStr := modifyStartTime.Format(utils.FormatDateTime)
-		pars = append(pars, modifyStartDateStr)
-
-		condition += " AND modify_time <= ?"
-		modifyEndTime, err := time.Parse(utils.FormatDate, modifyEndDate)
-		if err != nil {
-			br.Msg = "日期格式有误"
-			br.ErrMsg = "日期格式有误,Err:" + err.Error()
-			return
-		}
-		modifyEndTime = modifyEndTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
-		modifyEndDateStr := modifyEndTime.Format(utils.FormatDateTime)
-		pars = append(pars, modifyEndDateStr)
-	}
-	if keyWord != "" {
-		condition += ` AND (title like ? OR sys_real_name like ?) `
-		pars = utils.GetLikeKeywordPars(pars, keyWord, 2)
-	}
-	var sortCondition string
-	if sortParam != "" && sortType != "" {
-		sortCondition = " ORDER BY "
-		var param, sort string
-		switch sortParam {
-		case "PublishTime":
-			param = "publish_time"
-		case "ModifyTime":
-			param = "modify_time"
-		}
-		switch sortType {
-		case "asc":
-			sort = " ASC "
-		case "desc":
-			sort = " DESC "
-		}
-		if param != "" && sort != "" {
-			sortCondition += param + " " + sort
-		} else {
-			sortCondition = ""
-		}
-	}
-	if sortCondition == "" {
-		sortCondition = ` ORDER BY modify_time DESC `
-	}
-
-	total, err := models.GetReportPdfCountByCondition(condition, pars)
-	if err != nil {
-		br.Msg = "获取研报列表失败"
-		br.ErrMsg = "获取研报列表统计失败,Err:" + err.Error()
+	var req request.ImageReq
+	if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
+		br.Msg = "参数解析失败"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
 
-	startSize := utils.StartIndex(currentIndex, pageSize)
-	reportList, err := models.GetReportPdfByCondition(condition, sortCondition, pars, startSize, pageSize)
-	if err != nil {
-		br.Msg = "获取研报列表失败"
-		br.ErrMsg = "获取研报列表失败,Err:" + err.Error()
+	if req.ImageName == "" {
+		br.Msg = "图片名称为空"
 		return
 	}
 
-	page := paging.GetPaging(currentIndex, pageSize, total)
-	resp := new(response.ReportPdfListResp)
-	resp.List = reportList
-	resp.Paging = page
-
-	br.Ret = 200
-	br.Success = true
-	br.Data = resp
-	br.Msg = "获取成功"
-}
-
-// Edit
-// @Title 编辑研报
-// @Description 编辑研报
-// @Param	request	body request.ReportPdfEditReq true "type json string"
-// @Success 200 {object} models.ReportAuthorResp
-// @router /edit [post]
-func (this *ImageController) Edit() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-
-	var req request.ReportPdfEditReq
-	if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
-		br.Msg = "参数错误"
-		br.ErrMsg = "参数错误,Err:" + err.Error()
-		return
-	}
-	if req.ClassifyIdFirst <= 0 {
-		br.Msg = "请选择研报所属的一级分类"
-		return
-	}
-	if req.ClassifyIdSecond <= 0 {
-		br.Msg = "请选择研报所属的二级分类"
-		return
-	}
-	if req.PdfUrl == "" {
-		br.Msg = "请上传研报文件"
-		return
-	}
-	if req.PdfName == "" {
-		br.Msg = "请填写研报名称"
-		return
-	}
-	reportPdf, err := models.GetReportPdfById(req.ReportPdfId)
-	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
-			br.Msg = "研报不存在或已删除,请刷新页面"
-			return
-		}
-		br.Msg = "获取研报失败"
-		br.ErrMsg = "获取研报失败,系统错误,Err:" + err.Error()
+	if req.SrcUrl == "" {
+		br.Msg = "音频地址为空"
 		return
 	}
 
-	nameFirst, err := models.GetClassifyById(req.ClassifyIdFirst)
-	if err != nil {
-		br.Msg = "文件编辑失败"
-		br.ErrMsg = "一级类名获取失败,Err:" + err.Error()
+	if req.PermissionId <= 0 {
+		br.Msg = "品种标签为空"
 		return
 	}
-	nameSecond, err := models.GetClassifyById(req.ClassifyIdSecond)
-	if err != nil {
-		br.Msg = "文件编辑失败"
-		br.ErrMsg = "二级类名获取失败,Err:" + err.Error()
-		return
-	}
-	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
-		reportPdf.ClassifyIdFirst = req.ClassifyIdFirst
-		reportPdf.ClassifyIdSecond = req.ClassifyIdSecond
-		reportPdf.ClassifyNameFirst = nameFirst.ClassifyName
-		reportPdf.ClassifyNameSecond = nameSecond.ClassifyName
-		reportPdf.Author = req.Author
-		reportPdf.Abstract = req.Abstract
-		reportPdf.PdfUrl = req.PdfUrl
-		reportPdf.ModifyTime = time.Now()
-		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()
-			return
-		}
-		// 编辑es
-		go func(reportPdf *models.ReportPdf) {
-			reportpdfView := reportPdf.ToView()
-			docId := strconv.Itoa(reportpdfView.ReportPdfId)
-			err = elastic.EsAddOrEditReportPdf(utils.MINI_REPORT_INDEX_NAME, docId, reportpdfView)
-			if err != nil {
-				utils.FileLog.Info("pdf研报es编辑失败,Err:" + err.Error())
-				return
-			}
-			utils.FileLog.Info("pdf研报es编辑成功, pdfId:" + docId)
-		}(reportPdf)
+	var err error
+	imageInsert := &models.ImageSource{
+		ImgName:      req.ImageName,
+		SrcUrl:       req.SrcUrl,
+		PermissionId: req.PermissionId,
+		Deleted:      0,
+		CreatedTime:  time.Now(),
 	}
-	br.Msg = "研报编辑成功"
-	br.Ret = 200
-	br.Success = true
-}
 
-// Publish
-// @Title 发布研报
-// @Description 发布研报
-// @Param   ReportPdfId   query   string  true       "pdf研报id"
-// @Success 200 {object} models.BaseResponse
-// @router /publish [get]
-func (this *ImageController) Publish() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-	ReportPdfId, _ := this.GetInt("ReportPdfId")
-	reportPdf, err := models.GetReportPdfById(ReportPdfId)
+	_, err = imageInsert.Insert()
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
-			br.Msg = "研报不存在或已删除,请刷新页面"
-			return
-		}
-		br.Msg = "获取研报失败"
-		br.ErrMsg = "获取研报失败,系统错误,Err:" + err.Error()
-		return
-	}
-	if reportPdf.State == utils.ReportStatusUp {
-		br.Msg = "研报已发布"
-		return
-	}
-	reportPdf.State = utils.ReportStatusUp
-	reportPdf.PublishTime = time.Now()
-	err = reportPdf.Update([]string{"state", "publish_time"})
-	if err != nil {
-		br.Msg = "发布研报失败"
-		br.ErrMsg = "发布研报失败,系统错误,Err:" + err.Error()
+		br.Msg = "添加失败"
+		br.ErrMsg = "图片新增失败,Err:" + err.Error()
 		return
 	}
-	// 修改es
-	go func(reportPdf *models.ReportPdf) {
-		reportpdfView := reportPdf.ToView()
-		docId := strconv.Itoa(reportpdfView.ReportPdfId)
-		err = elastic.EsAddOrEditReportPdf(utils.MINI_REPORT_INDEX_NAME, docId, reportpdfView)
-		if err != nil {
-			utils.FileLog.Info("pdf研报es发布失败,Err:" + err.Error())
-			return
-		}
-		utils.FileLog.Info("pdf研报es发布成功, pdfId:" + docId)
-	}(reportPdf)
-	br.Msg = "发布研报成功"
+	br.Msg = "添加成功"
 	br.Ret = 200
 	br.Success = true
 }
 
-// PublishCancel
-// @Title 取消发布研报
-// @Description 取消发布研报
-// @Param   ReportPdfId   query   string  true       "pdf研报id"
-// @Success 200 {object} models.BaseResponse
-// @router /publishCancel [get]
-func (this *ImageController) PublishCancel() {
+// EditImage
+//
+//	@Title 编辑音频
+//
+// @Description 编辑音频
+// @Success 200 {object} models.ReportAuthorResp
+// @router /editImage [post]
+func (this *ImageController) EditImage() {
 	br := new(models.BaseResponse).Init()
 	defer func() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	ReportPdfId, _ := this.GetInt("ReportPdfId")
-	reportPdf, err := models.GetReportPdfById(ReportPdfId)
-	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
-			br.Msg = "研报不存在或已删除,请刷新页面"
-			return
-		}
-		br.Msg = "获取研报失败"
-		br.ErrMsg = "获取研报失败,系统错误,Err:" + err.Error()
+
+	var req request.ImageReq
+	if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
+		br.Msg = "参数解析失败"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
-	if reportPdf.State == utils.ReportStatusDown {
-		br.Msg = "研报已撤销"
+	if req.ImageId <= 0 {
+		br.Msg = "图片ID为空"
 		return
 	}
-	reportPdf.State = utils.ReportStatusDown
-	err = reportPdf.Update([]string{"state"})
-	if err != nil {
-		br.Msg = "发布研报失败"
-		br.ErrMsg = "发布研报失败,系统错误,Err:" + err.Error()
+	if req.ImageName == "" {
+		br.Msg = "图片名称为空"
 		return
 	}
-	// 修改es
-	go func(reportPdf *models.ReportPdf) {
-		reportpdfView := reportPdf.ToView()
-		docId := strconv.Itoa(reportpdfView.ReportPdfId)
-		err = elastic.EsAddOrEditReportPdf(utils.MINI_REPORT_INDEX_NAME, docId, reportpdfView)
-		if err != nil {
-			utils.FileLog.Info("pdf研报es取消发布失败,Err:" + err.Error())
-			return
-		}
-		utils.FileLog.Info("pdf研报es取消发布成功, pdfId:" + docId)
-	}(reportPdf)
-	br.Msg = "撤销研报成功"
-	br.Ret = 200
-	br.Success = true
-}
-
-// delete
-// @Title 删除研报
-// @Description 删除研报
-// @Param   ReportPdfId   query   string  true       "pdf研报id"
-// @Success 200 {object} models.BaseResponse
-// @router /delete [get]
-func (this *ImageController) Delete() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-	ReportPdfId, _ := this.GetInt("ReportPdfId")
-	reportPdf, err := models.GetReportPdfById(ReportPdfId)
-	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
-			br.Msg = "研报不存在或已删除,请刷新页面"
-			return
-		}
-		br.Msg = "获取研报失败"
-		br.ErrMsg = "获取研报失败,系统错误,Err:" + err.Error()
+	if req.SrcUrl == "" {
+		br.Msg = "图片src为空"
 		return
 	}
-	if reportPdf.State == utils.ReportStatusUp {
-		br.Msg = "研报已发布,不可以删除"
+	if req.PermissionId <= 0 {
+		br.Msg = "品种标签为空"
 		return
 	}
+	var err error
 
-	reportPdf.State = utils.ReportStatusDown
-	err = reportPdf.Delete()
-	if err != nil {
-		br.Msg = "研报删除失败"
-		br.ErrMsg = "研报删除失败,系统错误,Err:" + err.Error()
-		return
+	imageUpdate := &models.ImageSource{
+		Id:           req.ImageId,
+		ImgName:      req.ImageName,
+		SrcUrl:       req.SrcUrl,
+		PermissionId: req.PermissionId,
+		Deleted:      0,
+		CreatedTime:  time.Now(),
 	}
-	// 删除es
-	go func(reportPdf *models.ReportPdf) {
-		reportpdfView := reportPdf.ToView()
-		docId := strconv.Itoa(reportpdfView.ReportPdfId)
-		err = elastic.EsDeleteData(utils.MINI_REPORT_INDEX_NAME, docId)
-		if err != nil {
-			utils.FileLog.Info("pdf研报es删除失败,Err:" + err.Error())
-			return
-		}
-		utils.FileLog.Info("pdf研报es删除成功, pdfId:" + docId)
-	}(reportPdf)
-	br.Msg = "删除研报成功"
-	br.Ret = 200
-	br.Success = true
-}
 
-// Detail
-// @Title 研报详情
-// @Description 研报详情
-// @Param   ReportPdfId   query   string  true       "pdf研报id"
-// @Success 200 {object} models.BaseResponse
-// @router /detail [get]
-func (this *ImageController) Detail() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-	ReportPdfId, _ := this.GetInt("ReportPdfId")
-	reportPdf, err := models.GetReportPdfById(ReportPdfId)
+	err = imageUpdate.Update()
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
-			br.Msg = "研报不存在或已删除,请刷新页面"
-			return
-		}
-		br.Msg = "获取研报失败"
-		br.ErrMsg = "获取研报失败,系统错误,Err:" + err.Error()
+		br.Msg = "更新失败"
+		br.ErrMsg = "图片更新失败,Err:" + err.Error()
 		return
 	}
-
-	br.Data = reportPdf
+	br.Msg = "编辑成功"
 	br.Ret = 200
 	br.Success = true
-	br.Msg = "获取研报成功"
 }
 
-const (
-	img     = "image"
-	video   = "video"
-	audio   = "audio"
-	img_ext = ".jpg|.jpeg|.png|.gif|.bmp|.webp"
-)
-
-// @Title 上传图片
-// @Description 上传图片
-// @Param   File   query   file  true       "文件"
+// DeleteImage
+// @Title 删除音频
+//
+// @Description 删除音频
 // @Success 200 {object} models.ReportAuthorResp
-// @router /uploadFile [post]
-func (this *ImageController) UploadImage() {
+// @router /deleteImage [post]
+func (this *ImageController) DeleteImage() {
 	br := new(models.BaseResponse).Init()
 	defer func() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	f, h, err := this.GetFile("File")
-	if err != nil {
-		br.Msg = "获取资源信息失败"
-		br.ErrMsg = "获取资源信息失败,Err:" + err.Error()
-		return
-	}
-	defer f.Close()
-	size, err := strconv.Atoi(utils.UPLOAD_IMG_SIZE)
-	if err != nil {
-		size = 15
-	}
-	if h.Size > 1024*int64(size) {
-		br.Msg = fmt.Sprintf("图片大小不能超过%dK", size)
-		return
-	}
-	dateDir := time.Now().Format("20060102")
-	uploadDir := utils.STATIC_DIR + "ht/" + dateDir
-	err = os.MkdirAll(uploadDir, utils.DIR_MOD)
-	if err != nil {
-		br.Msg = "存储目录创建失败"
-		br.ErrMsg = "存储目录创建失败,Err:" + err.Error()
+
+	var req request.ImageReq
+	if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
+		br.Msg = "参数解析失败"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
-	randStr := utils.GetRandStringNoSpecialChar(28)
-	fileName := randStr
-	fpath := uploadDir + "/" + fileName
-	err = this.SaveToFile("File", fpath)
-	if err != nil {
-		br.Msg = "图片上传失败"
-		br.ErrMsg = "图片上传失败,Err:" + err.Error()
+	if req.ImageId <= 0 {
+		br.Msg = "图片ID为空"
 		return
 	}
-	pdfUploadDir := utils.RESOURCE_DIR + "analyst/"
-	savePdfToOssPath := pdfUploadDir + time.Now().Format("200601/20060102/")
-	imgName := utils.GetRandStringNoSpecialChar(28)
-	savePdfToOssPath += imgName
-
-	defer func() {
-		_ = os.Remove(fpath)
-	}()
+	var err error
 
-	ossClient := services.NewOssClient()
-	if ossClient == nil {
-		br.Msg = "图片上传失败"
-		br.ErrMsg = "初始化OSS服务失败"
-		return
+	imageDelete := &models.ImageSource{
+		Id:      req.ImageId,
+		Deleted: 1,
 	}
-	imgUrl, err := ossClient.UploadFile("", fpath, savePdfToOssPath)
+
+	err = imageDelete.Delete()
 	if err != nil {
-		br.Msg = "图片上传失败"
-		br.ErrMsg = "图片上传失败,Err:" + err.Error()
+		br.Msg = "删除失败"
+		br.ErrMsg = "图片删除失败,Err:" + err.Error()
 		return
 	}
-
-	base := path.Base(h.Filename)
-	resp := new(response.MediaUploadResp)
-	resp.Url = imgUrl
-	resp.FileName = base
-
-	br.Data = resp
-	br.Msg = "上传成功"
+	br.Msg = "删除成功"
 	br.Ret = 200
 	br.Success = true
 }

+ 749 - 0
controllers/image_back.go

@@ -0,0 +1,749 @@
+package controllers
+
+import (
+	"encoding/json"
+	"eta/eta_mini_crm_ht/models"
+	"eta/eta_mini_crm_ht/models/request"
+	"eta/eta_mini_crm_ht/models/response"
+	"eta/eta_mini_crm_ht/services"
+	"eta/eta_mini_crm_ht/services/elastic"
+	"eta/eta_mini_crm_ht/utils"
+	"fmt"
+	"github.com/rdlucklib/rdluck_tools/paging"
+
+	"os"
+	"path"
+	"strconv"
+	"strings"
+	"time"
+)
+
+type ImagePDFController struct {
+	BaseAuthController
+}
+
+// Author
+// @Title 获取报告作者接口
+// @Description 获取报告作者
+// @Success 200 {object} models.ReportAuthorResp
+// @router /author [get]
+func (this *ImagePDFController) Author() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	items, err := models.GetReportAuthorList()
+	if err != nil {
+		br.Msg = "获取失败!"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = items
+}
+
+// Add
+// @Title 添加研报
+// @Description 添加研报
+// @Param	request	body request.ReportPdfAddReq true "type json string"
+// @Success 200 {object} models.ReportAuthorResp
+// @router /add [post]
+func (this *ImagePDFController) Add() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	var req request.ReportPdfAddReq
+	if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
+		br.Msg = "参数解析失败"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.ClassifyIdFirst <= 0 && req.ClassifyIdSecond <= 0 && req.ClassifyIdThird <= 0 {
+		br.Msg = "请选择研报所属分类"
+		return
+	}
+	if req.PdfName == "" {
+		br.Msg = "pdf名称为空"
+		return
+	}
+	var nameFirst, nameSecond, nameThird *models.ClassifyView
+	var err error
+	if req.ClassifyIdFirst > 0 {
+		nameFirst, err = models.GetClassifyById(req.ClassifyIdFirst)
+		if err != nil {
+			br.Msg = "添加失败"
+			br.ErrMsg = "一级类名获取失败,Err:" + err.Error()
+			return
+		}
+	} else {
+		br.Msg = "该分类不存在或已删除,请刷新重试"
+		return
+	}
+	if req.ClassifyIdSecond > 0 {
+		nameSecond, err = models.GetClassifyById(req.ClassifyIdSecond)
+		if err != nil {
+			br.Msg = "添加失败"
+			br.ErrMsg = "二级类名获取失败,Err:" + err.Error()
+			return
+		}
+	}
+	if req.ClassifyIdThird > 0 {
+		nameThird, err = models.GetClassifyById(req.ClassifyIdThird)
+		if err != nil {
+			br.Msg = "添加失败"
+			br.ErrMsg = "三级类名获取失败,Err:" + err.Error()
+			return
+		}
+	}
+
+	pdf := &models.ReportPdf{
+		PdfUrl:            req.PdfUrl,
+		PdfName:           req.PdfName,
+		Title:             req.Title,
+		Author:            req.Author,
+		Abstract:          req.Abstract,
+		ClassifyIdFirst:   req.ClassifyIdFirst,
+		ClassifyNameFirst: nameFirst.ClassifyName,
+		PublishTime:       time.Now(),
+		ModifyTime:        time.Now(),
+		SysUserId:         this.SysUser.SysUserId,
+		SysRealName:       this.SysUser.SysRealName,
+		State:             utils.ReportStatusUp,
+	}
+	if nameSecond != nil {
+		pdf.ClassifyIdSecond = nameSecond.Id
+		pdf.ClassifyNameSecond = nameSecond.ClassifyName
+	}
+	if nameThird != nil {
+		pdf.ClassifyIdThird = nameThird.Id
+		pdf.ClassifyNameThird = nameThird.ClassifyName
+	}
+	insertId, err := pdf.Insert()
+	if err != nil {
+		br.Msg = "添加失败"
+		br.ErrMsg = "pdf研报新增失败,Err:" + err.Error()
+		return
+	}
+	pdf.ReportPdfId = int(insertId)
+	// 添加es
+	go func(reportPdf *models.ReportPdf) {
+		reportpdfView := reportPdf.ToView()
+		docId := strconv.Itoa(reportpdfView.ReportPdfId)
+		err = elastic.EsAddOrEditReportPdf(utils.MINI_REPORT_INDEX_NAME, docId, reportpdfView)
+		if err != nil {
+			utils.FileLog.Info("pdf研报es新增失败,Err:" + err.Error())
+			return
+		}
+		utils.FileLog.Info("pdf研报es新增成功, pdfId:" + docId)
+	}(pdf)
+
+	br.Msg = "添加成功"
+	br.Ret = 200
+	br.Success = true
+}
+
+// @Title 上传pdf研报
+// @Description 上传pdf研报
+// @Param   File   query   file  true       "文件"
+// @Success 200 {object} models.ReportAuthorResp
+// @router /uploadPdf [post]
+func (this *ImagePDFController) UploadPdf() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	f, h, err := this.GetFile("File")
+	if err != nil {
+		br.Msg = "获取资源信息失败"
+		br.ErrMsg = "获取资源信息失败,Err:" + err.Error()
+		return
+	}
+	defer f.Close()
+
+	ext := path.Ext(h.Filename)
+	if ext != ".pdf" {
+		br.Msg = "文件格式不正确"
+		return
+	}
+	size, err := strconv.Atoi(utils.UPLOAD_PDF_SIZE)
+	if err != nil {
+		size = 15
+	}
+	if h.Size > 1024*1024*int64(size) {
+		br.Msg = "文件大小不能超过15M"
+		return
+	}
+	dateDir := time.Now().Format("20060102")
+	uploadDir := utils.STATIC_DIR + "dongwu/" + dateDir
+	err = os.MkdirAll(uploadDir, utils.DIR_MOD)
+	if err != nil {
+		br.Msg = "存储目录创建失败"
+		br.ErrMsg = "存储目录创建失败,Err:" + err.Error()
+		return
+	}
+	randStr := utils.GetRandStringNoSpecialChar(28)
+	fileName := randStr + ext
+	fpath := uploadDir + "/" + fileName
+	err = this.SaveToFile("File", fpath)
+	if err != nil {
+		br.Msg = "文件上传失败"
+		br.ErrMsg = "文件上传失败,Err:" + err.Error()
+		return
+	}
+	pdfUploadDir := utils.RESOURCE_DIR + "pdf/"
+	savePdfToOssPath := pdfUploadDir + time.Now().Format("200601/20060102/")
+	pptName := utils.GetRandStringNoSpecialChar(28)
+	savePdfToOssPath += pptName + ".pdf"
+
+	defer func() {
+		_ = os.Remove(fpath)
+	}()
+
+	ossClient := services.NewOssClient()
+	if ossClient == nil {
+		br.Msg = "文件上传失败"
+		br.ErrMsg = "初始化OSS服务失败"
+		return
+	}
+	pdfUrl, err := ossClient.UploadFile("", fpath, savePdfToOssPath)
+	if err != nil {
+		br.Msg = "文件上传失败"
+		br.ErrMsg = "文件上传失败,Err:" + err.Error()
+		return
+	}
+
+	base := path.Base(h.Filename)
+	resp := new(response.ReportPdfUploadResp)
+	resp.Url = pdfUrl
+	resp.FileName = base
+
+	br.Data = resp
+	br.Msg = "上传成功"
+	br.Ret = 200
+	br.Success = true
+}
+
+// List
+// @Title pdf研报列表
+// @Description pdf研报列表
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   ClassifyIds   query   string  true       "二级分类id,可多选用英文,隔开"
+// @Param   State   query   int  true       "研报状态, 1:已发布 2:未发布"
+// @Param   PublishStartDate   query   string  true       "发布开始时间"
+// @Param   PublishEndDate   query   string  true       "发布结束时间"
+// @Param   ModifyStartDate   query   string  true       "更新开始时间"
+// @Param   ModifyEndDate   query   string  true       "更新结束时间"
+// @Param   KeyWord   query   string  true       "报告标题/创建人"
+// @Param   SortParam   query   string  true       "排序字段"
+// @Param   SortType   query   string  true       "排序方式"
+// @Success 200 {object} models.ReportAuthorResp
+// @router /list [get]
+func (this *ImagePDFController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	classifyIds := this.GetString("ClassifyIds")
+	state, _ := this.GetInt("State")
+	publishStartDate := this.GetString("PublishStartDate")
+	publishEndDate := this.GetString("PublishEndDate")
+	modifyStartDate := this.GetString("ModifyStartDate")
+	modifyEndDate := this.GetString("ModifyEndDate")
+	keyWord := this.GetString("KeyWord")
+	sortParam := this.GetString("SortParam")
+	sortType := this.GetString("SortType")
+
+	var condition string
+	var pars []interface{}
+
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	if classifyIds != "" {
+		classifyArr := strings.Split(classifyIds, ",")
+		condition += " AND classify_id_second in (" + utils.GetOrmReplaceHolder(len(classifyArr)) + ")"
+		pars = append(pars, classifyArr)
+	}
+
+	switch state {
+	case utils.ReportStatusUp:
+		condition += " AND state = ?"
+		pars = append(pars, state)
+	case utils.ReportStatusDown:
+		condition += " AND state = ?"
+		pars = append(pars, state)
+	}
+
+	if publishStartDate != "" && publishEndDate != "" {
+		condition += " AND publish_time >= ?"
+		publishStartTime, err := time.Parse(utils.FormatDate, publishStartDate)
+		if err != nil {
+			br.Msg = "日期格式有误"
+			br.ErrMsg = "日期格式有误,Err:" + err.Error()
+			return
+		}
+		publishStartDateStr := publishStartTime.Format(utils.FormatDateTime)
+		pars = append(pars, publishStartDateStr)
+
+		condition += " AND publish_time <= ?"
+		publishEndTime, err := time.Parse(utils.FormatDate, publishEndDate)
+		if err != nil {
+			br.Msg = "日期格式有误"
+			br.ErrMsg = "日期格式有误,Err:" + err.Error()
+			return
+		}
+		publishEndTime = publishEndTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
+		publishEndDateStr := publishEndTime.Format(utils.FormatDateTime)
+		pars = append(pars, publishEndDateStr)
+	}
+	if modifyStartDate != "" && modifyEndDate != "" {
+		condition += " AND modify_time >= ?"
+		modifyStartTime, err := time.Parse(utils.FormatDate, modifyStartDate)
+		if err != nil {
+			br.Msg = "日期格式有误"
+			br.ErrMsg = "日期格式有误,Err:" + err.Error()
+			return
+		}
+		modifyStartDateStr := modifyStartTime.Format(utils.FormatDateTime)
+		pars = append(pars, modifyStartDateStr)
+
+		condition += " AND modify_time <= ?"
+		modifyEndTime, err := time.Parse(utils.FormatDate, modifyEndDate)
+		if err != nil {
+			br.Msg = "日期格式有误"
+			br.ErrMsg = "日期格式有误,Err:" + err.Error()
+			return
+		}
+		modifyEndTime = modifyEndTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
+		modifyEndDateStr := modifyEndTime.Format(utils.FormatDateTime)
+		pars = append(pars, modifyEndDateStr)
+	}
+	if keyWord != "" {
+		condition += ` AND (title like ? OR sys_real_name like ?) `
+		pars = utils.GetLikeKeywordPars(pars, keyWord, 2)
+	}
+	var sortCondition string
+	if sortParam != "" && sortType != "" {
+		sortCondition = " ORDER BY "
+		var param, sort string
+		switch sortParam {
+		case "PublishTime":
+			param = "publish_time"
+		case "ModifyTime":
+			param = "modify_time"
+		}
+		switch sortType {
+		case "asc":
+			sort = " ASC "
+		case "desc":
+			sort = " DESC "
+		}
+		if param != "" && sort != "" {
+			sortCondition += param + " " + sort
+		} else {
+			sortCondition = ""
+		}
+	}
+	if sortCondition == "" {
+		sortCondition = ` ORDER BY modify_time DESC `
+	}
+
+	total, err := models.GetReportPdfCountByCondition(condition, pars)
+	if err != nil {
+		br.Msg = "获取研报列表失败"
+		br.ErrMsg = "获取研报列表统计失败,Err:" + err.Error()
+		return
+	}
+
+	startSize := utils.StartIndex(currentIndex, pageSize)
+	reportList, err := models.GetReportPdfByCondition(condition, sortCondition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取研报列表失败"
+		br.ErrMsg = "获取研报列表失败,Err:" + err.Error()
+		return
+	}
+
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(response.ReportPdfListResp)
+	resp.List = reportList
+	resp.Paging = page
+
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+	br.Msg = "获取成功"
+}
+
+// Edit
+// @Title 编辑研报
+// @Description 编辑研报
+// @Param	request	body request.ReportPdfEditReq true "type json string"
+// @Success 200 {object} models.ReportAuthorResp
+// @router /edit [post]
+func (this *ImagePDFController) Edit() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	var req request.ReportPdfEditReq
+	if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误,Err:" + err.Error()
+		return
+	}
+	if req.ClassifyIdFirst <= 0 {
+		br.Msg = "请选择研报所属的一级分类"
+		return
+	}
+	if req.ClassifyIdSecond <= 0 {
+		br.Msg = "请选择研报所属的二级分类"
+		return
+	}
+	if req.PdfUrl == "" {
+		br.Msg = "请上传研报文件"
+		return
+	}
+	if req.PdfName == "" {
+		br.Msg = "请填写研报名称"
+		return
+	}
+	reportPdf, err := models.GetReportPdfById(req.ReportPdfId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			br.Msg = "研报不存在或已删除,请刷新页面"
+			return
+		}
+		br.Msg = "获取研报失败"
+		br.ErrMsg = "获取研报失败,系统错误,Err:" + err.Error()
+		return
+	}
+
+	nameFirst, err := models.GetClassifyById(req.ClassifyIdFirst)
+	if err != nil {
+		br.Msg = "文件编辑失败"
+		br.ErrMsg = "一级类名获取失败,Err:" + err.Error()
+		return
+	}
+	nameSecond, err := models.GetClassifyById(req.ClassifyIdSecond)
+	if err != nil {
+		br.Msg = "文件编辑失败"
+		br.ErrMsg = "二级类名获取失败,Err:" + err.Error()
+		return
+	}
+	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
+		reportPdf.ClassifyIdFirst = req.ClassifyIdFirst
+		reportPdf.ClassifyIdSecond = req.ClassifyIdSecond
+		reportPdf.ClassifyNameFirst = nameFirst.ClassifyName
+		reportPdf.ClassifyNameSecond = nameSecond.ClassifyName
+		reportPdf.Author = req.Author
+		reportPdf.Abstract = req.Abstract
+		reportPdf.PdfUrl = req.PdfUrl
+		reportPdf.ModifyTime = time.Now()
+		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()
+			return
+		}
+		// 编辑es
+		go func(reportPdf *models.ReportPdf) {
+			reportpdfView := reportPdf.ToView()
+			docId := strconv.Itoa(reportpdfView.ReportPdfId)
+			err = elastic.EsAddOrEditReportPdf(utils.MINI_REPORT_INDEX_NAME, docId, reportpdfView)
+			if err != nil {
+				utils.FileLog.Info("pdf研报es编辑失败,Err:" + err.Error())
+				return
+			}
+			utils.FileLog.Info("pdf研报es编辑成功, pdfId:" + docId)
+		}(reportPdf)
+	}
+	br.Msg = "研报编辑成功"
+	br.Ret = 200
+	br.Success = true
+}
+
+// Publish
+// @Title 发布研报
+// @Description 发布研报
+// @Param   ReportPdfId   query   string  true       "pdf研报id"
+// @Success 200 {object} models.BaseResponse
+// @router /publish [get]
+func (this *ImagePDFController) Publish() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	ReportPdfId, _ := this.GetInt("ReportPdfId")
+	reportPdf, err := models.GetReportPdfById(ReportPdfId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			br.Msg = "研报不存在或已删除,请刷新页面"
+			return
+		}
+		br.Msg = "获取研报失败"
+		br.ErrMsg = "获取研报失败,系统错误,Err:" + err.Error()
+		return
+	}
+	if reportPdf.State == utils.ReportStatusUp {
+		br.Msg = "研报已发布"
+		return
+	}
+	reportPdf.State = utils.ReportStatusUp
+	reportPdf.PublishTime = time.Now()
+	err = reportPdf.Update([]string{"state", "publish_time"})
+	if err != nil {
+		br.Msg = "发布研报失败"
+		br.ErrMsg = "发布研报失败,系统错误,Err:" + err.Error()
+		return
+	}
+	// 修改es
+	go func(reportPdf *models.ReportPdf) {
+		reportpdfView := reportPdf.ToView()
+		docId := strconv.Itoa(reportpdfView.ReportPdfId)
+		err = elastic.EsAddOrEditReportPdf(utils.MINI_REPORT_INDEX_NAME, docId, reportpdfView)
+		if err != nil {
+			utils.FileLog.Info("pdf研报es发布失败,Err:" + err.Error())
+			return
+		}
+		utils.FileLog.Info("pdf研报es发布成功, pdfId:" + docId)
+	}(reportPdf)
+	br.Msg = "发布研报成功"
+	br.Ret = 200
+	br.Success = true
+}
+
+// PublishCancel
+// @Title 取消发布研报
+// @Description 取消发布研报
+// @Param   ReportPdfId   query   string  true       "pdf研报id"
+// @Success 200 {object} models.BaseResponse
+// @router /publishCancel [get]
+func (this *ImagePDFController) PublishCancel() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	ReportPdfId, _ := this.GetInt("ReportPdfId")
+	reportPdf, err := models.GetReportPdfById(ReportPdfId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			br.Msg = "研报不存在或已删除,请刷新页面"
+			return
+		}
+		br.Msg = "获取研报失败"
+		br.ErrMsg = "获取研报失败,系统错误,Err:" + err.Error()
+		return
+	}
+	if reportPdf.State == utils.ReportStatusDown {
+		br.Msg = "研报已撤销"
+		return
+	}
+	reportPdf.State = utils.ReportStatusDown
+	err = reportPdf.Update([]string{"state"})
+	if err != nil {
+		br.Msg = "发布研报失败"
+		br.ErrMsg = "发布研报失败,系统错误,Err:" + err.Error()
+		return
+	}
+	// 修改es
+	go func(reportPdf *models.ReportPdf) {
+		reportpdfView := reportPdf.ToView()
+		docId := strconv.Itoa(reportpdfView.ReportPdfId)
+		err = elastic.EsAddOrEditReportPdf(utils.MINI_REPORT_INDEX_NAME, docId, reportpdfView)
+		if err != nil {
+			utils.FileLog.Info("pdf研报es取消发布失败,Err:" + err.Error())
+			return
+		}
+		utils.FileLog.Info("pdf研报es取消发布成功, pdfId:" + docId)
+	}(reportPdf)
+	br.Msg = "撤销研报成功"
+	br.Ret = 200
+	br.Success = true
+}
+
+// delete
+// @Title 删除研报
+// @Description 删除研报
+// @Param   ReportPdfId   query   string  true       "pdf研报id"
+// @Success 200 {object} models.BaseResponse
+// @router /delete [get]
+func (this *ImagePDFController) Delete() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	ReportPdfId, _ := this.GetInt("ReportPdfId")
+	reportPdf, err := models.GetReportPdfById(ReportPdfId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			br.Msg = "研报不存在或已删除,请刷新页面"
+			return
+		}
+		br.Msg = "获取研报失败"
+		br.ErrMsg = "获取研报失败,系统错误,Err:" + err.Error()
+		return
+	}
+	if reportPdf.State == utils.ReportStatusUp {
+		br.Msg = "研报已发布,不可以删除"
+		return
+	}
+
+	reportPdf.State = utils.ReportStatusDown
+	err = reportPdf.Delete()
+	if err != nil {
+		br.Msg = "研报删除失败"
+		br.ErrMsg = "研报删除失败,系统错误,Err:" + err.Error()
+		return
+	}
+	// 删除es
+	go func(reportPdf *models.ReportPdf) {
+		reportpdfView := reportPdf.ToView()
+		docId := strconv.Itoa(reportpdfView.ReportPdfId)
+		err = elastic.EsDeleteData(utils.MINI_REPORT_INDEX_NAME, docId)
+		if err != nil {
+			utils.FileLog.Info("pdf研报es删除失败,Err:" + err.Error())
+			return
+		}
+		utils.FileLog.Info("pdf研报es删除成功, pdfId:" + docId)
+	}(reportPdf)
+	br.Msg = "删除研报成功"
+	br.Ret = 200
+	br.Success = true
+}
+
+// Detail
+// @Title 研报详情
+// @Description 研报详情
+// @Param   ReportPdfId   query   string  true       "pdf研报id"
+// @Success 200 {object} models.BaseResponse
+// @router /detail [get]
+func (this *ImagePDFController) Detail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	ReportPdfId, _ := this.GetInt("ReportPdfId")
+	reportPdf, err := models.GetReportPdfById(ReportPdfId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			br.Msg = "研报不存在或已删除,请刷新页面"
+			return
+		}
+		br.Msg = "获取研报失败"
+		br.ErrMsg = "获取研报失败,系统错误,Err:" + err.Error()
+		return
+	}
+
+	br.Data = reportPdf
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取研报成功"
+}
+
+const (
+	img     = "image"
+	video   = "video"
+	audio   = "audio"
+	img_ext = ".jpg|.jpeg|.png|.gif|.bmp|.webp"
+)
+
+// @Title 上传图片
+// @Description 上传图片
+// @Param   File   query   file  true       "文件"
+// @Success 200 {object} models.ReportAuthorResp
+// @router /uploadFile [post]
+func (this *ImagePDFController) UploadImage() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	f, h, err := this.GetFile("File")
+	if err != nil {
+		br.Msg = "获取资源信息失败"
+		br.ErrMsg = "获取资源信息失败,Err:" + err.Error()
+		return
+	}
+	defer f.Close()
+	size, err := strconv.Atoi(utils.UPLOAD_IMG_SIZE)
+	if err != nil {
+		size = 15
+	}
+	if h.Size > 1024*int64(size) {
+		br.Msg = fmt.Sprintf("图片大小不能超过%dK", size)
+		return
+	}
+	dateDir := time.Now().Format("20060102")
+	uploadDir := utils.STATIC_DIR + "ht/" + dateDir
+	err = os.MkdirAll(uploadDir, utils.DIR_MOD)
+	if err != nil {
+		br.Msg = "存储目录创建失败"
+		br.ErrMsg = "存储目录创建失败,Err:" + err.Error()
+		return
+	}
+	randStr := utils.GetRandStringNoSpecialChar(28)
+	fileName := randStr
+	fpath := uploadDir + "/" + fileName
+	err = this.SaveToFile("File", fpath)
+	if err != nil {
+		br.Msg = "图片上传失败"
+		br.ErrMsg = "图片上传失败,Err:" + err.Error()
+		return
+	}
+	pdfUploadDir := utils.RESOURCE_DIR + "analyst/"
+	savePdfToOssPath := pdfUploadDir + time.Now().Format("200601/20060102/")
+	imgName := utils.GetRandStringNoSpecialChar(28)
+	savePdfToOssPath += imgName
+
+	defer func() {
+		_ = os.Remove(fpath)
+	}()
+
+	ossClient := services.NewOssClient()
+	if ossClient == nil {
+		br.Msg = "图片上传失败"
+		br.ErrMsg = "初始化OSS服务失败"
+		return
+	}
+	imgUrl, err := ossClient.UploadFile("", fpath, savePdfToOssPath)
+	if err != nil {
+		br.Msg = "图片上传失败"
+		br.ErrMsg = "图片上传失败,Err:" + err.Error()
+		return
+	}
+
+	base := path.Base(h.Filename)
+	resp := new(response.MediaUploadResp)
+	resp.Url = imgUrl
+	resp.FileName = base
+
+	br.Data = resp
+	br.Msg = "上传成功"
+	br.Ret = 200
+	br.Success = true
+}

+ 163 - 0
controllers/message.go

@@ -0,0 +1,163 @@
+package controllers
+
+import (
+	"eta/eta_mini_crm_ht/models"
+	"eta/eta_mini_crm_ht/models/response"
+	"eta/eta_mini_crm_ht/utils"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"strings"
+)
+
+type MessageController struct {
+	BaseAuthController
+}
+
+// ReportList
+// @Title 研报列表
+// @Description pdf研报列表
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   ClassifyIds   query   string  true       "二级分类id,可多选用英文,隔开"
+// @Param   KeyWord   query   string  true       "报告标题/创建人"
+// @Param   SortType   query   string  true       "排序方式"
+// @Success 200 {object} models.ReportAuthorResp
+// @router /reportList [get]
+func (this *MessageController) ReportList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	permissionIds := this.GetString("PermissionIds")
+	analystNames := this.GetString("AnalystNames")
+	sortType := this.GetString("SortType")
+	var condition string
+	var pars []interface{}
+
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	if permissionIds != "" {
+		permissionArr := strings.Split(permissionIds, ",")
+		condition += " AND permission_id in (" + utils.GetOrmReplaceHolder(len(permissionArr)) + ")"
+		pars = append(pars, permissionArr)
+	}
+	if analystNames != "" {
+		analystNameArr := strings.Split(analystNames, ",")
+		condition += " AND author in (" + utils.GetOrmReplaceHolder(len(analystNameArr)) + ")"
+		pars = append(pars, analystNameArr)
+	}
+	sortCondition := " ORDER BY published_time "
+	if sortType == "" {
+		sortType = "DESC"
+	}
+	sortCondition = sortCondition + sortType
+	total, err := models.GetReportCountByCondition(condition, pars)
+	if err != nil {
+		br.Msg = "获取研报列表失败"
+		br.ErrMsg = "获取研报列表统计失败,Err:" + err.Error()
+		return
+	}
+
+	startSize := utils.StartIndex(currentIndex, pageSize)
+	reportList, err := models.GetReportByCondition(condition, sortCondition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取研报列表失败"
+		br.ErrMsg = "获取研报列表失败,Err:" + err.Error()
+		return
+	}
+	var reportViewList []*models.ReportView
+	for _, report := range reportList {
+		reportView := report.ToView()
+		reportViewList = append(reportViewList, reportView)
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(response.ReportListResp)
+	resp.List = reportViewList
+	resp.Paging = page
+
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+	br.Msg = "获取成功"
+}
+
+// AudioList
+// @Title 研报列表
+// @Description pdf研报列表
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   ClassifyIds   query   string  true       "二级分类id,可多选用英文,隔开"
+// @Param   KeyWord   query   string  true       "报告标题/创建人"
+// @Param   SortType   query   string  true       "排序方式"
+// @Success 200 {object} models.ReportAuthorResp
+// @router /audioList [get]
+func (this *MessageController) AudioList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	permissionIds := this.GetString("PermissionIds")
+	analystNames := this.GetString("AnalystNames")
+	sortType := this.GetString("SortType")
+	var condition string
+	var pars []interface{}
+
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	if permissionIds != "" {
+		permissionArr := strings.Split(permissionIds, ",")
+		condition += " AND permission_id in (" + utils.GetOrmReplaceHolder(len(permissionArr)) + ")"
+		pars = append(pars, permissionArr)
+	}
+	if analystNames != "" {
+		analystNameArr := strings.Split(analystNames, ",")
+		condition += " AND author in (" + utils.GetOrmReplaceHolder(len(analystNameArr)) + ")"
+		pars = append(pars, analystNameArr)
+	}
+	sortCondition := " ORDER BY published_time "
+	if sortType == "" {
+		sortType = "DESC"
+	}
+	sortCondition = sortCondition + sortType
+	total, err := models.GetReportCountByCondition(condition, pars)
+	if err != nil {
+		br.Msg = "获取研报列表失败"
+		br.ErrMsg = "获取研报列表统计失败,Err:" + err.Error()
+		return
+	}
+
+	startSize := utils.StartIndex(currentIndex, pageSize)
+	reportList, err := models.GetReportByCondition(condition, sortCondition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取研报列表失败"
+		br.ErrMsg = "获取研报列表失败,Err:" + err.Error()
+		return
+	}
+	var reportViewList []*models.ReportView
+	for _, report := range reportList {
+		reportView := report.ToView()
+		reportViewList = append(reportViewList, reportView)
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(response.ReportListResp)
+	resp.List = reportViewList
+	resp.Paging = page
+
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+	br.Msg = "获取成功"
+}

+ 2 - 0
models/db.go

@@ -46,5 +46,7 @@ func init() {
 		new(MetaInfo),
 		new(FeedBack),
 		new(MediaPermissionMapping),
+		new(ImageSource),
+		new(Report),
 	)
 }

+ 38 - 0
models/image_sources.go

@@ -0,0 +1,38 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+func (i *ImageSource) TableName() string {
+	return "image_sources"
+}
+
+type ImageSource struct {
+	Id           int       ` description:"Id"`
+	ImgName      string    `description:"图片名称"`
+	SrcUrl       string    `description:"图片资源"`
+	PermissionId int       `description:"品种"`
+	Deleted      int       `description:"是否删除"`
+	CreatedTime  time.Time `description:"创建时间"`
+	UpdatedTime  time.Time `description:"更新时间"`
+}
+
+func (i *ImageSource) Insert() (insertId int64, err error) {
+	o := orm.NewOrm()
+	insertId, err = o.Insert(i)
+	return
+}
+
+func (i *ImageSource) Update() (err error) {
+	o := orm.NewOrm()
+	_, err = o.Update(i, "img_name", "src_url", "permission_id")
+	return
+}
+
+func (i *ImageSource) Delete() (err error) {
+	o := orm.NewOrm()
+	_, err = o.Update(i, "deleted")
+	return
+}

+ 91 - 0
models/report.go

@@ -0,0 +1,91 @@
+package models
+
+import (
+	"time"
+
+	"github.com/beego/beego/v2/client/orm"
+)
+
+type ReportStatus string
+type ReportSource string
+
+const (
+	SourceETA     ReportSource = "ETA"
+	SourceHT      ReportSource = "HT"
+	StatusInit    ReportStatus = "INIT"
+	StatusPending ReportStatus = "PENDING"
+	StatusDone    ReportStatus = "DONE"
+	MaxBatchNum                = 1000
+	CommonColumns              = "id,org_id,author,abstract,title,source,cover_src,published_time"
+	taskColumns                = "id,author,published_time"
+)
+
+type Report struct {
+	ID            int
+	OrgID         int
+	Source        ReportSource
+	Title         string
+	Abstract      string
+	Author        string
+	CoverSrc      string
+	Status        ReportStatus
+	SendStatus    SendStatus
+	PublishedTime string
+	CreatedTime   time.Time
+	UpdatedTime   time.Time
+}
+
+type ReportView struct {
+	ID            int
+	OrgID         int
+	Source        ReportSource
+	Title         string
+	Abstract      string
+	Author        string
+	CoverSrc      string
+	SendStatus    SendStatus
+	PublishedTime string
+}
+
+func (r *Report) ToView() (item *ReportView) {
+	item = &ReportView{
+		ID:            r.ID,
+		OrgID:         r.OrgID,
+		Source:        r.Source,
+		Title:         r.Title,
+		Abstract:      r.Abstract,
+		Author:        r.Author,
+		CoverSrc:      r.CoverSrc,
+		SendStatus:    r.SendStatus,
+		PublishedTime: r.PublishedTime,
+	}
+	return
+
+}
+
+func (r *Report) tableName() string {
+	return "reports"
+}
+func GetReportCountByCondition(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(*) AS count FROM reports WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	err = o.Raw(sql, pars).QueryRow(&count)
+	return
+}
+
+func GetReportByCondition(condition, sortCondition string, pars []interface{}, startPage, pageSize int) (items []*Report, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM reports WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	if sortCondition != "" {
+		sql += sortCondition // 排序
+	}
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startPage, pageSize).QueryRows(&items)
+	return
+}

+ 7 - 0
models/request/media.go

@@ -9,3 +9,10 @@ type AudioReq struct {
 	PermissionIds       string
 	DurationMillisecond int
 }
+
+type ImageReq struct {
+	ImageId      int
+	ImageName    string
+	SrcUrl       string
+	PermissionId int
+}

+ 11 - 0
models/response/report.go

@@ -0,0 +1,11 @@
+package response
+
+import (
+	"eta/eta_mini_crm_ht/models"
+	"github.com/rdlucklib/rdluck_tools/paging"
+)
+
+type ReportListResp struct {
+	List   []*models.ReportView
+	Paging *paging.PagingItem `description:"分页数据"`
+}

+ 54 - 9
routers/commentsRouter.go

@@ -109,6 +109,42 @@ func init() {
             Params: nil})
 
     beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"],
+        beego.ControllerComments{
+            Method: "AddImage",
+            Router: `/addImage`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"],
+        beego.ControllerComments{
+            Method: "DeleteImage",
+            Router: `/deleteImage`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"],
+        beego.ControllerComments{
+            Method: "EditImage",
+            Router: `/editImage`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"],
+        beego.ControllerComments{
+            Method: "UploadImage",
+            Router: `/uploadImage`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"],
         beego.ControllerComments{
             Method: "Add",
             Router: `/add`,
@@ -117,7 +153,7 @@ func init() {
             Filters: nil,
             Params: nil})
 
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"],
+    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"],
         beego.ControllerComments{
             Method: "Author",
             Router: `/author`,
@@ -126,7 +162,7 @@ func init() {
             Filters: nil,
             Params: nil})
 
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"],
+    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"],
         beego.ControllerComments{
             Method: "Delete",
             Router: `/delete`,
@@ -135,7 +171,7 @@ func init() {
             Filters: nil,
             Params: nil})
 
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"],
+    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"],
         beego.ControllerComments{
             Method: "Detail",
             Router: `/detail`,
@@ -144,7 +180,7 @@ func init() {
             Filters: nil,
             Params: nil})
 
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"],
+    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"],
         beego.ControllerComments{
             Method: "Edit",
             Router: `/edit`,
@@ -153,7 +189,7 @@ func init() {
             Filters: nil,
             Params: nil})
 
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"],
+    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"],
         beego.ControllerComments{
             Method: "List",
             Router: `/list`,
@@ -162,7 +198,7 @@ func init() {
             Filters: nil,
             Params: nil})
 
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"],
+    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"],
         beego.ControllerComments{
             Method: "Publish",
             Router: `/publish`,
@@ -171,7 +207,7 @@ func init() {
             Filters: nil,
             Params: nil})
 
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"],
+    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"],
         beego.ControllerComments{
             Method: "PublishCancel",
             Router: `/publishCancel`,
@@ -180,7 +216,7 @@ func init() {
             Filters: nil,
             Params: nil})
 
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"],
+    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"],
         beego.ControllerComments{
             Method: "UploadImage",
             Router: `/uploadFile`,
@@ -189,7 +225,7 @@ func init() {
             Filters: nil,
             Params: nil})
 
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImageController"],
+    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:ImagePDFController"],
         beego.ControllerComments{
             Method: "UploadPdf",
             Router: `/uploadPdf`,
@@ -198,6 +234,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:MessageController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:MessageController"],
+        beego.ControllerComments{
+            Method: "ReportList",
+            Router: `/reportList`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:SysDepartmentController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:SysDepartmentController"],
         beego.ControllerComments{
             Method: "Add",

+ 11 - 1
routers/router.go

@@ -69,11 +69,21 @@ func init() {
 		),
 		beego.NSNamespace("/media",
 			beego.NSInclude(
-				&controllers.ImageController{},
+				//&controllers.ImagePDFController{},
 				&controllers.AudioController{},
 				&controllers.VideoController{},
 			),
 		),
+		beego.NSNamespace("/source",
+			beego.NSInclude(
+				&controllers.ImageController{},
+			),
+		),
+		beego.NSNamespace("/message",
+			beego.NSInclude(
+				&controllers.MessageController{},
+			),
+		),
 	)
 	beego.AddNamespace(ns)
 }