From 695667938a55f89e8fef45c8bd50550c23e45782 Mon Sep 17 00:00:00 2001 From: Tang Cheng Date: Tue, 28 May 2019 10:16:40 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E6=94=B9sourcetype=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 + .../supwisdom/dlpay/api/service/SourceTypeService.java | 9 +++++---- .../dlpay/api/service/impl/SourceTypeServiceImpl.java | 5 +++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index d9303c58..b11247b4 100644 --- a/build.gradle +++ b/build.gradle @@ -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' diff --git a/src/main/java/com/supwisdom/dlpay/api/service/SourceTypeService.java b/src/main/java/com/supwisdom/dlpay/api/service/SourceTypeService.java index 036007de..86a98418 100644 --- a/src/main/java/com/supwisdom/dlpay/api/service/SourceTypeService.java +++ b/src/main/java/com/supwisdom/dlpay/api/service/SourceTypeService.java @@ -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 getPaytypeConfigByPaytype(String pattype); + @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, readOnly = true) + Map getPaytypeConfigByPaytype(String pattype); } diff --git a/src/main/java/com/supwisdom/dlpay/api/service/impl/SourceTypeServiceImpl.java b/src/main/java/com/supwisdom/dlpay/api/service/impl/SourceTypeServiceImpl.java index 247342c3..60cf1a57 100644 --- a/src/main/java/com/supwisdom/dlpay/api/service/impl/SourceTypeServiceImpl.java +++ b/src/main/java/com/supwisdom/dlpay/api/service/impl/SourceTypeServiceImpl.java @@ -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 getPaytypeConfigByPaytype(String pattype) { List list = paytypeConfigDao.getByPaytype(pattype); Map map = new HashMap<>(list.size()); -- 2.17.1