package models import ( "hr_server/overall" "strings" ) //行政组织 type AdministrativeOrganization struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` Number string `json:"number" gorm:"column:number;type:varchar(50) unsigned;default:'';not null;comment:行政编码"` Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:组织名称"` Superior int64 `json:"superior" gorm:"column:superior;type:bigint(20) unsigned;default:0;not null;comment:上级ID"` OrganizationType int64 `json:"organizationtype" gorm:"column:organization_type;type:bigint(20) unsigned;default:0;not null;comment:行政组织类型"` Abbreviation string `json:"abbreviation" gorm:"column:abbreviation;type:varchar(255) unsigned;default:'';not null;comment:行政组织简称"` Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` WechatOrganizationId int64 `json:"wechatorganizationid" gorm:"column:wechat_organization_id;type:bigint(20) unsigned;default:0;not null;comment:微信组织架构对照码"` } func (AdministrativeOrganization *AdministrativeOrganization) TableName() string { return "administrative_organization" } //编辑行政组织内容 func (cont *AdministrativeOrganization) EiteCont(whereMap map[string]interface{}, saveData map[string]interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error return } //获取行政组织内容 func (cont *AdministrativeOrganization) GetCont(whereMap map[string]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 *AdministrativeOrganization) CountCont(whereMap map[string]interface{}) (countId int64) { overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) return }