Commit 1e5f66e9 by guojuxing

新增用户事务代码修改

parent f7e42df6
......@@ -8,13 +8,13 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.dto.UserResourceDTO;
import com.gic.auth.dto.UserRoleDTO;
import com.gic.auth.entity.TabSysUser;
import com.gic.auth.exception.AuthException;
import com.gic.auth.service.*;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.error.ErrorCode;
......@@ -49,6 +49,9 @@ public class UserApiServiceImpl implements UserApiService {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "手机号码不能重复");
}
if (StringUtils.isBlank(userDTO.getPhoneAreaCode())) {
userDTO.setPhoneAreaCode("86");
}
userDTO.setCreateTime(new Date());
userDTO.setUpdateTime(new Date());
userDTO.setStatus(1);
......@@ -60,7 +63,8 @@ public class UserApiServiceImpl implements UserApiService {
return response;
} else {
//事物回滚
throw new AuthException(response);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return response;
}
}
......@@ -79,16 +83,20 @@ public class UserApiServiceImpl implements UserApiService {
if (userService.isPhoneRepeat(userDTO.getUserId(), userDTO.getPhoneNumber())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "手机号码不能重复");
}
if (StringUtils.isBlank(userDTO.getPhoneAreaCode())) {
userDTO.setPhoneAreaCode("86");
}
userDTO.setUpdateTime(new Date());
userService.editUser(userDTO);
ServiceResponse<Integer> response = saveRole(userDTO.getUserId(), userDTO.getEnterpriseId(), userDTO.getUserRoleIds(),
ServiceResponse response = saveRole(userDTO.getUserId(), userDTO.getEnterpriseId(), userDTO.getUserRoleIds(),
userDTO.getUserResourceIds());
if (response.isSuccess()) {
return response;
} else {
//事物回滚
throw new AuthException(response);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return response;
}
}
......
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