1.add journal filter by tag

main
Gary 7 months ago
parent e414ad8b12
commit a7fd80ab97

@ -32,6 +32,8 @@ public interface JournalTagDao extends JpaRepository<JournalTag,String>, JpaSpec
@Query(value = "select journal_id FROM tb_journal_tag where tag_id=?1 or tag_id in (select id from tb_tag_info where parent_id=?1)", nativeQuery = true)
List<String> getJournalIdByTagId(String tagId);
@Query(value = "select tb_journal_tag.journal_id FROM tb_journal_tag, tb_tag_info where tb_tag_info.name_ch=?1 and (tb_journal_tag.tag_id=tb_tag_info.id or tb_journal_tag.tag_id in (select tb_tag_info.id from tb_tag_info where tb_tag_info.parent_id=tb_tag_info.id))", nativeQuery = true)
List<String> getJournalIdByTagName(String tag);
@Query(value = "select journal_id from tb_journal_tag where tag_id in (select tag_id from tb_journal_tag where journal_id=?1) and not journal_id=?1 order by rand() limit ?2", nativeQuery = true)
List<String> recommendByJournalId(String journalId, Integer limit);

@ -18,6 +18,8 @@ public class JournalQueryReq implements Serializable {
private static final long serialVersionUID = -1198060864891902188L;
@ApiModelProperty(value = "筛选条件类目Id", example = "民谣/国语 id")
private String categoryId;
@ApiModelProperty(value = "筛选条件:期刊标签", example = "民谣/国语")
private String tag;
@ApiModelProperty(value = "筛选条件:期刊号范围", example = "900~800")
private String journalNoRange;
@ApiModelProperty(value = "分页: 页码以1开始即获取最新的几期", example = "1")
@ -31,8 +33,9 @@ public class JournalQueryReq implements Serializable {
}
public String countString() {
return getString(categoryId) + "_" + getString(journalNoRange);
return getString(categoryId)+ "_" + getString(tag) + "_" + getString(journalNoRange);
}
private String getString(String value) {
return StringTools.isEmpty(value) ? null : value;
}

@ -228,6 +228,9 @@ public class JournalService {
if(StringUtils.isNotBlank(queryReq.getCategoryId())){
return journalTagDao.getJournalIdByTagId(queryReq.getCategoryId());
}
if(StringUtils.isNotBlank(queryReq.getTag())){
return journalTagDao.getJournalIdByTagName(queryReq.getTag());
}
return Collections.emptyList();
}

Loading…
Cancel
Save