Browse Source

添加人员档案

v1.1_dev
超级管理员 4 years ago
parent
commit
910caa03a9
  1. 2
      README.md
  2. 4
      api/version1/inlet.go
  3. 442
      api/version1/personnelapi/staff.go
  4. 137
      api/version1/personnelapi/type.go
  5. 26
      api/version1/shiyan/shiyan.go
  6. 22
      api/version1/shiyan/type.go
  7. 8
      apirouter/inlet.go
  8. 19
      apirouter/personnel/people.go
  9. 4
      apirouter/personnel/type.go
  10. 18
      apirouter/shiyanrouter/shiyan.go
  11. 3
      apirouter/shiyanrouter/type.go
  12. 4
      config/configApp/appConfig.yaml
  13. 8
      config/configApp/server.go
  14. 21
      config/configJson/org.json
  15. BIN
      hr_server.exe
  16. 11
      initialization/route/route_entry.go
  17. 24
      models/double_worker.go
  18. 2
      models/family_members.go
  19. 27
      models/personnel.go
  20. 2
      models/personnel_change_record.go
  21. 23
      models/personnel_content.go
  22. 18
      models/personnel_education.go
  23. 2
      overall/app_constant.go
  24. 3
      overall/overallhandle/errorcode.go
  25. 76
      overall/overallhandle/overall_handle.go

2
README.md

@ -40,4 +40,6 @@
## Log ## Log
``` ```
2022.04.19 建立人员信息相关数据模型 2022.04.19 建立人员信息相关数据模型
2022.04.20 处理员工档案的增删改查
``` ```

4
api/version1/inlet.go

@ -3,11 +3,15 @@ package version1
import ( import (
"hr_server/api/version1/administrativeorganization" "hr_server/api/version1/administrativeorganization"
"hr_server/api/version1/permitpowerapi" "hr_server/api/version1/permitpowerapi"
"hr_server/api/version1/personnelapi"
"hr_server/api/version1/shiyan"
) )
type ApiInlet struct { type ApiInlet struct {
OrganizationApi administrativeorganization.OrganizationApi OrganizationApi administrativeorganization.OrganizationApi
PermitPowerApi permitpowerapi.PermitPowerApi PermitPowerApi permitpowerapi.PermitPowerApi
StaffApi personnelapi.StaffApi
ShiyanApi shiyan.ShiYan
} }
var AppApiInlet = new(ApiInlet) var AppApiInlet = new(ApiInlet)

442
api/version1/personnelapi/staff.go

@ -0,0 +1,442 @@
package personnelapi
import (
"fmt"
"hr_server/models"
"hr_server/overall"
"hr_server/overall/overallhandle"
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
)
//人员列表
func (s *StaffApi) StaffList(c *gin.Context) {
var requestData peopleList
c.ShouldBindJSON(&requestData)
if requestData.Page < 0 {
requestData.Page = 1
}
if requestData.PageSize < 0 {
requestData.PageSize = 10
}
// gormDb := overall.CONSTANT_DB_HR.Model(&models.JobClass{}).Select("").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type")
var personnelModels models.Personnel
gormDb := overall.CONSTANT_DB_HR.Table(fmt.Sprintf("%s p", personnelModels.TableName())).Select("p.*,pc.mobilephone,pc.gender,pc.isdoubleworker,pc.isveterans,pc.entrydate,pc.probationperiod,pc.planformaldate").Joins("left join personnel_content as pc on pc.number = p.number")
if requestData.Number != "" {
gormDb = gormDb.Where("p.number LIKE ?", "%"+requestData.Number+"%")
}
if requestData.Name != "" {
gormDb = gormDb.Where("p.name LIKE ?", "%"+requestData.Name+"%")
}
if requestData.HireClass != 0 {
gormDb = gormDb.Where("p.hire_class = ?", requestData.HireClass)
}
if requestData.Company != 0 {
gormDb = gormDb.Where("p.company = ?", requestData.Company)
}
if requestData.Deparment != "" {
gormDb = gormDb.Where("FIND_IN_SET(?,p.`deparment`)", requestData.Deparment)
}
if requestData.AdminOrg != 0 {
gormDb = gormDb.Where("p.admin_org = ?", requestData.AdminOrg)
}
if requestData.Position != 0 {
gormDb = gormDb.Where("p.position = ?", requestData.Position)
}
if requestData.EmpType != 0 {
gormDb = gormDb.Where("p.emp_type = ?", requestData.EmpType)
} else {
gormDb = gormDb.Where("p.emp_type IN ?", overall.EmployeeStatusIng)
}
if requestData.Role != "" {
gormDb = gormDb.Where("FIND_IN_SET(?,p.`role`)", requestData.Role)
}
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
total = 0
}
var positionAry []peopleOutList
errGorm := gormDb.Order("p.company ASC,p.deparment ASC,p.admin_org ASC,p.position ASC").Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&positionAry).Error
for i, v := range positionAry {
var getSpur models.Position
getWhe := overallhandle.MapOut()
getWhe["id"] = v.Position
getSpur.GetCont(getWhe, "name")
positionAry[i].PositionName = getSpur.Name
var getSpurDepart models.AdministrativeOrganization
getWheDepart := overallhandle.MapOut()
getWheDepart["id"] = v.Company
getSpurDepart.GetCont(getWheDepart, "name")
positionAry[i].CompanyName = getSpurDepart.Name
//获取部门
departmentAry := strings.Split(v.Deparment, ",")
if len(departmentAry) > 0 {
var departCont []getDepartmentInfo
departErr := overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Select("id,number,name").Where("`id` IN ?", departmentAry).Order("`organization_type` ASC").Find(&departCont)
if departErr == nil {
var departNameAry []string
for _, d_v := range departCont {
departNameAry = append(departNameAry, d_v.Name)
}
if len(departNameAry) > 0 {
positionAry[i].DeparmentName = strings.Join(departNameAry, " ")
}
}
}
}
if errGorm != nil {
overallhandle.Result(105, errGorm, c)
} else {
overallhandle.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(positionAry)), positionAry, c)
}
}
//添加员工
func (s *StaffApi) AddStaff(c *gin.Context) {
var requestData addPersonnel
c.ShouldBindJSON(&requestData)
if requestData.Number == "" {
overallhandle.Result(1, requestData.Number, c, "工号不能为空!")
return
}
if requestData.Name == "" {
overallhandle.Result(1, requestData.Name, c, "姓名不能为空!")
return
}
if requestData.Gender == 0 {
requestData.Gender = 1
}
if requestData.HireType == 0 {
requestData.HireType = 1
}
if requestData.PoliticalOutlook == 0 {
requestData.PoliticalOutlook = 1
}
if requestData.Company == 0 {
requestData.Company = 1
}
if len(requestData.Department) < 1 {
overallhandle.Result(1, requestData.Department, c, "请您选择该员工归属哪个分厂(部室)!")
return
}
if requestData.Position == 0 {
overallhandle.Result(1, requestData.Position, c, "请分配员工职位(岗位)!")
return
}
if requestData.EmpType == 0 {
requestData.EmpType = 2
}
if requestData.PositionGrade == 0 {
overallhandle.Result(1, requestData.PositionGrade, c, "请分配员入职等级!")
return
}
if requestData.ProbationPeriod == 0 {
requestData.ProbationPeriod = 3
}
if requestData.Constellation == 0 {
requestData.Constellation = 1
}
if requestData.Health == 0 {
requestData.Health = 2
}
if requestData.Maritalstatus == 0 {
requestData.Maritalstatus = 1
}
if requestData.Iisdoubleworker == 0 {
requestData.Iisdoubleworker = 2
} else {
if requestData.Iisdoubleworker == 1 {
if requestData.SpouseName == "" {
overallhandle.Result(1, requestData.SpouseName, c, "请输入配偶姓名!")
return
}
if requestData.SpouseCompany == "" {
overallhandle.Result(1, requestData.SpouseName, c, "请输入配偶所在公司!")
return
}
if requestData.SpouseDepartment == "" {
overallhandle.Result(1, requestData.SpouseName, c, "请输入配偶所在部门!")
return
}
if requestData.SpousePosition == "" {
overallhandle.Result(1, requestData.SpouseName, c, "请输入配偶所在岗位!")
return
}
if requestData.SpouseTel == "" {
overallhandle.Result(1, requestData.SpouseName, c, "请输入配偶联系方式!")
return
}
}
}
if requestData.Isveterans == 0 {
requestData.Isveterans = 2
} else {
if requestData.Isveterans == 1 && requestData.Veteransnumber == "" {
overallhandle.Result(1, requestData.Veteransnumber, c, "请输入退役证编号!")
return
}
}
if requestData.Password == "" {
requestData.Password = overall.CONSTANT_CONFIG.Appsetup.DefaultPassword
}
//员工档案主
var staffInfo models.Personnel
//判断工号是存在
whereAry := overallhandle.MapOut()
whereAry["number"] = requestData.Number
if judgeNoErr := staffInfo.GetCont(whereAry, "number"); judgeNoErr == nil {
overallhandle.Result(1, requestData, c, "该工号已经被使用!请不要重复使用!")
return
}
staffInfo.Number = requestData.Number
staffInfo.Name = requestData.Name
staffInfo.HireClass = requestData.HireType
staffInfo.Position = requestData.Position
//获取职务信息
jobCont, jobErr := getJobInfo(requestData.Position)
if jobErr == nil {
staffInfo.PositionLevel = jobCont.Dutid
staffInfo.JobClass = jobCont.Jobid
}
staffInfo.AdminOrg = requestData.AdminOrg
staffInfo.Company = requestData.Company
staffInfo.EmpType = requestData.EmpType
staffInfo.Deparment = strings.Join(requestData.Department, ",")
staffInfo.Time = time.Now().Unix()
staffInfo.EiteTime = time.Now().Unix()
staffInfo.PositionGrade = requestData.PositionGrade
staffInfo.Icon = requestData.Icon
// staffInfo.Password = requestData.Password
var md5JiaMi overallhandle.Md5Encryption
md5JiaMi.Md5EncryptionInit(requestData.Password)
md5Token := md5JiaMi.Md5EncryptionAlgorithm()
staffInfo.Password = md5Token
peopleMasterErr := overall.CONSTANT_DB_HR.Create(&staffInfo).Error
if peopleMasterErr != nil {
overallhandle.Result(104, staffInfo, c)
return
}
//员工档案附表
synPro.Add(1)
go staffInfoCont(requestData)
//双职工
if requestData.Iisdoubleworker == 1 {
synPro.Add(1)
go doubleWorkerStaff(requestData)
}
//人员变动记录
synPro.Add(1)
go peopleGaiDong(staffInfo)
//教育经历
if len(requestData.EducationalExperience) > 0 {
synPro.Add(1)
go eduExperience(requestData.Number, requestData.EducationalExperience)
}
//紧急联系人
if len(requestData.EmergencyContact) > 0 {
synPro.Add(1)
go emeContact(requestData.Number, requestData.EmergencyContact)
}
//家庭成员
if len(requestData.MemberOfFamily) > 0 {
synPro.Add(1)
go familyPeople(requestData.Number, requestData.MemberOfFamily)
}
synPro.Wait()
overallhandle.Result(0, staffInfo, c)
}
//获取职务相关属性
func getJobInfo(jobId int64) (cont jobAttber, err error) {
var positionInfo models.Position
// err = overall.CONSTANT_DB_HR.Table(fmt.Sprintf("%s p", positionInfo.TableName())).Select("p.id,p.number,p.name,p.person_in_charge,d.id as dutid,d.name as dutname,d.number as dutnumber,j.id as jobid,j.name as jobname").Joins("left join duties as d on d.id = p.duties").Joins("left join job_class as j on j.id = d.job_type").Where("`p`.`id` = ?", jobId).First(&cont).Error
err = overall.CONSTANT_DB_HR.Model(&positionInfo).Select("position.id,position.number,position.name,position.person_in_charge,d.id as dutid,d.name as dutname,d.number as dutnumber,j.id as jobid,j.name as jobname").Joins("left join duties as d on d.id = position.duties").Joins("left join job_class as j on j.id = d.job_type").Where("`position`.`id` = ?", jobId).First(&cont).Error
return
}
//员工档案详情
func staffInfoCont(contData addPersonnel) {
defer synPro.Done()
var staffAttribute models.PersonnelContent
staffAttribute.Number = contData.Number
staffAttribute.Idcardno = contData.IDCardNo
staffAttribute.Mobilephone = contData.Mobilephone
staffAttribute.Gender = contData.Gender
brrthday, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.Birthday))
staffAttribute.Birthday = brrthday
staffAttribute.Myfolk = contData.Nation
staffAttribute.Nativeplace = contData.NativePlace
staffAttribute.Health = contData.Health
staffAttribute.Maritalstatus = contData.Maritalstatus
staffAttribute.Currentresidence = contData.CurrentResidence
staffAttribute.Time = time.Now().Unix()
staffAttribute.Constellation = contData.Constellation
staffAttribute.Isdoubleworker = contData.Iisdoubleworker
staffAttribute.Isveterans = contData.Isveterans
staffAttribute.Veteransnumber = contData.Veteransnumber
workInData := time.Now().Unix()
if contData.WorkingDate != "" {
workInData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.WorkingDate))
}
staffAttribute.Jobstartdate = workInData
entryData := time.Now().Unix()
if contData.EntryDate != "" {
entryData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.EntryDate))
}
staffAttribute.Entrydate = entryData
staffAttribute.Probationperiod = contData.ProbationPeriod
planformalData := time.Now().Unix()
if contData.ConfirmationDate != "" {
planformalData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.ConfirmationDate))
} else {
planformalData = overallhandle.GetFutureMonthTime(entryData, contData.ProbationPeriod, 2)
}
staffAttribute.Planformaldate = planformalData
staffAttribute.PoliticalOutlook = contData.PoliticalOutlook
overall.CONSTANT_DB_HR.Create(&staffAttribute)
}
//双职工
func doubleWorkerStaff(contData addPersonnel) {
defer synPro.Done()
var doublePeople models.DoubleWorker
doublePeople.Number = contData.Number
doublePeople.Name = contData.SpouseName
doublePeople.Company = contData.SpouseCompany
doublePeople.Department = contData.SpouseDepartment
doublePeople.Position = contData.SpousePosition
doublePeople.Tel = contData.SpouseTel
doublePeople.Time = time.Now().Unix()
overall.CONSTANT_DB_HR.Create(&doublePeople)
}
//人员变动记录
func peopleGaiDong(contData models.Personnel) {
defer synPro.Done()
var pcrInfo models.PersonnelChangeRecord
pcrInfo.Number = contData.Number
pcrInfo.Type = contData.HireClass
reason := ""
switch contData.HireClass {
case 1:
reason = "雇佣入职"
case 2:
reason = "再入职"
case 3:
reason = "职位分配"
case 4:
reason = "转正"
case 5:
reason = "停薪留职"
case 6:
reason = "退休"
case 7:
reason = "辞退"
case 8:
reason = "离职"
default:
reason = ""
}
pcrInfo.Reason = reason
pcrInfo.Position = contData.Position
pcrInfo.JobLevel = strconv.FormatInt(contData.PositionLevel, 10)
pcrInfo.JobGrade = contData.PositionGrade
pcrInfo.Company = contData.Company
pcrInfo.Department = contData.Deparment
pcrInfo.Adminorg = contData.AdminOrg
pcrInfo.Time = time.Now().Unix()
overall.CONSTANT_DB_HR.Create(&pcrInfo)
}
//教育经历
func eduExperience(number string, eduExpAry []educationalExperience) {
defer synPro.Done()
var leaExp []models.PersonnelEducation
maxLevel := 1
for eei, eev := range eduExpAry {
if maxLevel < eev.Education {
maxLevel = eev.Education
}
var leaExpInfo models.PersonnelEducation
leaExpInfo.Number = number
leaExpInfo.Education = eev.Education
leaExpInfo.GraduationSchool = eev.GraduationSchool
leaExpInfo.Subject = eev.Subject
admissionTime, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", eev.AdmissionTime))
leaExpInfo.AdmissionTime = admissionTime
graduationTime, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", eev.GraduationTime))
leaExpInfo.GraduationTime = graduationTime
leaExpInfo.Time = time.Now().Unix()
if eei == 0 {
leaExpInfo.Level = 2
}
leaExp = append(leaExp, leaExpInfo)
}
//设定最高学历
if len(leaExp) > 1 {
for mei, maxEdv := range leaExp {
if maxEdv.Education != 2 && maxEdv.Education == maxLevel {
leaExp[mei].Level = 3
}
}
}
if len(leaExp) > 0 {
overall.CONSTANT_DB_HR.Create(&leaExp)
}
}
//紧急联系人
func emeContact(number string, contAry []emergencyContact) {
defer synPro.Done()
var emerContAry []models.EmergencyContact
for _, emev := range contAry {
var emerInfo models.EmergencyContact
emerInfo.Number = number
emerInfo.Name = emev.Name
emerInfo.Relationship = emev.Relationship
emerInfo.Tel = emev.Mobilephone
emerInfo.Time = time.Now().Unix()
emerInfo.State = 1
emerContAry = append(emerContAry, emerInfo)
}
if len(emerContAry) > 0 {
overall.CONSTANT_DB_HR.Create(&emerContAry)
}
}
//家庭成员
func familyPeople(number string, contAry []memberOfFamily) {
defer synPro.Done()
var familyAry []models.FamilyMembers
for _, fv := range contAry {
var familyInfo models.FamilyMembers
familyInfo.Number = number
familyInfo.Relationship = fv.Relationship
familyInfo.Name = fv.Name
familyInfo.Company = fv.Company
familyInfo.Deparment = fv.Department
familyInfo.Postnme = fv.Position
familyInfo.Tel = fv.Mobilephone
familyInfo.PoliticalOutlook = fv.PoliticalOutlook
familyInfo.Time = time.Now().Unix()
familyAry = append(familyAry, familyInfo)
}
if len(familyAry) > 0 {
overall.CONSTANT_DB_HR.Create(&familyAry)
}
}

137
api/version1/personnelapi/type.go

@ -0,0 +1,137 @@
package personnelapi
import (
"hr_server/models"
"hr_server/overall/overallhandle"
"sync"
"github.com/gin-gonic/gin"
)
//协程
var synPro = sync.WaitGroup{}
//人员API
type StaffApi struct{}
//入口
func (s *StaffApi) Index(c *gin.Context) {
outputCont := overallhandle.MapOut()
outputCont["index"] = "人员档案API"
overallhandle.Result(0, outputCont, c)
}
//人员列表查询
type peopleList struct {
overallhandle.PageTurning
Number string `json:"number"` //工号
Name string `json:"name"` //name
HireClass int `json:"hireclass"` //雇佣类型
Company int64 `json:"company"` //公司
Deparment string `json:"deparment"` //部门
AdminOrg int64 `json:"adminorg"` //所属行政组织
Position int64 `json:"position"` //职位
EmpType int `json:"emptype"` //用工关系(1:实习生;2:待分配;3:试用员工;4:正式员工;5:停薪留职;6:退休;7:辞退;8:离职)
Role string `json:"role"`
}
//人员列表输出
type peopleOutList struct {
models.Personnel
Mobilephone string `json:"mobilephone" gorm:"column:mobilephone;type:varchar(50) unsigned;default:'';not null;comment:手机号码"`
Gender int `json:"gender" gorm:"column:type;gender:tinyint(1) unsigned;default:1;not null;comment:性别(1:男性;2:女性;3:中性)"`
Isdoubleworker int `json:"isdoubleworker" gorm:"column:type;isdoubleworker:tinyint(1) unsigned;default:1;not null;comment:是否双职工(1:是;2:否)"`
Isveterans int `json:"isveterans" gorm:"column:type;isveterans:tinyint(1) unsigned;default:1;not null;comment:是否为退役军人(1:是;2:否)"`
Entrydate int64 `json:"entrydate" gorm:"column:entrydate;type:bigint(20) unsigned;default:0;not null;comment:入职日期"`
Probationperiod int64 `json:"probationperiod" gorm:"column:probationperiod;type:int(5) unsigned;default:0;not null;comment:试用期"`
Planformaldate int64 `json:"planformaldate" gorm:"column:planformaldate;type:bigint(20) unsigned;default:0;not null;comment:预计转正日期"`
CompanyName string `json:"companyname"` //公司名称
DeparmentName string `json:"deparmentname"` //部门名称
PositionName string `json:"positionname"` //职位
}
//获取部门细腻些
type getDepartmentInfo struct {
Id int64 `json:"id"` //id
Number string `json:"number"` //行政编码
Name string `json:"name"` //组织名称
}
//添加员工参数
type addPersonnel struct {
Number string `json:"number"` //工号1
Password string `json:"password"` //密码1
Name string `json:"name"` //姓名1
Gender int `json:"gender"` //性别
Icon string `json:"icon"` //头像
HireType int `json:"hiretype"` //1雇佣类型(1:雇佣入职;2:再入职;3:返聘)
Mobilephone string `json:"mobilephone"` //联系电话
IDCardNo string `json:"idcardno"` //身份证号码
PoliticalOutlook int `json:"politicaloutlook"` //政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)
Company int64 `json:"company"` //公司
Department []string `json:"department"` //分厂(部室)
AdminOrg int64 `json:"adminorg"` //工段
Position int64 `json:"position"` //职位(岗位)1
EmpType int `json:"emptype"` //用工关系(1:实习生;2:待分配;3:试用员工;4:正式员工;5:停薪留职;6:退休;7:辞退;8:离职)
PositionGrade int64 `json:"positiongrade"` //入职等级
Nation string `json:"nation"` //民族
Birthday string `json:"birthday"` //生日
WorkingDate string `json:"workingdate"` //参加工作日期
EntryDate string `json:"entrydate"` //入职日期
ProbationPeriod int `json:"probationperiod"` //试用期(月)
ConfirmationDate string `json:"confirmationdate"` //转正日期
NativePlace string `json:"nativeplace"` //籍贯
CurrentResidence string `json:"currentresidence"` //现居地
Constellation int `json:"constellation"` //星座(1:白羊座;2:金牛座;3:双子座;4:巨蟹座;5:狮子座;6:处女座;7:天枰座;8:天蝎座;9:射手座;10:摩羯座;11:水瓶座;12:双鱼座)
Health int `json:"health"` //健康状况(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废
Maritalstatus int `json:"maritalstatus"` //婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异)
Iisdoubleworker int `json:"isdoubleworker"` //是否双职工(1:是;2:否)
Isveterans int `json:"isveterans"` //是否为退役军人(1:是;2:否)
Veteransnumber string `json:"veteransnumber"` //退役证编号
EducationalExperience []educationalExperience `json:"educationalexperience"` //教育经历
EmergencyContact []emergencyContact `json:"emergencycontact"` //紧急联系人
MemberOfFamily []memberOfFamily `json:"memberoffamily"` //家庭成员
SpouseName string `json:"spousename"` //配偶姓名
SpouseCompany string `json:"spousecompany"` //配偶所在公司
SpouseDepartment string `json:"spousedepartment"` //配偶所在部门
SpousePosition string `json:"spouseposition"` //配偶所在岗位
SpouseTel string `json:"spousetel"` //配偶联系方式
}
//教育经历
type educationalExperience struct {
AdmissionTime string `json:"admissiontime"` //入学时间
GraduationTime string `json:"graduationtime"` //毕业时间
Education int `json:"education"` //学历(1:初中及以下;2:中专;3:高中;4:中技;5:高技;6:函数专科;7:大学专科;8:函数本科;9:大学本科;10:硕士研究生;11:博士研究生;12:专家、教授)
Subject string `json:"subject"` //专业
GraduationSchool string `json:"graduationschool"` //毕业学校
}
//紧急联系人
type emergencyContact struct {
Name string `json:"name"` //姓名
Relationship string `json:"relationship"` //与紧急联系人
Mobilephone string `json:"mobilephone"` //联系电话
}
//家庭成员
type memberOfFamily struct {
emergencyContact
Company string `json:"company"` //公司
Department string `json:"department"` //分厂(部室)
Position string `json:"position"` //职位(岗位)
PoliticalOutlook int `json:"politicaloutlook"` //政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)
}
//职务相关
type jobAttber 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(255) unsigned;default:'';not null;comment:编号"`
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:名称"`
PersonInCharge int `json:"personincharge" gorm:"column:person_in_charge;type:tinyint(1) unsigned;default:0;not null;comment:是否为本部门负责人"`
Dutid int64 `json:"dutid" gorm:"column:dutid;type:bigint(20) unsigned;default:0;not null;comment:职务Id"`
Dutname string `json:"dutname" gorm:"column:dutname;type:varchar(255) unsigned;default:'';not null;comment:职务名称"`
DutNumber string `json:"dutnumber" gorm:"column:dutnumber;type:varchar(255) unsigned;default:'';not null;comment:职务编号"`
Jobid int64 `json:"jobid" gorm:"column:jobid;type:bigint(20) unsigned;default:0;not null;comment:职务分类Id"`
JobName string `json:"jobname" gorm:"column:jobname;type:varchar(255) unsigned;default:'';not null;comment:职务分类名称"`
}

26
api/version1/shiyan/shiyan.go

@ -0,0 +1,26 @@
package shiyan
import (
"fmt"
"hr_server/overall/overallhandle"
"time"
"github.com/gin-gonic/gin"
)
func (s *ShiYan) ShiyanCont(c *gin.Context) {
var requestData Jieshou
c.ShouldBindJSON(&requestData)
if requestData.Time == "" {
requestData.Time = overallhandle.UnixTimeToDay(time.Now().Unix(), 11)
}
entryData, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.Time))
planformalData := overallhandle.GetFutureMonthTime(entryData, requestData.ProbationPeriod, 2)
timeStr := overallhandle.UnixTimeToDay(planformalData, 11)
out := overallhandle.MapOut()
out["time"] = requestData.Time
out["entryData"] = entryData
out["timeStr"] = timeStr
overallhandle.Result(0, out, c)
}

22
api/version1/shiyan/type.go

@ -0,0 +1,22 @@
package shiyan
import (
"hr_server/overall/overallhandle"
"github.com/gin-gonic/gin"
)
//人员API
type ShiYan struct{}
//入口
func (s *ShiYan) Index(c *gin.Context) {
outputCont := overallhandle.MapOut()
outputCont["index"] = "实验API"
overallhandle.Result(0, outputCont, c)
}
type Jieshou struct {
Time string `json:"time"`
ProbationPeriod int `json:"probationperiod"` //试用期(月)
}

8
apirouter/inlet.go

@ -3,13 +3,17 @@ package apirouter
import ( import (
"hr_server/apirouter/organization" "hr_server/apirouter/organization"
"hr_server/apirouter/permit" "hr_server/apirouter/permit"
"hr_server/apirouter/personnel"
"hr_server/apirouter/shiyanrouter"
) )
//路由入口 //路由入口
type RouterGroup struct { type RouterGroup struct {
OrganizationApi organization.OrganizationRoute //组织架构 OrganizationApi organization.OrganizationRoute //组织架构
PermitPowerApi permit.PermitPower //权限相关操作 PermitPowerApi permit.PermitPower //权限相关操作
PersonnelRoute personnel.PersonnelRoute //人员管理
ShiyanApiRRouter shiyanrouter.ShiyanApiRouter
} }
var RouterGroupInlet = new(RouterGroup) var RouterGroupInlet = new(RouterGroup)

19
apirouter/personnel/people.go

@ -0,0 +1,19 @@
package personnel
import (
"hr_server/api/version1"
"github.com/gin-gonic/gin"
)
//员工档案
func (p *PersonnelRoute) InitRouterGroup(route *gin.RouterGroup) {
apiRouter := route.Group("staff")
var apiHandle = version1.AppApiInlet.StaffApi
{
apiRouter.GET("", apiHandle.Index) //入口
apiRouter.POST("", apiHandle.Index) //入口
apiRouter.POST("stafflist", apiHandle.StaffList) //人员列表
apiRouter.POST("addstaff", apiHandle.AddStaff) //添加人员档案
}
}

4
apirouter/personnel/type.go

@ -0,0 +1,4 @@
package personnel
//人员管理方面
type PersonnelRoute struct{}

18
apirouter/shiyanrouter/shiyan.go

@ -0,0 +1,18 @@
package shiyanrouter
import (
"hr_server/api/version1"
"github.com/gin-gonic/gin"
)
//组织架构
func (p *ShiyanApiRouter) InitRouterGroup(route *gin.RouterGroup) {
apiRouter := route.Group("shiyan")
var apiHandle = version1.AppApiInlet.ShiyanApi
{
apiRouter.GET("", apiHandle.Index) //入口
apiRouter.POST("", apiHandle.Index) //入口
apiRouter.POST("shiyan", apiHandle.ShiyanCont) //人员列表
}
}

3
apirouter/shiyanrouter/type.go

@ -0,0 +1,3 @@
package shiyanrouter
type ShiyanApiRouter struct{}

4
config/configApp/appConfig.yaml

@ -3,4 +3,6 @@
appsetup: appsetup:
port: 9999 #服务端口 port: 9999 #服务端口
readtime: 3600 #请求的读取操作在超时前的最大持续时间 readtime: 3600 #请求的读取操作在超时前的最大持续时间
writetime : 3600 #回复的写入操作在超时前的最大持续时间 writetime : 3600 #回复的写入操作在超时前的最大持续时间
appkey: 'heng_xin_gao_ke_AppKey' #应用程序密钥
password: '123456789' #系统默认密码

8
config/configApp/server.go

@ -7,7 +7,9 @@ type Server struct {
//服务配置详情 //服务配置详情
type appsetup struct { type appsetup struct {
Port int `mapstructure:"port" json:"port" yaml:"port"` Port int `mapstructure:"port" json:"port" yaml:"port"`
Readtime int `mapstructure:"readtime" json:"readtime" yaml:"readtime"` Readtime int `mapstructure:"readtime" json:"readtime" yaml:"readtime"`
Writetime int `mapstructure:"writetime" json:"writetime" yaml:"writetime"` Writetime int `mapstructure:"writetime" json:"writetime" yaml:"writetime"`
AppKey string `mapstructure:"appkey" json:"appkey" yaml:"appkey"`
DefaultPassword string `mapstructure:"password" json:"password" yaml:"password"`
} }

21
config/configJson/org.json

@ -0,0 +1,21 @@
{
"group":[
{
"old":3,
"new":2
}
],
"department":[
{
"newgroup":2,
"old":1,
"new":14
},
{
"newgroup":2,
"old":2,
"new":13
}
],
"workshopsection":[]
}

BIN
hr_server.exe

Binary file not shown.

11
initialization/route/route_entry.go

@ -23,6 +23,12 @@ func InitialRouter() *gin.Engine {
c.JSON(0, "通讯成功!") c.JSON(0, "通讯成功!")
}) })
} }
//人员档案
shhiyanApi := apirouter.RouterGroupInlet.ShiyanApiRRouter
{
shhiyanApi.InitRouterGroup(appLoadRouterGroup)
}
//注册路由 //注册路由
organizationApi := apirouter.RouterGroupInlet.OrganizationApi //组织架构 organizationApi := apirouter.RouterGroupInlet.OrganizationApi //组织架构
{ {
@ -33,5 +39,10 @@ func InitialRouter() *gin.Engine {
{ {
permitPowerApi.InitRouterGroup(appLoadRouterGroup) permitPowerApi.InitRouterGroup(appLoadRouterGroup)
} }
//人员档案
staffApi := apirouter.RouterGroupInlet.PersonnelRoute
{
staffApi.InitRouterGroup(appLoadRouterGroup)
}
return router return router
} }

24
models/double_worker.go

@ -0,0 +1,24 @@
package models
import "hr_server/overall"
//紧急联系人
type DoubleWorker struct {
Number string `json:"number" gorm:"primaryKey;column:number;type:varchar(30) unsigned;not null;comment:员工工号;index"`
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:姓名"`
Company string `json:"company" gorm:"column:company;type:varchar(255) unsigned;default:'';not null;comment:所在公司"`
Department string `json:"department" gorm:"column:department;type:varchar(255) unsigned;default:'';not null;comment:所在部门"`
Position string `json:"position" gorm:"column:position;type:varchar(255) unsigned;default:'';not null;comment:所在岗位"`
Tel string `json:"tel" gorm:"column:tel;type:varchar(255) unsigned;default:'';not null;comment:联系方式"`
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"`
}
func (DoubleWorker *DoubleWorker) TableName() string {
return "double_worker"
}
//编辑职务分类内容
func (DoubleWorker *DoubleWorker) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_HR.Model(&DoubleWorker).Where(whereMap).Updates(saveData).Error
return
}

2
models/family_members.go

@ -5,7 +5,7 @@ import "hr_server/overall"
//员工家属 //员工家属
type FamilyMembers struct { type FamilyMembers struct {
Number string `json:"number" gorm:"primaryKey;column:number;type:varchar(30) unsigned;not null;comment:员工工号;index"` Number string `json:"number" gorm:"primaryKey;column:number;type:varchar(30) unsigned;not null;comment:员工工号;index"`
Relationship string `json:"relationship" gorm:"column:relationship;type:varchar(255) unsigned;default:'';not null;comment:亲属关系"` Relationship string `json:"relationship" gorm:"column:relation;type:varchar(255) unsigned;default:'';not null;comment:亲属关系"`
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:姓名"` Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:姓名"`
Company string `json:"company" gorm:"column:company;type:varchar(255) unsigned;default:'';not null;comment:所在公司"` Company string `json:"company" gorm:"column:company;type:varchar(255) unsigned;default:'';not null;comment:所在公司"`
Deparment string `json:"deparment" gorm:"column:deparment;type:varchar(255) unsigned;default:'';not null;comment:所在部门"` Deparment string `json:"deparment" gorm:"column:deparment;type:varchar(255) unsigned;default:'';not null;comment:所在部门"`

27
models/personnel.go

@ -1,14 +1,17 @@
package models package models
import "hr_server/overall" import (
"hr_server/overall"
"strings"
)
//员工档案(主) //员工档案(主)
type Personnel struct { type Personnel struct {
Id int64 `json:"id" gorm:"primaryKey;column:m_id;type:bigint(20) unsigned;not null;comment:ID"` 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:员工工号"` 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:姓名"` Name string `json:"name" gorm:"column:name;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:再入职;)"` HireClass int `json:"hireclass" gorm:"column:hire_class;type:tinyint(1) unsigned;default:1;not null;comment:雇佣类型(1:雇佣入职;2:再入职;)"`
PositionLevel string `json:"positionlevel" gorm:"column:position_level;type:varchar(200) unsigned;default:'';not null;comment:入职职层"` PositionLevel int64 `json:"positionleveles" gorm:"column:positionleveles;type:bigint(20) unsigned;default:0;not null;comment:职位"`
Position int64 `json:"position" gorm:"column:position;type:bigint(20) unsigned;default:0;not null;comment:职位"` Position int64 `json:"position" gorm:"column:position;type:bigint(20) unsigned;default:0;not null;comment:职位"`
AdminOrg int64 `json:"adminorg" gorm:"column:admin_org;type:bigint(20) unsigned;default:0;not null;comment:所属行政组织"` AdminOrg int64 `json:"adminorg" gorm:"column:admin_org;type:bigint(20) unsigned;default:0;not null;comment:所属行政组织"`
Company int64 `json:"company" gorm:"column:company;type:bigint(20) unsigned;default:0;not null;comment:入职公司"` Company int64 `json:"company" gorm:"column:company;type:bigint(20) unsigned;default:0;not null;comment:入职公司"`
@ -19,14 +22,30 @@ type Personnel struct {
JobClass int64 `json:"jobclass" gorm:"column:job_class;type:bigint(20) unsigned;default:2;not null;comment:职务分类"` JobClass int64 `json:"jobclass" gorm:"column:job_class;type:bigint(20) unsigned;default:2;not null;comment:职务分类"`
PositionGrade int64 `json:"positiongrade" gorm:"column:position_grade;type:bigint(20) unsigned;default:0;not null;comment:入职职等"` PositionGrade int64 `json:"positiongrade" gorm:"column:position_grade;type:bigint(20) unsigned;default:0;not null;comment:入职职等"`
Role string `json:"role" gorm:"column:role;type:longtext;comment:变动原因"` Role string `json:"role" gorm:"column:role;type:longtext;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"`
Icon string `json:"icon" gorm:"column:icon;type:varchar(255) unsigned;default:'';not null;comment:头像"`
Password string `json:"password" gorm:"column:password;type:varchar(255) unsigned;default:'';not null;comment:密码"`
} }
func (Personnel *Personnel) TableName() string { func (Personnel *Personnel) TableName() string {
return "personnel" return "personnel"
} }
//编辑职务分类内容 //编辑员工档案
func (Personnel *Personnel) EiteCont(whereMap interface{}, saveData interface{}) (err error) { func (Personnel *Personnel) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_HR.Model(&Personnel).Where(whereMap).Updates(saveData).Error err = overall.CONSTANT_DB_HR.Model(&Personnel).Where(whereMap).Updates(saveData).Error
return return
} }
//获取员工档案
func (cont *Personnel) 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
}

2
models/personnel_change_record.go

@ -11,7 +11,7 @@ type PersonnelChangeRecord struct {
JobLevel string `json:"joblevel" gorm:"column:job_level;type:varchar(200) unsigned;default:'';not null;comment:入职职层"` JobLevel string `json:"joblevel" gorm:"column:job_level;type:varchar(200) unsigned;default:'';not null;comment:入职职层"`
JobGrade int64 `json:"jobgrade" gorm:"column:job_grade;type:bigint(20) unsigned;default:0;not null;comment:入职职等"` JobGrade int64 `json:"jobgrade" gorm:"column:job_grade;type:bigint(20) unsigned;default:0;not null;comment:入职职等"`
Company int64 `json:"company" gorm:"column:company;type:bigint(20) unsigned;default:0;not null;comment:入职公司"` Company int64 `json:"company" gorm:"column:company;type:bigint(20) unsigned;default:0;not null;comment:入职公司"`
Department int64 `json:"department" gorm:"column:department;type:bigint(20) unsigned;default:0;not null;comment:入职分厂"` Department string `json:"department" gorm:"column:department;type:varchar(255) unsigned;default:0;not null;comment:入职分厂"`
Adminorg int64 `json:"adminorg" gorm:"column:adminorg;type:bigint(20) unsigned;default:0;not null;comment:入职行政组织"` Adminorg int64 `json:"adminorg" gorm:"column:adminorg;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:写入时间"` Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:写入时间"`
} }

23
models/personnel_content.go

@ -11,7 +11,7 @@ type PersonnelContent struct {
Globalroaming string `json:"globalroaming" gorm:"column:globalroaming;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:手机号码"` 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:电子邮件"` Email string `json:"email" gorm:"column:email;type:varchar(255) unsigned;default:'';not null;comment:电子邮件"`
Gender int `json:"gender" gorm:"column:type;gender:tinyint(1) unsigned;default:1;not null;comment:性别(1:男性;2:女性;3:中性)"` Gender int `json:"gender" gorm:"column:gender;gender: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"` 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:民族"` 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:籍贯"` Nativeplace string `json:"nativeplace" gorm:"column:nativeplace;type:varchar(255) unsigned;default:'';not null;comment:籍贯"`
@ -19,19 +19,20 @@ type PersonnelContent struct {
Idcardenddate int64 `json:"idcardenddate" gorm:"column:idcardenddate;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:身份证地址"` 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:身份证签发机关"` IdcardIssued string `json:"idcardIssued" gorm:"column:idcardIssued;type:varchar(255) unsigned;default:'';not null;comment:身份证签发机关"`
Health int `json:"health" gorm:"column:type;health:tinyint(1) unsigned;default:1;not null;comment:健康状况(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废)"` Health int `json:"health" gorm:"column:health;health:tinyint(1) unsigned;default:1;not null;comment:健康状况(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废)"`
Maritalstatus int `json:"maritalstatus" gorm:"column:type;maritalstatus:tinyint(1) unsigned;default:1;not null;comment:婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异)"` Maritalstatus int `json:"maritalstatus" gorm:"column:maritalstatus;maritalstatus: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:内线电话"` 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:现居住地址"` Currentresidence string `json:"currentresidence" gorm:"column:currentresidence;type:varchar(255) unsigned;default:'';not null;comment:现居住地址"`
Time int64 `json:"time" gorm:"column:time;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:创建时间"`
Constellation string `json:"constellation" gorm:"column:constellation;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:type;isdoubleworker:tinyint(1) unsigned;default:1;not null;comment:是否双职工(1:是;2:否)"` Isdoubleworker int `json:"isdoubleworker" gorm:"column:isdoubleworker;isdoubleworker:tinyint(1) unsigned;default:1;comment:是否双职工(1:是;2:否)"`
Isveterans int `json:"isveterans" gorm:"column:type;isveterans:tinyint(1) unsigned;default:1;not null;comment:是否为退役军人(1:是;2:否)"` Isveterans int `json:"isveterans" gorm:"column:isveterans;isveterans:tinyint(1) unsigned;default:1;comment:是否为退役军人(1:是;2:否)"`
Veteransnumber string `json:"veteransnumber" gorm:"column:veteransnumber;type:varchar(255) unsigned;default:'';not null;comment:退役证编号"` 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;not null;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;not null;comment:入职日期"` Entrydate int64 `json:"entrydate" gorm:"column:entrydate;type:bigint(20) unsigned;default:0;comment:入职日期"`
Probationperiod int64 `json:"probationperiod" gorm:"column:probationperiod;type:int(5) unsigned;default:0;not null;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;not null;comment:预计转正日期"` Planformaldate int64 `json:"planformaldate" gorm:"column:planformaldate;type:bigint(20) unsigned;default:0;comment:预计转正日期"`
PoliticalOutlook int `json:"politicaloutlook" gorm:"column:political_outlook;political_outlook:tinyint(3) unsigned;default:1;comment:政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)"`
} }
func (PersonnelContent *PersonnelContent) TableName() string { func (PersonnelContent *PersonnelContent) TableName() string {

18
models/personnel_education.go

@ -5,18 +5,18 @@ import "hr_server/overall"
//教育经历 //教育经历
type PersonnelEducation struct { type PersonnelEducation struct {
Number string `json:"number" gorm:"primaryKey;column:number;type:varchar(30) unsigned;not null;comment:员工工号;index"` Number string `json:"number" gorm:"primaryKey;column:number;type:varchar(30) unsigned;comment:员工工号;index"`
Education string `json:"education" gorm:"column:education;type:varchar(255) unsigned;default:'';not null;comment:学历"` Education int `json:"education" gorm:"column:education;type:int(5) unsigned;default:1;comment:学历(1:初中及以下;2:中专;3:高中;4:中技;5:高技;6:函数专科;7:大学专科;8:函数本科;9:大学本科;10:硕士研究生;11:博士研究生;12:专家、教授)"`
GraduationSchool string `json:"graduationschool" gorm:"column:graduation_school;type:varchar(255) unsigned;default:'';not null;comment:毕业学校"` GraduationSchool string `json:"graduationschool" gorm:"column:graduation_school;type:varchar(255) unsigned;default:'';comment:毕业学校"`
Subject string `json:"subject" gorm:"column:subject;type:varchar(255) unsigned;default:'';not null;comment:专业"` Subject string `json:"subject" gorm:"column:subject;type:varchar(255) unsigned;default:'';comment:专业"`
AdmissionTime int64 `json:"admissiontime" gorm:"column:admission_time;type:bigint(20) unsigned;default:0;not null;comment:入学时间"` AdmissionTime int64 `json:"admissiontime" gorm:"column:admission_time;type:bigint(20) unsigned;default:0;comment:入学时间"`
GraduationTime int64 `json:"graduationtime" gorm:"column:graduation_time;type:bigint(20) unsigned;default:0;not null;comment:毕业时间"` GraduationTime int64 `json:"graduationtime" gorm:"column:graduation_time;type:bigint(20) unsigned;default:0;comment:毕业时间"`
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:写入时间"` Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;comment:写入时间"`
Level int `json:"level" gorm:"column:type;level:tinyint(1) unsigned;default:1;not null;comment:学历类型(1:普通;2:第一学历;3:最高学历)"` Level int `json:"level" gorm:"column:level;type:tinyint(1) unsigned;default:1;comment:学历类型(1:普通;2:第一学历;3:最高学历)"`
} }
func (PersonnelEducation *PersonnelEducation) TableName() string { func (PersonnelEducation *PersonnelEducation) TableName() string {
return "personnel_change_record" return "personnel_education"
} }
//编辑职务分类内容 //编辑职务分类内容

2
overall/app_constant.go

@ -5,4 +5,6 @@ var (
ConfigFilePathConstant = "./config/configApp/appConfig.yaml" //服务基础配置 ConfigFilePathConstant = "./config/configApp/appConfig.yaml" //服务基础配置
ConfigDatabaseConstant = "./config/configDatabase/database.yaml" ConfigDatabaseConstant = "./config/configDatabase/database.yaml"
ConfigRedisConstant = "./config/configNosql/redis.yaml" ConfigRedisConstant = "./config/configNosql/redis.yaml"
EmployeeStatusIng = []int{1, 2, 3, 4, 5} //用工关系(1:实习生;2:待分配;3:试用员工;4:正式员工;5:停薪留职;6:退休;7:辞退;8:离职)
EmployeeStatusOld = []int{7, 8} //用工关系(1:实习生;2:待分配;3:试用员工;4:正式员工;5:停薪留职;6:退休;7:辞退;8:离职)
) )

3
overall/overallhandle/errorcode.go

@ -2,8 +2,9 @@ package overallhandle
var ErrorCodeMsg = map[int]string{ var ErrorCodeMsg = map[int]string{
0: "成功", 0: "成功",
1: "",
100: "提交的数据格式错误!", 100: "提交的数据格式错误!",
101: "提交的数据不能为空!", 101: "提交的数据不能为空!",
103: "该数据已经存在!请不要重复添加", 103: "该数据已经存在!请不要重复添加",
104: "数据写入失败!", 104: "数据写入失败!",
105: "数据查询失败!", 105: "数据查询失败!",

76
overall/overallhandle/overall_handle.go

@ -2,6 +2,9 @@ package overallhandle
import ( import (
"bytes" "bytes"
"crypto/md5"
"crypto/sha1"
"encoding/hex"
"fmt" "fmt"
"hr_server/models" "hr_server/models"
"hr_server/overall" "hr_server/overall"
@ -315,3 +318,76 @@ func MenuThreePermit(parentId int64, menuAry []models.SystemMenuOperation) []Men
} }
return menuThree return menuThree
} }
/*
*加密算法
*/
type Md5Encryption struct {
Code string `json:"code"`
AppKey string `json:"appKey"`
}
func (m *Md5Encryption) Md5EncryptionAlgorithm() (md5Val string) {
if m.AppKey == "" {
m.Md5EncryptionInit(m.Code)
}
// fmt.Printf("Code ====> %v\n", m.Code)
// fmt.Printf("AppKey ====> %v\n", m.AppKey)
mdNew := md5.New()
mdNew.Write([]byte(m.AppKey))
keyMd5 := fmt.Sprintf("%x", mdNew.Sum(nil))
codeNewMd1 := md5.New()
codeNewMd1.Write([]byte(m.Code))
codeMd1 := fmt.Sprintf("%x", codeNewMd1.Sum(nil))
yiCeng := codeMd1 + keyMd5
yiCengNew := md5.New()
yiCengNew.Write([]byte(yiCeng))
yiCengMd5 := fmt.Sprintf("%x", yiCengNew.Sum(nil))
erCeng := yiCengMd5 + m.AppKey
erCengNew := md5.New()
erCengNew.Write([]byte(erCeng))
md5Val = fmt.Sprintf("%x", erCengNew.Sum(nil))
// md5Val = codeMd1
return
}
//初始化程序
func (m *Md5Encryption) Md5EncryptionInit(code string) {
m.AppKey = overall.CONSTANT_CONFIG.Appsetup.AppKey
m.Code = code
}
//sha1算法
func Sha1Encryption(str string) string {
sha1 := sha1.New()
sha1.Write([]byte(str))
return hex.EncodeToString(sha1.Sum(nil))
}
//计算当前时间N个月后的时间
/*
@timeStamp 当前时间戳
@futureTime 正数多少时间后负数多少时间前
*/
func GetFutureMonthTime(timeStamp int64, futureTime, class int) (dateStr int64) {
timeUnix := time.Unix(timeStamp, 0)
addDate := timeUnix.AddDate(0, 0, futureTime)
switch class {
case 2:
addDate = timeUnix.AddDate(0, futureTime, 0)
case 3:
addDate = timeUnix.AddDate(futureTime, 0, 0)
default:
addDate = timeUnix.AddDate(0, 0, futureTime)
}
dateStr = addDate.Unix()
return
}

Loading…
Cancel
Save