12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package bi_dashboard
- import (
- "eta_gn/eta_api/global"
- "eta_gn/eta_api/utils"
- "time"
- )
- type BiDashboardGrant struct {
- GrantId int `gorm:"primaryKey;autoIncrement;column:grant_id"` // 授权id
- BiDashboardId int `gorm:"column:bi_dashboard_id" ` // 看板id
- GrantAdminId int `gorm:"column:grant_admin_id"` // 授权的用户id
- CreateTime time.Time `gorm:"column:create_time"` // 授权时间
- }
- func (m *BiDashboardGrant) TableName() string {
- return "bi_dashboard_grant"
- }
- type GrantDashboardReq struct {
- BiDashboardId int `description:"看板id" `
- AdminIdStr string `description:"指定成员id,多个成员用英文,隔开"`
- }
- func MultiAddDashboardGrant(boardId int, list []*BiDashboardGrant) (err error) {
- to := global.DEFAULT_DmSQL.Begin()
- defer func() {
- if err != nil {
- _ = to.Rollback()
- } else {
- _ = to.Commit()
- }
- }()
- sql := "DELETE from bi_dashboard_grant where bi_dashboard_id=?"
- err = to.Exec(sql, boardId).Error
- if err != nil {
- return
- }
- if len(list) > 0 {
- tmpErr := to.CreateInBatches(list, utils.MultiAddNum).Error
- if tmpErr != nil {
- err = tmpErr
- return
- }
- }
- return
- }
- type PublicDashboardReq struct {
- BiDashboardId int `description:"看板id" `
- ClassifyId int `description:"分类id"`
- }
- func DeleteDashboardGrant(biDashboardId int) (err error) {
- return global.DEFAULT_DmSQL.Where("bi_dashboard_id=?", biDashboardId).Delete(&BiDashboardGrant{}).Error
- }
- func GetDashboardGrantInfo(biDashboardId int) (list []*BiDashboardGrant, err error) {
- return list, global.DEFAULT_DmSQL.Where("bi_dashboard_id=?", biDashboardId).Find(&list).Error
- }
|