2023-04-12 16:56:55 +08:00
|
|
|
package contracts
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"git.fsdpf.net/go/db"
|
2024-05-09 13:15:24 +08:00
|
|
|
"git.fsdpf.net/go/req"
|
2023-04-12 16:56:55 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type UserApprovalExecute int
|
|
|
|
|
|
|
|
// 审批状态
|
|
|
|
type UserApprovalStatus int
|
|
|
|
|
|
|
|
// 审批节点类型
|
|
|
|
type UserApprovalFlowType int
|
|
|
|
|
|
|
|
const (
|
|
|
|
// 驳回
|
|
|
|
UserApprovalExecute_Reject UserApprovalExecute = iota
|
|
|
|
// 通过
|
|
|
|
UserApprovalExecute_Resolve
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
// 待审批
|
|
|
|
UserApprovalStatus_Accept UserApprovalStatus = iota
|
|
|
|
// 审批中
|
|
|
|
UserApprovalStatus_Pending
|
|
|
|
// 通过
|
|
|
|
UserApprovalStatus_Resolve
|
|
|
|
// 驳回
|
|
|
|
UserApprovalStatus_Reject
|
|
|
|
// 取消审批
|
|
|
|
UserApprovalStatus_Cancel
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
// 角色节点
|
|
|
|
UserApprovalFlowType_Role UserApprovalFlowType = iota + 1
|
|
|
|
// 自动节点
|
|
|
|
UserApprovalFlowType_Condition
|
|
|
|
// 开始节点
|
|
|
|
UserApprovalFlowType_Begin
|
|
|
|
// 通过节点
|
|
|
|
UserApprovalFlowType_Reject
|
|
|
|
// 驳回节点
|
|
|
|
UserApprovalFlowType_Resolve
|
|
|
|
)
|
|
|
|
|
|
|
|
type UserApproval interface {
|
|
|
|
// 审批流名称
|
|
|
|
Name() string
|
|
|
|
// 发起审批请求
|
2024-05-09 13:15:24 +08:00
|
|
|
RequestApproval(req.Route, *http.Request) any
|
2023-04-12 16:56:55 +08:00
|
|
|
// 判断发起审批请求权限
|
2024-05-09 13:15:24 +08:00
|
|
|
HasUserRoles(req.User) bool
|
2023-04-12 16:56:55 +08:00
|
|
|
// 获取审批列表标记字段值
|
|
|
|
Execute(id int64, status UserApprovalExecute, r *http.Request, tx *db.Transaction) (current, next UserApprovalFlow, err error)
|
|
|
|
}
|
|
|
|
|
|
|
|
type UserApprovalFlow interface {
|
|
|
|
// 节点名称
|
|
|
|
Name() string
|
|
|
|
// 节点UUID
|
|
|
|
Uuid() string
|
|
|
|
// 节点类型
|
|
|
|
Type() UserApprovalFlowType
|
|
|
|
// 注入审批条件
|
|
|
|
InjectOrm(Orm) error
|
|
|
|
// 下一节点
|
|
|
|
Yes() string
|
|
|
|
// 下一节点
|
|
|
|
No() string
|
|
|
|
// 审批角色UUID
|
|
|
|
RoleUuid() string
|
|
|
|
// 上一节点
|
|
|
|
Parent() UserApproval
|
|
|
|
}
|
|
|
|
|
|
|
|
type GetUserApproval func(uuid string) (UserApproval, bool)
|