public async Task <SimpleDto <string> > Register(RegisterInputDto inputDto) { var exists = await _customerRepo.ExistAsync(t => t.Account == inputDto.Account); if (exists) { throw new BusinessException(new ErrorModel(ErrorCode.Forbidden, "该账号已经存在")); } var customer = _mapper.Map <Customer>(inputDto); customer.ID = IdGenerater.GetNextId(IdGenerater.DatacenterId, IdGenerater.WorkerId); var customerFinace = new CusFinance() { Account = customer.Account , Balance = 0 , ID = customer.ID }; await _cusManagerService.Register(customer, customerFinace); return(new SimpleDto <string> { Result = customer.ID.ToString() }); }
public async Task <AppSrvResult <SimpleDto <string> > > Register(RegisterInputDto inputDto) { var exists = await _customerRepo.ExistAsync(t => t.Account == inputDto.Account); if (exists) { return(Problem(HttpStatusCode.Forbidden, "该账号已经存在")); } var customer = _mapper.Map <Customer>(inputDto); customer.ID = IdGenerater.GetNextId(IdGenerater.DatacenterId, IdGenerater.WorkerId); var customerFinace = new CusFinance() { Account = customer.Account , Balance = 0 , ID = customer.ID }; await _cusManagerService.Register(customer, customerFinace); return(new SimpleDto <string>(customer.ID.ToString())); }
public async Task TestUowInterceptor() { var id = IdGenerater.GetNextId(IdGenerater.DatacenterId, IdGenerater.WorkerId); var customer = new Customer() { ID = id, Account = "alpha2008", Nickname = IdGenerater.GetNextId().ToString(), Realname = IdGenerater.GetNextId().ToString() }; var cusFinance = new CusFinance { Account = "alpha2008", ID = id, Balance = 0 }; /* * set session transaction isolation level repeatable read * start transaction * INSERT INTO `Customer` (`ID`, `Account`, `CreateBy`, `CreateTime`, `ModifyBy`, `ModifyTime`, `Nickname`, `Realname`) * VALUES (122339207606833152, 'alpha2008', 1600000000000, timestamp('2020-12-03 14:12:20.552579'), NULL, NULL, '1606975940001', '1606975940002') * INSERT INTO `CusFinance` (`ID`, `Account`, `Balance`, `CreateBy`, `CreateTime`, `ModifyBy`, `ModifyTime`) * VALUES (122339207606833152, 'alpha2008', 0, 1600000000000, timestamp('2020-12-03 14:12:20.756977'), NULL, NULL) * commit */ await _cusManger.Register(customer, cusFinance); bool exists = await _cusRsp.ExistAsync(c => c.ID == id); Assert.True(exists); }
public async Task Register(RegisterInputDto inputDto) { var exists = await _customerRepo.ExistAsync(t => t.Account == inputDto.Account); if (exists) { throw new BusinessException(new ErrorModel(ErrorCode.Forbidden, "该账号已经存在")); } var customer = _mapper.Map <Customer>(inputDto); customer.ID = new Snowflake(1, 1).NextId(); var customerFinace = new CusFinance() { Account = customer.Account , Balance = 0 , ID = customer.ID }; await _cusManagerService.Register(customer, customerFinace); }