|
|
@@ -1,17 +1,21 @@
|
|
|
package com.hr.service.impl;
|
|
|
|
|
|
+import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
|
|
|
import com.google.common.cache.Cache;
|
|
|
import com.google.common.cache.CacheBuilder;
|
|
|
import com.hr.dto.AggregateQueryDTO;
|
|
|
import com.hr.param.AccountInterfaceParam;
|
|
|
import com.hr.param.InterfaceConfigParam;
|
|
|
+import com.hr.param.SwitchStatusParam;
|
|
|
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.IpAccountRepository;
|
|
|
import com.hr.repository.jpa.IpInterfaceRepository;
|
|
|
import com.hr.repository.jpa.IpTokenInterfaceRepository;
|
|
|
import com.hr.repository.jpa.IpTokenRepository;
|
|
|
+import com.hr.service.IpAccountService;
|
|
|
import com.hr.service.IpTokenInterfaceService;
|
|
|
import com.hr.util.SnowflakeIdWorker;
|
|
|
import com.hr.vo.AccountInterfaceVO;
|
|
|
@@ -19,6 +23,7 @@ import com.hr.vo.IpAccountVO;
|
|
|
import com.hr.vo.IpTokenInterfaceVO;
|
|
|
import com.yy.basedevelop.dto.LoginUser;
|
|
|
import jakarta.persistence.criteria.Predicate;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.*;
|
|
|
@@ -47,6 +52,12 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
private static final Cache<String, AggregateQueryDTO> QUERY_CACHE = CacheBuilder.newBuilder()
|
|
|
.expireAfterWrite(100, TimeUnit.SECONDS)
|
|
|
.build();
|
|
|
+ @Autowired
|
|
|
+ private IpAccountService ipAccountService;
|
|
|
+ @Autowired
|
|
|
+ private IpAccountRepository ipAccountRepository;
|
|
|
+ @Autowired
|
|
|
+ private ParameterNamesModule parameterNamesModule;
|
|
|
|
|
|
/**
|
|
|
* 通过ID查询单条数据
|
|
|
@@ -96,16 +107,36 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean switchStatus(SwitchStatusParam switchStatusParam) {
|
|
|
+ Optional<IpTokenInterfacePO> optional = ipTokenInterfaceRepository.findById(switchStatusParam.getId());
|
|
|
+ if(!optional.isPresent()){
|
|
|
+ throw new RuntimeException("记录不存在");
|
|
|
+ }
|
|
|
+ IpTokenInterfacePO ipTokenInterfacePO = optional.get();
|
|
|
+
|
|
|
+ ipTokenInterfacePO.setStatus(switchStatusParam.getStatus());
|
|
|
+ ipTokenInterfaceRepository.save(ipTokenInterfacePO);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Page<AccountInterfaceVO> accountInterfaceList(AccountInterfaceParam pageParam) {
|
|
|
+ if(!StringUtils.isEmpty(pageParam.getAccNo())){
|
|
|
+ IpAccountPO accountPO = ipAccountRepository.findByAccNo(pageParam.getAccNo());
|
|
|
+ if(accountPO != null){
|
|
|
+ pageParam.setAid(accountPO.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
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());
|
|
|
+ po.setStatus(pageParam.getStatus());
|
|
|
+ po.setAid(pageParam.getAid());
|
|
|
+ Pageable pageAble = PageRequest.of(pageParam.getPageNum() -1, pageParam.getPageSize());
|
|
|
Example<IpTokenInterfacePO> example = Example.of(po, matcher);
|
|
|
Page<IpTokenInterfacePO> result = ipTokenInterfaceRepository.findAll(example, pageAble);
|
|
|
List<IpTokenInterfacePO> content = result.getContent();
|
|
|
@@ -128,7 +159,6 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if(!interfaceIdList.isEmpty()){
|
|
|
Specification<IpInterfacePO> spec = (root, query, cb) -> {
|
|
|
return root.get("id").in(interfaceIdList);
|
|
|
@@ -143,11 +173,15 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
BeanUtils.copyProperties(item, vo);
|
|
|
IpTokenPO ipTokenPO = tokenMap.get(item.getTid());
|
|
|
vo.setSecret(ipTokenPO.getSecret());
|
|
|
+ vo.setToken(ipTokenPO.getToken());
|
|
|
vo.setRemark(ipTokenPO.getRemark());
|
|
|
IpInterfacePO ipInterfacePO = interfaceMap.get(item.getIid());
|
|
|
vo.setInterfaceCode(ipInterfacePO.getInterfaceNo());
|
|
|
vo.setInterfaceName(ipInterfacePO.getInterfaceName());
|
|
|
+ vo.setInterfaceId(ipInterfacePO.getId());
|
|
|
vo.setManufacturer(ipInterfacePO.getManufacturer());
|
|
|
+ vo.setCallback(item.getIsCallback());
|
|
|
+ vo.setCallbackUrl(item.getCallbackUrl());
|
|
|
return vo;
|
|
|
}).toList();
|
|
|
Page<AccountInterfaceVO> resultPage = new PageImpl(resultList);
|
|
|
@@ -242,6 +276,7 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
ipTokenPO.setId(SnowflakeIdWorker.nextId());
|
|
|
ipTokenInterfacePO.setTid(ipTokenPO.getId());
|
|
|
}
|
|
|
+ ipTokenPO.setRemark(param.getRemark());
|
|
|
ipTokenPO.setToken(token);
|
|
|
ipTokenPO.setSecret(param.getSecret());
|
|
|
ipTokenPO.setUpdateTime(now);
|
|
|
@@ -249,6 +284,7 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
ipTokenPO.setUpdateUserName(user.getUsername());
|
|
|
ipTokenPO.setUpdateUserId(user.getUserid());
|
|
|
ipTokenRepository.save(ipTokenPO);
|
|
|
+ ipTokenInterfacePO.setIid(param.getInterfaceId());
|
|
|
ipTokenInterfacePO.setUpdateTime(now);
|
|
|
ipTokenInterfacePO.setUpdateUserName(user.getUsername());
|
|
|
ipTokenInterfacePO.setUpdateUserId(user.getUserid());
|