作者 tangxvhui

修复一些问题

... ... @@ -59,12 +59,12 @@ func (srv *SummaryEvaluationService) GetExecutorCycleList(param *command.QueryCy
offset = (param.PageNumber - 1) * param.PageSize
}
cycleData, err := evaluationDao.GetExecutorCycleList(param.UserId, offset, limit, isHrbp)
cycleData, err := evaluationDao.GetExecutorCycleList(param.CompanyId, param.UserId, offset, limit, isHrbp)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取周期列表"+err.Error())
}
cnt, err := evaluationDao.CountExecutorCycleList(param.UserId, domain.EvaluationSelf)
cnt, err := evaluationDao.CountExecutorCycleList(param.CompanyId, param.UserId, isHrbp)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -5,11 +5,24 @@ import "testing"
func TestGenerateToken(t *testing.T) {
ut := UserAuth{
CompanyId: 8,
UserId: 3422174102828544,
Phone: "17708397664",
UserId: 3435675157551872,
Phone: "18060823798",
PlatformId: 29,
AdminType: 1,
}
tk, _ := ut.CreateAccessToken()
t.Log(tk)
}
func TestParsetToken1(t *testing.T) {
ut := UserAuth{}
str := `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjM0MjE4NDc3MjcyOTYwMDAsImNvbXBhbnlJZCI6MTAsImNvbXBhbnlOYW1lIjoi5aSp6IGU5L-h5oGv56eR5oqA5pyJ6ZmQ5YWs5Y-4IiwicGhvbmUiOiIxNTY1OTM3NTk0MCIsInBsYXRmb3JtSWQiOjI5LCJuYW1lIjoi5bq35Lyf5Y2OIiwiYWRtaW5UeXBlIjoxfQ.v4qNLvYST03XpBdGnhYTK78A9v_k5IOdZ4r-WmDwfYg`
tk, _ := ut.ParseAccessToken(str)
t.Logf("%+v", tk)
}
func TestParsetToken2(t *testing.T) {
ut := UserAuth{}
str := `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjM0MjYxMDAxMTcwOTM4ODgsImNvbXBhbnlJZCI6MSwiY29tcGFueU5hbWUiOiLnpo_lt57ntKDlpKnkuIvpo5_lk4HmnInpmZDlhazlj7giLCJwaG9uZSI6IjE1NjU5Mzc1OTQwIiwicGxhdGZvcm1JZCI6MjksIm5hbWUiOiLlurfkvJ_ljY4iLCJhZG1pblR5cGUiOjF9.BwJ2mLdTlFKF322y4GeqPOW6wKroIrPSI8eNyuQEMkQ`
tk, _ := ut.ParseAccessToken(str)
t.Logf("%+v", tk)
}
... ...
... ... @@ -5,7 +5,6 @@ import (
"github.com/go-pg/pg/v10"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
type SummaryEvaluationDao struct {
... ... @@ -31,7 +30,7 @@ type ExecutorCycle struct {
// GetExecutorCycleList 获取执行人拥有的周期列表
// executorId 执行人id
// offset,limit 分页
func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int, limit int, isHrbp bool) ([]ExecutorCycle, error) {
func (d *SummaryEvaluationDao) GetExecutorCycleList(companyId int, executorId int, offset int, limit int, isHrbp bool) ([]ExecutorCycle, error) {
sqlStr := `select
distinct on(
summary_evaluation.cycle_id ,
... ... @@ -40,14 +39,16 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int,
summary_evaluation.cycle_id ,
summary_evaluation.cycle_name
from summary_evaluation
where summary_evaluation.executor ->>'userId'='?'
where summary_evaluation.company_id=?
`
tx := d.transactionContext.PgTx
condition := []interface{}{
executorId,
companyId, executorId,
}
if isHrbp {
sqlStr += ` or summary_evaluation."types"=4 `
sqlStr += ` and (summary_evaluation.executor ->>'userId'='?' or summary_evaluation."types"=4 ) `
} else {
sqlStr += ` and (summary_evaluation.executor ->>'userId'='?') `
}
condition = append(condition, offset, limit)
... ... @@ -58,22 +59,22 @@ func (d *SummaryEvaluationDao) GetExecutorCycleList(executorId int, offset int,
}
// CountExecutorCycleList 统计执行人拥有的周期列表
func (d *SummaryEvaluationDao) CountExecutorCycleList(executorId int, evaluationType domain.EvaluationType) (int, error) {
func (d *SummaryEvaluationDao) CountExecutorCycleList(companyId int, executorId int, isHrbp bool) (int, error) {
sqlStr := `select count(
distinct summary_evaluation.cycle_id
) as cnt
from summary_evaluation
where summary_evaluation.executor ->>'userId'='?' `
where summary_evaluation.company_id=? `
tx := d.transactionContext.PgTx
condition := []interface{}{
executorId,
companyId, executorId,
}
if evaluationType > 0 {
sqlStr += ` and summary_evaluation."types"=? `
condition = append(condition, int(evaluationType))
if isHrbp {
sqlStr += ` and (summary_evaluation.executor ->>'userId'='?' or summary_evaluation."types"=4 ) `
} else {
sqlStr += ` and (summary_evaluation.executor ->>'userId'='?') `
}
var cnt int
_, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
return cnt, err
... ...