mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-24 05:02:43 +08:00
线上课-学员返回学员的第一次学习时间
This commit is contained in:
parent
5fd6b8c2d8
commit
6b19c461f1
@ -34,7 +34,7 @@ import xyz.playedu.api.service.UserCourseHourRecordService;
|
||||
import xyz.playedu.api.service.UserCourseRecordService;
|
||||
import xyz.playedu.api.service.UserService;
|
||||
import xyz.playedu.api.types.JsonResponse;
|
||||
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.UserPaginateFilter;
|
||||
|
||||
@ -110,14 +110,15 @@ public class CourseUserController {
|
||||
.stream()
|
||||
.collect(Collectors.toMap(UserCourseRecord::getUserId, e -> e)));
|
||||
data.put(
|
||||
"user_course_hour_user_count",
|
||||
"user_course_hour_user_first_at",
|
||||
userCourseHourRecordService
|
||||
.getUserCourseHourUserCount(courseId, userIds, null)
|
||||
.getUserCourseHourUserFirstCreatedAt(courseId, userIds)
|
||||
.stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
UserCourseHourRecordUserCountMapper::getUserId,
|
||||
UserCourseHourRecordUserCountMapper::getTotal)));
|
||||
UserCourseHourRecordUserFirstCreatedAtMapper::getUserId,
|
||||
UserCourseHourRecordUserFirstCreatedAtMapper
|
||||
::getCreatedAt)));
|
||||
data.put("course", courseService.findOrFail(courseId));
|
||||
|
||||
return JsonResponse.data(data);
|
||||
|
@ -22,6 +22,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import xyz.playedu.api.domain.UserCourseHourRecord;
|
||||
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 java.util.List;
|
||||
@ -41,6 +42,9 @@ public interface UserCourseHourRecordMapper extends BaseMapper<UserCourseHourRec
|
||||
List<UserCourseHourRecordUserCountMapper> getUserCourseHourUserCount(
|
||||
Integer courseId, List<Integer> userIds, Integer isFinished);
|
||||
|
||||
List<UserCourseHourRecordUserFirstCreatedAtMapper> getUserCourseHourUserFirstCreatedAt(
|
||||
Integer courseId, List<Integer> userIds);
|
||||
|
||||
List<UserCourseHourRecord> paginate(UserCourseHourRecordPaginateFilter filter);
|
||||
|
||||
Long paginateCount(UserCourseHourRecordPaginateFilter filter);
|
||||
|
@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import xyz.playedu.api.domain.UserCourseHourRecord;
|
||||
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.UserCourseHourRecordPaginateFilter;
|
||||
|
||||
@ -58,6 +59,9 @@ public interface UserCourseHourRecordService extends IService<UserCourseHourReco
|
||||
List<UserCourseHourRecordUserCountMapper> getUserCourseHourUserCount(
|
||||
Integer courseId, List<Integer> userIds, Integer isFinished);
|
||||
|
||||
List<UserCourseHourRecordUserFirstCreatedAtMapper> getUserCourseHourUserFirstCreatedAt(
|
||||
Integer courseId, List<Integer> userIds);
|
||||
|
||||
PaginationResult<UserCourseHourRecord> paginate(
|
||||
int page, int size, UserCourseHourRecordPaginateFilter filter);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import xyz.playedu.api.mapper.UserCourseHourRecordMapper;
|
||||
import xyz.playedu.api.service.UserCourseHourRecordService;
|
||||
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.UserCourseHourRecordPaginateFilter;
|
||||
|
||||
@ -172,4 +173,13 @@ public class UserCourseHourRecordServiceImpl
|
||||
.eq("course_id", courseId)
|
||||
.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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
@ -128,4 +128,22 @@
|
||||
</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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user