mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-22 03:42:42 +08:00
数据库字段类型修改
This commit is contained in:
parent
a03e79f91b
commit
6b23dfe77b
@ -139,8 +139,8 @@ public class UserController {
|
||||
int nunRequiredHourCount = 0;//选修课时
|
||||
int requiredFinishedHourCount = 0;//已完成必修课时
|
||||
int nunRequiredFinishedHourCount = 0;//已完成选修课时
|
||||
Integer todayLearnDuration = userLearnDurationStatsService.todayUserDuration(FCtx.getId());//今日学习时长
|
||||
Integer learnDuration = userLearnDurationStatsService.userDuration(FCtx.getId());//学习总时长
|
||||
Long todayLearnDuration = userLearnDurationStatsService.todayUserDuration(FCtx.getId());//今日学习时长
|
||||
Long learnDuration = userLearnDurationStatsService.userDuration(FCtx.getId());//学习总时长
|
||||
|
||||
// -------- 学习数据统计 ----------
|
||||
if (courses.size() > 0) {
|
||||
@ -169,7 +169,7 @@ public class UserController {
|
||||
}
|
||||
}
|
||||
}
|
||||
HashMap<String, Integer> stats = new HashMap<>();
|
||||
HashMap<String, Object> stats = new HashMap<>();
|
||||
stats.put("required_course_count", requiredCourseCount);//必修课数量
|
||||
stats.put("nun_required_course_count", nunRequiredCourseCount);//选修课数量
|
||||
stats.put("required_finished_course_count", requiredFinishedCourseCount);//必修已完成线上课数
|
||||
|
@ -32,7 +32,7 @@ public class UserLearnDurationStats implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer duration;
|
||||
private Long duration;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
@Mapper
|
||||
public interface UserLearnDurationStatsMapper extends BaseMapper<UserLearnDurationStats> {
|
||||
|
||||
Integer getUserDuration(Integer userId);
|
||||
Long getUserDuration(Integer userId);
|
||||
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ public interface UserLearnDurationStatsService extends IService<UserLearnDuratio
|
||||
|
||||
List<UserLearnDurationStats> top10();
|
||||
|
||||
Integer todayUserDuration(Integer userId);
|
||||
Long todayUserDuration(Integer userId);
|
||||
|
||||
Integer userDuration(Integer userId);
|
||||
Long userDuration(Integer userId);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class UserLearnDurationStatsServiceImpl extends ServiceImpl<UserLearnDura
|
||||
if (stats == null) {
|
||||
UserLearnDurationStats newStats = new UserLearnDurationStats();
|
||||
newStats.setUserId(userId);
|
||||
newStats.setDuration(Math.toIntExact(duration));
|
||||
newStats.setDuration(duration);
|
||||
newStats.setCreatedDate(simpleDateFormat.parse(date));
|
||||
save(newStats);
|
||||
return;
|
||||
@ -40,7 +40,7 @@ public class UserLearnDurationStatsServiceImpl extends ServiceImpl<UserLearnDura
|
||||
|
||||
UserLearnDurationStats newStats = new UserLearnDurationStats();
|
||||
newStats.setId(stats.getId());
|
||||
newStats.setDuration((int) (stats.getDuration() + duration));
|
||||
newStats.setDuration(stats.getDuration() + duration);
|
||||
updateById(newStats);
|
||||
}
|
||||
|
||||
@ -68,20 +68,20 @@ public class UserLearnDurationStatsServiceImpl extends ServiceImpl<UserLearnDura
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer todayUserDuration(Integer userId) {
|
||||
public Long todayUserDuration(Integer userId) {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String today = simpleDateFormat.format(new Date());
|
||||
UserLearnDurationStats stats = getOne(query().getWrapper().eq("user_id", userId).eq("created_date", today));
|
||||
if (stats == null) {
|
||||
return 0;
|
||||
return 0L;
|
||||
}
|
||||
return stats.getDuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer userDuration(Integer userId) {
|
||||
Integer totalDuration = getBaseMapper().getUserDuration(userId);
|
||||
return totalDuration == null ? 0 : totalDuration;
|
||||
public Long userDuration(Integer userId) {
|
||||
Long totalDuration = getBaseMapper().getUserDuration(userId);
|
||||
return totalDuration == null ? 0L : totalDuration;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<resultMap id="BaseResultMap" type="xyz.playedu.api.domain.UserLearnDurationStats">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="userId" column="user_id" jdbcType="INTEGER"/>
|
||||
<result property="duration" column="duration" jdbcType="INTEGER"/>
|
||||
<result property="duration" column="duration" jdbcType="BIGINT"/>
|
||||
<result property="createdDate" column="created_date" jdbcType="DATE"/>
|
||||
</resultMap>
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
id,user_id,duration,
|
||||
created_date
|
||||
</sql>
|
||||
<select id="getUserDuration" resultType="java.lang.Integer">
|
||||
<select id="getUserDuration" resultType="java.lang.Long">
|
||||
SELECT sum(`duration`)
|
||||
FROM `user_learn_duration_stats`
|
||||
where `user_id` = #{userId};
|
||||
|
Loading…
x
Reference in New Issue
Block a user