|
@@ -28,10 +28,10 @@ import org.springblade.client.entity.LandDriver;
|
|
|
import org.springblade.client.land.mapper.LandDriverMapper;
|
|
import org.springblade.client.land.mapper.LandDriverMapper;
|
|
|
import org.springblade.client.land.service.ILandDriverService;
|
|
import org.springblade.client.land.service.ILandDriverService;
|
|
|
import org.springblade.client.vo.LandDriverVO;
|
|
import org.springblade.client.vo.LandDriverVO;
|
|
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
-import org.springblade.system.feign.ISysClient;
|
|
|
|
|
import org.springblade.system.user.entity.User;
|
|
import org.springblade.system.user.entity.User;
|
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -54,8 +54,6 @@ public class LandDriverServiceImpl extends ServiceImpl<LandDriverMapper, LandDri
|
|
|
|
|
|
|
|
private final IUserClient userClient;
|
|
private final IUserClient userClient;
|
|
|
|
|
|
|
|
- private final ISysClient sysClient;
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public IPage<LandDriverVO> selectLandDriverPage(IPage<LandDriverVO> page, LandDriverVO landDriver) {
|
|
public IPage<LandDriverVO> selectLandDriverPage(IPage<LandDriverVO> page, LandDriverVO landDriver) {
|
|
|
return page.setRecords(baseMapper.selectLandDriverPage(page, landDriver));
|
|
return page.setRecords(baseMapper.selectLandDriverPage(page, landDriver));
|
|
@@ -113,34 +111,40 @@ public class LandDriverServiceImpl extends ServiceImpl<LandDriverMapper, LandDri
|
|
|
@GlobalTransactional(rollbackFor = Exception.class)
|
|
@GlobalTransactional(rollbackFor = Exception.class)
|
|
|
public R createUser(LandDriver landDriver) {
|
|
public R createUser(LandDriver landDriver) {
|
|
|
LandDriver driver = baseMapper.selectById(landDriver.getId());
|
|
LandDriver driver = baseMapper.selectById(landDriver.getId());
|
|
|
- if (ObjectUtil.isEmpty(driver)) {
|
|
|
|
|
- return R.fail("操作失败");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- R<String> sysMessage;
|
|
|
|
|
- if (LandConstant.IS_ADMIN.equals(landDriver.getUserType())) {
|
|
|
|
|
- sysMessage = sysClient.getRoleIdString(AuthUtil.getTenantId(), LandConstant.DRIVER_ROLE, LandConstant.LAND_ADMIN);
|
|
|
|
|
- } else {
|
|
|
|
|
- sysMessage = sysClient.getRoleIdString(AuthUtil.getTenantId(), LandConstant.DRIVER_ROLE, LandConstant.LAND_OPERATOR);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!sysMessage.isSuccess() || sysMessage.getData() == null) {
|
|
|
|
|
- return R.fail("缺少必要角色");
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
User user = new User();
|
|
User user = new User();
|
|
|
user.setTenantId(AuthUtil.getTenantId());
|
|
user.setTenantId(AuthUtil.getTenantId());
|
|
|
user.setUserType(1);
|
|
user.setUserType(1);
|
|
|
user.setAccount(driver.getName());
|
|
user.setAccount(driver.getName());
|
|
|
- user.setPassword(LandConstant.USER_PASSWORD);
|
|
|
|
|
user.setName(driver.getName());
|
|
user.setName(driver.getName());
|
|
|
user.setRealName(driver.getName());
|
|
user.setRealName(driver.getName());
|
|
|
- user.setRoleId(sysMessage.getData());
|
|
|
|
|
|
|
+ user.setUserType(1);
|
|
|
|
|
+ user.setSex(driver.getSex());
|
|
|
|
|
+ user.setPhone(driver.getTel());
|
|
|
|
|
+ user.setRoleId(landDriver.getRoleId());
|
|
|
user.setDeptId(landDriver.getDeptId());
|
|
user.setDeptId(landDriver.getDeptId());
|
|
|
- userClient.saveUser(user);
|
|
|
|
|
|
|
|
|
|
- driver.setUserId(user.getId());
|
|
|
|
|
- baseMapper.updateById(driver);
|
|
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(driver.getUserId())) {
|
|
|
|
|
+ user.setId(driver.getUserId());
|
|
|
|
|
+ R<Boolean> result = userClient.updateUser(user);
|
|
|
|
|
+
|
|
|
|
|
+ if (!result.isSuccess()) {
|
|
|
|
|
+ throw new ServiceException(result.getMsg());
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ user.setPassword(LandConstant.USER_PASSWORD);
|
|
|
|
|
+ R<Boolean> result = userClient.saveUser(user);
|
|
|
|
|
+ if (!result.isSuccess()) {
|
|
|
|
|
+ throw new ServiceException(result.getMsg());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ R<User> userTemp = userClient.userByAccount(AuthUtil.getTenantId(), driver.getName());
|
|
|
|
|
+ if (!userTemp.isSuccess()) {
|
|
|
|
|
+ throw new ServiceException(userTemp.getMsg());
|
|
|
|
|
+ }
|
|
|
|
|
+ driver.setUserId(userTemp.getData().getId());
|
|
|
|
|
+ baseMapper.updateById(driver);
|
|
|
|
|
+ }
|
|
|
return R.success("操作成功");
|
|
return R.success("操作成功");
|
|
|
}
|
|
}
|
|
|
|
|
|