作者 tangxvhui
@@ -6,9 +6,11 @@ import ( @@ -6,9 +6,11 @@ import (
6 ) 6 )
7 7
8 type UpdatePermissionCommand struct { 8 type UpdatePermissionCommand struct {
9 - CompanyId int64 `cname:"公司Id"`  
10 - OptHrScore int `cname:"上级修改人资综评分数" json:"optHrScore" valid:"Required"`  
11 - OptEvalScore int `cname:"上级修改360°综评分数" json:"optEvalScore" valid:"Required"` 9 + CompanyId int64 `cname:"公司Id"`
  10 + OptHrScore int `cname:"上级修改人资综评分数" json:"optHrScore" 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) {
@@ -64,10 +64,12 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (*domain.Perm @@ -64,10 +64,12 @@ func (rs *PermissionService) Get(in *command.GetPermissionCommand) (*domain.Perm
64 var permission *domain.Permission 64 var permission *domain.Permission
65 if len(permissions) == 0 { // 不存在时,新增权限配置 65 if len(permissions) == 0 { // 不存在时,新增权限配置
66 value := &domain.Permission{ 66 value := &domain.Permission{
67 - Id: 0,  
68 - CompanyId: in.CompanyId,  
69 - OptHrScore: domain.PermissionOff,  
70 - OptEvalScore: domain.PermissionOff, 67 + Id: 0,
  68 + CompanyId: in.CompanyId,
  69 + OptHrScore: 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 +}
@@ -113,6 +113,9 @@ func (rs *RoleService) Remove(in *command.DeleteRoleCommand) (interface{}, error @@ -113,6 +113,9 @@ func (rs *RoleService) Remove(in *command.DeleteRoleCommand) (interface{}, error
113 if role.Type == domain.RoleTypeSystem { 113 if role.Type == domain.RoleTypeSystem {
114 return nil, application.ThrowError(application.BUSINESS_ERROR, "系统预制角色不可删除") 114 return nil, application.ThrowError(application.BUSINESS_ERROR, "系统预制角色不可删除")
115 } 115 }
  116 + if role.Type == domain.RoleTypeSuperAdmin {
  117 + return nil, application.ThrowError(application.BUSINESS_ERROR, "超级管理员角色不可删除")
  118 + }
116 119
117 if _, err := roleRepository.Remove(role); err != nil { 120 if _, err := roleRepository.Remove(role); err != nil {
118 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 121 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -160,7 +163,7 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ @@ -160,7 +163,7 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{
160 163
161 adapterList := make([]*adapter.RoleUserAdapter, 0) 164 adapterList := make([]*adapter.RoleUserAdapter, 0)
162 165
163 - // 如果不存在系统预支hrbp角色时,插入一条数据 166 + // 如果不存在系统预支hr-bp角色时,新增数据
164 var havaSystemType = false 167 var havaSystemType = false
165 for i := range roles { 168 for i := range roles {
166 if roles[i].Type == domain.RoleTypeSystem { 169 if roles[i].Type == domain.RoleTypeSystem {
@@ -190,6 +193,10 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ @@ -190,6 +193,10 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{
190 193
191 for i := range roles { 194 for i := range roles {
192 v := roles[i] 195 v := roles[i]
  196 +
  197 + if v.Type == domain.RoleTypeSuperAdmin { // 超级管理员角色不显示到界面上
  198 + continue
  199 + }
193 _, tempList, err := ruRepository.FindAllContainUser(1, 10, in.CompanyId, v.Id) 200 _, tempList, err := ruRepository.FindAllContainUser(1, 10, in.CompanyId, v.Id)
194 if err != nil { 201 if err != nil {
195 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 202 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -115,32 +115,68 @@ func (rs *RoleUserService) ListRole(in *command.UserRoleQueryCommand) (interface @@ -115,32 +115,68 @@ func (rs *RoleUserService) ListRole(in *command.UserRoleQueryCommand) (interface
115 return tool_funs.SimpleWrapGridMap(total, tempList), nil 115 return tool_funs.SimpleWrapGridMap(total, tempList), nil
116 } 116 }
117 117
118 -// GetHRBP 当前操作人是否拥有HRBP权限  
119 -// 返回 1 是 表示具有hrbp 权限  
120 -  
121 -func GetHRBP(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) {  
122 - roleRepo := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext})  
123 - roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})  
124 - _, roleList, err := roleRepo.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "companyId": companyId}) 118 +// GetHrBp 当前操作人是否拥有HR-BP权限 (1表示有权限)
  119 +func GetHrBp(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) {
  120 + roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext})
  121 + roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})
  122 + _, roles, err := roleRepository.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "companyId": companyId})
125 if err != nil { 123 if err != nil {
126 return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error()) 124 return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error())
127 } 125 }
128 - _, userRoleList, err := roleUserRepo.Find(map[string]interface{}{"companyId": companyId, "userId": operatorId}) 126 + if len(roles) == 0 {
  127 + return -1, nil
  128 + }
  129 +
  130 + _, userRoles, err := roleUserRepository.Find(map[string]interface{}{"companyId": companyId, "userId": operatorId})
129 if err != nil { 131 if err != nil {
130 return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error()) 132 return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error())
131 } 133 }
132 - // 拥有HRBP权限  
133 - hrbp := -1  
134 - for _, v := range userRoleList {  
135 - for _, v2 := range roleList {  
136 - if v.RoleId == v2.Id {  
137 - hrbp = 1  
138 - break 134 + if len(userRoles) == 0 {
  135 + return -1, nil
  136 + }
  137 +
  138 + hrBp := -1
  139 +loopFinish:
  140 + for _, userRole := range userRoles {
  141 + for _, role := range roles {
  142 + if userRole.RoleId == role.Id {
  143 + hrBp = domain.RoleTypeSystem
  144 + break loopFinish
139 } 145 }
140 } 146 }
141 - if hrbp == 1 {  
142 - break 147 + }
  148 + return hrBp, nil
  149 +}
  150 +
  151 +// GetSuperAdmin 当前操作人是否拥有超级管理员权限 (2表示有权限)
  152 +func GetSuperAdmin(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) {
  153 + roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext})
  154 + roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})
  155 + _, roles, err := roleRepository.Find(map[string]interface{}{"type": domain.RoleTypeSuperAdmin, "companyId": companyId})
  156 + if err != nil {
  157 + return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error())
  158 + }
  159 + if len(roles) == 0 {
  160 + return -1, nil
  161 + }
  162 +
  163 + _, userRoles, err := roleUserRepository.Find(map[string]interface{}{"companyId": companyId, "userId": operatorId})
  164 + if err != nil {
  165 + return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error())
  166 + }
  167 + if len(userRoles) == 0 {
  168 + return -1, nil
  169 + }
  170 +
  171 + superAdmin := -1
  172 +loopFinish:
  173 + for _, userRole := range userRoles {
  174 + for _, role := range roles {
  175 + if userRole.RoleId == role.Id {
  176 + superAdmin = domain.RoleTypeSuperAdmin
  177 + break loopFinish
  178 + }
143 } 179 }
144 } 180 }
145 - return hrbp, nil 181 + return superAdmin, nil
146 } 182 }
@@ -2,6 +2,7 @@ package service @@ -2,6 +2,7 @@ package service
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
5 "sort" 6 "sort"
6 "strconv" 7 "strconv"
7 "time" 8 "time"
@@ -29,28 +30,9 @@ func NewStaffAssessServeice() *StaffAssessServeice { @@ -29,28 +30,9 @@ func NewStaffAssessServeice() *StaffAssessServeice {
29 30
30 // 获取HRBP标记值 31 // 获取HRBP标记值
31 func (srv StaffAssessServeice) getHRBP(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) { 32 func (srv StaffAssessServeice) getHRBP(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) {
32 - roleRepo := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext})  
33 - roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})  
34 - _, roleList, err := roleRepo.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "companyId": companyId}) 33 + hrbp, err := service.GetHrBp(transactionContext, companyId, operatorId)
35 if err != nil { 34 if err != nil {
36 - return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error())  
37 - }  
38 - _, userRoleList, err := roleUserRepo.Find(map[string]interface{}{"companyId": companyId, "userId": operatorId})  
39 - if err != nil {  
40 - return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error())  
41 - }  
42 - // 拥有HRBP权限  
43 - hrbp := -1  
44 - for _, v := range userRoleList {  
45 - for _, v2 := range roleList {  
46 - if v.RoleId == v2.Id {  
47 - hrbp = 1  
48 - break  
49 - }  
50 - }  
51 - if hrbp == 1 {  
52 - break  
53 - } 35 + return -1, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
54 } 36 }
55 return hrbp, nil 37 return hrbp, nil
56 } 38 }
@@ -26,11 +26,11 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.Qu @@ -26,11 +26,11 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.Qu
26 _ = transactionContext.RollbackTransaction() 26 _ = transactionContext.RollbackTransaction()
27 }() 27 }()
28 //判断是否是hrbp 28 //判断是否是hrbp
29 - flagHrbp, err := roleService.GetHRBP(transactionContext, param.CompanyId, param.UserId) 29 + flagHrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.UserId)
30 if err != nil { 30 if err != nil {
31 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 31 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
32 } 32 }
33 - if flagHrbp != 1 { 33 + if flagHrbp != domain.RoleTypeSystem {
34 return nil, application.ThrowError(application.BUSINESS_ERROR, "暂无数据") 34 return nil, application.ThrowError(application.BUSINESS_ERROR, "暂无数据")
35 } 35 }
36 //判断是否是上级 36 //判断是否是上级
@@ -41,7 +41,7 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.Qu @@ -41,7 +41,7 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.Qu
41 "parentId": param.UserId, 41 "parentId": param.UserId,
42 "limit": 1, 42 "limit": 1,
43 }) 43 })
44 - if len(parentUser) == 0 && flagHrbp != 1 { 44 + if len(parentUser) == 0 && flagHrbp != domain.RoleTypeSystem {
45 return nil, application.ThrowError(application.BUSINESS_ERROR, "暂无数据") 45 return nil, application.ThrowError(application.BUSINESS_ERROR, "暂无数据")
46 } 46 }
47 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ 47 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
@@ -43,7 +43,7 @@ func (srv *SummaryEvaluationService) GetExecutorCycleList(param *command.QueryCy @@ -43,7 +43,7 @@ func (srv *SummaryEvaluationService) GetExecutorCycleList(param *command.QueryCy
43 "transactionContext": transactionContext, 43 "transactionContext": transactionContext,
44 }) 44 })
45 45
46 - flagHrbp, err := roleService.GetHRBP(transactionContext, param.CompanyId, param.UserId) 46 + flagHrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.UserId)
47 if err != nil { 47 if err != nil {
48 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 48 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
49 } 49 }
@@ -194,7 +194,7 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri @@ -194,7 +194,7 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
194 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 194 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
195 } 195 }
196 } 196 }
197 - isHrbp, err := roleService.GetHRBP(transactionContext, param.CompanyId, param.UserId) 197 + isHrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.UserId)
198 if err != nil { 198 if err != nil {
199 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 199 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
200 } 200 }
@@ -1772,11 +1772,11 @@ func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.Quer @@ -1772,11 +1772,11 @@ func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.Quer
1772 _ = transactionContext.RollbackTransaction() 1772 _ = transactionContext.RollbackTransaction()
1773 }() 1773 }()
1774 //判断是否是hrbp 1774 //判断是否是hrbp
1775 - flagHrbp, err := roleService.GetHRBP(transactionContext, param.CompanyId, param.UserId) 1775 + flagHrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.UserId)
1776 if err != nil { 1776 if err != nil {
1777 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1777 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1778 } 1778 }
1779 - if flagHrbp != 1 { 1779 + if flagHrbp != domain.RoleTypeSystem {
1780 return tool_funs.SimpleWrapGridMap(0, []string{}), nil 1780 return tool_funs.SimpleWrapGridMap(0, []string{}), nil
1781 } 1781 }
1782 //判断是否是上级 1782 //判断是否是上级
@@ -1788,7 +1788,7 @@ func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.Quer @@ -1788,7 +1788,7 @@ func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.Quer
1788 "parentId": param.UserId, 1788 "parentId": param.UserId,
1789 "limit": 1, 1789 "limit": 1,
1790 }) 1790 })
1791 - if len(parentUser) == 0 && flagHrbp != 1 { 1791 + if len(parentUser) == 0 && flagHrbp != domain.RoleTypeSystem {
1792 return tool_funs.SimpleWrapGridMap(0, []string{}), nil 1792 return tool_funs.SimpleWrapGridMap(0, []string{}), nil
1793 } 1793 }
1794 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ 1794 evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
@@ -437,11 +437,11 @@ func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEval @@ -437,11 +437,11 @@ func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEval
437 }() 437 }()
438 438
439 // 必须是HRBP权限的人才能编辑操作 439 // 必须是HRBP权限的人才能编辑操作
440 - hrbp, err := service.GetHRBP(transactionContext, param.CompanyId, param.UserId) 440 + hrbp, err := service.GetHrBp(transactionContext, param.CompanyId, param.UserId)
441 if err != nil { 441 if err != nil {
442 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 442 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
443 } 443 }
444 - if hrbp != 1 { 444 + if hrbp != domain.RoleTypeSystem {
445 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") 445 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
446 } 446 }
447 447
@@ -738,11 +738,11 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu @@ -738,11 +738,11 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
738 itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext}) 738 itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
739 739
740 // 必须是HRBP权限的人才能编辑操作 740 // 必须是HRBP权限的人才能编辑操作
741 - hrbp, err := service.GetHRBP(transactionContext, param.CompanyId, param.ExecutorId) 741 + hrbp, err := service.GetHrBp(transactionContext, param.CompanyId, param.ExecutorId)
742 if err != nil { 742 if err != nil {
743 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 743 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
744 } 744 }
745 - if hrbp != 1 { 745 + if hrbp != domain.RoleTypeSystem {
746 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") 746 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
747 } 747 }
748 748
@@ -135,11 +135,11 @@ func (us *UserService) EditParentUser(in *command.EditParentCommand) error { @@ -135,11 +135,11 @@ func (us *UserService) EditParentUser(in *command.EditParentCommand) error {
135 transactionContext.RollbackTransaction() 135 transactionContext.RollbackTransaction()
136 }() 136 }()
137 137
138 - hrbp, err := service.GetHRBP(transactionContext, in.CompanyId, in.OperatorId) 138 + hrbp, err := service.GetHrBp(transactionContext, in.CompanyId, in.OperatorId)
139 if err != nil { 139 if err != nil {
140 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 140 return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
141 } 141 }
142 - if hrbp != 1 { 142 + if hrbp != domain.RoleTypeSystem {
143 return application.ThrowError(application.BUSINESS_ERROR, "HRBP权限的员工才能操作") 143 return application.ThrowError(application.BUSINESS_ERROR, "HRBP权限的员工才能操作")
144 } 144 }
145 145
@@ -177,11 +177,11 @@ func (us *UserService) ImportParentUser(in *command.ImportParentUserCommand) (in @@ -177,11 +177,11 @@ func (us *UserService) ImportParentUser(in *command.ImportParentUserCommand) (in
177 transactionContext.RollbackTransaction() 177 transactionContext.RollbackTransaction()
178 }() 178 }()
179 179
180 - hrbp, err := service.GetHRBP(transactionContext, in.CompanyId, in.OperatorId) 180 + hrbp, err := service.GetHrBp(transactionContext, in.CompanyId, in.OperatorId)
181 if err != nil { 181 if err != nil {
182 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 182 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
183 } 183 }
184 - if hrbp != 1 { 184 + if hrbp != domain.RoleTypeSystem {
185 return nil, application.ThrowError(application.BUSINESS_ERROR, "HRBP权限的员工才能操作") 185 return nil, application.ThrowError(application.BUSINESS_ERROR, "HRBP权限的员工才能操作")
186 } 186 }
187 userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) 187 userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
@@ -8,13 +8,29 @@ const ( @@ -8,13 +8,29 @@ const (
8 ) 8 )
9 9
10 type Permission struct { 10 type Permission struct {
11 - Id int64 `json:"id,string"`  
12 - CompanyId int64 `json:"companyId" comment:"公司ID" `  
13 - OptHrScore int `json:"optHrScore" comment:"上级是否可以修改人资综评分数"`  
14 - OptEvalScore int `json:"optEvalScore" comment:"上级是否可以修改360°综评分数"`  
15 - CreatedAt time.Time `json:"createdAt" comment:"创建时间"`  
16 - UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"`  
17 - DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` 11 + Id int64 `json:"id,string"`
  12 + CompanyId int64 `json:"companyId" comment:"公司ID" `
  13 + OptHrScore int `json:"optHrScore" comment:"上级是否可以修改人资综评分数"`
  14 + OptEvalScore int `json:"optEvalScore" comment:"上级是否可以修改360°综评分数"`
  15 + OptConfirmPerf int `json:"optConfirmPerf " comment:"是否需要员工确认绩效"`
  16 + CycleDeadLine *CycleDeadline `json:"cycleDeadline" comment:"周期评估各业务截止时间"`
  17 + CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
  18 + UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"`
  19 + DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
  20 +}
  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:"分"`
18 } 34 }
19 35
20 type PermissionRepository interface { 36 type PermissionRepository interface {
@@ -3,8 +3,9 @@ package domain @@ -3,8 +3,9 @@ package domain
3 import "time" 3 import "time"
4 4
5 const ( 5 const (
6 - RoleTypeCommon int = 0 // 角色类型-后台添加角色  
7 - RoleTypeSystem int = 1 // 角色类型-系统预制角色(不可删除、编辑) 6 + RoleTypeCommon int = 0 // 角色类型-添加角色
  7 + RoleTypeSystem int = 1 // 角色类型-系统预制角色HR-BP(不可删除、编辑)
  8 + RoleTypeSuperAdmin int = 2 // 角色类型-系统预制超级管理员(不可删除、编辑)
8 ) 9 )
9 10
10 type Role struct { 11 type Role struct {
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"`  
7 - Id int64 `comment:"ID" pg:"pk:id"`  
8 - CompanyId int64 `comment:"公司ID"`  
9 - OptHrScore int `comment:"上级是否可以修改人资综评分数"`  
10 - OptEvalScore int `comment:"上级是否可以修改360°综评分数"`  
11 - CreatedAt time.Time `comment:"创建时间"`  
12 - UpdatedAt time.Time `comment:"更新时间"`  
13 - DeletedAt *time.Time `comment:"删除时间"` 9 + tableName struct{} `comment:"配置权限" pg:"permission"`
  10 + Id int64 `comment:"ID" pg:"pk:id"`
  11 + CompanyId int64 `comment:"公司ID"`
  12 + OptHrScore int `comment:"上级是否可以修改人资综评分数"`
  13 + OptEvalScore int `comment:"上级是否可以修改360°综评分数"`
  14 + OptConfirmPerf int `comment:"是否需要员工确认绩效"`
  15 + CycleDeadLine *domain.CycleDeadline `comment:"周期评估各业务截止时间"`
  16 + CreatedAt time.Time `comment:"创建时间"`
  17 + UpdatedAt time.Time `comment:"更新时间"`
  18 + DeletedAt *time.Time `comment:"删除时间"`
14 } 19 }
@@ -22,25 +22,29 @@ func NewPermissionRepository(transactionContext *pgTransaction.TransactionContex @@ -22,25 +22,29 @@ func NewPermissionRepository(transactionContext *pgTransaction.TransactionContex
22 22
23 func (repo *PermissionRepository) TransformToDomain(m *models.Permission) domain.Permission { 23 func (repo *PermissionRepository) TransformToDomain(m *models.Permission) domain.Permission {
24 return domain.Permission{ 24 return domain.Permission{
25 - Id: m.Id,  
26 - CompanyId: m.CompanyId,  
27 - OptHrScore: m.OptHrScore,  
28 - OptEvalScore: m.OptEvalScore,  
29 - CreatedAt: m.CreatedAt.Local(),  
30 - UpdatedAt: m.UpdatedAt.Local(),  
31 - DeletedAt: m.DeletedAt, 25 + Id: m.Id,
  26 + CompanyId: m.CompanyId,
  27 + OptHrScore: m.OptHrScore,
  28 + OptEvalScore: m.OptEvalScore,
  29 + OptConfirmPerf: m.OptConfirmPerf,
  30 + CycleDeadLine: m.CycleDeadLine,
  31 + CreatedAt: m.CreatedAt.Local(),
  32 + UpdatedAt: m.UpdatedAt.Local(),
  33 + DeletedAt: m.DeletedAt,
32 } 34 }
33 } 35 }
34 36
35 func (repo *PermissionRepository) TransformToModel(d *domain.Permission) models.Permission { 37 func (repo *PermissionRepository) TransformToModel(d *domain.Permission) models.Permission {
36 return models.Permission{ 38 return models.Permission{
37 - Id: d.Id,  
38 - CompanyId: d.CompanyId,  
39 - OptHrScore: d.OptHrScore,  
40 - OptEvalScore: d.OptEvalScore,  
41 - CreatedAt: d.CreatedAt,  
42 - UpdatedAt: d.UpdatedAt,  
43 - DeletedAt: d.DeletedAt, 39 + Id: d.Id,
  40 + CompanyId: d.CompanyId,
  41 + OptHrScore: d.OptHrScore,
  42 + OptEvalScore: d.OptEvalScore,
  43 + OptConfirmPerf: d.OptConfirmPerf,
  44 + CycleDeadLine: d.CycleDeadLine,
  45 + CreatedAt: d.CreatedAt,
  46 + UpdatedAt: d.UpdatedAt,
  47 + DeletedAt: d.DeletedAt,
44 } 48 }
45 } 49 }
46 50
  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 +