Эх сурвалжийг харах

图表变更通知的插入点接口

xingzai 2 жил өмнө
parent
commit
2297ed5ada

+ 3 - 3
controllers/base_auth.go

@@ -128,7 +128,7 @@ func (c *BaseAuth) Prepare() {
 	utils.FileLog.Info(fmt.Sprintf("URI:%s", uri))
 }
 
-//将请求传入的数据格式转换成签名需要的格式
+// 将请求传入的数据格式转换成签名需要的格式
 func convertParam(params map[string][]string) (signData map[string]string) {
 	signData = make(map[string]string)
 	for key := range params {
@@ -137,7 +137,7 @@ func convertParam(params map[string][]string) (signData map[string]string) {
 	return signData
 }
 
-//将请求传入的数据格式转换成签名需要的格式(目前只能处理简单的类型,数组、对象暂不支持)
+// 将请求传入的数据格式转换成签名需要的格式(目前只能处理简单的类型,数组、对象暂不支持)
 func convertParamInterface(params map[string]interface{}) (signData map[string]string) {
 	signData = make(map[string]string)
 	for key := range params {
@@ -167,7 +167,7 @@ func convertParamInterface(params map[string]interface{}) (signData map[string]s
 	return signData
 }
 
-//请求参数签名校验
+// 请求参数签名校验
 func checkSign(postData map[string]string, ip string) (err error) {
 	isSandbox := postData["is_sandbox"]
 	//如果是测试环境,且是沙箱环境的话,那么绕过测试

+ 56 - 0
controllers/chart.go

@@ -0,0 +1,56 @@
+package controllers
+
+import (
+	"encoding/json"
+	"hongze/hongze_open_api/models/request/chart"
+	celuePushTable "hongze/hongze_open_api/models/tables/cygx_chart"
+	"hongze/hongze_open_api/utils"
+	"time"
+)
+
+// 图表模块
+type ChartController struct {
+	BaseAuth
+}
+
+// ChartChange
+// @Title 图表变更通知的插入点接口
+// @Description 图表变更通知的插入点接口
+// @Param	request	body chart.CreatChartCeluePushReq true "type json string"
+// @Success 200 创建成功
+// @router /change [post]
+func (c *ChartController) ChartChange() {
+	var req chart.CreatChartCeluePushReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		c.FailWithMessage("参数解析异常")
+		return
+	}
+	//appid权限校验
+	appid := req.Appid
+	if utils.RunMode == "release" && appid != utils.CLPT_APPID {
+		c.FailWithMessage("无权限")
+		return
+	}
+	chartId := req.ChartId
+	action := req.Action
+	if chartId < 0 {
+		c.FailWithMessage("缺少 chart_id 参数")
+		return
+	}
+	if action != "add" && action != "edit" && action != "move" {
+		c.FailWithMessage("action参数类型错误")
+		return
+	}
+	item := new(celuePushTable.CygxChartCeluePush)
+	item.ChartId = chartId
+	item.Action = action
+	item.CreateTime = time.Now()
+	item.ModifyTime = time.Now()
+	err = celuePushTable.AddCygxChartCeluePush(item)
+	if err != nil {
+		c.OkWithMessage("创建失败")
+		return
+	}
+	c.OkWithMessage("创建成功")
+}

+ 8 - 6
models/db_init.go

@@ -9,6 +9,7 @@ import (
 	"hongze/hongze_open_api/models/tables/company"
 	"hongze/hongze_open_api/models/tables/company_product"
 	"hongze/hongze_open_api/models/tables/cygx_activity"
+	"hongze/hongze_open_api/models/tables/cygx_chart"
 	"hongze/hongze_open_api/models/tables/day_new"
 	"hongze/hongze_open_api/models/tables/open_api_user"
 	"hongze/hongze_open_api/models/tables/qs_event"
@@ -40,6 +41,7 @@ func init() {
 		new(open_api_user.OpenApiUser),                     //开放API用户表
 		new(admin.Admin),                                   //系统用户表
 		new(article.CygxArticleCeluePush),                  //策略平台推送过来更新的文章
+		new(cygx_chart.CygxChartCeluePush),                 //策略平台推送过来更新的图表
 		new(cygx_activity.CygxActivitySignup),              //易董报名审核
 		new(cygx_activity.CygxYidongActivitySignupLog),     //易董报名记录日志
 		new(cygx_activity.CygxYidongActivityExamineStatus), //易董审核记录日志
@@ -63,9 +65,9 @@ func initYb() {
 		new(yb_activity.Activity),      //研报活动
 		new(qs_event.QsEvent),          //全时与ficc研报活动的关系表
 		new(qs_event_user.QsEventUser), //全时参会信息
-		new(day_new.WeworkMsg),               // 企业微信会话存档表
-		new(day_new.WeworkMsgLog),         // 企业微信群消息拉取日志表
-		new(day_new.WeworkUser),              // 企业微信用户信息表
+		new(day_new.WeworkMsg),         // 企业微信会话存档表
+		new(day_new.WeworkMsgLog),      // 企业微信群消息拉取日志表
+		new(day_new.WeworkUser),        // 企业微信用户信息表
 	)
 }
 
@@ -81,8 +83,8 @@ func initCompany() {
 // initEnglishReport 英文研报
 func initEnglishReport() {
 	orm.RegisterModel(
-		new(tables.EnglishClassify),           //EnglishClassify 英文分类表
-		new(tables.EnglishPolicyReport),       //EnglishPolicyReport 英文策略表
-		new(tables.EnglishReport),             //英文研报表
+		new(tables.EnglishClassify),     //EnglishClassify 英文分类表
+		new(tables.EnglishPolicyReport), //EnglishPolicyReport 英文策略表
+		new(tables.EnglishReport),       //英文研报表
 	)
 }

+ 8 - 0
models/request/chart/chart.go

@@ -0,0 +1,8 @@
+package chart
+
+// CreateUserReq 新增用户的结构体
+type CreatChartCeluePushReq struct {
+	ChartId int    `description:"图表ID" json:"chart_id"`
+	Appid   string `description:"APPID" json:"appid"`
+	Action  string `description:"操作方式 add:新增、edit:修改、move:删除" json:"action"`
+}

+ 22 - 0
models/tables/cygx_chart/cygx_chart_celue_push.go

@@ -0,0 +1,22 @@
+package cygx_chart
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxChartCeluePush struct {
+	Id         int       `orm:"column(id)" description:"自增Id"`
+	ChartId    int       `description:"图表ID"`
+	Action     string    `description:"日志类型:add,edit,move"`
+	ModifyTime time.Time `description:"更新时间"`
+	CreateTime time.Time `description:"添加时间"`
+	IsHandle   int       `description:"是否处理过"`
+}
+
+// 新增
+func AddCygxChartCeluePush(item *CygxChartCeluePush) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}

+ 9 - 0
routers/commentsRouter.go

@@ -16,6 +16,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:ChartController"] = append(beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:ChartController"],
+        beego.ControllerComments{
+            Method: "ChartChange",
+            Router: `/change`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:CompanyUser"] = append(beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:CompanyUser"],
         beego.ControllerComments{
             Method: "GetUserReportList",

+ 5 - 0
routers/router.go

@@ -66,6 +66,11 @@ func init() {
 				&controllers.DayNewController{},
 			),
 		),
+		web.NSNamespace("/chart",
+			web.NSInclude(
+				&controllers.ChartController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 139 - 2
swagger/swagger.json

@@ -14,6 +14,31 @@
     },
     "basePath": "/api",
     "paths": {
+        "/chart/change": {
+            "post": {
+                "tags": [
+                    "chart"
+                ],
+                "description": "图表变更通知的插入点接口\n\u003cbr\u003e",
+                "operationId": "ChartController.图表变更通知的插入点接口",
+                "parameters": [
+                    {
+                        "in": "body",
+                        "name": "request",
+                        "description": "type json string",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/chart.CreatChartCeluePushReq"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "创建成功"
+                    }
+                }
+            }
+        },
         "/company_user/user_report_list": {
             "get": {
                 "tags": [
@@ -77,6 +102,33 @@
                 }
             }
         },
+        "/day_new/refresh": {
+            "get": {
+                "tags": [
+                    "day_new"
+                ],
+                "description": "手动刷新\n\u003cbr\u003e",
+                "operationId": "DayNewController.手动刷新企业微信群消息"
+            }
+        },
+        "/day_new/translate": {
+            "get": {
+                "tags": [
+                    "day_new"
+                ],
+                "description": "手动翻译内容\n\u003cbr\u003e",
+                "operationId": "DayNewController.手动翻译内容"
+            }
+        },
+        "/en/report/notify": {
+            "get": {
+                "tags": [
+                    "en/report"
+                ],
+                "description": "策略报告发布通知\n\u003cbr\u003e",
+                "operationId": "EnglishReportController.策略报告发布通知"
+            }
+        },
         "/quanshi/callback": {
             "post": {
                 "tags": [
@@ -466,7 +518,23 @@
                 }
             }
         },
-        "/yidong/activity/examine": {
+        "/wework/notify": {
+            "get": {
+                "tags": [
+                    "wework"
+                ],
+                "description": "企业微信通知\n\u003cbr\u003e",
+                "operationId": "WeworkController.企业微信通知"
+            },
+            "post": {
+                "tags": [
+                    "wework"
+                ],
+                "description": "企业微信通知\n\u003cbr\u003e",
+                "operationId": "WeworkController.企业微信通知"
+            }
+        },
+        "/yidong/activity/examine/signup": {
             "post": {
                 "tags": [
                     "yidong"
@@ -490,6 +558,31 @@
                     }
                 }
             }
+        },
+        "/yidong/activity/user/signup": {
+            "post": {
+                "tags": [
+                    "yidong"
+                ],
+                "description": "易董提交报名时,获取用户信息接口\n\u003cbr\u003e",
+                "operationId": "YiDongController.易董提交报名时,获取用户信息接口",
+                "parameters": [
+                    {
+                        "in": "body",
+                        "name": "request",
+                        "description": "type json string",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/yidong.ActivityExamineReq"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "创建成功"
+                    }
+                }
+            }
         }
     },
     "definitions": {
@@ -531,6 +624,25 @@
                 }
             }
         },
+        "chart.CreatChartCeluePushReq": {
+            "title": "CreatChartCeluePushReq",
+            "type": "object",
+            "properties": {
+                "action": {
+                    "description": "操作方式 add:新增、edit:修改、move:删除",
+                    "type": "string"
+                },
+                "appid": {
+                    "description": "APPID",
+                    "type": "string"
+                },
+                "chart_id": {
+                    "description": "图表ID",
+                    "type": "integer",
+                    "format": "int64"
+                }
+            }
+        },
         "classify.ClassifyList": {
             "title": "ClassifyList",
             "type": "object",
@@ -1429,12 +1541,25 @@
                     "description": "文章ID",
                     "type": "string"
                 },
+                "appid": {
+                    "description": "开放平台给分配的appid",
+                    "type": "string"
+                },
                 "list": {
                     "description": "审核结果",
                     "type": "array",
                     "items": {
                         "$ref": "#/definitions/yidong.ExamineStatusReq"
                     }
+                },
+                "sign": {
+                    "description": "签名",
+                    "type": "string"
+                },
+                "time": {
+                    "description": "时间戳",
+                    "type": "integer",
+                    "format": "int64"
                 }
             }
         },
@@ -1442,8 +1567,12 @@
             "title": "ExamineStatusReq",
             "type": "object",
             "properties": {
+                "create_time": {
+                    "description": "报名时间",
+                    "type": "string"
+                },
                 "examine_status": {
-                    "description": "审核状态 1,通过、2:未通过",
+                    "description": "审核状态 1,通过、2:未通过、3:取消报名",
                     "type": "integer",
                     "format": "int64"
                 },
@@ -1478,6 +1607,14 @@
         {
             "name": "yidong",
             "description": "易董\n"
+        },
+        {
+            "name": "wework",
+            "description": "用户\n"
+        },
+        {
+            "name": "chart",
+            "description": "图表模块\n"
         }
     ]
 }

+ 110 - 2
swagger/swagger.yml

@@ -11,6 +11,24 @@ info:
     url: http://www.apache.org/licenses/LICENSE-2.0.html
 basePath: /api
 paths:
+  /chart/change:
+    post:
+      tags:
+      - chart
+      description: |-
+        图表变更通知的插入点接口
+        <br>
+      operationId: ChartController.图表变更通知的插入点接口
+      parameters:
+      - in: body
+        name: request
+        description: type json string
+        required: true
+        schema:
+          $ref: '#/definitions/chart.CreatChartCeluePushReq'
+      responses:
+        "200":
+          description: 创建成功
   /company_user/user_report_list:
     get:
       tags:
@@ -56,6 +74,30 @@ paths:
             type: array
             items:
               $ref: '#/definitions/logic.UserView'
+  /day_new/refresh:
+    get:
+      tags:
+      - day_new
+      description: |-
+        手动刷新
+        <br>
+      operationId: DayNewController.手动刷新企业微信群消息
+  /day_new/translate:
+    get:
+      tags:
+      - day_new
+      description: |-
+        手动翻译内容
+        <br>
+      operationId: DayNewController.手动翻译内容
+  /en/report/notify:
+    get:
+      tags:
+      - en/report
+      description: |-
+        策略报告发布通知
+        <br>
+      operationId: EnglishReportController.策略报告发布通知
   /quanshi/callback:
     post:
       tags:
@@ -342,7 +384,22 @@ paths:
       responses:
         "200":
           description: 创建成功
-  /yidong/activity/examine:
+  /wework/notify:
+    get:
+      tags:
+      - wework
+      description: |-
+        企业微信通知
+        <br>
+      operationId: WeworkController.企业微信通知
+    post:
+      tags:
+      - wework
+      description: |-
+        企业微信通知
+        <br>
+      operationId: WeworkController.企业微信通知
+  /yidong/activity/examine/signup:
     post:
       tags:
       - yidong
@@ -360,6 +417,24 @@ paths:
       responses:
         "200":
           description: 创建成功
+  /yidong/activity/user/signup:
+    post:
+      tags:
+      - yidong
+      description: |-
+        易董提交报名时,获取用户信息接口
+        <br>
+      operationId: YiDongController.易董提交报名时,获取用户信息接口
+      parameters:
+      - in: body
+        name: request
+        description: type json string
+        required: true
+        schema:
+          $ref: '#/definitions/yidong.ActivityExamineReq'
+      responses:
+        "200":
+          description: 创建成功
 definitions:
   admin.CreateUserReq:
     title: CreateUserReq
@@ -389,6 +464,20 @@ definitions:
         description: 文章ID
         type: integer
         format: int64
+  chart.CreatChartCeluePushReq:
+    title: CreatChartCeluePushReq
+    type: object
+    properties:
+      action:
+        description: 操作方式 add:新增、edit:修改、move:删除
+        type: string
+      appid:
+        description: APPID
+        type: string
+      chart_id:
+        description: 图表ID
+        type: integer
+        format: int64
   classify.ClassifyList:
     title: ClassifyList
     type: object
@@ -1049,17 +1138,30 @@ definitions:
       activity_id:
         description: 文章ID
         type: string
+      appid:
+        description: 开放平台给分配的appid
+        type: string
       list:
         description: 审核结果
         type: array
         items:
           $ref: '#/definitions/yidong.ExamineStatusReq'
+      sign:
+        description: 签名
+        type: string
+      time:
+        description: 时间戳
+        type: integer
+        format: int64
   yidong.ExamineStatusReq:
     title: ExamineStatusReq
     type: object
     properties:
+      create_time:
+        description: 报名时间
+        type: string
       examine_status:
-        description: 审核状态 1,通过、2:未通过
+        description: 审核状态 1,通过、2:未通过、3:取消报名
         type: integer
         format: int64
       mobile:
@@ -1086,3 +1188,9 @@ tags:
 - name: yidong
   description: |
     易董
+- name: wework
+  description: |
+    用户
+- name: chart
+  description: |
+    图表模块

+ 13 - 11
utils/constants.go

@@ -4,7 +4,7 @@ const (
 	Md5Key = ""
 )
 
-//常量定义
+// 常量定义
 const (
 	FormatTime            = "15:04:05"                //时间格式
 	FormatDate            = "2006-01-02"              //日期格式
@@ -25,13 +25,13 @@ const (
 	EmailSendToUsers = "glji@hzinsights.com;pyan@hzinsights.com;cxzhang@hzinsights.com"
 )
 
-//手机号,电子邮箱正则
+// 手机号,电子邮箱正则
 const (
 	RegularMobile = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0-9])|(17[0-9])|(16[0-9])|(19[0-9]))\\d{8}$" //手机号码
 	RegularEmail  = `\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*`                                             //匹配电子邮箱
 )
 
-//客户状态
+// 客户状态
 const (
 	COMPANY_STATUS_TRY_OUT       = "试用"
 	COMPANY_STATUS_FOREVER       = "永续"
@@ -44,8 +44,8 @@ const (
 	COMPANY_APPROVE_STATUS = "待审批"
 )
 
-//管理员,ficc管理员,ficc销售,权益管理员,权益销售。
-//角色类型/类型编码
+// 管理员,ficc管理员,ficc销售,权益管理员,权益销售。
+// 角色类型/类型编码
 const (
 	ROLE_TYPE_ADMIN       = "管理员"
 	ROLE_TYPE_FICC_ADMIN  = "ficc管理员"
@@ -76,7 +76,7 @@ const (
 	ROLE_TYPE_SELLERS = "'ficc_admin','ficc_seller','rai_admin','rai_seller','ficc_group','rai_group','ficc_department','rai_department','compliance'"
 )
 
-//客户类型
+// 客户类型
 const (
 	COMPANY_CLASSIFY_FICC    = "ficc"
 	COMPANY_CLASSIFY_RAI     = "权益"
@@ -98,14 +98,16 @@ const (
 	REPORT_KEY = "Zdhuef3ajCLTpfGLn10cOJLJ" //报告加密Key
 )
 
-//缓存key
+// 缓存key
 const (
-	CACHE_KEY_ADMIN = "calendar:admin:list" //系统用户列表缓存key
-	CACHE_KEY_DAYNEW_REFRESH     = "admin:day_new:refresh"           //每日资讯拉取企业微信聊天记录
-	CACHE_KEY_DAYNEW_TRANSLATE   = "admin:day_new:translate"         //每日资讯中翻英
+	CACHE_KEY_ADMIN            = "calendar:admin:list"     //系统用户列表缓存key
+	CACHE_KEY_DAYNEW_REFRESH   = "admin:day_new:refresh"   //每日资讯拉取企业微信聊天记录
+	CACHE_KEY_DAYNEW_TRANSLATE = "admin:day_new:translate" //每日资讯中翻英
 )
 
 const ALIYUN_YBIMG_HOST = "https://hzstatic.hzinsights.com/static/yb_wx/"
 const HZ_DEFAULT_AVATAR = "https://hzstatic.hzinsights.com/static/yb_wx/hz_default_avatar.png"
 
-const HZPHONE = "057187186319" //弘则电话
+const HZPHONE = "057187186319" //弘则电话
+
+const CLPT_APPID = "XVuGlcyEEVNYVWx5" //策略平台APPID