Commit d124ac74 by yao.xiao

优化sql

parent 87108f78
...@@ -522,12 +522,14 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service. ...@@ -522,12 +522,14 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
for (ObjectCollectionTagged tagged: taggeds) { for (ObjectCollectionTagged tagged: taggeds) {
tagIds.add(Long.valueOf(tagged.getMdTagId())); tagIds.add(Long.valueOf(tagged.getMdTagId()));
} }
List<MdTag> mdTags = mdTagDALService.findByTagIdIn(tagIds); if (!tagIds.isEmpty()){
for (MdTag mdTag:mdTags) { List<MdTag> mdTags = mdTagDALService.findByTagIdIn(tagIds);
OpportunityCustomerTag tag = new OpportunityCustomerTag(); for (MdTag mdTag:mdTags) {
tag.setTagId(mdTag.getId()); OpportunityCustomerTag tag = new OpportunityCustomerTag();
tag.setTagName(mdTag.getTagName()); tag.setTagId(mdTag.getId());
tags.add(tag); tag.setTagName(mdTag.getTagName());
tags.add(tag);
}
} }
return tags; return tags;
} }
......
...@@ -124,17 +124,12 @@ ...@@ -124,17 +124,12 @@
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from ag_md_tag from ag_md_tag
<where> <where>
<choose> <if test="tagIds != null and tagIds.size() > 0">
<when test="tagIds != null and tagIds.size() > 0"> id in
id in <foreach item="item" collection="tagIds" separator="," open="(" close=")" index="index">
<foreach item="item" collection="tagIds" separator="," open="(" close=")" index="index"> #{item}
#{item} </foreach>
</foreach> </if>
</when>
<otherwise>
1 = 2
</otherwise>
</choose>
</where> </where>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
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