1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- package bi_dashboard
- import (
- "eta_gn/eta_api/global"
- "time"
- )
- type BiDashboardDetail struct {
- BiDashboardDetailId int `gorm:"primaryKey;autoIncrement;column:bi_dashboard_detail_id" ` // bi看板id
- BiDashboardId int `gorm:"column:bi_dashboard_id" ` // 看板id
- Type int `gorm:"column:type" ` // 1图表 2表格 3知识资源库
- Conf string `gorm:"column:conf" ` // 配置信息
- UniqueCode string `gorm:"column:unique_code;size:32;not null" ` // 报告唯一编码
- Sort int `gorm:"column:sort" ` // 排序字段
- CreateTime time.Time `gorm:"column:create_time" ` // 创建时间
- ModifyTime time.Time `gorm:"column:modify_time" ` // 更新时间
- }
- // tableName
- func (m *BiDashboardDetail) TableName() string {
- return "bi_dashboard_detail"
- }
- func (m *BiDashboardDetail) Insert() (err error) {
- return global.DEFAULT_DmSQL.Create(m).Error
- }
- func GetBiDashboardDetailById(id int) (list []*BiDashboardDetail, err error) {
- err = global.DEFAULT_DmSQL.Table("bi_dashboard_detail").Where("bi_dashboard_id IN ?", id).Find(&list).Error
- return
- }
- // GetBiDashboardDetailIdByBidashboardIdAndType 获取看板详情id
- func GetBiDashboardDetailIdByBidashboardIdAndType(bid int, t int) (ids []int, err error) {
- sql := "SELECT bi_dashboard_detail_id FROM bi_dashboard_detail WHERE bi_dashboard_id = ? AND type = ?"
- err = global.DEFAULT_DmSQL.Raw(sql, bid, t).Scan(&ids).Error
- return
- }
- // multiAdd
- func AddBiDashboardDetailMulti(items []*BiDashboardDetail) (err error) {
- return global.DEFAULT_DmSQL.CreateInBatches(items, 100).Error
- }
- // del
- func DeleteBiDashboardDetail(id int) (err error) {
- return global.DEFAULT_DmSQL.Where("bi_dashboard_id = ?", id).Delete(&BiDashboardDetail{}).Error
- }
- type MoveDashboardDetailReq struct {
- BiDashboardId int `description:"看板id"`
- BiDashboardDetailId int `description:"看板详情id"`
- Sort int `description:"排序"`
- OtherDetailId int `description:"交换的详情id"`
- OtherSort int `description:"交换的排序"`
- }
- // update
- func EditBiDashboardDetail(item *BiDashboardDetail) (err error) {
- return global.DEFAULT_DmSQL.Model(item).Where("bi_dashboard_detail_id = ?", item.BiDashboardDetailId).Updates(item).Error
- }
- type DelDashboardDetailReq struct {
- BiDashboardDetailId int `description:"看板详情id"`
- }
- // del
- func DeleteBiDashboardDetailByDetailId(id int) (err error) {
- return global.DEFAULT_DmSQL.Where("bi_dashboard_detail_id = ?", id).Delete(&BiDashboardDetail{}).Error
- }
- // GetUserIdListRelationBiDashboardDetailByCondition
- // @Description: 根据条件获取关联图的用户id列表
- // @author: Roc
- // @datetime 2024-12-26 10:13:47
- // @param condition string
- // @param pars []interface{}
- // @return total int
- // @return err error
- func GetUserIdListRelationBiDashboardDetailByCondition(condition string, pars []interface{}) (userIdList []int, err error) {
- sql := ` SELECT b.sys_admin_id FROM bi_dashboard_detail AS a
- JOIN bi_dashboard AS b on a.bi_dashboard_id = b.bi_dashboard_id WHERE 1=1 `
- if condition != "" {
- sql += condition
- }
- sql += ` GROUP BY b.sys_admin_id `
- err = global.DEFAULT_DmSQL.Raw(sql, pars...).Scan(&userIdList).Error
- return
- }
|