This commit is contained in:
none 2023-03-24 11:54:29 +08:00
parent 761458c370
commit f42c5a4236
4 changed files with 7 additions and 9 deletions

View File

@ -48,6 +48,7 @@ public class Course implements Serializable {
/**
* 1:必修,0:选修
*/
@JsonProperty("is_required")
private Integer isRequired;
/**

View File

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

View File

@ -70,7 +70,12 @@ public class UserLearnDurationStatsServiceImpl extends ServiceImpl<UserLearnDura
@Override
public Integer todayUserDuration(Integer userId) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
return getBaseMapper().getUserDateDuration(userId, simpleDateFormat.format(new Date()));
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 stats.getDuration();
}
@Override

View File

@ -15,12 +15,6 @@
id,user_id,duration,
created_date
</sql>
<select id="getUserDateDuration" resultType="java.lang.Integer">
SELECT `duration`
FROM `user_learn_duration_stats`
where `user_id` = #{userId}
and `created_date` = #{createdDate};
</select>
<select id="getUserDuration" resultType="java.lang.Integer">
SELECT sum(`duration`)
FROM `user_learn_duration_stats`