作者 tangxvhui

更新执行人的 周期列表输出

1 package service 1 package service
2 2
3 import ( 3 import (
  4 + "strconv"
  5 +
4 "github.com/linmadan/egglib-go/core/application" 6 "github.com/linmadan/egglib-go/core/application"
5 "github.com/linmadan/egglib-go/utils/tool_funs" 7 "github.com/linmadan/egglib-go/utils/tool_funs"
6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" 8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
7 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/command" 9 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/command"
8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 10 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
9 - "strconv"  
10 ) 11 )
11 12
12 type RoleUserService struct { 13 type RoleUserService struct {
@@ -115,6 +116,8 @@ func (rs *RoleUserService) ListRole(in *command.UserRoleQueryCommand) (interface @@ -115,6 +116,8 @@ func (rs *RoleUserService) ListRole(in *command.UserRoleQueryCommand) (interface
115 } 116 }
116 117
117 // GetHRBP 当前操作人是否拥有HRBP权限 118 // GetHRBP 当前操作人是否拥有HRBP权限
  119 +// 返回 1 是 表示具有hrbp 权限
  120 +
118 func GetHRBP(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) { 121 func GetHRBP(transactionContext application.TransactionContext, companyId int, operatorId int) (int, error) {
119 roleRepo := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) 122 roleRepo := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext})
120 roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) 123 roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})
@@ -3,6 +3,7 @@ package command @@ -3,6 +3,7 @@ package command
3 // 获取周期列表 3 // 获取周期列表
4 type QueryCycleList struct { 4 type QueryCycleList struct {
5 UserId int `json:"userId,string"` 5 UserId int `json:"userId,string"`
  6 + CompanyId int `json:"-"`
6 Types int `json:"types"` 7 Types int `json:"types"`
7 PageSize int `json:"pageSize"` 8 PageSize int `json:"pageSize"`
8 PageNumber int `json:"pageNumber"` 9 PageNumber int `json:"pageNumber"`
@@ -38,6 +38,15 @@ func (srv *SummaryEvaluationService) GetExecutorCycleList(param *command.QueryCy @@ -38,6 +38,15 @@ func (srv *SummaryEvaluationService) GetExecutorCycleList(param *command.QueryCy
38 evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{ 38 evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{
39 "transactionContext": transactionContext, 39 "transactionContext": transactionContext,
40 }) 40 })
  41 +
  42 + flagHrbp, err := roleService.GetHRBP(transactionContext, param.CompanyId, param.UserId)
  43 + if err != nil {
  44 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  45 + }
  46 + var isHrbp bool
  47 + if flagHrbp == 1 {
  48 + isHrbp = true
  49 + }
41 limit := 300 50 limit := 300
42 offset := 0 51 offset := 0
43 if param.PageSize > 0 { 52 if param.PageSize > 0 {
@@ -47,7 +56,7 @@ func (srv *SummaryEvaluationService) GetExecutorCycleList(param *command.QueryCy @@ -47,7 +56,7 @@ func (srv *SummaryEvaluationService) GetExecutorCycleList(param *command.QueryCy
47 offset = (param.PageNumber - 1) * param.PageSize 56 offset = (param.PageNumber - 1) * param.PageSize
48 } 57 }
49 58
50 - cycleData, err := evaluationDao.GetExecutorCycleList(param.UserId, offset, limit, domain.EvaluationSelf) 59 + cycleData, err := evaluationDao.GetExecutorCycleList(param.UserId, offset, limit, isHrbp)
51 if err != nil { 60 if err != nil {
52 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取周期列表"+err.Error()) 61 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取周期列表"+err.Error())
53 } 62 }
@@ -237,7 +246,9 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri @@ -237,7 +246,9 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
237 } 246 }
238 } 247 }
239 menu1.Child = append(menu1.Child, menu1_1, menu1_2) 248 menu1.Child = append(menu1.Child, menu1_1, menu1_2)
240 - menuList = append(menuList, menu1) 249 + if len(selfEvaluation) > 0 {
  250 + menuList = append(menuList, menu1)
  251 + }
241 menu2 := adapter.MenuListAdapter{ 252 menu2 := adapter.MenuListAdapter{
242 CycleId: 0, 253 CycleId: 0,
243 NodeName: "给他人评估", 254 NodeName: "给他人评估",
@@ -30,7 +30,7 @@ type ExecutorCycle struct { @@ -30,7 +30,7 @@ type ExecutorCycle struct {
30 // GetExecutorCycleList 获取执行人拥有的周期列表 30 // GetExecutorCycleList 获取执行人拥有的周期列表
31 // executorId 执行人id 31 // executorId 执行人id
32 // offset,limit 分页 32 // offset,limit 分页
33 -func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, limit int, evaluationType domain.EvaluationType) ([]ExecutorCycle, error) { 33 +func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, limit int, isHrbp bool) ([]ExecutorCycle, error) {
34 sqlStr := `select 34 sqlStr := `select
35 distinct 35 distinct
36 summary_evaluation.cycle_id , 36 summary_evaluation.cycle_id ,
@@ -42,12 +42,9 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, @@ -42,12 +42,9 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int,
42 condition := []interface{}{ 42 condition := []interface{}{
43 executorId, 43 executorId,
44 } 44 }
45 -  
46 - if evaluationType > 0 {  
47 - sqlStr += ` and summary_evaluation."types"=? `  
48 - condition = append(condition, int(evaluationType)) 45 + if isHrbp {
  46 + sqlStr += ` or summary_evaluation."types"=4 `
49 } 47 }
50 -  
51 condition = append(condition, offset, limit) 48 condition = append(condition, offset, limit)
52 sqlStr += ` order by summary_evaluation.cycle_id desc offset ? limit ? ` 49 sqlStr += ` order by summary_evaluation.cycle_id desc offset ? limit ? `
53 result := []ExecutorCycle{} 50 result := []ExecutorCycle{}