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