Commit 65642149 by wenyang

标签使用场景查询增加条件

parent 73b329a4
......@@ -188,22 +188,61 @@ public class MetadataServiceImpl implements MetadataService {
responseVO.setCommonResult(commonResult);
return responseVO;
}
Long isActive = null,upperTagViewId = null;
String taglevel = null,tagName = null,tagViewType = null;
if(requestVO.getIsActive() != null){
isActive = requestVO.getIsActive().longValue();
}
if(requestVO.getTaglevel() != null){
taglevel = requestVO.getTaglevel();
}
if(requestVO.getUpperTagViewId() != null){
upperTagViewId = requestVO.getUpperTagViewId();
}
if(requestVO.getTagViewType() != null){
tagViewType = requestVO.getTagViewType();
}
if(!CommonUtil.isNullOrBlank(requestVO.getTagName())){
if(requestVO.getTaglevel() == null){
commonResult.setSuccess(false);
commonResult.setMessage(ZHBErrorConfig.getErrorInfo("830036"));
responseVO.setCommonResult(commonResult);
return responseVO;
}
tagName = requestVO.getTagName()+"%";
}
PageHelper.clearPage();//偶然遇到了这个问题,同一个查询结果一会是10个(预期),一会是真实个数(刷新/重启应用就又变成真实个数) 查看日志,发现了问题:结果为10个时查询SQL自动加上了Limit 10
List<MdTagView> mdTagViewList = mdTagViewDALService.selectByIsActive(requestVO.getIsActive().longValue());
if (!CommonUtil.isNullOrBlank(requestVO.getTagViewType())){
BeanPropertyValueEqualsPredicate predicateClause = new BeanPropertyValueEqualsPredicate( "tagViewType", requestVO.getTagViewType());
mdTagViewList = (List<MdTagView>) CollectionUtils.select(mdTagViewList, predicateClause);
List<MdTagView> mdTagViewList = mdTagViewDALService.selectByIsActive(isActive,upperTagViewId,taglevel,tagViewType,tagName);
if(taglevel == null){
if((requestVO.getUpperTagViewId() != null || !CommonUtil.isNullOrBlank(requestVO.getTagName()))){
if(mdTagViewList != null && mdTagViewList.size() >0 && mdTagViewList.get(0) != null)
taglevel = ((MdTagView)mdTagViewList.get(0)).getTagLevel();
}else{
taglevel = "1";
}
}
List<TagViewQueryInfo> tagViewQueryInfos = new ArrayList<>(16);
List<MdTagView> mdTagViewAddList = new ArrayList<>(16);
BeanPropertyValueEqualsPredicate predicateClause = new BeanPropertyValueEqualsPredicate( "tagLevel", "1");
List<MdTagView> objectListSelect = (List<MdTagView>) CollectionUtils.select(mdTagViewList, predicateClause);
mdTagViewAddList.addAll(objectListSelect);
classificationBuildUpMdTagView(mdTagViewList,mdTagViewAddList,objectListSelect,tagViewQueryInfos);
if(isActive == null || isActive == 1L || (taglevel != null || upperTagViewId != null || !CommonUtil.isNullOrBlank(requestVO.getTagName()))){
List<MdTagView> mdTagViewAddList = new ArrayList<>(16);
BeanPropertyValueEqualsPredicate predicateClause = new BeanPropertyValueEqualsPredicate("tagLevel", taglevel);
List<MdTagView> objectListSelect = (List<MdTagView>) CollectionUtils.select(mdTagViewList, predicateClause);
mdTagViewAddList.addAll(objectListSelect);
classificationBuildUpMdTagView(mdTagViewList,mdTagViewAddList,objectListSelect,tagViewQueryInfos);
mdTagViewList.removeAll(mdTagViewAddList);
mdTagViewList.removeAll(mdTagViewAddList);
}else{
for (MdTagView mdTagView : mdTagViewList) {
TagViewQueryInfo tagViewQueryInfo = new TagViewQueryInfo();
BeanUtils.copyProperties(mdTagView,tagViewQueryInfo);
tagViewQueryInfo.setCreatedAt(CommonUtil.dateParseString(mdTagView.getCreatedAt(),"yyyy-MM-dd HH:mm:ss"));
tagViewQueryInfo.setUpdatedAt(CommonUtil.dateParseString(mdTagView.getUpdatedAt(),"yyyy-MM-dd HH:mm:ss"));
tagViewQueryInfos.add(tagViewQueryInfo);
}
}
responseVO.setTagViewQueryInfos(tagViewQueryInfos);
responseVO.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
......@@ -238,11 +277,11 @@ public class MetadataServiceImpl implements MetadataService {
private void tagViewQueryCheck(TagViewQueryRequestVO requestVO, CommonResult commonResult) {
if (CommonUtil.isNullOrZero(requestVO.getIsActive())){
commonResult.setSuccess(false);
commonResult.setMessage(ZHBErrorConfig.getErrorInfo("830031"));
return;
}
// if (CommonUtil.isNullOrZero(requestVO.getIsActive())){
// commonResult.setSuccess(false);
// commonResult.setMessage(ZHBErrorConfig.getErrorInfo("830031"));
// return;
// }
commonResult.setSuccess(true);
commonResult.setMessage(ZHBErrorConfig.getErrorInfo("800000"));
}
......
......@@ -6,6 +6,9 @@ package com.yd.api.metadata.vo;
*/
public class TagViewQueryRequestVO {
private String tagViewType; //标签显示类别(1=12宫格; 2=左侧热榜列表; 3=右上角筛选)
private String taglevel;//标签级别(1=一级; 2=二级; 3=三级)
private Long upperTagViewId;//上级标签
private String tagName;//标签名称
private Integer isActive;// 1=active 2=inactive
/**
......@@ -22,6 +25,47 @@ public class TagViewQueryRequestVO {
this.tagViewType = tagViewType;
}
/**
* @return the taglevel
*/
public String getTaglevel() {
return taglevel;
}
/**
* @param taglevel the taglevel to set
*/
public void setTaglevel(String taglevel) {
this.taglevel = taglevel;
}
/**
* @return the upperTagViewId
*/
public Long getUpperTagViewId() {
return upperTagViewId;
}
/**
* @param upperTagViewId the upperTagViewId to set
*/
public void setUpperTagViewId(Long upperTagViewId) {
this.upperTagViewId = upperTagViewId;
}
/**
* @return the tagName
*/
public String getTagName() {
return tagName;
}
/**
* @param tagName the tagName to set
*/
public void setTagName(String tagName) {
this.tagName = tagName;
}
/**
* @return the isActive
......@@ -36,12 +80,14 @@ public class TagViewQueryRequestVO {
public void setIsActive(Integer isActive) {
this.isActive = isActive;
}
@Override
public String toString() {
return "MdTagView{" +
", tagViewType='" + tagViewType + '\'' +
", taglevel='" + taglevel + '\'' +
", upperTagViewId='" + upperTagViewId + '\'' +
", tagName='" + tagName + '\'' +
", isActive=" + isActive +
'}';
}
......
......@@ -28,5 +28,6 @@ public interface MdTagViewMapper {
int batchInsert(@Param("list") List<MdTagView> list);
List<MdTagView> selectByIsActive(@Param("isActive")Long isActive);
List<MdTagView> selectByIsActive(@Param("isActive")Long isActive,@Param("upperTagViewId")Long upperTagViewId,
@Param("taglevel")String taglevel,@Param("tagViewType")String tagViewType,@Param("tagName")String tagName);
}
\ No newline at end of file
......@@ -9,7 +9,7 @@ import com.yd.dal.entity.meta.MdTagView;
*/
public interface MdTagViewDALService {
List<MdTagView> selectByIsActive(Long isActive);
List<MdTagView> selectByIsActive(Long isActive,Long upperTagViewId,String taglevel,String tagViewType,String tagName);
void insert(MdTagView mdTagView);
......
......@@ -20,8 +20,8 @@ public class MdTagViewDALServiceImpl implements MdTagViewDALService {
public MdTagViewMapper mapper;
@Override
public List<MdTagView> selectByIsActive(Long isActive) {
return mapper.selectByIsActive(isActive);
public List<MdTagView> selectByIsActive(Long isActive,Long upperTagViewId,String taglevel,String tagViewType,String tagName) {
return mapper.selectByIsActive(isActive, upperTagViewId, taglevel, tagViewType, tagName);
}
@Override
......
......@@ -396,8 +396,21 @@
<include refid="Base_Column_List" />
from ag_md_tag_view
<where>
1 = 1
<if test="isActive != null">
is_active = #{isActive,jdbcType=BIGINT}
and is_active = #{isActive,jdbcType=BIGINT}
</if>
<if test="upperTagViewId != null">
and upper_tag_view_id = #{upperTagViewId,jdbcType=BIGINT}
</if>
<if test="taglevel != null">
and tag_level = #{taglevel,jdbcType=VARCHAR}
</if>
<if test="tagViewType != null">
and tag_view_type = #{tagViewType,jdbcType=VARCHAR}
</if>
<if test="tagName != null">
and tag_name like #{tagName,jdbcType=VARCHAR}
</if>
</where>
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment