longhu пре 1 недеља
родитељ
комит
8e8e7140c8

+ 3 - 2
src/main/java/com/hr/controller/IpAccountController.java

@@ -1,5 +1,6 @@
 package com.hr.controller;
 
+import com.github.pagehelper.PageInfo;
 import com.hr.param.IpAccountParam;
 import com.hr.param.SwitchStatusParam;
 import com.hr.service.IpAccountService;
@@ -35,8 +36,8 @@ public class IpAccountController{
     @Operation(summary = "分页查询")
     @GetMapping("/list")
     public BasePageResult<IpAccountVO> paginQuery(IpAccountParam ipAccountParam){
-        Page<IpAccountVO> ipAccountPOS = ipAccountService.paginQuery(ipAccountParam, ipAccountParam.getPageNum(), ipAccountParam.getPageSize());
-        return BasePageResult.success(ipAccountPOS.getContent(), ipAccountPOS.getTotalElements(), ipAccountParam.getPageNum(), ipAccountParam.getPageSize());
+        PageInfo<IpAccountVO> ipAccountPOS = ipAccountService.paginQuery(ipAccountParam, ipAccountParam.getPageNum(), ipAccountParam.getPageSize());
+        return BasePageResult.success(ipAccountPOS.getList(), ipAccountPOS.getTotal(), ipAccountParam.getPageNum(), ipAccountParam.getPageSize());
     }
     
     /** 

+ 5 - 1
src/main/java/com/hr/param/IpAccountParam.java

@@ -3,7 +3,10 @@ package com.hr.param;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
- /**
+import java.util.Arrays;
+import java.util.List;
+
+/**
  * 账户表;IpAccount数据表的PO对象
  * @author : longhoo
  * @date : 2025-10-10
@@ -19,5 +22,6 @@ public class IpAccountParam extends PageParam{
     private String remark ;
     @Schema(description = "状态,normal 有效,disable 禁用,delete 删除")
     private String status ;
+    private List<String> statusList = Arrays.asList("normal", "disable");
 
 }

+ 5 - 0
src/main/java/com/hr/repository/jpa/IpAccountRepository.java

@@ -2,9 +2,12 @@ package com.hr.repository.jpa;
 
 import com.hr.param.IpAccountParam;
 import com.hr.repository.domain.IpAccountPO;
+import com.hr.vo.IpAccountVO;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
 
 import java.util.List;
 
@@ -19,4 +22,6 @@ public interface IpAccountRepository extends JpaRepository<IpAccountPO, Long> ,
     IpAccountPO queryById(Long aid);
 
     IpAccountPO findByAccNo(String accNo);
+
+    List<IpAccountVO> queryList(@Param("accNo") String accNo, @Param("statusList") List<String> statusList);
 }

+ 2 - 1
src/main/java/com/hr/repository/jpa/IpInterfaceRepository.java

@@ -22,5 +22,6 @@ public interface IpInterfaceRepository extends JpaRepository<IpInterfacePO,Long>
     IpInterfacePO findByInterfaceName(String interfaceName);
     IpInterfacePO findByInterfaceNo(String interfaceNo);
 
-    List<IpInterfaceVO> queryPage(IpInterfaceParam interfaceParam);
+    List<IpInterfaceVO> queryPage(@Param("interfaceName") String interfaceName, @Param("statusList") List<String> statusList);
+
 }

+ 2 - 1
src/main/java/com/hr/service/IpAccountService.java

@@ -1,6 +1,7 @@
 package com.hr.service;
 
 
+import com.github.pagehelper.PageInfo;
 import com.hr.param.IpAccountParam;
 import com.hr.param.SwitchStatusParam;
 import com.hr.repository.domain.IpAccountPO;
@@ -31,7 +32,7 @@ public interface IpAccountService{
      * @param size  每页大小
      * @return
      */
-    Page<IpAccountVO> paginQuery(IpAccountParam ipAccountParam, Integer current, Integer size);
+    PageInfo<IpAccountVO> paginQuery(IpAccountParam ipAccountParam, Integer current, Integer size);
     /** 
      * 新增数据
      *

+ 10 - 30
src/main/java/com/hr/service/impl/IpAccountServiceImpl.java

@@ -1,6 +1,7 @@
 package com.hr.service.impl;
 
 
+import com.github.pagehelper.PageInfo;
 import com.google.common.cache.Cache;
 import com.google.common.cache.CacheBuilder;
 import com.hr.dto.AggregateQueryDTO;
@@ -13,6 +14,7 @@ import com.hr.util.SnowflakeIdWorker;
 import com.hr.vo.IpAccountVO;
 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.*;
@@ -21,6 +23,7 @@ import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Optional;
 import java.util.concurrent.TimeUnit;
@@ -56,36 +59,12 @@ public class IpAccountServiceImpl implements IpAccountService {
     }
 
     @Override
-    public Page<IpAccountVO> paginQuery(IpAccountParam ipAccountParam, Integer current, Integer size) {
-        IpAccountPO ipAccountPO = new IpAccountPO();
-        BeanUtils.copyProperties(ipAccountParam, ipAccountPO);
-        Pageable pageAble = PageRequest.of(current -1, size);
-        Specification<IpAccountPO> spec = (root, query, cb) -> {
-
-            List<Predicate> predicates = new ArrayList<>();
-            if (ipAccountParam.getAccNo() != null) {
-                predicates.add(cb.like(root.get("accNo"), "%" + ipAccountParam.getAccNo() + "%"));
-            }
-            if(ipAccountParam.getStatus() != null){
-                predicates.add(cb.equal(root.get("status"), ipAccountParam.getStatus()));
-            }else{
-                predicates.add(cb.notLike(root.get("status"), "delete"));
-            }
-
-            return cb.and(predicates.toArray(new Predicate[0]));
-        };
-
-        Page<IpAccountPO> page = ipAccountRepository.findAll(spec, pageAble);
-        List<IpAccountVO> resultList = new ArrayList<>();
-
-        page.getContent().forEach(item -> {
-            IpAccountVO vo = new IpAccountVO();
-            BeanUtils.copyProperties(item, vo);
-            resultList.add(vo);
-        });
-        Page<IpAccountVO> resultPage = new PageImpl(resultList);
-        BeanUtils.copyProperties(page, resultPage);
-        return resultPage;
+    public PageInfo<IpAccountVO> paginQuery(IpAccountParam ipAccountParam, Integer current, Integer size) {
+        if (StringUtils.isNotEmpty(ipAccountParam.getStatus())) {
+            ipAccountParam.setStatusList(Arrays.asList(ipAccountParam.getStatus()));
+        }
+        List<IpAccountVO> resultList = ipAccountRepository.queryList(ipAccountParam.getAccNo(),ipAccountParam.getStatusList());
+        return PageInfo.of(resultList);
     }
     
     /** 
@@ -160,6 +139,7 @@ public class IpAccountServiceImpl implements IpAccountService {
             ipAccountPO.setAddUserId(userId);
             ipAccountPO.setAddUserName(userName);
         }
+        ipAccountPO.setStatus(accountParam.getStatus());
         ipAccountPO.setRemark(accountParam.getRemark());
         ipAccountPO.setUpdateTime(LocalDateTime.now());
         ipAccountPO.setUpdateUserId(userId);

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

@@ -69,7 +69,7 @@ public class IpInterfaceServiceImpl implements IpInterfaceService {
          if (StringUtils.isNotEmpty(interfaceParam.getStatus())) {
              interfaceParam.setStatusList(Arrays.asList(interfaceParam.getStatus()));
          }
-         List<IpInterfaceVO> dbList = ipInterfaceRepository.queryPage(interfaceParam);
+         List<IpInterfaceVO> dbList = ipInterfaceRepository.queryPage(interfaceParam.getInterfaceName(), interfaceParam.getStatusList());
          return PageInfo.of(dbList);
      }
 

+ 11 - 0
src/main/resources/mapper/IpAccountMapper.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+		PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+		"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.hr.repository.jpa.IpAccountRepository">
+
+
+    <select id="queryList" resultType="com.hr.vo.IpAccountVO">
+        select * from ip_account t where t.acc_no like '%'||:accNo||'%' and status in(:statusList)
+    </select>
+</mapper>

+ 1 - 2
src/main/resources/mapper/IpInterfaceMapper.xml

@@ -21,7 +21,6 @@
         where 1 = 1 and ord.ref_id = :id
     </select>
     <select id="queryPage" resultType="com.hr.vo.IpInterfaceVO">
-        select * from ip_interface where 1=1 and interface_name like '%'||:interfaceName||'%'
-        and status in (:statusList)
+        select * from ip_interface where 1=1 and interface_name like '%'||:interfaceName||'%' and status in (:statusList)
     </select>
 </mapper>