瀏覽代碼

no message

zhangchuanxing 1 周之前
父節點
當前提交
d10eec05f3

+ 125 - 0
controllers/jinmencaijing.go

@@ -4,18 +4,22 @@ import (
 	"encoding/json"
 	"fmt"
 	jinmencaijingReq "hongze/hongze_open_api/models/request/jinmencaijing"
+	reportSelectionResp "hongze/hongze_open_api/models/response/cygx_report_selection"
 	"hongze/hongze_open_api/models/response/jinmencaijing"
 	"hongze/hongze_open_api/models/tables/company"
 	"hongze/hongze_open_api/models/tables/company_product"
 	"hongze/hongze_open_api/models/tables/company_report_permission"
 	cygxActivity "hongze/hongze_open_api/models/tables/cygx/cygx_activity"
+	"hongze/hongze_open_api/models/tables/cygx/cygx_report_selection"
 	"hongze/hongze_open_api/models/tables/cygx/cygx_three_api_log"
 	"hongze/hongze_open_api/models/tables/wx_user"
 	"hongze/hongze_open_api/services/alarm_msg"
+	servicesCompany "hongze/hongze_open_api/services/company"
 	cygxSeriesActivity "hongze/hongze_open_api/services/cygx_activity"
 	servicesWxUser "hongze/hongze_open_api/services/wx_user"
 	"hongze/hongze_open_api/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -388,3 +392,124 @@ func (c *JinMenCaiJingController) ActivitySignupDetail() {
 //	encryptMobile := string(utils.DesBase64Encrypt([]byte(mobile)))
 //	fmt.Println(encryptMobile)
 //}
+
+// 重点公司详情接口
+// @Title 重点公司详情接口
+// @Description 重点公司详情接口
+// @router /report_selection/detail [get]
+func (c *JinMenCaiJingController) ReportSelectionDetail() {
+	//回调中url参数要做签名(get请求中的参数,按照自己的方式签名,避免链接被别人拿去随意请求)
+	articleId, _ := c.GetInt("article_id")
+	resp := new(reportSelectionResp.ReportSelectionLetailResp)
+	detail, err := cygx_report_selection.GetCygxReportSelectionInfoById(articleId)
+	if err != nil {
+		c.FailWithMessage("报告ID异常:" + strconv.Itoa(articleId))
+		return
+	}
+	detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
+	existMap := make(map[int]int)
+	var items []*reportSelectionResp.ReportSelectionChartPermission
+	var itemsSubject []*reportSelectionResp.ReportSelectionChartLogPermission
+	listLog, err := cygx_report_selection.GetReportSelectionlogListAll(articleId)
+	if err != nil {
+		c.FailWithMessage("获取信息失败")
+		return
+	}
+
+	//获取行业核心逻辑汇总
+	listChartLog, err := cygx_report_selection.GetCygxReportSelectionChartLogRepList(articleId)
+	if err != nil {
+		c.FailWithMessage("获取信息失败")
+		return
+	}
+	mapChartLog := make(map[string]string)
+	for _, v := range listChartLog {
+		mapChartLog[v.ChartPermissionName] = v.BodyChartSummary
+	}
+
+	PermissionNameMap, err := servicesCompany.GetPermissionNameMap()
+	if err != nil {
+		c.FailWithMessage("获取信息失败:")
+		return
+	}
+	for _, v := range listLog {
+		v.PermissionName = PermissionNameMap[v.ChartPermissionId]
+		item := new(reportSelectionResp.ReportSelectionChartPermission)
+		itemSubject := new(reportSelectionResp.ReportSelectionChartLogPermission)
+		itemSubject.PermissionName = v.PermissionName
+		if existMap[v.ChartPermissionId] == 0 {
+			item.PermissionName = v.PermissionName
+			listSonLog, err := cygx_report_selection.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
+			if err != nil {
+				c.FailWithMessage("获取信息失败")
+				return
+			}
+			for k2, v2 := range listSonLog {
+				if v2.IndustrialManagementId != "" {
+					listIndustrial, err := cygx_report_selection.GetIndustrialByIds(v2.IndustrialManagementId)
+					if err != nil {
+						c.FailWithMessage("获取信息失败")
+						return
+					}
+					listSonLog[k2].List = listIndustrial
+					if v2.SubjectName == "" {
+						v2.ShowName = v2.IndustrialManagementNames
+					} else {
+						v2.ShowName = v2.SubjectName
+					}
+				}
+				if v2.Label != "" {
+					CompanyLabelSlice := strings.Split(v2.Label, "{|}")
+					for _, vCompanyLabel := range CompanyLabelSlice {
+						v2.CompanyLabel = append(v2.CompanyLabel, "#"+vCompanyLabel+"#")
+					}
+				}
+				if v2.ThirdName != "" {
+					v2.ShowName = v2.ThirdName
+				}
+				subjectItem := new(reportSelectionResp.ReportSelectionChartLogSubjectName)
+				subjectItem.SubjectName = v2.SubjectName
+				subjectItem.IsNew = v2.IsNew
+				if v2.ThirdName != "" {
+					subjectItem.SubjectName = v2.ThirdName
+				} else {
+					if subjectItem.SubjectName == "" {
+						subjectItem.SubjectName = v2.IndustrialManagementNames
+					}
+				}
+				subjectItem.UniqueString = utils.MD5(fmt.Sprint("IN_ID", v2.IndustrialManagementId, "S_ID", v2.IndustrialSubjectId, "T_ID", v2.ThirdId))
+				v2.UniqueString = subjectItem.UniqueString
+				itemSubject.ListSubject = append(itemSubject.ListSubject, subjectItem)
+			}
+			item.BodyChartSummary = mapChartLog[v.PermissionName]
+
+			for _, vs := range listSonLog {
+				listItem := new(reportSelectionResp.CygxReportSelectionLogDetail)
+				listItem.IsNew = vs.IsNew
+				listItem.Body = vs.Body
+				listItem.CompanyLabel = vs.CompanyLabel
+				listItem.UniqueString = vs.UniqueString
+				listItem.ShowName = vs.ShowName
+				item.List = append(item.List, listItem)
+			}
+			item.PermissionName = PermissionNameMap[v.ChartPermissionId]
+			items = append(items, item)
+			itemsSubject = append(itemsSubject, itemSubject)
+		}
+		existMap[v.ChartPermissionId] = v.ChartPermissionId
+	}
+
+	resp.List = items
+	resp.ListPermissionSubject = itemsSubject
+	detailItem := new(reportSelectionResp.DetailCygxReportSelectionRep)
+	detailItem.ArticleId = detail.ArticleId
+	detailItem.Title = detail.Title
+	detailItem.Department = detail.Department
+	detailItem.PublishDate = detail.PublishDate
+	detailItem.ProductDescription = detail.ProductDescription
+	detailItem.UpdateDescription = detail.UpdateDescription
+	detailItem.FocusOn = detail.FocusOn
+	detailItem.MarketStrategy = detail.MarketStrategy
+	resp.Detail = detailItem
+	c.OkDetailed(resp, "获取成功")
+}

+ 67 - 0
models/response/cygx_report_selection/cygx_report_selection.go

@@ -0,0 +1,67 @@
+package cygx_report_selection
+
+type DetailCygxReportSelectionRep struct {
+	ArticleId          int    `description:"报告Id"`
+	Title              string `description:"标题"`
+	Department         string `description:"作者"`
+	PublishDate        string `description:"发布时间"`
+	ProductDescription string `description:"产品说明"`
+	UpdateDescription  string `description:"更新说明"`
+	FocusOn            string `description:"近期重点关注方向"`
+	MarketStrategy     string `description:"市场策略核心逻辑汇总"`
+}
+
+type ReportSelectionChartPermission struct {
+	PermissionName string `description:"行业名称"`
+	//ChartPermissionId int    `description:"权限名称"`
+	//IcoLink           string `orm:"column(image_url)"description:"图标链接"`
+	List             []*CygxReportSelectionLogDetail
+	BodyChartSummary string `description:"行业核心逻辑汇总"`
+}
+
+type CygxReportSelectionLogDetail struct {
+	//IndustrialManagementId    string   `description:"产业Id"`
+	//IndustrialManagementNames string   `description:"产业资源包名称  多个用 , 隔开"`
+	//IndustrialSubjectId       int      `description:"标的ID"`
+	//SubjectName               string   `description:"标的名称"`
+	//IsShowApplyButton         bool     `description:"是否展示申请路由按钮"`
+	IsNew        bool     `description:"是否展示新标签"`
+	Body         string   `description:"内容"`
+	CompanyLabel []string `description:"公司标签"`
+	//Label                     string   `description:"公司标签"`
+	//OverviewArticleId         int      `description:"综述报告Id"`
+	//IsShowOverviewArticle     int      `description:"是否展示综述报告 1展示,0隐藏"`
+	//ThirdId                   int      `description:"类似产业、标的的三方ID"`
+	//ThirdName                 string   `description:"类似产业、标的的三方名称"`
+	UniqueString string `description:"Md5唯一标识"`
+	ShowName     string `description:"展示名称"`
+	//List         []*IndustriaReportSelection
+}
+
+type IndustriaReportSelection struct {
+	IndustrialManagementId int    `description:"产业Id"`
+	IndustryName           string `description:"产业名称"`
+}
+
+type ReportSelectionChartLogPermission struct {
+	PermissionName string                                `description:"权限名称"`
+	ListSubject    []*ReportSelectionChartLogSubjectName `description:"标的列表"`
+}
+
+type ReportSelectionChartLogSubjectName struct {
+	SubjectName string `description:"标的名称"`
+	//IndustrialSubjectId      int    `description:"标的ID"`
+	//IndustrialManagementId   int    `description:"产业Id"`
+	//IndustrialManagementName string `description:"产业资源包名称"`
+	//ThirdId                  int    `description:"类似产业、标的的三方ID"`
+	//ThirdName                string `description:"类似产业、标的的三方名称"`
+	IsNew        bool   `description:"是否展示新标签"`
+	UniqueString string `description:"唯一标识"`
+}
+
+type ReportSelectionLetailResp struct {
+	Detail                *DetailCygxReportSelectionRep
+	List                  []*ReportSelectionChartPermission
+	ListPermissionSubject []*ReportSelectionChartLogPermission `description:"行业列表"`
+	IsShow                bool                                 `description:"是否展示"`
+}

+ 7 - 0
models/tables/chart_permission/chart_permission.go

@@ -40,3 +40,10 @@ func GetListByIds(permissionIds []int) (list []*ChartPermission, err error) {
 	_, err = o.Raw(sql, permissionIds).QueryRows(&list)
 	return
 }
+
+func GetChartPermissionListRai() (items []*ChartPermission, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM chart_permission WHERE product_id=2  ORDER BY sort ASC `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 22 - 0
models/tables/cygx/cygx_report_selection/cygx_report_selection_log.go

@@ -0,0 +1,22 @@
+package cygx_report_selection
+
+import "time"
+
+type CygxReportSelectionLog struct {
+	ArticleSunId              int       `description:"子级报告id"`
+	ArticleId                 int       `description:"父级报告Id"`
+	ChartPermissionId         int       `description:"行业ID"`
+	PermissionName            string    `description:"行业ID"`
+	CreateTime                time.Time `description:"创建时间"`
+	Body                      string    `description:"内容"`
+	IndustrialSubjectId       int       `description:"标的ID"`
+	IndustrialManagementId    string    `description:"产业资源包Id  多个用 , 隔开"`
+	IndustrialManagementNames string    `description:"产业资源包名称  多个用 , 隔开"`
+	SubjectName               string    `description:"标的名称"`
+	IcoLink                   string    `orm:"column(image_url)"description:"图标链接"`
+	CompanyLabel              []string  `description:"公司标签"`
+	Label                     string    `description:"公司标签"`
+	OverviewArticleId         int       `description:"综述报告Id"`
+	ThirdId                   int       `description:"类似产业、标的的三方ID"`
+	ThirdName                 string    `description:"类似产业、标的的三方名称"`
+}

+ 101 - 0
models/tables/cygx/cygx_report_selection/report_selection.go

@@ -0,0 +1,101 @@
+package cygx_report_selection
+
+import "github.com/beego/beego/v2/client/orm"
+
+type DetailCygxReportSelectionRep struct {
+	ArticleId          int    `description:"报告Id"`
+	Title              string `description:"标题"`
+	Department         string `description:"作者"`
+	PublishDate        string `description:"发布时间"`
+	CreateTime         string `description:"创建时间"`
+	LastUpdatedTime    string `description:"最后一次更新时间"`
+	Periods            int    `description:"期数"`
+	VideoUrl           string `description:"链接"`
+	VideoPlaySeconds   string `description:"时长"`
+	VideoName          string `description:"音频名称"`
+	ProductDescription string `description:"产品说明"`
+	UpdateDescription  string `description:"更新说明"`
+	FocusOn            string `description:"近期重点关注方向"`
+	MarketStrategy     string `description:"市场策略核心逻辑汇总"`
+	ReportLink         string `description:"报告链接"`
+	CeLueArticleId     int    `description:"策略报告详情"`
+	VisibleRange       int    `description:"设置可见范围1全部,0内部"`
+}
+
+type CygxReportSelectionChartLogRep struct {
+	ChartPermissionId   int    `description:"行业ID"`
+	ChartPermissionName string `description:"行业ID"`
+	BodyChartSummary    string `orm:"column(body)"description:"内容"`
+}
+
+// 通过ID获取详情
+func GetCygxReportSelectionInfoById(articleId int) (item *DetailCygxReportSelectionRep, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT * FROM cygx_report_selection  WHERE article_id=? AND publish_status = 1 `
+	err = o.Raw(sql, articleId).QueryRow(&item)
+	return
+}
+
+// 列表
+func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLog, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT s.subject_name , l.*  ,l.company_label as label
+			FROM
+			cygx_report_selection_log AS l
+			INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = l.industrial_subject_id 
+			WHERE l.article_id = ? `
+	_, err = o.Raw(sql, articleId).QueryRows(&items)
+	return
+}
+
+func GetCygxReportSelectionChartLogRepList(articleId int) (items []*CygxReportSelectionChartLogRep, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT l.*
+			FROM cygx_report_selection_chart_log AS l
+			WHERE  1= 1 AND article_id=?  `
+	_, err = o.Raw(sql, articleId).QueryRows(&items)
+	return
+}
+
+type CygxReportSelectionLogDetail struct {
+	IndustrialManagementId    string   `description:"产业Id"`
+	IndustrialManagementNames string   `description:"产业资源包名称  多个用 , 隔开"`
+	IndustrialSubjectId       int      `description:"标的ID"`
+	SubjectName               string   `description:"标的名称"`
+	IsShowApplyButton         bool     `description:"是否展示申请路由按钮"`
+	IsNew                     bool     `description:"是否展示新标签"`
+	Body                      string   `description:"内容"`
+	CompanyLabel              []string `description:"公司标签"`
+	Label                     string   `description:"公司标签"`
+	OverviewArticleId         int      `description:"综述报告Id"`
+	IsShowOverviewArticle     int      `description:"是否展示综述报告 1展示,0隐藏"`
+	ThirdId                   int      `description:"类似产业、标的的三方ID"`
+	ThirdName                 string   `description:"类似产业、标的的三方名称"`
+	UniqueString              string   `description:"Md5唯一标识"`
+	ShowName                  string   `description:"展示名称"`
+	List                      []*IndustriaReportSelection
+}
+
+type IndustriaReportSelection struct {
+	IndustrialManagementId int    `description:"产业Id"`
+	IndustryName           string `description:"产业名称"`
+}
+
+// 列表
+func GetReportSelectionlogSonListAll(articleId, chartPermissionId int) (items []*CygxReportSelectionLogDetail, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT  l.* ,l.company_label as label
+			FROM
+			cygx_report_selection_log AS l
+			LEFT JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = l.industrial_subject_id 
+			WHERE l.article_id = ? AND l.chart_permission_id =?`
+	_, err = o.Raw(sql, articleId, chartPermissionId).QueryRows(&items)
+	return
+}
+
+func GetIndustrialByIds(industrialManagementIds string) (items []*IndustriaReportSelection, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT * FROM cygx_industrial_management  WHERE industrial_management_id IN (` + industrialManagementIds + `)`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 9 - 0
routers/commentsRouter.go

@@ -133,6 +133,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:JinMenCaiJingController"] = append(beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:JinMenCaiJingController"],
+        beego.ControllerComments{
+            Method: "ReportSelectionDetail",
+            Router: `/report_selection/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:QuanShiControllerCommon"] = append(beego.GlobalControllerRouter["hongze/hongze_open_api/controllers:QuanShiControllerCommon"],
         beego.ControllerComments{
             Method: "CallBack",

+ 16 - 0
services/company/permission.go

@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"hongze/hongze_open_api/models/response/report"
 	"hongze/hongze_open_api/models/tables/admin"
+	"hongze/hongze_open_api/models/tables/chart_permission"
 	"hongze/hongze_open_api/models/tables/company"
 	"hongze/hongze_open_api/models/tables/company_product"
 	"hongze/hongze_open_api/models/tables/company_report_permission"
@@ -351,3 +352,18 @@ func GetValidPermissionIdListByCompany2ProductId(companyId, productId int) (list
 func GetValidPermissionByCompany2ProductId(companyId, productId int) (list []*company_report_permission.CompanyReportPermission, err error) {
 	return company_report_permission.GetPermissionListByCompanyIdAndProductId(companyId, productId)
 }
+
+// GetPermissionNameMap 权限名称与权限ID的map
+func GetPermissionNameMap() (mapItem map[int]string, err error) {
+	list, e := chart_permission.GetChartPermissionListRai()
+	if e != nil {
+		err = e
+		return
+	}
+	mapPermissionName := make(map[int]string)
+	for _, v := range list {
+		mapPermissionName[v.ChartPermissionId] = v.PermissionName
+	}
+	mapItem = mapPermissionName
+	return
+}