longhu 2 долоо хоног өмнө
parent
commit
a68a51c304

+ 4 - 8
src/main/java/com/hr/controller/IpInterfaceCallbackController.java

@@ -1,20 +1,19 @@
 package com.hr.controller;
 
 import com.hr.param.InterfaceCalledQueryParam;
-import com.hr.param.IpInterfaceParam;
-import com.hr.repository.domain.IpInterfacePO;
 import com.hr.repository.service.IpOrderService;
 import com.hr.vo.CallbackHistoryVO;
 import com.hr.vo.InterfaceCalledDetail;
 import com.hr.vo.IpInterfaceCallVO;
-import com.hr.vo.IpInterfaceVO;
 import com.yy.basedevelop.common.data.BasePageResult;
 import com.yy.basedevelop.common.data.BaseReturnDto;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
 
@@ -29,20 +28,17 @@ public class IpInterfaceCallbackController {
 
     /**
      * 分页查询
-     *
      * @param ipInterfaceCalledQueryParam 筛选条件
      * @return 查询结果
      */
     @Operation(summary = "分页查询接口调用记录")
     @GetMapping("/list")
     public BasePageResult<IpInterfaceCallVO> queryList(InterfaceCalledQueryParam ipInterfaceCalledQueryParam){
-        System.out.println();
         return ipOrderService.queryList(ipInterfaceCalledQueryParam);
     }
 
     /**
      * 查询接口的调用详情
-     *
      * @param id 筛选条件
      * @return 查询结果
      */

+ 12 - 1
src/main/java/com/hr/controller/IpInterfaceController.java

@@ -137,9 +137,20 @@ public class IpInterfaceController {
      * 查询账号下关联的接口列表
      */
     @Operation(summary = "查询账号下关联的接口列表")
-    @DeleteMapping("/account/ref/list")
+    @PostMapping("/account/ref/list")
     public BasePageResult<AccountInterfaceVO> accountInterfaceList(@RequestBody AccountInterfaceParam pageParam){
         Page<AccountInterfaceVO> result = ipTokenInterfaceService.accountInterfaceList(pageParam);
         return BasePageResult.success(result.getContent(), result.getTotalElements(), pageParam.getPageNum(), pageParam.getPageSize());
     }
+
+    /**
+     * 账号关联接口修改接口状态
+     * @param switchStatusParam 主键
+     * @return 是否成功
+     */
+    @Operation(summary = "修改状态")
+    @PostMapping("/account/interface/ref/switchStatus")
+    public BaseReturnDto<Boolean> accountInterfaceRefSwitch(@RequestBody SwitchStatusParam switchStatusParam){
+        return BaseReturnDto.success(ipTokenInterfaceService.switchStatus(switchStatusParam));
+    }
 }

+ 2 - 1
src/main/java/com/hr/externelSystem/BizHandlerFactory.java

@@ -76,6 +76,7 @@ public class BizHandlerFactory {
                 ipOrderPO.setStatus("fail");
                 ipLogPO.setStatus("fail");
             }
+            ipOrderPO.setInterfaceId(ipInterfacePO.getId());
             ipOrderPO.setUpdateTime(LocalDateTime.now());
             ipOrderPO.setBusinessNo(logDto.getBusinessNo());
             ipLogPO.setUrl(logDto.getUrl());
@@ -118,10 +119,10 @@ public class BizHandlerFactory {
     private void wrapCallBackOrder(IpOrderPO ipOrder, CallbackResponseVO callback, LocalDateTime callDateTime, JSONObject json) {
         IpLogPO ipLog = new IpLogPO();
         IpOrderPO ipOrderPO = new IpOrderPO();
-
         ipOrderPO.setId(SnowflakeIdWorker.nextId());
         ipOrderPO.setInterfaceName(ipOrder.getInterfaceName());
         ipOrderPO.setAccNo(ipOrder.getAccNo());
+        ipOrderPO.setInterfaceId(ipOrder.getInterfaceId());
         ipOrderPO.setRefId(ipOrder.getId());
         ipOrderPO.setCallbackUrl(ipOrder.getCallbackUrl());
         ipOrderPO.setAddTime(callDateTime);

+ 6 - 0
src/main/java/com/hr/param/AccountInterfaceParam.java

@@ -6,4 +6,10 @@ import lombok.Data;
 public class AccountInterfaceParam extends PageParam{
 
     private Long id;
+
+    private String accNo;
+
+    private String status;
+
+    private Long aid;
 }

+ 4 - 0
src/main/java/com/hr/repository/domain/IpOrderPO.java

@@ -23,6 +23,10 @@ public class IpOrderPO {
     @Schema(description = "主键")
 	private Long id;
 
+    @Column(name = "iid")
+    @Schema(description = "接口id")
+    private Long interfaceId;
+
     /**
      * 调用编号(业务编号),唯一,格式为年月日时分秒毫秒加6位随机数20250918010256001000001,;
      */

+ 1 - 0
src/main/java/com/hr/repository/jpa/IpTokenInterfaceRepository.java

@@ -12,4 +12,5 @@ import java.util.List;
  */
 public interface IpTokenInterfaceRepository extends JpaRepository<IpTokenInterfacePO,Long> {
 
+    IpTokenInterfacePO findByAidAndIid(Long aid, Long iid);
 }

+ 23 - 4
src/main/java/com/hr/repository/service/impl/IpOrderServiceImpl.java

@@ -1,14 +1,14 @@
 package com.hr.repository.service.impl;
 
+import com.alibaba.fastjson2.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.hr.param.InterfaceCalledQueryParam;
-import com.hr.repository.domain.IpLogPO;
-import com.hr.repository.domain.IpOrderPO;
-import com.hr.repository.jpa.IpLogRepository;
-import com.hr.repository.jpa.IpOrderRepository;
+import com.hr.repository.domain.*;
+import com.hr.repository.jpa.*;
 import com.hr.repository.service.IpOrderService;
 import com.hr.vo.*;
 import com.yy.basedevelop.common.data.BasePageResult;
+import com.yy.basedevelop.common.util.ToString;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.*;
@@ -28,6 +28,14 @@ public class IpOrderServiceImpl implements IpOrderService {
     private IpOrderRepository ipOrderRepository;
     @Autowired
     private IpLogRepository ipLogRepository;
+    @Autowired
+    private IpInterfaceRepository ipInterfaceRepository;
+    @Autowired
+    private IpTokenInterfaceRepository ipTokenInterfaceRepository;
+    @Autowired
+    private IpAccountRepository ipAccountRepository;
+    @Autowired
+    private IpTokenRepository ipTokenRepository;
 
     /** 
      * 通过ID查询单条数据 
@@ -85,13 +93,24 @@ public class IpOrderServiceImpl implements IpOrderService {
     @Override
     public InterfaceCalledDetail interfaceDetail(Long id) {
         IpOrderPO ipOrderPO = ipOrderRepository.findById(id).get();
+        ipOrderPO.getAccNo();
+        IpAccountPO accountPO = ipAccountRepository.findByAccNo(ipOrderPO.getAccNo());
         IpLogPO ipLog = ipLogRepository.findByOid(ipOrderPO.getId());
+        IpInterfacePO ipInterfacePO = ipInterfaceRepository.findById(ipOrderPO.getInterfaceId()).get();
+        IpTokenInterfacePO ipTokenInterfacePO = ipTokenInterfaceRepository.findByAidAndIid(accountPO.getId(), ipInterfacePO.getId());
+        Long tid = ipTokenInterfacePO.getTid();
+        IpTokenPO ipTokenPO = ipTokenRepository.findById(tid).get();
         InterfaceCalledDetail vo = new InterfaceCalledDetail();
         vo.setId(ipOrderPO.getId());
         vo.setAccountNo(ipOrderPO.getAccNo());
         vo.setInterfaceName(ipOrderPO.getInterfaceName());
         vo.setRequestParam(ipLog.getRequestParam());
         vo.setResponseParam(ipLog.getResponseResult());
+        JSONObject configParamJSON = new JSONObject();
+        configParamJSON.put("token", ipTokenPO.getToken());
+        configParamJSON.put("secret", ipTokenPO.getSecret());
+        vo.setConfigParam(configParamJSON.toJSONString());
+        vo.setInterfaceParam(ipInterfacePO.getInterfaceConfig());
         return vo;
     }
 

+ 4 - 0
src/main/java/com/hr/service/IpTokenInterfaceService.java

@@ -3,6 +3,7 @@ package com.hr.service;
 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.IpTokenInterfacePO;
 import com.hr.vo.AccountInterfaceVO;
 import com.hr.vo.IpTokenInterfaceVO;
@@ -62,4 +63,7 @@ public interface IpTokenInterfaceService{
     AggregateQueryDTO queryConfigByInterfaceCodeAndAccountNo(Long  accoutId, Long interfaceId);
 
     Page<AccountInterfaceVO> accountInterfaceList(AccountInterfaceParam pageParam);
+
+    Boolean switchStatus(SwitchStatusParam switchStatusParam);
+
 }

+ 4 - 1
src/main/java/com/hr/service/impl/IpAccountServiceImpl.java

@@ -143,9 +143,11 @@ public class IpAccountServiceImpl implements IpAccountService {
             if(ipAccountPO != null){
                 throw new RuntimeException("账户编号已存在");
             }
+            ipAccountPO = new IpAccountPO();
+            ipAccountPO.setAccNo(accountParam.getAccNo());
+            ipAccountPO.setStatus("normal");
         }else{
             ipAccountPO = ipAccountRepository.findById(accountParam.getId()).get();
-            ipAccountPO.setRemark(accountParam.getRemark());
         }
         if(accountParam.getId() == null){
             ipAccountPO.setId(SnowflakeIdWorker.nextId());
@@ -153,6 +155,7 @@ public class IpAccountServiceImpl implements IpAccountService {
             ipAccountPO.setAddUserId(userId);
             ipAccountPO.setAddUserName(userName);
         }
+        ipAccountPO.setRemark(accountParam.getRemark());
         ipAccountPO.setUpdateTime(LocalDateTime.now());
         ipAccountPO.setUpdateUserId(userId);
         ipAccountPO.setUpdateUserName(userName);

+ 4 - 4
src/main/java/com/hr/service/impl/IpInterfaceServiceImpl.java

@@ -15,6 +15,7 @@ import com.hr.vo.NameValueVO;
 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;
@@ -92,7 +93,6 @@ public class IpInterfaceServiceImpl implements IpInterfaceService {
     
     /** 
      * 更新数据
-     *
      * @param IpInterfacePO 实例对象
      * @return 实例对象
      */
@@ -155,11 +155,11 @@ public class IpInterfaceServiceImpl implements IpInterfaceService {
             if(ipInterfacePO != null){
                 throw new RuntimeException("接口名称已存在");
             }
-
             ipInterfacePO = ipInterfaceRepository.findByInterfaceNo(ipInterfaceParam.getInterfaceNo());
             if(ipInterfacePO != null){
                 throw new RuntimeException("接口编号已存在");
             }
+            ipInterfacePO = new IpInterfacePO();
         }else{
             ipInterfacePO = ipInterfaceRepository.findByInterfaceName(ipInterfaceParam.getInterfaceName());
             if(ipInterfaceParam != null && ipInterfacePO.getInterfaceName().equals(ipInterfaceParam.getInterfaceName()) && !ipInterfacePO.getId().equals(ipInterfaceParam.getId())){
@@ -170,8 +170,8 @@ public class IpInterfaceServiceImpl implements IpInterfaceService {
                 throw new RuntimeException("接口编号已存在");
             }
         }
-        ipInterfacePO = new IpInterfacePO();
-        BeanUtils.copyProperties(ipInterfaceParam, ipInterfacePO);
+
+        com.yy.basedevelop.common.BeanUtils.copyPropertiesIgnoreNullAndEmptyStr(ipInterfaceParam, ipInterfacePO);
         if(ipInterfaceParam.getId() == null){
             ipInterfacePO.setId(SnowflakeIdWorker.nextId());
             ipInterfacePO.setAddTime(LocalDateTime.now());

+ 38 - 2
src/main/java/com/hr/service/impl/IpTokenInterfaceServiceImpl.java

@@ -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,15 +107,35 @@ 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");
+        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);
@@ -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());

+ 9 - 0
src/main/java/com/hr/vo/AccountInterfaceVO.java

@@ -13,6 +13,12 @@ public class AccountInterfaceVO implements Serializable {
     @Schema(description = "id")
     private Long id;
 
+    @Schema(description = "账号NO")
+    private String accNo;
+
+    @Schema(description = "接口ID")
+    private Long interfaceId;
+
     @Schema(description = "接口名称")
     private String interfaceName;
 
@@ -38,6 +44,9 @@ public class AccountInterfaceVO implements Serializable {
     @Schema(description = "secret")
     private String secret;
 
+    @Schema(description = "token")
+    private String token;
+
     @Schema(description = "创建人")
     private String addUserName;
 

+ 4 - 0
src/main/java/com/hr/vo/InterfaceCalledDetail.java

@@ -16,4 +16,8 @@ public class InterfaceCalledDetail implements Serializable {
     private String requestParam;
 
     private String responseParam;
+
+    private String interfaceParam;
+
+    private String configParam;
 }