package modelskpi import ( "appPlatform/overall" "strings" ) // 子栏目关联指标视图 type SonTargetFather struct { Id int64 `json:"id" gorm:"primaryKey;column:q_id;type:bigint(20) unsigned;not null;comment:Id;index"` Title string `json:"title" gorm:"column:q_title;type:varchar(255);comment:指标子栏目名称"` ParentId int64 `json:"parentid" gorm:"column:q_parent_id;type:bigint(20) unsigned;default:0;not null;comment:归属指标"` State int `json:"state" gorm:"column:q_state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` AddTime int64 `json:"addTime" gorm:"column:q_time;type:bigint(20) unsigned;default:0;not null;comment:制定时间"` Depart string `json:"depart" gorm:"column:q_depart;type:mediumtext;comment:关联部门"` EtTitle string `json:"ettitle" gorm:"column:et_title;type:varchar(255);comment:指标名称"` Type int `json:"type" gorm:"column:et_type;type:int(1) unsigned;default:1;not null;comment:1:定性考核;2:定量考核"` Dimension int64 `json:"dimension" gorm:"column:et_dimension;type:bigint(20) unsigned;default:0;not null;comment:维度"` Key int64 `json:"key" gorm:"column:et_key;type:bigint(20) unsigned;default:0;not null;comment:UUID"` Uniteing string `json:"unites" gorm:"column:et_unit;type:varchar(255);comment:计量单位"` Cycles int `json:"cycle" gorm:"column:et_cycle;type:tinyint(1) unsigned;default:1;not null;comment:1:班;2:天;3:周;4:月;5:季度;6:年"` CycleAttres int `json:"cycleattr" gorm:"column:et_cycleattr;type:int(9) unsigned;default:1;not null;comment:辅助计数"` ScoringMethod int `json:"scoringmethod" gorm:"column:et_scoring_method;type:tinyint(1) unsigned;default:1;not null;comment:计分方式(1:自动;2:手动)"` } func (SonTargetFather *SonTargetFather) TableName() string { return "son_target_father" } // 编辑内容 func (cont *SonTargetFather) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error return } // 获取内容 func (cont *SonTargetFather) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_KPI.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 *SonTargetFather) CountCont(whereMap interface{}) (countId int64) { overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) return } // 读取全部信息 func (cont *SonTargetFather) ContMap(whereMap interface{}, field ...string) (countAry []SonTargetFather, err error) { gormDb := overall.CONSTANT_DB_KPI.Model(&cont) if len(field) > 0 { fieldStr := strings.Join(field, ",") gormDb = gormDb.Select(fieldStr) } err = gormDb.Where(whereMap).Order("sort ASC").Find(&countAry).Error return } // 删除内容 func (cont *SonTargetFather) DelCont(whereMap interface{}) (err error) { err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error return }