added: 首页主面板api

This commit is contained in:
none
2023-03-22 15:55:44 +08:00
parent d621cc5937
commit c1b3029f4b
15 changed files with 146 additions and 3 deletions

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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"));
}
}

View File

@@ -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)));
}
}