修改sourcetype定义
authorTang Cheng <cheng.tang@supwisdom.com>
Tue, 28 May 2019 02:16:40 +0000 (10:16 +0800)
committerTang Cheng <cheng.tang@supwisdom.com>
Tue, 28 May 2019 02:16:40 +0000 (10:16 +0800)
build.gradle
src/main/java/com/supwisdom/dlpay/api/service/SourceTypeService.java
src/main/java/com/supwisdom/dlpay/api/service/impl/SourceTypeServiceImpl.java

index d9303c5..b11247b 100644 (file)
@@ -34,6 +34,7 @@ dependencies {
 //    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'
     implementation 'org.springframework.social:spring-social-web:1.1.6.RELEASE'
     implementation 'org.jetbrains.kotlin:kotlin-reflect'
     implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
index 036007d..86a9841 100644 (file)
@@ -1,6 +1,7 @@
 package com.supwisdom.dlpay.api.service;
 
 import com.supwisdom.dlpay.api.domain.TSourceType;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -11,10 +12,10 @@ import java.util.Map;
  */
 public interface SourceTypeService {
 
-    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class,readOnly = true)
-    TSourceType getByPaytype(String paytype);
+  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true)
+  TSourceType getByPaytype(String paytype);
 
-    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class,readOnly = true)
-    Map<String,String> getPaytypeConfigByPaytype(String pattype);
+  @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true)
+  Map<String, String> getPaytypeConfigByPaytype(String pattype);
 
 }
index 247342c..60cf1a5 100644 (file)
@@ -6,6 +6,8 @@ import com.supwisdom.dlpay.api.domain.TSourceType;
 import com.supwisdom.dlpay.api.domain.TPaytypeConfig;
 import com.supwisdom.dlpay.api.service.SourceTypeService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheConfig;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
 import java.util.HashMap;
@@ -16,6 +18,7 @@ import java.util.Map;
  * Created by shuwei on 2019/4/9.
  */
 @Service
+@CacheConfig(cacheNames = "sourcetypeCache")
 public class SourceTypeServiceImpl implements SourceTypeService {
   @Autowired
   private SourceTypeDao paytypeDao;
@@ -23,11 +26,13 @@ public class SourceTypeServiceImpl implements SourceTypeService {
   private PaytypeConfigDao paytypeConfigDao;
 
   @Override
+  @Cacheable
   public TSourceType getByPaytype(String paytype) {
     return paytypeDao.getOne(paytype);
   }
 
   @Override
+  @Cacheable
   public Map<String, String> getPaytypeConfigByPaytype(String pattype) {
     List<TPaytypeConfig> list = paytypeConfigDao.getByPaytype(pattype);
     Map<String, String> map = new HashMap<>(list.size());