码迷,mamicode.com
首页 > 其他好文 > 详细

service层,抽取为接口

时间:2021-04-30 12:36:32      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:ota   png   mod   autowire   启动   auto   ati   add   name   

抽取为接口后,

 

springboot事务开启,不在报错。

@Transactional
public interface DescriptionService {

    
    public Description addDescription(Description description) ;

启动类

@SpringBootApplication
@EnableTransactionManagement
@MapperScan(basePackages = {"cn.taotao.dao"})
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 20*60)
@EnableCaching
public class Zhouyi3Application {

    
    public static void main(String[] args) {
        SpringApplication.run(Zhouyi3Application.class, args);
    }

    
}

 

 

springboot的redis注解,不再报错。

@Service
public class DescriptionServiceImpl implements DescriptionService {

    @Autowired
    private DescriptionMapper descriptionMapper;
    @Autowired
    private CategoryService categoryService;
    
    //@CachePut(cacheNames = "Description",key = "#description.id")
    public Description addDescription(Description description) {
        descriptionMapper.addDescription(description);
        descriptionMapper.updateDescriptionOrder(description.getId(), description.getId()*10);
        return description;
    }
    
    @CachePut(cacheNames = "Description",key="‘id:‘+#description.id")
    public Description modifyDescription(Description description) {
        descriptionMapper.modifyDescription(description);
        return description;
    }

 

抽取接口示意图

技术图片

 

service层,抽取为接口

标签:ota   png   mod   autowire   启动   auto   ati   add   name   

原文地址:https://www.cnblogs.com/sdgtxuyong/p/14720689.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!