From: Tang Cheng Date: Mon, 1 Jul 2019 14:59:03 +0000 (+0800) Subject: 修改数据字典 X-Git-Tag: 1.0.0^2~135 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=9d14aa267e6401cc47c0699891374eb6667d21b4;p=epayment%2Ffood_payapi.git 修改数据字典 --- diff --git a/build.gradle b/build.gradle index 8146c485..0fa18422 100644 --- a/build.gradle +++ b/build.gradle @@ -28,6 +28,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-redis' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-security' + implementation 'org.springframework.boot:spring-boot-starter-cache' implementation 'org.springframework.security:spring-security-oauth2-client' implementation 'org.springframework.security:spring-security-oauth2-jose' implementation 'org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.1.5.RELEASE' diff --git a/src/main/java/com/supwisdom/dlpay/AppPreparedEvent.java b/src/main/java/com/supwisdom/dlpay/AppPreparedEvent.java index 4dead6ae..0ccb0eb5 100644 --- a/src/main/java/com/supwisdom/dlpay/AppPreparedEvent.java +++ b/src/main/java/com/supwisdom/dlpay/AppPreparedEvent.java @@ -1,21 +1,16 @@ package com.supwisdom.dlpay; -import com.supwisdom.dlpay.system.common.DictPool; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.event.ApplicationReadyEvent; -import org.springframework.context.annotation.Configuration; import org.springframework.context.event.EventListener; //@Configuration public class AppPreparedEvent { - private final DictPool dictPool; - public AppPreparedEvent(@Autowired DictPool dictPool) { - this.dictPool = dictPool; + public AppPreparedEvent() { + } @EventListener(ApplicationReadyEvent.class) public void setupDictPool() { - dictPool.init(); //初始化字典 } } diff --git a/src/main/java/com/supwisdom/dlpay/api/domain/TSourceType.java b/src/main/java/com/supwisdom/dlpay/api/domain/TSourceType.java index 41d8ea94..1748dc5b 100644 --- a/src/main/java/com/supwisdom/dlpay/api/domain/TSourceType.java +++ b/src/main/java/com/supwisdom/dlpay/api/domain/TSourceType.java @@ -1,17 +1,20 @@ package com.supwisdom.dlpay.api.domain; +import com.supwisdom.dlpay.framework.domain.DictionaryTable; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import javax.validation.constraints.NotNull; +import java.io.Serializable; /** * Created by shuwei on 2019/4/9. */ @Entity @Table(name = "TB_SOURCETYPE") -public class TSourceType { +public class TSourceType implements DictionaryTable, Serializable { @Id @Column(name = "SOURCETYPE", nullable = false, length = 20) private String sourceType; @@ -118,4 +121,14 @@ public class TSourceType { public void setTenantid(String tenantid) { this.tenantid = tenantid; } + + @Override + public String getDictKey() { + return this.sourceType; + } + + @Override + public Object getDictValue() { + return this.paydesc; + } } diff --git a/src/main/java/com/supwisdom/dlpay/framework/dao/DictionaryDao.java b/src/main/java/com/supwisdom/dlpay/framework/dao/DictionaryDao.java index 05e15ea6..efdd3841 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/dao/DictionaryDao.java +++ b/src/main/java/com/supwisdom/dlpay/framework/dao/DictionaryDao.java @@ -2,6 +2,8 @@ package com.supwisdom.dlpay.framework.dao; import com.supwisdom.dlpay.framework.domain.TDictionary; import com.supwisdom.dlpay.framework.domain.TDictionaryPK; +import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.Cacheable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -9,5 +11,5 @@ import java.util.List; @Repository public interface DictionaryDao extends JpaRepository { - List findAllByDicttype(int dicttype); + List findAllByDicttype(String dicttype); } diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/DictionaryTable.java b/src/main/java/com/supwisdom/dlpay/framework/domain/DictionaryTable.java new file mode 100644 index 00000000..7d1d36a3 --- /dev/null +++ b/src/main/java/com/supwisdom/dlpay/framework/domain/DictionaryTable.java @@ -0,0 +1,7 @@ +package com.supwisdom.dlpay.framework.domain; + +public interface DictionaryTable { + String getDictKey(); + + Object getDictValue(); +} diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/JwtRedis.java b/src/main/java/com/supwisdom/dlpay/framework/domain/JwtRedis.java index 01828e0a..47ece23a 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/domain/JwtRedis.java +++ b/src/main/java/com/supwisdom/dlpay/framework/domain/JwtRedis.java @@ -4,7 +4,7 @@ import org.springframework.data.annotation.Id; import org.springframework.data.redis.core.RedisHash; -@RedisHash("api_jwt") +@RedisHash(value = "api_jwt", timeToLive = 3600L) public class JwtRedis { @Id String jti; diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/TDictionary.java b/src/main/java/com/supwisdom/dlpay/framework/domain/TDictionary.java index 24fccb2e..16c4a9a9 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/domain/TDictionary.java +++ b/src/main/java/com/supwisdom/dlpay/framework/domain/TDictionary.java @@ -2,14 +2,15 @@ package com.supwisdom.dlpay.framework.domain; import javax.persistence.*; import javax.validation.constraints.NotNull; +import java.io.Serializable; @Entity @Table(name = "TB_DICTIONARY") @IdClass(TDictionaryPK.class) -public class TDictionary { +public class TDictionary implements DictionaryTable, Serializable { @Id - @Column(name = "DICTTYPE", nullable = false, precision = 9) - private Integer dicttype; + @Column(name = "DICTTYPE", nullable = false) + private String dicttype; @Id @Column(name = "DICTVAL", nullable = false, length = 30) @@ -25,11 +26,11 @@ public class TDictionary { @NotNull private String tenantId; - public Integer getDicttype() { + public String getDicttype() { return dicttype; } - public void setDicttype(Integer dicttype) { + public void setDicttype(String dicttype) { this.dicttype = dicttype; } @@ -56,4 +57,14 @@ public class TDictionary { public void setDictcaption(String dictcaption) { this.dictcaption = dictcaption; } + + @Override + public String getDictKey() { + return this.dictval; + } + + @Override + public Object getDictValue() { + return this.dictcaption; + } } diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/TDictionaryPK.java b/src/main/java/com/supwisdom/dlpay/framework/domain/TDictionaryPK.java index 04874e2d..1dbb4c8b 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/domain/TDictionaryPK.java +++ b/src/main/java/com/supwisdom/dlpay/framework/domain/TDictionaryPK.java @@ -6,18 +6,18 @@ import java.io.Serializable; public class TDictionaryPK implements Serializable { @Id - @Column(name = "DICTTYPE", nullable = false, precision = 9) - private Integer dicttype; + @Column(name = "DICTTYPE", nullable = false) + private String dicttype; @Id @Column(name = "DICTVAL", nullable = false, length = 30) private String dictval; - public Integer getDicttype() { + public String getDicttype() { return dicttype; } - public void setDicttype(Integer dicttype) { + public void setDicttype(String dicttype) { this.dicttype = dicttype; } diff --git a/src/main/java/com/supwisdom/dlpay/framework/domain/TTranscode.java b/src/main/java/com/supwisdom/dlpay/framework/domain/TTranscode.java index d63b46bb..ac42871e 100644 --- a/src/main/java/com/supwisdom/dlpay/framework/domain/TTranscode.java +++ b/src/main/java/com/supwisdom/dlpay/framework/domain/TTranscode.java @@ -5,10 +5,11 @@ import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import javax.validation.constraints.NotNull; +import java.io.Serializable; @Entity @Table(name = "TB_TRANSCODE") -public class TTranscode { +public class TTranscode implements DictionaryTable, Serializable { @Id @Column(name = "TRANSCODE", nullable = false, precision = 4) private Integer transcode; @@ -43,4 +44,14 @@ public class TTranscode { public void setTenantId(String tenantId) { this.tenantId = tenantId; } + + @Override + public String getDictKey() { + return String.valueOf(this.transcode); + } + + @Override + public Object getDictValue() { + return this.transname; + } } diff --git a/src/main/java/com/supwisdom/dlpay/framework/util/Dictionary.java b/src/main/java/com/supwisdom/dlpay/framework/util/Dictionary.java new file mode 100644 index 00000000..af7b9e25 --- /dev/null +++ b/src/main/java/com/supwisdom/dlpay/framework/util/Dictionary.java @@ -0,0 +1,12 @@ +package com.supwisdom.dlpay.framework.util; + +public class Dictionary { + // dictionary 表字典 + public static final String REVERSE_FLAG = "reverseflagList"; + public static final String DTL_STATUS = "dtlStatusList"; + + ///////////////////////////////////// + public static final String SOURCE_TYPE = "sourcetypeList"; + public static final String TRANS_CODE = "transcodeList"; + public static final String PAY_TYPE = "paytypelist"; +} diff --git a/src/main/java/com/supwisdom/dlpay/system/common/DictPool.java b/src/main/java/com/supwisdom/dlpay/system/common/DictPool.java deleted file mode 100644 index 2a83dd1e..00000000 --- a/src/main/java/com/supwisdom/dlpay/system/common/DictPool.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.supwisdom.dlpay.system.common; - -import com.supwisdom.dlpay.system.service.DictionaryDataService; -import com.supwisdom.dlpay.util.ConstantUtil; -import kotlin.Suppress; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -import java.util.HashMap; -import java.util.Map; - -@Component("dictPool") -@Scope("singleton") -public class DictPool { - private static final HashMap dictmap = new HashMap<>(); - - private DictionaryDataService dictionaryDataService; - - public DictPool(@Autowired DictionaryDataService dataService) { - this.dictionaryDataService = dataService; - } - - @SuppressWarnings("unchecked") - public static HashMap getDictMap(String key) { - synchronized (dictmap) { - return (HashMap) dictmap.get(key); - } - } - - public static void updateDict(String dictType, Map value) { - synchronized (dictmap) { - dictmap.put(dictType, value); - } - } - - public void init() { - dictmap.put("allSourcetypeList", dictionaryDataService.getSystemAllSourcetype()); - dictmap.put("allReverseflagList", dictionaryDataService.getDictionaryByDicttype(ConstantUtil.DICTTYPE_NO1)); - - } -} diff --git a/src/main/java/com/supwisdom/dlpay/system/controller/DictPoolAction.java b/src/main/java/com/supwisdom/dlpay/system/controller/DictPoolAction.java index 085a27d9..af00076f 100644 --- a/src/main/java/com/supwisdom/dlpay/system/controller/DictPoolAction.java +++ b/src/main/java/com/supwisdom/dlpay/system/controller/DictPoolAction.java @@ -1,10 +1,12 @@ package com.supwisdom.dlpay.system.controller; import com.supwisdom.dlpay.api.bean.JsonResult; +import com.supwisdom.dlpay.system.service.DictionaryDataService; +import com.supwisdom.dlpay.system.service.DictionaryProxy; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; -import com.supwisdom.dlpay.system.common.DictPool; + import javax.servlet.http.HttpServletRequest; import javax.ws.rs.FormParam; import java.util.Map; @@ -12,18 +14,16 @@ import java.util.Map; @RestController public class DictPoolAction { @Autowired - private DictPool dictPool; + private DictionaryProxy dictionaryProxy; @GetMapping("/dictpool") public Map getDictDataByDicttype(@FormParam("dicttype") String dictType, HttpServletRequest request) { dictType = request.getParameter("dicttype"); - Map res = DictPool.getDictMap(dictType); - return res; + return dictionaryProxy.getDictionaryAsMap(dictType); } @GetMapping("/dictrefresh") public JsonResult refreshDict() { - dictPool.init(); return JsonResult.ok(); } diff --git a/src/main/java/com/supwisdom/dlpay/system/controller/DtlController.java b/src/main/java/com/supwisdom/dlpay/system/controller/DtlController.java index 1bd3bd81..0b3a8828 100644 --- a/src/main/java/com/supwisdom/dlpay/system/controller/DtlController.java +++ b/src/main/java/com/supwisdom/dlpay/system/controller/DtlController.java @@ -2,11 +2,16 @@ package com.supwisdom.dlpay.system.controller; import com.supwisdom.dlpay.api.domain.TPersondtl; import com.supwisdom.dlpay.api.domain.TShopdtl; +import com.supwisdom.dlpay.api.domain.TSourceType; +import com.supwisdom.dlpay.framework.domain.TDictionary; +import com.supwisdom.dlpay.framework.domain.TTranscode; +import com.supwisdom.dlpay.framework.util.Dictionary; import com.supwisdom.dlpay.framework.util.PageResult; import com.supwisdom.dlpay.framework.util.WebConstant; import com.supwisdom.dlpay.system.bean.ShopdtlSearchBean; import com.supwisdom.dlpay.system.bean.TreeSelectNode; import com.supwisdom.dlpay.system.bean.UserdtlSearchBean; +import com.supwisdom.dlpay.system.service.DictionaryProxy; import com.supwisdom.dlpay.system.service.DtlDataService; import com.supwisdom.dlpay.system.service.ShopDataService; import org.springframework.beans.factory.annotation.Autowired; @@ -19,11 +24,12 @@ import java.util.List; @Controller public class DtlController { - @Autowired - private ShopDataService shopDataService; @Autowired private DtlDataService dtlDataService; + @Autowired + private DictionaryProxy dictionaryProxy; + /** * ==================================================== * 个人流水查询 @@ -31,9 +37,16 @@ public class DtlController { */ @GetMapping("/dtl/userdtl") public String userdtlView(Model model) { - model.addAttribute("paytypelist", shopDataService.getConsumePaytypes()); - model.addAttribute("transcodelist", dtlDataService.getAllTranscodes()); - model.addAttribute("dtlstatuslist", dtlDataService.getAllDtlStatus()); +// model.addAttribute("paytypelist", shopDataService.getConsumePaytypes()); +// model.addAttribute("transcodelist", dtlDataService.getAllTranscodes()); +// model.addAttribute("dtlstatuslist", dtlDataService.getAllDtlStatus()); + + model.addAttribute(Dictionary.TRANS_CODE, + dictionaryProxy.getDictionaryAsList(Dictionary.TRANS_CODE)); + model.addAttribute(Dictionary.DTL_STATUS, + dictionaryProxy.getDictionaryAsList(Dictionary.DTL_STATUS)); + model.addAttribute(Dictionary.PAY_TYPE, + dictionaryProxy.getDictionaryAsList(Dictionary.SOURCE_TYPE)); return "system/dtl/userdtl"; } @@ -60,9 +73,12 @@ public class DtlController { */ @GetMapping("/dtl/shopdtl") public String shopdtlView(Model model) { - model.addAttribute("paytypelist", shopDataService.getConsumePaytypes()); - model.addAttribute("transcodelist", dtlDataService.getAllTranscodes()); - model.addAttribute("dtlstatuslist", dtlDataService.getAllDtlStatus()); + model.addAttribute(Dictionary.PAY_TYPE, + dictionaryProxy.getDictionaryAsList(Dictionary.SOURCE_TYPE)); + model.addAttribute(Dictionary.TRANS_CODE, + dictionaryProxy.getDictionaryAsList(Dictionary.TRANS_CODE)); + model.addAttribute(Dictionary.DTL_STATUS, + dictionaryProxy.getDictionaryAsList(Dictionary.DTL_STATUS)); return "system/dtl/shopdtl"; } diff --git a/src/main/java/com/supwisdom/dlpay/system/controller/ParamController.java b/src/main/java/com/supwisdom/dlpay/system/controller/ParamController.java index 53af3c48..7a16f3b8 100644 --- a/src/main/java/com/supwisdom/dlpay/system/controller/ParamController.java +++ b/src/main/java/com/supwisdom/dlpay/system/controller/ParamController.java @@ -369,7 +369,7 @@ public class ParamController { try { if (null == pageNo || pageNo < 1) pageNo = WebConstant.PAGENO_DEFAULT; if (null == pageSize || pageSize < 1) pageSize = WebConstant.PAGESIZE_DEFAULT; - return paramService.getPaytypePage(paytype, pageNo, pageSize); + return paramService.getSourceTypePage(paytype, pageNo, pageSize); } catch (Exception e) { e.printStackTrace(); return new PageResult<>(99, "系统查询错误"); @@ -393,7 +393,7 @@ public class ParamController { return JsonResult.error("参数传递错误"); } try { - TSourceType tPaytype = paramService.getPaytype(paytype); + TSourceType tPaytype = paramService.getSourceType(paytype); if (null == tPaytype) { return JsonResult.error("支付方式不存在!"); } @@ -419,7 +419,7 @@ public class ParamController { tPaytype.setEnable(state); //默认切换主状态 } - if (paramService.saveOrUpdatePaytype(tPaytype)) { + if (paramService.saveOrUpdateSourceType(tPaytype)) { return JsonResult.ok(state ? "启用成功" : "关闭成功"); } else { return JsonResult.error(!state ? "启用失败" : "关闭失败"); @@ -439,12 +439,12 @@ public class ParamController { return JsonResult.error("参数传递错误"); } try { - TSourceType tPaytype = paramService.getPaytype(paytype); + TSourceType tPaytype = paramService.getSourceType(paytype); if (null == tPaytype) { return JsonResult.error("支付方式不存在!"); } tPaytype.setPaydesc(paydesc.trim()); - if (paramService.saveOrUpdatePaytype(tPaytype)) { + if (paramService.saveOrUpdateSourceType(tPaytype)) { return JsonResult.ok("修改成功"); } else { return JsonResult.error("修改失败"); @@ -460,11 +460,11 @@ public class ParamController { @ResponseBody public JsonResult deletePaytype(@RequestParam("paytype") String paytype) { try { - TSourceType tPaytype = paramService.getPaytype(paytype); + TSourceType tPaytype = paramService.getSourceType(paytype); if (null == tPaytype) { return JsonResult.error("支付方式不存在!"); } - if (paramService.deletePaytype(tPaytype)) { + if (paramService.deleteSourceType(tPaytype)) { return JsonResult.ok("删除成功"); } else { return JsonResult.error("删除失败"); @@ -485,7 +485,7 @@ public class ParamController { @RequestParam(value = "anonymousEnable", required = false, defaultValue = "no") String anonymousEnable, @RequestParam("paydesc") String paydesc) { try { - TSourceType tPaytype = paramService.getPaytype(paytype); + TSourceType tPaytype = paramService.getSourceType(paytype); if (null != tPaytype) { return JsonResult.error("支付方式已经存在"); } @@ -497,7 +497,7 @@ public class ParamController { tPaytype.setChargeEnable(ConstantUtil.ENABLE_YES.equalsIgnoreCase(chargeEnable)); tPaytype.setConsumeEnable(ConstantUtil.ENABLE_YES.equalsIgnoreCase(consumeEnable)); tPaytype.setAnonymousEnable(ConstantUtil.ENABLE_YES.equalsIgnoreCase(anonymousEnable)); - if (paramService.saveOrUpdatePaytype(tPaytype)) { + if (paramService.saveOrUpdateSourceType(tPaytype)) { return JsonResult.ok("新增成功"); } else { return JsonResult.error("新增失败"); @@ -511,7 +511,7 @@ public class ParamController { @GetMapping("/param/checkpaytype") @ResponseBody public JsonResult checkPaytype(@RequestParam("paytype") String paytype) { - TSourceType tPaytype = paramService.getPaytype(paytype); + TSourceType tPaytype = paramService.getSourceType(paytype); if (null != tPaytype) { return JsonResult.error("支付方式已经存在"); } else { @@ -522,7 +522,7 @@ public class ParamController { @GetMapping("/param/load4paytypeconfig") @PreAuthorize("hasPermission('/param/load4paytypeconfig','')") public String load4PaytypeConfig(@RequestParam("paytype") String paytype, Model model) { - List configList = paramService.getPaytypeConfigList(paytype); + List configList = paramService.getSourceTypeConfigList(paytype); model.addAttribute("configlist", configList); model.addAttribute("paytype", paytype); return "system/param/paytypeconfig"; @@ -540,7 +540,7 @@ public class ParamController { try { String paytype = param.get(paytypeHtmlKey).trim(); param.remove(paytypeHtmlKey); - if (paramService.savePaytypeConfig(paytype, param)) { + if (paramService.saveSourceTypeConfig(paytype, param)) { return JsonResult.ok("配置成功"); } else { return JsonResult.error("配置失败"); diff --git a/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java b/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java index 91f12f87..f7f69bbb 100644 --- a/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java +++ b/src/main/java/com/supwisdom/dlpay/system/controller/ShopController.java @@ -7,11 +7,9 @@ import com.supwisdom.dlpay.api.domain.TShopPaytypeConfig; import com.supwisdom.dlpay.framework.domain.TShop; import com.supwisdom.dlpay.framework.domain.TShopacc; import com.supwisdom.dlpay.framework.service.SystemUtilService; -import com.supwisdom.dlpay.framework.util.PageResult; -import com.supwisdom.dlpay.framework.util.StringUtil; -import com.supwisdom.dlpay.framework.util.TradeDict; -import com.supwisdom.dlpay.framework.util.WebConstant; +import com.supwisdom.dlpay.framework.util.*; import com.supwisdom.dlpay.system.bean.ShopConfigBean; +import com.supwisdom.dlpay.system.service.DictionaryProxy; import com.supwisdom.dlpay.system.service.ParamService; import com.supwisdom.dlpay.system.service.ShopDataService; import com.supwisdom.dlpay.util.ConstantUtil; @@ -34,6 +32,9 @@ public class ShopController { @Autowired private SystemUtilService systemUtilService; + @Autowired + private DictionaryProxy dictionaryProxy; + @GetMapping("/shop/index") public String shopView() { return "system/shop/index"; @@ -157,7 +158,9 @@ public class ShopController { */ @GetMapping("/shop/config") public String shopConfigView(Model model) { - model.addAttribute("paytypelist", shopDataService.getConsumePaytypes()); +// model.addAttribute("paytypelist", shopDataService.getConsumePaytypes()); + model.addAttribute(Dictionary.PAY_TYPE, + dictionaryProxy.getDictionaryObject(Dictionary.SOURCE_TYPE)); return "system/shop/config"; } @@ -233,7 +236,8 @@ public class ShopController { @GetMapping("/shop/load4addpaytype") @PreAuthorize("hasPermission('/shop/load4addpaytype','')") public String load4AddShopPaytype(Model model) { - model.addAttribute("paytypelist", shopDataService.getConsumePaytypes()); + model.addAttribute(Dictionary.PAY_TYPE, + dictionaryProxy.getDictionaryAsList(Dictionary.SOURCE_TYPE)); return "system/shop/configform"; } @@ -250,7 +254,7 @@ public class ShopController { } try { TShopacc shopacc = shopDataService.getShopaccByAccno(shopaccno.trim()); - TSourceType tPaytype = paramService.getPaytype(paytype.trim()); + TSourceType tPaytype = paramService.getSourceType(paytype.trim()); if (null == shopacc) { return JsonResult.error("商户账户不存在!"); } diff --git a/src/main/java/com/supwisdom/dlpay/system/service/DictionaryDataService.java b/src/main/java/com/supwisdom/dlpay/system/service/DictionaryDataService.java index a378a8cc..48cc4df2 100644 --- a/src/main/java/com/supwisdom/dlpay/system/service/DictionaryDataService.java +++ b/src/main/java/com/supwisdom/dlpay/system/service/DictionaryDataService.java @@ -1,12 +1,13 @@ package com.supwisdom.dlpay.system.service; -import java.util.HashMap; +import com.supwisdom.dlpay.framework.domain.TDictionary; +import com.supwisdom.dlpay.framework.domain.TTranscode; -public interface DictionaryDataService { - HashMap getSystemAllSourcetype(); - - HashMap getDictionaryByDicttype(int dicttype); +import java.util.List; +public interface DictionaryDataService { + List getDictionaryByDictType(String dicttype); + List getTransCode(); } diff --git a/src/main/java/com/supwisdom/dlpay/system/service/DictionaryProxy.java b/src/main/java/com/supwisdom/dlpay/system/service/DictionaryProxy.java new file mode 100644 index 00000000..7f8d814f --- /dev/null +++ b/src/main/java/com/supwisdom/dlpay/system/service/DictionaryProxy.java @@ -0,0 +1,56 @@ +package com.supwisdom.dlpay.system.service; + +import com.supwisdom.dlpay.framework.domain.DictionaryTable; +import com.supwisdom.dlpay.framework.util.Dictionary; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Component +public class DictionaryProxy { + private final DictionaryDataService dictionaryDataService; + + private final ParamService paramService; + + public DictionaryProxy(DictionaryDataService dictionaryDataService, ParamService paramService) { + this.dictionaryDataService = dictionaryDataService; + this.paramService = paramService; + } + + @SuppressWarnings("UNCHECKED_CAST") + public Map getDictionaryObject(String dictType) { + List list = getDictionaryAsList(dictType); + Map result = new HashMap<>(); + for (Object item : list) { + if (item instanceof DictionaryTable) { + result.put(((DictionaryTable) item).getDictKey(), (T) item); + } + } + return result; + } + + public Map getDictionaryAsMap(String dictType) { + List list = getDictionaryAsList(dictType); + Map result = new HashMap<>(); + for (Object item : list) { + if (item instanceof DictionaryTable) { + DictionaryTable it = (DictionaryTable) item; + result.put(it.getDictKey(), it.getDictValue()); + } + } + return result; + } + + @SuppressWarnings("UNCHECKED_CAST") + public List getDictionaryAsList(String dictType) { + if (Dictionary.SOURCE_TYPE.equals(dictType)) { + return (List) paramService.getAllSourceType(); + } else if (Dictionary.TRANS_CODE.equals(dictType)) { + return (List) dictionaryDataService.getTransCode(); + } else { + return (List) dictionaryDataService.getDictionaryByDictType(dictType); + } + } +} diff --git a/src/main/java/com/supwisdom/dlpay/system/service/DtlDataService.java b/src/main/java/com/supwisdom/dlpay/system/service/DtlDataService.java index fa0affe9..59afc6de 100644 --- a/src/main/java/com/supwisdom/dlpay/system/service/DtlDataService.java +++ b/src/main/java/com/supwisdom/dlpay/system/service/DtlDataService.java @@ -20,12 +20,6 @@ public interface DtlDataService { @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) PageResult getShopdtlPage(ShopdtlSearchBean searchBean, int pageNo, int pageSize); - @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) - List getAllTranscodes(); - - @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) - List getAllDtlStatus(); - @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) List getTreeSelectShops(); } diff --git a/src/main/java/com/supwisdom/dlpay/system/service/ParamService.java b/src/main/java/com/supwisdom/dlpay/system/service/ParamService.java index 3d2b0e83..dc9d1806 100644 --- a/src/main/java/com/supwisdom/dlpay/system/service/ParamService.java +++ b/src/main/java/com/supwisdom/dlpay/system/service/ParamService.java @@ -49,23 +49,25 @@ public interface ParamService { boolean deleteApiClient(TApiClient apiClient); @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) - PageResult getPaytypePage(String paytype, int pageNo, int pageSize); + PageResult getSourceTypePage(String paytype, int pageNo, int pageSize); + + @Transactional(readOnly = true) + List getAllSourceType(); @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) - TSourceType getPaytype(String paytype); + TSourceType getSourceType(String paytype); @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) - boolean saveOrUpdatePaytype(TSourceType paytype); + boolean saveOrUpdateSourceType(TSourceType paytype); @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) - boolean deletePaytype(TSourceType paytype); + boolean deleteSourceType(TSourceType paytype); @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) - List getPaytypeConfigList(String paytype); + List getSourceTypeConfigList(String paytype); @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) - boolean savePaytypeConfig(String paytype, Map param) throws WebCheckException; - + boolean saveSourceTypeConfig(String paytype, Map param) throws WebCheckException; } diff --git a/src/main/java/com/supwisdom/dlpay/system/service/ShopDataService.java b/src/main/java/com/supwisdom/dlpay/system/service/ShopDataService.java index b2eb69bd..9f5bd1a8 100644 --- a/src/main/java/com/supwisdom/dlpay/system/service/ShopDataService.java +++ b/src/main/java/com/supwisdom/dlpay/system/service/ShopDataService.java @@ -28,9 +28,6 @@ public interface ShopDataService { @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) boolean saveOrUpdateShop(TShop shop) throws WebCheckException; - @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true) - List getConsumePaytypes(); - @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true) PageResult getShopPaytypeInfos(String shopaccno, String paytype, int pageNo, int pageSize); diff --git a/src/main/java/com/supwisdom/dlpay/system/service/impl/DictionaryDataServiceImpl.java b/src/main/java/com/supwisdom/dlpay/system/service/impl/DictionaryDataServiceImpl.java index 85e9438c..523bded2 100644 --- a/src/main/java/com/supwisdom/dlpay/system/service/impl/DictionaryDataServiceImpl.java +++ b/src/main/java/com/supwisdom/dlpay/system/service/impl/DictionaryDataServiceImpl.java @@ -1,45 +1,45 @@ package com.supwisdom.dlpay.system.service.impl; -import com.supwisdom.dlpay.api.dao.SourceTypeDao; -import com.supwisdom.dlpay.api.domain.TSourceType; import com.supwisdom.dlpay.framework.dao.DictionaryDao; +import com.supwisdom.dlpay.framework.dao.TranscodeDao; import com.supwisdom.dlpay.framework.domain.TDictionary; -import com.supwisdom.dlpay.framework.util.StringUtil; +import com.supwisdom.dlpay.framework.domain.TTranscode; import com.supwisdom.dlpay.system.service.DictionaryDataService; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; @Service public class DictionaryDataServiceImpl implements DictionaryDataService { - @Autowired - private SourceTypeDao sourceTypeDao; - @Autowired - private DictionaryDao dictionaryDao; + private final DictionaryDao dictionaryDao; + private final TranscodeDao transcodeDao; + + public DictionaryDataServiceImpl(DictionaryDao dictionaryDao, + TranscodeDao transcodeDao) { + this.dictionaryDao = dictionaryDao; + this.transcodeDao = transcodeDao; + } @Override - public HashMap getSystemAllSourcetype() { - HashMap result = new HashMap<>(0); - List list = sourceTypeDao.findAll(); - if (!StringUtil.isEmpty(list)) { - for (TSourceType tst : list) { - result.put(tst.getSourceType(), tst.getPaydesc()); - } + @Cacheable(cacheNames = "dicationary_cache", key = "#p0") + public List getDictionaryByDictType(String dicttype) { + List list = dictionaryDao.findAllByDicttype(dicttype); + if (!list.isEmpty()) { + return list; } - return result; + return new ArrayList<>(); } + @Override - public HashMap getDictionaryByDicttype(int dicttype) { - HashMap result = new HashMap<>(0); - List list = dictionaryDao.findAllByDicttype(dicttype); - if (!StringUtil.isEmpty(list)) { - for (TDictionary dict : list) { - result.put(dict.getDictval() == null ? "" : dict.getDictval(), dict.getDictcaption()); - } + @Cacheable(cacheNames = "trans_code_cache") + public List getTransCode() { + List list = transcodeDao.findAll(); + if (!list.isEmpty()) { + return list; } - return result; + return new ArrayList<>(); } } diff --git a/src/main/java/com/supwisdom/dlpay/system/service/impl/DtlDataServiceImpl.java b/src/main/java/com/supwisdom/dlpay/system/service/impl/DtlDataServiceImpl.java index 869bf31d..82fbdc23 100644 --- a/src/main/java/com/supwisdom/dlpay/system/service/impl/DtlDataServiceImpl.java +++ b/src/main/java/com/supwisdom/dlpay/system/service/impl/DtlDataServiceImpl.java @@ -4,20 +4,20 @@ import com.supwisdom.dlpay.api.dao.PersondtlDao; import com.supwisdom.dlpay.api.dao.ShopdtlDao; import com.supwisdom.dlpay.api.domain.TPersondtl; import com.supwisdom.dlpay.api.domain.TShopdtl; -import com.supwisdom.dlpay.framework.dao.DictionaryDao; import com.supwisdom.dlpay.framework.dao.ShopDao; import com.supwisdom.dlpay.framework.dao.TranscodeDao; import com.supwisdom.dlpay.framework.domain.TDictionary; import com.supwisdom.dlpay.framework.domain.TShop; import com.supwisdom.dlpay.framework.domain.TTranscode; import com.supwisdom.dlpay.framework.util.DateUtil; +import com.supwisdom.dlpay.framework.util.Dictionary; import com.supwisdom.dlpay.framework.util.PageResult; import com.supwisdom.dlpay.framework.util.StringUtil; import com.supwisdom.dlpay.system.bean.ShopdtlSearchBean; import com.supwisdom.dlpay.system.bean.TreeSelectNode; import com.supwisdom.dlpay.system.bean.UserdtlSearchBean; +import com.supwisdom.dlpay.system.service.DictionaryProxy; import com.supwisdom.dlpay.system.service.DtlDataService; -import com.supwisdom.dlpay.util.ConstantUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -32,6 +32,7 @@ import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; import java.util.ArrayList; import java.util.List; +import java.util.Map; @Service public class DtlDataServiceImpl implements DtlDataService { @@ -42,7 +43,7 @@ public class DtlDataServiceImpl implements DtlDataService { @Autowired private TranscodeDao transcodeDao; @Autowired - private DictionaryDao dictionaryDao; + private DictionaryProxy dictionaryProxy; @Autowired private ShopDao shopDao; @@ -53,32 +54,32 @@ public class DtlDataServiceImpl implements DtlDataService { @Override public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) { List predicates = new ArrayList<>(); - if(!StringUtil.isEmpty(searchBean.getStartAccdate())){ - predicates.add(criteriaBuilder.ge(root.get("accdate").as(Integer.class),Integer.valueOf(DateUtil.unParseToDateFormat(searchBean.getStartAccdate())))); + if (!StringUtil.isEmpty(searchBean.getStartAccdate())) { + predicates.add(criteriaBuilder.ge(root.get("accdate").as(Integer.class), Integer.valueOf(DateUtil.unParseToDateFormat(searchBean.getStartAccdate())))); } - if(!StringUtil.isEmpty(searchBean.getEndAccdate())){ - predicates.add(criteriaBuilder.le(root.get("accdate").as(Integer.class),Integer.valueOf(DateUtil.unParseToDateFormat(searchBean.getEndAccdate())))); + if (!StringUtil.isEmpty(searchBean.getEndAccdate())) { + predicates.add(criteriaBuilder.le(root.get("accdate").as(Integer.class), Integer.valueOf(DateUtil.unParseToDateFormat(searchBean.getEndAccdate())))); } - if(!StringUtil.isEmpty(searchBean.getStartTransdate())){ - predicates.add(criteriaBuilder.ge(root.get("transdate").as(Integer.class),Integer.valueOf(DateUtil.unParseToDateFormat(searchBean.getStartTransdate())))); + if (!StringUtil.isEmpty(searchBean.getStartTransdate())) { + predicates.add(criteriaBuilder.ge(root.get("transdate").as(Integer.class), Integer.valueOf(DateUtil.unParseToDateFormat(searchBean.getStartTransdate())))); } - if(!StringUtil.isEmpty(searchBean.getEndTransdate())){ - predicates.add(criteriaBuilder.le(root.get("transdate").as(Integer.class),Integer.valueOf(DateUtil.unParseToDateFormat(searchBean.getEndTransdate())))); + if (!StringUtil.isEmpty(searchBean.getEndTransdate())) { + predicates.add(criteriaBuilder.le(root.get("transdate").as(Integer.class), Integer.valueOf(DateUtil.unParseToDateFormat(searchBean.getEndTransdate())))); } - if(!StringUtil.isEmpty(searchBean.getPersonname())){ + if (!StringUtil.isEmpty(searchBean.getPersonname())) { predicates.add(criteriaBuilder.like(root.get("userName").as(String.class), "%" + searchBean.getPersonname().trim() + "%")); } - if(!StringUtil.isEmpty(searchBean.getSourcetype())){ + if (!StringUtil.isEmpty(searchBean.getSourcetype())) { predicates.add(criteriaBuilder.equal(root.get("sourceType").as(String.class), searchBean.getSourcetype().trim())); } - if(!StringUtil.isEmpty(searchBean.getTradeflag())){ + if (!StringUtil.isEmpty(searchBean.getTradeflag())) { predicates.add(criteriaBuilder.equal(root.get("tradeflag").as(String.class), searchBean.getTradeflag().trim())); } - if(!StringUtil.isEmpty(searchBean.getTranscode())){ + if (!StringUtil.isEmpty(searchBean.getTranscode())) { predicates.add(criteriaBuilder.equal(root.get("transcode").as(String.class), searchBean.getTranscode().trim())); } - if(!StringUtil.isEmpty(searchBean.getStatus())){ + if (!StringUtil.isEmpty(searchBean.getStatus())) { predicates.add(criteriaBuilder.equal(root.get("status").as(String.class), searchBean.getStatus().trim())); } return criteriaBuilder.and(predicates.toArray(new Predicate[0])); @@ -90,61 +91,44 @@ public class DtlDataServiceImpl implements DtlDataService { @Override public PageResult getShopdtlPage(ShopdtlSearchBean searchBean, int pageNo, int pageSize) { Pageable pageable = PageRequest.of(pageNo - 1, pageSize, Sort.by(Sort.Direction.DESC, "refno")); - Page page = shopdtlDao.findAll(new Specification() { - @Override - public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) { - List predicates = new ArrayList<>(); - if(!StringUtil.isEmpty(searchBean.getStartAccdate())){ - predicates.add(criteriaBuilder.ge(root.get("accdate").as(Integer.class),Integer.valueOf(DateUtil.unParseToDateFormat(searchBean.getStartAccdate())))); - } - if(!StringUtil.isEmpty(searchBean.getEndAccdate())){ - predicates.add(criteriaBuilder.le(root.get("accdate").as(Integer.class),Integer.valueOf(DateUtil.unParseToDateFormat(searchBean.getEndAccdate())))); - } - if(!StringUtil.isEmpty(searchBean.getStartTransdate())){ - predicates.add(criteriaBuilder.ge(root.get("transdate").as(Integer.class),Integer.valueOf(DateUtil.unParseToDateFormat(searchBean.getStartTransdate())))); + Page page = shopdtlDao.findAll((Specification) (root, query, criteriaBuilder) -> { + List predicates = new ArrayList<>(); + if (!StringUtil.isEmpty(searchBean.getStartAccdate())) { + predicates.add(criteriaBuilder.ge(root.get("accdate").as(Integer.class), Integer.valueOf(DateUtil.unParseToDateFormat(searchBean.getStartAccdate())))); + } + if (!StringUtil.isEmpty(searchBean.getEndAccdate())) { + predicates.add(criteriaBuilder.le(root.get("accdate").as(Integer.class), Integer.valueOf(DateUtil.unParseToDateFormat(searchBean.getEndAccdate())))); + } + if (!StringUtil.isEmpty(searchBean.getStartTransdate())) { + predicates.add(criteriaBuilder.ge(root.get("transdate").as(Integer.class), Integer.valueOf(DateUtil.unParseToDateFormat(searchBean.getStartTransdate())))); - } - if(!StringUtil.isEmpty(searchBean.getEndTransdate())){ - predicates.add(criteriaBuilder.le(root.get("transdate").as(Integer.class),Integer.valueOf(DateUtil.unParseToDateFormat(searchBean.getEndTransdate())))); - } - if(!StringUtil.isEmpty(searchBean.getShopname())){ - predicates.add(criteriaBuilder.like(root.get("shopname").as(String.class), "%" + searchBean.getShopname().trim() + "%")); - } - if(!StringUtil.isEmpty(searchBean.getShopaccno())){ - predicates.add(criteriaBuilder.equal(root.get("shopaccno").as(String.class), searchBean.getShopaccno().trim())); - } - if(!StringUtil.isEmpty(searchBean.getSourcetype())){ - predicates.add(criteriaBuilder.equal(root.get("sourceType").as(String.class), searchBean.getSourcetype().trim())); - } - if(!StringUtil.isEmpty(searchBean.getTradeflag())){ - predicates.add(criteriaBuilder.equal(root.get("tradeflag").as(String.class), searchBean.getTradeflag().trim())); - } - if(!StringUtil.isEmpty(searchBean.getTranscode())){ - predicates.add(criteriaBuilder.equal(root.get("transcode").as(String.class), searchBean.getTranscode().trim())); - } - if(!StringUtil.isEmpty(searchBean.getStatus())){ - predicates.add(criteriaBuilder.equal(root.get("status").as(String.class), searchBean.getStatus().trim())); - } - return criteriaBuilder.and(predicates.toArray(new Predicate[0])); } + if (!StringUtil.isEmpty(searchBean.getEndTransdate())) { + predicates.add(criteriaBuilder.le(root.get("transdate").as(Integer.class), Integer.valueOf(DateUtil.unParseToDateFormat(searchBean.getEndTransdate())))); + } + if (!StringUtil.isEmpty(searchBean.getShopname())) { + predicates.add(criteriaBuilder.like(root.get("shopname").as(String.class), "%" + searchBean.getShopname().trim() + "%")); + } + if (!StringUtil.isEmpty(searchBean.getShopaccno())) { + predicates.add(criteriaBuilder.equal(root.get("shopaccno").as(String.class), searchBean.getShopaccno().trim())); + } + if (!StringUtil.isEmpty(searchBean.getSourcetype())) { + predicates.add(criteriaBuilder.equal(root.get("sourceType").as(String.class), searchBean.getSourcetype().trim())); + } + if (!StringUtil.isEmpty(searchBean.getTradeflag())) { + predicates.add(criteriaBuilder.equal(root.get("tradeflag").as(String.class), searchBean.getTradeflag().trim())); + } + if (!StringUtil.isEmpty(searchBean.getTranscode())) { + predicates.add(criteriaBuilder.equal(root.get("transcode").as(String.class), searchBean.getTranscode().trim())); + } + if (!StringUtil.isEmpty(searchBean.getStatus())) { + predicates.add(criteriaBuilder.equal(root.get("status").as(String.class), searchBean.getStatus().trim())); + } + return criteriaBuilder.and(predicates.toArray(new Predicate[0])); }, pageable); return new PageResult<>(page); } - @Override - public List getAllTranscodes(){ - return transcodeDao.findAll(); - } - - @Override - public List getAllDtlStatus(){ - List list = dictionaryDao.findAllByDicttype(ConstantUtil.DICTTYPE_NO2); - if(!StringUtil.isEmpty(list)){ - return list; - } - return new ArrayList<>(0); - } - @Override public List getTreeSelectShops() { List shoplist = shopDao.getNormalShops(); @@ -160,7 +144,7 @@ public class DtlDataServiceImpl implements DtlDataService { if (fshopid.equals(shop.getFshopid())) { TreeSelectNode node = new TreeSelectNode(); node.setId(String.valueOf(shop.getShopid())); - if(!StringUtil.isEmpty(shop.getShopaccno())){ + if (!StringUtil.isEmpty(shop.getShopaccno())) { node.setId(shop.getShopaccno()); //替换商户账号 } node.setName(shop.getShopname()); @@ -168,9 +152,9 @@ public class DtlDataServiceImpl implements DtlDataService { node.setChecked(false); node.setAccno(shop.getShopaccno()); List children = getShopSelectTree(shoplist, shop.getShopid()); - if(null!=children && children.size()>0){ + if (null != children && children.size() > 0) { node.setChildren(children); - }else{ + } else { node.setChildren(null); } result.add(node); diff --git a/src/main/java/com/supwisdom/dlpay/system/service/impl/ParamServiceImpl.java b/src/main/java/com/supwisdom/dlpay/system/service/impl/ParamServiceImpl.java index babde310..4fe84f72 100644 --- a/src/main/java/com/supwisdom/dlpay/system/service/impl/ParamServiceImpl.java +++ b/src/main/java/com/supwisdom/dlpay/system/service/impl/ParamServiceImpl.java @@ -16,6 +16,8 @@ import com.supwisdom.dlpay.system.service.ParamService; import com.supwisdom.dlpay.util.ConstantUtil; import com.supwisdom.dlpay.util.WebCheckException; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -41,7 +43,7 @@ public class ParamServiceImpl implements ParamService { @Autowired private ApiClientDao apiClientDao; @Autowired - private SourceTypeDao paytypeDao; + private SourceTypeDao sourceTypeDao; @Autowired private PaytypeConfigDao paytypeConfigDao; @@ -150,42 +152,52 @@ public class ParamServiceImpl implements ParamService { } @Override - public PageResult getPaytypePage(String paytype, int pageNo, int pageSize) { + public PageResult getSourceTypePage(String paytype, int pageNo, int pageSize) { Pageable pageable = PageRequest.of(pageNo - 1, pageSize, Sort.by("sourceType")); if (!StringUtil.isEmpty(paytype)) { - return new PageResult<>(paytypeDao.findBySourceTypeContaining(paytype.trim(), pageable)); + return new PageResult<>(sourceTypeDao.findBySourceTypeContaining(paytype.trim(), pageable)); } - return new PageResult<>(paytypeDao.findAll(pageable)); + return new PageResult<>(sourceTypeDao.findAll(pageable)); } @Override - public TSourceType getPaytype(String paytype) { + @Cacheable(cacheNames = "source_type_cache", key = "#p0") + public TSourceType getSourceType(String paytype) { if (!StringUtil.isEmpty(paytype)) { - return paytypeDao.getBySourceType(paytype.trim()); + return sourceTypeDao.getBySourceType(paytype.trim()); } return null; } @Override - public boolean saveOrUpdatePaytype(TSourceType paytype) { + @Cacheable(cacheNames = "source_type_cache") + public List getAllSourceType() { + return sourceTypeDao.findAll(); + } + + @Override + @Cacheable(cacheNames = "source_type_cache", key = "#paytype.sourceType") + public boolean saveOrUpdateSourceType(TSourceType paytype) { if (null != paytype) { - paytypeDao.save(paytype); + sourceTypeDao.save(paytype); return true; } return false; } @Override - public boolean deletePaytype(TSourceType paytype) { + @CacheEvict(cacheNames = "source_type_cache", key = "#paytype.sourceType") + public boolean deleteSourceType(TSourceType paytype) { if (null != paytype) { - paytypeDao.delete(paytype); + sourceTypeDao.delete(paytype); return true; } return false; } @Override - public List getPaytypeConfigList(String paytype) { + @Cacheable(cacheNames = "source_type_config_cache", key = "#p0") + public List getSourceTypeConfigList(String paytype) { if (!StringUtil.isEmpty(paytype)) { List list = paytypeConfigDao.getByPaytypeOrderByConfigid(paytype.trim()); if (!StringUtil.isEmpty(list)) @@ -195,8 +207,9 @@ public class ParamServiceImpl implements ParamService { } @Override - public boolean savePaytypeConfig(String paytype, Map param) throws WebCheckException { - TSourceType tPaytype = getPaytype(paytype); + @Cacheable(cacheNames = "source_type_config_cache", key = "#p0") + public boolean saveSourceTypeConfig(String paytype, Map param) throws WebCheckException { + TSourceType tPaytype = getSourceType(paytype); if (null == tPaytype) throw new WebCheckException("支付能力[" + paytype + "]不存在"); for (String key : param.keySet()) { String value = param.get(key); diff --git a/src/main/java/com/supwisdom/dlpay/system/service/impl/ShopDataServiceImpl.java b/src/main/java/com/supwisdom/dlpay/system/service/impl/ShopDataServiceImpl.java index 0594fccf..88d4deb0 100644 --- a/src/main/java/com/supwisdom/dlpay/system/service/impl/ShopDataServiceImpl.java +++ b/src/main/java/com/supwisdom/dlpay/system/service/impl/ShopDataServiceImpl.java @@ -159,15 +159,6 @@ public class ShopDataServiceImpl implements ShopDataService { } } - @Override - public List getConsumePaytypes() { - List list = paytypeDao.getConsumeSourceTypes(); - if (!StringUtil.isEmpty(list)) { - return list; - } - return new ArrayList(0); - } - @Override public PageResult getShopPaytypeInfos(String shopaccno, String paytype, int pageNo, int pageSize) { Pageable pageable = PageRequest.of(pageNo - 1, pageSize, Sort.by("shopaccno", "paytype")); diff --git a/src/main/kotlin/com/supwisdom/dlpay/PayApiApplication.kt b/src/main/kotlin/com/supwisdom/dlpay/PayApiApplication.kt index 944944fe..0181d2d6 100644 --- a/src/main/kotlin/com/supwisdom/dlpay/PayApiApplication.kt +++ b/src/main/kotlin/com/supwisdom/dlpay/PayApiApplication.kt @@ -4,6 +4,7 @@ import io.lettuce.core.ReadFrom import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +import org.springframework.cache.annotation.EnableCaching import org.springframework.cloud.client.discovery.EnableDiscoveryClient import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @@ -70,6 +71,7 @@ class HttpSessionConfig { @SpringBootApplication @EnableDiscoveryClient @EnableScheduling +@EnableCaching class PayApiApplication fun main(args: Array) { diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index 6b60981a..5e91f802 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -490,21 +490,21 @@ INSERT INTO "tb_transcode" ("transcode", "transname", "tenantid") VALUES (3500, '账户充值', '{tenantid}'); INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") -VALUES ('cancel', 1, '冲正', '冲正状态', '{tenantid}'); +VALUES ('cancel', 'reverseFlagList', '冲正', '冲正状态', '{tenantid}'); INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") -VALUES ('reverse', 1, '手工撤销', '冲正状态', '{tenantid}'); +VALUES ('reverse', 'reverseFlagList', '手工撤销', '冲正状态', '{tenantid}'); INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") -VALUES ('none', 1, ' ', '冲正状态', '{tenantid}'); +VALUES ('none', 'reverseFlagList', '-', '冲正状态', '{tenantid}'); INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") -VALUES ('init', 2, '初始化', '流水状态', '{tenantid}'); +VALUES ('init', 'dtlStatusList', '初始化', '流水状态', '{tenantid}'); INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") -VALUES ('success', 2, '交易成功', '流水状态', '{tenantid}'); +VALUES ('success', 'dtlStatusList', '交易成功', '流水状态', '{tenantid}'); INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") -VALUES ('fail', 2, '交易失败', '流水状态', '{tenantid}'); +VALUES ('fail', 'dtlStatusList', '交易失败', '流水状态', '{tenantid}'); INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") -VALUES ('wip', 2, '待支付', '流水状态', '{tenantid}'); +VALUES ('wip', 'dtlStatusList','待支付', '流水状态', '{tenantid}'); INSERT INTO "tb_dictionary" ("dictval", "dicttype", "dictcaption", "dicttypename", "tenantid") -VALUES ('cancel', 2, '交易取消', '流水状态', '{tenantid}'); +VALUES ('cancel','dtlStatusList', '交易取消', '流水状态', '{tenantid}'); ---------------------------------------------------- commit; \ No newline at end of file diff --git a/src/main/resources/static/libs/custom.js b/src/main/resources/static/libs/custom.js index 24dc9ad4..e91928dd 100644 --- a/src/main/resources/static/libs/custom.js +++ b/src/main/resources/static/libs/custom.js @@ -21,7 +21,7 @@ data: "dicttype=" + dictType, contentType: "application/x-www-form-urlencoded", success: function (data) { - if (data == null || data == "") { + if (data == null || data === "") { that.storage.removeItem(dictType); } else { that.storage.setItem(dictType, JSON.stringify(data)); @@ -60,15 +60,15 @@ }, initAll: function (url) { this.url = url; - this.addNewDict("allSourcetypeList").addNewDict("allReverseflagList"); + this.addNewDict("sourcetypeList").addNewDict("reverseFlagList"); }, getDict: function (dictType) { var dict, that = this; - if (that.pool[dictType] != undefined) { + if (that.pool[dictType] !== undefined) { return that.pool[dictType]; } else { dict = that.storage.getItem(dictType); - if (dict == undefined) { + if (dict === undefined) { return null; } else { that.pool[dictType] = JSON.parse(dict); @@ -83,7 +83,7 @@ return code; } else { var c = "" + code; - return dict[c] == undefined ? code : dict[c]; + return dict[c] === undefined ? code : dict[c]; } } } diff --git a/src/main/resources/templates/system/dtl/userdtl.html b/src/main/resources/templates/system/dtl/userdtl.html index 4291d599..a2e9d964 100644 --- a/src/main/resources/templates/system/dtl/userdtl.html +++ b/src/main/resources/templates/system/dtl/userdtl.html @@ -12,7 +12,8 @@
-
-
@@ -47,7 +48,7 @@
@@ -58,12 +59,14 @@
-
-
-
@@ -92,7 +95,7 @@
@@ -181,25 +184,33 @@ {field: 'userName', title: '姓名', align: 'center', width: 150}, {field: 'amount', title: '交易金额', align: 'center', width: 120, sort: true}, { - field: 'transStatus', title: '状态', align: 'center', width: 90, templet: function (item) { - if (item.transStatus == 'init') { + field: 'status', + title: '状态', + align: 'center', + width: 90, + templet: function (item) { + if (item.status === 'init') { return '初始化'; - } else if (item.transStatus == 'success') { + } else if (item.status === 'success') { return '成功'; - } else if (item.transStatus == 'fail') { + } else if (item.status === 'fail') { return '失败'; - } else if (item.transStatus == 'wip') { + } else if (item.status === 'wip') { return '待支付'; } else { - return item.transStatus; + return item.status; } } }, { - field: 'tradeflag', title: '类型', align: 'center', width: 60, templet: function (item) { - if (item.tradeflag == 'in') { + field: 'tradeflag', + title: '类型', + align: 'center', + width: 60, + templet: function (item) { + if (item.tradeflag === 'in') { return '收入'; - } else if (item.tradeflag == 'out') { + } else if (item.tradeflag === 'out') { return '支出'; } else { return item.tradeflag; @@ -215,12 +226,16 @@ width: 130, sort: true, templet: function (item) { - return getTempDictValue('allSourcetypeList', item.sourceType); + return getTempDictValue('sourcetypeList', item.sourceType); } }, { - field: 'reverseFlag', title: '冲正状态', align: 'center', width: 100, templet: function (item) { - return getTempDictValue('allReverseflagList', item.reverseFlag); + field: 'reverseFlag', + title: '冲正状态', + align: 'center', + width: 100, + templet: function (item) { + return getTempDictValue('reverseFlagList', item.reverseFlag); } }, {field: 'oppositeAccName', title: '交易对象', align: 'center', width: 250},