|
@@ -1,18 +1,21 @@
|
|
|
package com.hr.repository.service.impl;
|
|
package com.hr.repository.service.impl;
|
|
|
|
|
|
|
|
-import com.github.pagehelper.PageHelper;
|
|
|
|
|
-import com.github.pagehelper.PageInfo;
|
|
|
|
|
-import com.hr.repository.domain.IpLogPO;
|
|
|
|
|
|
|
+import com.hr.param.InterfaceConfigParam;
|
|
|
import com.hr.repository.domain.IpTokenInterfacePO;
|
|
import com.hr.repository.domain.IpTokenInterfacePO;
|
|
|
|
|
+import com.hr.repository.domain.IpTokenPO;
|
|
|
import com.hr.repository.jpa.IpTokenInterfaceRepository;
|
|
import com.hr.repository.jpa.IpTokenInterfaceRepository;
|
|
|
|
|
+import com.hr.repository.jpa.IpTokenRepository;
|
|
|
import com.hr.repository.service.IpTokenInterfaceService;
|
|
import com.hr.repository.service.IpTokenInterfaceService;
|
|
|
|
|
+import com.hr.util.SnowflakeIdWorker;
|
|
|
import com.hr.vo.IpTokenInterfaceVO;
|
|
import com.hr.vo.IpTokenInterfaceVO;
|
|
|
|
|
+import com.yy.basedevelop.dto.LoginUser;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.*;
|
|
import org.springframework.data.domain.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* token与接口关系表;(ip_token_interface)表服务接口实现类
|
|
* token与接口关系表;(ip_token_interface)表服务接口实现类
|
|
@@ -23,7 +26,11 @@ import java.util.List;
|
|
|
public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IpTokenInterfaceRepository ipTokenInterfaceRepository;
|
|
private IpTokenInterfaceRepository ipTokenInterfaceRepository;
|
|
|
-
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IpTokenRepository ipTokenRepository;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IpTokenInterfaceService ipTokenInterfaceService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 通过ID查询单条数据
|
|
* 通过ID查询单条数据
|
|
|
*
|
|
*
|
|
@@ -31,7 +38,7 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
* @return 实例对象
|
|
* @return 实例对象
|
|
|
*/
|
|
*/
|
|
|
public IpTokenInterfaceVO queryById(Long tiid){
|
|
public IpTokenInterfaceVO queryById(Long tiid){
|
|
|
- IpTokenInterfacePO ipTokenInterfacePO = ipTokenInterfaceRepository.queryById(tiid);
|
|
|
|
|
|
|
+ IpTokenInterfacePO ipTokenInterfacePO = ipTokenInterfaceRepository.findById(tiid).get();
|
|
|
IpTokenInterfaceVO ipTokenInterfaceVO = new IpTokenInterfaceVO();
|
|
IpTokenInterfaceVO ipTokenInterfaceVO = new IpTokenInterfaceVO();
|
|
|
if(ipTokenInterfacePO != null){
|
|
if(ipTokenInterfacePO != null){
|
|
|
BeanUtils.copyProperties(ipTokenInterfacePO, ipTokenInterfaceVO);
|
|
BeanUtils.copyProperties(ipTokenInterfacePO, ipTokenInterfaceVO);
|
|
@@ -72,7 +79,66 @@ public class IpTokenInterfaceServiceImpl implements IpTokenInterfaceService {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void delAccountInterface(Long id) {
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void interfaceConfig(InterfaceConfigParam param, LoginUser user) {
|
|
|
|
|
+ String token = param.getToken();
|
|
|
|
|
+ Long id = param.getId();
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
+ IpTokenInterfacePO ipTokenInterfacePO;
|
|
|
|
|
+ IpTokenPO ipTokenPO;
|
|
|
|
|
+ if(id != null){
|
|
|
|
|
+ ipTokenInterfacePO = ipTokenInterfaceRepository.findById(param.getId()).get();
|
|
|
|
|
+ ipTokenPO = ipTokenRepository.findById(ipTokenInterfacePO.getTid()).get();
|
|
|
|
|
+ if(ipTokenPO == null){
|
|
|
|
|
+ throw new RuntimeException("参数异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ Optional<IpTokenInterfacePO> optional = ipTokenInterfaceRepository.findById(id);
|
|
|
|
|
+ if(!optional.isPresent()){
|
|
|
|
|
+ throw new RuntimeException("参数异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ ipTokenInterfacePO = new IpTokenInterfacePO();
|
|
|
|
|
+ ipTokenPO = new IpTokenPO();
|
|
|
|
|
+ ipTokenInterfacePO.setAid(param.getAccountId());
|
|
|
|
|
+ ipTokenInterfacePO.setIid(param.getInterfaceId());
|
|
|
|
|
+ ipTokenInterfacePO.setAddTime(now);
|
|
|
|
|
+ ipTokenInterfacePO.setAddUserId(user.getUserid());
|
|
|
|
|
+ ipTokenInterfacePO.setAddUserName(user.getUsername());
|
|
|
|
|
+ ipTokenInterfacePO.setId(SnowflakeIdWorker.nextId());
|
|
|
|
|
+ ipTokenPO.setAddUserId(user.getUserid());
|
|
|
|
|
+ ipTokenPO.setAddUserName(user.getUsername());
|
|
|
|
|
+ ipTokenPO.setAid(param.getAccountId());
|
|
|
|
|
+ ipTokenPO.setId(SnowflakeIdWorker.nextId());
|
|
|
|
|
+ ipTokenInterfacePO.setTid(ipTokenPO.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ ipTokenPO.setToken(token);
|
|
|
|
|
+ ipTokenPO.setUpdateTime(now);
|
|
|
|
|
+ ipTokenPO.setTokenStatus(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.setIsCallback(param.getCallback());
|
|
|
|
|
+ ipTokenInterfacePO.setCallbackUrl(param.getCallbackUrl());
|
|
|
|
|
+ ipTokenInterfaceRepository.save(ipTokenInterfacePO);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* 通过主键删除数据
|
|
* 通过主键删除数据
|
|
|
*
|
|
*
|
|
|
* @param tiid 主键
|
|
* @param tiid 主键
|