package models import ( "github.com/beego/beego/v2/client/orm" "github.com/rdlucklib/rdluck_tools/paging" "time" ) type EnglishReportDetail struct { Id int `orm:"column(id)" description:"报告Id"` AddType int `description:"新增方式:1:新增报告,2:继承报告"` ClassifyIdFirst int `description:"一级分类id"` ClassifyNameFirst string `description:"一级分类名称"` ClassifyIdSecond int `description:"二级分类id"` ClassifyNameSecond string `description:"二级分类名称"` Title string `description:"标题"` Abstract string `description:"摘要"` Author string `description:"作者"` Frequency string `description:"频度"` CreateTime string `description:"创建时间"` ModifyTime string `description:"修改时间"` State int `description:"1:未发布,2:已发布"` PublishTime string `description:"发布时间"` Stage int `description:"期数"` MsgIsSend int `description:"消息是否已发送,0:否,1:是"` Content string `description:"内容"` VideoUrl string `description:"音频文件URL"` VideoName string `description:"音频文件名称"` VideoPlaySeconds string `description:"音频播放时长"` ContentSub string `description:"内容前两个章节"` ThsMsgIsSend int `description:"客户群消息是否已发送,0:否,1:是"` HasChapter int `description:"是否有章节 0-否 1-是"` ChapterType string `description:"章节类型 day-晨报 week-周报"` ReportCode string `description:"报告唯一编码"` Overview string `description:"英文概述部分"` } type EnglishClassify struct { Id int `orm:"column(id);pk"` ClassifyName string `description:"分类名称"` Sort int `description:"排序"` ParentId int `description:"父级分类id"` CreateTime time.Time `description:"创建时间"` ModifyTime time.Time `description:"修改时间"` ClassifyLabel string `description:"分类标签"` ShowType int `description:"展示类型:1-列表 2-专栏"` IsShow int `description:"是否在小程序显示:1-显示 0-隐藏"` } type ElasticEnglishReportDetail struct { ReportId int `description:"报告id"` ClassifyIdFirst int `description:"一级分类id"` ClassifyNameFirst string `description:"一级分类名称"` ClassifyIdSecond int `description:"二级分类id"` ClassifyNameSecond string `description:"二级分类名称"` StageStr string `description:"报告期数"` Title string `description:"标题"` Abstract string `description:"摘要"` Author string `description:"作者"` Frequency string `description:"频度"` PublishState int `description:"状态:1:未发布,2:已发布"` BodyContent string `description:"内容"` ContentSub string `description:"前两段内容"` CreateTime string `description:"创建时间"` PublishTime string `description:"发布时间"` ReportCode string `description:"报告唯一编码"` Overview string `description:"英文概述部分"` } type SearchEnglishReportItem struct { Id int `description:"报告Id"` ClassifyIdFirst int `description:"一级分类id"` ClassifyNameFirst string `description:"一级分类名称"` ClassifyIdSecond int `description:"二级分类id"` ClassifyNameSecond string `description:"二级分类名称"` Title string `description:"标题"` Author string `description:"作者"` CreateTime string `description:"创建时间"` PublishTime string `description:"发布时间"` ContentSub string `description:"内容前两个章节"` ReportCode string `description:"报告唯一编码"` } type SearchEnglishReportResp struct { List []*SearchEnglishReportItem Paging *paging.PagingItem `description:"分页数据"` } func GetEnglishReportByCode(reportCode string) (item *EnglishReportDetail, err error) { o := orm.NewOrmUsingDB("rddp") sql := `SELECT * FROM english_report WHERE report_code=?` err = o.Raw(sql, reportCode).QueryRow(&item) return } type EnglishReportShareDetailResp struct { Report *EnglishReportDetail `description:"报告"` H5ShareEnName string `description:"研报分享抬头"` H5ReportShareImg string `description:"研报分享图片"` Hz int } func UpdateEnglishReportCounts(reportCode string) (err error) { o := orm.NewOrmUsingDB("rddp") sql := `UPDATE english_report SET pv = pv+1 WHERE report_code = ? ` _, err = o.Raw(sql, reportCode).Exec() return } func UpdateEnglishReportEmailCounts(reportCode string) (err error) { o := orm.NewOrmUsingDB("rddp") sql := `UPDATE english_report SET pv_email = pv_email+1 WHERE report_code = ? ` _, err = o.Raw(sql, reportCode).Exec() return } type EnglishClassifyList struct { Id int `description:"分类ID"` ClassifyName string `description:"分类名称"` Sort int `description:"排序"` ParentId int `description:"父级分类id"` CreateTime string `description:"创建时间"` ModifyTime string `description:"修改时间"` ClassifyLabel string `description:"分类标签"` ShowType int `description:"展示类型:1-列表 2-专栏"` IsShow int `description:"是否在小程序显示:1-显示 0-隐藏"` Child []*EnglishClassify } type EnglishClassifyListResp struct { List []*EnglishClassifyList } // GetParentEnglishClassify 获取一级分类列表 func GetParentEnglishClassify() (items []*EnglishClassify, err error) { sql := `SELECT * FROM english_classify WHERE parent_id=0 ORDER BY sort ASC,create_time ASC` o := orm.NewOrmUsingDB("rddp") _, err = o.Raw(sql).QueryRows(&items) return } // GetChildEnglishClassify 获取二级分类列表 func GetChildEnglishClassify() (items []*EnglishClassify, err error) { sql := `SELECT * FROM english_classify WHERE parent_id>0 ORDER BY sort ASC,create_time ASC` o := orm.NewOrmUsingDB("rddp") _, err = o.Raw(sql).QueryRows(&items) return } func GetEnglishReportListCount(condition string, pars []interface{}) (count int, err error) { //产品权限 oRddp := orm.NewOrmUsingDB("rddp") sql := `SELECT COUNT(1) AS count FROM english_report WHERE state=2 ` if condition != "" { sql += condition } err = oRddp.Raw(sql, pars).QueryRow(&count) return } type EnglishReportList struct { Id int `description:"报告Id"` AddType int `description:"新增方式:1:新增报告,2:继承报告"` ClassifyIdFirst int `description:"一级分类id"` ClassifyNameFirst string `description:"一级分类名称"` ClassifyIdSecond int `description:"二级分类id"` ClassifyNameSecond string `description:"二级分类名称"` Title string `description:"标题"` Abstract string `description:"摘要"` Author string `description:"作者"` Frequency string `description:"频度"` CreateTime string `description:"创建时间"` ModifyTime string `description:"修改时间"` PublishTime string `description:"发布时间"` Stage int `description:"期数"` VideoUrl string `description:"音频文件URL"` VideoName string `description:"音频文件名称"` VideoPlaySeconds string `description:"音频播放时长"` ReportCode string `description:"报告唯一编码"` ShareUrl string `description:"分享url"` } type EnglishReportListResp struct { List []*EnglishReportList Paging *paging.PagingItem `description:"分页数据"` } func GetEnglishReportList(condition string, pars []interface{}, startSize, pageSize int) (items []*EnglishReportDetail, err error) { o := orm.NewOrmUsingDB("rddp") sql := `SELECT * FROM english_report WHERE state=2 ` if condition != "" { sql += condition } sql += `ORDER BY publish_time DESC, id DESC LIMIT ?,?` _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items) return } func GetTrialEnglishReportByCode(reportCode string) (item *EnglishReportDetail, err error) { o := orm.NewOrmUsingDB("rddp_trial") sql := `SELECT * FROM english_report WHERE report_code=?` err = o.Raw(sql, reportCode).QueryRow(&item) return } func UpdateTrialEnglishReportCounts(reportCode string) (err error) { o := orm.NewOrmUsingDB("rddp_trial") sql := `UPDATE english_report SET pv = pv+1 WHERE report_code = ? ` _, err = o.Raw(sql, reportCode).Exec() return } func UpdateTrialEnglishReportEmailCounts(reportCode string) (err error) { o := orm.NewOrmUsingDB("rddp_trial") sql := `UPDATE english_report SET pv_email = pv_email+1 WHERE report_code = ? ` _, err = o.Raw(sql, reportCode).Exec() return }