作者 linmadan

修复运功idbug

... ... @@ -14,7 +14,7 @@ type EmployeeRepository struct {
}
func (repository *EmployeeRepository) nextIdentify() (int64, error) {
IdWorker, err := snowflake.NewIdWorker(1)
IdWorker, err := snowflake.NewIdWorker(2)
if err != nil {
return 0, err
}
... ... @@ -25,14 +25,14 @@ func (repository *EmployeeRepository) nextIdentify() (int64, error) {
func (repository *EmployeeRepository) Save(employee *domain.Employee) (*domain.Employee, error) {
tx := repository.transactionContext.PgTx
if employee.Identify() == nil {
_, err := repository.nextIdentify()
employeeId, err := repository.nextIdentify()
if err != nil {
return employee, err
}
if _, err := tx.QueryOne(
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)),
"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",
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 {
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 {
return employee, err
}
} else {
... ...