|
@@ -1,46 +1,47 @@
|
|
package models
|
|
package models
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "eta_gn/eta_api/global"
|
|
"eta_gn/eta_api/utils"
|
|
"eta_gn/eta_api/utils"
|
|
"fmt"
|
|
"fmt"
|
|
- "github.com/beego/beego/v2/client/orm"
|
|
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
type ReportChapterType struct {
|
|
type ReportChapterType struct {
|
|
- ReportChapterTypeId int `orm:"column(report_chapter_type_id);pk" description:"报告章节类型id"`
|
|
|
|
- ReportChapterTypeKey string `description:"章节key"`
|
|
|
|
- ReportChapterTypeThumb string `description:"H5展示的图片"`
|
|
|
|
- BannerUrl string `description:"banner显示图片"`
|
|
|
|
- ReportChapterTypeName string `description:"报告章节类型名称"`
|
|
|
|
- Sort int `description:"排序字段"`
|
|
|
|
- Enabled int `description:"启禁用状态"`
|
|
|
|
- CreatedTime time.Time `description:"创建时间"`
|
|
|
|
- LastUpdatedTime time.Time `description:"更新时间"`
|
|
|
|
- ResearchType string `description:"研报类型"`
|
|
|
|
- SelectedImage string `description:"选中时的图片"`
|
|
|
|
- UnselectedImage string `description:"没选中时的图片"`
|
|
|
|
- PcSelectedImage string `description:"PC-选中的图片"`
|
|
|
|
- PcUnselectedImage string `description:"PC-未选中的图片"`
|
|
|
|
- EditImgUrl string `description:"管理后台编辑时选用的图"`
|
|
|
|
- TickerTitle string `description:"指标列的标题"`
|
|
|
|
- IsShow int `description:"是否显示(研报小程序端根据此字段判断)"`
|
|
|
|
- PauseStartTime string `description:"暂停开始日期"`
|
|
|
|
- PauseEndTime string `description:"暂停结束日期"`
|
|
|
|
- IsSet int `description:"是否设置:0为设置,1已设置"`
|
|
|
|
- YbIconUrl string `description:"研报小程序icon"`
|
|
|
|
- YbBottomIcon string `description:"研报小程序详情底部icon"`
|
|
|
|
- ReportClassifyId int `description:"所属分类id"`
|
|
|
|
- InheritReportChapterTypeId int `description:"继承的报告章节类型id"`
|
|
|
|
|
|
+ ReportChapterTypeId int `gorm:"column:report_chapter_type_id"` //`orm:"column(report_chapter_type_id);pk" description:"报告章节类型id"`
|
|
|
|
+ ReportChapterTypeKey string `gorm:"column:report_chapter_type_key"` //`description:"章节key"`
|
|
|
|
+ ReportChapterTypeThumb string `gorm:"column:report_chapter_type_thumb"` //`description:"H5展示的图片"`
|
|
|
|
+ BannerUrl string `gorm:"column:banner_url"` //`description:"banner显示图片"`
|
|
|
|
+ ReportChapterTypeName string `gorm:"column:report_chapter_type_name"` //`description:"报告章节类型名称"`
|
|
|
|
+ Sort int `gorm:"column:sort"` //`description:"排序字段"`
|
|
|
|
+ Enabled int `gorm:"column:enabled"` //`description:"启禁用状态"`
|
|
|
|
+ CreatedTime time.Time `gorm:"column:created_time"` //`description:"创建时间"`
|
|
|
|
+ LastUpdatedTime time.Time `gorm:"column:last_updated_time"` //`description:"更新时间"`
|
|
|
|
+ ResearchType string `gorm:"column:research_type"` //`description:"研报类型"`
|
|
|
|
+ SelectedImage string `gorm:"column:selected_image"` //`description:"选中时的图片"`
|
|
|
|
+ UnselectedImage string `gorm:"column:unselected_image"` //`description:"没选中时的图片"`
|
|
|
|
+ PcSelectedImage string `gorm:"column:pc_selected_image"` //`description:"PC-选中的图片"`
|
|
|
|
+ PcUnselectedImage string `gorm:"column:pc_unselected_image"` //`description:"PC-未选中的图片"`
|
|
|
|
+ EditImgUrl string `gorm:"column:edit_img_url"` //`description:"管理后台编辑时选用的图"`
|
|
|
|
+ TickerTitle string `gorm:"column:ticker_title"` //`description:"指标列的标题"`
|
|
|
|
+ IsShow int `gorm:"column:is_show"` //`description:"是否显示(研报小程序端根据此字段判断)"`
|
|
|
|
+ PauseStartTime string `gorm:"column:pause_start_time"` //`description:"暂停开始日期"`
|
|
|
|
+ PauseEndTime string `gorm:"column:pause_end_time"` //`description:"暂停结束日期"`
|
|
|
|
+ IsSet int `gorm:"column:is_set"` //`description:"是否设置:0为设置,1已设置"`
|
|
|
|
+ YbIconUrl string `gorm:"column:yb_icon_url"` // `description:"研报小程序icon"`
|
|
|
|
+ YbBottomIcon string `gorm:"column:yb_bottom_icon"` // `description:"研报小程序详情底部icon"`
|
|
|
|
+ ReportClassifyId int `gorm:"column:report_classify_id"` // `description:"所属分类id"`
|
|
|
|
+ InheritReportChapterTypeId int `gorm:"column:inherit_report_chapter_type_id"` // `description:"继承的报告章节类型id"`
|
|
}
|
|
}
|
|
|
|
|
|
func (r *ReportChapterType) Create() (err error) {
|
|
func (r *ReportChapterType) Create() (err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
- id, err := o.Insert(r)
|
|
|
|
- if err != nil {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- r.ReportChapterTypeId = int(id)
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
|
+ //id, err := o.Insert(r)
|
|
|
|
+ //if err != nil {
|
|
|
|
+ // return
|
|
|
|
+ //}
|
|
|
|
+ //r.ReportChapterTypeId = int(id)
|
|
|
|
+ err = global.DmSQL["rddp"].Create(r).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -55,22 +56,24 @@ func (r *ReportChapterType) MultiCreate(addList []*ReportChapterType) (err error
|
|
if len(addList) <= 0 {
|
|
if len(addList) <= 0 {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
- _, err = o.InsertMulti(500, addList)
|
|
|
|
-
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
|
+ //_, err = o.InsertMulti(500, addList)
|
|
|
|
+ err = global.DmSQL["rddp"].CreateInBatches(addList, utils.MultiAddNum).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
func (r *ReportChapterType) Update(cols []string) (err error) {
|
|
func (r *ReportChapterType) Update(cols []string) (err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
- _, err = o.Update(r, cols...)
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
|
+ //_, err = o.Update(r, cols...)
|
|
|
|
+ err = global.DmSQL["rddp"].Model(r).Select(cols).Updates(r).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// DeleteReportChapterType 删除章节类型及相关权限
|
|
// DeleteReportChapterType 删除章节类型及相关权限
|
|
func DeleteReportChapterType(typeId int, reportType string) (err error) {
|
|
func DeleteReportChapterType(typeId int, reportType string) (err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
- to, err := o.Begin()
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
|
+ //to, err := o.Begin()
|
|
|
|
+ to := global.DmSQL["rddp"].Begin()
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -84,64 +87,70 @@ func DeleteReportChapterType(typeId int, reportType string) (err error) {
|
|
|
|
|
|
// 删除章节类型
|
|
// 删除章节类型
|
|
sql := `DELETE FROM report_chapter_type WHERE report_chapter_type_id = ? LIMIT 1`
|
|
sql := `DELETE FROM report_chapter_type WHERE report_chapter_type_id = ? LIMIT 1`
|
|
- _, err = to.Raw(sql, typeId).Exec()
|
|
|
|
-
|
|
|
|
|
|
+ //_, err = to.Raw(sql, typeId).Exec()
|
|
|
|
+ err = to.Exec(sql, typeId).Error
|
|
// 删除章节类型权限
|
|
// 删除章节类型权限
|
|
sql = `DELETE FROM report_chapter_type_permission WHERE report_chapter_type_id = ?`
|
|
sql = `DELETE FROM report_chapter_type_permission WHERE report_chapter_type_id = ?`
|
|
- _, err = to.Raw(sql, typeId).Exec()
|
|
|
|
-
|
|
|
|
|
|
+ //_, err = to.Raw(sql, typeId).Exec()
|
|
|
|
+ err = to.Exec(sql, typeId).Error
|
|
// 周报-删除实际权限
|
|
// 周报-删除实际权限
|
|
if reportType == utils.REPORT_TYPE_WEEK {
|
|
if reportType == utils.REPORT_TYPE_WEEK {
|
|
sql = `DELETE FROM chart_permission_chapter_mapping WHERE report_chapter_type_id = ? AND research_type = ?`
|
|
sql = `DELETE FROM chart_permission_chapter_mapping WHERE report_chapter_type_id = ? AND research_type = ?`
|
|
- _, err = to.Raw(sql, typeId, reportType).Exec()
|
|
|
|
|
|
+ //_, err = to.Raw(sql, typeId, reportType).Exec()
|
|
|
|
+ err = to.Exec(sql, typeId, reportType).Error
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetReportChapterTypeById 获取章节类型
|
|
// GetReportChapterTypeById 获取章节类型
|
|
func GetReportChapterTypeById(reportChapterTypeId int) (item *ReportChapterType, err error) {
|
|
func GetReportChapterTypeById(reportChapterTypeId int) (item *ReportChapterType, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` SELECT * FROM report_chapter_type WHERE report_chapter_type_id = ? `
|
|
sql := ` SELECT * FROM report_chapter_type WHERE report_chapter_type_id = ? `
|
|
- err = o.Raw(sql, reportChapterTypeId).QueryRow(&item)
|
|
|
|
|
|
+ //err = o.Raw(sql, reportChapterTypeId).QueryRow(&item)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, reportChapterTypeId).First(&item).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetReportChapterTypeList 获取章节类型列表
|
|
// GetReportChapterTypeList 获取章节类型列表
|
|
func GetReportChapterTypeList() (list []*ReportChapterType, err error) {
|
|
func GetReportChapterTypeList() (list []*ReportChapterType, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` SELECT * FROM report_chapter_type WHERE enabled = 1 `
|
|
sql := ` SELECT * FROM report_chapter_type WHERE enabled = 1 `
|
|
- _, err = o.Raw(sql).QueryRows(&list)
|
|
|
|
|
|
+ //_, err = o.Raw(sql).QueryRows(&list)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql).Find(&list).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetReportChapterTypeListByResearchType 通过报告类型获取章节类型列表
|
|
// GetReportChapterTypeListByResearchType 通过报告类型获取章节类型列表
|
|
func GetReportChapterTypeListByResearchType(researchType string) (list []*ReportChapterType, err error) {
|
|
func GetReportChapterTypeListByResearchType(researchType string) (list []*ReportChapterType, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` SELECT * FROM report_chapter_type WHERE research_type = ? AND enabled = 1`
|
|
sql := ` SELECT * FROM report_chapter_type WHERE research_type = ? AND enabled = 1`
|
|
- _, err = o.Raw(sql, researchType).QueryRows(&list)
|
|
|
|
|
|
+ //_, err = o.Raw(sql, researchType).QueryRows(&list)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, researchType).Find(&list).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetAllReportChapterTypeListByResearchType 通过报告类型获取章节类型列表
|
|
// GetAllReportChapterTypeListByResearchType 通过报告类型获取章节类型列表
|
|
func GetAllReportChapterTypeListByResearchType(researchType string) (list []*ReportChapterType, err error) {
|
|
func GetAllReportChapterTypeListByResearchType(researchType string) (list []*ReportChapterType, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` SELECT * FROM report_chapter_type WHERE research_type = ?`
|
|
sql := ` SELECT * FROM report_chapter_type WHERE research_type = ?`
|
|
- _, err = o.Raw(sql, researchType).QueryRows(&list)
|
|
|
|
|
|
+ //_, err = o.Raw(sql, researchType).QueryRows(&list)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, researchType).Find(&list).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetAllReportChapterTypeList 通过传入的条件获取所有的章节类型列表
|
|
// GetAllReportChapterTypeList 通过传入的条件获取所有的章节类型列表
|
|
func GetAllReportChapterTypeList(condition string, pars []interface{}) (list []*ReportChapterType, err error) {
|
|
func GetAllReportChapterTypeList(condition string, pars []interface{}) (list []*ReportChapterType, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` SELECT * FROM report_chapter_type WHERE 1=1 `
|
|
sql := ` SELECT * FROM report_chapter_type WHERE 1=1 `
|
|
sql += condition
|
|
sql += condition
|
|
- _, err = o.Raw(sql, pars).QueryRows(&list)
|
|
|
|
|
|
+ //_, err = o.Raw(sql, pars).QueryRows(&list)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, pars).Find(&list).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetEnableReportChapterTypeList 获取未暂停的章节类型列表
|
|
// GetEnableReportChapterTypeList 获取未暂停的章节类型列表
|
|
func GetEnableReportChapterTypeList(researchType string) (list []*ReportChapterType, err error) {
|
|
func GetEnableReportChapterTypeList(researchType string) (list []*ReportChapterType, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` SELECT
|
|
sql := ` SELECT
|
|
*
|
|
*
|
|
FROM
|
|
FROM
|
|
@@ -157,22 +166,24 @@ func GetEnableReportChapterTypeList(researchType string) (list []*ReportChapterT
|
|
NOW() NOT BETWEEN pause_start_time AND pause_end_time
|
|
NOW() NOT BETWEEN pause_start_time AND pause_end_time
|
|
)
|
|
)
|
|
) `
|
|
) `
|
|
- _, err = o.Raw(sql, researchType).QueryRows(&list)
|
|
|
|
|
|
+ //_, err = o.Raw(sql, researchType).QueryRows(&list)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, researchType).Find(&list).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// DayWeekReportPauseTime 晨报周报暂停时间
|
|
// DayWeekReportPauseTime 晨报周报暂停时间
|
|
type DayWeekReportPauseTime struct {
|
|
type DayWeekReportPauseTime struct {
|
|
- ResearchType string `description:"报告类型 day; week;"`
|
|
|
|
- PauseStartTime string `description:"暂停开始时间"`
|
|
|
|
- PauseEndTime string `description:"暂停结束时间"`
|
|
|
|
|
|
+ ResearchType string `gorm:"column:research_type"` //`description:"报告类型 day; week;"`
|
|
|
|
+ PauseStartTime string `gorm:"column:pause_start_time"` //`description:"暂停开始时间"`
|
|
|
|
+ PauseEndTime string `gorm:"column:pause_end_time"` //`description:"暂停结束时间"`
|
|
}
|
|
}
|
|
|
|
|
|
// GetDayWeekReportPauseTimeList 获取晨报周报暂停时间
|
|
// GetDayWeekReportPauseTimeList 获取晨报周报暂停时间
|
|
func GetDayWeekReportPauseTimeList() (list []*DayWeekReportPauseTime, err error) {
|
|
func GetDayWeekReportPauseTimeList() (list []*DayWeekReportPauseTime, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` SELECT research_type, MAX(a.pause_start_time) AS pause_start_time, MAX(a.pause_end_time) AS pause_end_time FROM report_chapter_type AS a WHERE a.is_set = 1 GROUP BY a.research_type`
|
|
sql := ` SELECT research_type, MAX(a.pause_start_time) AS pause_start_time, MAX(a.pause_end_time) AS pause_end_time FROM report_chapter_type AS a WHERE a.is_set = 1 GROUP BY a.research_type`
|
|
- _, err = o.Raw(sql).QueryRows(&list)
|
|
|
|
|
|
+ //_, err = o.Raw(sql).QueryRows(&list)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql).Find(&list).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -183,9 +194,9 @@ type SetDayWeekReportUpdateRuleReq struct {
|
|
}
|
|
}
|
|
|
|
|
|
type DayWeekReportUpdateRule struct {
|
|
type DayWeekReportUpdateRule struct {
|
|
- ReportChapterTypeId int `description:"章节类型ID"`
|
|
|
|
- PauseStartTime string `description:"暂停开始时间"`
|
|
|
|
- PauseEndTime string `description:"暂停结束时间"`
|
|
|
|
|
|
+ ReportChapterTypeId int `gorm:"column:report_chapter_type_id"` //`description:"章节类型ID"`
|
|
|
|
+ PauseStartTime string `gorm:"column:pause_start_time"` //`description:"暂停开始时间"`
|
|
|
|
+ PauseEndTime string `gorm:"column:pause_end_time"` //`description:"暂停结束时间"`
|
|
}
|
|
}
|
|
|
|
|
|
// SetDayWeekReportEnableUpdateRuleReq 设置章节类型的永久暂停请求体
|
|
// SetDayWeekReportEnableUpdateRuleReq 设置章节类型的永久暂停请求体
|
|
@@ -196,16 +207,18 @@ type SetDayWeekReportEnableUpdateRuleReq struct {
|
|
|
|
|
|
// ResetDayWeekReportUpdateRule 重置章节类型的暂停时间
|
|
// ResetDayWeekReportUpdateRule 重置章节类型的暂停时间
|
|
func ResetDayWeekReportUpdateRule(researchType string) (err error) {
|
|
func ResetDayWeekReportUpdateRule(researchType string) (err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` UPDATE report_chapter_type SET pause_start_time = null, pause_end_time = null, is_set = 0 WHERE research_type = ?`
|
|
sql := ` UPDATE report_chapter_type SET pause_start_time = null, pause_end_time = null, is_set = 0 WHERE research_type = ?`
|
|
- _, err = o.Raw(sql, researchType).Exec()
|
|
|
|
|
|
+ //_, err = o.Raw(sql, researchType).Exec()
|
|
|
|
+ err = global.DmSQL["rddp"].Exec(sql, researchType).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// SetDayWeekReportUpdateRule 设置章节类型的暂停时间
|
|
// SetDayWeekReportUpdateRule 设置章节类型的暂停时间
|
|
func SetDayWeekReportUpdateRule(researchType string, list []DayWeekReportUpdateRule) (err error) {
|
|
func SetDayWeekReportUpdateRule(researchType string, list []DayWeekReportUpdateRule) (err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
- to, err := o.Begin()
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
|
+ //to, err := o.Begin()
|
|
|
|
+ to := global.DmSQL["rddp"].Begin()
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -219,7 +232,8 @@ func SetDayWeekReportUpdateRule(researchType string, list []DayWeekReportUpdateR
|
|
|
|
|
|
// 先将所有品种的状态变更为启用
|
|
// 先将所有品种的状态变更为启用
|
|
sql := ` UPDATE report_chapter_type SET pause_start_time = null, pause_end_time = null, is_set = 0 WHERE research_type = ?`
|
|
sql := ` UPDATE report_chapter_type SET pause_start_time = null, pause_end_time = null, is_set = 0 WHERE research_type = ?`
|
|
- _, err = to.Raw(sql, researchType).Exec()
|
|
|
|
|
|
+ //_, err = to.Raw(sql, researchType).Exec()
|
|
|
|
+ err = global.DmSQL["rddp"].Exec(sql, researchType).Error
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -229,7 +243,8 @@ func SetDayWeekReportUpdateRule(researchType string, list []DayWeekReportUpdateR
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
tmpSql := ` UPDATE report_chapter_type SET pause_start_time = ?, pause_end_time = ?, is_set = 1 WHERE research_type = ? AND report_chapter_type_id = ? `
|
|
tmpSql := ` UPDATE report_chapter_type SET pause_start_time = ?, pause_end_time = ?, is_set = 1 WHERE research_type = ? AND report_chapter_type_id = ? `
|
|
- _, err = to.Raw(tmpSql, v.PauseStartTime, v.PauseEndTime, researchType, v.ReportChapterTypeId).Exec()
|
|
|
|
|
|
+ //_, err = to.Raw(tmpSql, v.PauseStartTime, v.PauseEndTime, researchType, v.ReportChapterTypeId).Exec()
|
|
|
|
+ err = global.DmSQL["rddp"].Exec(tmpSql, v.PauseStartTime, v.PauseEndTime, researchType, v.ReportChapterTypeId).Error
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -240,8 +255,9 @@ func SetDayWeekReportUpdateRule(researchType string, list []DayWeekReportUpdateR
|
|
|
|
|
|
// SetDayWeekReportEnableUpdateRule 设置章节类型的禁用状态
|
|
// SetDayWeekReportEnableUpdateRule 设置章节类型的禁用状态
|
|
func SetDayWeekReportEnableUpdateRule(dayReportChapterTypeIdList, weekReportChapterTypeIdList []string) (err error) {
|
|
func SetDayWeekReportEnableUpdateRule(dayReportChapterTypeIdList, weekReportChapterTypeIdList []string) (err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
- to, err := o.Begin()
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
|
+ //to, err := o.Begin()
|
|
|
|
+ to := global.DmSQL["rddp"].Begin()
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -256,7 +272,8 @@ func SetDayWeekReportEnableUpdateRule(dayReportChapterTypeIdList, weekReportChap
|
|
researchType := `day`
|
|
researchType := `day`
|
|
// 先将所有品种的状态变更为启用
|
|
// 先将所有品种的状态变更为启用
|
|
sql := ` UPDATE report_chapter_type SET enabled = 1 WHERE research_type = ?`
|
|
sql := ` UPDATE report_chapter_type SET enabled = 1 WHERE research_type = ?`
|
|
- _, err = to.Raw(sql, researchType).Exec()
|
|
|
|
|
|
+ //_, err = to.Raw(sql, researchType).Exec()
|
|
|
|
+ err = global.DmSQL["rddp"].Exec(sql, researchType).Error
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -265,7 +282,8 @@ func SetDayWeekReportEnableUpdateRule(dayReportChapterTypeIdList, weekReportChap
|
|
num := len(dayReportChapterTypeIdList)
|
|
num := len(dayReportChapterTypeIdList)
|
|
if num > 0 {
|
|
if num > 0 {
|
|
sql = ` UPDATE report_chapter_type SET pause_start_time = null, pause_end_time = null, is_set = 0 , enabled = 0 WHERE research_type = ? AND report_chapter_type_id IN (` + utils.GetOrmInReplace(num) + `) `
|
|
sql = ` UPDATE report_chapter_type SET pause_start_time = null, pause_end_time = null, is_set = 0 , enabled = 0 WHERE research_type = ? AND report_chapter_type_id IN (` + utils.GetOrmInReplace(num) + `) `
|
|
- _, err = to.Raw(sql, researchType, dayReportChapterTypeIdList).Exec()
|
|
|
|
|
|
+ //_, err = to.Raw(sql, researchType, dayReportChapterTypeIdList).Exec()
|
|
|
|
+ err = global.DmSQL["rddp"].Exec(sql, researchType, dayReportChapterTypeIdList).Error
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -273,7 +291,8 @@ func SetDayWeekReportEnableUpdateRule(dayReportChapterTypeIdList, weekReportChap
|
|
researchType := `week`
|
|
researchType := `week`
|
|
// 先将所有品种的状态变更为启用
|
|
// 先将所有品种的状态变更为启用
|
|
sql := ` UPDATE report_chapter_type SET enabled = 1 WHERE research_type = ?`
|
|
sql := ` UPDATE report_chapter_type SET enabled = 1 WHERE research_type = ?`
|
|
- _, err = to.Raw(sql, researchType).Exec()
|
|
|
|
|
|
+ //_, err = to.Raw(sql, researchType).Exec()
|
|
|
|
+ err = global.DmSQL["rddp"].Exec(sql, researchType).Error
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -282,7 +301,8 @@ func SetDayWeekReportEnableUpdateRule(dayReportChapterTypeIdList, weekReportChap
|
|
num := len(weekReportChapterTypeIdList)
|
|
num := len(weekReportChapterTypeIdList)
|
|
if num > 0 {
|
|
if num > 0 {
|
|
sql = ` UPDATE report_chapter_type SET pause_start_time = null, pause_end_time = null, is_set = 0 , enabled = 0 WHERE research_type = ? AND report_chapter_type_id IN (` + utils.GetOrmInReplace(num) + `) `
|
|
sql = ` UPDATE report_chapter_type SET pause_start_time = null, pause_end_time = null, is_set = 0 , enabled = 0 WHERE research_type = ? AND report_chapter_type_id IN (` + utils.GetOrmInReplace(num) + `) `
|
|
- _, err = to.Raw(sql, researchType, weekReportChapterTypeIdList).Exec()
|
|
|
|
|
|
+ //_, err = to.Raw(sql, researchType, weekReportChapterTypeIdList).Exec()
|
|
|
|
+ err = global.DmSQL["rddp"].Exec(sql, researchType, weekReportChapterTypeIdList).Error
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return
|
|
return
|
|
@@ -298,17 +318,19 @@ type StopUpdateReportChapterTypeResp struct {
|
|
|
|
|
|
// GetStopUpdateReportChapterTypeListByResearchType 获取暂停更新章节类型列表
|
|
// GetStopUpdateReportChapterTypeListByResearchType 获取暂停更新章节类型列表
|
|
func GetStopUpdateReportChapterTypeListByResearchType() (list []*ReportChapterType, err error) {
|
|
func GetStopUpdateReportChapterTypeListByResearchType() (list []*ReportChapterType, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` SELECT * FROM report_chapter_type WHERE is_set = 1 AND pause_end_time >= ? AND enabled = 1 `
|
|
sql := ` SELECT * FROM report_chapter_type WHERE is_set = 1 AND pause_end_time >= ? AND enabled = 1 `
|
|
- _, err = o.Raw(sql, time.Now().Format(utils.FormatDate)).QueryRows(&list)
|
|
|
|
|
|
+ //_, err = o.Raw(sql, time.Now().Format(utils.FormatDate)).QueryRows(&list)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, time.Now().Format(utils.FormatDate)).First(&list).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetDisableUpdateReportChapterTypeListByResearchType 获取停止更新的章节类型列表
|
|
// GetDisableUpdateReportChapterTypeListByResearchType 获取停止更新的章节类型列表
|
|
func GetDisableUpdateReportChapterTypeListByResearchType() (list []*ReportChapterType, err error) {
|
|
func GetDisableUpdateReportChapterTypeListByResearchType() (list []*ReportChapterType, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` SELECT * FROM report_chapter_type WHERE enabled = 0`
|
|
sql := ` SELECT * FROM report_chapter_type WHERE enabled = 0`
|
|
- _, err = o.Raw(sql).QueryRows(&list)
|
|
|
|
|
|
+ //_, err = o.Raw(sql).QueryRows(&list)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql).Find(&list).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -324,37 +346,39 @@ type ReportChapterTypeListResp struct {
|
|
|
|
|
|
// GetReportChapterTypeCount 获取章节类型总数
|
|
// GetReportChapterTypeCount 获取章节类型总数
|
|
func GetReportChapterTypeCount(condition string, pars []interface{}) (count int, err error) {
|
|
func GetReportChapterTypeCount(condition string, pars []interface{}) (count int, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` SELECT COUNT(1) FROM report_chapter_type WHERE 1 = 1 `
|
|
sql := ` SELECT COUNT(1) FROM report_chapter_type WHERE 1 = 1 `
|
|
sql += condition
|
|
sql += condition
|
|
- err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
|
|
|
+ //err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, pars).Scan(&count).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetReportChapterTypePageList 获取章节类型列表
|
|
// GetReportChapterTypePageList 获取章节类型列表
|
|
func GetReportChapterTypePageList(condition string, pars []interface{}) (list []*ReportChapterType, err error) {
|
|
func GetReportChapterTypePageList(condition string, pars []interface{}) (list []*ReportChapterType, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` SELECT * FROM report_chapter_type WHERE 1 = 1 `
|
|
sql := ` SELECT * FROM report_chapter_type WHERE 1 = 1 `
|
|
sql += condition
|
|
sql += condition
|
|
sql += ` ORDER BY sort ASC, created_time DESC`
|
|
sql += ` ORDER BY sort ASC, created_time DESC`
|
|
- _, err = o.Raw(sql, pars).QueryRows(&list)
|
|
|
|
|
|
+ //_, err = o.Raw(sql, pars).QueryRows(&list)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, pars).Find(&list).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// ReportChapterTypeListItem 章节类型列表信息
|
|
// ReportChapterTypeListItem 章节类型列表信息
|
|
type ReportChapterTypeListItem struct {
|
|
type ReportChapterTypeListItem struct {
|
|
- ReportChapterTypeId int `description:"报告章节类型id"`
|
|
|
|
- ReportChapterTypeName string `description:"报告章节类型名称"`
|
|
|
|
- Sort int `description:"排序字段"`
|
|
|
|
- CreatedTime string `description:"创建时间"`
|
|
|
|
- ResearchType string `description:"研报类型"`
|
|
|
|
- SelectedImage string `description:"选中时的图片"`
|
|
|
|
- UnselectedImage string `description:"没选中时的图片"`
|
|
|
|
- WordsImage string `description:"带字的icon"`
|
|
|
|
- EditImgUrl string `description:"管理后台编辑时选用的图"`
|
|
|
|
- IsShow int `description:"显示隐藏: 1-显示; 0-隐藏"`
|
|
|
|
- ChartPermissionIdList []int `description:"权限id数组"`
|
|
|
|
- Enabled int `description:"是否可用,1可用,0禁用"`
|
|
|
|
|
|
+ ReportChapterTypeId int `gorm:"column:report_chapter_type_id"` //`description:"报告章节类型id"`
|
|
|
|
+ ReportChapterTypeName string `gorm:"column:report_chapter_type_name"` //`description:"报告章节类型名称"`
|
|
|
|
+ Sort int `gorm:"column:sort"` //`description:"排序字段"`
|
|
|
|
+ CreatedTime string `gorm:"column:created_time"` //`description:"创建时间"`
|
|
|
|
+ ResearchType string `gorm:"column:research_type"` //`description:"研报类型"`
|
|
|
|
+ SelectedImage string `gorm:"column:selected_image"` //`description:"选中时的图片"`
|
|
|
|
+ UnselectedImage string `gorm:"column:unselected_image"` //`description:"没选中时的图片"`
|
|
|
|
+ WordsImage string `gorm:"column:words_image"` //`description:"带字的icon"`
|
|
|
|
+ EditImgUrl string `gorm:"column:edit_img_url"` //`description:"管理后台编辑时选用的图"`
|
|
|
|
+ IsShow int `gorm:"column:is_show"` //`description:"显示隐藏: 1-显示; 0-隐藏"`
|
|
|
|
+ ChartPermissionIdList []int `gorm:"-"` //`description:"权限id数组"`
|
|
|
|
+ Enabled int `gorm:"column:enabled"` //`description:"是否可用,1可用,0禁用"`
|
|
}
|
|
}
|
|
|
|
|
|
// ReportChapterTypeAddReq 新增章节类型请求体
|
|
// ReportChapterTypeAddReq 新增章节类型请求体
|
|
@@ -407,63 +431,70 @@ type ReportChapterTypeEnabledReq struct {
|
|
|
|
|
|
// GetReportChapterTypeByCondition 获取章节类型
|
|
// GetReportChapterTypeByCondition 获取章节类型
|
|
func GetReportChapterTypeByCondition(condition string, pars []interface{}) (item *ReportChapterType, err error) {
|
|
func GetReportChapterTypeByCondition(condition string, pars []interface{}) (item *ReportChapterType, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` SELECT * FROM report_chapter_type WHERE 1 = 1 `
|
|
sql := ` SELECT * FROM report_chapter_type WHERE 1 = 1 `
|
|
sql += condition
|
|
sql += condition
|
|
sql += ` LIMIT 1`
|
|
sql += ` LIMIT 1`
|
|
- err = o.Raw(sql, pars).QueryRow(&item)
|
|
|
|
|
|
+ //err = o.Raw(sql, pars).QueryRow(&item)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, pars).Find(&item).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetMaxSort 获取最大的排序值
|
|
// GetMaxSort 获取最大的排序值
|
|
func (r *ReportChapterType) GetMaxSort() (maxSort int, err error) {
|
|
func (r *ReportChapterType) GetMaxSort() (maxSort int, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := `SELECT max(sort) AS sort FROM report_chapter_type`
|
|
sql := `SELECT max(sort) AS sort FROM report_chapter_type`
|
|
- err = o.Raw(sql).QueryRow(&maxSort)
|
|
|
|
|
|
+ //err = o.Raw(sql).QueryRow(&maxSort)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql).Scan(&maxSort).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetMaxSortByResearchType 获取最大的排序值
|
|
// GetMaxSortByResearchType 获取最大的排序值
|
|
func (r *ReportChapterType) GetMaxSortByResearchType(researchType string) (maxSort int, err error) {
|
|
func (r *ReportChapterType) GetMaxSortByResearchType(researchType string) (maxSort int, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := `SELECT max(sort) AS sort FROM report_chapter_type WHERE research_type = ?`
|
|
sql := `SELECT max(sort) AS sort FROM report_chapter_type WHERE research_type = ?`
|
|
- err = o.Raw(sql, researchType).QueryRow(&maxSort)
|
|
|
|
|
|
+ //err = o.Raw(sql, researchType).QueryRow(&maxSort)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, researchType).Scan(&maxSort).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// UpdateReportChapterTypeSortByResearchType 根据父类id更新排序
|
|
// UpdateReportChapterTypeSortByResearchType 根据父类id更新排序
|
|
func UpdateReportChapterTypeSortByResearchType(researchType string, reportChapterTypeId, nowSort int, updateSort string) (err error) {
|
|
func UpdateReportChapterTypeSortByResearchType(researchType string, reportChapterTypeId, nowSort int, updateSort string) (err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` update report_chapter_type set sort = ` + updateSort + ` WHERE research_type=? AND sort > ?`
|
|
sql := ` update report_chapter_type set sort = ` + updateSort + ` WHERE research_type=? AND sort > ?`
|
|
if reportChapterTypeId > 0 {
|
|
if reportChapterTypeId > 0 {
|
|
sql += ` or ( report_chapter_type_id > ` + fmt.Sprint(reportChapterTypeId) + ` and sort = ` + fmt.Sprint(nowSort) + `)`
|
|
sql += ` or ( report_chapter_type_id > ` + fmt.Sprint(reportChapterTypeId) + ` and sort = ` + fmt.Sprint(nowSort) + `)`
|
|
}
|
|
}
|
|
|
|
|
|
- _, err = o.Raw(sql, researchType, nowSort).Exec()
|
|
|
|
|
|
+ //_, err = o.Raw(sql, researchType, nowSort).Exec()
|
|
|
|
+ err = global.DmSQL["rddp"].Exec(sql, researchType, nowSort).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetFirstReportChapterTypeByParentId 获取当前父级分类下,且排序数相同 的排序第一条的数据
|
|
// GetFirstReportChapterTypeByParentId 获取当前父级分类下,且排序数相同 的排序第一条的数据
|
|
func (r *ReportChapterType) GetFirstReportChapterTypeByResearchType(researchType string) (item *ReportChapterType, err error) {
|
|
func (r *ReportChapterType) GetFirstReportChapterTypeByResearchType(researchType string) (item *ReportChapterType, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` SELECT * FROM report_chapter_type WHERE 1 = 1 AND research_type = ? ORDER BY sort ASC, report_chapter_type_id ASC LIMIT 1`
|
|
sql := ` SELECT * FROM report_chapter_type WHERE 1 = 1 AND research_type = ? ORDER BY sort ASC, report_chapter_type_id ASC LIMIT 1`
|
|
- err = o.Raw(sql, researchType).QueryRow(&item)
|
|
|
|
|
|
+ //err = o.Raw(sql, researchType).QueryRow(&item)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, researchType).First(&item).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// GetReportChapterTypeById 获取章节类型
|
|
// GetReportChapterTypeById 获取章节类型
|
|
func (r *ReportChapterType) GetReportChapterTypeById(reportChapterTypeId int) (item *ReportChapterType, err error) {
|
|
func (r *ReportChapterType) GetReportChapterTypeById(reportChapterTypeId int) (item *ReportChapterType, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` SELECT * FROM report_chapter_type WHERE report_chapter_type_id = ?`
|
|
sql := ` SELECT * FROM report_chapter_type WHERE report_chapter_type_id = ?`
|
|
- err = o.Raw(sql, reportChapterTypeId).QueryRow(&item)
|
|
|
|
|
|
+ //err = o.Raw(sql, reportChapterTypeId).QueryRow(&item)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, reportChapterTypeId).First(&item).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
// SetEnabled 更新启动禁用
|
|
// SetEnabled 更新启动禁用
|
|
func (r *ReportChapterType) SetEnabled(id, enabled int) (err error) {
|
|
func (r *ReportChapterType) SetEnabled(id, enabled int) (err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` update report_chapter_type set enabled = ? WHERE report_chapter_type_id = ?`
|
|
sql := ` update report_chapter_type set enabled = ? WHERE report_chapter_type_id = ?`
|
|
- _, err = o.Raw(sql, enabled, id).Exec()
|
|
|
|
|
|
+ //_, err = o.Raw(sql, enabled, id).Exec()
|
|
|
|
+ err = global.DmSQL["rddp"].Exec(sql, enabled, id).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -475,9 +506,10 @@ func (r *ReportChapterType) SetEnabled(id, enabled int) (err error) {
|
|
// @return list []*ReportChapterType
|
|
// @return list []*ReportChapterType
|
|
// @return err error
|
|
// @return err error
|
|
func GetReportChapterTypeListByClassifyId(classifyId int) (list []*ReportChapterType, err error) {
|
|
func GetReportChapterTypeListByClassifyId(classifyId int) (list []*ReportChapterType, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` SELECT * FROM report_chapter_type WHERE report_classify_id = ? AND enabled = 1`
|
|
sql := ` SELECT * FROM report_chapter_type WHERE report_classify_id = ? AND enabled = 1`
|
|
- _, err = o.Raw(sql, classifyId).QueryRows(&list)
|
|
|
|
|
|
+ //_, err = o.Raw(sql, classifyId).QueryRows(&list)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, classifyId).Find(&list).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -489,8 +521,9 @@ func GetReportChapterTypeListByClassifyId(classifyId int) (list []*ReportChapter
|
|
// @return list []*ReportChapterType
|
|
// @return list []*ReportChapterType
|
|
// @return err error
|
|
// @return err error
|
|
func GetAllReportChapterTypeListByClassifyId(classifyId int) (list []*ReportChapterType, err error) {
|
|
func GetAllReportChapterTypeListByClassifyId(classifyId int) (list []*ReportChapterType, err error) {
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
sql := ` SELECT * FROM report_chapter_type WHERE report_classify_id = ? `
|
|
sql := ` SELECT * FROM report_chapter_type WHERE report_classify_id = ? `
|
|
- _, err = o.Raw(sql, classifyId).QueryRows(&list)
|
|
|
|
|
|
+ //_, err = o.Raw(sql, classifyId).QueryRows(&list)
|
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, classifyId).Find(&list).Error
|
|
return
|
|
return
|
|
}
|
|
}
|