package modelAppPlatform import ( "appPlatform/overall" "strings" ) // 个人图表设置 type Mychart struct { Uuid int64 `gorm:"column:uuid;type:bigint(20) unsigned;primary_key" json:"uuid"` TableKey string `gorm:"column:tableKey;type:varchar(200);comment:关联得表单key" json:"tableKey"` UserKey int64 `gorm:"column:userKey;type:bigint(20) unsigned;comment:使用人的KEY;NOT NULL" json:"userKey"` ChartView string `gorm:"column:chartView;type:longtext;comment:图标设定值" json:"chartView"` EditTime int64 `gorm:"column:editTime;type:bigint(20) unsigned;comment:编辑时间" json:"editTime"` } func (m Mychart) Create(mychart *Mychart) { panic("unimplemented") } func (m *Mychart) TableName() string { return "mychart" } // 写入内容 func (cont *Mychart) WriteCont() (err error) { err = overall.CONSTANT_DB_AppPlatform.Create(&cont).Error return } // 编辑内容 func (cont *Mychart) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Updates(saveData).Error return } // 获取内容 func (cont *Mychart) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_AppPlatform.Model(&cont) if len(field) > 0 { fieldStr := strings.Join(field, ",") gormDb = gormDb.Select(fieldStr) } gormDb = gormDb.Where(whereMap) err = gormDb.First(&cont).Error return } // 根据条件获取总数 func (cont *Mychart) CountCont(whereMap interface{}) (countId int64) { overall.CONSTANT_DB_AppPlatform.Model(&cont).Where(whereMap).Count(&countId) return } // 读取全部信息 func (cont *Mychart) ContMap(whereMap interface{}, field ...string) (countAry []Mychart, err error) { gormDb := overall.CONSTANT_DB_AppPlatform.Model(&cont) if len(field) > 0 { fieldStr := strings.Join(field, ",") gormDb = gormDb.Select(fieldStr) } err = gormDb.Where(whereMap).Find(&countAry).Error return } // 删除内容 func (cont *Mychart) DelCont(whereMap interface{}) (err error) { err = overall.CONSTANT_DB_AppPlatform.Where(whereMap).Delete(&cont).Error return }