作者 郑周

1. 增加权限字段

... ... @@ -9,6 +9,8 @@ type UpdatePermissionCommand struct {
CompanyId int64 `cname:"公司Id"`
OptHrScore int `cname:"上级修改人资综评分数" json:"optHrScore" valid:"Required"`
OptEvalScore int `cname:"上级修改360°综评分数" json:"optEvalScore" valid:"Required"`
OptConfirmPerf int `cname:"是否需要员工确认绩效" json:"optConfirmPerf"`
CycleDeadLine *domain.CycleDeadline `cname:"周期评估各业务截止时间" json:"cycleDeadline"`
}
func (in *UpdatePermissionCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -68,6 +68,8 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (*domain.Perm
CompanyId: in.CompanyId,
OptHrScore: domain.PermissionOff,
OptEvalScore: domain.PermissionOff,
OptConfirmPerf: domain.PermissionOff,
CycleDeadLine: rs.defaultCycleDeadline(),
}
permission, err = permissionRepository.Insert(value)
if err != nil {
... ... @@ -75,9 +77,59 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (*domain.Perm
}
} else {
permission = permissions[0]
// 纠正数据
var isChange = false
if permission.OptHrScore == 0 {
isChange = true
permission.OptHrScore = domain.PermissionOff
}
if permission.OptEvalScore == 0 {
isChange = true
permission.OptEvalScore = domain.PermissionOff
}
if permission.OptConfirmPerf == 0 {
isChange = true
permission.OptConfirmPerf = domain.PermissionOff
}
if permission.CycleDeadLine == nil {
isChange = true
permission.CycleDeadLine = rs.defaultCycleDeadline()
}
if isChange {
permission, err = permissionRepository.Insert(permission)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return permission, nil
}
// 创建默认周期截止时间
func (rs *PermissionService) defaultCycleDeadline() *domain.CycleDeadline {
return &domain.CycleDeadline{
AssessmentSelf: domain.DeadlineTime{
Hour: 3 * 24,
Minute: 0,
},
AssessmentAll: domain.DeadlineTime{
Hour: 5 * 24,
Minute: 0,
},
AssessmentHr: domain.DeadlineTime{
Hour: 5 * 24,
Minute: 0,
},
AssessmentSuperior: domain.DeadlineTime{
Hour: 7 * 24,
Minute: 0,
},
ViewMyPerf: domain.DeadlineTime{
Hour: 9 * 24,
Minute: 0,
},
}
}
... ...
... ... @@ -12,11 +12,27 @@ type Permission struct {
CompanyId int64 `json:"companyId" comment:"公司ID" `
OptHrScore int `json:"optHrScore" comment:"上级是否可以修改人资综评分数"`
OptEvalScore int `json:"optEvalScore" comment:"上级是否可以修改360°综评分数"`
OptConfirmPerf int `json:"optConfirmPerf " comment:"是否需要员工确认绩效"`
CycleDeadLine *CycleDeadline `json:"cycleDeadline" comment:"周期评估各业务截止时间"`
CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"`
DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
}
// CycleDeadline 周期评估截止时间
type CycleDeadline struct {
AssessmentSelf DeadlineTime `json:"assessmentSelf" comment:"综合自评"`
AssessmentAll DeadlineTime `json:"assessmentAll" comment:"360评估"`
AssessmentHr DeadlineTime `json:"assessmentHr" comment:"人资评估"`
AssessmentSuperior DeadlineTime `json:"assessmentSuperior" comment:"上级评估"`
ViewMyPerf DeadlineTime `json:"viewMyPerf" comment:"查看我的绩效"`
}
type DeadlineTime struct {
Hour int `json:"hour" comment:"时"`
Minute int `json:"minute" comment:"分"`
}
type PermissionRepository interface {
Insert(permission *Permission) (*Permission, error)
FindOne(queryOptions map[string]interface{}) (*Permission, error)
... ...
package models
import "time"
import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"time"
)
type Permission struct {
tableName struct{} `comment:"配置权限" pg:"permission"`
... ... @@ -8,6 +11,8 @@ type Permission struct {
CompanyId int64 `comment:"公司ID"`
OptHrScore int `comment:"上级是否可以修改人资综评分数"`
OptEvalScore int `comment:"上级是否可以修改360°综评分数"`
OptConfirmPerf int `comment:"是否需要员工确认绩效"`
CycleDeadLine *domain.CycleDeadline `comment:"周期评估各业务截止时间"`
CreatedAt time.Time `comment:"创建时间"`
UpdatedAt time.Time `comment:"更新时间"`
DeletedAt *time.Time `comment:"删除时间"`
... ...
... ... @@ -26,6 +26,8 @@ func (repo *PermissionRepository) TransformToDomain(m *models.Permission) domain
CompanyId: m.CompanyId,
OptHrScore: m.OptHrScore,
OptEvalScore: m.OptEvalScore,
OptConfirmPerf: m.OptConfirmPerf,
CycleDeadLine: m.CycleDeadLine,
CreatedAt: m.CreatedAt.Local(),
UpdatedAt: m.UpdatedAt.Local(),
DeletedAt: m.DeletedAt,
... ... @@ -38,6 +40,8 @@ func (repo *PermissionRepository) TransformToModel(d *domain.Permission) models.
CompanyId: d.CompanyId,
OptHrScore: d.OptHrScore,
OptEvalScore: d.OptEvalScore,
OptConfirmPerf: d.OptConfirmPerf,
CycleDeadLine: d.CycleDeadLine,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
DeletedAt: d.DeletedAt,
... ...
-- 权限表建新列
ALTER TABLE public."permission" ADD opt_confirm_perf int8 NULL DEFAULT 1;
COMMENT ON COLUMN public."permission".opt_confirm_perf IS '是否需要员工确认绩效';
ALTER TABLE public."permission" ADD cycle_deadline jsonb NULL;
COMMENT ON COLUMN public."permission".cycle_deadline IS '周期评估各业务截止时间';
... ...