32 changed files with 749 additions and 8 deletions
@ -1,9 +1,13 @@ |
|||||
package version1 |
package version1 |
||||
|
|
||||
import "hr_server/api/version1/administrativeorganization" |
import ( |
||||
|
"hr_server/api/version1/administrativeorganization" |
||||
|
"hr_server/api/version1/permitpowerapi" |
||||
|
) |
||||
|
|
||||
type ApiInlet struct { |
type ApiInlet struct { |
||||
OrganizationApi administrativeorganization.OrganizationApi |
OrganizationApi administrativeorganization.OrganizationApi |
||||
|
PermitPowerApi permitpowerapi.PermitPowerApi |
||||
} |
} |
||||
|
|
||||
var AppApiInlet = new(ApiInlet) |
var AppApiInlet = new(ApiInlet) |
||||
|
|||||
@ -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 |
||||
|
} |
||||
@ -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) |
||||
|
} |
||||
|
} |
||||
@ -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"` //按钮权限
|
||||
|
} |
||||
@ -1,11 +1,15 @@ |
|||||
package apirouter |
package apirouter |
||||
|
|
||||
import "hr_server/apirouter/organization" |
import ( |
||||
|
"hr_server/apirouter/organization" |
||||
|
"hr_server/apirouter/permit" |
||||
|
) |
||||
|
|
||||
//路由入口
|
//路由入口
|
||||
|
|
||||
type RouterGroup struct { |
type RouterGroup struct { |
||||
OrganizationApi organization.OrganizationRoute //组织架构
|
OrganizationApi organization.OrganizationRoute //组织架构
|
||||
|
PermitPowerApi permit.PermitPower //权限相关操作
|
||||
} |
} |
||||
|
|
||||
var RouterGroupInlet = new(RouterGroup) |
var RouterGroupInlet = new(RouterGroup) |
||||
|
|||||
@ -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) //岗位(职位)配权
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,4 @@ |
|||||
|
package permit |
||||
|
|
||||
|
//权限相关操作
|
||||
|
type PermitPower struct{} |
||||
@ -0,0 +1,6 @@ |
|||||
|
|
||||
|
#App主配置 |
||||
|
appsetup: |
||||
|
port: 9999 #服务端口 |
||||
|
readtime: 3600 #请求的读取操作在超时前的最大持续时间 |
||||
|
writetime : 3600 #回复的写入操作在超时前的最大持续时间 |
||||
@ -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"` |
||||
|
} |
||||
@ -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 |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -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日志 |
||||
@ -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 |
||||
|
} |
||||
@ -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 |
||||
Binary file not shown.
@ -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 |
||||
|
} |
||||
@ -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 |
||||
|
} |
||||
@ -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" |
||||
|
} |
||||
@ -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 |
||||
|
} |
||||
@ -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 |
||||
|
} |
||||
@ -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 |
||||
|
} |
||||
@ -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 |
||||
|
} |
||||
@ -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 |
||||
|
} |
||||
@ -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 |
||||
|
} |
||||
Loading…
Reference in new issue