|
@@ -22,6 +22,10 @@ type ChartClassify struct {
|
|
|
Source int `description:"1:ETA图库;2:商品价格曲线"`
|
|
|
IsJoinPermission int `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
|
|
|
ChartClassifyNameEn string `description:"英文分类名称"`
|
|
|
+ RootId int `description:"顶级分类id"`
|
|
|
+ IsSelected int `description:"是否精选资源,0:否;1:是"`
|
|
|
+ ResourceStatus int `description:"在ETA投研资源库中的状态,0:初始状态,1上架,2下架"`
|
|
|
+ LevelPath string `description:"所有的父级分类id"`
|
|
|
}
|
|
|
|
|
|
func AddChartClassify(item *ChartClassify) (lastId int64, err error) {
|
|
@@ -167,6 +171,12 @@ func GetChartClassifyByParentId(parentId, source int) (items []*ChartClassifyIte
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+func GetChartClassifyByParentIdAndIsSelected(parentId, source int, isSelected int) (items []*ChartClassifyItems, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ sql := ` SELECT * FROM chart_classify WHERE parent_id=? AND source = ? AND is_selected = ? order by sort asc,chart_classify_id asc`
|
|
|
+ _, err = o.Raw(sql, parentId, source, isSelected).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
// GetChartClassifyAll
|
|
|
// @param source int 1:ETA图库;2:商品价格曲线;3:相关性图表
|
|
|
func GetChartClassifyAll(source int) (items []*ChartClassifyItems, err error) {
|
|
@@ -176,30 +186,41 @@ func GetChartClassifyAll(source int) (items []*ChartClassifyItems, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// GetChartClassifyAll
|
|
|
+// @param source int 1:ETA图库;2:商品价格曲线;3:相关性图表
|
|
|
+func GetChartClassifyIsSelectedAll(source int, isSelected int) (items []*ChartClassifyItems, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ sql := ` SELECT * FROM chart_classify WHERE parent_id<>0 AND source = ? AND is_selected = ? order by sort asc,chart_classify_id asc`
|
|
|
+ _, err = o.Raw(sql, source, isSelected).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
type ChartClassifyItems struct {
|
|
|
ChartClassifyId int `description:"分类id"`
|
|
|
ChartInfoId int `description:"指标id"`
|
|
|
ChartClassifyName string
|
|
|
ChartClassifyNameEn string
|
|
|
ParentId int
|
|
|
- Level int `description:"层级"`
|
|
|
- Sort int `description:"排序字段,越小越靠前,默认值:10"`
|
|
|
- UniqueCode string `description:"唯一编码"`
|
|
|
- Source int `description:"来源id"`
|
|
|
- SourceName string `description:"来源名称"`
|
|
|
- SysUserId int `description:"创建人id"`
|
|
|
- SysUserRealName string `description:"创建人姓名"`
|
|
|
- DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间"`
|
|
|
- StartDate string `description:"自定义开始日期"`
|
|
|
- EndDate string `description:"自定义结束日期"`
|
|
|
- ChartType int `description:"生成样式:1:曲线图,2:季节性图"`
|
|
|
- Calendar string `description:"公历/农历"`
|
|
|
- SeasonStartDate string `description:"季节性图开始日期"`
|
|
|
- SeasonEndDate string `description:"季节性图开始日期"`
|
|
|
- Children []*ChartClassifyItems
|
|
|
- Button ChartClassifyItemsButton `description:"按钮权限"`
|
|
|
+ Level int `description:"层级"`
|
|
|
+ Sort int `description:"排序字段,越小越靠前,默认值:10"`
|
|
|
+ UniqueCode string `description:"唯一编码"`
|
|
|
+ Source int `description:"来源id"`
|
|
|
+ SourceName string `description:"来源名称"`
|
|
|
+ SysUserId int `description:"创建人id"`
|
|
|
+ SysUserRealName string `description:"创建人姓名"`
|
|
|
+ DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间"`
|
|
|
+ StartDate string `description:"自定义开始日期"`
|
|
|
+ EndDate string `description:"自定义结束日期"`
|
|
|
+ ChartType int `description:"生成样式:1:曲线图,2:季节性图"`
|
|
|
+ Calendar string `description:"公历/农历"`
|
|
|
+ SeasonStartDate string `description:"季节性图开始日期"`
|
|
|
+ SeasonEndDate string `description:"季节性图开始日期"`
|
|
|
+ Children []*ChartClassifyItems `gorm:"-"`
|
|
|
+ Button ChartClassifyItemsButton `gorm:"-" description:"按钮权限"`
|
|
|
IsJoinPermission int `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
|
|
|
HaveOperaAuth bool `description:"是否有数据权限,默认:false"`
|
|
|
+ Disable bool `description:"勾选是否禁用"`
|
|
|
+ IsSelected int `description:"是否精选资源,0:否;1:是"`
|
|
|
+ ResourceStatus int `description:"在ETA投研资源库中的状态,0:初始状态,1上架,2下架"`
|
|
|
}
|
|
|
|
|
|
// ChartClassifyItemsButton 操作按钮
|
|
@@ -433,6 +454,14 @@ func GetChartClassifyAllBySource(source int) (items []*ChartClassifyItems, err e
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// GetChartClassifyAllBySourceIsSelected 根据来源获取所有精选分类
|
|
|
+func GetChartClassifyAllBySourceIsSelected(source int, isSelected int) (items []*ChartClassifyItems, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ sql := ` SELECT * FROM chart_classify WHERE source = ? AND is_selected = ? ORDER BY parent_id ASC, sort ASC, chart_classify_id ASC`
|
|
|
+ _, err = o.Raw(sql, source, isSelected).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// GetChartInfoBySourceAndParentId 根据图表来源及父级ID获取图表
|
|
|
func GetChartInfoBySourceAndParentId(source, parentId, adminId int) (items []*ChartClassifyItems, err error) {
|
|
|
o := orm.NewOrmUsingDB("data")
|
|
@@ -449,3 +478,39 @@ func GetChartInfoBySourceAndParentId(source, parentId, adminId int) (items []*Ch
|
|
|
_, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
|
+// GetChartClassifyInfoSelectedBySource 获取所有的精选目录
|
|
|
+func GetChartClassifyInfoSelectedBySource(source int) (items []*ChartClassify, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ sql := ` SELECT * FROM chart_classify WHERE source = ? AND is_selected = ? ORDER BY parent_id ASC, sort ASC, chart_classify_id ASC`
|
|
|
+ _, err = o.Raw(sql, source, utils.ChartClassifyIsSelected).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func GetChartClassifyByLevelPath(levelPath string, source int) (items []*ChartClassify, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ sql := `SELECT * FROM chart_classify where level_path like '` + levelPath + `%' and source = ?`
|
|
|
+ _, err = o.Raw(sql, source).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func UpdateChartClassifyIsSelected(source int, isSelected int, levelPath string) (err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ sql := `UPDATE chart_classify SET is_selected = ? WHERE source = ? AND level_path LIKE '` + levelPath + `%'`
|
|
|
+ _, err = o.Raw(sql, isSelected, source).Exec()
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func UpdateChartClassifyResourceStatus(source int, resourceStatus int, levelPath string) (err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ sql := `UPDATE chart_classify SET resource_status = ? WHERE source = ? AND level_path LIKE '` + levelPath + `%'`
|
|
|
+ _, err = o.Raw(sql, resourceStatus, source).Exec()
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 查询存在已经上架的图表的分类
|
|
|
+func GetChartClassifyHasUpChartBySource(source int, levelPath string) (count int, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ sql := `SELECT count(1) FROM chart_info WHERE source = ? AND resource_status = ? and chart_classify_id in (SELECT chart_classify_id FROM chart_classify WHERE level_path like '` + levelPath + `%')`
|
|
|
+ err = o.Raw(sql, source, utils.ChartClassifyResourceStatusUp).QueryRow(&count)
|
|
|
+ return
|
|
|
+}
|