|
@@ -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")
|
|
|
|