作者 linmadan

修复运功idbug

@@ -14,7 +14,7 @@ type EmployeeRepository struct { @@ -14,7 +14,7 @@ type EmployeeRepository struct {
14 } 14 }
15 15
16 func (repository *EmployeeRepository) nextIdentify() (int64, error) { 16 func (repository *EmployeeRepository) nextIdentify() (int64, error) {
17 - IdWorker, err := snowflake.NewIdWorker(1) 17 + IdWorker, err := snowflake.NewIdWorker(2)
18 if err != nil { 18 if err != nil {
19 return 0, err 19 return 0, err
20 } 20 }
@@ -25,14 +25,14 @@ func (repository *EmployeeRepository) nextIdentify() (int64, error) { @@ -25,14 +25,14 @@ func (repository *EmployeeRepository) nextIdentify() (int64, error) {
25 func (repository *EmployeeRepository) Save(employee *domain.Employee) (*domain.Employee, error) { 25 func (repository *EmployeeRepository) Save(employee *domain.Employee) (*domain.Employee, error) {
26 tx := repository.transactionContext.PgTx 26 tx := repository.transactionContext.PgTx
27 if employee.Identify() == nil { 27 if employee.Identify() == nil {
28 - _, err := repository.nextIdentify() 28 + employeeId, err := repository.nextIdentify()
29 if err != nil { 29 if err != nil {
30 return employee, err 30 return employee, err
31 } 31 }
32 if _, err := tx.QueryOne( 32 if _, err := tx.QueryOne(
33 pg.Scan(&employee.EmployeeId, &employee.CompanyId, &employee.EmployeeInfo.Uid, &employee.EmployeeInfo.EmployeeName, &employee.EmployeeInfo.EmployeeAccount, &employee.EmployeeInfo.EmployeeAvatarUrl, &employee.EmployeeInfo.IsPrincipal, &employee.SuMoney, &employee.Status, pg.Array(&employee.Permissions)), 33 pg.Scan(&employee.EmployeeId, &employee.CompanyId, &employee.EmployeeInfo.Uid, &employee.EmployeeInfo.EmployeeName, &employee.EmployeeInfo.EmployeeAccount, &employee.EmployeeInfo.EmployeeAvatarUrl, &employee.EmployeeInfo.IsPrincipal, &employee.SuMoney, &employee.Status, pg.Array(&employee.Permissions)),
34 "INSERT INTO employees (id, company_id, uid, employee_name, employee_account, employee_avatar_url, is_principal, su_money, status, permissions) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, uid, employee_name, employee_account, employee_avatar_url, is_principal, su_money, status, permissions", 34 "INSERT INTO employees (id, company_id, uid, employee_name, employee_account, employee_avatar_url, is_principal, su_money, status, permissions) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, uid, employee_name, employee_account, employee_avatar_url, is_principal, su_money, status, permissions",
35 - employee.EmployeeId, employee.CompanyId, employee.EmployeeInfo.Uid, employee.EmployeeInfo.EmployeeName, employee.EmployeeInfo.EmployeeAccount, employee.EmployeeInfo.EmployeeAvatarUrl, employee.EmployeeInfo.IsPrincipal, employee.SuMoney, employee.Status, pg.Array(employee.Permissions)); err != nil { 35 + employeeId, employee.CompanyId, employee.EmployeeInfo.Uid, employee.EmployeeInfo.EmployeeName, employee.EmployeeInfo.EmployeeAccount, employee.EmployeeInfo.EmployeeAvatarUrl, employee.EmployeeInfo.IsPrincipal, employee.SuMoney, employee.Status, pg.Array(employee.Permissions)); err != nil {
36 return employee, err 36 return employee, err
37 } 37 }
38 } else { 38 } else {