1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package cross_variety
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- // ChartVarietyMapping
- // @Description: 图表与品种的关系表
- type ChartVarietyMapping struct {
- Id int `orm:"column(id);pk"`
- ChartInfoId int `description:"图表id"`
- ChartVarietyId int `description:"品种id"`
- ModifyTime time.Time `description:"修改时间"`
- CreateTime time.Time `description:"创建时间"`
- }
- // GetChartVarietyMappingList
- // @Description: 获取图表与品种的关系列表表
- // @author: Roc
- // @datetime 2023-11-24 15:22:36
- // @param chartInfoId int
- // @return items []*ChartVarietyMapping
- // @return err error
- func GetChartVarietyMappingList(chartInfoId int) (items []*ChartVarietyMapping, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM chart_variety_mapping WHERE chart_info_id = ? `
- _, err = o.Raw(sql, chartInfoId).QueryRows(&items)
- return
- }
- // GetCountChartByVarietyId
- // @Description: 根据品种id获取引用该标签的图表数量
- // @author: Roc
- // @datetime 2023-11-27 10:41:46
- // @param tagId int
- // @return total int64
- // @return err error
- func GetCountChartByVarietyId(varietyId int) (total int64, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT count(1) total FROM chart_info AS a JOIN
- chart_variety_mapping AS b on a.chart_info_id = b.chart_info_id
- WHERE b.chart_variety_id = ? `
- err = o.Raw(sql, varietyId).QueryRow(&total)
- return
- }
|