Browse Source

合作方分页组件

zishan-an 1 year ago
parent
commit
6aa4decad2

+ 9 - 3
src/main/java/com/kexun/controller/CooperatorController.java

@@ -6,6 +6,8 @@ package com.kexun.controller;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import com.kexun.common.utils.Result;
 import com.kexun.entity.*;
 import com.kexun.service.CooperatorService;
@@ -36,16 +38,20 @@ public class CooperatorController {
 
     // 获取合作方信息
     @GetMapping("cooperatorList")
-    public Result cooperatorList() {
+    public Result cooperatorList(@RequestParam int pageNum) {
+        int pageSize = 10;
+        PageHelper.startPage(pageNum, pageSize);//设置分页信息
         JSONObject resJson=new JSONObject();
-        List<CooperatorInfo> list= CooperatorService.list();
+        List<CooperatorInfo> list= CooperatorService.selectPage();
 
         for(int i=0; i<list.size(); i++)
         {
             String time = list.get(i).getCreateTime().replace(".0","");
             list.get(i).setCreateTime(time);
         }
-        resJson.put("cooperator_List",list);
+        PageInfo pageInfo=new PageInfo(list);
+
+        resJson.put("cooperator_List",pageInfo);
 //        System.out.println(list);
 
         return Result.success("ok",resJson);

+ 1 - 0
src/main/java/com/kexun/mapper/CooperatorMapper.java

@@ -17,6 +17,7 @@ public interface CooperatorMapper extends BaseMapper<CooperatorInfo> {
 
     List<CooperatorProduct> QueryProduct(@Param("cooperatorNum") String cooperatorNum);
 
+    List<CooperatorInfo> selectAll();
 }
 
 

+ 2 - 0
src/main/java/com/kexun/service/CooperatorService.java

@@ -18,4 +18,6 @@ public interface CooperatorService extends IService<CooperatorInfo> {
     List<CooperatorField> findCooperatorFieldByNum(String cooperatorNum);
     List<CooperatorProduct> findCooperatorProductByNum(String cooperatorNum);
     CooperatorInfo findByID(long id);
+
+    List<CooperatorInfo> selectPage();
 }

+ 7 - 5
src/main/java/com/kexun/service/impl/CooperatorServiceImpl.java

@@ -2,13 +2,9 @@ package com.kexun.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.kexun.entity.CooperatorField;
-import com.kexun.entity.CooperatorInfo;
-import com.kexun.entity.CooperatorProduct;
-import com.kexun.entity.UserField;
+import com.kexun.entity.*;
 import com.kexun.mapper.CooperatorMapper;
 import com.kexun.service.CooperatorService;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -44,6 +40,12 @@ public class CooperatorServiceImpl extends ServiceImpl<CooperatorMapper, Coopera
         return l;
     }
 
+    public List<CooperatorInfo> selectPage() {
+//        System.out.println("aaa");
+        List<CooperatorInfo> l = cooperatorMapper.selectAll();
+        return l;
+    }
+
     @Override
     public CooperatorInfo findByID(long id) {
         QueryWrapper<CooperatorInfo> wrapper=new QueryWrapper<CooperatorInfo>().eq("id",id);

+ 4 - 0
src/main/resources/mapper/CooperatorMapper.xml

@@ -45,6 +45,10 @@
 
     </select>
 
+    <select id="selectAll" resultType="com.kexun.entity.CooperatorInfo">
+        select * from cooperator_info
+    </select>
+
     <select id="QueryProduct" resultType="com.kexun.entity.CooperatorProduct" >
         SELECT DISTINCT
             prd_product.product_num,