作者 陈志颖

fix:修改无效员工错误描述

@@ -18,22 +18,26 @@ type OperationSuMoneyService struct { @@ -18,22 +18,26 @@ type OperationSuMoneyService struct {
18 func (service *OperationSuMoneyService) Operation(uid int64, operatorUid int64, suMoney float64, operationType int, recordDescription string) (*domain.SuMoneyTransactionRecord, error) { 18 func (service *OperationSuMoneyService) Operation(uid int64, operatorUid int64, suMoney float64, operationType int, recordDescription string) (*domain.SuMoneyTransactionRecord, error) {
19 var employeeRepository domain.EmployeeRepository 19 var employeeRepository domain.EmployeeRepository
20 var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository 20 var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository
  21 +
21 var employeeDao *dao.EmployeeDao 22 var employeeDao *dao.EmployeeDao
22 if repository, err := repository.NewEmployeeRepository(service.transactionContext); err != nil { 23 if repository, err := repository.NewEmployeeRepository(service.transactionContext); err != nil {
23 return nil, err 24 return nil, err
24 } else { 25 } else {
25 employeeRepository = repository 26 employeeRepository = repository
26 } 27 }
  28 +
27 if repository, err := repository.NewSuMoneyTransactionRecordRepository(service.transactionContext); err != nil { 29 if repository, err := repository.NewSuMoneyTransactionRecordRepository(service.transactionContext); err != nil {
28 return nil, err 30 return nil, err
29 } else { 31 } else {
30 suMoneyTransactionRecordRepository = repository 32 suMoneyTransactionRecordRepository = repository
31 } 33 }
  34 +
32 if dao, err := dao.NewEmployeeDao(service.transactionContext); err != nil { 35 if dao, err := dao.NewEmployeeDao(service.transactionContext); err != nil {
33 return nil, err 36 return nil, err
34 } else { 37 } else {
35 employeeDao = dao 38 employeeDao = dao
36 } 39 }
  40 +
37 employee, err := employeeRepository.FindOne(map[string]interface{}{ 41 employee, err := employeeRepository.FindOne(map[string]interface{}{
38 "uid": uid, 42 "uid": uid,
39 }) 43 })
@@ -74,7 +74,7 @@ func (repository *EmployeeRepository) FindOne(queryOptions map[string]interface{ @@ -74,7 +74,7 @@ func (repository *EmployeeRepository) FindOne(queryOptions map[string]interface{
74 } 74 }
75 if err := query.First(); err != nil { 75 if err := query.First(); err != nil {
76 if err.Error() == "pg: no rows in result set" { 76 if err.Error() == "pg: no rows in result set" {
77 - return nil, fmt.Errorf("没有此员工") 77 + return nil, fmt.Errorf("无效的员工")
78 } else { 78 } else {
79 return nil, err 79 return nil, err
80 } 80 }