diff --git a/README.md b/README.md index 95e3b68..3d8f685 100644 --- a/README.md +++ b/README.md @@ -39,5 +39,5 @@ ## Log ``` -日志 -``` \ No newline at end of file +2022.04.19 建立人员信息相关数据模型 +``` diff --git a/api/version1/administrativeorganization/govcont.go b/api/version1/administrativeorganization/govcont.go index c9ce6c3..972f6c7 100644 --- a/api/version1/administrativeorganization/govcont.go +++ b/api/version1/administrativeorganization/govcont.go @@ -263,3 +263,30 @@ func (o *OrganizationApi) EiteGovStateOrDel(c *gin.Context) { } } } + +//行政组织树 +func (o *OrganizationApi) GovThree(c *gin.Context) { + var requestData govThreeType + c.ShouldBindJSON(&requestData) + if requestData.Id == 0 && requestData.IdStr == "" { + requestData.Id = 0 + } + if requestData.IdStr != "" { + idInt64, _ := strconv.ParseInt(requestData.IdStr, 10, 64) + requestData.Id = idInt64 + } + var govMap overallhandle.MenuList + gormDb := overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Select("administrative_organization.*,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` = 1") + if requestData.Level != 0 { + gormDb = gormDb.Where("aot.level <= ?", requestData.Level) + } + err := gormDb.Find(&govMap).Error + if err != nil { + overallhandle.Result(107, err, c) + return + } + // fmt.Printf("id==========>%v", requestData) + // govMap.GovRecursion(requestData.Id, 0) + govMapThree := overallhandle.GovThreeList(requestData.Id, govMap) + overallhandle.Result(0, govMapThree, c) +} diff --git a/api/version1/administrativeorganization/position.go b/api/version1/administrativeorganization/position.go index 95102aa..7d6dd66 100644 --- a/api/version1/administrativeorganization/position.go +++ b/api/version1/administrativeorganization/position.go @@ -49,15 +49,22 @@ func (o *OrganizationApi) PositionList(c *gin.Context) { total = 0 } var positionAry []positionOutInfo - errGorm := gormDb.Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&positionAry).Error + errGorm := gormDb.Order("p.department DESC,p.duties DESC,p.duties 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.Superior - fmt.Printf("%v\n", v.Superior) + // fmt.Printf("%v\n", v.Superior) getSpur.GetCont(getWhe, "number", "name") positionAry[i].SuperiorNumber = getSpur.Number positionAry[i].SuperiorName = getSpur.Name + + var getSpurDepart models.AdministrativeOrganization + getWheDepart := overallhandle.MapOut() + getWheDepart["id"] = v.Department + getSpurDepart.GetCont(getWheDepart, "name") + positionAry[i].DepartmentName = getSpurDepart.Name + } if errGorm != nil { overallhandle.Result(105, errGorm, c) @@ -123,6 +130,7 @@ func (o *OrganizationApi) AddPositionCont(c *gin.Context) { isExit := overallhandle.MapOut() isExit["department"] = departmentId isExit["name"] = requestData.Name + isExit["administrative_organization"] = organizationId judgeErr := positionCont.GetCont(isExit) if judgeErr == nil { overallhandle.Result(101, isExit, c, "该职位在本部门下已经存在!请不要重复添加") diff --git a/api/version1/administrativeorganization/type.go b/api/version1/administrativeorganization/type.go index cb1fbd4..b294ecb 100644 --- a/api/version1/administrativeorganization/type.go +++ b/api/version1/administrativeorganization/type.go @@ -12,6 +12,7 @@ type OrganizationApi struct{} //入口 func (o *OrganizationApi) Index(c *gin.Context) { outputCont := overallhandle.MapOut() + outputCont["index"] = "组织管理入口" overallhandle.Result(0, outputCont, c) } @@ -162,4 +163,11 @@ type positionOutInfo struct { JobName string `json:"jobname" gorm:"column:jobname;type:varchar(255) unsigned;default:'';not null;comment:职务类型"` SuperiorName string `json:"superiorname"` //上级名称 SuperiorNumber string `json:"superiornumber"` //上级编号 + DepartmentName string `json:"departmentname"` +} + +//行政组织树查询 +type govThreeType struct { + overallhandle.GetId + Level int `json:"level"` } diff --git a/api/version1/inlet.go b/api/version1/inlet.go index 574fce2..21a6a53 100644 --- a/api/version1/inlet.go +++ b/api/version1/inlet.go @@ -1,9 +1,13 @@ package version1 -import "hr_server/api/version1/administrativeorganization" +import ( + "hr_server/api/version1/administrativeorganization" + "hr_server/api/version1/permitpowerapi" +) type ApiInlet struct { OrganizationApi administrativeorganization.OrganizationApi + PermitPowerApi permitpowerapi.PermitPowerApi } var AppApiInlet = new(ApiInlet) diff --git a/api/version1/permitpowerapi/menu_permit.go b/api/version1/permitpowerapi/menu_permit.go new file mode 100644 index 0000000..484ceb2 --- /dev/null +++ b/api/version1/permitpowerapi/menu_permit.go @@ -0,0 +1,43 @@ +package permitpowerapi + +import ( + "hr_server/models" + "hr_server/overall" + "hr_server/overall/overallhandle" + + "github.com/gin-gonic/gin" +) + +//权限列表 + +func (p *PermitPowerApi) PermitPowerList(c *gin.Context) { + var muneList []models.SystemMenu + err := overall.CONSTANT_DB_Master.Model(&models.SystemMenu{}).Where("m_steat = 1").Order("m_sort ASC").Order("m_id ASC").Find(&muneList).Error + if err != nil { + overallhandle.Result(105, err, c, "职位编码不能为空!") + return + } + var list []models.SystemMenuOperation + for _, v := range muneList { + var listCont models.SystemMenuOperation + listCont.Id = v.Id + listCont.Title = v.Title // 菜单名称"` + listCont.State = v.State // 是否启用(1:启用;2:禁用;3:删除)"` + listCont.ParentId = v.ParentId // '父级(顶级:0)"` + listCont.ApiUrl = v.ApiUrl // 地址"` + listCont.Time = v.Time // 创建时间"` + listCont.EiteTime = v.EiteTime // 修改时间"` + listCont.UserId = v.UserId // 写入人"` + listCont.Sort = v.Sort // 排序"` + listCont.MenuPermit = getMenuButton(v.Id) + list = append(list, listCont) + } + printList := overallhandle.MenuThreePermit(0, list) + overallhandle.Result(0, printList, c) +} + +//获取菜单按钮 +func getMenuButton(menuId int64) (buttonList []models.MenuOperation) { + overall.CONSTANT_DB_Master.Where("menu_id = ?", menuId).Find(&buttonList) + return +} diff --git a/api/version1/permitpowerapi/position_permit.go b/api/version1/permitpowerapi/position_permit.go new file mode 100644 index 0000000..7190c1b --- /dev/null +++ b/api/version1/permitpowerapi/position_permit.go @@ -0,0 +1,47 @@ +package permitpowerapi + +import ( + "encoding/json" + "hr_server/models" + "hr_server/overall/overallhandle" + "time" + + "github.com/gin-gonic/gin" +) + +//岗位(职位)配权 +func (p *PermitPowerApi) PositionAllotment(c *gin.Context) { + var requestData PositionAllotmentType + err := c.ShouldBindJSON(&requestData) + if err != nil { + overallhandle.Result(100, err, c) + return + } + if requestData.Id == "" { + overallhandle.Result(101, requestData.Id, c) + return + } + whereAry := overallhandle.MapOut() + whereAry["id"] = requestData.Id + var jobClassInfo models.Position + //判断行政组织是否存在 + judgeExist := jobClassInfo.GetCont(whereAry) + if judgeExist != nil { + overallhandle.Result(107, judgeExist, c) + return + } + //权限 + menuPermit, _ := json.Marshal(requestData.MenuPermit) + buttonPermit, _ := json.Marshal(requestData.ButtonPermit) + //赋权 + saveData := overallhandle.MapOut() + saveData["time"] = time.Now().Unix() + saveData["menu_permit"] = menuPermit + saveData["button_permit"] = buttonPermit + eiteErr := jobClassInfo.EiteCont(whereAry, saveData) + if eiteErr != nil { + overallhandle.Result(106, eiteErr, c) + } else { + overallhandle.Result(0, saveData, c) + } +} diff --git a/api/version1/permitpowerapi/type.go b/api/version1/permitpowerapi/type.go new file mode 100644 index 0000000..299e0b7 --- /dev/null +++ b/api/version1/permitpowerapi/type.go @@ -0,0 +1,23 @@ +package permitpowerapi + +import ( + "hr_server/overall/overallhandle" + + "github.com/gin-gonic/gin" +) + +type PermitPowerApi struct{} + +//入口 +func (p *PermitPowerApi) Index(c *gin.Context) { + outputCont := overallhandle.MapOut() + outputCont["index"] = "权限管理入口" + overallhandle.Result(0, outputCont, c) +} + +//岗位(职位)配权 +type PositionAllotmentType struct { + Id string `json:"id"` //岗位(职位) ID + MenuPermit []int64 `json:"menupermit"` //菜单权限 + ButtonPermit []int64 `json:"buttonpermit"` //按钮权限 +} diff --git a/apirouter/inlet.go b/apirouter/inlet.go index 2693202..38bc306 100644 --- a/apirouter/inlet.go +++ b/apirouter/inlet.go @@ -1,11 +1,15 @@ package apirouter -import "hr_server/apirouter/organization" +import ( + "hr_server/apirouter/organization" + "hr_server/apirouter/permit" +) //路由入口 type RouterGroup struct { OrganizationApi organization.OrganizationRoute //组织架构 + PermitPowerApi permit.PermitPower //权限相关操作 } var RouterGroupInlet = new(RouterGroup) diff --git a/apirouter/organization/organization_group.go b/apirouter/organization/organization_group.go index 1fdaa09..bf993a1 100644 --- a/apirouter/organization/organization_group.go +++ b/apirouter/organization/organization_group.go @@ -37,6 +37,8 @@ func (o *OrganizationRoute) InitRouterGroup(route *gin.RouterGroup) { apiRouter.POST("addgovcont", apiHandle.AddGovCont) //添加行政组织 apiRouter.POST("eitegovcont", apiHandle.EiteGovCont) //编辑行政组织 apiRouter.POST("eitegovstateordel", apiHandle.EiteGovStateOrDel) //编辑行政组织状态或删除 + + apiRouter.POST("govthree", apiHandle.GovThree) //行政组织树 //职位(岗位) apiRouter.POST("positionlist", apiHandle.PositionList) //职位(岗位)列表 apiRouter.POST("getpositioncont", apiHandle.GetPositionCont) //获取职位(岗位) diff --git a/apirouter/permit/permit.go b/apirouter/permit/permit.go new file mode 100644 index 0000000..52da4f8 --- /dev/null +++ b/apirouter/permit/permit.go @@ -0,0 +1,19 @@ +package permit + +import ( + "hr_server/api/version1" + + "github.com/gin-gonic/gin" +) + +//组织架构 +func (p *PermitPower) InitRouterGroup(route *gin.RouterGroup) { + apiRouter := route.Group("permit") + var apiHandle = version1.AppApiInlet.PermitPowerApi + { + apiRouter.GET("", apiHandle.Index) //入口 + apiRouter.POST("", apiHandle.Index) //入口 + apiRouter.POST("permitlist", apiHandle.PermitPowerList) //权限列表 + apiRouter.POST("positionallotment", apiHandle.PositionAllotment) //岗位(职位)配权 + } +} diff --git a/apirouter/permit/type.go b/apirouter/permit/type.go new file mode 100644 index 0000000..91c5d12 --- /dev/null +++ b/apirouter/permit/type.go @@ -0,0 +1,4 @@ +package permit + +//权限相关操作 +type PermitPower struct{} diff --git a/config_server/configApp/appConfig.yaml b/config_server/configApp/appConfig.yaml new file mode 100644 index 0000000..577326b --- /dev/null +++ b/config_server/configApp/appConfig.yaml @@ -0,0 +1,6 @@ + +#App主配置 +appsetup: + port: 9999 #服务端口 + readtime: 3600 #请求的读取操作在超时前的最大持续时间 + writetime : 3600 #回复的写入操作在超时前的最大持续时间 \ No newline at end of file diff --git a/config_server/configApp/server.go b/config_server/configApp/server.go new file mode 100644 index 0000000..b3b9646 --- /dev/null +++ b/config_server/configApp/server.go @@ -0,0 +1,13 @@ +package configApp + +//服务基础配置 +type Server struct { + Appsetup appsetup `mapstructure:"appsetup" json:"appsetup" yaml:"appsetup"` +} + +//服务配置详情 +type appsetup struct { + Port int `mapstructure:"port" json:"port" yaml:"port"` + Readtime int `mapstructure:"readtime" json:"readtime" yaml:"readtime"` + Writetime int `mapstructure:"writetime" json:"writetime" yaml:"writetime"` +} diff --git a/config_server/configDatabase/database.go b/config_server/configDatabase/database.go new file mode 100644 index 0000000..8073347 --- /dev/null +++ b/config_server/configDatabase/database.go @@ -0,0 +1,71 @@ +package configDatabase + +import ( + "fmt" + + "gorm.io/driver/mysql" + "gorm.io/gorm" + "gorm.io/gorm/logger" +) + +type MysqlSetUp struct { + MasterMysql MasterMysqlSetUp `mapstructure:"master" json:"master" yaml:"master"` //主数据库 + //其他数据库依次添加 + WechatMysql MasterMysqlSetUp `mapstructure:"wechat" json:"wechat" yaml:"wechat"` //微信数据库 + HrMysql MasterMysqlSetUp `mapstructure:"hrdatabase" json:"hrdatabase" yaml:"hrdatabase"` //HR数据库 +} + +type MasterMysqlSetUp struct { + UrlPath string `mapstructure:"url_path" json:"url_path" yaml:"url_path"` // 服务器地址 + Port int `mapstructure:"port" json:"port" yaml:"port"` // 端口 + Charset string `mapstructure:"charset" json:"charset" yaml:"charset"` // 编码方式 + ParseTime bool `mapstructure:"parseTime" json:"parseTime" yaml:"parseTime"` // 是否自动转换时间 + Loc string `mapstructure:"loc" json:"loc" yaml:"loc"` // 时区 + Name string `mapstructure:"name" json:"name" yaml:"name"` // 数据库名称 + UserName string `mapstructure:"username" json:"username" yaml:"username"` // 账号 + PassWord string `mapstructure:"password" json:"password" yaml:"password"` // 密码 + MaxIdleConns int `mapstructure:"max_idle_conns" json:"max_idle_conns" yaml:"max_idle_conns"` // 最大空闲数 + MaxOpenConns int `mapstructure:"max_open_conns" json:"max_open_conns" yaml:"max_open_conns"` // 最大链接数 + GormLog bool `mapstructure:"gorm_log" json:"gorm_log" yaml:"gorm_log"` // 是否开启Gorm全局日志 +} + +func (m *MasterMysqlSetUp) SqlDsn() (dsnStr string) { + dsnStr = fmt.Sprintf("%v:%v@tcp(%v:%v)/%v?charset=%v", m.UserName, m.PassWord, m.UrlPath, m.Port, m.Name, m.Charset) + if m.ParseTime == true { + dsnStr = fmt.Sprintf("%v:%v@tcp(%v:%v)/%v?charset=%v&parseTime=%v&loc=%v", m.UserName, m.PassWord, m.UrlPath, m.Port, m.Name, m.Charset, m.ParseTime, m.Loc) + } + return +} + +func (m *MasterMysqlSetUp) OpenSql() *gorm.DB { + sqlConfig := mysql.Config{ + DSN: m.SqlDsn(), // DSN + DefaultStringSize: 255, // string 类型字段的默认长度 + DisableDatetimePrecision: true, // 禁用 datetime 精度,MySQL 5.6 之前的数据库不支持 + DontSupportRenameIndex: true, // 重命名索引时采用删除并新建的方式,MySQL 5.7 之前的数据库和 MariaDB 不支持重命名索引 + DontSupportRenameColumn: true, // 用 `change` 重命名列,MySQL 8 之前的数据库和 MariaDB 不支持重命名列 + SkipInitializeWithVersion: false, // 根据版本自动配置 + } + if m.GormLog == true { + if opDb, err := gorm.Open(mysql.New(sqlConfig), &gorm.Config{ + Logger: logger.Default.LogMode(logger.Info), + }); err != nil { + return nil + } else { + sqlDb, _ := opDb.DB() + sqlDb.SetMaxIdleConns(m.MaxIdleConns) + sqlDb.SetMaxOpenConns(m.MaxOpenConns) + return opDb + } + } else { + if opDb, err := gorm.Open(mysql.New(sqlConfig)); err != nil { + return nil + } else { + sqlDb, _ := opDb.DB() + sqlDb.SetMaxIdleConns(m.MaxIdleConns) + sqlDb.SetMaxOpenConns(m.MaxOpenConns) + return opDb + } + } + +} diff --git a/config_server/configDatabase/database.yaml b/config_server/configDatabase/database.yaml new file mode 100644 index 0000000..7b756db --- /dev/null +++ b/config_server/configDatabase/database.yaml @@ -0,0 +1,41 @@ +#数据库配置 + +#主数据库 +master: + url_path: '127.0.0.1' #数据库地址 + port: 3306 #数据库端口 + charset: 'utf8mb4' #数据库编码方式 + parseTime: 'True' #是否自动转换时间 + loc: 'Local' #时区 + name: 'hengxingaoke_tes' #数据库名称 + username: 'hengxingaoke_tes' #数据库用户民 + password: 'JsTt6iTpkZ85wDnF' #数据库密码 + max_idle_conns: 100 #最大空闲数量 + max_open_conns: 1500 #最大打开数量 + gorm_log: false #是否开启gorm日志 +#微信数据库 +wechat: + url_path: '127.0.0.1' #数据库地址 + port: 3306 #数据库端口 + charset: 'utf8mb4' #数据库编码方式 + parseTime: 'True' #是否自动转换时间 + loc: 'Local' #时区 + name: 'wechatuser' #数据库名称 + username: 'wechatuser' #数据库用户民 + password: '8jrFG2AzpJPxs88m' #数据库密码 + max_idle_conns: 100 #最大空闲数量 + max_open_conns: 1500 #最大打开数量 + gorm_log: false #是否开启gorm日志 +#HR数据库 +hrdatabase: + url_path: '127.0.0.1' #数据库地址 + port: 3306 #数据库端口 + charset: 'utf8mb4' #数据库编码方式 + parseTime: 'True' #是否自动转换时间 + loc: 'Local' #时区 + name: 'human_resources' #数据库名称 + username: 'human_resources' #数据库用户民 + password: 'hn4FaeBtePdnw2K6' #数据库密码 + max_idle_conns: 100 #最大空闲数量 + max_open_conns: 1500 #最大打开数量 + gorm_log: true #是否开启gorm日志 \ No newline at end of file diff --git a/config_server/configNosql/redis.go b/config_server/configNosql/redis.go new file mode 100644 index 0000000..5d23743 --- /dev/null +++ b/config_server/configNosql/redis.go @@ -0,0 +1,37 @@ +package confignosql + +import ( + "context" + "fmt" + + "github.com/go-redis/redis/v8" +) + +type RedisSetUp struct { + MasterRedis RedisConfitSetUp `mapstructure:"master" json:"master" yaml:"master"` //主数据库 + MasterRedis1 RedisConfitSetUp `mapstructure:"master1" json:"master1" yaml:"master1"` //主数据库 +} + +type RedisConfitSetUp struct { + UrlPath string `mapstructure:"url_path" json:"url_path" yaml:"url_path"` // 服务器地址 + Port int `mapstructure:"port" json:"port" yaml:"port"` // 端口 + Name int `mapstructure:"name" json:"name" yaml:"name"` // 数据库名称 + PassWord string `mapstructure:"password" json:"password" yaml:"password"` // 密码 +} + +func (r *RedisConfitSetUp) OpenRedis() *redis.Client { + address := fmt.Sprintf("%v:%v", r.UrlPath, r.Port) + fmt.Printf("开启%v Redis库 %v\n", address, r.Name) + redisClient := redis.NewClient(&redis.Options{ + Addr: address, + Password: r.PassWord, + DB: r.Name, + }) + pingLink, err := redisClient.Ping(context.Background()).Result() + if err != nil { + fmt.Printf("%v Redis链接失败!原因:%v\n", r.Name, err) + } else { + fmt.Printf("%v Redis链接成功!=====>%v\n", r.Name, pingLink) + } + return redisClient +} diff --git a/config_server/configNosql/redis.yaml b/config_server/configNosql/redis.yaml new file mode 100644 index 0000000..7356f5b --- /dev/null +++ b/config_server/configNosql/redis.yaml @@ -0,0 +1,41 @@ +#Redis配置文件 +master: + url_path: '127.0.0.1' + port: 6379 #数据库端口 + password: "" + name: 0 + +#Redis配置文件 +master1: + url_path: '127.0.0.1' + port: 6379 #数据库端口 + password: "" + name: 1 + +#Redis配置文件 +master2: + url_path: '127.0.0.1' + port: 6379 #数据库端口 + password: "" + name: 2 + +#Redis配置文件 +master3: + url_path: '127.0.0.1' + port: 6379 #数据库端口 + password: "" + name: 3 + +#Redis配置文件 +master4: + url_path: '127.0.0.1' + port: 6379 #数据库端口 + password: "" + name: 4 + +#Redis配置文件 +master5: + url_path: '127.0.0.1' + port: 6379 #数据库端口 + password: "" + name: 5 \ No newline at end of file diff --git a/hr_server.exe b/hr_server.exe index 57737f8..ea5271c 100644 Binary files a/hr_server.exe and b/hr_server.exe differ diff --git a/initialization/route/route_entry.go b/initialization/route/route_entry.go index c8b165a..cea7a7b 100644 --- a/initialization/route/route_entry.go +++ b/initialization/route/route_entry.go @@ -28,5 +28,10 @@ func InitialRouter() *gin.Engine { { organizationApi.InitRouterGroup(appLoadRouterGroup) } + //权限相关操作 + permitPowerApi := apirouter.RouterGroupInlet.PermitPowerApi + { + permitPowerApi.InitRouterGroup(appLoadRouterGroup) + } return router } diff --git a/models/administrative_organization.go b/models/administrative_organization.go index 5900731..ea1e8da 100644 --- a/models/administrative_organization.go +++ b/models/administrative_organization.go @@ -45,3 +45,9 @@ func (cont *AdministrativeOrganization) CountCont(whereMap map[string]interface{ overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) return } + +//读取全部信息 +func (cont *AdministrativeOrganization) ContMap(whereMap interface{}) (countAry []AdministrativeOrganization) { + overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Find(&countAry) + return +} diff --git a/models/emergency_contact.go b/models/emergency_contact.go new file mode 100644 index 0000000..30adf89 --- /dev/null +++ b/models/emergency_contact.go @@ -0,0 +1,23 @@ +package models + +import "hr_server/overall" + +//紧急联系人 +type EmergencyContact 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:紧急联系人姓名"` + Relationship string `json:"relationship" gorm:"column:relationship;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:创建时间"` + State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` +} + +func (EmergencyContact *EmergencyContact) TableName() string { + return "emergency_contact" +} + +//编辑职务分类内容 +func (EmergencyContact *EmergencyContact) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_HR.Model(&EmergencyContact).Where(whereMap).Updates(saveData).Error + return +} diff --git a/models/family_members.go b/models/family_members.go new file mode 100644 index 0000000..f68a934 --- /dev/null +++ b/models/family_members.go @@ -0,0 +1,26 @@ +package models + +import "hr_server/overall" + +//员工家属 +type FamilyMembers struct { + 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:亲属关系"` + 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:所在公司"` + Deparment string `json:"deparment" gorm:"column:deparment;type:varchar(255) unsigned;default:'';not null;comment:所在部门"` + Postnme string `json:"postnme" gorm:"column:postnme;type:varchar(255) unsigned;default:'';not null;comment:所在岗位"` + Tel string `json:"tel" gorm:"column:tel;type:varchar(255) unsigned;default:'';not null;comment:紧急联系人电话"` + PoliticalOutlook int `json:"politicaloutlook" gorm:"column:political_outlook;type:int(3) unsigned;default:1;not null;comment:政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` +} + +func (FamilyMembers *FamilyMembers) TableName() string { + return "family_members" +} + +//编辑职务分类内容 +func (FamilyMembers *FamilyMembers) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_HR.Model(&FamilyMembers).Where(whereMap).Updates(saveData).Error + return +} diff --git a/models/menu_operation.go b/models/menu_operation.go new file mode 100644 index 0000000..369eadb --- /dev/null +++ b/models/menu_operation.go @@ -0,0 +1,12 @@ +package models + +//菜单功能 +type MenuOperation struct { + OperId int64 `json:"operId" gorm:"primaryKey;column:oper_id;type:bigint(20) unsigned;not null;comment:功能ID"` + MenuId int64 `json:"menuId" gorm:"column:menu_id;type:bigint(20) unsigned;not null;default:0;comment:菜单id"` + OperTitle string `json:"operTitle" gorm:"column:oper_title;type:varchar(255);not null;comment:操作名称"` +} + +func (MenuOperation *MenuOperation) TableName() string { + return "menu_operation" +} diff --git a/models/personnel.go b/models/personnel.go new file mode 100644 index 0000000..909584d --- /dev/null +++ b/models/personnel.go @@ -0,0 +1,32 @@ +package models + +import "hr_server/overall" + +//员工档案(主) +type Personnel struct { + Id int64 `json:"id" gorm:"primaryKey;column:m_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:姓名"` + 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:入职职层"` + 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:所属行政组织"` + Company int64 `json:"company" gorm:"column:company;type:bigint(20) unsigned;default:0;not null;comment:入职公司"` + 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:离职)"` + Deparment string `json:"deparment" gorm:"column:deparment;type:text;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:编辑时间"` + 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:入职职等"` + Role string `json:"role" gorm:"column:role;type:longtext;comment:变动原因"` +} + +func (Personnel *Personnel) TableName() string { + return "personnel" +} + +//编辑职务分类内容 +func (Personnel *Personnel) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_HR.Model(&Personnel).Where(whereMap).Updates(saveData).Error + return +} diff --git a/models/personnel_change_record.go b/models/personnel_change_record.go new file mode 100644 index 0000000..7aa4417 --- /dev/null +++ b/models/personnel_change_record.go @@ -0,0 +1,27 @@ +package models + +import "hr_server/overall" + +//人员变动记录 +type PersonnelChangeRecord struct { + Number string `json:"number" gorm:"primaryKey;column:number;type:varchar(30) unsigned;not null;comment:员工工号;index"` + Type int `json:"type" gorm:"column:type;type:tinyint(1) unsigned;default:1;not null;comment:变动类型(1:雇佣入职;2:再入职;3:职位分配;4:转正;5:停薪留职;6:退休;7:辞退;8:离职)"` + Reason string `json:"reason" gorm:"column:reason;type:text;comment:变动原因"` + Position int64 `json:"position" gorm:"column:position;type:bigint(20) unsigned;default:0;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:入职职等"` + 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:入职分厂"` + 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:写入时间"` +} + +func (PersonnelChangeRecord *PersonnelChangeRecord) TableName() string { + return "personnel_change_record" +} + +//编辑职务分类内容 +func (PersonnelChangeRecord *PersonnelChangeRecord) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_HR.Model(&PersonnelChangeRecord).Where(whereMap).Updates(saveData).Error + return +} diff --git a/models/personnel_content.go b/models/personnel_content.go new file mode 100644 index 0000000..f2b7e5d --- /dev/null +++ b/models/personnel_content.go @@ -0,0 +1,45 @@ +package models + +import "hr_server/overall" + +//员工附属信息 + +type PersonnelContent struct { + Number string `json:"number" gorm:"primaryKey;column:number;type:varchar(30) unsigned;not null;comment:员工工号;index"` + 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:type;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"` + 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:type;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:离异)"` + 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:现居住地址"` + 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:现居住地址"` + 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:否)"` + Veteransnumber string `json:"veteransnumber" gorm:"column:veteransnumber;type:varchar(255) unsigned;default:'';not null;comment:退役证编号"` + Jobstartdate int64 `json:"jobstartdate" gorm:"column:jobstartdate;type:bigint(20) unsigned;default:0;not null;comment:参加工作日期"` + 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:预计转正日期"` +} + +func (PersonnelContent *PersonnelContent) TableName() string { + return "personnel_content" +} + +//编辑职务分类内容 +func (PersonnelContent *PersonnelContent) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_HR.Model(&PersonnelContent).Where(whereMap).Updates(saveData).Error + return +} diff --git a/models/personnel_education.go b/models/personnel_education.go new file mode 100644 index 0000000..550901a --- /dev/null +++ b/models/personnel_education.go @@ -0,0 +1,26 @@ +package models + +import "hr_server/overall" + +//教育经历 + +type PersonnelEducation struct { + Number string `json:"number" gorm:"primaryKey;column:number;type:varchar(30) unsigned;not null;comment:员工工号;index"` + Education string `json:"education" gorm:"column:education;type:varchar(255) unsigned;default:'';not null;comment:学历"` + GraduationSchool string `json:"graduationschool" gorm:"column:graduation_school;type:varchar(255) unsigned;default:'';not null;comment:毕业学校"` + Subject string `json:"subject" gorm:"column:subject;type:varchar(255) unsigned;default:'';not null;comment:专业"` + AdmissionTime int64 `json:"admissiontime" gorm:"column:admission_time;type:bigint(20) unsigned;default:0;not null;comment:入学时间"` + GraduationTime int64 `json:"graduationtime" gorm:"column:graduation_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:写入时间"` + Level int `json:"level" gorm:"column:type;level:tinyint(1) unsigned;default:1;not null;comment:学历类型(1:普通;2:第一学历;3:最高学历)"` +} + +func (PersonnelEducation *PersonnelEducation) TableName() string { + return "personnel_change_record" +} + +//编辑职务分类内容 +func (PersonnelEducation *PersonnelEducation) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_HR.Model(&PersonnelEducation).Where(whereMap).Updates(saveData).Error + return +} diff --git a/models/position_level.go b/models/position_level.go new file mode 100644 index 0000000..f02a28a --- /dev/null +++ b/models/position_level.go @@ -0,0 +1,21 @@ +package models + +import "hr_server/overall" + +//职位等级 +type PositionLevel 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:等级名称"` + Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` +} + +func (PositionLevel *PositionLevel) TableName() string { + return "personnel_change_record" +} + +//编辑职务分类内容 +func (PositionLevel *PositionLevel) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_HR.Model(&PositionLevel).Where(whereMap).Updates(saveData).Error + return +} diff --git a/models/system_nenu.go b/models/system_nenu.go new file mode 100644 index 0000000..290710a --- /dev/null +++ b/models/system_nenu.go @@ -0,0 +1,47 @@ +package models + +import ( + "hr_server/overall" + "strings" +) + +//菜单 +type SystemMenu struct { + Id int64 `json:"id" gorm:"primaryKey;column:m_id;type:bigint(20) unsigned;not null;comment:ID"` + Title string `json:"title" gorm:"column:m_title;type:varchar(255);not null;comment:菜单名称"` + State int `json:"state" gorm:"column:m_steat;type:tinyint(1) unsigned;default:1;not null;comment:是否启用(1:启用;2:禁用;3:删除)"` + ParentId int64 `json:"parentId" gorm:"column:m_parent;type:bigint(30) unsigned;default:0;not null;comment:'父级(顶级:0)"` + ApiUrl string `json:"apiUrl" gorm:"column:m_url;type:varchar(255);not null;comment:地址"` + Time int64 `json:"time" gorm:"column:m_time;type:bigint(30) unsigned;default:0;not null;comment:创建时间"` + EiteTime int64 `json:"eiteTime" gorm:"column:m_eite_time;type:bigint(30) unsigned;default:0;not null;comment:修改时间"` + UserId int64 `json:"userId" gorm:"column:m_user_id;type:bigint(20) unsigned;not null;default:0;comment:写入人"` + Sort int `json:"sort" gorm:"column:m_sort;type:tinyint(3) unsigned;default:0;not null;comment:排序"` +} + +func (SystemMenu *SystemMenu) TableName() string { + return "system_menu" +} + +//菜单管理 +type SystemMenuOperation struct { + SystemMenu + MenuPermit []MenuOperation `json:"menupermit"` +} + +//根据条件获取总数 +func (cont *SystemMenu) CountCont(whereMap map[string]interface{}) (countId int64) { + overall.CONSTANT_DB_Master.Model(&cont).Where(whereMap).Count(&countId) + return +} + +//获取行政组织内容 +func (cont *SystemMenu) GetCont(whereMap map[string]interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_Master.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} diff --git a/overall/overallhandle/overall_handle.go b/overall/overallhandle/overall_handle.go index 5b5b686..9f32035 100644 --- a/overall/overallhandle/overall_handle.go +++ b/overall/overallhandle/overall_handle.go @@ -261,5 +261,57 @@ func CreateNumber(firstWords, govClass string) (numberStr string) { return } -// //获取行政组织的部门 -// func GetOrgDepartment() +type MenuList []OutGovCont + +//行政组织递归 +func (g *MenuList) GovRecursion(parentId, level int64) []govThree { + var govMap []govThree + + list := g.findChildren(parentId) + if len(list) == 0 { + return govMap + } + for _, v := range list { + // child := g.GovRecursion(v.Superior, level+1) + g.GovRecursion(v.Superior, level+1) + // govMap = append(govMap, govThree{v, child}) + } + return govMap +} + +//获取子集 +func (g *MenuList) findChildren(parentId int64) []OutGovCont { + child := []OutGovCont{} + + for _, v := range *g { + if v.Superior == parentId { + child = append(child, v) + } + } + return child +} + +func GovThreeList(parentId int64, govAry []OutGovCont) []govThree { + var govMap []govThree + for _, v := range govAry { + // var zhucont govThree + if v.Superior == parentId { + child := GovThreeList(v.Id, govAry) + govMap = append(govMap, govThree{v, child}) + } + + } + return govMap +} + +//菜单权限递归 +func MenuThreePermit(parentId int64, menuAry []models.SystemMenuOperation) []MenuPermitThree { + var menuThree []MenuPermitThree + for _, v := range menuAry { + if v.ParentId == parentId { + child := MenuThreePermit(v.Id, menuAry) + menuThree = append(menuThree, MenuPermitThree{v, child}) + } + } + return menuThree +} diff --git a/overall/overallhandle/type.go b/overall/overallhandle/type.go index 6eab594..fa5a9f3 100644 --- a/overall/overallhandle/type.go +++ b/overall/overallhandle/type.go @@ -1,5 +1,7 @@ package overallhandle +import "hr_server/models" + //格式化输出 type Reply struct { Code int `json:"code"` @@ -35,3 +37,22 @@ type outGovToClass struct { Abbreviation string `json:"abbreviation" gorm:"column:abbreviation;type:varchar(255) unsigned;default:'';not null;comment:行政组织简称"` Level int64 `json:"level" gorm:"column:level;type:int(5) unsigned;default:1;not null;comment:级别"` } + +//输出行政组织信息 +type OutGovCont struct { + models.AdministrativeOrganization + ClassName string `json:"classname" gorm:"column:classname;type:varchar(255) unsigned;default:'';not null;comment:行政组织分类名称"` + Level int64 `json:"level" gorm:"column:level;type:int(5) unsigned;default:1;not null;comment:级别"` +} + +//组织架构树 +type govThree struct { + OutGovCont + Child []govThree `json:"child"` +} + +//输出菜单权限树 +type MenuPermitThree struct { + models.SystemMenuOperation + Child []MenuPermitThree `json:"child"` +}