浏览代码

no message

zhangchuanxing 3 月之前
父节点
当前提交
e3d8e7b7eb
共有 5 个文件被更改,包括 170 次插入0 次删除
  1. 42 0
      controllers/article.go
  2. 92 0
      models/vmp.go
  3. 9 0
      routers/commentsRouter.go
  4. 26 0
      services/vmp.go
  5. 1 0
      utils/constants.go

+ 42 - 0
controllers/article.go

@@ -852,3 +852,45 @@ func (this *ArticleController) ApplyAppointmentExpert() {
 	br.Success = true
 	br.Msg = "操作成功"
 }
+
+// @Title 获取上海策略平台报告详情
+// @Description 获取上海策略平台报告详情接口
+// @Param   ArticleId   query   int  true       "报告ID"
+// @Success 200 {object} models.ArticleDetailResp
+// @router /detail_vmp [get]
+func (this *ArticleController) DetailVmp() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+
+	articleId, _ := this.GetInt("ArticleId")
+	var clueApiUrl string
+	clueApiUrl = fmt.Sprint(utils.ApiUrl, "articles/", articleId)
+	authorization := utils.ApiAuthorization
+	body, err := services.PublicGetDate(clueApiUrl, authorization)
+	if err != nil {
+		br.Msg = "约访专家失败"
+		br.ErrMsg = "约访专家失败,Err:" + err.Error()
+		return
+	}
+	var articleResultDate models.ArticleDetailResultApi
+	err = json.Unmarshal(body, &articleResultDate)
+	if err != nil {
+		br.Msg = "约访专家失败"
+		br.ErrMsg = "约访专家失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = articleResultDate
+}

+ 92 - 0
models/vmp.go

@@ -9,3 +9,95 @@ type ChartUserTokenResultApi struct {
 	Code int                  `json:"code"`
 	Msg  string               `json:"msg"`
 }
+
+// Root represents the top-level structure of the data.
+type Root struct {
+	Code int    `json:"code" comment:"状态码"`
+	Msg  string `json:"msg" comment:"操作信息"`
+	Data Data   `json:"data" comment:"数据详情"`
+}
+
+// Data represents the main content of the response.
+type Data struct {
+	ID            int      `json:"id" comment:"文章ID"`
+	Title         string   `json:"title" comment:"文章标题"`
+	TitleEn       string   `json:"title_en" comment:"文章英文标题"`
+	Frequency     string   `json:"frequency" comment:"更新频率"`
+	CreateDate    string   `json:"create_date" comment:"创建时间"`
+	UpdateDate    string   `json:"update_date" comment:"更新时间"`
+	PublishDate   string   `json:"publish_date" comment:"发布时间"`
+	PublishStatus int      `json:"publish_status" comment:"发布状态"`
+	VerifyStatus  int      `json:"verify_status" comment:"审核状态"`
+	PublishArea   string   `json:"publish_area" comment:"发布区域"`
+	AccessLevel   int      `json:"access_level" comment:"访问级别"`
+	IsActive      bool     `json:"is_active" comment:"是否激活"`
+	AuthorPhone   string   `json:"author_phone_number" comment:"作者手机号"`
+	Cover         string   `json:"cover" comment:"封面图片"`
+	IndustryID    int      `json:"industry_id" comment:"行业ID"`
+	ContentID     int      `json:"content_id" comment:"内容ID"`
+	TypeID        int      `json:"type_id" comment:"类型ID"`
+	FieldID       int      `json:"field_id" comment:"领域ID"`
+	SeriesID      int      `json:"series_id" comment:"系列ID"`
+	File          string   `json:"file" comment:"文件链接"`
+	Stock         []string `json:"stock" comment:"相关股票"`
+	IsFocused     int      `json:"is_focused" comment:"是否聚焦"`
+	Content       Content  `json:"content" comment:"内容详情"`
+	Industry      Industry `json:"industry" comment:"行业详情"`
+	Type          ItemType `json:"type" comment:"类型详情"`
+	Field         Field    `json:"field" comment:"领域详情"`
+	Series        Series   `json:"series" comment:"系列详情"`
+	Author        Author   `json:"author" comment:"作者信息"`
+	CoAuthor      []string `json:"co_author" comment:"协作者"`
+	Corpus        Corpus   `json:"corpus" comment:"语料库信息"`
+}
+
+// Content represents the details of the content.
+type Content struct {
+	ID         int    `json:"id" comment:"内容ID"`
+	Body       string `json:"body" comment:"正文"`
+	Abstract   string `json:"abstract" comment:"摘要"`
+	Annotation string `json:"annotation" comment:"注释"`
+	AutoSave   string `json:"auto_save" comment:"自动保存内容"`
+}
+
+// Industry represents the industry details.
+type Industry struct {
+	ID          int    `json:"id" comment:"行业ID"`
+	Name        string `json:"name" comment:"行业名称"`
+	Description string `json:"description" comment:"行业描述"`
+}
+
+// ItemType represents the type of the article.
+type ItemType struct {
+	ID          int    `json:"id" comment:"类型ID"`
+	Name        string `json:"name" comment:"类型名称"`
+	Description string `json:"description" comment:"类型描述"`
+}
+
+// Field represents the field details.
+type Field struct {
+	ID          int    `json:"id" comment:"领域ID"`
+	Name        string `json:"name" comment:"领域名称"`
+	Description string `json:"description" comment:"领域描述"`
+	IndustryID  int    `json:"industry_id" comment:"行业ID"`
+}
+
+// Series represents the series details.
+type Series struct {
+	ID          int    `json:"id" comment:"系列ID"`
+	Name        string `json:"name" comment:"系列名称"`
+	Description string `json:"description" comment:"系列描述"`
+	IndustryID  int    `json:"industry_id" comment:"行业ID"`
+}
+
+// Author represents the author details.
+type Author struct {
+	Name string `json:"name" comment:"作者姓名"`
+}
+
+//// Corpus represents the corpus details.
+//type Corpus struct {
+//	ID        int    `json:"id" comment:"语料ID"`
+//	ArticleID int    `json:"article_id" comment:"文章ID"`
+//	Corpus    string `json:"corpus" comment:"语料内容"`
+//}

+ 9 - 0
routers/commentsRouter.go

@@ -205,6 +205,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_mfyx/controllers:ArticleController"] = append(beego.GlobalControllerRouter["hongze/hongze_mfyx/controllers:ArticleController"],
+        beego.ControllerComments{
+            Method: "DetailVmp",
+            Router: `/detail_vmp`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_mfyx/controllers:ArticleController"] = append(beego.GlobalControllerRouter["hongze/hongze_mfyx/controllers:ArticleController"],
         beego.ControllerComments{
             Method: "InterviewApply",

+ 26 - 0
services/vmp.go

@@ -55,3 +55,29 @@ func GetUserTokenByMobile(mobile string) (token string, err error) {
 	}
 	return
 }
+
+// get公共请求方法
+func PublicGetDate(url, authorization string) (body []byte, err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", url+"Get ErrMsg:"+err.Error(), utils.EmailSendToUsers)
+		}
+	}()
+	method := "GET"
+	client := &nhttp.Client{}
+	req, err := nhttp.NewRequest(method, url, nil)
+	if err != nil {
+		return
+	}
+	req.Header.Add("Authorization", authorization)
+	res, err := client.Do(req)
+	if err != nil {
+		return
+	}
+	defer res.Body.Close()
+	body, err = ioutil.ReadAll(res.Body)
+	if err != nil {
+		return
+	}
+	return
+}

+ 1 - 0
utils/constants.go

@@ -48,6 +48,7 @@ const (
 	DefaultHeadimgurl = "https://hzstatic.hzinsights.com/static/images/202401/20240103/u6Ykx23BMTnwtvYhZnJktgD54MLp.png"
 	REGISTER_PLATFORM = 5    // 来源 1小程序,2:网页 5:买方研选
 	IS_SHOW_WX_PAY    = true // 是否展示微信支付
+	ApiAuthorization  = "bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkiLCJwaG9uZV9udW1iZXIiOiIxMjM0NTY3ODkiLCJuYW1lIjoi5YW25LuWIiwiZW50cmFuY2UiOiJwYXNzd3dvcmQiLCJpYXQiOjE2MzQ4NzA1OTQsImV4cCI6MTYzNDg3NDE5NH0.tho2L9jsbDPn8ltEGUVDve_nHsh0Kzf6ZrSz0RcZ0ag"
 	ApiUrl            = "https://vmp.hzinsights.com/v2api/"
 )