作者 tangxvhui

修复一些问题

@@ -59,12 +59,12 @@ func (srv *SummaryEvaluationService) GetExecutorCycleList(param *command.QueryCy @@ -59,12 +59,12 @@ func (srv *SummaryEvaluationService) GetExecutorCycleList(param *command.QueryCy
59 offset = (param.PageNumber - 1) * param.PageSize 59 offset = (param.PageNumber - 1) * param.PageSize
60 } 60 }
61 61
62 - cycleData, err := evaluationDao.GetExecutorCycleList(param.UserId, offset, limit, isHrbp) 62 + cycleData, err := evaluationDao.GetExecutorCycleList(param.CompanyId, param.UserId, offset, limit, isHrbp)
63 if err != nil { 63 if err != nil {
64 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取周期列表"+err.Error()) 64 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取周期列表"+err.Error())
65 } 65 }
66 66
67 - cnt, err := evaluationDao.CountExecutorCycleList(param.UserId, domain.EvaluationSelf) 67 + cnt, err := evaluationDao.CountExecutorCycleList(param.CompanyId, param.UserId, isHrbp)
68 if err != nil { 68 if err != nil {
69 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 69 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
70 } 70 }
@@ -5,11 +5,24 @@ import "testing" @@ -5,11 +5,24 @@ import "testing"
5 func TestGenerateToken(t *testing.T) { 5 func TestGenerateToken(t *testing.T) {
6 ut := UserAuth{ 6 ut := UserAuth{
7 CompanyId: 8, 7 CompanyId: 8,
8 - UserId: 3422174102828544,  
9 - Phone: "17708397664", 8 + UserId: 3435675157551872,
  9 + Phone: "18060823798",
10 PlatformId: 29, 10 PlatformId: 29,
11 AdminType: 1, 11 AdminType: 1,
12 } 12 }
13 tk, _ := ut.CreateAccessToken() 13 tk, _ := ut.CreateAccessToken()
14 t.Log(tk) 14 t.Log(tk)
15 } 15 }
  16 +
  17 +func TestParsetToken1(t *testing.T) {
  18 + ut := UserAuth{}
  19 + str := `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjM0MjE4NDc3MjcyOTYwMDAsImNvbXBhbnlJZCI6MTAsImNvbXBhbnlOYW1lIjoi5aSp6IGU5L-h5oGv56eR5oqA5pyJ6ZmQ5YWs5Y-4IiwicGhvbmUiOiIxNTY1OTM3NTk0MCIsInBsYXRmb3JtSWQiOjI5LCJuYW1lIjoi5bq35Lyf5Y2OIiwiYWRtaW5UeXBlIjoxfQ.v4qNLvYST03XpBdGnhYTK78A9v_k5IOdZ4r-WmDwfYg`
  20 + tk, _ := ut.ParseAccessToken(str)
  21 + t.Logf("%+v", tk)
  22 +}
  23 +func TestParsetToken2(t *testing.T) {
  24 + ut := UserAuth{}
  25 + str := `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjM0MjYxMDAxMTcwOTM4ODgsImNvbXBhbnlJZCI6MSwiY29tcGFueU5hbWUiOiLnpo_lt57ntKDlpKnkuIvpo5_lk4HmnInpmZDlhazlj7giLCJwaG9uZSI6IjE1NjU5Mzc1OTQwIiwicGxhdGZvcm1JZCI6MjksIm5hbWUiOiLlurfkvJ_ljY4iLCJhZG1pblR5cGUiOjF9.BwJ2mLdTlFKF322y4GeqPOW6wKroIrPSI8eNyuQEMkQ`
  26 + tk, _ := ut.ParseAccessToken(str)
  27 + t.Logf("%+v", tk)
  28 +}
@@ -5,7 +5,6 @@ import ( @@ -5,7 +5,6 @@ import (
5 5
6 "github.com/go-pg/pg/v10" 6 "github.com/go-pg/pg/v10"
7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
8 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"  
9 ) 8 )
10 9
11 type SummaryEvaluationDao struct { 10 type SummaryEvaluationDao struct {
@@ -31,7 +30,7 @@ type ExecutorCycle struct { @@ -31,7 +30,7 @@ type ExecutorCycle struct {
31 // GetExecutorCycleList 获取执行人拥有的周期列表 30 // GetExecutorCycleList 获取执行人拥有的周期列表
32 // executorId 执行人id 31 // executorId 执行人id
33 // offset,limit 分页 32 // offset,limit 分页
34 -func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, limit int, isHrbp bool) ([]ExecutorCycle, error) { 33 +func (d *SummaryEvaluationDao) GetExecutorCycleList(companyId int, executorId int, offset int, limit int, isHrbp bool) ([]ExecutorCycle, error) {
35 sqlStr := `select 34 sqlStr := `select
36 distinct on( 35 distinct on(
37 summary_evaluation.cycle_id , 36 summary_evaluation.cycle_id ,
@@ -40,14 +39,16 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, @@ -40,14 +39,16 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int,
40 summary_evaluation.cycle_id , 39 summary_evaluation.cycle_id ,
41 summary_evaluation.cycle_name 40 summary_evaluation.cycle_name
42 from summary_evaluation 41 from summary_evaluation
43 - where summary_evaluation.executor ->>'userId'='?' 42 + where summary_evaluation.company_id=?
44 ` 43 `
45 tx := d.transactionContext.PgTx 44 tx := d.transactionContext.PgTx
46 condition := []interface{}{ 45 condition := []interface{}{
47 - executorId, 46 + companyId, executorId,
48 } 47 }
49 if isHrbp { 48 if isHrbp {
50 - sqlStr += ` or summary_evaluation."types"=4 ` 49 + sqlStr += ` and (summary_evaluation.executor ->>'userId'='?' or summary_evaluation."types"=4 ) `
  50 + } else {
  51 + sqlStr += ` and (summary_evaluation.executor ->>'userId'='?') `
51 } 52 }
52 condition = append(condition, offset, limit) 53 condition = append(condition, offset, limit)
53 54
@@ -58,22 +59,22 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, @@ -58,22 +59,22 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int,
58 } 59 }
59 60
60 // CountExecutorCycleList 统计执行人拥有的周期列表 61 // CountExecutorCycleList 统计执行人拥有的周期列表
61 -func (d *SummaryEvaluationDao) CountExecutorCycleList(executorId int, evaluationType domain.EvaluationType) (int, error) { 62 +func (d *SummaryEvaluationDao) CountExecutorCycleList(companyId int, executorId int, isHrbp bool) (int, error) {
62 sqlStr := `select count( 63 sqlStr := `select count(
63 distinct summary_evaluation.cycle_id 64 distinct summary_evaluation.cycle_id
64 ) as cnt 65 ) as cnt
65 from summary_evaluation 66 from summary_evaluation
66 - where summary_evaluation.executor ->>'userId'='?' ` 67 + where summary_evaluation.company_id=? `
67 68
68 tx := d.transactionContext.PgTx 69 tx := d.transactionContext.PgTx
69 condition := []interface{}{ 70 condition := []interface{}{
70 - executorId, 71 + companyId, executorId,
71 } 72 }
72 - if evaluationType > 0 {  
73 - sqlStr += ` and summary_evaluation."types"=? `  
74 - condition = append(condition, int(evaluationType)) 73 + if isHrbp {
  74 + sqlStr += ` and (summary_evaluation.executor ->>'userId'='?' or summary_evaluation."types"=4 ) `
  75 + } else {
  76 + sqlStr += ` and (summary_evaluation.executor ->>'userId'='?') `
75 } 77 }
76 -  
77 var cnt int 78 var cnt int
78 _, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...) 79 _, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
79 return cnt, err 80 return cnt, err