| | |
| | | <artifactId>mybatis-plus-boot-starter</artifactId> |
| | | <version>3.4.2</version> |
| | | </dependency> |
| | | <dependency> |
| | | <!-- <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
| | | <artifactId>spring-boot-starter-test</artifactId> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | </dependency>--> |
| | | <!-- Swagger2 核心依赖 --> |
| | | <dependency> |
| | | <groupId>io.springfox</groupId> |
| | |
| | | <version>${spring-boot.version}</version> |
| | | <configuration> |
| | | <mainClass>com.linghu.LingHuApplication</mainClass> |
| | | <skip>true</skip> |
| | | |
| | | </configuration> |
| | | <executions> |
| | | <execution> |
| | |
| | | @RequestParam(value = "type_id",required = false) Integer type_id, |
| | | @RequestParam(value = "keywordId", required = false) Integer keywordId, |
| | | @RequestParam(value = "questionId",required = false) Integer questionId, |
| | | @RequestParam(value = "isNow") Integer isNow |
| | | @RequestParam(value = "isNow",required = false) Integer isNow |
| | | ) { |
| | | List<Integer> platForm=new ArrayList<>(); |
| | | //先查找当前关键词下,所有的回答 的 所有的平台名称 |
| | | Keyword keyword = keywordMapper.selectById(keywordId); |
| | | Keyword keyword=new Keyword(); |
| | | if (keywordId!=null){ |
| | | keyword = keywordMapper.selectById(keywordId); |
| | | } |
| | | |
| | | if (keywordId != null && questionId == null) { |
| | | |
| | | List<Reference> references = referenceMapper.selectList(new LambdaQueryWrapper<Reference>() |
| | |
| | | ); |
| | | platForm = references.stream().map(Reference::getPlatform_id).filter(Objects::nonNull).distinct().collect(Collectors.toList()); |
| | | } |
| | | if (questionId != null) { |
| | | if (keywordId != null && questionId != null) { |
| | | List<Reference> references = referenceMapper.selectList(new LambdaQueryWrapper<Reference>() |
| | | .eq(Reference::getKeyword_id, keywordId) |
| | | .eq(Reference::getNum, isNow== 0 ? 1 : keyword.getNum()) |
| | |
| | | if (!platForm.isEmpty()){ |
| | | queryWrapper.in(Platform::getPlatform_id, platForm); |
| | | }else { |
| | | if (page != null && pageSize != null){ |
| | | Page<Platform> pageInfo = new Page<>(page, pageSize); |
| | | Page<Platform> result = platformService.page(pageInfo, queryWrapper); |
| | | return ResponseResult.success(new CustomPage<>(result)); |
| | | }else { |
| | | CustomPage<Platform> customPage = new CustomPage<>(new Page<>()); |
| | | customPage.setRecords(new ArrayList<>()); |
| | | customPage.setTotal(0); |
| | | return ResponseResult.success(customPage); |
| | | } |
| | | |
| | | } |
| | | |
| | | if (type_id != null) { |
| | | queryWrapper.eq(Platform::getType_id, type_id); |
| | | } |
| | |
| | | @RequestParam(required = false) Integer pageSize, |
| | | @RequestParam(required = false) Integer keywordId, |
| | | @RequestParam(required = false) Integer questionId, |
| | | @RequestParam Integer isNow |
| | | @RequestParam(required = false) Integer isNow |
| | | ) { |
| | | List<Integer> typeIds=new ArrayList<>(); |
| | | Keyword keyword=new Keyword(); |
| | | //先查找当前关键词下,所有的回答 的 所有的平台名称 |
| | | Keyword keyword = keywordMapper.selectById(keywordId); |
| | | if (isNow==0){ |
| | | typeIds= keywordMapper.getTypeIds(keywordId,questionId,0); |
| | | }else { |
| | | typeIds= keywordMapper.getTypeIds(keywordId,questionId,keyword.getNum()); |
| | | if (keywordId != null) { |
| | | keyword = keywordMapper.selectById(keywordId); |
| | | } |
| | | |
| | | |
| | | typeIds= keywordMapper.getTypeIds(keywordId,questionId,isNow,keyword); |
| | | |
| | | |
| | | |
| | | /* if (keywordId != null && questionId == null) { |
| | | |
| | |
| | | if (!typeIds.isEmpty()) { |
| | | queryWrapper.in(Type::getType_id, typeIds); |
| | | }else { |
| | | if (page != null && pageSize != null) { |
| | | Page<Type> pageInfo = new Page<>(page, pageSize); |
| | | Page<Type> result = typeService.page(pageInfo, queryWrapper); |
| | | return ResponseResult.success(result.getRecords()); |
| | | }else { |
| | | return ResponseResult.success(new ArrayList<>()); |
| | | } |
| | | |
| | | } |
| | | |
| | | if (page != null && pageSize != null) { |
| | | Page<Type> pageInfo = new Page<>(page, pageSize); |
| | | Page<Type> result = typeService.page(pageInfo, queryWrapper); |
| | |
| | | |
| | | List<ResultListVO> getResultByPlatformId(@Param("keywordId") Integer keywordId, @Param("questionId")Integer questionId, @Param("num")Integer num, @Param("platformId") Integer platformId); |
| | | |
| | | List<Integer> getTypeIds(@Param("keywordId") Integer keywordId, @Param("questionId") Integer questionId, @Param("num") Integer num); |
| | | List<Integer> getTypeIds(@Param("keywordId") Integer keywordId, @Param("questionId") Integer questionId, @Param("isNow") Integer isNow,@Param("keyword") Keyword keyword); |
| | | } |
| | | |
| | | |
| | |
| | | <if test="questionId != null"> |
| | | AND r.question_id = #{questionId} |
| | | </if> |
| | | AND r.num = #{num} |
| | | <if test="isNow != null"> |
| | | <!-- 当 isNow=1 时使用 keyword.num,否则使用 1 --> |
| | | AND r.num = |
| | | <choose> |
| | | <when test="isNow == 1"> |
| | | #{keyword.num} |
| | | </when> |
| | | <otherwise> |
| | | 1 |
| | | </otherwise> |
| | | </choose> |
| | | </if> |
| | | |
| | | |
| | | ORDER BY t.type_id -- 按 type_id 排序,结果更规范 |
| | | </select> |
| | | </mapper> |