作者 郑周

1. 系统权限参数更新,判断超级管理员权限标记

... ... @@ -7,6 +7,7 @@ import (
type UpdatePermissionCommand struct {
CompanyId int64 `cname:"公司Id"`
UserId int64 `cname:"用户ID"`
OptHrScore int `cname:"上级修改人资综评分数" json:"optHrScore" valid:"Required"`
OptEvalScore int `cname:"上级修改360°综评分数" json:"optEvalScore" valid:"Required"`
OptConfirmPerf int `cname:"是否需要员工确认绩效" json:"optConfirmPerf"`
... ...
... ... @@ -4,6 +4,7 @@ import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission/command"
service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
... ... @@ -23,6 +24,7 @@ func (rs *PermissionService) Update(in *command.UpdatePermissionCommand) (interf
defer func() {
transactionContext.RollbackTransaction()
}()
permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})
// 获取权限配置
_, permissions, err := permissionRepository.Find(map[string]interface{}{"companyId": in.CompanyId})
... ... @@ -36,6 +38,45 @@ func (rs *PermissionService) Update(in *command.UpdatePermissionCommand) (interf
permission.OptHrScore = in.OptHrScore
permission.OptEvalScore = in.OptEvalScore
// 超级管理员权限传参
if in.OptConfirmPerf > 0 || in.CycleDeadLine != nil {
superAdmin, err := service.GetSuperAdmin(transactionContext, int(in.CompanyId), int(in.UserId))
if err != nil {
return nil, err
}
if superAdmin != domain.RoleTypeSuperAdmin {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
}
switch in.OptConfirmPerf {
case domain.PermissionOff, domain.PermissionOn:
default:
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "是否需要员工确认绩效参数错误")
}
var cycleDeadLine = in.CycleDeadLine
var allMinuteSelf = cycleDeadLine.AssessmentSelf.Hour*60 + cycleDeadLine.AssessmentSelf.Minute
var allMinute360 = cycleDeadLine.AssessmentAll.Hour*60 + cycleDeadLine.AssessmentAll.Minute
//var allMinuteHr = cycleDeadLine.AssessmentHr.Hour*60 + cycleDeadLine.AssessmentHr.Minute
var allMinuteSuperior = cycleDeadLine.AssessmentSuperior.Hour*60 + cycleDeadLine.AssessmentSuperior.Minute
var allMinuteMy = cycleDeadLine.ViewMyPerf.Hour*60 + cycleDeadLine.ViewMyPerf.Minute
// 注. 360和人资评估时间截止是相同的(前端只传递一个360评估参数)
cycleDeadLine.AssessmentHr.Hour = cycleDeadLine.AssessmentAll.Hour
cycleDeadLine.AssessmentHr.Minute = cycleDeadLine.AssessmentAll.Minute
if allMinuteSelf > allMinute360 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "截止时间:[360评估]不能小于[综合自评]")
}
if allMinute360 > allMinuteSuperior {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "截止时间:[上级评估]不能小于[360评估]")
}
if allMinuteSuperior > allMinuteMy {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "截止时间:[查看我的绩效]不能小于[上级评估]")
}
permission.OptConfirmPerf = in.OptConfirmPerf
permission.CycleDeadLine = in.CycleDeadLine
}
permission, err = permissionRepository.Insert(permission)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -3,7 +3,7 @@ package domain
import "time"
const (
RoleTypeCommon int = 0 // 角色类型-添加角色
RoleTypeCommon int = 0 // 角色类型-普通角色
RoleTypeSystem int = 1 // 角色类型-系统预制角色HR-BP(不可删除、编辑)
RoleTypeSuperAdmin int = 2 // 角色类型-系统预制超级管理员(不可删除、编辑)
)
... ...
... ... @@ -20,6 +20,7 @@ func (controller *PermissionController) UpdatePermission() {
} else {
ua := middlewares.GetUser(controller.Ctx)
in.CompanyId = ua.CompanyId
in.UserId = ua.UserId
controller.Response(ruService.Update(in))
}
}
... ...