123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- package chart_collect
- import (
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "time"
- )
- type ChartCollect struct {
- ChartCollectId int `orm:"column(chart_collect_id);pk"`
- UserId int `orm:"column(user_id)" description:"用户ID"`
- BusinessCode string `orm:"column(business_code)" description:"客户编码"`
- RealName string `orm:"column(real_name)" description:"用户姓名"`
- CollectTime time.Time `orm:"column(collect_time)" description:"收藏时间"`
- ChartInfoId int `orm:"column(chart_info_id)" description:"图表ID"`
- CollectClassifyId int `orm:"column(collect_classify_id)" description:"收藏的分类ID"`
- ChartSource int `orm:"column(chart_source)" description:"图表来源"`
- CreateTime time.Time `orm:"column(create_time)" description:"创建时间"`
- ModifyTime time.Time `orm:"column(modify_time)" description:"修改时间"`
- }
- type ChartCollectAddReq struct {
- ChartInfoId int `description:"图表id"`
- CollectClassifyId int `description:"收藏分类id"`
- }
- type ChartCollectView struct {
- ChartCollectId int `orm:"column(chart_collect_id);pk"`
- ChartInfoId int `description:"图表id"`
- UserId int `description:"用户id"`
- CreateTime time.Time `description:"创建时间"`
- CollectTime string `description:"收藏时间"`
- CollectClassifyId int
- ChartName string `description:"来源名称"`
- ChartNameEn string `description:"英文图表名称"`
- ChartImage string `description:"图表图片"`
- UniqueCode string `description:"图表唯一编码"`
- }
- type ChartCollectListResp struct {
- Paging *paging.PagingItem
- List []*ChartCollectView
- }
- type ChartCollectEditReq struct {
- ChartCollectId int `description:"我的图表主键"`
- CurrentClassifyId int `description:"当前分类ID"`
- ClassifyId []int `description:"分类id,数组形式"`
- }
- func GetChartCollectPageByCondition(condition string, pars []interface{}, currentIndex, pageSize int) (item []*ChartCollectView, err error) {
- o := orm.NewOrm()
- //sql := ` SELECT * FROM chart_collect WHERE 1=1 `
- sql := `SELECT a.*,b.chart_name_en,b.chart_name, b.unique_code, b.chart_image FROM chart_collect AS a
- INNER JOIN chart_info AS b ON a.chart_info_id=b.chart_info_id
- WHERE 1=1
- `
- if condition != "" {
- sql += condition
- }
- sql += ` GROUP BY a.chart_info_id order by a.chart_collect_id desc limit ?,?`
- _, err = o.Raw(sql, pars, currentIndex, pageSize).QueryRows(&item)
- return
- }
- func GetChartCollectDetailByCondition(condition string, pars []interface{}) (item []*ChartCollectView, err error) {
- o := orm.NewOrm()
- //sql := ` SELECT * FROM chart_collect WHERE 1=1 `
- sql := `SELECT a.*,b.chart_name_en,b.chart_name, b.unique_code, b.chart_image FROM chart_collect AS a
- INNER JOIN chart_info AS b ON a.chart_info_id=b.chart_info_id
- WHERE 1=1
- `
- if condition != "" {
- sql += condition
- }
- sql += ` GROUP BY a.chart_info_id`
- _, err = o.Raw(sql, pars).QueryRows(&item)
- return
- }
- func GetChartCollectCountByCondition(condition string, pars []interface{}) (total int64, err error) {
- o := orm.NewOrm()
- sql := `SELECT a.chart_info_id FROM chart_collect AS a INNER JOIN chart_info AS b ON a.chart_info_id=b.chart_info_id
- WHERE 1=1
- `
- if condition != "" {
- sql += condition
- }
- sql += ` GROUP BY a.chart_info_id`
- totalSql := `select count(1) as total from (` + sql + `) as t`
- err = o.Raw(totalSql, pars).QueryRow(&total)
- return
- }
- // ModifyChartClassifyPublicReq 修改我的图库分类是否可见
- type ModifyChartClassifyPublicReq struct {
- ClassifyId int `description:"分类id"`
- IsPublic int `description:"是否所有人可见,0:仅自己可见,1:所有人可见"`
- }
- // CopyChartClassifyReq 复制我的图库分类
- type CopyChartClassifyReq struct {
- ClassifyId int `description:"分类id"`
- }
- // ChartCollectClassifyItem 我的图表分类信息
- type ChartCollectClassifyItem struct {
- CollectClassifyId int `description:"分类ID"`
- ClassifyName string `description:"分类名称"`
- UserId int `description:"创建人id"`
- /*IsPublic int `description:"是否公共分类"`
- IsCompanyPublic int `description:"是否为用户公共分类"`*/
- ChartNum int `description:"分类下的图表数量"`
- }
- // ClassifyIdAndNum 我的图表-分类ID及图表数
- type ClassifyIdAndNum struct {
- ClassifyId int `description:"分类ID"`
- ChartNum int `description:"分类下的图表数量"`
- }
- type ChartCollectAddResp struct {
- CollectMsg string `description:"提示信息"`
- }
- func GetChartCollectByUserIdChartInfoId(userId, chartInfoId int) (item *ChartCollect, err error) {
- o := orm.NewOrm()
- sql := ` SELECT * FROM chart_collect WHERE user_id=? AND chart_info_id=? `
- err = o.Raw(sql, userId, chartInfoId).QueryRow(&item)
- return
- }
|