package sysin import ( "context" "hotgo/internal/consts" "hotgo/internal/library/dict" "hotgo/internal/model/entity" "hotgo/internal/model/input/form" "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/os/gtime" ) type ApprovalRequestInsertFields struct { ApprovalNo string `json:"approvalNo"` ApprovalType string `json:"approvalType"` TargetType string `json:"targetType"` TargetId uint64 `json:"targetId"` Action string `json:"action"` Title string `json:"title"` PayloadJson *gjson.Json `json:"payloadJson"` DiffJson *gjson.Json `json:"diffJson"` RiskLevel int `json:"riskLevel"` RequiredApprovals uint `json:"requiredApprovals"` ApprovalStatus int `json:"approvalStatus"` ApplicantId uint64 `json:"applicantId"` ExpireAt *gtime.Time `json:"expireAt"` Version uint `json:"version"` Remark string `json:"remark"` CreatedBy uint64 `json:"createdBy"` } type ApprovalCreateInp struct { ApprovalType string `json:"approvalType" v:"required|max-length:32#审批类型不能为空|审批类型不能超过32个字符" dc:"审批类型"` TargetType string `json:"targetType" v:"required|max-length:32#目标类型不能为空|目标类型不能超过32个字符" dc:"目标类型"` TargetId uint64 `json:"targetId" dc:"目标ID"` Action string `json:"action" v:"required|max-length:64#拟执行动作不能为空|拟执行动作不能超过64个字符" dc:"拟执行动作"` Title string `json:"title" v:"required|max-length:200#审批标题不能为空|审批标题不能超过200个字符" dc:"审批标题"` PayloadJson *gjson.Json `json:"payloadJson" v:"required#待执行数据不能为空" dc:"待执行数据快照"` DiffJson *gjson.Json `json:"diffJson" dc:"前后差异"` RiskLevel int `json:"riskLevel" d:"1" dc:"风险等级"` RequiredApprovals uint `json:"requiredApprovals" d:"1" v:"min:1|max:10#至少需要1人审批|审批人数不能超过10人" dc:"需要通过数"` ExpireAt *gtime.Time `json:"expireAt" dc:"超时时间"` Remark string `json:"remark" v:"max-length:500#备注不能超过500个字符" dc:"备注"` } func (in *ApprovalCreateInp) Filter(ctx context.Context) error { if !dict.HasOptionKey(consts.ApprovalRiskLevelOptions, in.RiskLevel) { return gerror.New("审批风险等级不合法") } if in.ExpireAt != nil && in.ExpireAt.Before(gtime.Now()) { return gerror.New("审批超时时间必须晚于当前时间") } return nil } type ApprovalCreateModel struct { Id uint64 `json:"id" dc:"审批ID"` ApprovalNo string `json:"approvalNo" dc:"审批单号"` } type ApprovalListInp struct { form.PageReq ApprovalNo string `json:"approvalNo" dc:"审批单号"` ApprovalType string `json:"approvalType" dc:"审批类型"` TargetType string `json:"targetType" dc:"目标类型"` TargetId uint64 `json:"targetId" dc:"目标ID"` ApprovalStatus int `json:"approvalStatus" dc:"审批状态"` RiskLevel int `json:"riskLevel" dc:"风险等级"` Applicant string `json:"applicant" dc:"申请人关键词"` CreatedAt []*gtime.Time `json:"createdAt" dc:"创建时间"` } func (in *ApprovalListInp) Filter(ctx context.Context) error { return nil } type ApprovalListModel struct { Id uint64 `json:"id"` ApprovalNo string `json:"approvalNo"` ApprovalType string `json:"approvalType"` TargetType string `json:"targetType"` TargetId uint64 `json:"targetId"` Action string `json:"action"` Title string `json:"title"` RiskLevel int `json:"riskLevel"` RequiredApprovals uint `json:"requiredApprovals"` ApprovalStatus int `json:"approvalStatus"` ApplicantId uint64 `json:"applicantId"` SubmittedAt *gtime.Time `json:"submittedAt"` DecidedAt *gtime.Time `json:"decidedAt"` ExpireAt *gtime.Time `json:"expireAt"` Version uint `json:"version"` CreatedAt *gtime.Time `json:"createdAt"` UpdatedAt *gtime.Time `json:"updatedAt"` AllowedActions []string `json:"allowedActions" dc:"当前用户可执行动作"` } type ApprovalViewInp struct { Id uint64 `json:"id" v:"required|min:1#审批ID不能为空|审批ID不能为空" dc:"审批ID"` } func (in *ApprovalViewInp) Filter(ctx context.Context) error { return nil } type ApprovalActionModel struct { entity.ApprovalAction } type ApprovalViewModel struct { entity.ApprovalRequest Actions []*ApprovalActionModel `json:"actions" dc:"审批记录"` AllowedActions []string `json:"allowedActions" dc:"当前用户可执行动作"` } type ApprovalSubmitInp struct { Id uint64 `json:"id" v:"required|min:1#审批ID不能为空|审批ID不能为空"` Version uint `json:"version" dc:"数据版本"` } func (in *ApprovalSubmitInp) Filter(ctx context.Context) error { return nil } type ApprovalDecisionInp struct { Id uint64 `json:"id" v:"required|min:1#审批ID不能为空|审批ID不能为空"` Version uint `json:"version" dc:"数据版本"` ReasonCode string `json:"reasonCode" v:"max-length:64#原因编码不能超过64个字符" dc:"原因编码"` Comment string `json:"comment" v:"max-length:1000#审批意见不能超过1000个字符" dc:"审批意见"` MfaVerified int `json:"mfaVerified" dc:"是否已二次认证"` } func (in *ApprovalDecisionInp) Filter(ctx context.Context) error { return nil } type ApprovalCancelInp struct { Id uint64 `json:"id" v:"required|min:1#审批ID不能为空|审批ID不能为空"` Version uint `json:"version" dc:"数据版本"` Comment string `json:"comment" v:"max-length:1000#取消原因不能超过1000个字符" dc:"取消原因"` } func (in *ApprovalCancelInp) Filter(ctx context.Context) error { return nil }