mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-26 23:22:44 +08:00
学员列表返回学员所属部门
This commit is contained in:
parent
c1b3029f4b
commit
89ae0e0b78
@ -83,7 +83,14 @@ public class UserController {
|
||||
}
|
||||
|
||||
PaginationResult<User> result = userService.paginate(page, size, filter);
|
||||
return JsonResponse.data(result);
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("data", result.getData());
|
||||
data.put("total", result.getTotal());
|
||||
data.put("user_dep_ids", userService.getDepIdsGroup(result.getData().stream().map(User::getId).toList()));
|
||||
data.put("departments", departmentService.id2name());
|
||||
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_STORE)
|
||||
|
@ -8,6 +8,7 @@ import xyz.playedu.api.types.paginate.PaginationResult;
|
||||
import xyz.playedu.api.types.paginate.UserPaginateFilter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author tengteng
|
||||
@ -44,4 +45,6 @@ public interface UserService extends IService<User> {
|
||||
Long todayCount();
|
||||
|
||||
Long yesterdayCount();
|
||||
|
||||
Map<Integer, List<Integer>> getDepIdsGroup(List<Integer> userIds);
|
||||
}
|
||||
|
@ -19,7 +19,10 @@ import xyz.playedu.api.util.HelperUtil;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author tengteng
|
||||
@ -185,6 +188,22 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
String yesterdayDate = simpleDateFormat.format(new Date(System.currentTimeMillis() - 86400000));
|
||||
return count(query().getWrapper().between("created_at", simpleDateFormat.parse(yesterdayDate), simpleDateFormat.parse(todayDate)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, List<Integer>> getDepIdsGroup(List<Integer> userIds) {
|
||||
if (userIds == null || userIds.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
Map<Integer, List<UserDepartment>> data = userDepartmentService
|
||||
.list(userDepartmentService.query().getWrapper().in("user_id", userIds))
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(UserDepartment::getUserId));
|
||||
Map<Integer, List<Integer>> result = new HashMap<>();
|
||||
data.forEach((userId, records) -> {
|
||||
result.put(userId, records.stream().map(UserDepartment::getDepId).toList());
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user