You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
148 lines
14 KiB
148 lines
14 KiB
package modelshr
|
|
|
|
import (
|
|
"appPlatform/middleware/grocerystore"
|
|
"appPlatform/overall"
|
|
"encoding/json"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// 员工档案(主)
|
|
type UserOrgCont struct {
|
|
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"`
|
|
Number string `json:"number" gorm:"column:number;type:varchar(30) unsigned;not null;comment:员工工号"`
|
|
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:姓名"`
|
|
Icon string `json:"icon" gorm:"column:icon;type:varchar(255) unsigned;default:'';not null;comment:头像"`
|
|
HireClass int `json:"hireclass" gorm:"column:hire_class;type:tinyint(1) unsigned;default:1;not null;comment:雇佣类型(1:雇佣入职;2:再入职;)"`
|
|
EmpType int `json:"emptype" gorm:"column:emp_type;type:tinyint(1) unsigned;default:1;not null;comment:用工关系(1:临时工 , 2:编外人员 ;3:实习&实习生;4:试用员工;5:待分配;6:待岗;7:临时调入;8:正式员工;9:长期病假;10:停薪留职;11:退休;12:辞职;13:辞退;14:离职)"`
|
|
MainDeparment int64 `json:"maindeparment" gorm:"column:maindeparment;type:bigint(20) unsigned;default:0;not null;comment:主部门"`
|
|
Deparment string `json:"deparment" gorm:"column:deparment;type:text;comment:部门"`
|
|
AdminOrg int64 `json:"adminorg" gorm:"column:admin_org;type:bigint(20) unsigned;default:0;not null;comment:所属行政组织"`
|
|
TeamId int64 `json:"teamid" gorm:"column:teamid;type:bigint(20) unsigned;default:0;not null;comment:班组"`
|
|
JobClass int64 `json:"jobclass" gorm:"column:job_class;type:bigint(20) unsigned;default:2;not null;comment:职务分类"`
|
|
JobId int64 `json:"jobid" gorm:"column:job_id;type:bigint(20) unsigned;default:0;not null;comment:职务"`
|
|
JobLeve int64 `json:"jobleve" gorm:"column:job_leve;type:bigint(20) unsigned;default:0;not null;comment:职务等级"`
|
|
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:写入时间"`
|
|
EiteTime int64 `json:"eitetime" gorm:"column:eite_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"`
|
|
Wechat string `json:"wechat" gorm:"column:wechat;type:varchar(255) unsigned;default:'';not null;comment:微信UserId"`
|
|
WorkWechat string `json:"workwechat" gorm:"column:work_wechat;type:varchar(255) unsigned;default:'';not null;comment:企业微信UserId"`
|
|
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)`
|
|
Key int64 `json:"key" gorm:"column:key;type:bigint(50) unsigned;default:0;not null;comment:key"`
|
|
IsAdmin int `json:"isadmin" gorm:"column:is_admin;type:tinyint(1) unsigned;default:1;not null;comment:是否为管理员(1:不是;2:分公司;3:集团管理员;4:超级管`
|
|
Password string `json:"password" gorm:"column:password;type:varchar(255) unsigned;default:'';not null;comment:密码"`
|
|
Role string `json:"role" gorm:"column:role;type:longtext;comment:角色"`
|
|
EmpTypeName string `json:"emptypename" gorm:"column:emp_type_name;type:varchar(255) unsigned;default:'';not null;comment:用工关系中文"`
|
|
HireClassName string `json:"hireclassname" gorm:"column:hire_class_name;type:varchar(255) unsigned;default:'';not null;comment:雇佣类型中文"`
|
|
SunMainDeparment int64 `json:"sunmaindeparment" gorm:"column:sun_main_deparment;type:bigint(20) unsigned;default:0;not null;comment:二级主部门"`
|
|
Ruleid int64 `json:"ruleid" gorm:"column:ruleid;type:bigint(20) unsigned;default:0;not null;comment:轮询规则"`
|
|
IconPhoto string `json:"iconphoto" gorm:"column:icon_photo;type:longtext;default:'';not null;comment:照片"`
|
|
PersonInCharge int `json:"personincharge" gorm:"column:person_in_charge;type:tinyint(1) unsigned;default:1;not null;comment:负责人(1:是;2:否)`
|
|
ResponsibleDepartment string `json:"responsibledepartment" gorm:"column:responsible_department;type:longtext;default:'';not null;comment:负责的行政组织"`
|
|
ResponsibleDepartmentJson string `json:"responsibledepartmentjson" gorm:"column:responsible_department_json;type:longtext;default:'';not null;comment:负责的行政组织json"`
|
|
WorkSection int64 `json:"workSection" gorm:"column:work_section;type:bigint(20) unsigned;default:0;not null;comment:工段"`
|
|
IsShowTrue int64 `json:"isShowTrue" gorm:"column:is_show_true;type:int(5) unsigned;default:2;not null;comment:信息是否锁定`
|
|
ExcelTemplate int64 `json:"excelTemplate" gorm:"column:excel_template;type:bigint(20) unsigned;default:0;not null;comment:信息来源于哪个模板`
|
|
PositionCategory string `json:"positionCategory" gorm:"column:positionCategory;type:tinytext;comment:岗位序列"`
|
|
|
|
Idcardno string `json:"idcardno" gorm:"column:idcardno;type:varchar(50) unsigned;default:'';not null;comment:身份证号"`
|
|
Passportno string `json:"passportno" gorm:"column:passportno;type:varchar(50) unsigned;default:'';not null;comment:护照号码"`
|
|
Globalroaming string `json:"globalroaming" gorm:"column:globalroaming;type:varchar(50) unsigned;default:'';not null;comment:国际区号"`
|
|
Mobilephone string `json:"mobilephone" gorm:"column:mobilephone;type:varchar(50) unsigned;default:'';not null;comment:手机号码"`
|
|
Email string `json:"email" gorm:"column:email;type:varchar(255) unsigned;default:'';not null;comment:电子邮件"`
|
|
Gender int `json:"gender" gorm:"column:gender;type:tinyint(1) unsigned;default:1;not null;comment:性别(1:男性;2:女性;3:中性)"`
|
|
Birthday int64 `json:"birthday" gorm:"column:birthday;type:bigint(20) unsigned;default:0;not null;comment:birthday"`
|
|
Myfolk string `json:"myfolk" gorm:"column:myfolk;type:varchar(50) unsigned;default:'';not null;comment:民族"`
|
|
Nativeplace string `json:"nativeplace" gorm:"column:nativeplace;type:varchar(255) unsigned;default:'';not null;comment:籍贯"`
|
|
Idcardstartdate int64 `json:"idcardstartdate" gorm:"column:idcardstartdate;type:bigint(20) unsigned;default:0;not null;comment:身份证有效期开始"`
|
|
Idcardenddate int64 `json:"idcardenddate" gorm:"column:idcardenddate;type:bigint(20) unsigned;default:0;not null;comment:身份证有效期结束"`
|
|
Idcardaddress string `json:"idcardaddress" gorm:"column:idcardaddress;type:varchar(255) unsigned;default:'';not null;comment:身份证地址"`
|
|
IdcardIssued string `json:"idcardIssued" gorm:"column:idcardIssued;type:varchar(255) unsigned;default:'';not null;comment:身份证签发机关"`
|
|
Health int `json:"health" gorm:"column:health;type:tinyint(1) unsigned;default:1;not null;comment:健康状况(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废)"`
|
|
Maritalstatus int `json:"maritalstatus" gorm:"column:maritalstatus;type:tinyint(1) unsigned;default:1;not null;comment:婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异)"`
|
|
Internaltelephone string `json:"internaltelephone" gorm:"column:internaltelephone;type:varchar(255) unsigned;default:'';not null;comment:内线电话"`
|
|
Currentresidence string `json:"currentresidence" gorm:"column:currentresidence;type:varchar(255) unsigned;default:'';not null;comment:现居住地址"`
|
|
Constellation int `json:"constellationing" gorm:"column:constellationing;type:tinyint(3) unsigned;comment:星座(1:白羊座;2:金牛座;3:双子座;4:巨蟹座;5:狮子座;6:处女座;7:天枰座;8:天蝎座;9:射手座;10:摩羯座;11:水瓶座;12:双鱼座)"`
|
|
Isdoubleworker int `json:"isdoubleworker" gorm:"column:isdoubleworker;type:tinyint(1) unsigned;default:1;comment:是否双职工(1:是;2:否)"`
|
|
Isveterans int `json:"isveterans" gorm:"column:isveterans;type:tinyint(1) unsigned;default:1;comment:是否为退役军人(1:是;2:否)"`
|
|
Veteransnumber string `json:"veteransnumber" gorm:"column:veteransnumber;type:varchar(255) unsigned;default:'';comment:退役证编号"`
|
|
Jobstartdate int64 `json:"jobstartdate" gorm:"column:jobstartdate;type:bigint(20) unsigned;default:0;comment:参加工作日期"`
|
|
Entrydate int64 `json:"entrydate" gorm:"column:entrydate;type:bigint(20) unsigned;default:0;comment:入职日期"`
|
|
Probationperiod int `json:"probationperiod" gorm:"column:probationperiod;type:int(5) unsigned;default:0;comment:试用期"`
|
|
Planformaldate int64 `json:"planformaldate" gorm:"column:planformaldate;type:bigint(20) unsigned;default:0;comment:预计转正日期"`
|
|
PoliticalOutlook int `json:"politicaloutlook" gorm:"column:political_outlook;type:tinyint(3) unsigned;default:1;comment:政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)"`
|
|
|
|
MaritalstatusCn string `json:"maritalstatuscn" gorm:"column:maritalstatus_cn;type:varchar(50) unsigned;default:'';not null;comment:婚姻状况汉字说明"`
|
|
ConstellationingCn string `json:"constellationingcn" gorm:"column:constellationing_cn;type:varchar(50) unsigned;default:'';not null;comment:星座汉字说明"`
|
|
PoliticalOutlookCn string `json:"politicaloutlookcn" gorm:"column:political_outlook_cn;type:varchar(50) unsigned;default:'';not null;comment:政治面貌汉字说明"`
|
|
HealthCn string `json:"healthcn" gorm:"column:health_cn;type:varchar(50) unsigned;default:'';not null;comment:健康状况中文说明"`
|
|
NameUsedBefore string `json:"nameusedbefore" gorm:"column:name_used_before;type:varchar(255) unsigned;default:'';not null;comment:曾用名"`
|
|
CareerPlanning string `json:"career_planning" gorm:"column:career_planning;type:longtext;default:'';not null;comment:职业生涯规划"`
|
|
HelpObtained string `json:"help_obtained" gorm:"column:help_obtained;type:longtext;default:'';not null;comment:个人期望从组织获得的帮助"`
|
|
Hobby string `json:"hobby" gorm:"column:hobby;type:text;default:'';not null;comment:爱好"`
|
|
|
|
DomicileType string `json:"domicileType" gorm:"column:domicile_type;type:varchar(100) unsigned;default:'';not null;comment:户籍类型"`
|
|
IdCardnoLongTerm int `json:"idCardnoLongTerm" gorm:"column:idCardnoLongTerm;type:int(1) unsigned;default:0;not null;comment:身份证是否长期有效(1:是;2:否)"`
|
|
MobileShortNumber string `json:"mobileShortNumber" gorm:"column:mobileShortNumber;type:varchar(50) unsigned;default:'';not null;comment:手机小号"`
|
|
Channel int `json:"channel" gorm:"column:channel;type:int(1) unsigned;default:0;not null;comment:入职渠道(1:社会招聘;2:校园招聘;3:内部推荐)"`
|
|
BloodType string `json:"bloodType" gorm:"column:bloodType;type:varchar(10) unsigned;default:'';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;"`
|
|
AssignType int `json:"assignType" gorm:"column:assignType;type:int(1) unsigned;default:50;not null;comment:1:主职;2:兼职"`
|
|
}
|
|
|
|
func (cont *UserOrgCont) TableName() string {
|
|
return "user_org_cont"
|
|
}
|
|
|
|
// 编辑员工档案
|
|
func (cont *UserOrgCont) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
|
|
err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error
|
|
fmt.Printf("编辑信息:---2--->%v\n", err)
|
|
err = overall.CONSTANT_DB_HrInside.Model(&cont).Where(whereMap).Updates(saveData).Error
|
|
fmt.Printf("编辑信息:---3--->%v\n", err)
|
|
return
|
|
}
|
|
|
|
// 获取员工档案
|
|
func (cont *UserOrgCont) 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
|
|
}
|
|
|
|
// 根据ID获取行政组织内容
|
|
func (cont *UserOrgCont) RedisCont(key string, class int) (err error) {
|
|
redisFileKey := fmt.Sprintf("UserDossier:Info:%v_%v", key, overall.CONSTANT_CONFIG.RedisPrefixStr.Alias)
|
|
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS4) //设定redis库
|
|
isTrue, tokens := redisClient.Get(redisFileKey)
|
|
if isTrue && tokens != "" {
|
|
err = json.Unmarshal([]byte(tokens), &cont)
|
|
return
|
|
} else {
|
|
var jsonStr []byte
|
|
switch class {
|
|
case 1:
|
|
err = overall.CONSTANT_DB_HR.Model(&cont).Where("`number` = ?", key).First(&cont).Error
|
|
case 2:
|
|
err = overall.CONSTANT_DB_HR.Model(&cont).Where("`key` = ?", key).First(&cont).Error
|
|
default:
|
|
err = overall.CONSTANT_DB_HR.Model(&cont).Where("`id` = ?", key).First(&cont).Error
|
|
}
|
|
|
|
if err == nil {
|
|
redisClient.SetRedisTime(0)
|
|
jsonStr, err = json.Marshal(cont)
|
|
redisClient.Set(redisFileKey, string(jsonStr))
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|