mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-22 18:29:51 +08:00
added: 首页主面板api
This commit is contained in:
@@ -42,4 +42,6 @@ public interface AdminUserService extends IService<AdminUser> {
|
||||
void passwordChange(AdminUser user, String password);
|
||||
|
||||
List<AdminUser> chunks(List<Integer> ids);
|
||||
|
||||
Long total();
|
||||
}
|
||||
|
||||
@@ -51,4 +51,6 @@ public interface CourseService extends IService<Course> {
|
||||
Map<Integer, List<Integer>> getCategoryIdsGroup(List<Integer> courseIds);
|
||||
|
||||
Map<Integer, List<Integer>> getDepIdsGroup(List<Integer> courseIds);
|
||||
|
||||
Long total();
|
||||
}
|
||||
|
||||
@@ -45,4 +45,6 @@ public interface DepartmentService extends IService<Department> {
|
||||
Map<Integer, List<Department>> groupByParent();
|
||||
|
||||
Map<Integer, String> id2name();
|
||||
|
||||
Long total();
|
||||
}
|
||||
|
||||
@@ -41,4 +41,6 @@ public interface ResourceCategoryService extends IService<ResourceCategory> {
|
||||
Map<Integer, List<ResourceCategory>> groupByParent();
|
||||
|
||||
Map<Integer, String> id2name();
|
||||
|
||||
Long total();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package xyz.playedu.api.service;
|
||||
import xyz.playedu.api.domain.UserLearnDurationStats;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author tengteng
|
||||
* @description 针对表【user_learn_duration_stats】的数据库操作Service
|
||||
@@ -10,4 +12,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface UserLearnDurationStatsService extends IService<UserLearnDurationStats> {
|
||||
void storeOrUpdate(Integer userId, Long startTime, Long endTime);
|
||||
|
||||
Long todayTotal();
|
||||
|
||||
Long yesterdayTotal();
|
||||
|
||||
List<UserLearnDurationStats> top10();
|
||||
}
|
||||
|
||||
@@ -38,4 +38,10 @@ public interface UserService extends IService<User> {
|
||||
void passwordChange(User user, String oldPassword, String newPassword) throws ServiceException;
|
||||
|
||||
List<User> chunks(List<Integer> ids, List<String> fields);
|
||||
|
||||
Long total();
|
||||
|
||||
Long todayCount();
|
||||
|
||||
Long yesterdayCount();
|
||||
}
|
||||
|
||||
@@ -175,6 +175,11 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
||||
public List<AdminUser> chunks(List<Integer> ids) {
|
||||
return list(query().getWrapper().in("id", ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long total() {
|
||||
return count();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package xyz.playedu.api.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import xyz.playedu.api.domain.ResourceCourseCategory;
|
||||
@@ -210,6 +209,11 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long total() {
|
||||
return count();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -223,6 +223,11 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
||||
public Map<Integer, String> id2name() {
|
||||
return all().stream().collect(Collectors.toMap(Department::getId, Department::getName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long total() {
|
||||
return count();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -209,6 +209,11 @@ public class ResourceCategoryServiceImpl extends ServiceImpl<ResourceCategoryMap
|
||||
public Map<Integer, String> id2name() {
|
||||
return all().stream().collect(Collectors.toMap(ResourceCategory::getId, ResourceCategory::getName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long total() {
|
||||
return count();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author tengteng
|
||||
@@ -16,8 +17,7 @@ import java.util.Date;
|
||||
* @createDate 2023-03-22 13:55:29
|
||||
*/
|
||||
@Service
|
||||
public class UserLearnDurationStatsServiceImpl extends ServiceImpl<UserLearnDurationStatsMapper, UserLearnDurationStats>
|
||||
implements UserLearnDurationStatsService {
|
||||
public class UserLearnDurationStatsServiceImpl extends ServiceImpl<UserLearnDurationStatsMapper, UserLearnDurationStats> implements UserLearnDurationStatsService {
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
@@ -43,6 +43,29 @@ public class UserLearnDurationStatsServiceImpl extends ServiceImpl<UserLearnDura
|
||||
newStats.setDuration((int) (stats.getDuration() + duration));
|
||||
updateById(newStats);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public Long todayTotal() {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String today = simpleDateFormat.format(new Date());
|
||||
return count(query().getWrapper().eq("created_date", today));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public Long yesterdayTotal() {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String yesterday = simpleDateFormat.format(new Date(System.currentTimeMillis() - 86399000));
|
||||
return count(query().getWrapper().eq("created_date", yesterday));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserLearnDurationStats> top10() {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String today = simpleDateFormat.format(new Date());
|
||||
return list(query().getWrapper().eq("created_date", today).orderByDesc("duration").last("limit 10"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package xyz.playedu.api.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import xyz.playedu.api.constant.SystemConstant;
|
||||
@@ -16,6 +17,7 @@ import xyz.playedu.api.types.paginate.PaginationResult;
|
||||
import xyz.playedu.api.types.paginate.UserPaginateFilter;
|
||||
import xyz.playedu.api.util.HelperUtil;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -160,6 +162,29 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
public List<User> chunks(List<Integer> ids, List<String> fields) {
|
||||
return list(query().getWrapper().in("id", ids).select(fields));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long total() {
|
||||
return count();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public Long todayCount() {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date now = new Date();
|
||||
String todayDate = simpleDateFormat.format(now);
|
||||
return count(query().getWrapper().between("created_at", simpleDateFormat.parse(todayDate), now));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public Long yesterdayCount() {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String todayDate = simpleDateFormat.format(new Date());
|
||||
String yesterdayDate = simpleDateFormat.format(new Date(System.currentTimeMillis() - 86400000));
|
||||
return count(query().getWrapper().between("created_at", simpleDateFormat.parse(yesterdayDate), simpleDateFormat.parse(todayDate)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user