Selaa lähdekoodia

专家保存其它信息的标签

master
PoffyZhang 1 vuosi sitten
vanhempi
commit
856ca45ca8
2 muutettua tiedostoa jossa 44 lisäystä ja 4 poistoa
  1. +6
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/UserGuidanceController.java
  2. +38
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/UserGuidanceManage.java

+ 6
- 3
pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/UserGuidanceController.java Näytä tiedosto

@@ -9,9 +9,7 @@ import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@@ -38,4 +36,9 @@ public class UserGuidanceController {
return userGuidanceManage.detailUserGuidance(user);
}

@ApiOperation(value = "删除重复用户", notes = "删除重复用户")
@GetMapping("/remove-repeat/{userId}")
public String removeRepeat(@PathVariable Long userId) {
return userGuidanceManage.removeRepeat(userId);
}
}

+ 38
- 1
pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/UserGuidanceManage.java Näytä tiedosto

@@ -1,16 +1,24 @@
package com.ningdatech.pmapi.sys.manage;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.ningdatech.basic.function.VUtils;
import com.ningdatech.pmapi.common.constant.BizConst;
import com.ningdatech.pmapi.fiscal.entity.CompanyFiscalCode;
import com.ningdatech.pmapi.fiscal.service.ICompanyFiscalCodeService;
import com.ningdatech.pmapi.signature.entity.CompanySignature;
import com.ningdatech.pmapi.signature.service.ICompanySignatureService;
import com.ningdatech.pmapi.sys.contants.UserGuidanceContant;
import com.ningdatech.pmapi.sys.model.entity.UserRole;
import com.ningdatech.pmapi.sys.model.vo.UserGuidanceDetailVO;
import com.ningdatech.pmapi.sys.model.vo.UserGuidanceVO;
import com.ningdatech.pmapi.sys.service.IUserRoleService;
import com.ningdatech.pmapi.user.entity.UserAuth;
import com.ningdatech.pmapi.user.entity.UserInfo;
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails;
import com.ningdatech.pmapi.user.service.IUserAuthService;
import com.ningdatech.pmapi.user.service.IUserInfoService;
import com.wflow.bean.entity.WflowOrgModels;
import com.wflow.enums.ProcessDefTypeEnum;
import com.wflow.service.OrgProcdefService;
@@ -21,6 +29,7 @@ import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
* @Classname UserGuidanceManage
@@ -35,7 +44,11 @@ public class UserGuidanceManage {

private final OrgProcdefService orgProcdefService;

private final ICompanyFiscalCodeService fiscalCodeService;
private final IUserInfoService userInfoService;

private final IUserRoleService userRoleService;

private final IUserAuthService userAuthService;

private final ICompanySignatureService signatureService;

@@ -111,4 +124,28 @@ public class UserGuidanceManage {
vo.setDetails(details);
return vo;
}

/**
* 删除重复用户
* @param userId
* @return
*/
public String removeRepeat(Long userId) {
UserInfo user = userInfoService.getById(userId);
VUtils.isTrue(Objects.isNull(user)).throwMessage("该用户不存在 删除重复失败");
List<UserInfo> repeatUsers = userInfoService.list(Wrappers.lambdaQuery(UserInfo.class)
.eq(UserInfo::getUsername, user.getUsername())
.ne(UserInfo::getId, userId)
.isNull(UserInfo::getAccountId));
if(CollUtil.isNotEmpty(repeatUsers)){
List<Long> repeatIds = repeatUsers.stream().map(UserInfo::getId).collect(Collectors.toList());
userInfoService.removeBatchByIds(repeatIds);
userAuthService.remove(Wrappers.lambdaQuery(UserAuth.class)
.in(UserAuth::getUserId,repeatIds));
userRoleService.remove(Wrappers.lambdaQuery(UserRole.class)
.in(UserRole::getUserId,repeatIds));
return "删除成功";
}
return "不存在重复的用户";
}
}

Loading…
Peruuta
Tallenna