| | |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.model.TSysActivity; |
| | | import com.ruoyi.system.model.TSysEducationalInfo; |
| | | import com.ruoyi.system.model.TSysLive; |
| | | import com.ruoyi.system.model.TSysProductIntroduction; |
| | | import com.ruoyi.system.query.TSysProductIntroductionQuery; |
| | | import com.ruoyi.system.service.TSysActivityService; |
| | | import com.ruoyi.system.service.TSysEducationalInfoService; |
| | | import com.ruoyi.system.service.TSysLiveService; |
| | | import com.ruoyi.system.service.TSysProductIntroductionService; |
| | | import com.ruoyi.system.vo.TSysProductIntroductionVO; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private final TSysProductIntroductionService sysProductIntroductionService; |
| | | private final TokenService tokenService; |
| | | private final RedisCache redisCache; |
| | | private final TSysEducationalInfoService sysEducationalInfoService; |
| | | private final TSysActivityService sysActivityService; |
| | | private final TSysLiveService sysLiveService; |
| | | @Autowired |
| | | public TSysProductIntroductionController(TSysProductIntroductionService sysProductIntroductionService, TokenService tokenService, RedisCache redisCache) { |
| | | public TSysProductIntroductionController(TSysProductIntroductionService sysProductIntroductionService, TokenService tokenService, RedisCache redisCache, TSysEducationalInfoService sysEducationalInfoService, TSysActivityService sysActivityService, TSysLiveService sysLiveService) { |
| | | this.sysProductIntroductionService = sysProductIntroductionService; |
| | | this.tokenService = tokenService; |
| | | this.redisCache = redisCache; |
| | | this.sysEducationalInfoService = sysEducationalInfoService; |
| | | this.sysActivityService = sysActivityService; |
| | | this.sysLiveService = sysLiveService; |
| | | } |
| | | |
| | | /** |
| | |
| | | @PostMapping(value = "/list") |
| | | public R<List<TSysProductIntroduction>> list() { |
| | | return R.ok(sysProductIntroductionService.list(Wrappers.lambdaQuery(TSysProductIntroduction.class).orderByDesc(TSysProductIntroduction::getCreateTime))); |
| | | } |
| | | |
| | | /** |
| | | * 获取产品介绍管理列表 |
| | | */ |
| | | @ApiOperation(value = "获取产品介绍列表-banner使用") |
| | | @PostMapping(value = "/listBanner") |
| | | public R<List<TSysProductIntroduction>> listBanner() { |
| | | return R.ok(sysProductIntroductionService.list(Wrappers.lambdaQuery(TSysProductIntroduction.class) |
| | | .eq(TSysProductIntroduction::getStatus,1) |
| | | .eq(TSysProductIntroduction::getShowType,1) |
| | | .orderByDesc(TSysProductIntroduction::getCreateTime))); |
| | | } |
| | | |
| | | /** |
| | |
| | | .eq(TSysProductIntroduction::getId,id)); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 热门推荐统计数量 |
| | | */ |
| | | @ApiOperation(value = "热门推荐统计数量") |
| | | @GetMapping(value = "/recommendationsCount") |
| | | public R<Map<String,Integer>> recommendationsCount() { |
| | | |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | // 查询教育资讯 |
| | | List<TSysEducationalInfo> sysEducationalInfos = sysEducationalInfoService.list(Wrappers.<TSysEducationalInfo>lambdaQuery() |
| | | .eq(TSysEducationalInfo::getStatus, 1)); |
| | | int educationalCount = sysEducationalInfos.size(); |
| | | for (TSysEducationalInfo sysEducationalInfo : sysEducationalInfos) { |
| | | Set<Long> userIds = redisCache.getCacheSet(Constants.SYS_EDUCATION_CLICK_COUNT+sysEducationalInfo.getId()); |
| | | if(userIds.contains(userId)){ |
| | | educationalCount = educationalCount - 1; |
| | | } |
| | | } |
| | | // 查询产品介绍 |
| | | List<TSysProductIntroduction> sysProductIntroductions = sysProductIntroductionService.list(Wrappers.lambdaQuery(TSysProductIntroduction.class) |
| | | .eq(TSysProductIntroduction::getStatus, 1)); |
| | | int productCount = sysProductIntroductions.size(); |
| | | for (TSysProductIntroduction sysProductIntroduction : sysProductIntroductions) { |
| | | Set<Long> userIds = redisCache.getCacheSet(Constants.SYS_PRODUCT_CLICK_COUNT+sysProductIntroduction.getId()); |
| | | if(userIds.contains(userId)){ |
| | | productCount = productCount - 1; |
| | | } |
| | | } |
| | | // 查询热门活动 |
| | | List<TSysActivity> sysActivities = sysActivityService.list(Wrappers.lambdaQuery(TSysActivity.class) |
| | | .eq(TSysActivity::getStatus, 1)); |
| | | int activityCount = sysActivities.size(); |
| | | for (TSysActivity sysActivity : sysActivities) { |
| | | Set<Long> userIds = redisCache.getCacheSet(Constants.SYS_ACTIVITY_CLICK_COUNT+sysActivity.getId()); |
| | | if(userIds.contains(userId)){ |
| | | activityCount = activityCount - 1; |
| | | } |
| | | } |
| | | // 查询直播 |
| | | List<TSysLive> sysLives = sysLiveService.list(); |
| | | int liveCount = sysLives.size(); |
| | | for (TSysLive sysLive : sysLives) { |
| | | Set<Long> userIds = redisCache.getCacheSet(Constants.SYS_LIVE_CLICK_COUNT+sysLive.getId()); |
| | | if(userIds.contains(userId)){ |
| | | liveCount = liveCount - 1; |
| | | } |
| | | } |
| | | |
| | | Map<String,Integer> map = new HashMap<>(); |
| | | map.put("educationalCount",educationalCount); |
| | | map.put("productCount",productCount); |
| | | map.put("activityCount",activityCount); |
| | | map.put("liveCount",liveCount); |
| | | return R.ok(map); |
| | | } |
| | | |
| | | } |
| | | |