1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- package bi_dashboard
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type BiDashboardDetail struct {
- BiDashboardDetailId int `orm:"column(bi_dashboard_detail_id);pk" ` // 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
- func (m *BiDashboardDetail) TableName() string {
- return "bi_dashboard_detail"
- }
- // add
- //func AddBiDashboardDetail(item *BiDashboardDetail) (err error) {
- //err = global.DEFAULT_DmSQL.Create(item).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
- o := orm.NewOrm()
- _, err = o.Raw("SELECT * FROM bi_dashboard_detail where bi_dashboard_id = ?", id).QueryRows(&list)
- return
- }
- // multiAdd
- func AddBiDashboardDetailMulti(items []*BiDashboardDetail) (err error) {
- o := orm.NewOrm()
- _, err = o.InsertMulti(len(items), items)
- return
- }
- // del
- func DeleteBiDashboardDetail(id int) (err error) {
- o := orm.NewOrm()
- _, err = o.Raw("DELETE from bi_dashboard_detail where bi_dashboard_id=?", id).Exec()
- return
- }
- 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
- o := orm.NewOrm()
- _, err = o.Raw("UPDATE bi_dashboard_detail SET bi_dashboard_id=?,type=?,unique_code=?,sort=?,modify_time=? WHERE bi_dashboard_detail_id=?", item.BiDashboardId, item.Type, item.UniqueCode, item.Sort, item.ModifyTime, item.BiDashboardDetailId).Exec()
- return
- }
- 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
- o := orm.NewOrm()
- _, err = o.Raw("DELETE from bi_dashboard_detail where bi_dashboard_detail_id=?", id).Exec()
- return
- }
|