mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-23 04:22:43 +08:00
commit
1479727e59
@ -4,10 +4,10 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||||
<mirrors>
|
<mirrors>
|
||||||
<mirror>
|
<mirror>
|
||||||
<id>ali</id>
|
<id>Ali</id>
|
||||||
<name>ali Maven</name>
|
<name>Ali Maven</name>
|
||||||
<mirrorOf>*</mirrorOf>
|
<mirrorOf>*</mirrorOf>
|
||||||
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||||
</mirror>
|
</mirror>
|
||||||
</mirrors>
|
</mirrors>
|
||||||
</settings>
|
</settings>
|
||||||
|
2
pom.xml
2
pom.xml
@ -10,7 +10,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<groupId>xyz.playedu</groupId>
|
<groupId>xyz.playedu</groupId>
|
||||||
<artifactId>playedu-api</artifactId>
|
<artifactId>playedu-api</artifactId>
|
||||||
<version>1.0-beta.4</version>
|
<version>1.0-beta.5</version>
|
||||||
<name>playedu-api</name>
|
<name>playedu-api</name>
|
||||||
<description>playedu-api</description>
|
<description>playedu-api</description>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -37,11 +37,11 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class ExceptionController {
|
public class ExceptionController {
|
||||||
|
|
||||||
@ExceptionHandler(Exception.class)
|
// @ExceptionHandler(Exception.class)
|
||||||
public JsonResponse exceptionHandler(Exception e) {
|
// public JsonResponse exceptionHandler(Exception e) {
|
||||||
log.error(e.getMessage());
|
// log.error(e.getMessage());
|
||||||
return JsonResponse.error("系统错误", 500);
|
// return JsonResponse.error("系统错误", 500);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@ExceptionHandler(ServiceException.class)
|
@ExceptionHandler(ServiceException.class)
|
||||||
public JsonResponse serviceExceptionHandler(ServiceException e) {
|
public JsonResponse serviceExceptionHandler(ServiceException e) {
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package xyz.playedu.api.controller.backend;
|
package xyz.playedu.api.controller.backend;
|
||||||
|
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import org.apache.commons.collections4.MapUtils;
|
import org.apache.commons.collections4.MapUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
@ -22,19 +25,21 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import xyz.playedu.api.constant.BPermissionConstant;
|
import xyz.playedu.api.constant.BPermissionConstant;
|
||||||
|
import xyz.playedu.api.domain.User;
|
||||||
import xyz.playedu.api.domain.UserCourseRecord;
|
import xyz.playedu.api.domain.UserCourseRecord;
|
||||||
import xyz.playedu.api.event.UserCourseRecordDestroyEvent;
|
import xyz.playedu.api.event.UserCourseRecordDestroyEvent;
|
||||||
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
|
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
|
||||||
import xyz.playedu.api.request.backend.CourseUserDestroyRequest;
|
import xyz.playedu.api.request.backend.CourseUserDestroyRequest;
|
||||||
import xyz.playedu.api.service.UserCourseRecordService;
|
import xyz.playedu.api.service.*;
|
||||||
import xyz.playedu.api.service.UserService;
|
|
||||||
import xyz.playedu.api.types.JsonResponse;
|
import xyz.playedu.api.types.JsonResponse;
|
||||||
|
import xyz.playedu.api.types.mapper.UserCourseHourRecordUserFirstCreatedAtMapper;
|
||||||
import xyz.playedu.api.types.paginate.PaginationResult;
|
import xyz.playedu.api.types.paginate.PaginationResult;
|
||||||
import xyz.playedu.api.types.paginate.UserCourseRecordPaginateFilter;
|
import xyz.playedu.api.types.paginate.UserPaginateFilter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author 杭州白书科技有限公司
|
* @Author 杭州白书科技有限公司
|
||||||
@ -42,17 +47,25 @@ import java.util.List;
|
|||||||
* @create 2023/3/24 16:08
|
* @create 2023/3/24 16:08
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
@Slf4j
|
||||||
@RequestMapping("/backend/v1/course/{courseId}/user")
|
@RequestMapping("/backend/v1/course/{courseId}/user")
|
||||||
public class CourseUserController {
|
public class CourseUserController {
|
||||||
|
|
||||||
|
@Autowired private CourseService courseService;
|
||||||
|
|
||||||
@Autowired private UserCourseRecordService userCourseRecordService;
|
@Autowired private UserCourseRecordService userCourseRecordService;
|
||||||
|
|
||||||
|
@Autowired private UserCourseHourRecordService userCourseHourRecordService;
|
||||||
|
|
||||||
@Autowired private UserService userService;
|
@Autowired private UserService userService;
|
||||||
|
|
||||||
|
@Autowired private DepartmentService departmentService;
|
||||||
|
|
||||||
@Autowired private ApplicationContext ctx;
|
@Autowired private ApplicationContext ctx;
|
||||||
|
|
||||||
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE_USER)
|
@BackendPermissionMiddleware(slug = BPermissionConstant.COURSE_USER)
|
||||||
@GetMapping("/index")
|
@GetMapping("/index")
|
||||||
|
@SneakyThrows
|
||||||
public JsonResponse index(
|
public JsonResponse index(
|
||||||
@PathVariable(name = "courseId") Integer courseId,
|
@PathVariable(name = "courseId") Integer courseId,
|
||||||
@RequestParam HashMap<String, Object> params) {
|
@RequestParam HashMap<String, Object> params) {
|
||||||
@ -63,25 +76,64 @@ public class CourseUserController {
|
|||||||
String name = MapUtils.getString(params, "name");
|
String name = MapUtils.getString(params, "name");
|
||||||
String email = MapUtils.getString(params, "email");
|
String email = MapUtils.getString(params, "email");
|
||||||
String idCard = MapUtils.getString(params, "id_card");
|
String idCard = MapUtils.getString(params, "id_card");
|
||||||
|
Integer depId = MapUtils.getInteger(params, "dep_id");
|
||||||
|
|
||||||
UserCourseRecordPaginateFilter filter = new UserCourseRecordPaginateFilter();
|
UserPaginateFilter filter = new UserPaginateFilter();
|
||||||
filter.setCourseId(courseId);
|
|
||||||
filter.setName(name);
|
filter.setName(name);
|
||||||
filter.setEmail(email);
|
filter.setEmail(email);
|
||||||
filter.setIdCard(idCard);
|
|
||||||
filter.setSortAlgo(sortAlgo);
|
filter.setSortAlgo(sortAlgo);
|
||||||
filter.setSortField(sortField);
|
filter.setSortField(sortField);
|
||||||
|
filter.setIdCard(idCard);
|
||||||
|
|
||||||
PaginationResult<UserCourseRecord> result =
|
// 所属部门
|
||||||
userCourseRecordService.paginate(page, size, filter);
|
if (depId != null && depId > 0) { // 设置过滤部门
|
||||||
|
filter.setDepIds(
|
||||||
|
new ArrayList<>() {
|
||||||
|
{
|
||||||
|
add(depId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else { // 默认读取课程关联的全部部门
|
||||||
|
List<Integer> depIds = courseService.getDepIdsByCourseId(courseId);
|
||||||
|
if (depIds != null && depIds.size() > 0) {
|
||||||
|
filter.setDepIds(depIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PaginationResult<User> result = userService.paginate(page, size, filter);
|
||||||
|
|
||||||
|
List<Integer> userIds = result.getData().stream().map(User::getId).toList();
|
||||||
|
|
||||||
HashMap<String, Object> data = new HashMap<>();
|
HashMap<String, Object> data = new HashMap<>();
|
||||||
data.put("data", result.getData());
|
data.put("data", result.getData());
|
||||||
data.put("total", result.getTotal());
|
data.put("total", result.getTotal());
|
||||||
data.put(
|
data.put(
|
||||||
"users",
|
"user_course_records",
|
||||||
userService.chunks(
|
userCourseRecordService
|
||||||
result.getData().stream().map(UserCourseRecord::getUserId).toList()));
|
.chunk(
|
||||||
|
userIds,
|
||||||
|
new ArrayList<>() {
|
||||||
|
{
|
||||||
|
add(courseId);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.toMap(UserCourseRecord::getUserId, e -> e)));
|
||||||
|
data.put(
|
||||||
|
"user_course_hour_user_first_at",
|
||||||
|
userCourseHourRecordService
|
||||||
|
.getUserCourseHourUserFirstCreatedAt(courseId, userIds)
|
||||||
|
.stream()
|
||||||
|
.collect(
|
||||||
|
Collectors.toMap(
|
||||||
|
UserCourseHourRecordUserFirstCreatedAtMapper::getUserId,
|
||||||
|
UserCourseHourRecordUserFirstCreatedAtMapper
|
||||||
|
::getCreatedAt)));
|
||||||
|
data.put("course", courseService.findOrFail(courseId));
|
||||||
|
data.put(
|
||||||
|
"user_dep_ids",
|
||||||
|
userService.getDepIdsGroup(result.getData().stream().map(User::getId).toList()));
|
||||||
|
data.put("departments", departmentService.id2name());
|
||||||
|
|
||||||
return JsonResponse.data(data);
|
return JsonResponse.data(data);
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,12 @@ public class DepartmentController {
|
|||||||
String name = MapUtils.getString(params, "name");
|
String name = MapUtils.getString(params, "name");
|
||||||
String email = MapUtils.getString(params, "email");
|
String email = MapUtils.getString(params, "email");
|
||||||
String idCard = MapUtils.getString(params, "id_card");
|
String idCard = MapUtils.getString(params, "id_card");
|
||||||
String depIds = String.valueOf(id);
|
List<Integer> depIds =
|
||||||
|
new ArrayList<>() {
|
||||||
|
{
|
||||||
|
add(id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
String courseIdsStr = MapUtils.getString(params, "course_ids");
|
String courseIdsStr = MapUtils.getString(params, "course_ids");
|
||||||
String showMode = MapUtils.getString(params, "show_mode");
|
String showMode = MapUtils.getString(params, "show_mode");
|
||||||
|
@ -43,6 +43,7 @@ import xyz.playedu.api.request.backend.UserRequest;
|
|||||||
import xyz.playedu.api.service.*;
|
import xyz.playedu.api.service.*;
|
||||||
import xyz.playedu.api.service.internal.UserDepartmentService;
|
import xyz.playedu.api.service.internal.UserDepartmentService;
|
||||||
import xyz.playedu.api.types.JsonResponse;
|
import xyz.playedu.api.types.JsonResponse;
|
||||||
|
import xyz.playedu.api.types.mapper.UserCourseHourRecordCourseCountMapper;
|
||||||
import xyz.playedu.api.types.paginate.PaginationResult;
|
import xyz.playedu.api.types.paginate.PaginationResult;
|
||||||
import xyz.playedu.api.types.paginate.UserCourseHourRecordPaginateFilter;
|
import xyz.playedu.api.types.paginate.UserCourseHourRecordPaginateFilter;
|
||||||
import xyz.playedu.api.types.paginate.UserCourseRecordPaginateFilter;
|
import xyz.playedu.api.types.paginate.UserCourseRecordPaginateFilter;
|
||||||
@ -98,8 +99,17 @@ public class UserController {
|
|||||||
Integer isVerify = MapUtils.getInteger(params, "is_verify");
|
Integer isVerify = MapUtils.getInteger(params, "is_verify");
|
||||||
Integer isSetPassword = MapUtils.getInteger(params, "is_set_password");
|
Integer isSetPassword = MapUtils.getInteger(params, "is_set_password");
|
||||||
String createdAt = MapUtils.getString(params, "created_at");
|
String createdAt = MapUtils.getString(params, "created_at");
|
||||||
String depIds = MapUtils.getString(params, "dep_ids");
|
String depIdsStr = MapUtils.getString(params, "dep_ids");
|
||||||
|
List<Integer> depIds = null;
|
||||||
|
if (depIdsStr != null && depIdsStr.trim().length() > 0) {
|
||||||
|
if ("0".equals(depIdsStr)) {
|
||||||
|
depIds = new ArrayList<>();
|
||||||
|
} else {
|
||||||
|
depIds = Arrays.stream(depIdsStr.split(",")).map(Integer::valueOf).toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Integer> finalDepIds = depIds;
|
||||||
UserPaginateFilter filter =
|
UserPaginateFilter filter =
|
||||||
new UserPaginateFilter() {
|
new UserPaginateFilter() {
|
||||||
{
|
{
|
||||||
@ -110,7 +120,7 @@ public class UserController {
|
|||||||
setIsLock(isLock);
|
setIsLock(isLock);
|
||||||
setIsVerify(isVerify);
|
setIsVerify(isVerify);
|
||||||
setIsSetPassword(isSetPassword);
|
setIsSetPassword(isSetPassword);
|
||||||
setDepIds(depIds);
|
setDepIds(finalDepIds);
|
||||||
setSortAlgo(sortAlgo);
|
setSortAlgo(sortAlgo);
|
||||||
setSortField(sortField);
|
setSortField(sortField);
|
||||||
}
|
}
|
||||||
@ -482,6 +492,14 @@ public class UserController {
|
|||||||
userCourseRecords = userCourseRecordService.chunk(id, courseIds);
|
userCourseRecords = userCourseRecordService.chunk(id, courseIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取学员线上课的课时学习数量(只要学习了就算,不一定需要已完成)
|
||||||
|
Map<Integer, Integer> userCourseHourCount =
|
||||||
|
userCourseHourRecordService.getUserCourseHourCount(id, courseIds, null).stream()
|
||||||
|
.collect(
|
||||||
|
Collectors.toMap(
|
||||||
|
UserCourseHourRecordCourseCountMapper::getCourseId,
|
||||||
|
UserCourseHourRecordCourseCountMapper::getTotal));
|
||||||
|
|
||||||
HashMap<String, Object> data = new HashMap<>();
|
HashMap<String, Object> data = new HashMap<>();
|
||||||
data.put("open_courses", openCourses);
|
data.put("open_courses", openCourses);
|
||||||
data.put("departments", departments);
|
data.put("departments", departments);
|
||||||
@ -490,6 +508,7 @@ public class UserController {
|
|||||||
"user_course_records",
|
"user_course_records",
|
||||||
userCourseRecords.stream()
|
userCourseRecords.stream()
|
||||||
.collect(Collectors.toMap(UserCourseRecord::getCourseId, e -> e)));
|
.collect(Collectors.toMap(UserCourseRecord::getCourseId, e -> e)));
|
||||||
|
data.put("user_course_hour_count", userCourseHourCount);
|
||||||
|
|
||||||
return JsonResponse.data(data);
|
return JsonResponse.data(data);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 杭州白书科技有限公司
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package xyz.playedu.api.controller.frontend;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import xyz.playedu.api.domain.ResourceCategory;
|
||||||
|
import xyz.playedu.api.service.ResourceCategoryService;
|
||||||
|
import xyz.playedu.api.types.JsonResponse;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/v1/category")
|
||||||
|
public class CategoryController {
|
||||||
|
|
||||||
|
@Autowired private ResourceCategoryService resourceCategoryService;
|
||||||
|
|
||||||
|
@GetMapping("/all")
|
||||||
|
public JsonResponse all() {
|
||||||
|
List<ResourceCategory> categories = resourceCategoryService.all();
|
||||||
|
HashMap<String, Object> data = new HashMap<>();
|
||||||
|
data.put(
|
||||||
|
"categories",
|
||||||
|
categories.stream().collect(Collectors.groupingBy(ResourceCategory::getParentId)));
|
||||||
|
return JsonResponse.data(data);
|
||||||
|
}
|
||||||
|
}
|
@ -30,7 +30,7 @@ import xyz.playedu.api.exception.ServiceException;
|
|||||||
import xyz.playedu.api.request.frontend.ChangePasswordRequest;
|
import xyz.playedu.api.request.frontend.ChangePasswordRequest;
|
||||||
import xyz.playedu.api.service.*;
|
import xyz.playedu.api.service.*;
|
||||||
import xyz.playedu.api.types.JsonResponse;
|
import xyz.playedu.api.types.JsonResponse;
|
||||||
import xyz.playedu.api.types.mapper.UserCourseHourRecordCountMapper;
|
import xyz.playedu.api.types.mapper.UserCourseHourRecordCourseCountMapper;
|
||||||
import xyz.playedu.api.types.response.UserLatestLearn;
|
import xyz.playedu.api.types.response.UserLatestLearn;
|
||||||
import xyz.playedu.api.util.PrivacyUtil;
|
import xyz.playedu.api.util.PrivacyUtil;
|
||||||
|
|
||||||
@ -106,6 +106,8 @@ public class UserController {
|
|||||||
return JsonResponse.error("请选择部门");
|
return JsonResponse.error("请选择部门");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Integer categoryId = MapUtils.getInteger(params, "category_id");
|
||||||
|
|
||||||
List<Integer> userJoinDepIds = userService.getDepIdsByUserId(FCtx.getId());
|
List<Integer> userJoinDepIds = userService.getDepIdsByUserId(FCtx.getId());
|
||||||
if (userJoinDepIds == null) {
|
if (userJoinDepIds == null) {
|
||||||
return JsonResponse.error("当前学员未加入任何部门");
|
return JsonResponse.error("当前学员未加入任何部门");
|
||||||
@ -126,9 +128,10 @@ public class UserController {
|
|||||||
{
|
{
|
||||||
add(depId);
|
add(depId);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
categoryId);
|
||||||
// 全部部门课
|
// 全部部门课
|
||||||
List<Course> openCourses = courseService.getOpenCoursesAndShow(500);
|
List<Course> openCourses = courseService.getOpenCoursesAndShow(500, categoryId);
|
||||||
// 汇总到一个list中
|
// 汇总到一个list中
|
||||||
if (depCourses != null && depCourses.size() > 0) {
|
if (depCourses != null && depCourses.size() > 0) {
|
||||||
courses.addAll(depCourses);
|
courses.addAll(depCourses);
|
||||||
@ -218,8 +221,8 @@ public class UserController {
|
|||||||
.stream()
|
.stream()
|
||||||
.collect(
|
.collect(
|
||||||
Collectors.toMap(
|
Collectors.toMap(
|
||||||
UserCourseHourRecordCountMapper::getCourseId,
|
UserCourseHourRecordCourseCountMapper::getCourseId,
|
||||||
UserCourseHourRecordCountMapper::getTotal)));
|
UserCourseHourRecordCourseCountMapper::getTotal)));
|
||||||
|
|
||||||
return JsonResponse.data(data);
|
return JsonResponse.data(data);
|
||||||
}
|
}
|
||||||
|
@ -36,5 +36,5 @@ public interface CourseMapper extends BaseMapper<Course> {
|
|||||||
|
|
||||||
Long paginateCount(CoursePaginateFiler filer);
|
Long paginateCount(CoursePaginateFiler filer);
|
||||||
|
|
||||||
List<Course> openCoursesAndShow(Integer limit);
|
List<Course> openCoursesAndShow(Integer limit, Integer categoryId);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import xyz.playedu.api.domain.UserCourseHourRecord;
|
import xyz.playedu.api.domain.UserCourseHourRecord;
|
||||||
import xyz.playedu.api.types.mapper.UserCourseHourRecordCountMapper;
|
import xyz.playedu.api.types.mapper.UserCourseHourRecordCourseCountMapper;
|
||||||
|
import xyz.playedu.api.types.mapper.UserCourseHourRecordUserCountMapper;
|
||||||
|
import xyz.playedu.api.types.mapper.UserCourseHourRecordUserFirstCreatedAtMapper;
|
||||||
import xyz.playedu.api.types.paginate.UserCourseHourRecordPaginateFilter;
|
import xyz.playedu.api.types.paginate.UserCourseHourRecordPaginateFilter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -34,9 +36,15 @@ import java.util.List;
|
|||||||
public interface UserCourseHourRecordMapper extends BaseMapper<UserCourseHourRecord> {
|
public interface UserCourseHourRecordMapper extends BaseMapper<UserCourseHourRecord> {
|
||||||
List<UserCourseHourRecord> getUserLatestRecords(Integer userId, Integer size);
|
List<UserCourseHourRecord> getUserLatestRecords(Integer userId, Integer size);
|
||||||
|
|
||||||
List<UserCourseHourRecordCountMapper> getUserCourseHourCount(
|
List<UserCourseHourRecordCourseCountMapper> getUserCourseHourCount(
|
||||||
Integer userId, List<Integer> courseIds, Integer isFinished);
|
Integer userId, List<Integer> courseIds, Integer isFinished);
|
||||||
|
|
||||||
|
List<UserCourseHourRecordUserCountMapper> getUserCourseHourUserCount(
|
||||||
|
Integer courseId, List<Integer> userIds, Integer isFinished);
|
||||||
|
|
||||||
|
List<UserCourseHourRecordUserFirstCreatedAtMapper> getUserCourseHourUserFirstCreatedAt(
|
||||||
|
Integer courseId, List<Integer> userIds);
|
||||||
|
|
||||||
List<UserCourseHourRecord> paginate(UserCourseHourRecordPaginateFilter filter);
|
List<UserCourseHourRecord> paginate(UserCourseHourRecordPaginateFilter filter);
|
||||||
|
|
||||||
Long paginateCount(UserCourseHourRecordPaginateFilter filter);
|
Long paginateCount(UserCourseHourRecordPaginateFilter filter);
|
||||||
|
@ -77,8 +77,12 @@ public interface CourseService extends IService<Course> {
|
|||||||
|
|
||||||
List<Course> getOpenCoursesAndShow(Integer limit);
|
List<Course> getOpenCoursesAndShow(Integer limit);
|
||||||
|
|
||||||
|
List<Course> getOpenCoursesAndShow(Integer limit, Integer categoryId);
|
||||||
|
|
||||||
List<Course> getDepCoursesAndShow(List<Integer> depIds);
|
List<Course> getDepCoursesAndShow(List<Integer> depIds);
|
||||||
|
|
||||||
|
List<Course> getDepCoursesAndShow(List<Integer> depIds, Integer categoryId);
|
||||||
|
|
||||||
Map<Integer, List<Integer>> getCategoryIdsGroup(List<Integer> courseIds);
|
Map<Integer, List<Integer>> getCategoryIdsGroup(List<Integer> courseIds);
|
||||||
|
|
||||||
Map<Integer, List<Integer>> getDepIdsGroup(List<Integer> courseIds);
|
Map<Integer, List<Integer>> getDepIdsGroup(List<Integer> courseIds);
|
||||||
|
@ -18,7 +18,9 @@ package xyz.playedu.api.service;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
import xyz.playedu.api.domain.UserCourseHourRecord;
|
import xyz.playedu.api.domain.UserCourseHourRecord;
|
||||||
import xyz.playedu.api.types.mapper.UserCourseHourRecordCountMapper;
|
import xyz.playedu.api.types.mapper.UserCourseHourRecordCourseCountMapper;
|
||||||
|
import xyz.playedu.api.types.mapper.UserCourseHourRecordUserCountMapper;
|
||||||
|
import xyz.playedu.api.types.mapper.UserCourseHourRecordUserFirstCreatedAtMapper;
|
||||||
import xyz.playedu.api.types.paginate.PaginationResult;
|
import xyz.playedu.api.types.paginate.PaginationResult;
|
||||||
import xyz.playedu.api.types.paginate.UserCourseHourRecordPaginateFilter;
|
import xyz.playedu.api.types.paginate.UserCourseHourRecordPaginateFilter;
|
||||||
|
|
||||||
@ -51,9 +53,15 @@ public interface UserCourseHourRecordService extends IService<UserCourseHourReco
|
|||||||
|
|
||||||
void remove(Integer userId, Integer courseId, Integer hourId);
|
void remove(Integer userId, Integer courseId, Integer hourId);
|
||||||
|
|
||||||
List<UserCourseHourRecordCountMapper> getUserCourseHourCount(
|
List<UserCourseHourRecordCourseCountMapper> getUserCourseHourCount(
|
||||||
Integer userId, List<Integer> courseIds, Integer isFinished);
|
Integer userId, List<Integer> courseIds, Integer isFinished);
|
||||||
|
|
||||||
|
List<UserCourseHourRecordUserCountMapper> getUserCourseHourUserCount(
|
||||||
|
Integer courseId, List<Integer> userIds, Integer isFinished);
|
||||||
|
|
||||||
|
List<UserCourseHourRecordUserFirstCreatedAtMapper> getUserCourseHourUserFirstCreatedAt(
|
||||||
|
Integer courseId, List<Integer> userIds);
|
||||||
|
|
||||||
PaginationResult<UserCourseHourRecord> paginate(
|
PaginationResult<UserCourseHourRecord> paginate(
|
||||||
int page, int size, UserCourseHourRecordPaginateFilter filter);
|
int page, int size, UserCourseHourRecordPaginateFilter filter);
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,40 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Course> getOpenCoursesAndShow(Integer limit) {
|
public List<Course> getOpenCoursesAndShow(Integer limit) {
|
||||||
return getBaseMapper().openCoursesAndShow(limit);
|
return getBaseMapper().openCoursesAndShow(limit, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Course> getOpenCoursesAndShow(Integer limit, Integer categoryId) {
|
||||||
|
return getBaseMapper().openCoursesAndShow(limit, categoryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Course> getDepCoursesAndShow(List<Integer> depIds, Integer categoryId) {
|
||||||
|
if (depIds == null || depIds.size() == 0) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
List<Integer> courseIds = courseDepartmentService.getCourseIdsByDepIds(depIds);
|
||||||
|
if (courseIds == null || courseIds.size() == 0) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
if (categoryId != null && categoryId > 0) {
|
||||||
|
List<Integer> tmpCourseIds =
|
||||||
|
courseCategoryService.getCourseIdsByCategoryIds(
|
||||||
|
new ArrayList<>() {
|
||||||
|
{
|
||||||
|
add(categoryId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (tmpCourseIds == null || tmpCourseIds.size() == 0) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
courseIds = courseIds.stream().filter(tmpCourseIds::contains).toList();
|
||||||
|
if (courseIds.size() == 0) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list(query().getWrapper().in("id", courseIds).eq("is_show", 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,7 +25,9 @@ import xyz.playedu.api.domain.UserCourseHourRecord;
|
|||||||
import xyz.playedu.api.event.UserCourseHourFinishedEvent;
|
import xyz.playedu.api.event.UserCourseHourFinishedEvent;
|
||||||
import xyz.playedu.api.mapper.UserCourseHourRecordMapper;
|
import xyz.playedu.api.mapper.UserCourseHourRecordMapper;
|
||||||
import xyz.playedu.api.service.UserCourseHourRecordService;
|
import xyz.playedu.api.service.UserCourseHourRecordService;
|
||||||
import xyz.playedu.api.types.mapper.UserCourseHourRecordCountMapper;
|
import xyz.playedu.api.types.mapper.UserCourseHourRecordCourseCountMapper;
|
||||||
|
import xyz.playedu.api.types.mapper.UserCourseHourRecordUserCountMapper;
|
||||||
|
import xyz.playedu.api.types.mapper.UserCourseHourRecordUserFirstCreatedAtMapper;
|
||||||
import xyz.playedu.api.types.paginate.PaginationResult;
|
import xyz.playedu.api.types.paginate.PaginationResult;
|
||||||
import xyz.playedu.api.types.paginate.UserCourseHourRecordPaginateFilter;
|
import xyz.playedu.api.types.paginate.UserCourseHourRecordPaginateFilter;
|
||||||
|
|
||||||
@ -127,7 +129,7 @@ public class UserCourseHourRecordServiceImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UserCourseHourRecordCountMapper> getUserCourseHourCount(
|
public List<UserCourseHourRecordCourseCountMapper> getUserCourseHourCount(
|
||||||
Integer userId, List<Integer> courseIds, Integer isFinished) {
|
Integer userId, List<Integer> courseIds, Integer isFinished) {
|
||||||
if (courseIds == null || courseIds.size() == 0) {
|
if (courseIds == null || courseIds.size() == 0) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
@ -135,6 +137,15 @@ public class UserCourseHourRecordServiceImpl
|
|||||||
return getBaseMapper().getUserCourseHourCount(userId, courseIds, isFinished);
|
return getBaseMapper().getUserCourseHourCount(userId, courseIds, isFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UserCourseHourRecordUserCountMapper> getUserCourseHourUserCount(
|
||||||
|
Integer courseId, List<Integer> userIds, Integer isFinished) {
|
||||||
|
if (userIds == null || userIds.size() == 0) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return getBaseMapper().getUserCourseHourUserCount(courseId, userIds, isFinished);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(Integer userId, Integer courseId) {
|
public void remove(Integer userId, Integer courseId) {
|
||||||
remove(query().getWrapper().eq("user_id", userId).eq("course_id", courseId));
|
remove(query().getWrapper().eq("user_id", userId).eq("course_id", courseId));
|
||||||
@ -162,4 +173,13 @@ public class UserCourseHourRecordServiceImpl
|
|||||||
.eq("course_id", courseId)
|
.eq("course_id", courseId)
|
||||||
.eq("hour_id", hourId));
|
.eq("hour_id", hourId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UserCourseHourRecordUserFirstCreatedAtMapper> getUserCourseHourUserFirstCreatedAt(
|
||||||
|
Integer courseId, List<Integer> userIds) {
|
||||||
|
if (userIds == null || userIds.size() == 0) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return getBaseMapper().getUserCourseHourUserFirstCreatedAt(courseId, userIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ import lombok.Data;
|
|||||||
* @create 2023/3/29 10:01
|
* @create 2023/3/29 10:01
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class UserCourseHourRecordCountMapper {
|
public class UserCourseHourRecordCourseCountMapper {
|
||||||
@JsonProperty("course_id")
|
@JsonProperty("course_id")
|
||||||
private Integer courseId;
|
private Integer courseId;
|
||||||
|
|
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 杭州白书科技有限公司
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package xyz.playedu.api.types.mapper;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author 杭州白书科技有限公司
|
||||||
|
*
|
||||||
|
* @create 2023/5/8 11:22
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserCourseHourRecordUserCountMapper {
|
||||||
|
@JsonProperty("user_id")
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
|
private Integer total;
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2023 杭州白书科技有限公司
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package xyz.playedu.api.types.mapper;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author 杭州白书科技有限公司
|
||||||
|
*
|
||||||
|
* @create 2023/5/8 14:42
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserCourseHourRecordUserFirstCreatedAtMapper {
|
||||||
|
@JsonProperty("user_id")
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
|
@JsonProperty("created_at")
|
||||||
|
private Date createdAt;
|
||||||
|
}
|
@ -17,6 +17,8 @@ package xyz.playedu.api.types.paginate;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author 杭州白书科技有限公司
|
* @Author 杭州白书科技有限公司
|
||||||
*
|
*
|
||||||
@ -36,7 +38,7 @@ public class UserPaginateFilter {
|
|||||||
// 创建时间范围过滤
|
// 创建时间范围过滤
|
||||||
private String[] createdAt;
|
private String[] createdAt;
|
||||||
|
|
||||||
private String depIds;
|
private List<Integer> depIds;
|
||||||
|
|
||||||
// 排序控制
|
// 排序控制
|
||||||
private String sortField;
|
private String sortField;
|
||||||
|
@ -171,9 +171,15 @@
|
|||||||
<select id="openCoursesAndShow" resultType="xyz.playedu.api.domain.Course">
|
<select id="openCoursesAndShow" resultType="xyz.playedu.api.domain.Course">
|
||||||
SELECT `courses`.*
|
SELECT `courses`.*
|
||||||
FROM `courses`
|
FROM `courses`
|
||||||
LEFT JOIN `course_department` ON `course_department`.`course_id` = `courses`.`id`
|
LEFT JOIN `course_department` ON `course_department`.`course_id` = `courses`.`id`
|
||||||
|
<if test="categoryId != null and categoryId > 0">
|
||||||
|
INNER JOIN `resource_course_category` ON `resource_course_category`.`course_id` = `courses`.`id`
|
||||||
|
</if>
|
||||||
WHERE `course_department`.`course_id` IS NULL
|
WHERE `course_department`.`course_id` IS NULL
|
||||||
AND `courses`.`is_show` = 1
|
AND `courses`.`is_show` = 1
|
||||||
LIMIT #{limit}
|
<if test="categoryId != null and categoryId > 0">
|
||||||
|
AND `resource_course_category`.`category_id` = #{categoryId}
|
||||||
|
</if>
|
||||||
|
LIMIT #{limit}
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -38,11 +38,11 @@
|
|||||||
limit #{size};
|
limit #{size};
|
||||||
</select>
|
</select>
|
||||||
<select id="getUserCourseHourCount"
|
<select id="getUserCourseHourCount"
|
||||||
resultType="xyz.playedu.api.types.mapper.UserCourseHourRecordCountMapper">
|
resultType="xyz.playedu.api.types.mapper.UserCourseHourRecordCourseCountMapper">
|
||||||
SELECT `course_id`, count(1) AS `total`
|
SELECT `course_id`, count(1) AS `total`
|
||||||
FROM `user_course_hour_records`
|
FROM `user_course_hour_records`
|
||||||
WHERE `user_id` = #{userId}
|
WHERE `user_id` = #{userId}
|
||||||
<if test="courseIds != null and #{courseIds}.size() > 0">
|
<if test="courseIds != null and courseIds.size > 0">
|
||||||
AND `course_id` IN (<foreach collection="courseIds" item="courseId" separator=",">#{courseId}</foreach>)
|
AND `course_id` IN (<foreach collection="courseIds" item="courseId" separator=",">#{courseId}</foreach>)
|
||||||
</if>
|
</if>
|
||||||
<if test="isFinished != null">
|
<if test="isFinished != null">
|
||||||
@ -115,4 +115,35 @@
|
|||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getUserCourseHourUserCount"
|
||||||
|
resultType="xyz.playedu.api.types.mapper.UserCourseHourRecordUserCountMapper">
|
||||||
|
SELECT `user_id`, count(1) AS `total`
|
||||||
|
FROM `user_course_hour_records`
|
||||||
|
WHERE `course_id` = #{courseId}
|
||||||
|
<if test="userIds != null and userIds.size > 0">
|
||||||
|
AND `user_id` IN (<foreach collection="userIds" item="userId" separator=",">#{userId}</foreach>)
|
||||||
|
</if>
|
||||||
|
<if test="isFinished != null">
|
||||||
|
AND `is_finisehd` = #{isFinished}
|
||||||
|
</if>
|
||||||
|
GROUP BY `user_id`;
|
||||||
|
</select>
|
||||||
|
<select id="getUserCourseHourUserFirstCreatedAt"
|
||||||
|
resultType="xyz.playedu.api.types.mapper.UserCourseHourRecordUserFirstCreatedAtMapper">
|
||||||
|
SELECT `t1`.`created_at`, `t1`.`user_id`
|
||||||
|
FROM `user_course_hour_records` AS `t1`
|
||||||
|
INNER JOIN (SELECT `t2`.`user_id`, min(`t2`.`created_at`) as `created_at`
|
||||||
|
FROM `user_course_hour_records` AS `t2`
|
||||||
|
WHERE `t2`.`course_id` = #{courseId}
|
||||||
|
<if test="userIds != null and userIds.size > 0">
|
||||||
|
AND `t2`.`user_id` IN (<foreach collection="userIds" item="userId" separator=",">#{userId}</foreach>)
|
||||||
|
</if>
|
||||||
|
GROUP BY `t2`.`user_id`) AS `t3`
|
||||||
|
ON `t3`.`user_id` = `t1`.`user_id`
|
||||||
|
AND `t3`.`created_at` = `t1`.`created_at`
|
||||||
|
WHERE `t1`.`course_id` = #{courseId}
|
||||||
|
<if test="userIds != null and userIds.size > 0">
|
||||||
|
AND `t1`.`user_id` IN (<foreach collection="userIds" item="userId" separator=",">#{userId}</foreach>)
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -36,24 +36,23 @@
|
|||||||
<select id="paginateCount" resultType="java.lang.Long">
|
<select id="paginateCount" resultType="java.lang.Long">
|
||||||
SELECT count(1)
|
SELECT count(1)
|
||||||
FROM `users`
|
FROM `users`
|
||||||
<if test="depIds != null and depIds != ''">
|
|
||||||
<choose>
|
|
||||||
<when test="depIds.indexOf('0') == 0">
|
|
||||||
LEFT JOIN `user_department` ON `user_department`.`user_id` = `users`.`id`
|
|
||||||
</when>
|
|
||||||
<otherwise>
|
|
||||||
INNER JOIN `user_department` ON `user_department`.`user_id` = `users`.`id`
|
|
||||||
</otherwise>
|
|
||||||
</choose>
|
|
||||||
</if>
|
|
||||||
<where>
|
<where>
|
||||||
<if test="depIds != null and depIds != ''">
|
<if test="depIds != null">
|
||||||
<choose>
|
<choose>
|
||||||
<when test="depIds.indexOf('0') == 0">
|
<when test="depIds.size == 0">
|
||||||
AND `user_department`.`user_id` IS NULL
|
AND `users`.`id` IN (
|
||||||
|
SELECT `users`.`id` from `users` LEFT JOIN `user_department` ON `user_department`.`user_id` =
|
||||||
|
`users`.`id`
|
||||||
|
WHERE `user_department`.`user_id` IS NULL
|
||||||
|
)
|
||||||
</when>
|
</when>
|
||||||
<otherwise>
|
<otherwise>
|
||||||
AND `user_department`.`dep_id` IN (#{depIds})
|
AND `users`.`id` IN (
|
||||||
|
SELECT `users`.`id` from `users` LEFT JOIN `user_department` ON `user_department`.`user_id` =
|
||||||
|
`users`.`id`
|
||||||
|
WHERE `user_department`.`dep_id` IN (<foreach collection="depIds" item="depId" separator=",">
|
||||||
|
#{depId}</foreach>)
|
||||||
|
)
|
||||||
</otherwise>
|
</otherwise>
|
||||||
</choose>
|
</choose>
|
||||||
</if>
|
</if>
|
||||||
@ -78,7 +77,7 @@
|
|||||||
<if test="isSetPassword != null">
|
<if test="isSetPassword != null">
|
||||||
AND `users`.`is_set_password` = #{isSetPassword}
|
AND `users`.`is_set_password` = #{isSetPassword}
|
||||||
</if>
|
</if>
|
||||||
<if test="createdAt != null">
|
<if test="createdAt != null and createdAt.size == 2">
|
||||||
AND `users`.`created_at` BETWEEN
|
AND `users`.`created_at` BETWEEN
|
||||||
<foreach collection="createdAt" item="createdAtItem" separator=" AND ">#{createdAtItem}</foreach>
|
<foreach collection="createdAt" item="createdAtItem" separator=" AND ">#{createdAtItem}</foreach>
|
||||||
</if>
|
</if>
|
||||||
@ -88,24 +87,23 @@
|
|||||||
<select id="paginate" resultType="xyz.playedu.api.domain.User">
|
<select id="paginate" resultType="xyz.playedu.api.domain.User">
|
||||||
SELECT `users`.*
|
SELECT `users`.*
|
||||||
FROM `users`
|
FROM `users`
|
||||||
<if test="depIds != null and depIds != ''">
|
|
||||||
<choose>
|
|
||||||
<when test="depIds.indexOf('0') == 0">
|
|
||||||
LEFT JOIN `user_department` ON `user_department`.`user_id` = `users`.`id`
|
|
||||||
</when>
|
|
||||||
<otherwise>
|
|
||||||
INNER JOIN `user_department` ON `user_department`.`user_id` = `users`.`id`
|
|
||||||
</otherwise>
|
|
||||||
</choose>
|
|
||||||
</if>
|
|
||||||
<where>
|
<where>
|
||||||
<if test="depIds != null and depIds != ''">
|
<if test="depIds != null">
|
||||||
<choose>
|
<choose>
|
||||||
<when test="depIds.indexOf('0') == 0">
|
<when test="depIds.size == 0">
|
||||||
AND `user_department`.`user_id` IS NULL
|
AND `users`.`id` IN (
|
||||||
|
SELECT `users`.`id` from `users` LEFT JOIN `user_department` ON `user_department`.`user_id` =
|
||||||
|
`users`.`id`
|
||||||
|
WHERE `user_department`.`user_id` IS NULL
|
||||||
|
)
|
||||||
</when>
|
</when>
|
||||||
<otherwise>
|
<otherwise>
|
||||||
AND `user_department`.`dep_id` IN (#{depIds})
|
AND `users`.`id` IN (
|
||||||
|
SELECT `users`.`id` from `users` LEFT JOIN `user_department` ON `user_department`.`user_id` =
|
||||||
|
`users`.`id`
|
||||||
|
WHERE `user_department`.`dep_id` IN (<foreach collection="depIds" item="depId" separator=",">
|
||||||
|
#{depId}</foreach>)
|
||||||
|
)
|
||||||
</otherwise>
|
</otherwise>
|
||||||
</choose>
|
</choose>
|
||||||
</if>
|
</if>
|
||||||
@ -130,7 +128,7 @@
|
|||||||
<if test="isSetPassword != null">
|
<if test="isSetPassword != null">
|
||||||
AND `users`.`is_set_password` = #{isSetPassword}
|
AND `users`.`is_set_password` = #{isSetPassword}
|
||||||
</if>
|
</if>
|
||||||
<if test="createdAt != null">
|
<if test="createdAt != null and createdAt.size == 2">
|
||||||
AND `users`.`created_at` BETWEEN
|
AND `users`.`created_at` BETWEEN
|
||||||
<foreach collection="createdAt" item="createdAtItem" separator=" AND ">#{createdAtItem}</foreach>
|
<foreach collection="createdAt" item="createdAtItem" separator=" AND ">#{createdAtItem}</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user