Commit 2f69b317 authored by 李健华's avatar 李健华

添加金融数据库,实现创建用户双写-异常抛出

parent a5a267c0
...@@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.Modifying; ...@@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List; import java.util.List;
...@@ -15,5 +16,4 @@ import java.util.List; ...@@ -15,5 +16,4 @@ import java.util.List;
*/ */
public interface IFinancialUserRepository extends JpaRepository<User, Long>, JpaSpecificationExecutor<User> { public interface IFinancialUserRepository extends JpaRepository<User, Long>, JpaSpecificationExecutor<User> {
} }
...@@ -162,6 +162,9 @@ public class UserRegisterServiceImpl implements IUserRegisterService { ...@@ -162,6 +162,9 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
user = userService.saveUser(user); user = userService.saveUser(user);
cn.quantgroup.xyqb.financial.entity.User financialUser = new cn.quantgroup.xyqb.financial.entity.User(); cn.quantgroup.xyqb.financial.entity.User financialUser = new cn.quantgroup.xyqb.financial.entity.User();
BeanUtils.copyProperties(user, financialUser); BeanUtils.copyProperties(user, financialUser);
if (financialUserService.findOne(user.getId())) {
throw new RuntimeException("双写失败,数据已存在--" + user.getId());
}
financialUserService.saveUser(financialUser); financialUserService.saveUser(financialUser);
userRegisterParam.setUser(user); userRegisterParam.setUser(user);
return user; return user;
......
...@@ -16,4 +16,6 @@ import java.util.Map; ...@@ -16,4 +16,6 @@ import java.util.Map;
*/ */
public interface IFinancialUserService { public interface IFinancialUserService {
User saveUser(User user); User saveUser(User user);
boolean findOne(Long id);
} }
...@@ -29,4 +29,13 @@ public class FinancialUserServiceImpl implements IFinancialUserService, IBaseCon ...@@ -29,4 +29,13 @@ public class FinancialUserServiceImpl implements IFinancialUserService, IBaseCon
public User saveUser(User user) { public User saveUser(User user) {
return financialUserRepository.saveAndFlush(user); return financialUserRepository.saveAndFlush(user);
} }
@Override
public boolean findOne(Long id) {
User user = financialUserRepository.findOne(id);
if (user != null) {
return true;
}
return false;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment