fix: 修复关联表查询速度慢的问题
This commit is contained in:
+8
-1
@@ -459,7 +459,14 @@ public class TsUserServiceImpl extends ServiceImpl<TsUserDao, TsUser> implements
|
|||||||
@Override
|
@Override
|
||||||
public IPage<TsUser> getAllUsers(TsUser tsUser) {
|
public IPage<TsUser> getAllUsers(TsUser tsUser) {
|
||||||
List<String> ids=new ArrayList<>();
|
List<String> ids=new ArrayList<>();
|
||||||
ids.add(tsUser.getInstitutionId());
|
QueryWrapper<TsInstitution> queryWrapper=new QueryWrapper<>();
|
||||||
|
queryWrapper.like("parent_id",tsUser.getInstitutionId());
|
||||||
|
List<TsInstitution> tsmiddle=tsInstitutionService.list(queryWrapper);
|
||||||
|
if(tsmiddle!=null && !tsmiddle.isEmpty()){
|
||||||
|
tsmiddle.forEach(tsInstitution -> {
|
||||||
|
ids.add(tsInstitution.getId());
|
||||||
|
});
|
||||||
|
}
|
||||||
// List<String> middle=new ArrayList<>();
|
// List<String> middle=new ArrayList<>();
|
||||||
// middle.addAll(ids);
|
// middle.addAll(ids);
|
||||||
// boolean flag=true;
|
// boolean flag=true;
|
||||||
|
|||||||
@@ -82,8 +82,6 @@
|
|||||||
on u.usid=up.user_id
|
on u.usid=up.user_id
|
||||||
left join ts_position p
|
left join ts_position p
|
||||||
on up.position_id=p.id
|
on up.position_id=p.id
|
||||||
left join ts_institution ti
|
|
||||||
on ti.id = u.INSTITUTION_ID
|
|
||||||
where 1=1
|
where 1=1
|
||||||
<if test="TsUser.uname != null and TsUser.uname != '' ">
|
<if test="TsUser.uname != null and TsUser.uname != '' ">
|
||||||
and (u.uname like concat('%',#{TsUser.uname},'%') or u.ACCOUNT like concat(#{TsUser.uname},'%'))
|
and (u.uname like concat('%',#{TsUser.uname},'%') or u.ACCOUNT like concat(#{TsUser.uname},'%'))
|
||||||
@@ -92,9 +90,9 @@
|
|||||||
and u.email like concat('%',#{TsUser.email},'%')
|
and u.email like concat('%',#{TsUser.email},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test=" null != ids and ids.size()> 0">
|
<if test=" null != ids and ids.size()> 0">
|
||||||
and
|
and INSTITUTION_ID in
|
||||||
<foreach item="id" collection="ids" open="(" separator="or" close=")" index="index">
|
<foreach item="id" collection="ids" open="(" separator="," close=")" index="index">
|
||||||
ti.parent_ids like concat('%',#{id},'%')
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
ORDER BY p.id is null,p.create_time
|
ORDER BY p.id is null,p.create_time
|
||||||
@@ -107,8 +105,6 @@
|
|||||||
on u.usid=up.user_id
|
on u.usid=up.user_id
|
||||||
left join ts_position p
|
left join ts_position p
|
||||||
on up.position_id=p.id
|
on up.position_id=p.id
|
||||||
left join ts_institution ti
|
|
||||||
on ti.id = u.INSTITUTION_ID
|
|
||||||
where 1=1
|
where 1=1
|
||||||
<if test="TsUser.uname != null and TsUser.uname != '' ">
|
<if test="TsUser.uname != null and TsUser.uname != '' ">
|
||||||
and u.uname like concat('%',#{TsUser.uname},'%')
|
and u.uname like concat('%',#{TsUser.uname},'%')
|
||||||
@@ -117,9 +113,9 @@
|
|||||||
and u.email like concat('%',#{TsUser.email},'%')
|
and u.email like concat('%',#{TsUser.email},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test=" null != ids and ids.size()> 0">
|
<if test=" null != ids and ids.size()> 0">
|
||||||
and
|
and INSTITUTION_ID in
|
||||||
<foreach item="id" collection="ids" open="(" separator="or" close=")" index="index">
|
<foreach item="id" collection="ids" open="(" separator="," close=")" index="index">
|
||||||
ti.parent_ids like concat('%',#{id},'%')
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
Reference in New Issue
Block a user