123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- package ficc_report
- import (
- "github.com/beego/beego/v2/client/orm"
- "hongze/hongze_clpt/utils"
- "time"
- )
- type ReportChapter struct {
- ReportChapterId int `gorm:"primaryKey;column:report_chapter_id;type:int(10) unsigned;not null" json:"-"`
- ReportId int `gorm:"column:report_id;type:int(10);not null;default:0" json:"report_id"` //报告ID
- ReportType string `gorm:"column:report_type;type:varchar(255);not null;default:''" json:"report_type"` //晨报-day;周报-week;
- ClassifyIdFirst int `gorm:"column:classify_id_first;type:int(10);default:0" json:"classify_id_first"` //一级分类id
- ClassifyNameFirst string `gorm:"column:classify_name_first;type:varchar(255);default:''" json:"classify_name_first"` //一级分类名称
- TypeId int `gorm:"column:type_id;type:int(10);not null;default:0" json:"type_id"` //品种ID
- TypeName string `gorm:"column:type_name;type:varchar(255);not null;default:''" json:"type_name"` //品种名称
- Title string `gorm:"column:title;type:varchar(255);not null;default:''" json:"title"` //章节标题
- Abstract string `gorm:"column:abstract;type:varchar(255);not null;default:''" json:"abstract"` //摘要
- AddType int `gorm:"column:add_type;type:int(10);not null;default:0" json:"add_type"` //是否为继承报告1-空白报告2-继承报告
- Author string `gorm:"column:author;type:varchar(255);not null;default:''" json:"author"` //作者
- Content string `gorm:"column:content;type:longtext;" json:"content"` //内容
- ContentSub string `gorm:"column:content_sub;type:longtext;" json:"content_sub"` //内容前两章
- Stage int `gorm:"column:stage;type:int(10);not null;default:0" json:"stage"` //期数
- Trend string `gorm:"column:trend;type:varchar(255);not null;default:''" json:"trend"` //趋势观点
- Sort int `gorm:"column:sort;type:int(10);not null;default:0" json:"sort"` //排序:数值越小越靠前
- IsEdit int `gorm:"column:is_edit;type:int(10);not null;default:0" json:"is_edit"` //是否编辑
- PublishState int `gorm:"column:publish_state;type:int(4);not null;default:0" json:"publish_state"` //发布状态1-待发布2-已发布
- PublishTime time.Time `gorm:"column:publish_time;type:datetime" json:"publish_time"` //发布时间
- VideoUrl string `gorm:"column:video_url;type:varchar(255);not null;default:''" json:"video_url"` //音频文件URL
- VideoName string `gorm:"column:video_name;type:varchar(255);not null;default:''" json:"video_name"` //音频文件名称
- VideoPlaySeconds string `gorm:"column:video_play_seconds;type:varchar(255);not null;default:''" json:"video_play_seconds"` //音频播放时长
- VideoSize string `gorm:"column:video_size;type:varchar(255);not null;default:''" json:"video_size"` //音频文件大小,单位M
- CreateTime time.Time `gorm:"column:create_time;type:datetime" json:"create_time"` //创建时间
- ModifyTime time.Time `gorm:"column:modify_time;type:datetime" json:"modify_time"` //修改时间
- ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局。默认:1" json:"report_layout"`
- VoiceGenerateType int8 `description:"音频生成方式,0:系统生成,1:人工上传" json:"voice_generate_type"`
- }
- // ReportChapterPermissionMappingItem 报告章节的权限关系表
- type ReportChapterPermissionMappingItem struct {
- ReportChapterPermissionMappingId int `gorm:"primaryKey;column:report_chapter_permission_mapping_id" json:"report_chapter_permission_mapping_id"`
- ReportChapterId int `gorm:"column:report_chapter_id" json:"report_chapter_id"` // 报告章节的id
- ChartPermissionId int `gorm:"column:chart_permission_id" json:"chart_permission_id"` // 权限id
- TypeId int `gorm:"column:type_id" json:"type_id"` // 报告章节类型id
- CreateTime time.Time `gorm:"column:create_time" json:"create_time"`
- }
- // @Description: 根据报告ID列表获取章节
- func GetReportChapterPermissionMappingItemListByReportId(reportId int) (items []*ReportChapterPermissionMappingItem, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT a.report_chapter_permission_mapping_id ,a.report_chapter_id ,a.chart_permission_id ,a.create_time ,b.type_id
- FROM report_chapter_permission_mapping AS a
- INNER JOIN report_chapter AS b ON a.report_chapter_id = b.report_chapter_id
- WHERE b.report_id = ? `
- _, err = o.Raw(sql, reportId).QueryRows(&items)
- return
- }
- type ReportChapterList []*ReportChapterListItem
- // GetListByChapterIds 根据章节IDs获取列表
- func GetListByChapterIds(chapterIds []int) (items []*ReportChapter, err error) {
- o := orm.NewOrmUsingDB("rddp")
- var condition string
- var pars []interface{}
- condition = ` AND publish_state = 2 `
- if len(chapterIds) > 0 {
- condition += ` AND report_chapter_id IN (` + utils.GetOrmInReplace(len(chapterIds)) + `) `
- pars = append(pars, chapterIds)
- }
- sql := `SELECT *
- FROM report_chapter
- WHERE 1=1 ` + condition + ` ORDER BY sort asc, report_chapter_id asc `
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
- // GetListByReportId 根据报告ID获取章节列表
- func GetListByReportId(reportId int, classifyNameFirst string) (items []*ReportChapter, err error) {
- var where string
- if classifyNameFirst == "周报" {
- where = " AND report_id = ? AND is_edit = 1 AND publish_state = 2"
- } else {
- where = " AND report_id = ? AND publish_state = 2"
- }
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT report_chapter_id, report_id, type_id, type_name, abstract, title, author, publish_time, trend,video_url,video_name,video_play_seconds,video_size
- FROM report_chapter
- WHERE 1=1 ` + where + ` ORDER BY sort asc, report_chapter_id asc `
- _, err = o.Raw(sql, reportId).QueryRows(&items)
- return
- }
|