|
@@ -404,20 +404,22 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
|
|
Long dirId = param.getDirId();
|
|
Long dirId = param.getDirId();
|
|
StringBuilder builder = new StringBuilder();
|
|
StringBuilder builder = new StringBuilder();
|
|
builder.append("( ");
|
|
builder.append("( ");
|
|
- builder.append("select id,create_time,update_time,name, null as status, IFNULL(null,'dir') as type,user_id, null as icon,null as preview_icon, " +
|
|
|
|
- "null as file_name, null as file_size,null as oss_path, null as scene_code,null as dpi,null as temp_id,parent_id as dir_id, null as dirName, " +
|
|
|
|
- "IFNULL(null, 1) as sortType from tb_dir where is_delete=0") ;
|
|
|
|
- builder.append(" and user_id='").append(userName).append("'");
|
|
|
|
- builder.append(" and type='").append(type).append("'");
|
|
|
|
- if (dirId != null && dirId > 1){
|
|
|
|
- builder.append(" and parent_id=").append(dirId);
|
|
|
|
- } else {
|
|
|
|
- builder.append(" and parent_id=1");
|
|
|
|
- }
|
|
|
|
|
|
+ builder.append("select a.id,a.create_time,a.update_time,a.name, null as status, IFNULL(null,'dir') as type,a.user_id, null as icon,null as preview_icon, " +
|
|
|
|
+ "null as file_name, null as file_size,null as oss_path, null as scene_code,null as dpi,null as temp_id,a.parent_id as dir_id, b.name as dirName, " +
|
|
|
|
+ "IFNULL(null, 1) as sortType from tb_dir a left join tb_dir b on b.id=a.parent_id where a.is_delete=0") ;
|
|
|
|
+ builder.append(" and a.user_id='").append(userName).append("'");
|
|
|
|
+ builder.append(" and a.type='").append(type).append("'");
|
|
|
|
|
|
|
|
+ // 搜索是互斥关系
|
|
if (StrUtil.isNotBlank(searchKey)){
|
|
if (StrUtil.isNotBlank(searchKey)){
|
|
searchKey = RegexUtil.sqlReplaceSpecialStr(searchKey);
|
|
searchKey = RegexUtil.sqlReplaceSpecialStr(searchKey);
|
|
- builder.append(" and name like '%").append(searchKey).append("%'");
|
|
|
|
|
|
+ builder.append(" and a.name like '%").append(searchKey).append("%'");
|
|
|
|
+ } else {
|
|
|
|
+ if (dirId != null && dirId > 1){
|
|
|
|
+ builder.append(" and a.parent_id=").append(dirId);
|
|
|
|
+ } else {
|
|
|
|
+ builder.append(" and a.parent_id=1");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
builder.append(" ) union all ( ");
|
|
builder.append(" ) union all ( ");
|
|
@@ -431,16 +433,18 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
|
|
builder.append(" and a.user_id='").append(userName).append("'");
|
|
builder.append(" and a.user_id='").append(userName).append("'");
|
|
builder.append(" and a.type='").append(type).append("'");
|
|
builder.append(" and a.type='").append(type).append("'");
|
|
|
|
|
|
- // dirId为空或者为1 :根目录
|
|
|
|
- if (dirId != null && dirId > 1){
|
|
|
|
- builder.append(" and a.dir_id=").append(dirId);
|
|
|
|
- } else {
|
|
|
|
- builder.append(" and (a.dir_id is null or a.dir_id=1)");
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
|
|
if (StrUtil.isNotBlank(searchKey)){
|
|
if (StrUtil.isNotBlank(searchKey)){
|
|
searchKey = RegexUtil.sqlReplaceSpecialStr(searchKey);
|
|
searchKey = RegexUtil.sqlReplaceSpecialStr(searchKey);
|
|
builder.append(" and a.name like '%").append(searchKey).append("%'");
|
|
builder.append(" and a.name like '%").append(searchKey).append("%'");
|
|
|
|
+ } else {
|
|
|
|
+ // dirId为空或者为1 :根目录
|
|
|
|
+ if (dirId != null && dirId > 1){
|
|
|
|
+ builder.append(" and a.dir_id=").append(dirId);
|
|
|
|
+ } else {
|
|
|
|
+ builder.append(" and (a.dir_id is null or a.dir_id=1)");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|