|
@@ -12,6 +12,9 @@ import (
|
|
|
|
|
|
const (
|
|
|
indexName = "report_index"
|
|
|
+
|
|
|
+ SourceETA = "ETA"
|
|
|
+ SourceHT = "HT"
|
|
|
)
|
|
|
|
|
|
func elastic() *es.ESClient {
|
|
@@ -29,13 +32,14 @@ type ESReport struct {
|
|
|
}
|
|
|
|
|
|
type ReportDTO struct {
|
|
|
- ReportID int `json:"report_id"`
|
|
|
- OrgId int `json:"org_id"`
|
|
|
- Title string `json:"title"`
|
|
|
- Author string `json:"author"`
|
|
|
- Source reportDao.ReportSource `json:"source"`
|
|
|
- Abstract string `json:"abstract"`
|
|
|
- PublishedTime string `json:"published_time"`
|
|
|
+ ReportID int `json:"report_id"`
|
|
|
+ OrgId int `json:"org_id"`
|
|
|
+ Title string `json:"title"`
|
|
|
+ Author string `json:"author"`
|
|
|
+ Source string `json:"source"`
|
|
|
+ Abstract string `json:"abstract"`
|
|
|
+ PublishedTime string `json:"published_time"`
|
|
|
+ PermissionNames interface{} `json:"permissionNames"`
|
|
|
}
|
|
|
|
|
|
type PermissionDTO struct {
|
|
@@ -58,14 +62,31 @@ func GetPermissionList() (dtoList []PermissionDTO, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetReportLabelsById(id int, source reportDao.ReportSource) {
|
|
|
+func GetReportPermissionsById(id int, source string) (permissionIds []PermissionDTO) {
|
|
|
switch source {
|
|
|
- case reportDao.SourceETA:
|
|
|
- //eta.GetReportLabelById()
|
|
|
+ case SourceETA:
|
|
|
+ return getETAReportFirstPermissions(id)
|
|
|
+ case SourceHT:
|
|
|
+ return []PermissionDTO{}
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func getETAReportFirstPermissions(id int) (permissionDTOs []PermissionDTO) {
|
|
|
+ classifyId, err := etaDao.GetReportClassifyById(id)
|
|
|
+ if err != nil || classifyId == 0 {
|
|
|
+ logger.Error("获取研报分类信息失败:%v", err)
|
|
|
return
|
|
|
- case reportDao.SourceHT:
|
|
|
+ }
|
|
|
+ permissions, err := etaDao.GetFirstPermissionsByClassifyID(classifyId)
|
|
|
+ if err != nil {
|
|
|
+ logger.Error("获取研报一级品种信息失败:%v", err)
|
|
|
return
|
|
|
}
|
|
|
+ for _, permission := range permissions {
|
|
|
+ permissionDTOs = append(permissionDTOs, convertPermissionDTO(permission))
|
|
|
+ }
|
|
|
+ return
|
|
|
}
|
|
|
func (es ESReport) GetId() string {
|
|
|
return strconv.Itoa(es.ReportID)
|
|
@@ -106,9 +127,9 @@ func GetListByConditionDesc(column string, limit int) (dtoList []ReportDTO, err
|
|
|
logger.Error("获取研报失败:%v", err)
|
|
|
return
|
|
|
}
|
|
|
- dtoList = []ReportDTO{}
|
|
|
for _, report := range reports {
|
|
|
- dtoList = append(dtoList, convertReportDTO(report))
|
|
|
+ dto := convertReportDTO(report)
|
|
|
+ dtoList = append(dtoList, dto)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -152,7 +173,7 @@ func convertReportDTO(report reportDao.Report) ReportDTO {
|
|
|
Title: report.Title,
|
|
|
OrgId: report.OrgID,
|
|
|
Author: report.Author,
|
|
|
- Source: report.Source,
|
|
|
+ Source: string(report.Source),
|
|
|
Abstract: report.Abstract,
|
|
|
PublishedTime: report.PublishedTime,
|
|
|
}
|