增加版本信息
diff --git a/build.gradle b/build.gradle
index 274fcf0..068eb80 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,41 +1,32 @@
plugins {
- id 'org.springframework.boot'
- id 'org.jetbrains.kotlin.jvm'
- id 'org.jetbrains.kotlin.plugin.jpa'
- id 'org.jetbrains.kotlin.plugin.spring'
+ id "org.springframework.boot" version "2.1.6.RELEASE"
+ id 'org.jetbrains.kotlin.jvm' version '1.3.31'
+ id 'org.jetbrains.kotlin.plugin.jpa' version '1.3.31'
+ id 'org.jetbrains.kotlin.plugin.spring' version '1.3.31'
+ id "com.palantir.git-version" version "0.12.0-rc2"
id 'com.palantir.docker' version '0.22.1'
}
apply plugin: 'io.spring.dependency-management'
+apply plugin: 'java'
group = 'com.supwisdom'
-version = doorVersion
+version = '1.0'
sourceCompatibility = jdkVersion
+doorVersion = gitVersion()
repositories {
mavenCentral()
}
def startClass = 'com.supwisdom.dlpay.DoorApplicationKt'
-println("Build version: $version")
-repositories {
- mavenCentral()
-}
-
-springBoot {
- mainClassName = startClass
-}
-
+println("Build version: $doorVersion")
bootJar {
- launchScript()
mainClassName = startClass
-}
-
-jar {
manifest {
- attributes('Payapi-Version': version)
+ attributes('Door-Version': doorVersion)
}
}
@@ -52,7 +43,6 @@
implementation 'org.springframework.boot:spring-boot-autoconfigure'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.0.1.RELEASE'
-// implementation 'org.springframework.security.oauth:spring-security-oauth2'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.session:spring-session-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-cache'
@@ -62,15 +52,13 @@
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'
- implementation 'com.github.chenhaiyangs:rpc-tcc-transaction-spring:1.2.0'
- implementation 'com.github.chenhaiyangs:rpc-tcc-transaction-api:1.1.0'
- implementation 'com.github.chenhaiyangs:rpc-tcc-transaction-core:1.2.0'
implementation 'org.postgresql:postgresql:42.2.5'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'
implementation 'com.jcabi:jcabi-manifests:1.1'
implementation 'org.bitbucket.b_c:jose4j:0.6.3'
implementation 'io.github.microutils:kotlin-logging:1.6.26'
implementation 'org.slf4j:slf4j-parent:1.7.26'
+ implementation 'redis.clients:jedis:2.9.3'
implementation group: 'commons-lang', name:'commons-lang',version: '2.5'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
implementation group: 'com.sun.jersey', name: 'jersey-client', version: '1.19'
@@ -83,8 +71,6 @@
implementation 'cn.afterturn:easypoi-base:3.0.3'
-
-
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
testImplementation 'org.springframework.boot:spring-boot-starter-test'
diff --git a/gradle.properties b/gradle.properties
index 9ed40a0..08923a4 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,4 +1,2 @@
-springbootVersion = 2.1.3.RELEASE
-kotlinVersion = 1.3.31
doorVersion = 1.0
jdkVersion = 1.8
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index 39b7b24..11e2bdf 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,20 +1,2 @@
-pluginManagement {
- resolutionStrategy {
- eachPlugin {
- if (requested.id.namespace != null) {
- if (requested.id.namespace.startsWith("org.jetbrains.kotlin")) {
- println "Kotlin version $kotlinVersion"
- useVersion kotlinVersion
- } else if(requested.id.namespace.startsWith("org.springframework")) {
- println "Springboot version $springbootVersion"
- useVersion springbootVersion
- }
- }
- }
- }
- repositories {
- gradlePluginPortal()
- }
-}
rootProject.name = 'door'
diff --git a/src/main/java/com/supwisdom/dlpay/doorlist/controller/DoorlistMgrController.java b/src/main/java/com/supwisdom/dlpay/doorlist/controller/DoorlistMgrController.java
index a766f1e..27c2fd3 100644
--- a/src/main/java/com/supwisdom/dlpay/doorlist/controller/DoorlistMgrController.java
+++ b/src/main/java/com/supwisdom/dlpay/doorlist/controller/DoorlistMgrController.java
@@ -16,18 +16,16 @@
import com.supwisdom.dlpay.system.page.Pagination;
import com.supwisdom.dlpay.system.service.SystemService;
import com.supwisdom.dlpay.util.RedisUtil;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
-import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -37,213 +35,217 @@
@RequestMapping("/doorlistMgr")
public class DoorlistMgrController {
- protected static Logger logger = Logger.getLogger(DoorlistMgrController.class);
+ protected static Logger logger = LoggerFactory.getLogger(DoorlistMgrController.class);
- @Autowired
- SystemService systemService;
- @Autowired
- WebInterfaceService webInterfaceService;
- @Autowired
- NcService ncService;
+ @Autowired
+ SystemService systemService;
+ @Autowired
+ WebInterfaceService webInterfaceService;
+ @Autowired
+ NcService ncService;
- @RequestMapping("/downDoorList")
- public String downDoorList(ModelMap model){
- return "doorlist/addDoorlist";
+ @RequestMapping("/downDoorList")
+ public String downDoorList(ModelMap model) {
+ return "doorlist/addDoorlist";
+ }
+
+ @RequestMapping("/deleteDoorList")
+ public String deleteDoorList(ModelMap model) {
+ return "doorlist/deleteDoorlist";
+ }
+
+ @RequestMapping("/searchDoorlist")
+ public String searchDoorlist(ModelMap model) {
+ return "doorlist/searchDoorlist";
+ }
+
+ /**
+ * 填充查询门禁列表下拉菜单
+ *
+ * @return
+ * @throws Exception
+ */
+ @ResponseBody
+ @RequestMapping(value = "/getFillFormList")
+ public Map getFillFormList(@AuthenticationPrincipal TOperator operUser) throws Exception {
+ Map map = new HashMap();
+ try {
+ String opertype = operUser.getOpertype();
+ //名单状态
+ List<TDictionaryId> syncDicts = systemService.findTDictionaryByType(3);
+ map.put("syncDicts", syncDicts);
+ //厂商id
+ List<TKey> allFactoryId = webInterfaceService.getAllKeys();
+ map.put("allFactoryId", allFactoryId);
+ //操作标记
+ List<TDictionaryId> operDicts = new ArrayList<TDictionaryId>();
+ operDicts.addAll(systemService.findByType(2, "A"));
+ operDicts.addAll(systemService.findByType(2, "D"));
+ operDicts.addAll(systemService.findByType(2, "C"));
+ map.put("operDicts", operDicts);
+
+ List<TRegion> regions = null;
+ List<TBuilding> buildings = null;
+ if (!StringUtil.isEmpty(opertype) && (opertype.equals("S") || opertype.equals("P"))) {
+ regions = systemService.getAllRegions();
+ buildings = ncService.getAllBuilding();
+ map.put("regions", regions);
+ map.put("buildings", buildings);
+ } else if (!StringUtil.isEmpty(operUser.getRegionid())) {
+ regions = systemService.getRegionListById(operUser.getRegionid());
+ map.put("regions", regions);
+ buildings = systemService.getBuildingByRegionId(operUser.getRegionid());
+ map.put("buildings", buildings);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
}
+ return map;
+ }
- @RequestMapping("/deleteDoorList")
- public String deleteDoorList(ModelMap model){
- return "doorlist/deleteDoorlist";
+ /**
+ * 查询设备名单
+ *
+ * @param request
+ * @param factoryId
+ * @param doorName
+ * @param custName
+ * @param stuempNo
+ * @param syncStatus
+ * @param operFlag
+ * @param buildingid
+ * @param regionid
+ * @param allocatStartDate
+ * @param allocatEndDate
+ * @param pageNo
+ * @param pageSize
+ * @param operUser
+ * @return
+ */
+ @ResponseBody
+ @RequestMapping(value = "/getAllCardList")
+ public Map getAllCardList(HttpServletRequest request,
+ @RequestParam(value = "factoryId", required = false, defaultValue = "all") String factoryId,
+ @RequestParam(value = "doorName", required = false, defaultValue = "") String doorName,
+ @RequestParam(value = "custName", required = false, defaultValue = "") String custName,
+ @RequestParam(value = "stuempNo", required = false, defaultValue = "") String stuempNo,
+ @RequestParam(value = "syncStatus", required = false, defaultValue = "all") String syncStatus,
+ @RequestParam(value = "operFlag", required = false, defaultValue = "all") String operFlag,
+ @RequestParam(value = "buildingid", required = false, defaultValue = "") String buildingid,
+ @RequestParam(value = "regionid", required = false, defaultValue = "") String regionid,
+ @RequestParam(value = "allocatStartDate", required = false, defaultValue = "") String allocatStartDate,
+ @RequestParam(value = "allocatEndDate", required = false, defaultValue = "") String allocatEndDate,
+ @RequestParam(value = "pageNo", required = false, defaultValue = "1") int pageNo,
+ @RequestParam(value = "pageSize", required = false, defaultValue = "15") int pageSize,
+ @AuthenticationPrincipal TOperator operUser) {
+
+ Map map = new HashMap();
+ try {
+ String opertype = operUser.getOpertype();
+ boolean flag = true;
+ Pagination pResult = new Pagination();
+ if (!StringUtil.isEmpty(opertype) && (opertype.equals("S") || opertype.equals("P"))) {
+ pResult = webInterfaceService.getSystemCardListFrSearch(factoryId, allocatStartDate, allocatEndDate, doorName, custName, stuempNo, syncStatus, operFlag, buildingid, regionid, pageNo, pageSize);
+ } else if (!StringUtil.isEmpty(operUser.getRegionid())) {
+ pResult = webInterfaceService.getOperatorCardListFrSearch(factoryId, allocatStartDate, allocatEndDate, doorName, custName, stuempNo, syncStatus, operFlag, buildingid, regionid, pageNo, pageSize, operUser.getRegionid());
+ }
+ map.put("PageResult", pResult);
+ map.put("index", flag);
+ map.put("result", "查询设备名单成功!");
+ } catch (Exception e) {
+ e.printStackTrace();
+ map.put("result", "查询设备名单失败!");
+ logger.error("查询设备名单失败:" + e.getMessage());
}
+ return map;
+ }
- @RequestMapping("/searchDoorlist")
- public String searchDoorlist(ModelMap model){
- return "doorlist/searchDoorlist";
+ /**
+ * 注解方式导出设备名单Excel
+ *
+ * @param modelMap
+ * @param request
+ * @param response
+ * @param factoryId
+ * @param doorName
+ * @param custName
+ * @param stuempNo
+ * @param syncStatus
+ * @param operFlag
+ * @param buildingid
+ * @param regionid
+ * @param allocatStartDate
+ * @param allocatEndDate
+ * @param operUser
+ */
+ @RequestMapping(value = "/exportExcel", method = RequestMethod.GET)
+ public void download(ModelMap modelMap, HttpServletRequest request, HttpServletResponse response,
+ @RequestParam(value = "factoryId", required = false, defaultValue = "all") String factoryId,
+ @RequestParam(value = "doorName", required = false, defaultValue = "") String doorName,
+ @RequestParam(value = "custName", required = false, defaultValue = "") String custName,
+ @RequestParam(value = "stuempNo", required = false, defaultValue = "") String stuempNo,
+ @RequestParam(value = "syncStatus", required = false, defaultValue = "all") String syncStatus,
+ @RequestParam(value = "operFlag", required = false, defaultValue = "all") String operFlag,
+ @RequestParam(value = "buildingid", required = false, defaultValue = "") String buildingid,
+ @RequestParam(value = "regionid", required = false, defaultValue = "") String regionid,
+ @RequestParam(value = "allocatStartDate", required = false, defaultValue = "") String allocatStartDate,
+ @RequestParam(value = "allocatEndDate", required = false, defaultValue = "") String allocatEndDate,
+ @AuthenticationPrincipal TOperator operUser) {
+ String opertype = operUser.getOpertype();
+ /**
+ * 1.查询值
+ */
+ List<TDoorcardlstInfo> cardList = null;
+ if (!StringUtil.isEmpty(opertype) && (opertype.equals("S") || opertype.equals("P"))) {
+ cardList = webInterfaceService.getSystemCardListMap(factoryId, allocatStartDate, allocatEndDate,
+ doorName, custName, stuempNo, syncStatus, operFlag, buildingid, regionid);
+ } else if (!StringUtil.isEmpty(operUser.getRegionid())) {
+ cardList = webInterfaceService.getOperatorCardListMap(factoryId, allocatStartDate, allocatEndDate,
+ doorName, custName, stuempNo, syncStatus, operFlag, buildingid, regionid, operUser.getRegionid());
}
/**
- * 填充查询门禁列表下拉菜单
- * @return
- * @throws Exception
+ * 2.设置表格属性: title:标题 sheetName:工作簿名 type:表格类型
*/
- @ResponseBody
- @RequestMapping(value = "/getFillFormList")
- public Map getFillFormList(@AuthenticationPrincipal TOperator operUser) throws Exception {
- Map map = new HashMap();
- try {
- String opertype = operUser.getOpertype();
- //名单状态
- List<TDictionaryId> syncDicts = systemService.findTDictionaryByType(3);
- map.put("syncDicts", syncDicts);
- //厂商id
- List<TKey> allFactoryId = webInterfaceService.getAllKeys();
- map.put("allFactoryId", allFactoryId);
- //操作标记
- List<TDictionaryId> operDicts = new ArrayList<TDictionaryId>();
- operDicts.addAll(systemService.findByType(2, "A"));
- operDicts.addAll(systemService.findByType(2, "D"));
- operDicts.addAll(systemService.findByType(2, "C"));
- map.put("operDicts", operDicts);
+ ExportParams params = new ExportParams("设备名单列表", "设备名单", ExcelType.XSSF);
- List<TRegion> regions = null;
- List<TBuilding> buildings = null;
- if (!StringUtil.isEmpty(opertype) &&(opertype.equals("S")||opertype.equals("P"))) {
- regions = systemService.getAllRegions();
- buildings = ncService.getAllBuilding();
- map.put("regions", regions);
- map.put("buildings", buildings);
- }else if (!StringUtil.isEmpty(operUser.getRegionid())){
- regions = systemService.getRegionListById(operUser.getRegionid());
- map.put("regions", regions);
- buildings = systemService.getBuildingByRegionId(operUser.getRegionid());
- map.put("buildings", buildings);
- }
+ modelMap.put(NormalExcelConstants.DATA_LIST, cardList);//设置值
+ modelMap.put(NormalExcelConstants.PARAMS, params);//设置属性
+ modelMap.put(NormalExcelConstants.CLASS, TDoorcardlstInfo.class);
+ modelMap.put(NormalExcelConstants.FILE_NAME, "下发设备名单");
+ PoiBaseView.render(modelMap, request, response, NormalExcelConstants.EASYPOI_EXCEL_VIEW);
- }catch (Exception e){
- e.printStackTrace();
- }
- return map;
+ }
+
+ /**
+ * 重新下发名单
+ *
+ * @param request
+ * @param tDoorcardlstInfos
+ * @return
+ */
+ @ResponseBody
+ @RequestMapping(value = "/reSaveDoorCardList", method = {RequestMethod.POST})
+ public Map reSaveDoorCardList(HttpServletRequest request,
+ @RequestBody TDoorcardlstInfo[] tDoorcardlstInfos) {
+ Map map = new HashMap();
+ String msg = "";
+ try {
+ List<Long> listIds = new ArrayList<>();
+ for (TDoorcardlstInfo tDoorcardlstInfo : tDoorcardlstInfos) {
+ listIds.add(Long.valueOf(tDoorcardlstInfo.getListid()));
+ }
+ webInterfaceService.updateDoorcardlstToNoWithIds(listIds);
+ RedisUtil.incr("zcard_max_version");
+ map.put("result", "重新下发设备名单成功!");
+ } catch (Exception e) {
+ e.printStackTrace();
+ map.put("result", "重新下发设备名单失败!");
+ msg = "重新下发设备名单异常";
+ logger.error("重定向出错:" + e.getMessage());
}
-
- /**
- * 查询设备名单
- * @param request
- * @param factoryId
- * @param doorName
- * @param custName
- * @param stuempNo
- * @param syncStatus
- * @param operFlag
- * @param buildingid
- * @param regionid
- * @param allocatStartDate
- * @param allocatEndDate
- * @param pageNo
- * @param pageSize
- * @param operUser
- * @return
- */
- @ResponseBody
- @RequestMapping(value = "/getAllCardList")
- public Map getAllCardList(HttpServletRequest request,
- @RequestParam(value = "factoryId", required = false, defaultValue = "all") String factoryId,
- @RequestParam(value = "doorName", required = false, defaultValue = "") String doorName,
- @RequestParam(value = "custName", required = false, defaultValue = "") String custName,
- @RequestParam(value = "stuempNo", required = false, defaultValue = "") String stuempNo,
- @RequestParam(value = "syncStatus", required = false, defaultValue = "all") String syncStatus,
- @RequestParam(value = "operFlag", required = false, defaultValue = "all") String operFlag,
- @RequestParam(value = "buildingid", required = false, defaultValue = "") String buildingid,
- @RequestParam(value = "regionid",required = false,defaultValue = "") String regionid,
- @RequestParam(value = "allocatStartDate", required = false, defaultValue = "") String allocatStartDate,
- @RequestParam(value = "allocatEndDate", required = false, defaultValue = "") String allocatEndDate,
- @RequestParam(value = "pageNo", required = false, defaultValue = "1") int pageNo,
- @RequestParam(value = "pageSize", required = false, defaultValue = "15") int pageSize,
- @AuthenticationPrincipal TOperator operUser) {
-
- Map map = new HashMap();
- try {
- String opertype = operUser.getOpertype();
- boolean flag = true;
- Pagination pResult = new Pagination();
- if (!StringUtil.isEmpty(opertype) &&(opertype.equals("S")||opertype.equals("P"))){
- pResult = webInterfaceService.getSystemCardListFrSearch(factoryId, allocatStartDate, allocatEndDate, doorName, custName, stuempNo, syncStatus, operFlag, buildingid, regionid, pageNo, pageSize);
- }else if (!StringUtil.isEmpty(operUser.getRegionid())){
- pResult = webInterfaceService.getOperatorCardListFrSearch(factoryId, allocatStartDate, allocatEndDate, doorName, custName, stuempNo, syncStatus, operFlag, buildingid, regionid, pageNo, pageSize,operUser.getRegionid());
- }
- map.put("PageResult", pResult);
- map.put("index", flag);
- map.put("result", "查询设备名单成功!");
- } catch (Exception e) {
- e.printStackTrace();
- map.put("result", "查询设备名单失败!");
- logger.error("查询设备名单失败:" + e.getMessage());
- }
- return map;
- }
-
- /**
- * 注解方式导出设备名单Excel
- * @param modelMap
- * @param request
- * @param response
- * @param factoryId
- * @param doorName
- * @param custName
- * @param stuempNo
- * @param syncStatus
- * @param operFlag
- * @param buildingid
- * @param regionid
- * @param allocatStartDate
- * @param allocatEndDate
- * @param operUser
- */
- @RequestMapping(value = "/exportExcel", method = RequestMethod.GET)
- public void download(ModelMap modelMap, HttpServletRequest request, HttpServletResponse response,
- @RequestParam(value = "factoryId", required = false, defaultValue = "all") String factoryId,
- @RequestParam(value = "doorName", required = false, defaultValue = "") String doorName,
- @RequestParam(value = "custName", required = false, defaultValue = "") String custName,
- @RequestParam(value = "stuempNo", required = false, defaultValue = "") String stuempNo,
- @RequestParam(value = "syncStatus", required = false, defaultValue = "all") String syncStatus,
- @RequestParam(value = "operFlag", required = false, defaultValue = "all") String operFlag,
- @RequestParam(value = "buildingid", required = false, defaultValue = "") String buildingid,
- @RequestParam(value = "regionid",required = false,defaultValue = "") String regionid,
- @RequestParam(value = "allocatStartDate", required = false, defaultValue = "") String allocatStartDate,
- @RequestParam(value = "allocatEndDate", required = false, defaultValue = "") String allocatEndDate,
- @AuthenticationPrincipal TOperator operUser) {
- String opertype = operUser.getOpertype();
- /**
- * 1.查询值
- */
- List<TDoorcardlstInfo> cardList = null;
- if (!StringUtil.isEmpty(opertype) &&(opertype.equals("S")||opertype.equals("P"))) {
- cardList=webInterfaceService.getSystemCardListMap(factoryId, allocatStartDate, allocatEndDate,
- doorName, custName, stuempNo, syncStatus, operFlag, buildingid, regionid);
- }else if (!StringUtil.isEmpty(operUser.getRegionid())){
- cardList = webInterfaceService.getOperatorCardListMap(factoryId, allocatStartDate, allocatEndDate,
- doorName, custName, stuempNo, syncStatus, operFlag, buildingid, regionid,operUser.getRegionid());
- }
-
- /**
- * 2.设置表格属性: title:标题 sheetName:工作簿名 type:表格类型
- */
- ExportParams params = new ExportParams("设备名单列表", "设备名单", ExcelType.XSSF);
-
- modelMap.put(NormalExcelConstants.DATA_LIST, cardList);//设置值
- modelMap.put(NormalExcelConstants.PARAMS, params);//设置属性
- modelMap.put(NormalExcelConstants.CLASS, TDoorcardlstInfo.class);
- modelMap.put(NormalExcelConstants.FILE_NAME, "下发设备名单");
- PoiBaseView.render(modelMap, request, response, NormalExcelConstants.EASYPOI_EXCEL_VIEW);
-
- }
-
- /**
- * 重新下发名单
- * @param request
- * @param tDoorcardlstInfos
- * @return
- */
- @ResponseBody
- @RequestMapping(value = "/reSaveDoorCardList", method = {RequestMethod.POST})
- public Map reSaveDoorCardList(HttpServletRequest request,
- @RequestBody TDoorcardlstInfo[] tDoorcardlstInfos){
- Map map = new HashMap();
- String msg = "";
- try {
- List<Long> listIds = new ArrayList<>();
- for (TDoorcardlstInfo tDoorcardlstInfo:tDoorcardlstInfos){
- listIds.add(Long.valueOf(tDoorcardlstInfo.getListid()));
- }
- webInterfaceService.updateDoorcardlstToNoWithIds(listIds);
- RedisUtil.incr("zcard_max_version");
- map.put("result","重新下发设备名单成功!");
- }catch (Exception e){
- e.printStackTrace();
- map.put("result","重新下发设备名单失败!");
- msg = "重新下发设备名单异常";
- logger.error("重定向出错:"+e.getMessage());
- }
- map.put("msg",msg);
- return map;
- }
+ map.put("msg", msg);
+ return map;
+ }
}
diff --git a/src/main/java/com/supwisdom/dlpay/ncmgr/controller/NcMgrController.java b/src/main/java/com/supwisdom/dlpay/ncmgr/controller/NcMgrController.java
index f339ef6..030ea46 100644
--- a/src/main/java/com/supwisdom/dlpay/ncmgr/controller/NcMgrController.java
+++ b/src/main/java/com/supwisdom/dlpay/ncmgr/controller/NcMgrController.java
@@ -12,7 +12,8 @@
import com.supwisdom.dlpay.system.page.Pagination;
import com.supwisdom.dlpay.system.service.SystemService;
import com.supwisdom.dlpay.util.RedisUtil;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
@@ -28,7 +29,7 @@
@Controller
@RequestMapping("/ncmgr")
public class NcMgrController {
- protected static Logger logger = Logger.getLogger(NcMgrController.class);
+ protected static Logger logger = LoggerFactory.getLogger(NcMgrController.class);
@Autowired
private NcService ncService;
diff --git a/src/main/java/com/supwisdom/dlpay/system/controller/SystemController.java b/src/main/java/com/supwisdom/dlpay/system/controller/SystemController.java
index 5e80929..5066fd6 100644
--- a/src/main/java/com/supwisdom/dlpay/system/controller/SystemController.java
+++ b/src/main/java/com/supwisdom/dlpay/system/controller/SystemController.java
@@ -1,6 +1,5 @@
package com.supwisdom.dlpay.system.controller;
-import com.google.gson.Gson;
import com.supwisdom.dlpay.framework.domain.TOperator;
import com.supwisdom.dlpay.framework.util.DateUtil;
import com.supwisdom.dlpay.framework.util.StringUtil;
@@ -14,7 +13,8 @@
import com.supwisdom.dlpay.system.page.Pagination;
import com.supwisdom.dlpay.system.service.SystemService;
import com.supwisdom.dlpay.util.RedisUtil;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
@@ -30,7 +30,7 @@
@Controller
@RequestMapping("/system")
public class SystemController {
- protected static Logger logger = Logger.getLogger(SystemController.class);
+ protected static Logger logger = LoggerFactory.getLogger(SystemController.class);
@Autowired
private SystemService systemService;
diff --git a/src/main/java/com/supwisdom/dlpay/util/RedisUtil.java b/src/main/java/com/supwisdom/dlpay/util/RedisUtil.java
index 2661536..43859f5 100644
--- a/src/main/java/com/supwisdom/dlpay/util/RedisUtil.java
+++ b/src/main/java/com/supwisdom/dlpay/util/RedisUtil.java
@@ -1,7 +1,6 @@
package com.supwisdom.dlpay.util;
-
import com.supwisdom.dlpay.system.bean.PropertiesBean;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
@@ -10,521 +9,527 @@
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
-import java.io.IOException;
import java.util.*;
public class RedisUtil {
- private static final Logger log = LoggerFactory.getLogger(RedisUtil.class);
- //等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时。如果超过等待时间,则直接抛出JedisConnectionException;
- private static int MAX_WAIT = 30 * 1000;
- //超时时间
- private static int TIMEOUT = 10 * 1000;
+ private static final Logger log = LoggerFactory.getLogger(RedisUtil.class);
+ //等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时。如果超过等待时间,则直接抛出JedisConnectionException;
+ private static int MAX_WAIT = 30 * 1000;
+ //超时时间
+ private static int TIMEOUT = 10 * 1000;
- private static String host;
- private static int port;
- private static String password;
+ private static String host;
+ private static int port;
+ private static String password;
- private static JedisPool jedisPool = null;
+ private static JedisPool jedisPool = null;
+ /**
+ * Jedis实例获取返回码
+ *
+ * @author jqlin
+ */
+ public static class JedisStatus {
/**
- * Jedis实例获取返回码
- *
- * @author jqlin
- *
+ * Jedis实例获取失败
*/
- public static class JedisStatus{
- /**Jedis实例获取失败*/
- public static final long FAIL_LONG = -5L;
- /**Jedis实例获取失败*/
- public static final int FAIL_INT = -5;
- /**Jedis实例获取失败*/
- public static final String FAIL_STRING = "-5";
- }
-
-
- private static void initialPool() {
- try {
- JedisPoolConfig config = new JedisPoolConfig();
- //最大连接数,如果赋值为-1,则表示不限制;如果pool已经分配了maxActive个jedis实例,则此时pool的状态为exhausted(耗尽)。
- config.setMaxTotal(3000);
- //最大空闲数,控制一个pool最多有多少个状态为idle(空闲的)的jedis实例,默认值也是8。
- config.setMaxIdle(300);
- //最小空闲数
- config.setMinIdle(20);
- //是否在从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个
- config.setTestOnBorrow(true);
- //在return给pool时,是否提前进行validate操作
- config.setTestOnReturn(true);
- //在空闲时检查有效性,默认false
- config.setTestWhileIdle(true);
- config.setBlockWhenExhausted(false);
- //表示一个对象至少停留在idle状态的最短时间,然后才能被idle object evitor扫描并驱逐;
- //这一项只有在timeBetweenEvictionRunsMillis大于0时才有意义
- config.setMinEvictableIdleTimeMillis(30000);
- //表示idle object evitor两次扫描之间要sleep的毫秒数
- config.setTimeBetweenEvictionRunsMillis(60000);
- //表示idle object evitor每次扫描的最多的对象数
- config.setNumTestsPerEvictionRun(1000);
- //等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时。如果超过等待时间,则直接抛出JedisConnectionException;
- config.setMaxWaitMillis(MAX_WAIT);
-
-
- if (StringUtils.isNotBlank(password)) {
- jedisPool = new JedisPool(config, host, port, TIMEOUT, password);
- log.info("host:"+host+"port:"+port+"password:"+password);
- } else {
- jedisPool = new JedisPool(config, host, port, TIMEOUT);
- log.info("host:"+host+"port:"+port);
- }
- } catch (Exception e) {
- if(jedisPool != null){
- jedisPool.close();
- }
- log.error("初始化Redis连接池失败", e);
- }
- }
-
+ public static final long FAIL_LONG = -5L;
/**
- * 初始化Redis连接池
+ * Jedis实例获取失败
*/
- static {
- PropertiesBean propertiesBean = SpringContextUtil.getBean(PropertiesBean.class);
- host=propertiesBean.getHost();
- port=propertiesBean.getPort();
- password=propertiesBean.getPassword();
- initialPool();
- }
-
+ public static final int FAIL_INT = -5;
/**
- * 在多线程环境同步初始化
+ * Jedis实例获取失败
*/
- private static synchronized void poolInit() {
- if (jedisPool == null) {
- initialPool();
- }
+ public static final String FAIL_STRING = "-5";
+ }
+
+
+ private static void initialPool() {
+ try {
+ JedisPoolConfig config = new JedisPoolConfig();
+ //最大连接数,如果赋值为-1,则表示不限制;如果pool已经分配了maxActive个jedis实例,则此时pool的状态为exhausted(耗尽)。
+ config.setMaxTotal(3000);
+ //最大空闲数,控制一个pool最多有多少个状态为idle(空闲的)的jedis实例,默认值也是8。
+ config.setMaxIdle(300);
+ //最小空闲数
+ config.setMinIdle(20);
+ //是否在从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个
+ config.setTestOnBorrow(true);
+ //在return给pool时,是否提前进行validate操作
+ config.setTestOnReturn(true);
+ //在空闲时检查有效性,默认false
+ config.setTestWhileIdle(true);
+ config.setBlockWhenExhausted(false);
+ //表示一个对象至少停留在idle状态的最短时间,然后才能被idle object evitor扫描并驱逐;
+ //这一项只有在timeBetweenEvictionRunsMillis大于0时才有意义
+ config.setMinEvictableIdleTimeMillis(30000);
+ //表示idle object evitor两次扫描之间要sleep的毫秒数
+ config.setTimeBetweenEvictionRunsMillis(60000);
+ //表示idle object evitor每次扫描的最多的对象数
+ config.setNumTestsPerEvictionRun(1000);
+ //等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时。如果超过等待时间,则直接抛出JedisConnectionException;
+ config.setMaxWaitMillis(MAX_WAIT);
+
+
+ if (StringUtils.isNotBlank(password)) {
+ jedisPool = new JedisPool(config, host, port, TIMEOUT, password);
+ log.info("host:" + host + "port:" + port + "password:" + password);
+ } else {
+ jedisPool = new JedisPool(config, host, port, TIMEOUT);
+ log.info("host:" + host + "port:" + port);
+ }
+ } catch (Exception e) {
+ if (jedisPool != null) {
+ jedisPool.close();
+ }
+ log.error("初始化Redis连接池失败", e);
+ }
+ }
+
+ /**
+ * 初始化Redis连接池
+ */
+ static {
+ PropertiesBean propertiesBean = SpringContextUtil.getBean(PropertiesBean.class);
+ host = propertiesBean.getHost();
+ port = propertiesBean.getPort();
+ password = propertiesBean.getPassword();
+ initialPool();
+ }
+
+ /**
+ * 在多线程环境同步初始化
+ */
+ private static synchronized void poolInit() {
+ if (jedisPool == null) {
+ initialPool();
+ }
+ }
+
+ /**
+ * 同步获取Jedis实例
+ *
+ * @return Jedis
+ */
+ public static Jedis getJedis() {
+ if (jedisPool == null) {
+ poolInit();
}
- /**
- * 同步获取Jedis实例
- *
- * @return Jedis
- */
- public static Jedis getJedis() {
- if (jedisPool == null) {
- poolInit();
- }
-
- Jedis jedis = null;
- try {
- if (jedisPool != null) {
- jedis = jedisPool.getResource();
- }
- } catch (Exception e) {
- log.error("同步获取Jedis实例失败" + e.getMessage(), e);
- returnBrokenResource(jedis);
- }
-
- return jedis;
+ Jedis jedis = null;
+ try {
+ if (jedisPool != null) {
+ jedis = jedisPool.getResource();
+ }
+ } catch (Exception e) {
+ log.error("同步获取Jedis实例失败" + e.getMessage(), e);
+ returnBrokenResource(jedis);
}
- /**
- * 释放jedis资源
- *
- * @param jedis
- */
- @SuppressWarnings("deprecation")
- public static void returnResource(final Jedis jedis) {
- if (jedis != null && jedisPool != null) {
- jedisPool.returnResource(jedis);
- }
+ return jedis;
+ }
+
+ /**
+ * 释放jedis资源
+ *
+ * @param jedis
+ */
+ @SuppressWarnings("deprecation")
+ public static void returnResource(final Jedis jedis) {
+ if (jedis != null && jedisPool != null) {
+ jedisPool.returnResource(jedis);
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ public static void returnBrokenResource(final Jedis jedis) {
+ if (jedis != null && jedisPool != null) {
+ jedisPool.returnBrokenResource(jedis);
+ jedisPool.close();
+ }
+ }
+
+ /**
+ * 设置值
+ *
+ * @param key
+ * @param value
+ * @return -5:Jedis实例获取失败<br/>OK:操作成功<br/>null:操作失败
+ * @author jqlin
+ */
+ public static String set(String key, String value) {
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return JedisStatus.FAIL_STRING;
}
- @SuppressWarnings("deprecation")
- public static void returnBrokenResource(final Jedis jedis) {
- if (jedis != null && jedisPool != null) {
- jedisPool.returnBrokenResource(jedis);
- jedisPool.close();
- }
+ String result = null;
+ try {
+ result = jedis.set(key, value);
+ } catch (Exception e) {
+ log.error("设置值失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
}
- /**
- * 设置值
- *
- * @param key
- * @param value
- * @return -5:Jedis实例获取失败<br/>OK:操作成功<br/>null:操作失败
- * @author jqlin
- */
- public static String set(String key, String value) {
- Jedis jedis = getJedis();
- if(jedis == null){
- return JedisStatus.FAIL_STRING;
- }
+ return result;
+ }
- String result = null;
- try {
- result = jedis.set(key, value);
- } catch (Exception e) {
- log.error("设置值失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ /**
+ * 设置值
+ *
+ * @param key
+ * @param value
+ * @param expire 过期时间,单位:秒
+ * @return -5:Jedis实例获取失败<br/>OK:操作成功<br/>null:操作失败
+ * @author jqlin
+ */
+ public static String set(String key, String value, int expire) {
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return JedisStatus.FAIL_STRING;
}
- /**
- * 设置值
- *
- * @param key
- * @param value
- * @param expire 过期时间,单位:秒
- * @return -5:Jedis实例获取失败<br/>OK:操作成功<br/>null:操作失败
- * @author jqlin
- */
- public static String set(String key, String value, int expire) {
- Jedis jedis = getJedis();
- if(jedis == null){
- return JedisStatus.FAIL_STRING;
- }
-
- String result = null;
- try {
- result = jedis.set(key, value);
- jedis.expire(key, expire);
- } catch (Exception e) {
- log.error("设置值失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ String result = null;
+ try {
+ result = jedis.set(key, value);
+ jedis.expire(key, expire);
+ } catch (Exception e) {
+ log.error("设置值失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
}
- /**
- * 获取值
- *
- * @param key
- * @return
- * @author jqlin
- */
- public static String get(String key) {
- Jedis jedis = getJedis();
- if(jedis == null){
- return JedisStatus.FAIL_STRING;
- }
+ return result;
+ }
- String result = null;
- try {
- result = jedis.get(key);
- } catch (Exception e) {
- log.error("获取值失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ /**
+ * 获取值
+ *
+ * @param key
+ * @return
+ * @author jqlin
+ */
+ public static String get(String key) {
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return JedisStatus.FAIL_STRING;
}
- /**
- * 递减指令:decr(默认从0开始,递减会出现负数,这点跟memcache不一样,mc到0)
- * @param key
- * @return
- */
- public static Long decr(String key) {
- long result = JedisStatus.FAIL_LONG;
-
- Jedis jedis = getJedis();
- if(jedis == null){
- return result;
- }
- try {
- result = jedis.decr(key);
- } catch (Exception e) {
- log.error("redis decr error and key = " + key, e);
- }finally {
- returnResource(jedis);
- }
- return result;
+ String result = null;
+ try {
+ result = jedis.get(key);
+ } catch (Exception e) {
+ log.error("获取值失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
}
- /**
- * 获取自增id
- * 该方法单机每秒并发在1100左右
- * @param key 键
- * @return 值
- */
- public static long incr(String key) {
- long value = 0L;
- Jedis jedis = null;
- try {
- jedis = getJedis();
- value=jedis.incr(key);
- } catch (Exception e) {
- log.debug("incrementAndGet,key="+key, e);
- } finally {
- returnResource(jedis);
- }
- return value;
+ return result;
+ }
+
+ /**
+ * 递减指令:decr(默认从0开始,递减会出现负数,这点跟memcache不一样,mc到0)
+ *
+ * @param key
+ * @return
+ */
+ public static Long decr(String key) {
+ long result = JedisStatus.FAIL_LONG;
+
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return result;
+ }
+ try {
+ result = jedis.decr(key);
+ } catch (Exception e) {
+ log.error("redis decr error and key = " + key, e);
+ } finally {
+ returnResource(jedis);
+ }
+ return result;
+ }
+
+ /**
+ * 获取自增id
+ * 该方法单机每秒并发在1100左右
+ *
+ * @param key 键
+ * @return 值
+ */
+ public static long incr(String key) {
+ long value = 0L;
+ Jedis jedis = null;
+ try {
+ jedis = getJedis();
+ value = jedis.incr(key);
+ } catch (Exception e) {
+ log.debug("incrementAndGet,key=" + key, e);
+ } finally {
+ returnResource(jedis);
+ }
+ return value;
+ }
+
+ /**
+ * 自增长指定的值
+ *
+ * @param key
+ * @param val
+ * @return
+ */
+ public static long incrby(String key, long val) {
+ long value = 0L;
+ Jedis jedis = null;
+ try {
+ jedis = getJedis();
+ value = jedis.incrBy(key, val);
+ } catch (Exception e) {
+ log.debug("incrementAndGet,key=" + key, e);
+ } finally {
+ returnResource(jedis);
+ }
+ return value;
+ }
+
+ /**
+ * 设置key的过期时间
+ *
+ * @param key
+ * @param seconds -5:Jedis实例获取失败,1:成功,0:失败
+ * @return
+ * @author jqlin
+ */
+ public static long expire(String key, int seconds) {
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return JedisStatus.FAIL_LONG;
}
- /**
- * 自增长指定的值
- * @param key
- * @param val
- * @return
- */
- public static long incrby(String key,long val) {
- long value = 0L;
- Jedis jedis = null;
- try {
- jedis = getJedis();
- value=jedis.incrBy(key,val);
- } catch (Exception e) {
- log.debug("incrementAndGet,key="+key, e);
- } finally {
- returnResource(jedis);
- }
- return value;
+ long result = 0;
+ try {
+ result = jedis.expire(key, seconds);
+ } catch (Exception e) {
+ log.error(String.format("设置key=%s的过期时间失败:%s", key, e.getMessage()), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
}
- /**
- * 设置key的过期时间
- *
- * @param key
- * @param seconds -5:Jedis实例获取失败,1:成功,0:失败
- * @return
- * @author jqlin
- */
- public static long expire(String key, int seconds) {
- Jedis jedis = getJedis();
- if(jedis == null){
- return JedisStatus.FAIL_LONG;
- }
+ return result;
+ }
- long result = 0;
- try {
- result = jedis.expire(key, seconds);
- } catch (Exception e) {
- log.error(String.format("设置key=%s的过期时间失败:" + e.getMessage(), key), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ /**
+ * 判断key是否存在
+ *
+ * @param key
+ * @return
+ * @author jqlin
+ */
+ public static boolean exists(String key) {
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ log.warn("Jedis实例获取为空");
+ return false;
}
- /**
- * 判断key是否存在
- *
- * @param key
- * @return
- * @author jqlin
- */
- public static boolean exists(String key) {
- Jedis jedis = getJedis();
- if(jedis == null){
- log.warn("Jedis实例获取为空");
- return false;
- }
-
- boolean result = false;
- try {
- result = jedis.exists(key);
- } catch (Exception e) {
- log.error(String.format("判断key=%s是否存在失败:" + e.getMessage(), key), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ boolean result = false;
+ try {
+ result = jedis.exists(key);
+ } catch (Exception e) {
+ log.error(String.format("判断key=%s是否存在失败:" + e.getMessage(), key), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
}
- /**
- * 删除key
- *
- * @param keys
- * @return -5:Jedis实例获取失败,1:成功,0:失败
- * @author jqlin
- */
- public static long del(String... keys) {
- Jedis jedis = getJedis();
- if(jedis == null){
- return JedisStatus.FAIL_LONG;
- }
+ return result;
+ }
- long result = JedisStatus.FAIL_LONG;
- try {
- result = jedis.del(keys);
- } catch (Exception e) {
- log.error(String.format("删除key=%s失败:" + e.getMessage(), keys), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ /**
+ * 删除key
+ *
+ * @param keys
+ * @return -5:Jedis实例获取失败,1:成功,0:失败
+ * @author jqlin
+ */
+ public static long del(String... keys) {
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return JedisStatus.FAIL_LONG;
}
- /**
- * set if not exists,若key已存在,则setnx不做任何操作
- *
- * @param key
- * @param value key已存在,1:key赋值成功
- * @return
- * @author jqlin
- */
- public static long setnx(String key, String value) {
- long result = JedisStatus.FAIL_LONG;
-
- Jedis jedis = getJedis();
- if(jedis == null){
- return result;
- }
-
- try {
- result = jedis.setnx(key, value);
- } catch (Exception e) {
- log.error("设置值失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ long result = JedisStatus.FAIL_LONG;
+ try {
+ result = jedis.del(keys);
+ } catch (Exception e) {
+ log.error(String.format("删除key=%s失败:%s", keys, e.getMessage()), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
}
- /**
- * set if not exists,若key已存在,则setnx不做任何操作
- *
- * @param key
- * @param value key已存在,1:key赋值成功
- * @param expire 过期时间,单位:秒
- * @return
- * @author jqlin
- */
- public static long setnx(String key, String value, int expire) {
- long result = JedisStatus.FAIL_LONG;
+ return result;
+ }
- Jedis jedis = getJedis();
- if(jedis == null){
- return result;
- }
+ /**
+ * set if not exists,若key已存在,则setnx不做任何操作
+ *
+ * @param key
+ * @param value key已存在,1:key赋值成功
+ * @return
+ * @author jqlin
+ */
+ public static long setnx(String key, String value) {
+ long result = JedisStatus.FAIL_LONG;
- try {
- result = jedis.setnx(key, value);
- jedis.expire(key, expire);
- } catch (Exception e) {
- log.error("设置值失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return result;
}
-
- /**
- * 在列表key的头部插入元素
- *
- * @param key
- * @param values -5:Jedis实例获取失败,>0:返回操作成功的条数,0:失败
- * @return
- * @author jqlin
- */
- public static long lpush(String key, String... values) {
- long result = JedisStatus.FAIL_LONG;
-
- Jedis jedis = getJedis();
- if(jedis == null){
- return result;
- }
-
- try {
- result = jedis.lpush(key, values);
- } catch (Exception e) {
- log.error("在列表key的头部插入元素失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ try {
+ result = jedis.setnx(key, value);
+ } catch (Exception e) {
+ log.error("设置值失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
}
- /**
- * 在列表key的尾部插入元素
- *
- * @param key
- * @param values -5:Jedis实例获取失败,>0:返回操作成功的条数,0:失败
- * @return
- * @author jqlin
- */
- public static long rpush(String key, String... values) {
- long result = JedisStatus.FAIL_LONG;
+ return result;
+ }
- Jedis jedis = getJedis();
- if(jedis == null){
- return result;
- }
+ /**
+ * set if not exists,若key已存在,则setnx不做任何操作
+ *
+ * @param key
+ * @param value key已存在,1:key赋值成功
+ * @param expire 过期时间,单位:秒
+ * @return
+ * @author jqlin
+ */
+ public static long setnx(String key, String value, int expire) {
+ long result = JedisStatus.FAIL_LONG;
- try {
- result = jedis.rpush(key, values);
- } catch (Exception e) {
- log.error("在列表key的尾部插入元素失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return result;
}
- /**
- * 返回存储在key列表的特定元素
- *
- *
- * @param key
- * @param start 开始索引,索引从0开始,0表示第一个元素,1表示第二个元素
- * @param end 结束索引,-1表示最后一个元素,-2表示倒数第二个元素
- * @return redis client获取失败返回null
- * @author jqlin
- */
- public static List<String> lrange(String key, long start, long end) {
- Jedis jedis = getJedis();
- if(jedis == null){
- return null;
- }
-
- List<String> result = null;
- try {
- result = jedis.lrange(key, start, end);
- } catch (Exception e) {
- log.error("查询列表元素失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ try {
+ result = jedis.setnx(key, value);
+ jedis.expire(key, expire);
+ } catch (Exception e) {
+ log.error("设置值失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
}
- /**
- * 获取List缓存对象
- *
- * @param key
- * @param start
- * @param end
- * @return List<T> 返回类型
- * @author jqlin
- */
+ return result;
+ }
+
+
+ /**
+ * 在列表key的头部插入元素
+ *
+ * @param key
+ * @param values -5:Jedis实例获取失败,>0:返回操作成功的条数,0:失败
+ * @return
+ * @author jqlin
+ */
+ public static long lpush(String key, String... values) {
+ long result = JedisStatus.FAIL_LONG;
+
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return result;
+ }
+
+ try {
+ result = jedis.lpush(key, values);
+ } catch (Exception e) {
+ log.error("在列表key的头部插入元素失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
+ }
+
+ return result;
+ }
+
+ /**
+ * 在列表key的尾部插入元素
+ *
+ * @param key
+ * @param values -5:Jedis实例获取失败,>0:返回操作成功的条数,0:失败
+ * @return
+ * @author jqlin
+ */
+ public static long rpush(String key, String... values) {
+ long result = JedisStatus.FAIL_LONG;
+
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return result;
+ }
+
+ try {
+ result = jedis.rpush(key, values);
+ } catch (Exception e) {
+ log.error("在列表key的尾部插入元素失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
+ }
+
+ return result;
+ }
+
+ /**
+ * 返回存储在key列表的特定元素
+ *
+ * @param key
+ * @param start 开始索引,索引从0开始,0表示第一个元素,1表示第二个元素
+ * @param end 结束索引,-1表示最后一个元素,-2表示倒数第二个元素
+ * @return redis client获取失败返回null
+ * @author jqlin
+ */
+ public static List<String> lrange(String key, long start, long end) {
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return null;
+ }
+
+ List<String> result = null;
+ try {
+ result = jedis.lrange(key, start, end);
+ } catch (Exception e) {
+ log.error("查询列表元素失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
+ }
+
+ return result;
+ }
+
+ /**
+ * 获取List缓存对象
+ *
+ * @param key
+ * @param start
+ * @param end
+ * @return List<T> 返回类型
+ * @author jqlin
+ */
// public static <T> List<T> range(String key, long start, long end, Class<T> clazz){
// List<String> dataList = lrange(key, start, end);
// if(CollectionUtils.isEmpty(dataList)){
@@ -534,149 +539,149 @@
// return JavaJsonConvert.json2List(dataList.toString(), clazz);
// }
- /**
- * 获取列表长度
- *
- * @param key -5:Jedis实例获取失败
- * @return
- * @author jqlin
- */
- public static long llen(String key) {
- Jedis jedis = getJedis();
- if(jedis == null){
- return JedisStatus.FAIL_LONG;
- }
-
- long result = 0;
- try {
- result = jedis.llen(key);
- } catch (Exception e) {
- log.error("获取列表长度失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ /**
+ * 获取列表长度
+ *
+ * @param key -5:Jedis实例获取失败
+ * @return
+ * @author jqlin
+ */
+ public static long llen(String key) {
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return JedisStatus.FAIL_LONG;
}
- /**
- * 移除等于value的元素<br/><br/>
- * 当count>0时,从表头开始查找,移除count个;<br/>
- * 当count=0时,从表头开始查找,移除所有等于value的;<br/>
- * 当count<0时,从表尾开始查找,移除count个
- *
- * @param key
- * @param count
- * @param value
- * @return -5:Jedis实例获取失败
- * @author jqlin
- */
- public static long lrem(String key, long count, String value) {
- Jedis jedis = getJedis();
- if(jedis == null){
- return JedisStatus.FAIL_LONG;
- }
-
- long result = 0;
- try {
- result = jedis.lrem(key, count, value);
- } catch (Exception e) {
- log.error("获取列表长度失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ long result = 0;
+ try {
+ result = jedis.llen(key);
+ } catch (Exception e) {
+ log.error("获取列表长度失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
}
- /**
- * 对列表进行修剪
- *
- * @param key
- * @param start
- * @param end
- * @return -5:Jedis实例获取失败,OK:命令执行成功
- * @author jqlin
- */
- public static String ltrim(String key, long start, long end) {
- Jedis jedis = getJedis();
- if(jedis == null){
- return JedisStatus.FAIL_STRING;
- }
+ return result;
+ }
- String result = "";
- try {
- result = jedis.ltrim(key, start, end);
- } catch (Exception e) {
- log.error("获取列表长度失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ /**
+ * 移除等于value的元素<br/><br/>
+ * 当count>0时,从表头开始查找,移除count个;<br/>
+ * 当count=0时,从表头开始查找,移除所有等于value的;<br/>
+ * 当count<0时,从表尾开始查找,移除count个
+ *
+ * @param key
+ * @param count
+ * @param value
+ * @return -5:Jedis实例获取失败
+ * @author jqlin
+ */
+ public static long lrem(String key, long count, String value) {
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return JedisStatus.FAIL_LONG;
}
- /**
- * 设置对象
- *
- * @param key
- * @param obj
- * @return
- * @author jqlin
- */
- public static <T> String setObject(String key ,T obj){
- Jedis jedis = getJedis();
- if(jedis == null){
- return JedisStatus.FAIL_STRING;
- }
-
- String result = null;
- try {
- byte[] data=SerializeUtil.serialize(obj);
- result = jedis.set(key.getBytes(), data);
- } catch (Exception e) {
- log.error("设置对象失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ long result = 0;
+ try {
+ result = jedis.lrem(key, count, value);
+ } catch (Exception e) {
+ log.error("获取列表长度失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
}
- /**
- * 获取对象
- *
- * @param key
- * @return
- * @author jqlin
- */
- @SuppressWarnings("unchecked")
- public static <T> T getObject(String key){
- Jedis jedis = getJedis();
- if(jedis == null){
- return null;
- }
+ return result;
+ }
- T result = null;
- try {
- byte[] data = jedis.get(key.getBytes());
- if(data != null && data.length > 0){
- result=(T)SerializeUtil.deserialize(data);
- }
- } catch (Exception e) {
- log.error("获取对象失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ /**
+ * 对列表进行修剪
+ *
+ * @param key
+ * @param start
+ * @param end
+ * @return -5:Jedis实例获取失败,OK:命令执行成功
+ * @author jqlin
+ */
+ public static String ltrim(String key, long start, long end) {
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return JedisStatus.FAIL_STRING;
}
+ String result = "";
+ try {
+ result = jedis.ltrim(key, start, end);
+ } catch (Exception e) {
+ log.error("获取列表长度失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
+ }
+
+ return result;
+ }
+
+ /**
+ * 设置对象
+ *
+ * @param key
+ * @param obj
+ * @return
+ * @author jqlin
+ */
+ public static <T> String setObject(String key, T obj) {
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return JedisStatus.FAIL_STRING;
+ }
+
+ String result = null;
+ try {
+ byte[] data = SerializeUtil.serialize(obj);
+ result = jedis.set(key.getBytes(), data);
+ } catch (Exception e) {
+ log.error("设置对象失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
+ }
+
+ return result;
+ }
+
+ /**
+ * 获取对象
+ *
+ * @param key
+ * @return
+ * @author jqlin
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T getObject(String key) {
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return null;
+ }
+
+ T result = null;
+ try {
+ byte[] data = jedis.get(key.getBytes());
+ if (data != null && data.length > 0) {
+ result = (T) SerializeUtil.deserialize(data);
+ }
+ } catch (Exception e) {
+ log.error("获取对象失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
+ }
+
+ return result;
+ }
+
// /**
// * 设置List集合(慎用)
// *
@@ -742,216 +747,216 @@
// return null;
// }
- /**
- * 缓存Map赋值
- *
- * @param key
- * @param field
- * @param value
- * @return -5:Jedis实例获取失败
- * @author jqlin
- */
- public static long hset(String key, String field, String value) {
- Jedis jedis = getJedis();
- if(jedis == null){
- return JedisStatus.FAIL_LONG;
- }
-
- long result = 0L;
- try {
- result = jedis.hset(key, field, value);
- } catch (Exception e) {
- log.error("缓存Map赋值失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ /**
+ * 缓存Map赋值
+ *
+ * @param key
+ * @param field
+ * @param value
+ * @return -5:Jedis实例获取失败
+ * @author jqlin
+ */
+ public static long hset(String key, String field, String value) {
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return JedisStatus.FAIL_LONG;
}
-
- /**
- * 获取缓存的Map值
- *
- * @param key
- * @return
- */
- public static String hget(String key, String field){
- Jedis jedis = getJedis();
- if(jedis == null){
- return null;
- }
-
- String result = null;
- try {
- result = jedis.hget(key, field);
- } catch (Exception e) {
- log.error("获取缓存的Map值失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return result;
+ long result = 0L;
+ try {
+ result = jedis.hset(key, field, value);
+ } catch (Exception e) {
+ log.error("缓存Map赋值失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
}
- /**
- * 获取map所有的字段和值
- *
- * @param key
- * @return
- * @author jqlin
- */
- public static Map<String, String> hgetAll(String key){
- Map<String, String> map = new HashMap<String, String>();
+ return result;
+ }
- Jedis jedis = getJedis();
- if(jedis == null){
- log.warn("Jedis实例获取为空");
- return map;
- }
- try {
- map = jedis.hgetAll(key);
- } catch (Exception e) {
- log.error("获取map所有的字段和值失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return map;
+ /**
+ * 获取缓存的Map值
+ *
+ * @param key
+ * @return
+ */
+ public static String hget(String key, String field) {
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ return null;
}
- /**
- * 查看哈希表 key 中,指定的field字段是否存在。
- *
- * @param key
- * @param field
- * @return
- * @author jqlin
- */
- public static Boolean hexists(String key, String field){
- Jedis jedis = getJedis();
- if(jedis == null){
- log.warn("Jedis实例获取为空");
- return null;
- }
-
- try {
- return jedis.hexists(key, field);
- } catch (Exception e) {
- log.error("查看哈希表field字段是否存在失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return null;
+ String result = null;
+ try {
+ result = jedis.hget(key, field);
+ } catch (Exception e) {
+ log.error("获取缓存的Map值失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
}
- /**
- * 获取所有哈希表中的字段
- *
- * @param key
- * @return
- * @author jqlin
- */
- public static Set<String> hkeys(String key) {
- Set<String> set = new HashSet<String>();
- Jedis jedis = getJedis();
- if(jedis == null){
- log.warn("Jedis实例获取为空");
- return set;
- }
+ return result;
+ }
- try {
- return jedis.hkeys(key);
- } catch (Exception e) {
- log.error("获取所有哈希表中的字段失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
+ /**
+ * 获取map所有的字段和值
+ *
+ * @param key
+ * @return
+ * @author jqlin
+ */
+ public static Map<String, String> hgetAll(String key) {
+ Map<String, String> map = new HashMap<String, String>();
- return null;
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ log.warn("Jedis实例获取为空");
+ return map;
}
- /**
- * 获取所有哈希表中的值
- *
- * @param key
- * @return
- * @author jqlin
- */
- public static List<String> hvals(String key) {
- List<String> list = new ArrayList<String>();
- Jedis jedis = getJedis();
- if(jedis == null){
- log.warn("Jedis实例获取为空");
- return list;
- }
-
- try {
- return jedis.hvals(key);
- } catch (Exception e) {
- log.error("获取所有哈希表中的值失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return null;
+ try {
+ map = jedis.hgetAll(key);
+ } catch (Exception e) {
+ log.error("获取map所有的字段和值失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
}
- /**
- * 从哈希表 key 中删除指定的field
- *
- * @param key
- * @param fields
- * @return
- * @author jqlin
- */
- public static long hdel(String key, String... fields){
- Jedis jedis = getJedis();
- if(jedis == null){
- log.warn("Jedis实例获取为空");
- return JedisStatus.FAIL_LONG;
- }
+ return map;
+ }
- try {
- return jedis.hdel(key, fields);
- } catch (Exception e) {
- log.error("map删除指定的field失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return 0;
+ /**
+ * 查看哈希表 key 中,指定的field字段是否存在。
+ *
+ * @param key
+ * @param field
+ * @return
+ * @author jqlin
+ */
+ public static Boolean hexists(String key, String field) {
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ log.warn("Jedis实例获取为空");
+ return null;
}
- public static Set<String> keys(String pattern){
- Set<String> keyList = new HashSet<String>();
- Jedis jedis = getJedis();
- if(jedis == null){
- log.warn("Jedis实例获取为空");
- return keyList;
- }
-
- try {
- keyList = jedis.keys(pattern);
- } catch (Exception e) {
- log.error("操作keys失败:" + e.getMessage(), e);
- returnBrokenResource(jedis);
- } finally {
- returnResource(jedis);
- }
-
- return keyList;
+ try {
+ return jedis.hexists(key, field);
+ } catch (Exception e) {
+ log.error("查看哈希表field字段是否存在失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
}
+ return null;
+ }
+
+ /**
+ * 获取所有哈希表中的字段
+ *
+ * @param key
+ * @return
+ * @author jqlin
+ */
+ public static Set<String> hkeys(String key) {
+ Set<String> set = new HashSet<String>();
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ log.warn("Jedis实例获取为空");
+ return set;
+ }
+
+ try {
+ return jedis.hkeys(key);
+ } catch (Exception e) {
+ log.error("获取所有哈希表中的字段失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
+ }
+
+ return null;
+ }
+
+ /**
+ * 获取所有哈希表中的值
+ *
+ * @param key
+ * @return
+ * @author jqlin
+ */
+ public static List<String> hvals(String key) {
+ List<String> list = new ArrayList<String>();
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ log.warn("Jedis实例获取为空");
+ return list;
+ }
+
+ try {
+ return jedis.hvals(key);
+ } catch (Exception e) {
+ log.error("获取所有哈希表中的值失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
+ }
+
+ return null;
+ }
+
+ /**
+ * 从哈希表 key 中删除指定的field
+ *
+ * @param key
+ * @param fields
+ * @return
+ * @author jqlin
+ */
+ public static long hdel(String key, String... fields) {
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ log.warn("Jedis实例获取为空");
+ return JedisStatus.FAIL_LONG;
+ }
+
+ try {
+ return jedis.hdel(key, fields);
+ } catch (Exception e) {
+ log.error("map删除指定的field失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
+ }
+
+ return 0;
+ }
+
+ public static Set<String> keys(String pattern) {
+ Set<String> keyList = new HashSet<String>();
+ Jedis jedis = getJedis();
+ if (jedis == null) {
+ log.warn("Jedis实例获取为空");
+ return keyList;
+ }
+
+ try {
+ keyList = jedis.keys(pattern);
+ } catch (Exception e) {
+ log.error("操作keys失败:" + e.getMessage(), e);
+ returnBrokenResource(jedis);
+ } finally {
+ returnResource(jedis);
+ }
+
+ return keyList;
+ }
+
/*public static void main(String[] args) throws IOException {
// System.out.println(hset("map", "a","3"));
// System.out.println(hset("map", "b","3"));
@@ -963,5 +968,4 @@
}*/
-
}
diff --git a/src/main/kotlin/com/supwisdom/dlpay/framework/controller/framework_controller.kt b/src/main/kotlin/com/supwisdom/dlpay/framework/controller/framework_controller.kt
index 139f37b..9fbd8c2 100644
--- a/src/main/kotlin/com/supwisdom/dlpay/framework/controller/framework_controller.kt
+++ b/src/main/kotlin/com/supwisdom/dlpay/framework/controller/framework_controller.kt
@@ -14,7 +14,7 @@
@GetMapping("/version")
fun version(): ResponseEntity<Any> {
return try {
- Manifests.read("Payapi-Version").let {
+ Manifests.read("Door-Version").let {
ResponseEntity.ok(ResponseBodyBuilder.create()
.data("version", it)
.success())
diff --git a/src/main/kotlin/com/supwisdom/dlpay/framework/service/impl/framework_service_impl.kt b/src/main/kotlin/com/supwisdom/dlpay/framework/service/impl/framework_service_impl.kt
index 32c6d92..4351ce7 100644
--- a/src/main/kotlin/com/supwisdom/dlpay/framework/service/impl/framework_service_impl.kt
+++ b/src/main/kotlin/com/supwisdom/dlpay/framework/service/impl/framework_service_impl.kt
@@ -1,10 +1,6 @@
package com.supwisdom.dlpay.framework.service.impl
-import com.google.gson.Gson
-import com.google.gson.reflect.TypeToken
import com.jcabi.manifests.Manifests
-import com.supwisdom.dlpay.api.bean.ConsumeFeetype
-import com.supwisdom.dlpay.exception.RequestParamCheckException
import com.supwisdom.dlpay.exception.TransactionProcessException
import com.supwisdom.dlpay.framework.core.JwtConfig
import com.supwisdom.dlpay.framework.core.JwtTokenUtil
@@ -34,7 +30,7 @@
override fun getSystemVersion(): String {
return try {
- Manifests.read("Payapi-Version") ?: "version 1.0"
+ Manifests.read("Door-Version") ?: "unknown"
} catch (ex: Exception) {
// ex.printStackTrace()
"unknown"