正在显示
4 个修改的文件
包含
34 行增加
和
2 行删除
@@ -298,7 +298,7 @@ func (suMoneyService *SuMoneyService) ListSuMoneyById(exportSuMoneyCommand *comm | @@ -298,7 +298,7 @@ func (suMoneyService *SuMoneyService) ListSuMoneyById(exportSuMoneyCommand *comm | ||
298 | employeeRepository = value | 298 | employeeRepository = value |
299 | } | 299 | } |
300 | 300 | ||
301 | - if _, employees, err := employeeRepository.Find(tool_funs.SimpleStructToMap(exportSuMoneyCommand)); err != nil { | 301 | + if _, employees, err := employeeRepository.FindByIds(tool_funs.SimpleStructToMap(exportSuMoneyCommand)); err != nil { |
302 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 302 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
303 | } else { | 303 | } else { |
304 | if err := transactionContext.CommitTransaction(); err != nil { | 304 | if err := transactionContext.CommitTransaction(); err != nil { |
@@ -21,6 +21,7 @@ type EmployeeRepository interface { | @@ -21,6 +21,7 @@ type EmployeeRepository interface { | ||
21 | Remove(employee *Employee) (*Employee, error) | 21 | Remove(employee *Employee) (*Employee, error) |
22 | FindOne(queryOptions map[string]interface{}) (*Employee, error) | 22 | FindOne(queryOptions map[string]interface{}) (*Employee, error) |
23 | Find(queryOptions map[string]interface{}) (int64, []*Employee, error) | 23 | Find(queryOptions map[string]interface{}) (int64, []*Employee, error) |
24 | + FindByIds(queryOptions map[string]interface{}) (int64, []*Employee, error) | ||
24 | } | 25 | } |
25 | 26 | ||
26 | func (employee *Employee) Identify() interface{} { | 27 | func (employee *Employee) Identify() interface{} { |
@@ -317,7 +317,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter | @@ -317,7 +317,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter | ||
317 | queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name") | 317 | queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name") |
318 | queryWealth = queryWealth.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money") | 318 | queryWealth = queryWealth.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money") |
319 | queryWealth = queryWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC) AS ranking") | 319 | queryWealth = queryWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC) AS ranking") |
320 | - queryWealth = queryWealth.Where(`e.status = ?`, 1) | 320 | + queryWealth = queryWealth.Where(`e.status = ?`, 1) // 离职员工过滤 |
321 | queryWealth = queryWealth.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3, 6})) | 321 | queryWealth = queryWealth.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3, 6})) |
322 | if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { | 322 | if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { |
323 | queryWealth = queryWealth.Where("e.company_id = ?", companyId) | 323 | queryWealth = queryWealth.Where("e.company_id = ?", companyId) |
@@ -84,6 +84,37 @@ func (repository *EmployeeRepository) FindOne(queryOptions map[string]interface{ | @@ -84,6 +84,37 @@ func (repository *EmployeeRepository) FindOne(queryOptions map[string]interface{ | ||
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | +func (repository *EmployeeRepository) FindByIds(queryOptions map[string]interface{}) (int64, []*domain.Employee, error) { | ||
88 | + tx := repository.transactionContext.PgTx | ||
89 | + var employeeModels []*models.Employee | ||
90 | + employees := make([]*domain.Employee, 0) | ||
91 | + query := tx.Model(&employeeModels) | ||
92 | + if ids, ok := queryOptions["ids"]; ok && len(ids.([]int)) != 0 { | ||
93 | + query = query.Where("employee.uid IN (?)", pg.In(ids.([]int)) ) | ||
94 | + } | ||
95 | + if where, ok := queryOptions["where"]; ok && where.(map[string]interface{}) != nil { | ||
96 | + if personNameMatch, ok := where.(map[string]interface{})["personNameMatch"]; ok && (personNameMatch != "") { | ||
97 | + query = query.Where("employee.employee_name LIKE ?", fmt.Sprintf("%%%s%%", personNameMatch.(string))) | ||
98 | + } | ||
99 | + if companyId, ok := where.(map[string]interface{})["companyId"]; ok && companyId.(float64) != 0 { | ||
100 | + query = query.Where("employee.company_id = ?", companyId) | ||
101 | + } | ||
102 | + } | ||
103 | + query = query.Where(`employee.status = ?`, 1) | ||
104 | + if count, err := query.Order("uid DESC").SelectAndCount(); err != nil { | ||
105 | + return 0, employees, err | ||
106 | + } else { | ||
107 | + for _, employeeModel := range employeeModels { | ||
108 | + if employee, err := repository.transformPgModelToDomainModel(employeeModel); err != nil { | ||
109 | + return 0, employees, err | ||
110 | + } else { | ||
111 | + employees = append(employees, employee) | ||
112 | + } | ||
113 | + } | ||
114 | + return int64(count), employees, nil | ||
115 | + } | ||
116 | +} | ||
117 | + | ||
87 | func (repository *EmployeeRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Employee, error) { | 118 | func (repository *EmployeeRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Employee, error) { |
88 | tx := repository.transactionContext.PgTx | 119 | tx := repository.transactionContext.PgTx |
89 | var employeeModels []*models.Employee | 120 | var employeeModels []*models.Employee |
-
请 注册 或 登录 后发表评论