You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.6 KiB
58 lines
1.6 KiB
package com.example.demo.serviceImpl;
|
|
|
|
|
|
import com.example.demo.domain.entity.Detail;
|
|
import com.example.demo.mapper.DetailMapper;
|
|
import com.example.demo.sevice.DetailService;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.cache.annotation.CacheConfig;
|
|
import org.springframework.cache.annotation.CachePut;
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import java.util.List;
|
|
|
|
@Service
|
|
@Transactional
|
|
@RequiredArgsConstructor
|
|
@CacheConfig(cacheNames = "detail")
|
|
public class DetailServiceImpl implements DetailService {
|
|
|
|
@Autowired
|
|
|
|
private DetailMapper detailMapper;
|
|
|
|
|
|
@Override
|
|
public int add(Detail detail) {
|
|
return detailMapper.add(detail);
|
|
}
|
|
|
|
@Override
|
|
public int edit(Detail detail) {
|
|
return 0;
|
|
}
|
|
@Cacheable(key="#root.method.name")
|
|
@Override
|
|
public Detail getDetail(int id) {
|
|
return null;
|
|
}
|
|
|
|
@Cacheable(key="#root.method.name+ #detail.hashCode()")
|
|
@Override
|
|
public List<Detail> getAllDetail(Detail detail) {
|
|
return detailMapper.select(detail);
|
|
}
|
|
|
|
@Cacheable(key="#root.method.name + ':'+ #pageNum + '-' + #pageSize + '-' + #detail.hashCode() ")
|
|
@Override
|
|
public PageInfo<Detail> getDetailByPage(int pageNum, int pageSize, Detail detail) {
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
List<Detail> list= detailMapper.select(detail);
|
|
return new PageInfo<>(list);
|
|
}
|
|
}
|