package bi_dashboard import ( "eta_gn/eta_api/global" "time" ) type BiDashboard struct { BiDashboardId int `gorm:"primaryKey;autoIncrement;column:bi_dashboard_id"` // bi看板id BiDashboardClassifyId int `gorm:"column:bi_dashboard_classify_id" ` // 看板分类id BiDashboardName string `gorm:"column:bi_dashboard_name;size:255"` // 看板名称 SysAdminId int `gorm:"column:sys_admin_id" ` // 创建人ID SysAdminName string `gorm:"column:sys_admin_name;size:128" ` // 创建人姓名 Sort int `gorm:"column:sort" ` // 排序字段 CreateTime time.Time `gorm:"column:create_time" ` // 创建时间 ModifyTime time.Time `gorm:"column:modify_time"` // 更新时间 State int `gorm:"column:state"` // 状态 1:未公开; 4-待审批;5-已驳回;6-已通过 } // tableName func (m *BiDashboard) TableName() string { return "bi_dashboard" } func (m *BiDashboard) Update(cols []string) (err error) { err = global.DEFAULT_DmSQL.Model(m).Select(cols).Updates(m).Error return } // AddBiDashboard 新增看板 func AddBiDashboard(item *BiDashboard) (lastId int64, err error) { err = global.DEFAULT_DmSQL.Create(item).Error lastId = int64(item.BiDashboardId) return } func GetBiDashboardList(condition string, pars []interface{}) (items []*BiDashboard, err error) { sql := `SELECT * FROM bi_dashboard WHERE 1=1 ` if condition != "" { sql += condition } // sql += `ORDER BY modify_time DESC ` err = global.DEFAULT_DmSQL.Raw(sql, pars...).Find(&items).Error return } // GetDashboardById 获取看板 func GetDashboardById(id int) (item *BiDashboard, err error) { sql := `SELECT * FROM bi_dashboard WHERE bi_dashboard_id = ? limit 1` err = global.DEFAULT_DmSQL.Raw(sql, id).First(&item).Error return } // del func DelDashboard(id int) (err error) { return global.DEFAULT_DmSQL.Delete(&BiDashboard{BiDashboardId: id}).Error } // BiDashboardEditingCache PPT编辑缓存信息 type BiDashboardEditingCache struct { IsEditing bool `description:"是否有人编辑"` AdminId int `description:"编辑者ID"` Editor string `description:"编辑者姓名"` Tips string `description:"提示信息"` } // DashboardDetailResp 详情响应体 type DashboardDetailResp struct { *BiDashboard IsGrant int `description:"是否共享,0:不是,1:是"` Editor BiDashboardEditingCache `description:"编辑人信息"` List []*BiDashboardDetail } type AddDashboardReq struct { List []*AddDashboardListReq BiDashboardName string `description:"看板名称"` } type AddDashboardListReq struct { Type int UniqueCode string Sort int } type EditDashboardReq struct { List []*AddDashboardListReq BiDashboardId int `description:"看板id"` BiDashboardName string `description:"看板名称"` } // update func EditDashboard(item *BiDashboard) (err error) { return global.DEFAULT_DmSQL.Model(item).Updates(item).Error } type DelDashboardReq struct { BiDashboardId int `description:"看板id"` } // GetAllGrantList 获取已经有权限的看板列表 func GetAllGrantList(sysUserId int) (list []*BiDashboard, err error) { sql := `SELECT a.* FROM bi_dashboard a JOIN bi_dashboard_grant b on a.bi_dashboard_id=b.bi_dashboard_id WHERE b.grant_admin_id=?` err = global.DEFAULT_DmSQL.Raw(sql, sysUserId).Find(&list).Error return } func SaveDashboard(item *BiDashboard) (err error) { return global.DEFAULT_DmSQL.Save(item).Error } // BiDashboardEditingReq 标记编辑中请求体 type BiDashboardEditingReq struct { BiDashboardId int `description:"看板主键ID"` Status int `description:"标记状态: 1-编辑中; 2-编辑完成"` } // GetAllMyShareList 获取我共享的看板 func GetAllMyShareList(sysUserId int) (list []*BiDashboard, err error) { sql := `SELECT a.* FROM bi_dashboard a JOIN bi_dashboard_grant b on a.bi_dashboard_id=b.bi_dashboard_id WHERE a."sys_admin_id" = ? GROUP BY a."bi_dashboard_id" ,"bi_dashboard_classify_id" ,"bi_dashboard_name" ,"sys_admin_id" , "sys_admin_name" ,"sort" ,a."create_time" ,a."modify_time" ,"state" ` err = global.DEFAULT_DmSQL.Raw(sql, sysUserId).Find(&list).Error return } // getByName func GetDashboardByName(name string) (item *BiDashboard, err error) { sql := `SELECT * FROM bi_dashboard WHERE bi_dashboard_name = ? limit 1` err = global.DEFAULT_DmSQL.Raw(sql, name).First(&item).Error return }