From 50eb0d8180c766302a930472dcfa4b6491d7029b Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Wed, 4 Apr 2018 20:26:13 +0800 Subject: [PATCH] add contract analysis & pageable --- .../mappers/system/ClientsContractMapper.java | 6 +++-- .../system/core/ClientContractService.java | 6 +++-- .../core/impl/ClientContractServiceImpl.java | 22 +++++++++++++++--- .../manage/system/web/contractController.java | 11 +++++++-- .../mappers/system/ClientsContractMapper.xml | 5 ++++ src/main/ui/static/sys/contract.js | 13 ++++++++--- .../static/sys/templates/contract_sign.html | 23 +++++++++++++++++-- 7 files changed, 72 insertions(+), 14 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.java index 873ad7b61..b143de628 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.java @@ -1,11 +1,12 @@ package au.com.royalpay.payment.manage.mappers.system; -import java.sql.SQLType; import java.util.List; import org.apache.ibatis.annotations.Param; import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import com.github.miemiedev.mybatis.paginator.domain.PageList; import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; @@ -27,6 +28,7 @@ public interface ClientsContractMapper { @AutoSql(type = SqlType.SELECT) List list(); - List listWithClientInfo(); + PageList listWithClientInfo(PageBounds pagination); + List analysisSingstatus(); } diff --git a/src/main/java/au/com/royalpay/payment/manage/system/core/ClientContractService.java b/src/main/java/au/com/royalpay/payment/manage/system/core/ClientContractService.java index cf064e9b2..e9ea8072c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/system/core/ClientContractService.java +++ b/src/main/java/au/com/royalpay/payment/manage/system/core/ClientContractService.java @@ -1,9 +1,9 @@ package au.com.royalpay.payment.manage.system.core; import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import java.util.Date; -import java.util.List; public interface ClientContractService { @@ -17,5 +17,7 @@ public interface ClientContractService { void saveContract(int client_id, Date expire_date, String channel); - List list(); + JSONObject list(PageBounds pagination); + + JSONObject analysis(); } diff --git a/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java index dbc70175d..a4aedb370 100644 --- a/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java @@ -8,8 +8,10 @@ import au.com.royalpay.payment.manage.system.core.ClientContractService; import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.exceptions.NotFoundException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException; +import au.com.royalpay.payment.tools.utils.PageListUtils; import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import org.apache.commons.lang3.time.DateUtils; import org.slf4j.Logger; @@ -101,7 +103,7 @@ public class ClientContractServiceImpl implements ClientContractService { } @Override - public JSONObject getClientContractExpire(int client_id,String channel) { + public JSONObject getClientContractExpire(int client_id, String channel) { JSONObject client = clientManager.getClientInfo(client_id); if (client == null) { throw new NotFoundException("merchant not found please check ID"); @@ -130,7 +132,21 @@ public class ClientContractServiceImpl implements ClientContractService { } @Override - public List list() { - return clientsContractMapper.listWithClientInfo(); + public JSONObject list(PageBounds pagination) { + return PageListUtils.buildPageListResult(clientsContractMapper.listWithClientInfo(pagination)); + } + + @Override + public JSONObject analysis() { + List contractAnalysis =clientsContractMapper.analysisSingstatus(); + JSONObject result = new JSONObject(); + for (JSONObject jsonObject : contractAnalysis) { + if(jsonObject.getIntValue("has_sign")==1){ + result.put("has_sign",jsonObject.getIntValue("count")); + }else { + result.put("not_sign",jsonObject.getIntValue("count")); + } + } + return result; } } diff --git a/src/main/java/au/com/royalpay/payment/manage/system/web/contractController.java b/src/main/java/au/com/royalpay/payment/manage/system/web/contractController.java index 5d1362c3e..631d910cd 100644 --- a/src/main/java/au/com/royalpay/payment/manage/system/web/contractController.java +++ b/src/main/java/au/com/royalpay/payment/manage/system/web/contractController.java @@ -5,9 +5,11 @@ import au.com.royalpay.payment.manage.settlement.core.ManualSettleSupport; import au.com.royalpay.payment.manage.system.core.ClientContractService; import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.List; @@ -23,8 +25,13 @@ public class contractController { private ManualSettleSupport manualSettleSupport; @ManagerMapping(value = "/contract/list", method = RequestMethod.GET) - public List contractList() { - return clientContractService.list(); + public JSONObject contractList(@RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int limit) { + return clientContractService.list(new PageBounds(page,limit)); + } + + @ManagerMapping(value = "/contract", method = RequestMethod.GET) + public JSONObject contractAnalysis() { + return clientContractService.analysis(); } @ManagerMapping(value = "/manualSettle/list", method = RequestMethod.GET) diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.xml index 8530d41d2..2dc237318 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.xml @@ -13,4 +13,9 @@ left join sys_accounts a on a.account_id = cc.sign_account_id + + \ No newline at end of file diff --git a/src/main/ui/static/sys/contract.js b/src/main/ui/static/sys/contract.js index f1cbcb5fd..a463c557d 100644 --- a/src/main/ui/static/sys/contract.js +++ b/src/main/ui/static/sys/contract.js @@ -20,9 +20,16 @@ define(['angular'], function (angular) { }) }]); app.controller('contractAnalysisCtrl', ['$scope', '$http', '$state', '$filter', 'commonDialog', function ($scope, $http, $state, $filter, commonDialog) { - $scope.getContractAnalysis = function () { - $http.get('/manage/common/analysis/contract/list').then(function (resp) { - $scope.contract_analysis = resp.data; + $scope.pagination = {}; + $scope.getContractAnalysis = function (page) { + var params = {}; + params.page = page || $scope.pagination.page || 1; + $http.get('/manage/common/analysis/contract/list', {params: params}).then(function (resp) { + $scope.contract = resp.data.data; + $scope.pagination = resp.data.pagination; + }); + $http.get('/manage/common/analysis/contract').then(function (resp) { + $scope.analysis = resp.data; }); }; $scope.getContractAnalysis(); diff --git a/src/main/ui/static/sys/templates/contract_sign.html b/src/main/ui/static/sys/templates/contract_sign.html index 043991313..d41656762 100644 --- a/src/main/ui/static/sys/templates/contract_sign.html +++ b/src/main/ui/static/sys/templates/contract_sign.html @@ -13,7 +13,9 @@ \ No newline at end of file