ソースを参照

文档管理中心

gmy 5 ヶ月 前
コミット
04b3ab6e4b

+ 43 - 17
controllers/document_manange/document_manage_controller.go

@@ -116,19 +116,11 @@ func (this *DocumentManageController) DocumentReportList() {
 		return
 	}
 
-	chartPermissionId, err := this.GetInt("ChartPermissionId")
-	if err != nil {
-		br.Msg = "获取品种ID失败"
-		br.ErrMsg = "获取品种ID失败,Err:" + err.Error()
-		return
-	}
+	chartPermissionIdString := this.GetString("ChartPermissionIdList")
+	chartPermissionIdList := strings.Split(chartPermissionIdString, ",")
 
-	classifyId, err := this.GetInt("ClassifyId")
-	if err != nil {
-		br.Msg = "获取分类ID失败"
-		br.ErrMsg = "获取分类ID失败,Err:" + err.Error()
-		return
-	}
+	classifyIdString := this.GetString("ClassifyIdList")
+	classifyIdList := strings.Split(classifyIdString, ",")
 
 	keyword := this.GetString("Keyword")
 	orderField := this.GetString("OrderField")
@@ -142,7 +134,7 @@ func (this *DocumentManageController) DocumentReportList() {
 	if currentIndex <= 0 {
 		currentIndex = 1
 	}
-	documentReportPage, err := document_manage_service.DocumentReportList(documentType, chartPermissionId, classifyId, keyword, orderField, orderType, currentIndex, pageSize)
+	documentReportPage, err := document_manage_service.DocumentReportList(documentType, chartPermissionIdList, classifyIdList, keyword, orderField, orderType, currentIndex, pageSize)
 	if err != nil {
 		br.Msg = "获取报告列表失败"
 		br.ErrMsg = "获取报告列表失败,Err:" + err.Error()
@@ -160,7 +152,7 @@ func (this *DocumentManageController) DocumentReportList() {
 // @Title 睿思报告列表
 // @Description 睿思报告列表
 // @Success 200 {object} models.ReportListResp
-// @router /document/report/list [get]
+// @router /document/rui/si/report/list [get]
 func (this *DocumentManageController) RuiSiReportList() {
 	br := new(models.BaseResponse).Init()
 
@@ -168,8 +160,9 @@ func (this *DocumentManageController) RuiSiReportList() {
 		return
 	}
 
-	classifyIdSting := this.GetString("ClassifyIdList")
-	classifyIdList := strings.Split(classifyIdSting, ",")
+	classifyIdFirst, _ := this.GetInt("ClassifyIdFirst", 0)
+	classifyIdSecond, _ := this.GetInt("ClassifyIdSecond", 0)
+	classifyIdThird, _ := this.GetInt("ClassifyIdThird", 0)
 
 	keyword := this.GetString("Keyword")
 	orderField := this.GetString("OrderField")
@@ -183,7 +176,7 @@ func (this *DocumentManageController) RuiSiReportList() {
 	if currentIndex <= 0 {
 		currentIndex = 1
 	}
-	RuiSiReportPage, err := document_manage_service.RuiSiReportList(classifyIdList, keyword, orderField, orderType, currentIndex, pageSize)
+	RuiSiReportPage, err := document_manage_service.RuiSiReportList(classifyIdFirst, classifyIdSecond, classifyIdThird, keyword, orderField, orderType, currentIndex, pageSize)
 	if err != nil {
 		br.Msg = "获取报告列表失败"
 		br.ErrMsg = "获取报告列表失败,Err:" + err.Error()
@@ -197,6 +190,39 @@ func (this *DocumentManageController) RuiSiReportList() {
 	return
 }
 
+// DocumentRuiSiDetail
+// @Title 睿思报告详情
+// @Description 睿思报告详情
+// @Success 200 “获取成功”
+// @router /document/rui/si/detail [get]
+func (this *DocumentManageController) DocumentRuiSiDetail() {
+	br := new(models.BaseResponse).Init()
+
+	if !HandleResponseWithValidation(this, br) {
+		return
+	}
+	// 获取指标数据列表
+	this.GetString("DocumentRuiSiDetail")
+
+	reportId, err := this.GetInt("ReportId")
+	if err != nil {
+		br.Msg = "获取报告ID失败"
+		br.ErrMsg = "获取报告ID失败,Err:" + err.Error()
+		return
+	}
+
+	reportDetail, err := document_manage_service.DocumentRuiSiDetail(reportId)
+	if err != nil {
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = &reportDetail
+	return
+}
+
 // DocumentSave
 // @Title 新建文档
 // @Description 新建文档

+ 12 - 1
models/chart_permission.go

@@ -39,11 +39,22 @@ type ChartPermission struct {
 	IsPublic              int       `description:"是否是公有权限1:公有权限,0私有权限" json:"is_public"`
 }
 
+type ChartPermissionVO struct {
+	ChartPermissionId   int       `orm:"column(chart_permission_id);pk" description:"问题ID" json:"chart_permission_id"`
+	ChartPermissionName string    `description:"名称" json:"chart_permission_name"`
+	PermissionName      string    `description:"权限名" json:"permission_name"`
+	Sort                int       `description:"排序" json:"sort"`
+	Enabled             int       `description:"是否可用" json:"enabled"`
+	CreatedTime         time.Time `description:"创建时间" json:"created_time"`
+	LastUpdatedTime     time.Time `description:"更新时间" json:"last_updated_time"`
+	ParentId            int       `description:"父级权限id" json:"parent_id"`
+	Children            []*ChartPermissionVO
+}
+
 type ChartPermissionItem struct {
 	PermissionId   int    `description:"品种权限ID"`
 	PermissionName string `description:"品种权限名称"`
 	ParentId       int    `description:"父级ID"`
-	IsPublic       int    `description:"是否是公有权限1:公有权限,0私有权限" `
 	Enabled        int    `description:"是否可用:1可用,0不可用" `
 	Sort           int    `description:"排序"`
 	CreateTime     string `description:"创建时间"`

+ 5 - 5
models/document_manage_model/outside_report.go

@@ -48,8 +48,8 @@ func init() {
 // GetOutsideReportListByConditionCount 根据条件查询列表条数
 func GetOutsideReportListByConditionCount(condition string, pars []interface{}) (count int, err error) {
 	o := orm.NewOrmUsingDB("rddp")
-	sql := `select count(1) from outside_report t1 inner join chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id  where 1 = 1 `
-	sql += sql + condition
+	sql := `select count(1) from outside_report t1 left join chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id  where 1 = 1 `
+	sql += condition
 	err = o.Raw(sql, pars).QueryRow(&count)
 	if err != nil {
 		return 0, err
@@ -61,14 +61,14 @@ func GetOutsideReportListByConditionCount(condition string, pars []interface{})
 // GetOutsideReportListByCondition 根据条件查询列表
 func GetOutsideReportListByCondition(condition string, pars []interface{}) (list []OutsideReport, err error) {
 	o := orm.NewOrmUsingDB("rddp")
-	sql := `select * from outside_report t1 inner join chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id  where 1 = 1 `
-	sql += sql + condition
+	sql := `select * from outside_report t1 inner left chart_permission_search_key_word_mapping t2 on t1.classify_id = t2.classify_id  where 1 = 1 `
+	sql += condition
 	_, err = o.Raw(sql, pars).QueryRows(&list)
 	if err != nil {
 		return nil, err
 	}
 
-	return nil, err
+	return list, err
 }
 
 // SaveOutsideReport 保存报告

+ 86 - 24
services/document_manage_service/document_manage_service.go

@@ -57,7 +57,7 @@ func getChildClassify(classifyList []*models.ClassifyList, classifyId int) *[]mo
 	return &childList
 }
 
-func DocumentVarietyList() ([]*models.ChartPermission, error) {
+func DocumentVarietyList() ([]models.ChartPermissionVO, error) {
 	logs.Info("DocumentVarietyList")
 
 	cp := new(models.ChartPermission)
@@ -72,10 +72,47 @@ func DocumentVarietyList() ([]*models.ChartPermission, error) {
 		return nil, err
 	}
 
-	return chartPermissionList, nil
+	// 递归处理品种 拿到父级品种和对应的子级品种
+	permissionVOList := make([]models.ChartPermissionVO, 0)
+	for _, chartPermission := range chartPermissionList {
+		if chartPermission.ParentId == 0 {
+			permissionVO := models.ChartPermissionVO{
+				ChartPermissionId:   chartPermission.ChartPermissionId,
+				ChartPermissionName: chartPermission.ChartPermissionName,
+				ParentId:            chartPermission.ParentId,
+				Enabled:             chartPermission.Enabled,
+				Sort:                chartPermission.Sort,
+				CreatedTime:         chartPermission.CreatedTime,
+			}
+			permissionVO.Children = getChildVariety(chartPermissionList, permissionVO.ChartPermissionId)
+			permissionVOList = append(permissionVOList, permissionVO)
+		}
+	}
+
+	return permissionVOList, nil
 }
 
-func DocumentReportList(documentType, chartPermissionId, classifyId int, keyword string, orderField, orderType string, startSize, pageSize int) (*document_manage_model.OutsideReportPage, error) {
+func getChildVariety(permissionList []*models.ChartPermission, permissionId int) []*models.ChartPermissionVO {
+	childList := make([]*models.ChartPermissionVO, 0)
+	for _, permission := range permissionList {
+		if permission.ParentId == permissionId {
+			permissionVO := models.ChartPermissionVO{
+				ChartPermissionId:   permission.ChartPermissionId,
+				ChartPermissionName: permission.ChartPermissionName,
+				ParentId:            permission.ParentId,
+				Enabled:             permission.Enabled,
+				Sort:                permission.Sort,
+				CreatedTime:         permission.CreatedTime,
+			}
+			permissionVO.Children = getChildVariety(permissionList, permissionVO.ChartPermissionId)
+			childList = append(childList, &permissionVO)
+		}
+	}
+	return childList
+
+}
+
+func DocumentReportList(documentType int, chartPermissionIdList []string, classifyIdList []string, keyword string, orderField, orderType string, startSize, pageSize int) (*document_manage_model.OutsideReportPage, error) {
 	logs.Info("DocumentVarietyList")
 
 	var condition string
@@ -84,13 +121,17 @@ func DocumentReportList(documentType, chartPermissionId, classifyId int, keyword
 	if documentType == 1 {
 		condition = ` and t1.source!=3`
 	}
-	if classifyId > 0 {
-		condition += ` and t1.classify_id=?`
-		pars = append(pars, classifyId)
+	if len(classifyIdList) > 0 {
+		condition += ` and t1.classify_id in (` + utils.GetOrmInReplace(len(classifyIdList)) + `)`
+		for _, classifyId := range classifyIdList {
+			pars = append(pars, classifyId)
+		}
 	}
-	if chartPermissionId > 0 {
-		condition += ` and t2.chart_permission_id=?`
-		pars = append(pars, chartPermissionId)
+	if len(chartPermissionIdList) > 0 {
+		condition += ` and t2.chart_permission_id in (` + utils.GetOrmInReplace(len(chartPermissionIdList)) + `)`
+		for _, chartPermissionId := range chartPermissionIdList {
+			pars = append(pars, chartPermissionId)
+		}
 	}
 	if keyword != "" {
 		condition += ` and t1.title like ? or t1.sys_user_name like ?`
@@ -110,7 +151,7 @@ func DocumentReportList(documentType, chartPermissionId, classifyId int, keyword
 	}
 
 	if orderField != "" && orderType != "" {
-		condition += ` order by ` + orderField + ` ` + orderType
+		condition += ` order by t1.` + orderField + ` ` + orderType
 	} else {
 		condition += ` order by t1.modify_time desc`
 	}
@@ -125,30 +166,39 @@ func DocumentReportList(documentType, chartPermissionId, classifyId int, keyword
 	return &reportPage, nil
 }
 
-func RuiSiReportList(classifyList []string, keyword string, orderField, orderType string, startSize, pageSize int) (*models.ReportListResp, error) {
+func RuiSiReportList(classifyIdFirst, classifyIdSecond, classifyIdThird int, keyword string, orderField, orderType string, startSize, pageSize int) (*models.ReportListResp, error) {
 	logs.Info("RuiSiReportList")
 
 	var condition string
 	pars := make([]interface{}, 0)
 
-	if len(classifyList) > 0 {
-		// 查询所有子级分类
-
-		condition += ` and t1.classify_id in (` + utils.GetOrmInReplace(len(classifyList)) + `)`
-
+	if classifyIdFirst > 0 {
+		condition += ` AND a.classify_id_first = ? `
+		pars = append(pars, classifyIdFirst)
+	}
+	if classifyIdSecond > 0 {
+		condition += ` AND a.classify_id_second = ? `
+		pars = append(pars, classifyIdSecond)
+	}
+	if classifyIdThird > 0 {
+		condition += ` AND a.classify_id_third = ? `
+		pars = append(pars, classifyIdThird)
 	}
 	if keyword != "" {
-		condition += ` and t1.title like ? or t1.sys_user_name like ?`
+		condition += ` and a.title like ? or a.admin_real_name like ?`
 		pars = append(pars, "%"+keyword+"%", "%"+keyword+"%")
 	}
 
-	models.GetReportListCountV1(condition, pars)
+	// 作者为 全球市场战略研究中心 PCI Research
+	condition += ` and a.author = '全球市场战略研究中心 PCI Research'`
+	// 已发布的报告
+	condition += ` and a.enabled = 2`
 
-	count, err := document_manage_model.GetOutsideReportListByConditionCount(condition, pars)
+	count, err := models.GetReportListCountV1(condition, pars)
 	if err != nil {
 		return nil, err
 	}
-	reportPage := document_manage_model.OutsideReportPage{}
+	reportPage := models.ReportListResp{}
 
 	page := paging.GetPaging(startSize, pageSize, count)
 	if count <= 0 {
@@ -157,21 +207,33 @@ func RuiSiReportList(classifyList []string, keyword string, orderField, orderTyp
 	}
 
 	if orderField != "" && orderType != "" {
-		condition += ` order by ` + orderField + ` ` + orderType
+		condition += ` order by a.` + orderField + ` ` + orderType
 	} else {
-		condition += ` order by t1.modify_time desc`
+		condition += ` order by a.publish_time desc`
 	}
 
-	outsideReportList, err := document_manage_model.GetOutsideReportListByCondition(condition, pars)
+	reportList, err := models.GetReportListV1(condition, pars, startSize, pageSize)
 	if err != nil {
 		return nil, err
 	}
+
 	reportPage.Paging = page
-	reportPage.List = outsideReportList
+	reportPage.List = reportList
 
 	return &reportPage, nil
 }
 
+func DocumentRuiSiDetail(reportId int) (*models.ReportDetail, error) {
+	logs.Info("DocumentRuiSiDetail")
+
+	reportDetail, err := models.GetReportById(reportId)
+	if err != nil {
+		return nil, err
+	}
+
+	return reportDetail, nil
+}
+
 func DocumentSave(outsideReport *document_manage_model.OutsideReportBO) error {
 	logs.Info("DocumentSave")