109 lines
3.5 KiB
Go
109 lines
3.5 KiB
Go
package schema
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/guxuan/hailin_service/internal/config"
|
|
"github.com/guxuan/hailin_service/pkg/util"
|
|
)
|
|
|
|
const (
|
|
JobStatusDisabled = "disabled"
|
|
JobStatusEnabled = "enabled"
|
|
)
|
|
|
|
var (
|
|
JobOrderParams = []util.OrderByParam{
|
|
{Field: "created_at", Direction: util.DESC},
|
|
{Field: "sequence", Direction: util.DESC},
|
|
}
|
|
JobOrderNoCreatedAtParams = []util.OrderByParam{
|
|
{Field: "sequence", Direction: util.DESC},
|
|
}
|
|
)
|
|
|
|
// Article management for RBAC
|
|
type Job struct {
|
|
ID string `json:"id" gorm:"size:20;primarykey;"` //主键
|
|
JobAreaID string `json:"jobAreaId" gorm:"size:20;not null;index"` //职位地区id
|
|
Title string `json:"title" gorm:"size:128;not null;index"` //标题
|
|
Introduce string `json:"introduce" gorm:"type:text"` //要求
|
|
Duty string `json:"duty" gorm:"type:text"` //职责
|
|
Salary string `json:"salary" gorm:"size:50"` //薪资
|
|
Sequence int `json:"sequence" gorm:"index;"` //排序
|
|
Status string `json:"status" gorm:"size:20;index"` //状态
|
|
CreatedAt time.Time `json:"created_at" gorm:"index;"`
|
|
UpdatedAt time.Time `json:"updated_at" gorm:"index;"`
|
|
}
|
|
type JobArea struct {
|
|
ID string `json:"id" gorm:"size:20;primarykey;"` // Unique ID
|
|
Name string `json:"name" gorm:"size:128;not null;index"` // 区域名字
|
|
Status string `json:"status" gorm:"size:20;index"` // Status of banner (enabled, disabled) // Child menus
|
|
CreatedAt time.Time `json:"created_at" gorm:"index;"` // Create time
|
|
UpdatedAt time.Time `json:"updated_at" gorm:"index;"` // Update time
|
|
}
|
|
|
|
type WebJobData struct {
|
|
JobAreaTitle string `json:"jobAreaTitle"`
|
|
JobList Jobs `json:"jobList"`
|
|
}
|
|
|
|
func (a *Job) TableName() string {
|
|
return config.C.FormatTableName("job")
|
|
}
|
|
func (a *JobArea) TableName() string {
|
|
return config.C.FormatTableName("job_area")
|
|
}
|
|
|
|
// Defining the query parameters for the `Menu` struct.
|
|
type JobQueryParam struct {
|
|
util.PaginationParam
|
|
JobAreaID string `form:"jobAreaId"` // Display name of menu
|
|
LikeTitle string `form:"title"` // Display name of menu
|
|
Status string `form:"status"` // Status of menu (enabled, disabled)
|
|
}
|
|
|
|
// Defining the query options for the `Menu` struct.
|
|
type JobQueryOptions struct {
|
|
util.QueryOptions
|
|
}
|
|
|
|
// Defining the query result for the `Menu` struct.
|
|
type JobQueryResult struct {
|
|
Data Jobs
|
|
PageResult *util.PaginationResult
|
|
}
|
|
|
|
// Defining the slice of `Menu` struct.
|
|
type Jobs []*Job
|
|
|
|
func (a Jobs) Len() int {
|
|
return len(a)
|
|
}
|
|
|
|
type JobForm struct {
|
|
Title string `json:"title" binding:"required,max=128"` // Display name of menu
|
|
Sequence int `json:"sequence"` // Sequence for sorting (Order by desc)
|
|
JobAreaId string `json:"jobAreaId" `
|
|
Introduce string `json:"introduce"`
|
|
Duty string `json:"duty" `
|
|
Salary string `json:"salary"` // Details about banner
|
|
Status string `json:"status" binding:"required,oneof=disabled enabled"` // Status of menu (enabled, disabled)
|
|
}
|
|
|
|
type JobAreaForm struct {
|
|
Name string `json:"name" binding:"required,max=128"` // Display name of menu // Details about banner
|
|
Status string `json:"status" binding:"required,oneof=disabled enabled"`
|
|
}
|
|
|
|
func (a *JobForm) FillTo(job *Job) error {
|
|
job.Title = a.Title
|
|
job.JobAreaID = a.JobAreaId
|
|
job.Sequence = a.Sequence
|
|
job.Introduce = a.Introduce
|
|
job.Duty = a.Duty
|
|
job.Salary = a.Salary
|
|
job.Status = a.Status
|
|
return nil
|
|
}
|