package models import ( "hr_server/overall" "strings" ) type UserOrg struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` Userkey int64 `json:"userKey" gorm:"primaryKey;column:userKey;type:bigint(20) unsigned;not null;comment:员工唯一识别符;"` Company int64 `json:"company" gorm:"primaryKey;column:company;type:bigint(20) unsigned;not null;comment:所属公司;"` Orgid int64 `json:"orgid" gorm:"primaryKey;column:orgid;type:bigint(20) unsigned;not null;comment:行政组织ID;"` Position int64 `json:"position" gorm:"primaryKey;column:position;type:bigint(20) unsigned;not null;comment:职位;"` TeamsId int64 `json:"teamsId" gorm:"primaryKey;column:teamsId;type:bigint(20) unsigned;not null;comment:班组Id;"` StartTime int64 `json:"startTime" gorm:"primaryKey;column:startTime;type:bigint(20) unsigned;not null;comment:任职开始时间;"` AssignType int `json:"assignType" gorm:"column:assignType;type:int(1) unsigned;default:50;not null;comment:1:主职;2:兼职"` Time int64 `json:"time" gorm:"primaryKey;column:time;type:bigint(20) unsigned;not null;comment:编辑时间;"` } func (UserOrg *UserOrg) TableName() string { return "userOrg" } // 编辑内容 func (cont *UserOrg) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error return } // 获取内容 func (cont *UserOrg) 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 *UserOrg) CountCont(whereMap interface{}) (countId int64) { overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) return } // 读取全部信息 func (cont *UserOrg) ContMap(whereMap interface{}, field ...string) (countAry []UserOrg, 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 *UserOrg) DelCont(whereMap interface{}) (err error) { err = overall.CONSTANT_DB_HR.Where(whereMap).Delete(&cont).Error return }