Files
ArmedPolice/app/common/model/work_schedule.go

73 lines
2.3 KiB
Go
Raw Normal View History

2021-11-03 14:51:14 +08:00
package model
2021-11-05 18:07:32 +08:00
import "strings"
2021-11-05 15:27:04 +08:00
// WorkSchedule 工单流程数据模型
2021-11-03 14:51:14 +08:00
type WorkSchedule struct {
Model
2021-11-16 16:39:21 +08:00
Kind WorkScheduleKind `gorm:"column:kind;type:tinyint(1);default:1;comment:工单类型1维修工单" json:"-"`
2021-11-08 11:09:27 +08:00
Title string `gorm:"column:title;type:varchar(30);default:null;comment:标题" json:"title"`
2021-11-09 14:08:02 +08:00
Stage int `gorm:"column:stage;type:tinyint(1);default:1;comment:阶段" json:"stage"`
Step int `gorm:"column:step;type:tinyint(1);default:1;comment:步骤1阶段-1步骤" json:"step"`
2021-11-16 16:39:21 +08:00
Target WorkScheduleTarget `gorm:"column:target;type:tinyint(1);default:1;comment:对象类型1个人2角色" json:"target"`
2021-11-09 14:08:02 +08:00
TargetValue string `gorm:"column:target_value;type:tinyint(1);default:1;comment:对象信息" json:"target_value"`
IsCountersign WorkScheduleCountersign `gorm:"column:is_countersign;type:tinyint(1);default:0;comment:是否会签" json:"is_countersign"`
2021-11-03 14:51:14 +08:00
ModelDeleted
ModelAt
}
2021-11-09 14:08:02 +08:00
// WorkScheduleKind 工单流程类型
type WorkScheduleKind int
const (
// WorkScheduleKindForRepair 维修工单
WorkScheduleKindForRepair WorkScheduleKind = iota + 1
)
2021-11-05 15:27:04 +08:00
// WorkScheduleTarget 工单对象类型
type WorkScheduleTarget int
const (
// WorkScheduleTargetForPerson 个人
2021-11-05 18:07:32 +08:00
WorkScheduleTargetForPerson WorkScheduleTarget = iota + 1
2021-11-05 15:27:04 +08:00
// WorkScheduleTargetForRole 角色
WorkScheduleTargetForRole
)
2021-11-08 11:09:27 +08:00
// WorkScheduleCountersign 工单会签模式
type WorkScheduleCountersign int
const (
// WorkScheduleCountersignForNot 不是会签模式
WorkScheduleCountersignForNot WorkScheduleCountersign = iota
// WorkScheduleCountersignForYes 是会签模式
WorkScheduleCountersignForYes
)
2021-11-03 14:51:14 +08:00
func (m *WorkSchedule) TableName() string {
return "work_schedule"
}
2021-11-08 11:09:27 +08:00
func (m *WorkSchedule) CountersignStatus() bool {
return m.IsCountersign == WorkScheduleCountersignForYes
}
2021-11-05 18:07:32 +08:00
func (m *WorkSchedule) GetTargetValueAttribute() []string {
return strings.Split(m.TargetValue, ",")
}
func (m *WorkSchedule) SetTargetValueAttribute(value []string) {
m.TargetValue = strings.Join(value, ",")
}
2021-11-09 14:08:02 +08:00
func (m *WorkSchedule) KindTitle() string {
if m.Kind == WorkScheduleKindForRepair {
return "维修工单"
}
return ""
}
2021-11-03 14:51:14 +08:00
func NewWorkSchedule() *WorkSchedule {
return &WorkSchedule{}
}