数据库字段类型修改

This commit is contained in:
none 2023-04-04 09:42:39 +08:00
parent a03e79f91b
commit 6b23dfe77b
6 changed files with 16 additions and 16 deletions

View File

@ -139,8 +139,8 @@ public class UserController {
int nunRequiredHourCount = 0;//选修课时 int nunRequiredHourCount = 0;//选修课时
int requiredFinishedHourCount = 0;//已完成必修课时 int requiredFinishedHourCount = 0;//已完成必修课时
int nunRequiredFinishedHourCount = 0;//已完成选修课时 int nunRequiredFinishedHourCount = 0;//已完成选修课时
Integer todayLearnDuration = userLearnDurationStatsService.todayUserDuration(FCtx.getId());//今日学习时长 Long todayLearnDuration = userLearnDurationStatsService.todayUserDuration(FCtx.getId());//今日学习时长
Integer learnDuration = userLearnDurationStatsService.userDuration(FCtx.getId());//学习总时长 Long learnDuration = userLearnDurationStatsService.userDuration(FCtx.getId());//学习总时长
// -------- 学习数据统计 ---------- // -------- 学习数据统计 ----------
if (courses.size() > 0) { 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("required_course_count", requiredCourseCount);//必修课数量
stats.put("nun_required_course_count", nunRequiredCourseCount);//选修课数量 stats.put("nun_required_course_count", nunRequiredCourseCount);//选修课数量
stats.put("required_finished_course_count", requiredFinishedCourseCount);//必修已完成线上课数 stats.put("required_finished_course_count", requiredFinishedCourseCount);//必修已完成线上课数

View File

@ -32,7 +32,7 @@ public class UserLearnDurationStats implements Serializable {
/** /**
* *
*/ */
private Integer duration; private Long duration;
/** /**
* *

View File

@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@Mapper @Mapper
public interface UserLearnDurationStatsMapper extends BaseMapper<UserLearnDurationStats> { public interface UserLearnDurationStatsMapper extends BaseMapper<UserLearnDurationStats> {
Integer getUserDuration(Integer userId); Long getUserDuration(Integer userId);
} }

View File

@ -19,7 +19,7 @@ public interface UserLearnDurationStatsService extends IService<UserLearnDuratio
List<UserLearnDurationStats> top10(); List<UserLearnDurationStats> top10();
Integer todayUserDuration(Integer userId); Long todayUserDuration(Integer userId);
Integer userDuration(Integer userId); Long userDuration(Integer userId);
} }

View File

@ -32,7 +32,7 @@ public class UserLearnDurationStatsServiceImpl extends ServiceImpl<UserLearnDura
if (stats == null) { if (stats == null) {
UserLearnDurationStats newStats = new UserLearnDurationStats(); UserLearnDurationStats newStats = new UserLearnDurationStats();
newStats.setUserId(userId); newStats.setUserId(userId);
newStats.setDuration(Math.toIntExact(duration)); newStats.setDuration(duration);
newStats.setCreatedDate(simpleDateFormat.parse(date)); newStats.setCreatedDate(simpleDateFormat.parse(date));
save(newStats); save(newStats);
return; return;
@ -40,7 +40,7 @@ public class UserLearnDurationStatsServiceImpl extends ServiceImpl<UserLearnDura
UserLearnDurationStats newStats = new UserLearnDurationStats(); UserLearnDurationStats newStats = new UserLearnDurationStats();
newStats.setId(stats.getId()); newStats.setId(stats.getId());
newStats.setDuration((int) (stats.getDuration() + duration)); newStats.setDuration(stats.getDuration() + duration);
updateById(newStats); updateById(newStats);
} }
@ -68,20 +68,20 @@ public class UserLearnDurationStatsServiceImpl extends ServiceImpl<UserLearnDura
} }
@Override @Override
public Integer todayUserDuration(Integer userId) { public Long todayUserDuration(Integer userId) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String today = simpleDateFormat.format(new Date()); String today = simpleDateFormat.format(new Date());
UserLearnDurationStats stats = getOne(query().getWrapper().eq("user_id", userId).eq("created_date", today)); UserLearnDurationStats stats = getOne(query().getWrapper().eq("user_id", userId).eq("created_date", today));
if (stats == null) { if (stats == null) {
return 0; return 0L;
} }
return stats.getDuration(); return stats.getDuration();
} }
@Override @Override
public Integer userDuration(Integer userId) { public Long userDuration(Integer userId) {
Integer totalDuration = getBaseMapper().getUserDuration(userId); Long totalDuration = getBaseMapper().getUserDuration(userId);
return totalDuration == null ? 0 : totalDuration; return totalDuration == null ? 0L : totalDuration;
} }
} }

View File

@ -7,7 +7,7 @@
<resultMap id="BaseResultMap" type="xyz.playedu.api.domain.UserLearnDurationStats"> <resultMap id="BaseResultMap" type="xyz.playedu.api.domain.UserLearnDurationStats">
<id property="id" column="id" jdbcType="INTEGER"/> <id property="id" column="id" jdbcType="INTEGER"/>
<result property="userId" column="user_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"/> <result property="createdDate" column="created_date" jdbcType="DATE"/>
</resultMap> </resultMap>
@ -15,7 +15,7 @@
id,user_id,duration, id,user_id,duration,
created_date created_date
</sql> </sql>
<select id="getUserDuration" resultType="java.lang.Integer"> <select id="getUserDuration" resultType="java.lang.Long">
SELECT sum(`duration`) SELECT sum(`duration`)
FROM `user_learn_duration_stats` FROM `user_learn_duration_stats`
where `user_id` = #{userId}; where `user_id` = #{userId};