liujie
2 天以前 3033ccf3878fae2c204df53be2a283f29f5853ed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.ruoyi.system.service.impl;
 
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>
 * 产品介绍 服务实现类
 * </p>
 *
 * @author xiaochen
 * @since 2025-08-20
 */
@Service
public class TSysProductIntroductionServiceImpl extends ServiceImpl<TSysProductIntroductionMapper, TSysProductIntroduction> implements TSysProductIntroductionService {
 
    @Autowired
    private RedisCache redisCache;
 
    @Override
    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;
    }
    @Override
    public PageInfo<TSysProductIntroduction> pageListApp(TSysProductIntroductionQuery query) {
        PageInfo<TSysProductIntroduction> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TSysProductIntroduction> list = this.baseMapper.pageListApp(query,pageInfo);
        pageInfo.setRecords(list);
        return pageInfo;
    }
}