作者 郑周

1. 增加权限字段

@@ -9,6 +9,8 @@ type UpdatePermissionCommand struct { @@ -9,6 +9,8 @@ type UpdatePermissionCommand struct {
9 CompanyId int64 `cname:"公司Id"` 9 CompanyId int64 `cname:"公司Id"`
10 OptHrScore int `cname:"上级修改人资综评分数" json:"optHrScore" valid:"Required"` 10 OptHrScore int `cname:"上级修改人资综评分数" json:"optHrScore" valid:"Required"`
11 OptEvalScore int `cname:"上级修改360°综评分数" json:"optEvalScore" valid:"Required"` 11 OptEvalScore int `cname:"上级修改360°综评分数" json:"optEvalScore" valid:"Required"`
  12 + OptConfirmPerf int `cname:"是否需要员工确认绩效" json:"optConfirmPerf"`
  13 + CycleDeadLine *domain.CycleDeadline `cname:"周期评估各业务截止时间" json:"cycleDeadline"`
12 } 14 }
13 15
14 func (in *UpdatePermissionCommand) Valid(validation *validation.Validation) { 16 func (in *UpdatePermissionCommand) Valid(validation *validation.Validation) {
@@ -68,6 +68,8 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (*domain.Perm @@ -68,6 +68,8 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (*domain.Perm
68 CompanyId: in.CompanyId, 68 CompanyId: in.CompanyId,
69 OptHrScore: domain.PermissionOff, 69 OptHrScore: domain.PermissionOff,
70 OptEvalScore: domain.PermissionOff, 70 OptEvalScore: domain.PermissionOff,
  71 + OptConfirmPerf: domain.PermissionOff,
  72 + CycleDeadLine: rs.defaultCycleDeadline(),
71 } 73 }
72 permission, err = permissionRepository.Insert(value) 74 permission, err = permissionRepository.Insert(value)
73 if err != nil { 75 if err != nil {
@@ -75,9 +77,59 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (*domain.Perm @@ -75,9 +77,59 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (*domain.Perm
75 } 77 }
76 } else { 78 } else {
77 permission = permissions[0] 79 permission = permissions[0]
  80 + // 纠正数据
  81 + var isChange = false
  82 + if permission.OptHrScore == 0 {
  83 + isChange = true
  84 + permission.OptHrScore = domain.PermissionOff
  85 + }
  86 + if permission.OptEvalScore == 0 {
  87 + isChange = true
  88 + permission.OptEvalScore = domain.PermissionOff
  89 + }
  90 + if permission.OptConfirmPerf == 0 {
  91 + isChange = true
  92 + permission.OptConfirmPerf = domain.PermissionOff
  93 + }
  94 + if permission.CycleDeadLine == nil {
  95 + isChange = true
  96 + permission.CycleDeadLine = rs.defaultCycleDeadline()
  97 + }
  98 + if isChange {
  99 + permission, err = permissionRepository.Insert(permission)
  100 + if err != nil {
  101 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  102 + }
  103 + }
78 } 104 }
79 if err := transactionContext.CommitTransaction(); err != nil { 105 if err := transactionContext.CommitTransaction(); err != nil {
80 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 106 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
81 } 107 }
82 return permission, nil 108 return permission, nil
83 } 109 }
  110 +
  111 +// 创建默认周期截止时间
  112 +func (rs *PermissionService) defaultCycleDeadline() *domain.CycleDeadline {
  113 + return &domain.CycleDeadline{
  114 + AssessmentSelf: domain.DeadlineTime{
  115 + Hour: 3 * 24,
  116 + Minute: 0,
  117 + },
  118 + AssessmentAll: domain.DeadlineTime{
  119 + Hour: 5 * 24,
  120 + Minute: 0,
  121 + },
  122 + AssessmentHr: domain.DeadlineTime{
  123 + Hour: 5 * 24,
  124 + Minute: 0,
  125 + },
  126 + AssessmentSuperior: domain.DeadlineTime{
  127 + Hour: 7 * 24,
  128 + Minute: 0,
  129 + },
  130 + ViewMyPerf: domain.DeadlineTime{
  131 + Hour: 9 * 24,
  132 + Minute: 0,
  133 + },
  134 + }
  135 +}
@@ -12,11 +12,27 @@ type Permission struct { @@ -12,11 +12,27 @@ type Permission struct {
12 CompanyId int64 `json:"companyId" comment:"公司ID" ` 12 CompanyId int64 `json:"companyId" comment:"公司ID" `
13 OptHrScore int `json:"optHrScore" comment:"上级是否可以修改人资综评分数"` 13 OptHrScore int `json:"optHrScore" comment:"上级是否可以修改人资综评分数"`
14 OptEvalScore int `json:"optEvalScore" comment:"上级是否可以修改360°综评分数"` 14 OptEvalScore int `json:"optEvalScore" comment:"上级是否可以修改360°综评分数"`
  15 + OptConfirmPerf int `json:"optConfirmPerf " comment:"是否需要员工确认绩效"`
  16 + CycleDeadLine *CycleDeadline `json:"cycleDeadline" comment:"周期评估各业务截止时间"`
15 CreatedAt time.Time `json:"createdAt" comment:"创建时间"` 17 CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
16 UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` 18 UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"`
17 DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` 19 DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
18 } 20 }
19 21
  22 +// CycleDeadline 周期评估截止时间
  23 +type CycleDeadline struct {
  24 + AssessmentSelf DeadlineTime `json:"assessmentSelf" comment:"综合自评"`
  25 + AssessmentAll DeadlineTime `json:"assessmentAll" comment:"360评估"`
  26 + AssessmentHr DeadlineTime `json:"assessmentHr" comment:"人资评估"`
  27 + AssessmentSuperior DeadlineTime `json:"assessmentSuperior" comment:"上级评估"`
  28 + ViewMyPerf DeadlineTime `json:"viewMyPerf" comment:"查看我的绩效"`
  29 +}
  30 +
  31 +type DeadlineTime struct {
  32 + Hour int `json:"hour" comment:"时"`
  33 + Minute int `json:"minute" comment:"分"`
  34 +}
  35 +
20 type PermissionRepository interface { 36 type PermissionRepository interface {
21 Insert(permission *Permission) (*Permission, error) 37 Insert(permission *Permission) (*Permission, error)
22 FindOne(queryOptions map[string]interface{}) (*Permission, error) 38 FindOne(queryOptions map[string]interface{}) (*Permission, error)
1 package models 1 package models
2 2
3 -import "time" 3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  5 + "time"
  6 +)
4 7
5 type Permission struct { 8 type Permission struct {
6 tableName struct{} `comment:"配置权限" pg:"permission"` 9 tableName struct{} `comment:"配置权限" pg:"permission"`
@@ -8,6 +11,8 @@ type Permission struct { @@ -8,6 +11,8 @@ type Permission struct {
8 CompanyId int64 `comment:"公司ID"` 11 CompanyId int64 `comment:"公司ID"`
9 OptHrScore int `comment:"上级是否可以修改人资综评分数"` 12 OptHrScore int `comment:"上级是否可以修改人资综评分数"`
10 OptEvalScore int `comment:"上级是否可以修改360°综评分数"` 13 OptEvalScore int `comment:"上级是否可以修改360°综评分数"`
  14 + OptConfirmPerf int `comment:"是否需要员工确认绩效"`
  15 + CycleDeadLine *domain.CycleDeadline `comment:"周期评估各业务截止时间"`
11 CreatedAt time.Time `comment:"创建时间"` 16 CreatedAt time.Time `comment:"创建时间"`
12 UpdatedAt time.Time `comment:"更新时间"` 17 UpdatedAt time.Time `comment:"更新时间"`
13 DeletedAt *time.Time `comment:"删除时间"` 18 DeletedAt *time.Time `comment:"删除时间"`
@@ -26,6 +26,8 @@ func (repo *PermissionRepository) TransformToDomain(m *models.Permission) domain @@ -26,6 +26,8 @@ func (repo *PermissionRepository) TransformToDomain(m *models.Permission) domain
26 CompanyId: m.CompanyId, 26 CompanyId: m.CompanyId,
27 OptHrScore: m.OptHrScore, 27 OptHrScore: m.OptHrScore,
28 OptEvalScore: m.OptEvalScore, 28 OptEvalScore: m.OptEvalScore,
  29 + OptConfirmPerf: m.OptConfirmPerf,
  30 + CycleDeadLine: m.CycleDeadLine,
29 CreatedAt: m.CreatedAt.Local(), 31 CreatedAt: m.CreatedAt.Local(),
30 UpdatedAt: m.UpdatedAt.Local(), 32 UpdatedAt: m.UpdatedAt.Local(),
31 DeletedAt: m.DeletedAt, 33 DeletedAt: m.DeletedAt,
@@ -38,6 +40,8 @@ func (repo *PermissionRepository) TransformToModel(d *domain.Permission) models. @@ -38,6 +40,8 @@ func (repo *PermissionRepository) TransformToModel(d *domain.Permission) models.
38 CompanyId: d.CompanyId, 40 CompanyId: d.CompanyId,
39 OptHrScore: d.OptHrScore, 41 OptHrScore: d.OptHrScore,
40 OptEvalScore: d.OptEvalScore, 42 OptEvalScore: d.OptEvalScore,
  43 + OptConfirmPerf: d.OptConfirmPerf,
  44 + CycleDeadLine: d.CycleDeadLine,
41 CreatedAt: d.CreatedAt, 45 CreatedAt: d.CreatedAt,
42 UpdatedAt: d.UpdatedAt, 46 UpdatedAt: d.UpdatedAt,
43 DeletedAt: d.DeletedAt, 47 DeletedAt: d.DeletedAt,
  1 +-- 权限表建新列
  2 +ALTER TABLE public."permission" ADD opt_confirm_perf int8 NULL DEFAULT 1;
  3 +COMMENT ON COLUMN public."permission".opt_confirm_perf IS '是否需要员工确认绩效';
  4 +
  5 +ALTER TABLE public."permission" ADD cycle_deadline jsonb NULL;
  6 +COMMENT ON COLUMN public."permission".cycle_deadline IS '周期评估各业务截止时间';
  7 +