|
@@ -3,16 +3,12 @@ package com.xjrsoft.module.concat.controller;
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
-import com.xjrsoft.common.enums.DeleteMark;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
-import com.xjrsoft.common.utils.TreeUtil;
|
|
|
+import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
|
|
|
import com.xjrsoft.module.concat.dto.ConcatTreeDto;
|
|
|
-import com.xjrsoft.module.concat.service.IXjrUserService;
|
|
|
import com.xjrsoft.module.concat.vo.ConcatTreeVo;
|
|
|
import com.xjrsoft.module.organization.entity.Department;
|
|
|
import com.xjrsoft.module.organization.service.IDepartmentService;
|
|
|
-import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -22,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @title: 通讯录
|
|
@@ -35,7 +31,6 @@ import java.util.Objects;
|
|
|
@Api(value = "/concat" + "/concat",tags = "通讯录")
|
|
|
@AllArgsConstructor
|
|
|
public class ConcatController {
|
|
|
- private final IXjrUserService xjrUserService;
|
|
|
private final IDepartmentService departmentService;
|
|
|
|
|
|
|
|
@@ -61,21 +56,30 @@ public class ConcatController {
|
|
|
}}
|
|
|
);
|
|
|
}
|
|
|
- MPJLambdaWrapper<XjrUser> wrapper = new MPJLambdaWrapper<>();
|
|
|
- wrapper.leftJoin("xjr_user_dept_relation t2 on t.id = t2.user_id")
|
|
|
- .like("t5.hierarchy", parentId)
|
|
|
- .leftJoin("xjr_user_role_relation t3 ON t.id = t3.user_id")
|
|
|
- .leftJoin("xjr_role t4 ON t4.id = t3.role_id")
|
|
|
- .leftJoin("xjr_department t5 ON t2.dept_id = t5.id")
|
|
|
- .eq("t4.id", 2)
|
|
|
- .eq(StrUtil.isNotEmpty(dto.getName()), XjrUser::getName, dto.getName())
|
|
|
- .eq(StrUtil.isNotEmpty(dto.getMobile()), XjrUser::getMobile, dto.getMobile());
|
|
|
- List<XjrUser> userList = xjrUserService.selectJoinList(XjrUser.class, wrapper);
|
|
|
- for (XjrUser user : userList) {
|
|
|
+ String sql = "SELECT t1.name, t1.mobile,t2.dept_id FROM xjr_user t1" +
|
|
|
+ " LEFT JOIN xjr_user_dept_relation t2 ON t1.id = t2.user_id" +
|
|
|
+ " LEFT JOIN xjr_user_role_relation t3 ON t1.id = t3.user_id" +
|
|
|
+ " LEFT JOIN xjr_department t5 ON t2.dept_id = t5.id" +
|
|
|
+ " WHERE t1.delete_mark = 0" +
|
|
|
+ " AND t3.role_id = 2";
|
|
|
+ if(dto.getDeptId() != null){
|
|
|
+ sql += " AND t5.hierarchy LIKE '%" + dto.getDeptId() + "%'";
|
|
|
+ }else{
|
|
|
+ sql += " AND t5.id = " + parentId;
|
|
|
+ }
|
|
|
+ if(StrUtil.isNotEmpty(dto.getName())){
|
|
|
+ concatList = new ArrayList<>();
|
|
|
+ sql += "AND (t1.mobile = '%" + dto.getName() + "%' OR t1.name LIKE '%" + dto.getName() + "%')";
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> userList = SqlRunnerAdapter.db().selectList(sql);
|
|
|
+ if(StrUtil.isNotEmpty(dto.getName())){
|
|
|
+ concatList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ for (Map<String, Object> user : userList) {
|
|
|
concatList.add(
|
|
|
new ConcatTreeVo(){{
|
|
|
- setName(user.getName());
|
|
|
- setMobile(user.getMobile());
|
|
|
+ setName(user.get("name").toString());
|
|
|
+ setMobile(user.get("mobile").toString());
|
|
|
setType(2);
|
|
|
}}
|
|
|
);
|