|
|
@@ -1,24 +1,31 @@
|
|
|
-package com.hr.repository.service.impl;
|
|
|
+package com.hr.service.impl;
|
|
|
|
|
|
import com.hr.dto.AggregateQueryDTO;
|
|
|
+import com.hr.param.AccountInterfaceParam;
|
|
|
import com.hr.param.InterfaceConfigParam;
|
|
|
+import com.hr.repository.domain.IpAccountPO;
|
|
|
+import com.hr.repository.domain.IpInterfacePO;
|
|
|
import com.hr.repository.domain.IpTokenInterfacePO;
|
|
|
import com.hr.repository.domain.IpTokenPO;
|
|
|
+import com.hr.repository.jpa.IpInterfaceRepository;
|
|
|
import com.hr.repository.jpa.IpTokenInterfaceRepository;
|
|
|
import com.hr.repository.jpa.IpTokenRepository;
|
|
|
-import com.hr.repository.service.IpTokenInterfaceService;
|
|
|
+import com.hr.service.IpTokenInterfaceService;
|
|
|
import com.hr.util.SnowflakeIdWorker;
|
|
|
+import com.hr.vo.AccountInterfaceVO;
|
|
|
+import com.hr.vo.IpAccountVO;
|
|
|
import com.hr.vo.IpTokenInterfaceVO;
|
|
|
import com.yy.basedevelop.dto.LoginUser;
|
|
|
-import org.springdoc.core.converters.FileSupportConverter;
|
|
|
+import jakarta.persistence.criteria.Predicate;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.*;
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* token与接口关系表;(ip_token_interface)表服务接口实现类
|
|
|
@@ -32,9 +39,7 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
@Autowired
|
|
|
private IpTokenRepository ipTokenRepository;
|
|
|
@Autowired
|
|
|
- private IpTokenInterfaceService ipTokenInterfaceService;
|
|
|
- @Autowired
|
|
|
- private FileSupportConverter fileSupportConverter;
|
|
|
+ private IpInterfaceRepository ipInterfaceRepository;
|
|
|
|
|
|
/**
|
|
|
* 通过ID查询单条数据
|
|
|
@@ -84,6 +89,66 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Page<AccountInterfaceVO> accountInterfaceList(AccountInterfaceParam pageParam) {
|
|
|
+ ExampleMatcher matcher = ExampleMatcher.matchingAll()
|
|
|
+ .withIgnoreNullValues() // 忽略 null 字段
|
|
|
+ .withMatcher("aid", ExampleMatcher.GenericPropertyMatchers.exact())
|
|
|
+ .withMatcher("status", ExampleMatcher.GenericPropertyMatchers.exact())
|
|
|
+ .withIgnoreCase();
|
|
|
+ IpTokenInterfacePO po = new IpTokenInterfacePO();
|
|
|
+ po.setStatus("normal");
|
|
|
+ Pageable pageAble = PageRequest.of(pageParam.getPageNum(), pageParam.getPageSize());
|
|
|
+ Example<IpTokenInterfacePO> example = Example.of(po, matcher);
|
|
|
+ Page<IpTokenInterfacePO> result = ipTokenInterfaceRepository.findAll(example, pageAble);
|
|
|
+ List<IpTokenInterfacePO> content = result.getContent();
|
|
|
+
|
|
|
+ List<Long> tokenIdList = new ArrayList<>();
|
|
|
+ List<Long> interfaceIdList = new ArrayList<>();
|
|
|
+ for (IpTokenInterfacePO interfacePO : content) {
|
|
|
+ tokenIdList.add(interfacePO.getTid());
|
|
|
+ interfaceIdList.add(interfacePO.getIid());
|
|
|
+ }
|
|
|
+ Map<Long, IpTokenPO> tokenMap = new HashMap<>();
|
|
|
+ Map<Long, IpInterfacePO> interfaceMap = new HashMap<>();
|
|
|
+ if(!tokenIdList.isEmpty()){
|
|
|
+ Specification<IpTokenPO> spec = (root, query, cb) -> {
|
|
|
+ return root.get("id").in(tokenIdList);
|
|
|
+ };
|
|
|
+ List<IpTokenPO> ipTokenList = ipTokenRepository.findAll(spec);
|
|
|
+ for (IpTokenPO ipTokenPO : ipTokenList) {
|
|
|
+ tokenMap.put(ipTokenPO.getId(), ipTokenPO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(!interfaceIdList.isEmpty()){
|
|
|
+ Specification<IpInterfacePO> spec = (root, query, cb) -> {
|
|
|
+ return root.get("id").in(interfaceIdList);
|
|
|
+ };
|
|
|
+ List<IpInterfacePO> ipInterfacePOList = ipInterfaceRepository.findAll(spec);
|
|
|
+ for (IpInterfacePO interfacePO : ipInterfacePOList) {
|
|
|
+ interfaceMap.put(interfacePO.getId(), interfacePO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<AccountInterfaceVO> resultList = content.stream().map(item -> {
|
|
|
+ AccountInterfaceVO vo = new AccountInterfaceVO();
|
|
|
+ BeanUtils.copyProperties(item, vo);
|
|
|
+ IpTokenPO ipTokenPO = tokenMap.get(item.getTid());
|
|
|
+ vo.setSecret(ipTokenPO.getSecret());
|
|
|
+ vo.setRemark(ipTokenPO.getRemark());
|
|
|
+ IpInterfacePO ipInterfacePO = interfaceMap.get(item.getIid());
|
|
|
+ vo.setInterfaceCode(ipInterfacePO.getInterfaceNo());
|
|
|
+ vo.setInterfaceName(ipInterfacePO.getInterfaceName());
|
|
|
+ vo.setManufacturer(ipInterfacePO.getManufacturer());
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ Page<AccountInterfaceVO> resultPage = new PageImpl(resultList);
|
|
|
+ BeanUtils.copyProperties(result, resultPage);
|
|
|
+ return resultPage;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public AggregateQueryDTO queryConfigByInterfaceCodeAndAccountNo(Long accountId, Long interfaceId) {
|
|
|
AggregateQueryDTO resultDTO = new AggregateQueryDTO();
|
|
|
@@ -108,15 +173,26 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void delAccountInterface(Long id) {
|
|
|
+ public void delAccountInterface(Long id, LoginUser user) {
|
|
|
Optional<IpTokenInterfacePO> ipTokenInterfacePOOptional = ipTokenInterfaceRepository.findById(id);
|
|
|
if(!ipTokenInterfacePOOptional.isPresent()){
|
|
|
throw new RuntimeException("参数异常");
|
|
|
}
|
|
|
IpTokenInterfacePO ipTokenInterfacePO = ipTokenInterfacePOOptional.get();
|
|
|
Long tid = ipTokenInterfacePO.getTid();
|
|
|
- ipTokenInterfaceRepository.deleteById(id);
|
|
|
- ipTokenRepository.deleteById(tid);
|
|
|
+ IpTokenPO ipTokenPO = ipTokenRepository.findById(tid).get();
|
|
|
+ ipTokenPO.setUpdateUserId(user.getUserid());
|
|
|
+ ipTokenPO.setUpdateUserName(user.getUsername());
|
|
|
+ ipTokenPO.setUpdateTime(LocalDateTime.now());
|
|
|
+ ipTokenPO.setStatus("delete");
|
|
|
+ ipTokenRepository.save(ipTokenPO);
|
|
|
+
|
|
|
+ ipTokenInterfacePO.setUpdateUserId(user.getUserid());
|
|
|
+ ipTokenInterfacePO.setUpdateUserName(user.getUsername());
|
|
|
+ ipTokenInterfacePO.setUpdateTime(LocalDateTime.now());
|
|
|
+ ipTokenInterfacePO.setStatus("delete");
|
|
|
+ ipTokenInterfaceRepository.save(ipTokenInterfacePO);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -142,6 +218,7 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
ipTokenInterfacePO.setAid(param.getAccountId());
|
|
|
ipTokenInterfacePO.setIid(param.getInterfaceId());
|
|
|
ipTokenInterfacePO.setAddTime(now);
|
|
|
+ ipTokenInterfacePO.setStatus("normal");
|
|
|
ipTokenInterfacePO.setAddUserId(user.getUserid());
|
|
|
ipTokenInterfacePO.setAddUserName(user.getUsername());
|
|
|
ipTokenInterfacePO.setId(SnowflakeIdWorker.nextId());
|
|
|
@@ -152,15 +229,16 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
ipTokenInterfacePO.setTid(ipTokenPO.getId());
|
|
|
}
|
|
|
ipTokenPO.setToken(token);
|
|
|
+ ipTokenPO.setSecret(param.getSecret());
|
|
|
ipTokenPO.setUpdateTime(now);
|
|
|
- ipTokenPO.setTokenStatus(param.getStatus());
|
|
|
+ ipTokenPO.setStatus(param.getStatus());
|
|
|
ipTokenPO.setUpdateUserName(user.getUsername());
|
|
|
ipTokenPO.setUpdateUserId(user.getUserid());
|
|
|
ipTokenRepository.save(ipTokenPO);
|
|
|
ipTokenInterfacePO.setUpdateTime(now);
|
|
|
ipTokenInterfacePO.setUpdateUserName(user.getUsername());
|
|
|
ipTokenInterfacePO.setUpdateUserId(user.getUserid());
|
|
|
- ipTokenInterfacePO.setCallbackNum(param.getCallbackNum());
|
|
|
+ ipTokenInterfacePO.setCallbackNum(param.getCallbackNum() == null ? 0 : param.getCallbackNum());
|
|
|
ipTokenInterfacePO.setIsCallback(param.getCallback());
|
|
|
ipTokenInterfacePO.setCallbackUrl(param.getCallbackUrl());
|
|
|
ipTokenInterfaceRepository.save(ipTokenInterfacePO);
|