Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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()));
        }