liujie
2 天以前 3033ccf3878fae2c204df53be2a283f29f5853ed
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TSysProductIntroductionServiceImpl.java
@@ -2,14 +2,20 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.system.mapper.TSysProductIntroductionMapper;
import com.ruoyi.system.model.TSysEducationalInfo;
import com.ruoyi.system.model.TSysProductIntroduction;
import com.ruoyi.system.query.TSysProductIntroductionQuery;
import com.ruoyi.system.service.TSysProductIntroductionService;
import com.ruoyi.system.vo.TSysProductIntroductionVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Set;
/**
 * <p>
@@ -22,10 +28,25 @@
@Service
public class TSysProductIntroductionServiceImpl extends ServiceImpl<TSysProductIntroductionMapper, TSysProductIntroduction> implements TSysProductIntroductionService {
    @Autowired
    private RedisCache redisCache;
    @Override
    public PageInfo<TSysProductIntroduction> pageList(TSysProductIntroductionQuery query) {
        PageInfo<TSysProductIntroduction> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TSysProductIntroduction> list = this.baseMapper.pageList(query,pageInfo);
    public PageInfo<TSysProductIntroductionVO> pageList(TSysProductIntroductionQuery query) {
        PageInfo<TSysProductIntroductionVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TSysProductIntroductionVO> list = this.baseMapper.pageList(query,pageInfo);
        if (CollectionUtils.isEmpty(list)){
            return pageInfo;
        }
        if(query.getRoleType() == 5){
            Long userId = query.getUserId();
            for (TSysProductIntroductionVO tSysProductIntroduction : list) {
                Set<Long> cacheSet = redisCache.getCacheSet(Constants.SYS_PRODUCT_CLICK_COUNT + tSysProductIntroduction.getId());
                if(cacheSet.contains(userId)){
                    tSysProductIntroduction.setIsView(true);
                }
            }
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }