78 lines
4.2 KiB
Go
78 lines
4.2 KiB
Go
|
|
package hr
|
|||
|
|
|
|||
|
|
import (
|
|||
|
|
"WiiGoLibrary/framework/db/v1/utils/mssql/unique"
|
|||
|
|
"WiiGoLibrary/framework/db/v1/utils/tool"
|
|||
|
|
"WiiGoLibrary/framework/hub/v1/dblib"
|
|||
|
|
"time"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
const PositionTable = "hr_u_position"
|
|||
|
|
|
|||
|
|
// PositionModel 岗位模型
|
|||
|
|
type PositionModel struct {
|
|||
|
|
RecordGuid unique.UUID `gorm:"column:RecordGuid;type:UNIQUEIDENTIFIER;primaryKey;not null;default:newid();" json:"RecordGuid"`
|
|||
|
|
PositionID int64 `gorm:"column:PositionID;type:BIGINT;not null;" json:"PositionID"` // 岗位编号
|
|||
|
|
PositionName string `gorm:"column:PositionName;type:NVARCHAR(50);not null;" json:"PositionName"` // 岗位名称
|
|||
|
|
PositionCode string `gorm:"column:PositionCode;type:NVARCHAR(20);not null;" json:"PositionCode"` // 岗位代码
|
|||
|
|
Description string `gorm:"column:Description;type:NVARCHAR(200);" json:"Description"` // 岗位描述
|
|||
|
|
Level int16 `gorm:"column:Level;type:SMALLINT;not null;default:0;" json:"Level"` // 岗位级别
|
|||
|
|
CategoryID int16 `gorm:"column:CategoryID;type:SMALLINT;not null;default:0;" json:"CategoryID"` // 岗位类别ID
|
|||
|
|
CategoryName string `gorm:"column:CategoryName;type:NVARCHAR(50);" json:"CategoryName"` // 岗位类别名称
|
|||
|
|
IsManagement bool `gorm:"column:IsManagement;type:BIT;not null;default:0;" json:"IsManagement"` // 是否管理岗位
|
|||
|
|
Status int16 `gorm:"column:Status;type:SMALLINT;not null;default:1;" json:"Status"` // 状态:1-启用,0-禁用
|
|||
|
|
RecordType int16 `gorm:"column:RecordType;not null;" json:"RecordType"` // 记录类型
|
|||
|
|
RecordStatus int16 `gorm:"column:RecordStatus;not null;default:0;" json:"RecordStatus"` // 记录状态
|
|||
|
|
CreateTime time.Time `gorm:"column:CreateTime;type:DATETIME;default:CURRENT_TIMESTAMP;<-:create;" json:"CreateTime"`
|
|||
|
|
UpdateTime time.Time `gorm:"column:UpdateTime;type:DATETIME;default:CURRENT_TIMESTAMP;autoUpdateTime;" json:"UpdateTime"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// OrgPositionRelModel 组织与岗位关系模型
|
|||
|
|
type OrgPositionRelModel struct {
|
|||
|
|
RecordGuid unique.UUID `gorm:"column:RecordGuid;type:UNIQUEIDENTIFIER;primaryKey;not null;default:newid();" json:"RecordGuid"`
|
|||
|
|
OrganizationID int64 `gorm:"column:OrganizationID;type:BIGINT;not null;index:idx_org_position;" json:"OrganizationID"` // 组织ID
|
|||
|
|
PositionID int64 `gorm:"column:PositionID;type:BIGINT;not null;index:idx_org_position;" json:"PositionID"` // 岗位ID
|
|||
|
|
HeadCount int `gorm:"column:HeadCount;type:INT;not null;default:1;" json:"HeadCount"` // 岗位编制人数
|
|||
|
|
OrganizationGuid unique.UUID `gorm:"column:OrganizationGuid;type:UNIQUEIDENTIFIER;not null;" json:"OrganizationGuid"` // 组织GUID
|
|||
|
|
PositionGuid unique.UUID `gorm:"column:PositionGuid;type:UNIQUEIDENTIFIER;not null;" json:"PositionGuid"` // 岗位GUID
|
|||
|
|
RecordType int16 `gorm:"column:RecordType;not null;" json:"RecordType"` // 记录类型
|
|||
|
|
RecordStatus int16 `gorm:"column:RecordStatus;not null;default:0;" json:"RecordStatus"` // 记录状态
|
|||
|
|
CreateTime time.Time `gorm:"column:CreateTime;type:DATETIME;default:CURRENT_TIMESTAMP;<-:create;" json:"CreateTime"`
|
|||
|
|
UpdateTime time.Time `gorm:"column:UpdateTime;type:DATETIME;default:CURRENT_TIMESTAMP;autoUpdateTime;" json:"UpdateTime"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
const OrgPositionRelTable = "hr_r_organization_position"
|
|||
|
|
|
|||
|
|
func init() {
|
|||
|
|
dblib.DBIns.RegisterAutoMigrateModel(&PositionModel{})
|
|||
|
|
dblib.DBIns.RegisterAutoMigrateModel(&OrgPositionRelModel{})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (p *PositionModel) TableName() string {
|
|||
|
|
return PositionTable
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (op *OrgPositionRelModel) TableName() string {
|
|||
|
|
return OrgPositionRelTable
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func PositionInstance() *PositionModel {
|
|||
|
|
return &PositionModel{
|
|||
|
|
RecordGuid: unique.NewV4(),
|
|||
|
|
PositionID: tool.GenerateID(),
|
|||
|
|
IsManagement: false,
|
|||
|
|
Status: 1, // 默认启用
|
|||
|
|
RecordType: 0,
|
|||
|
|
RecordStatus: 0,
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func OrgPositionRelInstance() *OrgPositionRelModel {
|
|||
|
|
return &OrgPositionRelModel{
|
|||
|
|
RecordGuid: unique.NewV4(),
|
|||
|
|
HeadCount: 1,
|
|||
|
|
RecordType: 0,
|
|||
|
|
RecordStatus: 0,
|
|||
|
|
}
|
|||
|
|
}
|