Kaynağa Gözat

给振凯出一个报告变更通知的插入点接口

xingzai 2 yıl önce
ebeveyn
işleme
f9d53fc27a

+ 45 - 0
controllers/report.go

@@ -1,8 +1,11 @@
 package controllers
 
 import (
+	"encoding/json"
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/common"
+	"hongze/hongze_open_api/models/request/article"
+	celuePushTable "hongze/hongze_open_api/models/tables/article"
 	tables "hongze/hongze_open_api/models/tables/report"
 	"hongze/hongze_open_api/models/tables/wx_user"
 	"hongze/hongze_open_api/utils"
@@ -257,3 +260,45 @@ func (c *ReportControllerCommon) GetResearchReportChapter() {
 	}
 	c.OkDetailed(reportInfo, "获取成功")
 }
+
+// @Title 报告变更通知的插入点接口
+// @Description 报告变更通知的插入点接口
+// @Param	request	body article.CreatArticleCeluePushReq true "type json string"
+// @Success 200 创建成功
+// @router /article/change [post]
+func (c *ReportController) ArticleChange() {
+	//appid权限校验
+	appid := c.GetString("appid", "")
+	if utils.RunMode == "release" && appid != "CQWx3EqDLNk7bVHo" {
+		c.FailWithMessage("无权限")
+		return
+	}
+	var req article.CreatArticleCeluePushReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		c.FailWithMessage("参数解析异常")
+		return
+	}
+
+	articleId := req.ArticleId
+	action := req.Action
+	if articleId < 0 {
+		c.FailWithMessage("缺少 article_id 参数")
+		return
+	}
+	if action != "add" && action != "edit" && action != "move" {
+		c.FailWithMessage("action参数类型错误")
+		return
+	}
+	item := new(celuePushTable.CygxArticleCeluePush)
+	item.ArticleId = articleId
+	item.Action = action
+	item.CreateTime = time.Now()
+	item.ModifyTime = time.Now()
+	err = celuePushTable.AddCygxArticleCeluePush(item)
+	if err != nil {
+		c.OkWithMessage("创建失败")
+		return
+	}
+	c.OkWithMessage("创建成功")
+}

+ 6 - 4
models/db_init.go

@@ -4,6 +4,7 @@ import (
 	_ "github.com/go-sql-driver/mysql"
 	"github.com/rdlucklib/rdluck_tools/orm"
 	"hongze/hongze_open_api/models/tables/admin"
+	"hongze/hongze_open_api/models/tables/article"
 	"hongze/hongze_open_api/models/tables/company"
 	"hongze/hongze_open_api/models/tables/open_api_user"
 	"hongze/hongze_open_api/models/tables/wx_user"
@@ -29,10 +30,11 @@ func init() {
 
 	//注册对象
 	orm.RegisterModel(
-		new(open_api_user.OpenApiUser), //开放API用户表
-		new(company.Company),           //company客户表
-		new(wx_user.WxUser),            //微信用户表
-		new(admin.Admin),               //系统用户表
+		new(open_api_user.OpenApiUser),    //开放API用户表
+		new(company.Company),              //company客户表
+		new(wx_user.WxUser),               //微信用户表
+		new(admin.Admin),                  //系统用户表
+		new(article.CygxArticleCeluePush), //策略平台推送过来更新的文章
 	)
 
 }

+ 7 - 0
models/request/article/article.go

@@ -0,0 +1,7 @@
+package article
+
+// CreateUserReq 新增用户的结构体
+type CreatArticleCeluePushReq struct {
+	ArticleId int    `description:"文章ID" json:"article_id"`
+	Action    string `description:"操作方式 add:新增、edit:修改、move:删除" json:"action"`
+}

+ 22 - 0
models/tables/article/cygx_article_celue_push.go

@@ -0,0 +1,22 @@
+package article
+
+import (
+	"github.com/rdlucklib/rdluck_tools/orm"
+	"time"
+)
+
+type CygxArticleCeluePush struct {
+	Id         int       `orm:"column(id)" description:"自增Id"`
+	ArticleId  int       `description:"文章ID"`
+	Action     string    `description:"日志类型:add,edit,move"`
+	ModifyTime time.Time `description:"更新时间"`
+	CreateTime time.Time `description:"添加时间"`
+	IsHandle   int       `description:"是否处理过"`
+}
+
+// 新增
+func AddCygxArticleCeluePush(item *CygxArticleCeluePush) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}

+ 9 - 0
routers/commentsRouter_controllers.go

@@ -34,6 +34,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:ReportController"],
+        beego.ControllerComments{
+            Method: "ArticleChange",
+            Router: "/article/change",
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:ReportController"],
         beego.ControllerComments{
             Method: "ListReport",

+ 40 - 0
swagger/swagger.json

@@ -77,6 +77,31 @@
                 }
             }
         },
+        "/report/article/change": {
+            "post": {
+                "tags": [
+                    "report"
+                ],
+                "description": "报告变更通知的插入点接口",
+                "operationId": "ReportController.报告变更通知的插入点接口",
+                "parameters": [
+                    {
+                        "in": "body",
+                        "name": "request",
+                        "description": "type json string",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/article.CreatArticleCeluePushReq"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "创建成功"
+                    }
+                }
+            }
+        },
         "/report/getReportChapterInfo": {
             "get": {
                 "tags": [
@@ -246,6 +271,21 @@
                 }
             }
         },
+        "article.CreatArticleCeluePushReq": {
+            "title": "CreatArticleCeluePushReq",
+            "type": "object",
+            "properties": {
+                "action": {
+                    "description": "操作方式 add:新增、edit:修改、move:删除",
+                    "type": "string"
+                },
+                "article_id": {
+                    "description": "文章ID",
+                    "type": "integer",
+                    "format": "int64"
+                }
+            }
+        },
         "company_report_permission.ResearchReportTypeContent": {
             "title": "ResearchReportTypeContent",
             "type": "object",

+ 27 - 0
swagger/swagger.yml

@@ -79,6 +79,22 @@ paths:
             type: array
             items:
               $ref: '#/definitions/logic.UserView'
+  /report/article/change:
+    post:
+      tags:
+      - report
+      description: 报告变更通知的插入点接口
+      operationId: ReportController.报告变更通知的插入点接口
+      parameters:
+      - in: body
+        name: request
+        description: type json string
+        required: true
+        schema:
+          $ref: '#/definitions/article.CreatArticleCeluePushReq'
+      responses:
+        "200":
+          description: 创建成功
   /report/getReportChapterInfo:
     get:
       tags:
@@ -194,6 +210,17 @@ definitions:
         description: 角色类型,枚举值。1:ficc研究员;2:权益研究员;3:ficc销售;4:权益销售
         type: integer
         format: int64
+  article.CreatArticleCeluePushReq:
+    title: CreatArticleCeluePushReq
+    type: object
+    properties:
+      action:
+        description: 操作方式 add:新增、edit:修改、move:删除
+        type: string
+      article_id:
+        description: 文章ID
+        type: integer
+        format: int64
   company_report_permission.ResearchReportTypeContent:
     title: ResearchReportTypeContent
     type: object