feat:完善项目

This commit is contained in:
henry
2021-11-05 18:07:32 +08:00
parent d20ac3e09f
commit 85b58968d1
13 changed files with 254 additions and 17 deletions

View File

@ -0,0 +1,55 @@
package model
import (
"ArmedPolice/app/common/model"
"fmt"
)
type WorkSchedule struct {
*model.WorkSchedule
}
// WorkScheduleInfo 工单流程信息
type WorkScheduleInfo struct {
ID uint64 `json:"id"`
Reviewer []uint64 `json:"reviewer"`
}
// ValidateAuth 验证权限
func (m *WorkSchedule) ValidateAuth(uid uint64) (bool, error) {
// 流程权限信息
auths := make(map[string]bool, 0)
for _, v := range m.GetTargetValueAttribute() {
auths[v] = true
}
// 触发审核对象
switch m.Target {
case model.WorkScheduleTargetForPerson: // 个人
_, has := auths[fmt.Sprintf("%d", uid)]
return has, nil
case model.WorkScheduleTargetForRole: // 角色
// 查询角色信息
roleIDs := make([]uint64, 0)
mSysUserRole := model.NewSysUserRole()
if err := model.Pluck(mSysUserRole, "role_id", &roleIDs, model.NewWhere("uid", uid)); err != nil {
return false, err
}
for _, v := range roleIDs {
if _, has := auths[fmt.Sprintf("%d", v)]; has {
return has, nil
}
}
break
}
return false, nil
}
func (m *WorkSchedule) NextSchedule() (*WorkScheduleInfo, error) {
return nil, nil
}
func NewWorkSchedule() *WorkSchedule {
return &WorkSchedule{model.NewWorkSchedule()}
}