zhangjinli 3 years ago
parent 51da20458e
commit 569143cbcc

@ -83,11 +83,13 @@ public class UserController {
@Operation(summary = "成员列表")
@PostMapping("/list")
@AdminTokenValid
public Result addTag(@Validated @RequestBody UParam param) {
public Result list(@Validated @RequestBody UParam param) {
QueryWrapper<User> qw = new QueryWrapper<>();
qw
.and(param.getDepartment() != null, q -> q.like("t2.name", param.getDepartment())
.or(o -> o.like("t3.name", param.getDepartment())))
// .and(param.getDepartment() != null, q -> q.like("t2.name", param.getDepartment())
// .or(o -> o.like("t3.name", param.getDepartment())))
.inSql(param.getDepartment() != null,"t2.openid",
"SELECT t1.openid from qywxDepartmentUserLink as t1 LEFT JOIN qywxDepartment as t2 on t1.departmentId = t2.departmentId and t2.name like "+"%"+param.getDepartment()+"%")
.like(param.getName() != null, "t1.name", param.getName());
return Result.success(userService.userDpList(MybatisPlusUtil.SetNumPage(param.getPageNum(), param.getPageSize()), qw));
}

@ -26,14 +26,13 @@ public interface QywxDepartmentGroupLinkMapper extends BaseMapper<QywxDepartment
"</script>")
void groupAddDepartment(Integer groupId, List<Integer> departmentIdList, LocalDateTime creatAt);
List<Map> departmentList(Integer groupId);
@Select(" SELECT t1.departmentId,t1.creatAt,t3.name as departmentName\n" +
" ,t4.id as userId,t4.name as userName\n" +
@Select(" SELECT t1.departmentId,t1.creatAt,t2.department as departmentName\n" +
" ,t3.id as userId,t3.name as userName\n" +
" from qywxDepartmentGroupLink as t1\n" +
" LEFT JOIN qywxDepartmentGroup as t2 on t1.groupId = t2.id\n" +
" INNER JOIN qywxDepartment as t3 on t3.departmentId = t1.departmentId\n" +
" INNER JOIN user as t4 on t4.main_department = t1.departmentId\n" +
" where t2.id = #{groupId} \n" +
" GROUP BY userName\n" +
" INNER JOIN (SELECT t.*,d.name as department from qywxDepartmentUserLink t left join qywxDepartment d on t.departmentId = d.departmentId) as t2 on t1.departmentId = t2.departmentId\n" +
" INNER JOIN user as t3 on t3.openid = t2.openid\n" +
" where t1.groupId = #{groupId} \n" +
" GROUP BY userId\n" +
" ORDER BY creatAt DESC")
List<Map> departmentList2(Integer groupId);
@Select("<script> "+

@ -13,15 +13,13 @@
</resultMap>
<select id="departmentList" resultMap="departmentListMap">
SELECT t1.*,t2.name,t3.name as departmentName
,t4.id as userId,t4.name as userName
SELECT t1.departmentId,t1.creatAt,t2.department as departmentName ,t3.id as userId,t3.name as userName
from qywxDepartmentGroupLink as t1
LEFT JOIN qywxDepartmentGroup as t2 on t1.groupId = t2.id
INNER JOIN qywxDepartment as t3 on t3.departmentId = t1.departmentId
LEFT JOIN user as t4 on t4.main_department = t1.departmentId
where t2.id = #{groupId}
GROUP BY groupId, departmentId
,userName
INNER JOIN (SELECT t.*,d.name as department from qywxDepartmentUserLink t left join qywxDepartment d on
t.departmentId = d.departmentId) as t2 on t1.departmentId = t2.departmentId
INNER JOIN user as t3 on t3.openid = t2.openid
where t1.groupId = #{groupId}
GROUP BY groupId, departmentId ,userId
ORDER BY creatAt DESC
</select>

Loading…
Cancel
Save