dcs 1 gadu atpakaļ
vecāks
revīzija
19ad851e58

+ 19 - 1
virgo.api/src/main/java/com/bosshand/virgo/api/controller/ContractController.java

@@ -12,7 +12,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping({"contract"})
@@ -36,6 +38,11 @@ public class ContractController {
     @RequestMapping(value = "/list", method = RequestMethod.POST)
     public Response getList(@RequestBody Contract contract) {
         List<Contract> list = contractService.getList(contract);
+        tags(list);
+        return Response.ok(list);
+    }
+
+    private void tags(List<Contract> list) {
         List<Tag> tags = new ArrayList<>();
         for (Contract ct : list) {
             tags.clear();
@@ -46,7 +53,18 @@ public class ContractController {
             }
             ct.setTagList(tags);
         }
-        return Response.ok(list);
+    }
+
+    @ApiOperation("分页获取")
+    @RequestMapping(value = "/{currPage}/{pageSize}", method = RequestMethod.POST)
+    public Response list(@RequestBody Contract contract, @PathVariable int currPage, @PathVariable int pageSize) {
+        int totalCount = contractService.getTotalCount(contract);
+        List<Contract> dataList = contractService.getLimit(contract, currPage, pageSize);
+        tags(dataList);
+        Map<String, Object> result = new HashMap<>();
+        result.put("dataList", dataList);
+        result.put("totalCount", totalCount);
+        return Response.ok(result);
     }
 
     @ApiOperation("更新")

+ 15 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/controller/MerchantController.java

@@ -9,6 +9,10 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 @RestController
 @RequestMapping({"Merchant"})
 @Api(tags = {"客商管理"})
@@ -30,6 +34,17 @@ public class MerchantController {
         return Response.ok(merchantService.getList(merchant));
     }
 
+    @ApiOperation("分页获取")
+    @RequestMapping(value = "/{currPage}/{pageSize}", method = RequestMethod.POST)
+    public Response list(@RequestBody Merchant merchant, @PathVariable int currPage, @PathVariable int pageSize) {
+        int totalCount = merchantService.getTotalCount(merchant);
+        List<Merchant> dataList = merchantService.getLimit(merchant, currPage, pageSize);
+        Map<String, Object> result = new HashMap<>();
+        result.put("dataList", dataList);
+        result.put("totalCount", totalCount);
+        return Response.ok(result);
+    }
+
     @ApiOperation("更新")
     @RequestMapping(value = "/update", method = RequestMethod.PUT)
     public Response update(@RequestBody Merchant merchant) {

+ 6 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/dao/ContractDao.java

@@ -2,6 +2,7 @@ package com.bosshand.virgo.api.dao;
 
 import com.bosshand.virgo.api.model.Contract;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -17,4 +18,9 @@ public interface ContractDao {
     List<Contract> getList(Contract contract);
 
     Contract get(long id);
+
+    int getTotalCount(Contract contract);
+
+    List<Contract> getLimit(@Param("p") Contract p, @Param("currIndex") int currIndex, @Param("pageSize") int pageSize);
+
 }

+ 5 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/dao/MerchantDao.java

@@ -2,6 +2,7 @@ package com.bosshand.virgo.api.dao;
 
 import com.bosshand.virgo.api.model.Merchant;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -18,4 +19,8 @@ public interface MerchantDao {
 
     Merchant get(long id);
 
+    int getTotalCount(Merchant merchant);
+
+    List<Merchant> getLimit(@Param("p") Merchant p, @Param("currIndex") int currIndex, @Param("pageSize") int pageSize);
+
 }

+ 3 - 3
virgo.api/src/main/java/com/bosshand/virgo/api/model/Contract.java

@@ -127,7 +127,7 @@ public class Contract {
     /**
      * 文档id
      */
-    private String documentId;
+    private long documentId;
 
     /**
      * 自定义字段
@@ -318,11 +318,11 @@ public class Contract {
         this.attachment = attachment;
     }
 
-    public String getDocumentId() {
+    public long getDocumentId() {
         return documentId;
     }
 
-    public void setDocumentId(String documentId) {
+    public void setDocumentId(long documentId) {
         this.documentId = documentId;
     }
 

+ 10 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/service/ContractService.java

@@ -32,4 +32,14 @@ public class ContractService {
     public Contract get(long id) {
         return contractDao.get(id);
     }
+
+    public int getTotalCount(Contract contract) {
+        return contractDao.getTotalCount(contract);
+    }
+
+    public List<Contract> getLimit(Contract contract, int currPage, int pageSize) {
+        int currIndex = (currPage - 1) * pageSize;
+        return contractDao.getLimit(contract, currIndex, pageSize);
+    }
+
 }

+ 9 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/service/MerchantService.java

@@ -33,4 +33,13 @@ public class MerchantService {
         return merchantDao.get(id);
     }
 
+    public int getTotalCount(Merchant merchant) {
+        return merchantDao.getTotalCount(merchant);
+    }
+
+    public List<Merchant> getLimit(Merchant merchant, int currPage, int pageSize) {
+        int currIndex = (currPage - 1) * pageSize;
+        return merchantDao.getLimit(merchant, currIndex, pageSize);
+    }
+
 }

+ 63 - 0
virgo.api/src/main/resources/mapper/ContractMapper.xml

@@ -107,4 +107,67 @@
         </where>
     </select>
 
+    <select id="getTotalCount" parameterType="com.bosshand.virgo.api.model.Contract" resultType="Integer">
+        SELECT count(*) FROM contract
+        <where>
+            <if test="organizationId!=0">and organizationId=#{organizationId}</if>
+            <if test="organizationName!=null">and organizationName=#{organizationName}</if>
+            <if test="roleId!=0">and roleId=#{roleId}</if>
+            <if test="investmentPromotion!=null">and investmentPromotion=#{investmentPromotion}</if>
+            <if test="operator!=null">and operator=#{operator}</if>
+            <if test="tenant!=null">and tenant=#{tenant}</if>
+            <if test="industry!=null">and industry=#{industry}</if>
+            <if test="corporation!=null">and corporation=#{corporation}</if>
+            <if test="signatory!=null">and signatory=#{signatory}</if>
+            <if test="tenantContactPerson!=null">and tenantContactPerson=#{tenantContactPerson}</if>
+            <if test="signingDate!=null">and signingDate=#{signingDate}</if>
+            <if test="startDate!=null">and startDate=#{startDate}</if>
+            <if test="endDate!=null">and endDate=#{endDate}</if>
+            <if test="lateFeesStartingDays!=null">and lateFeesStartingDays=#{lateFeesStartingDays}</if>
+            <if test="lateFeesProportion!=null">and lateFeesProportion=#{lateFeesProportion}</if>
+            <if test="lateFeesCeiling!=null">and lateFeesCeiling=#{lateFeesCeiling}</if>
+            <if test="tagIds != null">and
+                <foreach item="tagId" collection="tagIds.split(',')" open="(" separator=" and " close=")">
+                    FIND_IN_SET (#{tagId}, tagIds)
+                </foreach>
+            </if>
+            <if test="projectItemTargetRoomIds!=null">and projectItemTargetRoomIds=#{projectItemTargetRoomIds}</if>
+            <if test="attachment!=null">and attachment=#{attachment}</if>
+            <if test="documentId!=0">and documentId=#{documentId}</if>
+            <if test="data!=null">and data=#{data}</if>
+        </where>
+    </select>
+
+    <select id="getLimit" resultMap="contractResult">
+        SELECT * FROM contract
+        <where>
+            <if test="p.organizationId!=0">and organizationId=#{p.organizationId}</if>
+            <if test="p.organizationName!=null">and organizationName=#{p.organizationName}</if>
+            <if test="p.roleId!=0">and roleId=#{p.roleId}</if>
+            <if test="p.investmentPromotion!=null">and investmentPromotion=#{p.investmentPromotion}</if>
+            <if test="p.operator!=null">and operator=#{p.operator}</if>
+            <if test="p.tenant!=null">and tenant=#{p.tenant}</if>
+            <if test="p.industry!=null">and industry=#{p.industry}</if>
+            <if test="p.corporation!=null">and corporation=#{p.corporation}</if>
+            <if test="p.signatory!=null">and signatory=#{p.signatory}</if>
+            <if test="p.tenantContactPerson!=null">and tenantContactPerson=#{p.tenantContactPerson}</if>
+            <if test="p.signingDate!=null">and signingDate=#{p.signingDate}</if>
+            <if test="p.startDate!=null">and startDate=#{p.startDate}</if>
+            <if test="p.endDate!=null">and endDate=#{p.endDate}</if>
+            <if test="p.lateFeesStartingDays!=null">and lateFeesStartingDays=#{p.lateFeesStartingDays}</if>
+            <if test="p.lateFeesProportion!=null">and lateFeesProportion=#{p.lateFeesProportion}</if>
+            <if test="p.lateFeesCeiling!=null">and lateFeesCeiling=#{p.lateFeesCeiling}</if>
+            <if test="p.tagIds != null">and
+                <foreach item="tagId" collection="p.tagIds.split(',')" open="(" separator=" and " close=")">
+                    FIND_IN_SET (#{tagId}, tagIds)
+                </foreach>
+            </if>
+            <if test="p.projectItemTargetRoomIds!=null">and projectItemTargetRoomIds=#{p.projectItemTargetRoomIds}</if>
+            <if test="p.attachment!=null">and attachment=#{p.attachment}</if>
+            <if test="p.documentId!=0">and documentId=#{p.documentId}</if>
+            <if test="p.data!=null">and data=#{p.data}</if>
+        </where>
+        limit #{currIndex} , #{pageSize}
+    </select>
+
 </mapper>

+ 29 - 0
virgo.api/src/main/resources/mapper/MerchantMapper.xml

@@ -58,4 +58,33 @@
         </where>
     </select>
 
+    <select id="getTotalCount" parameterType="com.bosshand.virgo.api.model.LookRecord" resultType="Integer">
+        SELECT count(*) FROM merchant
+        <where>
+            <if test="organizationId!=0">and organizationId=#{organizationId}</if>
+            <if test="industryType!=null">and industryType=#{industryType}</if>
+            <if test="name!=null">and name=#{name},</if>
+            <if test="legalPerson!=null">and legalPerson=#{legalPerson}</if>
+            <if test="establishDate!=null">and establishDate=#{establishDate}</if>
+            <if test="businessTerm!=null">and businessTerm=#{businessTerm}</if>
+            <if test="registeredCapital!=null">and registeredCapital=#{registeredCapital}</if>
+            <if test="data!=null">and data=#{data},</if>
+        </where>
+    </select>
+
+    <select id="getLimit" resultMap="merchantResult">
+        SELECT * FROM merchant
+        <where>
+            <if test="p.organizationId!=0">and organizationId=#{p.organizationId}</if>
+            <if test="p.industryType!=null">and industryType=#{p.industryType}</if>
+            <if test="p.name!=null">and name=#{p.name},</if>
+            <if test="p.legalPerson!=null">and legalPerson=#{p.legalPerson}</if>
+            <if test="p.establishDate!=null">and establishDate=#{p.establishDate}</if>
+            <if test="p.businessTerm!=null">and businessTerm=#{p.businessTerm}</if>
+            <if test="p.registeredCapital!=null">and registeredCapital=#{p.registeredCapital}</if>
+            <if test="p.data!=null">and data=#{p.data},</if>
+        </where>
+        limit #{currIndex} , #{pageSize}
+    </select>
+
 </mapper>

+ 13 - 0
virgo.core/src/main/java/com/bosshand/virgo/core/model/MgrOrganizationProject.java

@@ -32,6 +32,11 @@ public class MgrOrganizationProject {
      */
     private long agentId;
 
+    /**
+     * 客商id
+     */
+    private long merchantId;
+
     /**
      * 身份id
      */
@@ -85,6 +90,14 @@ public class MgrOrganizationProject {
         this.agentId = agentId;
     }
 
+    public long getMerchantId() {
+        return merchantId;
+    }
+
+    public void setMerchantId(long merchantId) {
+        this.merchantId = merchantId;
+    }
+
     public long getIdentityId() {
         return identityId;
     }

+ 3 - 3
virgo.core/src/main/java/com/bosshand/virgo/core/service/MgrUserService.java

@@ -266,9 +266,9 @@ public class MgrUserService {
     				resources = resource.getData();
     				menus = resource.getComment();
     			}
-    		}
-    		currentUserRole.setResources(resources);
-    		currentUserRole.setMenus(menus);
+				currentUserRole.setResources(resources);
+				currentUserRole.setMenus(menus);
+			}
     	}
 
     	subject.getSession().setTimeout(25920000000L);

+ 3 - 1
virgo.core/src/main/resources/mapper/MgrOrganizationProjectMapper.xml

@@ -11,6 +11,7 @@
         <result column="userId" property="userId"/>
         <result column="clientId" property="clientId"/>
         <result column="agentId" property="agentId"/>
+        <result column="merchantId" property="merchantId"/>
         <result column="identityId" property="identityId"/>
     </resultMap>
 
@@ -27,7 +28,8 @@
     </select>
 
     <insert id="insert">
-        insert into mgr_organization_project (organizationId, projectId, userId, clientId, agentId, identityId) value (#{organizationId}, #{projectId}, #{userId}, #{clientId}, #{agentId}, #{identityId})
+        insert into mgr_organization_project (organizationId, projectId, userId, clientId, agentId, merchantId, identityId)
+        value (#{organizationId}, #{projectId}, #{userId}, #{clientId}, #{agentId}, #{merchantId}, #{identityId})
     </insert>
 
     <delete id="delete">