package modelshr import ( "appPlatform/overall" "strings" ) // 轮询规则 type PollingRules struct { Id int64 `gorm:"primaryKey;column:id" json:"id"` //type:int64 comment: version:2022-11-16 09:16 Teamid int64 `gorm:"column:teamid" json:"teamid"` //type:int64 comment:班组;规则 version:2022-11-16 09:16 State int `gorm:"column:state" json:"state"` //type:*int comment:状态(1:启用;2:禁用;3:删除);状态(1:启用;2:禁用;3:删除) version:2022-11-16 09:16 Time int64 `gorm:"column:time" json:"time"` //type:int64 comment:时间;时间 version:2022-11-16 09:16 Sort int `gorm:"column:sort" json:"sort"` //type:*int comment:排序 version:2022-11-16 09:16 TypeId int64 `gorm:"column:type_id" json:"typeid"` //type:int64 comment:类型 TeamName string `gorm:"column:teamname" json:"teamname"` } func (PollingRules *PollingRules) TableName() string { return "polling_rules" } // 编辑内容 func (cont *PollingRules) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error return } // 获取内容 func (cont *PollingRules) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.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 *PollingRules) CountCont(whereMap interface{}) (countId int64) { overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) return } // 读取全部信息 func (cont *PollingRules) ContMap(whereMap interface{}, field ...string) (countAry []PollingRules, err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { fieldStr := strings.Join(field, ",") gormDb = gormDb.Select(fieldStr) } err = gormDb.Where(whereMap).Find(&countAry).Error return } // 删除内容 func (cont *PollingRules) DelCont(whereMap interface{}) (err error) { err = overall.CONSTANT_DB_HR.Where(whereMap).Delete(&cont).Error return }