zwxi 6 月之前
父节点
当前提交
4925987245

+ 48 - 26
controllers/bi_dashboard.go

@@ -5,7 +5,6 @@ import (
 	"errors"
 	"eta_gn/eta_api/models"
 	"eta_gn/eta_api/models/bi_dashboard"
-	"eta_gn/eta_api/services"
 	"eta_gn/eta_api/services/ppt"
 	"eta_gn/eta_api/utils"
 	"time"
@@ -67,19 +66,41 @@ func (this *BIDaShboardController) AddDashboard() {
 		return
 	}
 
-	//item := &bi_dashboard.BiDashboard{
-	//	BiDashboardClassifyId: int(req.ClassifyId),
-	//	BiDashboardName:       req.BiDashboardName,
-	//	SysAdminId:            this.SysUser.AdminId,
-	//	SysAdminName:          this.SysUser.AdminName,
-	//	//Sort:                  0,
-	//	CreateTime:            time.Now(),
-	//	ModifyTime:            time.Now(),
-	//	State:                 1,
-	//}
-	//for i, listReq := range req.List {
-	//
-	//}
+	item := &bi_dashboard.BiDashboard{
+		BiDashboardClassifyId: req.ClassifyId,
+		BiDashboardName:       req.BiDashboardName,
+		SysAdminId:            this.SysUser.AdminId,
+		SysAdminName:          this.SysUser.AdminName,
+		//Sort:                  0,
+		CreateTime:            time.Now(),
+		ModifyTime:            time.Now(),
+		State:                 1,
+	}
+	id, e := bi_dashboard.AddBiDashboard(item)
+	if e != nil {
+		err = e
+		br.Msg = "新增失败"
+		br.ErrMsg = "新增失败,Err:" + e.Error()
+		return
+	}
+	detailList := make([]*bi_dashboard.BiDashboardDetail, 0)
+	for _, v := range req.List {
+		item := &bi_dashboard.BiDashboardDetail{
+			BiDashboardId: int(id),
+			Type:          v.Type,
+			UniqueCode:    v.UniqueCode,
+			Sort:          v.Sort,
+			CreateTime:    time.Now(),
+			ModifyTime:    time.Now(),
+		}
+		detailList = append(detailList, item)
+	}
+	err = bi_dashboard.AddBiDashboardDetailMulti(detailList)
+	if err != nil {
+		br.Msg = "新增详情失败"
+		br.ErrMsg = "新增详情失败,Err:" + err.Error()
+		return
+	}
 
 
 	br.Ret = 200
@@ -291,25 +312,26 @@ func (this *BIDaShboardController) DetailPpt() {
 		br.Ret = 408
 		return
 	}
-	pptId, _ := this.GetInt("PptId")
+	dashboardId, _ := this.GetInt("DashboardId")
+
 
-	pptInfo, err := models.GetPptV2ById(pptId)
+	dashboardItem, err := bi_dashboard.GetDashboardById(dashboardId)
 	if err != nil {
-		br.Msg = "信息获取失败"
-		br.ErrMsg = "信息获取失败,Err:" + err.Error()
+		err = errors.New("我的看板列表查询出错:" + err.Error())
 		return
 	}
 
-	// 编辑中
-	editor, e := services.UpdatePptEditing(pptId, 0, sysUser.AdminId, sysUser.RealName, false)
-	if e != nil {
-		br.Msg = "操作失败"
-		br.ErrMsg = "更新编辑状态失败, err: " + e.Error()
+	detailList, err := bi_dashboard.GetBiDashboardDetailById(dashboardId)
+	if err != nil {
+		br.Msg = "详情获取失败"
+		br.ErrMsg = "详情获取失败,Err:" + err.Error()
 		return
 	}
-	resp := new(models.PPTDetailResp)
-	resp.PptV2 = pptInfo
-	resp.Editor = editor
+
+
+	resp := new(bi_dashboard.DashboardDetailResp)
+	resp.BiDashboard = dashboardItem
+	resp.List = detailList
 
 	br.Ret = 200
 	br.Success = true

+ 27 - 9
models/bi_dashboard/bi_dashboard.go

@@ -6,15 +6,15 @@ import (
 )
 
 type BiDashboard struct {
-	BiDashboardId         int       `gorm:"primaryKey;autoIncrement;column:bi_dashboard_id" json:"biDashboardId"` // bi看板id
-	BiDashboardClassifyId int       `gorm:"column:bi_dashboard_classify_id" json:"biDashboardClassifyId"`         // 看板分类id
-	BiDashboardName       string    `gorm:"column:bi_dashboard_name;size:255" json:"biDashboardName"`             // 看板名称
-	SysAdminId            int       `gorm:"column:sys_admin_id" json:"sysAdminId"`                                // 创建人ID
-	SysAdminName          string    `gorm:"column:sys_admin_name;size:128" json:"sysAdminName"`                   // 创建人姓名
-	Sort                  int       `gorm:"column:sort" json:"sort"`                                              // 排序字段
-	CreateTime            time.Time `gorm:"column:create_time" json:"createTime"`                                 // 创建时间
-	ModifyTime            time.Time `gorm:"column:modify_time" json:"modifyTime"`                                 // 更新时间
-	State                 int       `gorm:"column:state" json:"state"`                                            // 状态
+	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"`                                    // 状态
 }
 
 // tableName
@@ -53,3 +53,21 @@ func GetBiDashboardList(condition string, pars []interface{}) (items []*BiDashbo
 	err = global.DEFAULT_DmSQL.Raw(sql, pars...).Find(&items).Error
 	return
 }
+
+// GetDashboardById 获取看板
+func GetDashboardById(id int) (item *BiDashboard, err error) {
+	//o := orm.NewOrmUsingDB("rddp")
+	sql := `SELECT * FROM bi_dashboard WHERE bi_dashboard_classify_id = ? limit 1`
+
+
+	//sql += `ORDER BY create_time DESC LIMIT ?,?`
+	//_, err = o.Raw(sql).QueryRows(&items)
+	err = global.DEFAULT_DmSQL.Raw(sql, id).First(&item).Error
+	return
+}
+
+// DashboardDetailResp 详情响应体
+type DashboardDetailResp struct {
+	*BiDashboard
+	List []*BiDashboardDetail
+}

+ 5 - 5
models/bi_dashboard/bi_dashboard_classify.go

@@ -6,11 +6,11 @@ import (
 )
 
 type BiDashboardClassify struct {
-	BiDashboardClassifyId int       `gorm:"primaryKey;autoIncrement;column:bi_dashboard_classify_id" json:"biDashboardClassifyId"` // bi看板分类id
-	BiDashboardClassifyName string    `gorm:"column:bi_dashboard_classify_name;size:255;not null" json:"biDashboardClassifyName"` // 看板分类名称
-	Sort                   int       `gorm:"column:sort" json:"sort"` // 排序字段
-	CreateTime             time.Time `gorm:"column:create_time" json:"createTime"` // 创建时间
-	ModifyTime             time.Time `gorm:"column:modify_time" json:"modifyTime"` // 更新时间
+	BiDashboardClassifyId int       `gorm:"primaryKey;autoIncrement;column:bi_dashboard_classify_id"` // bi看板分类id
+	BiDashboardClassifyName string    `gorm:"column:bi_dashboard_classify_name;size:255;not null" ` // 看板分类名称
+	Sort                   int       `gorm:"column:sort" ` // 排序字段
+	CreateTime             time.Time `gorm:"column:create_time" ` // 创建时间
+	ModifyTime             time.Time `gorm:"column:modify_time"` // 更新时间
 }
 
 // tableName

+ 14 - 8
models/bi_dashboard/bi_dashboard_detail.go

@@ -6,13 +6,13 @@ import (
 )
 
 type BiDashboardDetail struct {
-	BiDashboardDetailId int       `gorm:"primaryKey;autoIncrement;column:bi_dashboard_detail_id" json:"biDashboardDetailId"` // bi看板id
-	BiDashboardId       int       `gorm:"column:bi_dashboard_id" json:"biDashboardId"`                                       // 看板id
-	Type                int       `gorm:"column:type" json:"type"`                                                           // 1图表 2表格
-	UniqueCode          string    `gorm:"column:unique_code;size:32;not null" json:"uniqueCode"`                             // 报告唯一编码
-	Sort                int       `gorm:"column:sort" json:"sort"`                                                           // 排序字段
-	CreateTime          time.Time `gorm:"column:create_time" json:"createTime"`                                              // 创建时间
-	ModifyTime          time.Time `gorm:"column:modify_time" json:"modifyTime"`                                              // 更新时间
+	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表格
+	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
@@ -26,6 +26,12 @@ func AddBiDashboardDetail(item *BiDashboardDetail) (err error) {
 	return
 }
 
+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
+}
+
 // multiAdd
 func AddBiDashboardDetailMulti(items []*BiDashboardDetail) (err error) {
 	return global.DEFAULT_DmSQL.CreateInBatches(items, 100).Error
@@ -33,7 +39,7 @@ func AddBiDashboardDetailMulti(items []*BiDashboardDetail) (err error) {
 
 type AddDashboardReq struct {
 	List            []*AddDashboardListReq
-	ClassifyId      int64  `description:"分类id"`
+	ClassifyId      int    `description:"分类id"`
 	BiDashboardName string `description:"看板名称"`
 }
 

+ 4 - 4
models/bi_dashboard/bi_dashboard_grant.go

@@ -6,10 +6,10 @@ import (
 )
 
 type BiDashboardGrant struct {
-	GrantId       int       `gorm:"primaryKey;autoIncrement;column:grant_id" json:"grantId"` // 授权id
-	BiDashboardId int       `gorm:"column:bi_dashboard_id" json:"biDashboardId"`        // 看板id
-	AdminId       int       `gorm:"column:admin_id" json:"adminId"`                   // 授权的用户id
-	CreateTime    time.Time `gorm:"column:create_time" json:"createTime"`               // 授权时间
+	GrantId       int       `gorm:"primaryKey;autoIncrement;column:grant_id"` // 授权id
+	BiDashboardId int       `gorm:"column:bi_dashboard_id" `        // 看板id
+	AdminId       int       `gorm:"column:admin_id"`                   // 授权的用户id
+	CreateTime    time.Time `gorm:"column:create_time"`               // 授权时间
 }
 
 // tableName

+ 45 - 0
routers/commentsRouter.go

@@ -8098,6 +8098,51 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta_gn/eta_api/controllers:BIDaShboardController"] = append(beego.GlobalControllerRouter["eta_gn/eta_api/controllers:BIDaShboardController"],
+        beego.ControllerComments{
+            Method: "AddDashboard",
+            Router: `/add`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta_gn/eta_api/controllers:BIDaShboardController"] = append(beego.GlobalControllerRouter["eta_gn/eta_api/controllers:BIDaShboardController"],
+        beego.ControllerComments{
+            Method: "DeletePpt",
+            Router: `/delete`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta_gn/eta_api/controllers:BIDaShboardController"] = append(beego.GlobalControllerRouter["eta_gn/eta_api/controllers:BIDaShboardController"],
+        beego.ControllerComments{
+            Method: "DetailPpt",
+            Router: `/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta_gn/eta_api/controllers:BIDaShboardController"] = append(beego.GlobalControllerRouter["eta_gn/eta_api/controllers:BIDaShboardController"],
+        beego.ControllerComments{
+            Method: "EditPpt",
+            Router: `/edit`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta_gn/eta_api/controllers:BIDaShboardController"] = append(beego.GlobalControllerRouter["eta_gn/eta_api/controllers:BIDaShboardController"],
+        beego.ControllerComments{
+            Method: "MyList",
+            Router: `/my_list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta_gn/eta_api/controllers:BannerController"] = append(beego.GlobalControllerRouter["eta_gn/eta_api/controllers:BannerController"],
         beego.ControllerComments{
             Method: "Upload",