FragmentService.java 984 B

12345678910111213141516171819202122232425262728293031
  1. package com.goafanti.fragment.service;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.cache.annotation.CachePut;
  4. import org.springframework.cache.annotation.Cacheable;
  5. import org.springframework.stereotype.Service;
  6. import org.springframework.transaction.annotation.Transactional;
  7. import com.goafanti.common.dao.HtmlFragmentMapper;
  8. import com.goafanti.common.model.HtmlFragment;
  9. import com.goafanti.core.mybatis.BaseMybatisDao;
  10. @Service
  11. @Transactional
  12. public class FragmentService extends BaseMybatisDao<HtmlFragmentMapper> {
  13. @Autowired
  14. HtmlFragmentMapper htmlFragmentMapper;
  15. @Cacheable(value = "HtmlFragmentCache", key = "'HtmlFragment:'+#id")
  16. public HtmlFragment selectById(String id) {
  17. return htmlFragmentMapper.selectByPrimaryKey(id);
  18. }
  19. @CachePut(value = "HtmlFragmentCache", key = "'HtmlFragment:'+#id")
  20. public HtmlFragment save(String id, HtmlFragment record) {
  21. htmlFragmentMapper.insert(record);
  22. return record;
  23. }
  24. }