|
@@ -2,6 +2,8 @@ package com.ruoyi.web.work.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.exception.ServiceException;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.web.work.api.util.AppUtil;
|
|
|
import com.ruoyi.web.work.domain.Company;
|
|
|
import com.ruoyi.web.work.domain.Relate;
|
|
@@ -62,13 +64,33 @@ public class RelateServiceImpl extends ServiceImpl<RelateMapper, Relate> impleme
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
+ @Transactional()
|
|
|
@Override
|
|
|
- public boolean remove(Relate relate) {
|
|
|
- if (relateMapper.remove(relate)) {
|
|
|
- User user = userService.getById(AppUtil.getUser().getId());
|
|
|
- user.setIsCompany(user.getIsCompany() - 1);
|
|
|
- return userService.updateById(user);
|
|
|
+ public AjaxResult removeUser(Relate relate) {
|
|
|
+ relate.setCompanyId(SecurityUtils.getLoginUser().getUser().getCompanyId());
|
|
|
+ if (!relateMapper.remove(relate)) {
|
|
|
+ throw new ServiceException("解除关联失败,请联系平台");
|
|
|
}
|
|
|
- return false;
|
|
|
+ User user = userService.getById(relate.getUserId());
|
|
|
+ user.setIsCompany(user.getIsCompany() - 1);
|
|
|
+ if (!userService.updateById(user)) {
|
|
|
+ throw new ServiceException("更新用户信息失败,请联系平台");
|
|
|
+ }
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public AjaxResult remove(Relate relate) {
|
|
|
+ relate.setUserId(AppUtil.getUser().getId());
|
|
|
+ if (!relateMapper.remove(relate)) {
|
|
|
+ throw new ServiceException("解除关联失败,请联系平台");
|
|
|
+ }
|
|
|
+ User user = userService.getById(AppUtil.getUser().getId());
|
|
|
+ user.setIsCompany(user.getIsCompany() - 1);
|
|
|
+ if (!userService.updateById(user)) {
|
|
|
+ throw new ServiceException("更新用户信息失败,请联系平台");
|
|
|
+ }
|
|
|
+ return AjaxResult.success();
|
|
|
}
|
|
|
}
|