Kaynağa Gözat

fix homepage

zwxi 5 ay önce
ebeveyn
işleme
2699ae8f61

+ 17 - 1
controllers/bi_dashboard.go

@@ -1164,12 +1164,28 @@ func (this *BIDaShboardController) HomePage() {
 	}()
 
 	item, err := bi_dashboard.GetBiDashboardHomePageById(this.SysUser.AdminId)
-	if err != nil {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "数据不存在"
 		br.ErrMsg = "数据不存在,Err:" + err.Error()
 		return
 	}
 
+	publicCond := ` AND state = 6 AND bi_dashboard_classify_id > 0 `
+	publicPars := []interface{}{this.SysUser.AdminId}
+	publicList, err := bi_dashboard.GetBiDashboardList(publicCond, publicPars)
+	if err != nil {
+		err = errors.New("我的看板列表查询出错:" + err.Error())
+		return
+	}
+
+	if item.BiDashboardHomePageId == 0 && len(publicList) > 0 {
+		item = &bi_dashboard.BiDashboardHomePage{
+			AdminId:               publicList[0].SysAdminId,
+			BiDashboardId:         publicList[0].BiDashboardId,
+			FromType:              3,
+		}
+	}
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "查询成功"

+ 1 - 1
models/bi_dashboard/bi_dashboard_home_page.go

@@ -8,7 +8,7 @@ import (
 type BiDashboardHomePage struct {
 	BiDashboardHomePageId int       `gorm:"primaryKey;autoIncrement;comment:'bi首页看板id'"`
 	BiDashboardId         int       `gorm:"type:int(10);default:null;comment:'看板id'"`
-	AdminId               int       `gorm:"type:int(10);default:null;comment:'1图表 2表格'"`
+	AdminId               int       `gorm:"type:int(10);default:null;"`
 	CreateTime            time.Time `gorm:"type:datetime;comment:'创建时间'"`
 	ModifyTime            time.Time `gorm:"type:datetime;comment:'更新时间'"`
 	FromType              int       `gorm:"type:int(10);default:null;comment:'来源,前端跳转用 1我的 2共享 3公共"`