Browse Source

test 智能研报

hsun 1 year ago
parent
commit
128a57b746

+ 24 - 15
controllers/smart_report/smart_report.go

@@ -321,7 +321,7 @@ func (this *SmartReportController) Detail() {
 // @Description 发布/取消发布
 // @Param	request	body smart_report.SmartReportPublishReq true "type json string"
 // @Success 200 string "操作成功"
-// @router /edit [post]
+// @router /publish [post]
 func (this *SmartReportController) Publish() {
 	br := new(models.BaseResponse).Init()
 	defer func() {
@@ -370,6 +370,10 @@ func (this *SmartReportController) Publish() {
 	cols := []string{"State", "ModifyTime"}
 	item.State = req.PublishState
 	item.ModifyTime = time.Now().Local()
+	if req.PublishState == 2 {
+		cols = append(cols, "PublishTime")
+		item.PublishTime = time.Now().Local()
+	}
 	// 取消发布时同时清除掉Img和PDF的文件地址
 	if req.PublishState == 1 {
 		cols = append(cols, "DetailImgUrl", "DetailPdfUrl")
@@ -436,11 +440,11 @@ func (this *SmartReportController) PrePublish() {
 		br.Msg = "发布时间不能为空"
 		return
 	}
-	//if req.PreMsgSend != 0 && req.PreMsgSend != 1 {
-	//	br.Msg = "参数错误"
-	//	br.ErrMsg = "是否发送模版消息标识错误"
-	//	return
-	//}
+	if req.PreMsgSend != 0 && req.PreMsgSend != 1 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "是否发送模版消息标识错误"
+		return
+	}
 	preTime, e := time.ParseInLocation(utils.FormatDateTime, req.PrePublishTime, time.Local)
 	if e != nil {
 		br.Msg = "发布时间格式错误"
@@ -553,10 +557,15 @@ func (this *SmartReportController) SendMsg() {
 		br.Msg = "消息已推送,请勿重复操作"
 		return
 	}
+	if item.State != 2 {
+		br.Msg = "报告未发布, 不可推送"
+		return
+	}
 
 	item.MsgIsSend = 1
+	item.MsgSendTime = time.Now().Local()
 	item.ModifyTime = time.Now().Local()
-	if e = item.Update([]string{"MsgIsSend", "ModifyTime"}); e != nil {
+	if e = item.Update([]string{"MsgIsSend", "MsgSendTime", "ModifyTime"}); e != nil {
 		br.Msg = "操作失败"
 		br.ErrMsg = "更新报告推送状态失败, Err: " + e.Error()
 		return
@@ -689,7 +698,7 @@ func (this *SmartReportController) SaveContent() {
 // @Description 标记报告编辑状态接口
 // @Param	request	body request.MarkEditEnReport true "type json string"
 // @Success 200 标记成功 ;202 标记成功
-// @router /mark [post]
+// @router /mark_edit [post]
 func (this *SmartReportController) MarkEditStatus() {
 	br := new(models.BaseResponse).Init()
 	defer func() {
@@ -706,14 +715,14 @@ func (this *SmartReportController) MarkEditStatus() {
 		br.Ret = 408
 		return
 	}
-	var req models.MarkEditReport
+	var req smart_report.SmartReportMarkEditReq
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
 	if err != nil {
 		br.Msg = "参数解析异常!"
 		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
-	if req.ReportId <= 0 {
+	if req.SmartReportId <= 0 {
 		br.Msg = "缺少报告Id"
 		return
 	}
@@ -734,7 +743,7 @@ func (this *SmartReportController) MarkEditStatus() {
 		adminIdName[ad.AdminId] = ad.RealName
 	}
 
-	data, e := smartReportService.UpdateSmartReportEditing(req.ReportId, req.Status, sysUser.AdminId, sysUser.RealName, adminIdName)
+	data, e := smartReportService.UpdateSmartReportEditing(req.SmartReportId, req.Status, sysUser.AdminId, sysUser.RealName, adminIdName)
 	if e != nil {
 		br.Msg = e.Error()
 		return
@@ -790,7 +799,7 @@ func (this *SmartReportController) List() {
 		Keyword          string `form:"Keyword"`
 	}
 	params := new(SmartReportListReq)
-	if e := this.ParseForm(&params); e != nil {
+	if e := this.ParseForm(params); e != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "入参解析失败, Err: " + e.Error()
 		return
@@ -865,9 +874,9 @@ func (this *SmartReportController) List() {
 
 	// 列表查询过滤掉富文本内容
 	fields := []string{
-		"SmartReportId", "ReportCode", "ClassifyIdFirst", "ClassifyNameFirst", "ClassifyIdSecond", "ClassifyNameSecond", "AddType",
-		"Title", "Author", "Frequency", "Stage", "VideoUrl", "VideoName", "VideoPlaySeconds", "VideoSize", "AdminId", "AdminRealName", "State",
-		"PublishTime", "PrePublishTime", "PreMsgSend", "MsgIsSend", "MsgSendTime", "CreateTime", "ModifyTime",
+		"smart_report_id", "report_code", "classify_id_first", "classify_name_first", "classify_id_second", "classify_name_second", "add_type",
+		"title", "author", "frequency", "stage", "video_url", "video_name", "video_play_seconds", "video_size", "detail_img_url", "detail_pdf_url",
+		"admin_id", "admin_real_name", "state", "publish_time", "pre_publish_time", "pre_msg_send", "msg_is_send", "msg_send_time", "create_time", "modify_time",
 	}
 	list, e := reportOB.GetPageItemsByCondition(condition, pars, fields, "", startSize, params.PageSize)
 	if e != nil {

+ 13 - 0
models/db.go

@@ -9,6 +9,7 @@ import (
 	"eta/eta_api/models/ppt_english"
 	"eta/eta_api/models/sandbox"
 	"eta/eta_api/models/semantic_analysis"
+	"eta/eta_api/models/smart_report"
 	"eta/eta_api/models/system"
 	"eta/eta_api/models/yb"
 	"eta/eta_api/utils"
@@ -136,6 +137,10 @@ func init() {
 
 	// 外部链接
 	initOutLink()
+
+	// 智能研报
+	initSmartReport()
+
 	// ETA试用相关表
 	if utils.BusinessCode == utils.BusinessCodeSandbox {
 		initEtaTrial()
@@ -414,3 +419,11 @@ func initEtaTrial() {
 		new(eta_trial.QuestionnaireFillRecord), // 问卷填写记录表
 	)
 }
+
+// initSmartReport 智能研报相关表
+func initSmartReport() {
+	orm.RegisterModel(
+		new(smart_report.SmartReport),        // 智能研报主表
+		new(smart_report.SmartReportSaveLog), // 智能研报-保存记录表
+	)
+}

+ 9 - 2
models/smart_report/smart_report.go

@@ -17,7 +17,7 @@ const (
 
 // SmartReport 智能研报
 type SmartReport struct {
-	SmartReportId      int       `orm:"column(smart_report_id)" description:"智能研报ID"`
+	SmartReportId      int       `orm:"column(smart_report_id);pk" description:"智能研报ID"`
 	ReportCode         string    `description:"报告唯一编码"`
 	ClassifyIdFirst    int       `description:"一级分类ID"`
 	ClassifyNameFirst  string    `description:"一级分类名称"`
@@ -199,6 +199,7 @@ func FormatSmartReport2Item(origin *SmartReport) (item *SmartReportItem) {
 		return
 	}
 	item.SmartReportId = origin.SmartReportId
+	item.ReportCode = origin.ReportCode
 	item.ClassifyIdFirst = origin.ClassifyIdFirst
 	item.ClassifyNameFirst = origin.ClassifyNameFirst
 	item.ClassifyIdSecond = origin.ClassifyIdSecond
@@ -269,9 +270,9 @@ type SmartReportPrePublishReq struct {
 
 // SmartReportSaveContentReq 保存草稿请求体
 type SmartReportSaveContentReq struct {
+	SmartReportId int    `description:"智能研报ID"`
 	Content       string `description:"内容"`
 	ContentStruct string `description:"内容结构"`
-	SmartReportId int    `description:"智能研报ID"`
 	NoChange      int    `description:"内容是否未改变:1:内容未改变"`
 }
 
@@ -285,6 +286,12 @@ type SmartReportSendMsgReq struct {
 	SmartReportId int `description:"智能研报ID"`
 }
 
+// SmartReportMarkEditReq 标记编辑英文研报的请求数据
+type SmartReportMarkEditReq struct {
+	SmartReportId int `description:"智能研报ID"`
+	Status        int `description:"标记状态: 1-编辑中; 2-编辑完成"`
+}
+
 // SmartReportListResp 智能研报
 type SmartReportListResp struct {
 	List   []*SmartReportItem

+ 1 - 1
models/smart_report/smart_report_save_log.go

@@ -10,7 +10,7 @@ import (
 
 // SmartReportSaveLog 智能研报保存记录
 type SmartReportSaveLog struct {
-	Id            int       `orm:"column(id)" description:"智能研报ID"`
+	Id            int       `orm:"column(id);pk"`
 	SmartReportId int       `description:"智能研报ID"`
 	Content       string    `description:"内容"`
 	ContentSub    string    `description:"内容前两个章节"`

+ 10 - 10
routers/commentsRouter.go

@@ -4471,15 +4471,6 @@ func init() {
             Filters: nil,
             Params: nil})
 
-    beego.GlobalControllerRouter["eta/eta_api/controllers/smart_report:SmartReportController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/smart_report:SmartReportController"],
-        beego.ControllerComments{
-            Method: "Publish",
-            Router: `/edit`,
-            AllowHTTPMethods: []string{"post"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
     beego.GlobalControllerRouter["eta/eta_api/controllers/smart_report:SmartReportController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/smart_report:SmartReportController"],
         beego.ControllerComments{
             Method: "LastPublishedReport",
@@ -4501,7 +4492,7 @@ func init() {
     beego.GlobalControllerRouter["eta/eta_api/controllers/smart_report:SmartReportController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/smart_report:SmartReportController"],
         beego.ControllerComments{
             Method: "MarkEditStatus",
-            Router: `/mark`,
+            Router: `/mark_edit`,
             AllowHTTPMethods: []string{"post"},
             MethodParams: param.Make(),
             Filters: nil,
@@ -4516,6 +4507,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_api/controllers/smart_report:SmartReportController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/smart_report:SmartReportController"],
+        beego.ControllerComments{
+            Method: "Publish",
+            Router: `/publish`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_api/controllers/smart_report:SmartReportController"] = append(beego.GlobalControllerRouter["eta/eta_api/controllers/smart_report:SmartReportController"],
         beego.ControllerComments{
             Method: "Remove",