|
|
@@ -1,6 +1,8 @@
|
|
|
package com.hr.service.impl;
|
|
|
|
|
|
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import com.google.common.cache.Cache;
|
|
|
import com.google.common.cache.CacheBuilder;
|
|
|
import com.hr.dto.AggregateQueryDTO;
|
|
|
@@ -21,6 +23,8 @@ import com.hr.util.SnowflakeIdWorker;
|
|
|
import com.hr.vo.AccountInterfaceVO;
|
|
|
import com.hr.vo.IpAccountVO;
|
|
|
import com.hr.vo.IpTokenInterfaceVO;
|
|
|
+import com.yy.basedevelop.common.data.BasePageResult;
|
|
|
+import com.yy.basedevelop.common.util.ruoyi.utils.DateUtils;
|
|
|
import com.yy.basedevelop.dto.LoginUser;
|
|
|
import jakarta.persistence.criteria.Predicate;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
@@ -30,7 +34,6 @@ import org.springframework.data.domain.*;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -121,26 +124,19 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<AccountInterfaceVO> accountInterfaceList(AccountInterfaceParam pageParam) {
|
|
|
+ public BasePageResult<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(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();
|
|
|
-
|
|
|
+ List<String> statusList = Arrays.asList("normal", "disable");
|
|
|
+ if(StringUtils.isNotEmpty(pageParam.getStatus())){
|
|
|
+ statusList = Arrays.asList(pageParam.getStatus());
|
|
|
+ }
|
|
|
+ PageHelper.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
|
+ BasePageResult<IpTokenInterfacePO> content = ipTokenInterfaceRepository.queryList(pageParam.getAid(),statusList);
|
|
|
List<Long> tokenIdList = new ArrayList<>();
|
|
|
List<Long> interfaceIdList = new ArrayList<>();
|
|
|
for (IpTokenInterfacePO interfacePO : content) {
|
|
|
@@ -184,8 +180,7 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
vo.setCallbackUrl(item.getCallbackUrl());
|
|
|
return vo;
|
|
|
}).toList();
|
|
|
- Page<AccountInterfaceVO> resultPage = new PageImpl(resultList);
|
|
|
- BeanUtils.copyProperties(result, resultPage);
|
|
|
+ BasePageResult<AccountInterfaceVO> resultPage = new BasePageResult<>(resultList,content.getTotal(),content.getPage(), content.getPageSize());
|
|
|
return resultPage;
|
|
|
|
|
|
}
|
|
|
@@ -231,13 +226,13 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
IpTokenPO ipTokenPO = ipTokenRepository.findById(tid).get();
|
|
|
ipTokenPO.setUpdateUserId(user.getUserid());
|
|
|
ipTokenPO.setUpdateUserName(user.getUsername());
|
|
|
- ipTokenPO.setUpdateTime(LocalDateTime.now());
|
|
|
+ ipTokenPO.setUpdateTime(new Date());
|
|
|
ipTokenPO.setStatus("delete");
|
|
|
ipTokenRepository.save(ipTokenPO);
|
|
|
|
|
|
ipTokenInterfacePO.setUpdateUserId(user.getUserid());
|
|
|
ipTokenInterfacePO.setUpdateUserName(user.getUsername());
|
|
|
- ipTokenInterfacePO.setUpdateTime(LocalDateTime.now());
|
|
|
+ ipTokenInterfacePO.setUpdateTime(new Date());
|
|
|
ipTokenInterfacePO.setStatus("delete");
|
|
|
ipTokenInterfaceRepository.save(ipTokenInterfacePO);
|
|
|
|
|
|
@@ -247,9 +242,10 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
public void interfaceConfig(InterfaceConfigParam param, LoginUser user) {
|
|
|
String token = param.getToken();
|
|
|
Long id = param.getId();
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
+ Date now = new Date();
|
|
|
IpTokenInterfacePO ipTokenInterfacePO;
|
|
|
IpTokenPO ipTokenPO;
|
|
|
+ // 校验唯一性
|
|
|
if(id != null){
|
|
|
ipTokenInterfacePO = ipTokenInterfaceRepository.findById(param.getId()).get();
|
|
|
ipTokenPO = ipTokenRepository.findById(ipTokenInterfacePO.getTid()).get();
|
|
|
@@ -261,12 +257,17 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
throw new RuntimeException("参数异常");
|
|
|
}
|
|
|
}else{
|
|
|
+ IpTokenInterfacePO ipTokenInterfacePO1 = ipTokenInterfaceRepository.findByAidAndIid(param.getAccountId(), param.getInterfaceId());
|
|
|
+ if(ipTokenInterfacePO1 != null){
|
|
|
+ throw new RuntimeException("该账号下已存在对应接口");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
ipTokenInterfacePO = new IpTokenInterfacePO();
|
|
|
ipTokenPO = new IpTokenPO();
|
|
|
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());
|
|
|
@@ -286,6 +287,7 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
ipTokenRepository.save(ipTokenPO);
|
|
|
ipTokenInterfacePO.setIid(param.getInterfaceId());
|
|
|
ipTokenInterfacePO.setUpdateTime(now);
|
|
|
+ ipTokenInterfacePO.setStatus(param.getStatus());
|
|
|
ipTokenInterfacePO.setUpdateUserName(user.getUsername());
|
|
|
ipTokenInterfacePO.setUpdateUserId(user.getUserid());
|
|
|
ipTokenInterfacePO.setCallbackNum(param.getCallbackNum() == null ? 0 : param.getCallbackNum());
|