package modelskpi import ( "fmt" "key_performance_indicators/overall" "strings" ) // 岗位指标 type PostTarget struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` Title string `json:"title" gorm:"column:title;type:varchar(255) unsigned;default:'';not null;comment:标题"` Type int `json:"type" gorm:"column:type;type:int(1) unsigned;default:1;not null;comment:1:定性考核;2:定量考核"` State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` Share int `json:"share" gorm:"column:share;type:int(1) unsigned;default:1;not null;comment:1:共用;2:私用"` ReleDepart int64 `json:"reledepart" gorm:"column:rele_depart;type:bigint(20) unsigned;default:0;not null;comment:相关部门"` DepartmentsPost string `json:"departmentspost" gorm:"column:departments_post;type:text ;default:'';comment:相关岗位"` Dimension int64 `json:"dimension" gorm:"column:dimension;type:bigint(20) unsigned;default:0;not null;comment:维度"` Key int64 `json:"key" gorm:"column:key;type:bigint(20) unsigned;default:0;not null;comment:UUID"` Report string `json:"report" gorm:"column:report;type:text ;default:'';comment:上报人"` Unit string `json:"unit" gorm:"column:unit;type:varchar(255) unsigned;default:'';not null;comment:单位"` Cycle int `json:"cycle" gorm:"column:cycle;type:int(1) unsigned;default:1;not null;comment:1:班;2:天;3:周;4:月;5:季度;6:年"` Cycleattr int `json:"cycleattr" gorm:"column:cycleattr;type:int(9) unsigned;default:1;not null;comment:辅助计数"` ScoringMethod int `json:"scoringmethod" gorm:"column:scoring_method;type:int(1) unsigned;default:0;not null;comment:计分方式(1:自动;2:手动)"` VisibleRange string `json:"visiblerange" gorm:"column:visible_range;type:text ;default:'';comment:可见范围"` VisibleGroup string `json:"visiblegroup" gorm:"column:visible_group;type:text ;default:'';comment:可见范围(集团)"` } func (PostTarget *PostTarget) TableName() string { return "post_target" } // 编辑内容 func (cont *PostTarget) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error return } // 获取内容 func (cont *PostTarget) 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) for _, v := range field { gormDb = gormDb.Select(v) } } gormDb = gormDb.Where(whereMap) err = gormDb.First(&cont).Error fmt.Printf("GetCont---------->%v------->%v\n", err, cont) return } // 根据条件获取总数 func (cont *PostTarget) CountCont(whereMap interface{}) (countId int64) { overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId) return } // 读取全部信息 func (cont *PostTarget) ContMap(whereMap interface{}, field ...string) (countAry []PostTarget, 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).Find(&countAry).Error return } // 删除内容 func (cont *PostTarget) DelCont(whereMap interface{}) (err error) { err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error return }