|
|
@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.jzg.commons.core.page.HttpResult;
|
|
|
import com.jzg.commons.entity.dto.*;
|
|
|
@@ -64,26 +65,15 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public HttpResult deleteById(String id) {
|
|
|
- boolean isExist = sysOrganizationUserLinkService.selectByOrgId(id);
|
|
|
- if (isExist){
|
|
|
- return HttpResult.error("该机构下还有用户,请先删除用户");
|
|
|
- }
|
|
|
- return sysOrganizationMapper.deleteById(id) > 1 ? HttpResult.ok("删除成功") : HttpResult.error("删除失败");
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public boolean nameExists(SysOrganizationAdd organizationAdd) {
|
|
|
LambdaQueryWrapper<SysOrganization> last = new LambdaQueryWrapper<SysOrganization>()
|
|
|
.eq(SysOrganization::getName, organizationAdd.getName())
|
|
|
- .eq(SysOrganization::getSystemCode, organizationAdd.getSystemCode())
|
|
|
- .eq(SysOrganization::getAttribute, organizationAdd.getAttribute())
|
|
|
- .eq(SysOrganization::getIsDelete, 0)
|
|
|
+ .eq(SysOrganization::getDeptId, organizationAdd.getDeptId())
|
|
|
.last("limit 1");
|
|
|
+ if (StringUtils.isNotEmpty(organizationAdd.getId())){
|
|
|
+ last.ne(SysOrganization::getId, organizationAdd.getId());
|
|
|
+ }
|
|
|
boolean exists = sysOrganizationMapper.exists(last);
|
|
|
return exists;
|
|
|
}
|
|
|
@@ -101,6 +91,11 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
|
|
|
|
|
|
@Override
|
|
|
public HttpResult addTeamUsers(SysOrganizationUserLinkAdd organizationUserLinkAdd) {
|
|
|
+
|
|
|
+ SysOrganizationUserLink userLink = sysOrganizationUserLinkService.selectByOrgIdAndUserId(organizationUserLinkAdd);
|
|
|
+ if (ObjectUtil.isNotEmpty(userLink)){
|
|
|
+ return HttpResult.error("该团队、渠道、电销组已关联该用户,请勿重复关联");
|
|
|
+ }
|
|
|
SysOrganizationUserLink organizationUserLink = new SysOrganizationUserLink();
|
|
|
BeanUtils.copyProperties(organizationUserLinkAdd, organizationUserLink);
|
|
|
return sysOrganizationUserLinkService.save(organizationUserLink) ? HttpResult.ok("添加成功") : HttpResult.error("添加失败");
|
|
|
@@ -111,19 +106,30 @@ public class SysOrganizationServiceImpl extends ServiceImpl<SysOrganizationMappe
|
|
|
SysOrganization sysOrganization = sysOrganizationMapper.selectById(setPerson.getId());
|
|
|
if (ObjectUtil.isNotEmpty(sysOrganization)){
|
|
|
sysOrganization.setManagerId(setPerson.getManagerId());
|
|
|
- return sysOrganizationMapper.updateById(sysOrganization) > 1 ? HttpResult.ok("设置成功") : HttpResult.error("设置失败");
|
|
|
+ return sysOrganizationMapper.updateById(sysOrganization) > 0 ? HttpResult.ok("设置成功") : HttpResult.error("设置失败");
|
|
|
}
|
|
|
return HttpResult.error("所选团队、渠道、电销组不存在或以删除,请刷新");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public HttpResult deleteAssociatedUsers(DeleteAssociatedUsers deleteAssociatedUsers) {
|
|
|
- boolean isDelete = sysOrganizationUserLinkService.deleteAssociatedUsers(deleteAssociatedUsers);
|
|
|
- return isDelete ? HttpResult.ok("删除成功") : HttpResult.error("删除失败");
|
|
|
+ return sysOrganizationUserLinkService.deleteAssociatedUsers(deleteAssociatedUsers);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public HttpResult getDetails(Long userId) {
|
|
|
return HttpResult.ok(sysOrganizationMapper.getDetails(userId));
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpResult updateByIdDelete(String id) {
|
|
|
+ Long idCount = sysOrganizationUserLinkService.selectByOrgIdCount(id);
|
|
|
+ if (null != idCount && idCount > 0){
|
|
|
+ return HttpResult.error("该机构下还有用户,请先删除用户");
|
|
|
+ }
|
|
|
+ LambdaUpdateWrapper<SysOrganization> updateWrapper = new LambdaUpdateWrapper<SysOrganization>()
|
|
|
+ .eq(SysOrganization::getId, id)
|
|
|
+ .set(SysOrganization::getIsDelete, 1);
|
|
|
+ return sysOrganizationMapper.update(updateWrapper) > 0 ? HttpResult.ok("删除成功") : HttpResult.error("删除失败");
|
|
|
+ }
|
|
|
}
|