mirror of
https://gitee.com/orangeform/orange-admin.git
synced 2026-01-18 02:56:30 +08:00
commit:1.5多应用版本
This commit is contained in:
72
orange-demo-single-service/application-webadmin/pom.xml
Normal file
72
orange-demo-single-service/application-webadmin/pom.xml
Normal file
@@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.orange.demo</groupId>
|
||||
<artifactId>OrangeSingleDemo</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>application-webadmin</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>application</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<!-- 业务组件依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.orange.demo</groupId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.orange.demo</groupId>
|
||||
<artifactId>common-redis</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.orange.demo</groupId>
|
||||
<artifactId>common-sequence</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.orange.demo</groupId>
|
||||
<artifactId>application-common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.*</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.orange.demo.webadmin;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
/**
|
||||
* 应用服务启动类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@EnableAsync
|
||||
@SpringBootApplication
|
||||
@ComponentScan("com.orange.demo")
|
||||
public class WebAdminApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(WebAdminApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.orange.demo.webadmin.app.controller;
|
||||
|
||||
import cn.jimmyshi.beanquery.BeanQuery;
|
||||
import com.orange.demo.webadmin.app.model.AreaCode;
|
||||
import com.orange.demo.webadmin.app.service.AreaCodeService;
|
||||
import com.orange.demo.common.core.object.ResponseResult;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 行政区划数据访问接口类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/areaCode")
|
||||
public class AreaCodeController {
|
||||
|
||||
@Autowired
|
||||
private AreaCodeService areaCodeService;
|
||||
|
||||
/**
|
||||
* 按照字典的形式返回行政区划列表。
|
||||
*
|
||||
* @return 字典形式的行政区划列表。
|
||||
*/
|
||||
@GetMapping("/listDict")
|
||||
public ResponseResult<List<Map<String, Object>>> listDict() {
|
||||
List<AreaCode> resultList = areaCodeService.getAllListFromCache();
|
||||
return ResponseResult.success(BeanQuery.select(
|
||||
"parentId as parentId", "areaId as id", "areaName as name").executeFrom(resultList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据上级行政区划Id获取其下级行政区划列表。
|
||||
*
|
||||
* @param parentId 上级行政区划Id。
|
||||
* @return 按照字典的形式返回下级行政区划列表。
|
||||
*/
|
||||
@GetMapping("/listDictByParentId")
|
||||
public ResponseResult<List<Map<String, Object>>> listDictByParentId(@RequestParam(required = false) Long parentId) {
|
||||
Collection<AreaCode> resultList = areaCodeService.getListByParentId(parentId);
|
||||
if (CollectionUtils.isEmpty(resultList)) {
|
||||
return ResponseResult.success(new LinkedList<>());
|
||||
}
|
||||
return ResponseResult.success(BeanQuery.select(
|
||||
"parentId as parentId", "areaId as id", "areaName as name").executeFrom(resultList));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
package com.orange.demo.webadmin.app.controller;
|
||||
|
||||
import cn.jimmyshi.beanquery.BeanQuery;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import com.orange.demo.common.core.upload.BaseUpDownloader;
|
||||
import com.orange.demo.common.core.upload.UpDownloaderFactory;
|
||||
import com.orange.demo.common.core.upload.UploadResponseInfo;
|
||||
import com.orange.demo.common.core.upload.UploadStoreInfo;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.orange.demo.webadmin.app.vo.*;
|
||||
import com.orange.demo.webadmin.app.dto.*;
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.webadmin.app.service.*;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.constant.*;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.redis.cache.SessionCacheHelper;
|
||||
import com.orange.demo.webadmin.config.ApplicationConfig;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.*;
|
||||
import javax.validation.groups.Default;
|
||||
|
||||
/**
|
||||
* 课程数据操作控制器类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/course")
|
||||
public class CourseController {
|
||||
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
@Autowired
|
||||
private ApplicationConfig appConfig;
|
||||
@Autowired
|
||||
private SessionCacheHelper cacheHelper;
|
||||
@Autowired
|
||||
private UpDownloaderFactory upDownloaderFactory;
|
||||
|
||||
/**
|
||||
* 新增课程数据数据。
|
||||
*
|
||||
* @param courseDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody("course") CourseDto courseDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(courseDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
Course course = MyModelUtil.copyTo(courseDto, Course.class);
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = courseService.verifyRelatedData(course, null);
|
||||
if (!callResult.isSuccess()) {
|
||||
errorMessage = callResult.getErrorMessage();
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
course = courseService.saveNew(course);
|
||||
return ResponseResult.success(course.getCourseId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新课程数据数据。
|
||||
*
|
||||
* @param courseDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody("course") CourseDto courseDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(courseDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
Course course = MyModelUtil.copyTo(courseDto, Course.class);
|
||||
Course originalCourse = courseService.getById(course.getCourseId());
|
||||
if (originalCourse == null) {
|
||||
// NOTE: 修改下面方括号中的话述
|
||||
errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = courseService.verifyRelatedData(course, originalCourse);
|
||||
if (!callResult.isSuccess()) {
|
||||
errorMessage = callResult.getErrorMessage();
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
if (!courseService.update(course, originalCourse)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除课程数据数据。
|
||||
*
|
||||
* @param courseId 删除对象主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long courseId) {
|
||||
String errorMessage;
|
||||
if (MyCommonUtil.existBlankArgument(courseId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
Course originalCourse = courseService.getById(courseId);
|
||||
if (originalCourse == null) {
|
||||
// NOTE: 修改下面方括号中的话述
|
||||
errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
if (!courseService.remove(courseId)) {
|
||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出符合过滤条件的课程数据列表。
|
||||
*
|
||||
* @param courseDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<CourseVo>> list(
|
||||
@MyRequestBody("courseFilter") CourseDto courseDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
Course courseFilter = MyModelUtil.copyTo(courseDtoFilter, Course.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Course.class);
|
||||
List<Course> courseList = courseService.getCourseListWithRelation(courseFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(courseList, Course.INSTANCE));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看指定课程数据对象详情。
|
||||
*
|
||||
* @param courseId 指定对象主键Id。
|
||||
* @return 应答结果对象,包含对象详情。
|
||||
*/
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<CourseVo> view(@RequestParam Long courseId) {
|
||||
if (MyCommonUtil.existBlankArgument(courseId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
Course course = courseService.getByIdWithRelation(courseId, MyRelationParam.full());
|
||||
if (course == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
CourseVo courseVo = Course.INSTANCE.fromModel(course);
|
||||
return ResponseResult.success(courseVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 附件文件下载。
|
||||
* 这里将图片和其他类型的附件文件放到不同的父目录下,主要为了便于今后图片文件的迁移。
|
||||
*
|
||||
* @param courseId 附件所在记录的主键Id。
|
||||
* @param fieldName 附件所属的字段名。
|
||||
* @param filename 文件名。如果没有提供该参数,就从当前记录的指定字段中读取。
|
||||
* @param asImage 下载文件是否为图片。
|
||||
* @param response Http 应答对象。
|
||||
*/
|
||||
@GetMapping("/download")
|
||||
public void download(
|
||||
@RequestParam(required = false) Long courseId,
|
||||
@RequestParam String fieldName,
|
||||
@RequestParam String filename,
|
||||
@RequestParam Boolean asImage,
|
||||
HttpServletResponse response) {
|
||||
if (MyCommonUtil.existBlankArgument(fieldName, filename, asImage)) {
|
||||
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
||||
return;
|
||||
}
|
||||
// 使用try来捕获异常,是为了保证一旦出现异常可以返回500的错误状态,便于调试。
|
||||
// 否则有可能给前端返回的是200的错误码。
|
||||
try {
|
||||
// 如果请求参数中没有包含主键Id,就判断该文件是否为当前session上传的。
|
||||
if (courseId == null) {
|
||||
if (!cacheHelper.existSessionUploadFile(filename)) {
|
||||
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Course course = courseService.getById(courseId);
|
||||
if (course == null) {
|
||||
ResponseResult.output(HttpServletResponse.SC_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
String fieldJsonData = (String) ReflectUtil.getFieldValue(course, fieldName);
|
||||
if (fieldJsonData == null) {
|
||||
ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST);
|
||||
return;
|
||||
}
|
||||
if (!BaseUpDownloader.containFile(fieldJsonData, filename)) {
|
||||
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
UploadStoreInfo storeInfo = MyModelUtil.getUploadStoreInfo(Course.class, fieldName);
|
||||
if (!storeInfo.isSupportUpload()) {
|
||||
ResponseResult.output(HttpServletResponse.SC_NOT_IMPLEMENTED,
|
||||
ResponseResult.error(ErrorCodeEnum.INVALID_UPLOAD_FIELD));
|
||||
return;
|
||||
}
|
||||
BaseUpDownloader upDownloader = upDownloaderFactory.get(storeInfo.getStoreType());
|
||||
upDownloader.doDownload(appConfig.getUploadFileBaseDir(),
|
||||
Course.class.getSimpleName(), fieldName, filename, asImage, response);
|
||||
} catch (Exception e) {
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传操作。
|
||||
*
|
||||
* @param fieldName 上传文件名。
|
||||
* @param asImage 是否作为图片上传。如果是图片,今后下载的时候无需权限验证。否则就是附件上传,下载时需要权限验证。
|
||||
* @param uploadFile 上传文件对象。
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
public void upload(
|
||||
@RequestParam String fieldName,
|
||||
@RequestParam Boolean asImage,
|
||||
@RequestParam("uploadFile") MultipartFile uploadFile) throws Exception {
|
||||
UploadStoreInfo storeInfo = MyModelUtil.getUploadStoreInfo(Course.class, fieldName);
|
||||
// 这里就会判断参数中指定的字段,是否支持上传操作。
|
||||
if (!storeInfo.isSupportUpload()) {
|
||||
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN,
|
||||
ResponseResult.error(ErrorCodeEnum.INVALID_UPLOAD_FIELD));
|
||||
return;
|
||||
}
|
||||
// 根据字段注解中的存储类型,通过工厂方法获取匹配的上传下载实现类,从而解耦。
|
||||
BaseUpDownloader upDownloader = upDownloaderFactory.get(storeInfo.getStoreType());
|
||||
UploadResponseInfo responseInfo = upDownloader.doUpload(null,
|
||||
appConfig.getUploadFileBaseDir(), Course.class.getSimpleName(), fieldName, asImage, uploadFile);
|
||||
if (responseInfo.getUploadFailed()) {
|
||||
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN,
|
||||
ResponseResult.error(ErrorCodeEnum.UPLOAD_FAILED, responseInfo.getErrorMessage()));
|
||||
return;
|
||||
}
|
||||
cacheHelper.putSessionUploadFile(responseInfo.getFilename());
|
||||
ResponseResult.output(ResponseResult.success(responseInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 以字典形式返回全部课程数据数据集合。字典的键值为[courseId, courseName]。
|
||||
* 白名单接口,登录用户均可访问。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @return 应答结果对象,包含的数据为 List<Map<String, String>>,map中包含两条记录,key的值分别是id和name,value对应具体数据。
|
||||
*/
|
||||
@GetMapping("/listDict")
|
||||
public ResponseResult<List<Map<String, Object>>> listDict(Course filter) {
|
||||
List<Course> resultList = courseService.getListByFilter(filter);
|
||||
return ResponseResult.success(BeanQuery.select(
|
||||
"courseId as id", "courseName as name").executeFrom(resultList));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.orange.demo.webadmin.app.controller;
|
||||
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.orange.demo.webadmin.app.vo.*;
|
||||
import com.orange.demo.webadmin.app.dto.*;
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.webadmin.app.service.*;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.constant.*;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 课程统计操作控制器类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/courseTransStats")
|
||||
public class CourseTransStatsController {
|
||||
|
||||
@Autowired
|
||||
private CourseTransStatsService courseTransStatsService;
|
||||
|
||||
/**
|
||||
* 列出符合过滤条件的课程统计列表。
|
||||
*
|
||||
* @param courseTransStatsDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<CourseTransStatsVo>> list(
|
||||
@MyRequestBody("courseTransStatsFilter") CourseTransStatsDto courseTransStatsDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
CourseTransStats courseTransStatsFilter = MyModelUtil.copyTo(courseTransStatsDtoFilter, CourseTransStats.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, CourseTransStats.class);
|
||||
List<CourseTransStats> courseTransStatsList = courseTransStatsService.getCourseTransStatsListWithRelation(courseTransStatsFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(courseTransStatsList, CourseTransStats.INSTANCE));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组列出符合过滤条件的课程统计列表。
|
||||
*
|
||||
* @param courseTransStatsDtoFilter 过滤对象。
|
||||
* @param groupParam 分组参数。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@PostMapping("/listWithGroup")
|
||||
public ResponseResult<MyPageData<CourseTransStatsVo>> listWithGroup(
|
||||
@MyRequestBody("courseTransStatsFilter") CourseTransStatsDto courseTransStatsDtoFilter,
|
||||
@MyRequestBody(required = true) MyGroupParam groupParam,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, CourseTransStats.class);
|
||||
groupParam = MyGroupParam.buildGroupBy(groupParam, CourseTransStats.class);
|
||||
if (groupParam == null) {
|
||||
return ResponseResult.error(
|
||||
ErrorCodeEnum.INVALID_ARGUMENT_FORMAT, "数据参数错误,分组参数不能为空!");
|
||||
}
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
CourseTransStats filter = MyModelUtil.copyTo(courseTransStatsDtoFilter, CourseTransStats.class);
|
||||
MyGroupCriteria criteria = groupParam.getGroupCriteria();
|
||||
List<CourseTransStats> resultList = courseTransStatsService.getGroupedCourseTransStatsListWithRelation(
|
||||
filter, criteria.getGroupSelect(), criteria.getGroupBy(), orderBy);
|
||||
// 分页连同对象数据转换copy工作,下面的方法一并完成。
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(resultList, CourseTransStats.INSTANCE));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看指定课程统计对象详情。
|
||||
*
|
||||
* @param statsId 指定对象主键Id。
|
||||
* @return 应答结果对象,包含对象详情。
|
||||
*/
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<CourseTransStatsVo> view(@RequestParam Long statsId) {
|
||||
if (MyCommonUtil.existBlankArgument(statsId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
CourseTransStats courseTransStats = courseTransStatsService.getByIdWithRelation(statsId, MyRelationParam.full());
|
||||
if (courseTransStats == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
CourseTransStatsVo courseTransStatsVo = CourseTransStats.INSTANCE.fromModel(courseTransStats);
|
||||
return ResponseResult.success(courseTransStatsVo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.orange.demo.webadmin.app.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import cn.jimmyshi.beanquery.BeanQuery;
|
||||
import com.orange.demo.webadmin.app.dto.GradeDto;
|
||||
import com.orange.demo.webadmin.app.model.Grade;
|
||||
import com.orange.demo.webadmin.app.service.GradeService;
|
||||
import com.orange.demo.common.core.constant.ErrorCodeEnum;
|
||||
import com.orange.demo.common.core.util.MyModelUtil;
|
||||
import com.orange.demo.common.core.util.MyCommonUtil;
|
||||
import com.orange.demo.common.core.object.ResponseResult;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.groups.Default;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 年级操作控制器类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/grade")
|
||||
public class GradeController {
|
||||
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
|
||||
/**
|
||||
* 新增年级数据。
|
||||
*
|
||||
* @param gradeDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Integer> add(@MyRequestBody("grade") GradeDto gradeDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(gradeDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
Grade grade = MyModelUtil.copyTo(gradeDto, Grade.class);
|
||||
grade = gradeService.saveNew(grade);
|
||||
return ResponseResult.success(grade.getGradeId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新年级数据。
|
||||
*
|
||||
* @param gradeDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody("grade") GradeDto gradeDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(gradeDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
Grade grade = MyModelUtil.copyTo(gradeDto, Grade.class);
|
||||
Grade originalGrade = gradeService.getById(grade.getGradeId());
|
||||
if (originalGrade == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
if (!gradeService.update(grade, originalGrade)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除年级数据。
|
||||
*
|
||||
* @param gradeId 删除对象主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Integer gradeId) {
|
||||
if (MyCommonUtil.existBlankArgument(gradeId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
if (!gradeService.remove(gradeId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 白名单接口,登录用户均可访问。以字典形式返回全部年级数据集合。
|
||||
* 所有数据全部取自于缓存,对于数据库中存在,但是缓存中不存在的数据,不会返回。
|
||||
*
|
||||
* @return 应答结果对象,包含字典形式的数据集合。
|
||||
*/
|
||||
@GetMapping("/listDict")
|
||||
public ResponseResult<List<Map<String, Object>>> listDict() {
|
||||
List<Grade> resultList = gradeService.getAllListFromCache();
|
||||
if (CollectionUtils.isNotEmpty(resultList)) {
|
||||
gradeService.reloadCachedData(true);
|
||||
resultList = gradeService.getAllList();
|
||||
}
|
||||
return ResponseResult.success(BeanQuery.select(
|
||||
"gradeId as id", "gradeName as name").executeFrom(resultList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 白名单接口,登录用户均可访问。以字典形式返回全部年级数据集合。
|
||||
* fullResultList中的字典列表全部取自于数据库,而cachedResultList全部取自于缓存,前端负责比对。
|
||||
*
|
||||
* @return 应答结果对象,包含字典形式的数据集合。
|
||||
*/
|
||||
@GetMapping("/listAll")
|
||||
public ResponseResult<JSONObject> listAll() {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("fullResultList", BeanQuery.select(
|
||||
"gradeId as id", "gradeName as name").executeFrom(gradeService.getAllList()));
|
||||
jsonObject.put("cachedResultList", BeanQuery.select(
|
||||
"gradeId as id", "gradeName as name").executeFrom(gradeService.getAllListFromCache()));
|
||||
return ResponseResult.success(jsonObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将当前字典表的数据重新加载到缓存中。
|
||||
* 由于缓存的数据更新,在add/update/delete等接口均有同步处理。因此该接口仅当同步过程中出现问题时,
|
||||
* 可手工调用,或者每天晚上定时同步一次。
|
||||
*/
|
||||
@GetMapping("/reloadCachedData")
|
||||
public ResponseResult<Boolean> reloadCachedData() {
|
||||
gradeService.reloadCachedData(true);
|
||||
return ResponseResult.success(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package com.orange.demo.webadmin.app.controller;
|
||||
|
||||
import cn.jimmyshi.beanquery.BeanQuery;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.orange.demo.webadmin.app.vo.*;
|
||||
import com.orange.demo.webadmin.app.dto.*;
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.webadmin.app.service.*;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.constant.*;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.groups.Default;
|
||||
|
||||
/**
|
||||
* 校区数据操作控制器类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/schoolInfo")
|
||||
public class SchoolInfoController {
|
||||
|
||||
@Autowired
|
||||
private SchoolInfoService schoolInfoService;
|
||||
|
||||
/**
|
||||
* 新增校区数据数据。
|
||||
*
|
||||
* @param schoolInfoDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody("schoolInfo") SchoolInfoDto schoolInfoDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(schoolInfoDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SchoolInfo schoolInfo = MyModelUtil.copyTo(schoolInfoDto, SchoolInfo.class);
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = schoolInfoService.verifyRelatedData(schoolInfo, null);
|
||||
if (!callResult.isSuccess()) {
|
||||
errorMessage = callResult.getErrorMessage();
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
schoolInfo = schoolInfoService.saveNew(schoolInfo);
|
||||
return ResponseResult.success(schoolInfo.getSchoolId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新校区数据数据。
|
||||
*
|
||||
* @param schoolInfoDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody("schoolInfo") SchoolInfoDto schoolInfoDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(schoolInfoDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SchoolInfo schoolInfo = MyModelUtil.copyTo(schoolInfoDto, SchoolInfo.class);
|
||||
SchoolInfo originalSchoolInfo = schoolInfoService.getById(schoolInfo.getSchoolId());
|
||||
if (originalSchoolInfo == null) {
|
||||
// NOTE: 修改下面方括号中的话述
|
||||
errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = schoolInfoService.verifyRelatedData(schoolInfo, originalSchoolInfo);
|
||||
if (!callResult.isSuccess()) {
|
||||
errorMessage = callResult.getErrorMessage();
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
if (!schoolInfoService.update(schoolInfo, originalSchoolInfo)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除校区数据数据。
|
||||
*
|
||||
* @param schoolId 删除对象主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long schoolId) {
|
||||
String errorMessage;
|
||||
if (MyCommonUtil.existBlankArgument(schoolId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
SchoolInfo originalSchoolInfo = schoolInfoService.getById(schoolId);
|
||||
if (originalSchoolInfo == null) {
|
||||
// NOTE: 修改下面方括号中的话述
|
||||
errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
if (!schoolInfoService.remove(schoolId)) {
|
||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出符合过滤条件的校区数据列表。
|
||||
*
|
||||
* @param schoolInfoDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<SchoolInfoVo>> list(
|
||||
@MyRequestBody("schoolInfoFilter") SchoolInfoDto schoolInfoDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
SchoolInfo schoolInfoFilter = MyModelUtil.copyTo(schoolInfoDtoFilter, SchoolInfo.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, SchoolInfo.class);
|
||||
List<SchoolInfo> schoolInfoList = schoolInfoService.getSchoolInfoListWithRelation(schoolInfoFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(schoolInfoList, SchoolInfo.INSTANCE));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看指定校区数据对象详情。
|
||||
*
|
||||
* @param schoolId 指定对象主键Id。
|
||||
* @return 应答结果对象,包含对象详情。
|
||||
*/
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<SchoolInfoVo> view(@RequestParam Long schoolId) {
|
||||
if (MyCommonUtil.existBlankArgument(schoolId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
SchoolInfo schoolInfo = schoolInfoService.getByIdWithRelation(schoolId, MyRelationParam.full());
|
||||
if (schoolInfo == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
SchoolInfoVo schoolInfoVo = SchoolInfo.INSTANCE.fromModel(schoolInfo);
|
||||
return ResponseResult.success(schoolInfoVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 以字典形式返回全部校区数据数据集合。字典的键值为[schoolId, schoolName]。
|
||||
* 白名单接口,登录用户均可访问。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @return 应答结果对象,包含的数据为 List<Map<String, String>>,map中包含两条记录,key的值分别是id和name,value对应具体数据。
|
||||
*/
|
||||
@GetMapping("/listDict")
|
||||
public ResponseResult<List<Map<String, Object>>> listDict(SchoolInfo filter) {
|
||||
List<SchoolInfo> resultList = schoolInfoService.getListByFilter(filter);
|
||||
return ResponseResult.success(BeanQuery.select(
|
||||
"schoolId as id", "schoolName as name").executeFrom(resultList));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.orange.demo.webadmin.app.controller;
|
||||
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.orange.demo.webadmin.app.vo.*;
|
||||
import com.orange.demo.webadmin.app.dto.*;
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.webadmin.app.service.*;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.constant.*;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生行为统计操作控制器类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/studentActionStats")
|
||||
public class StudentActionStatsController {
|
||||
|
||||
@Autowired
|
||||
private StudentActionStatsService studentActionStatsService;
|
||||
|
||||
/**
|
||||
* 列出符合过滤条件的学生行为统计列表。
|
||||
*
|
||||
* @param studentActionStatsDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<StudentActionStatsVo>> list(
|
||||
@MyRequestBody("studentActionStatsFilter") StudentActionStatsDto studentActionStatsDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
StudentActionStats studentActionStatsFilter = MyModelUtil.copyTo(studentActionStatsDtoFilter, StudentActionStats.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, StudentActionStats.class);
|
||||
List<StudentActionStats> studentActionStatsList = studentActionStatsService.getStudentActionStatsListWithRelation(studentActionStatsFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(studentActionStatsList, StudentActionStats.INSTANCE));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组列出符合过滤条件的学生行为统计列表。
|
||||
*
|
||||
* @param studentActionStatsDtoFilter 过滤对象。
|
||||
* @param groupParam 分组参数。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@PostMapping("/listWithGroup")
|
||||
public ResponseResult<MyPageData<StudentActionStatsVo>> listWithGroup(
|
||||
@MyRequestBody("studentActionStatsFilter") StudentActionStatsDto studentActionStatsDtoFilter,
|
||||
@MyRequestBody(required = true) MyGroupParam groupParam,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, StudentActionStats.class);
|
||||
groupParam = MyGroupParam.buildGroupBy(groupParam, StudentActionStats.class);
|
||||
if (groupParam == null) {
|
||||
return ResponseResult.error(
|
||||
ErrorCodeEnum.INVALID_ARGUMENT_FORMAT, "数据参数错误,分组参数不能为空!");
|
||||
}
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
StudentActionStats filter = MyModelUtil.copyTo(studentActionStatsDtoFilter, StudentActionStats.class);
|
||||
MyGroupCriteria criteria = groupParam.getGroupCriteria();
|
||||
List<StudentActionStats> resultList = studentActionStatsService.getGroupedStudentActionStatsListWithRelation(
|
||||
filter, criteria.getGroupSelect(), criteria.getGroupBy(), orderBy);
|
||||
// 分页连同对象数据转换copy工作,下面的方法一并完成。
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(resultList, StudentActionStats.INSTANCE));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看指定学生行为统计对象详情。
|
||||
*
|
||||
* @param statsId 指定对象主键Id。
|
||||
* @return 应答结果对象,包含对象详情。
|
||||
*/
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<StudentActionStatsVo> view(@RequestParam Long statsId) {
|
||||
if (MyCommonUtil.existBlankArgument(statsId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
StudentActionStats studentActionStats = studentActionStatsService.getByIdWithRelation(statsId, MyRelationParam.full());
|
||||
if (studentActionStats == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
StudentActionStatsVo studentActionStatsVo = StudentActionStats.INSTANCE.fromModel(studentActionStats);
|
||||
return ResponseResult.success(studentActionStatsVo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package com.orange.demo.webadmin.app.controller;
|
||||
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.orange.demo.webadmin.app.vo.*;
|
||||
import com.orange.demo.webadmin.app.dto.*;
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.webadmin.app.service.*;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.constant.*;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.groups.Default;
|
||||
|
||||
/**
|
||||
* 学生行为流水操作控制器类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/studentActionTrans")
|
||||
public class StudentActionTransController {
|
||||
|
||||
@Autowired
|
||||
private StudentActionTransService studentActionTransService;
|
||||
|
||||
/**
|
||||
* 新增学生行为流水数据。
|
||||
*
|
||||
* @param studentActionTransDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody("studentActionTrans") StudentActionTransDto studentActionTransDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(studentActionTransDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
StudentActionTrans studentActionTrans = MyModelUtil.copyTo(studentActionTransDto, StudentActionTrans.class);
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = studentActionTransService.verifyRelatedData(studentActionTrans, null);
|
||||
if (!callResult.isSuccess()) {
|
||||
errorMessage = callResult.getErrorMessage();
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
studentActionTrans = studentActionTransService.saveNew(studentActionTrans);
|
||||
return ResponseResult.success(studentActionTrans.getTransId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新学生行为流水数据。
|
||||
*
|
||||
* @param studentActionTransDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody("studentActionTrans") StudentActionTransDto studentActionTransDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(studentActionTransDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
StudentActionTrans studentActionTrans = MyModelUtil.copyTo(studentActionTransDto, StudentActionTrans.class);
|
||||
StudentActionTrans originalStudentActionTrans = studentActionTransService.getById(studentActionTrans.getTransId());
|
||||
if (originalStudentActionTrans == null) {
|
||||
// NOTE: 修改下面方括号中的话述
|
||||
errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = studentActionTransService.verifyRelatedData(studentActionTrans, originalStudentActionTrans);
|
||||
if (!callResult.isSuccess()) {
|
||||
errorMessage = callResult.getErrorMessage();
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
if (!studentActionTransService.update(studentActionTrans, originalStudentActionTrans)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除学生行为流水数据。
|
||||
*
|
||||
* @param transId 删除对象主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long transId) {
|
||||
String errorMessage;
|
||||
if (MyCommonUtil.existBlankArgument(transId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
StudentActionTrans originalStudentActionTrans = studentActionTransService.getById(transId);
|
||||
if (originalStudentActionTrans == null) {
|
||||
// NOTE: 修改下面方括号中的话述
|
||||
errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
if (!studentActionTransService.remove(transId)) {
|
||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出符合过滤条件的学生行为流水列表。
|
||||
*
|
||||
* @param studentActionTransDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<StudentActionTransVo>> list(
|
||||
@MyRequestBody("studentActionTransFilter") StudentActionTransDto studentActionTransDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
StudentActionTrans studentActionTransFilter = MyModelUtil.copyTo(studentActionTransDtoFilter, StudentActionTrans.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, StudentActionTrans.class);
|
||||
List<StudentActionTrans> studentActionTransList = studentActionTransService.getStudentActionTransListWithRelation(studentActionTransFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(studentActionTransList, StudentActionTrans.INSTANCE));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看指定学生行为流水对象详情。
|
||||
*
|
||||
* @param transId 指定对象主键Id。
|
||||
* @return 应答结果对象,包含对象详情。
|
||||
*/
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<StudentActionTransVo> view(@RequestParam Long transId) {
|
||||
if (MyCommonUtil.existBlankArgument(transId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
StudentActionTrans studentActionTrans = studentActionTransService.getByIdWithRelation(transId, MyRelationParam.full());
|
||||
if (studentActionTrans == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
StudentActionTransVo studentActionTransVo = StudentActionTrans.INSTANCE.fromModel(studentActionTrans);
|
||||
return ResponseResult.success(studentActionTransVo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,438 @@
|
||||
package com.orange.demo.webadmin.app.controller;
|
||||
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.orange.demo.webadmin.app.vo.*;
|
||||
import com.orange.demo.webadmin.app.dto.*;
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.webadmin.app.service.*;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.constant.*;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.groups.Default;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 班级数据操作控制器类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/studentClass")
|
||||
public class StudentClassController {
|
||||
|
||||
@Autowired
|
||||
private StudentClassService studentClassService;
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
@Autowired
|
||||
private StudentService studentService;
|
||||
|
||||
/**
|
||||
* 新增班级数据数据。
|
||||
*
|
||||
* @param studentClassDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody("studentClass") StudentClassDto studentClassDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(studentClassDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
StudentClass studentClass = MyModelUtil.copyTo(studentClassDto, StudentClass.class);
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = studentClassService.verifyRelatedData(studentClass, null);
|
||||
if (!callResult.isSuccess()) {
|
||||
errorMessage = callResult.getErrorMessage();
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
studentClass = studentClassService.saveNew(studentClass);
|
||||
return ResponseResult.success(studentClass.getClassId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新班级数据数据。
|
||||
*
|
||||
* @param studentClassDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody("studentClass") StudentClassDto studentClassDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(studentClassDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
StudentClass studentClass = MyModelUtil.copyTo(studentClassDto, StudentClass.class);
|
||||
StudentClass originalStudentClass = studentClassService.getById(studentClass.getClassId());
|
||||
if (originalStudentClass == null) {
|
||||
// NOTE: 修改下面方括号中的话述
|
||||
errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = studentClassService.verifyRelatedData(studentClass, originalStudentClass);
|
||||
if (!callResult.isSuccess()) {
|
||||
errorMessage = callResult.getErrorMessage();
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
if (!studentClassService.update(studentClass, originalStudentClass)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除班级数据数据。
|
||||
*
|
||||
* @param classId 删除对象主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long classId) {
|
||||
String errorMessage;
|
||||
if (MyCommonUtil.existBlankArgument(classId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
StudentClass originalStudentClass = studentClassService.getById(classId);
|
||||
if (originalStudentClass == null) {
|
||||
// NOTE: 修改下面方括号中的话述
|
||||
errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
if (!studentClassService.remove(classId)) {
|
||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出符合过滤条件的班级数据列表。
|
||||
*
|
||||
* @param studentClassDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<StudentClassVo>> list(
|
||||
@MyRequestBody("studentClassFilter") StudentClassDto studentClassDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
StudentClass studentClassFilter = MyModelUtil.copyTo(studentClassDtoFilter, StudentClass.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, StudentClass.class);
|
||||
List<StudentClass> studentClassList = studentClassService.getStudentClassListWithRelation(studentClassFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(studentClassList, StudentClass.INSTANCE));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看指定班级数据对象详情。
|
||||
*
|
||||
* @param classId 指定对象主键Id。
|
||||
* @return 应答结果对象,包含对象详情。
|
||||
*/
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<StudentClassVo> view(@RequestParam Long classId) {
|
||||
if (MyCommonUtil.existBlankArgument(classId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
StudentClass studentClass = studentClassService.getByIdWithRelation(classId, MyRelationParam.full());
|
||||
if (studentClass == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
StudentClassVo studentClassVo = StudentClass.INSTANCE.fromModel(studentClass);
|
||||
return ResponseResult.success(studentClassVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出不与指定班级数据存在多对多关系的 [课程数据] 列表数据。通常用于查看添加新 [课程数据] 对象的候选列表。
|
||||
*
|
||||
* @param classId 主表关联字段。
|
||||
* @param courseDtoFilter [课程数据] 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,返回符合条件的数据列表。
|
||||
*/
|
||||
@PostMapping("/listNotInClassCourse")
|
||||
public ResponseResult<MyPageData<CourseVo>> listNotInClassCourse(
|
||||
@MyRequestBody Long classId,
|
||||
@MyRequestBody("courseFilter") CourseDto courseDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
ResponseResult<Void> verifyResult = this.doClassCourseVerify(classId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
Course filter = MyModelUtil.copyTo(courseDtoFilter, Course.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Course.class);
|
||||
List<Course> courseList =
|
||||
courseService.getNotInCourseListByClassId(classId, filter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(courseList, Course.INSTANCE));
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出与指定班级数据存在多对多关系的 [课程数据] 列表数据。
|
||||
*
|
||||
* @param classId 主表关联字段。
|
||||
* @param courseDtoFilter [课程数据] 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,返回符合条件的数据列表。
|
||||
*/
|
||||
@PostMapping("/listClassCourse")
|
||||
public ResponseResult<MyPageData<CourseVo>> listClassCourse(
|
||||
@MyRequestBody Long classId,
|
||||
@MyRequestBody("courseFilter") CourseDto courseDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
ResponseResult<Void> verifyResult = this.doClassCourseVerify(classId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
Course filter = MyModelUtil.copyTo(courseDtoFilter, Course.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Course.class);
|
||||
List<Course> courseList =
|
||||
courseService.getCourseListByClassId(classId, filter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(courseList, Course.INSTANCE));
|
||||
}
|
||||
|
||||
private ResponseResult<Void> doClassCourseVerify(Long classId) {
|
||||
if (MyCommonUtil.existBlankArgument(classId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
if (!studentClassService.existId(classId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加班级数据和 [课程数据] 对象的多对多关联关系数据。
|
||||
*
|
||||
* @param classId 主表主键Id。
|
||||
* @param classCourseDtoList 关联对象列表。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/addClassCourse")
|
||||
public ResponseResult<Void> addClassCourse(
|
||||
@MyRequestBody Long classId,
|
||||
@MyRequestBody(value = "classCourseList", elementType = ClassCourseDto.class) List<ClassCourseDto> classCourseDtoList) {
|
||||
if (MyCommonUtil.existBlankArgument(classId, classCourseDtoList)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
for (ClassCourseDto classCourse : classCourseDtoList) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(classCourse);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
}
|
||||
Set<Long> courseIdSet =
|
||||
classCourseDtoList.stream().map(ClassCourseDto::getCourseId).collect(Collectors.toSet());
|
||||
if (!studentClassService.existId(classId)
|
||||
|| !courseService.existUniqueKeyList("courseId", courseIdSet)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
||||
}
|
||||
List<ClassCourse> classCourseList =
|
||||
MyModelUtil.copyCollectionTo(classCourseDtoList, ClassCourse.class);
|
||||
studentClassService.addClassCourseList(classCourseList, classId);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新指定班级数据和指定 [课程数据] 的多对多关联数据。
|
||||
*
|
||||
* @param classCourseDto 对多对中间表对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/updateClassCourse")
|
||||
public ResponseResult<Void> updateClassCourse(
|
||||
@MyRequestBody("classCourse") ClassCourseDto classCourseDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(classCourseDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
ClassCourse classCourse = MyModelUtil.copyTo(classCourseDto, ClassCourse.class);
|
||||
if (!studentClassService.updateClassCourse(classCourse)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示班级数据和指定 [课程数据] 的多对多关联详情数据。
|
||||
*
|
||||
* @param classId 主表主键Id。
|
||||
* @param courseId 从表主键Id。
|
||||
* @return 应答结果对象,包括中间表详情。
|
||||
*/
|
||||
@GetMapping("/viewClassCourse")
|
||||
public ResponseResult<ClassCourseVo> viewClassCourse(
|
||||
@RequestParam Long classId, @RequestParam Long courseId) {
|
||||
if (MyCommonUtil.existBlankArgument(classId, courseId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
ClassCourse classCourse = studentClassService.getClassCourse(classId, courseId);
|
||||
if (classCourse == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
ClassCourseVo classCourseVo = MyModelUtil.copyTo(classCourse, ClassCourseVo.class);
|
||||
return ResponseResult.success(classCourseVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除指定班级数据和指定 [课程数据] 的多对多关联关系。
|
||||
*
|
||||
* @param classId 主表主键Id。
|
||||
* @param courseId 从表主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/deleteClassCourse")
|
||||
public ResponseResult<Void> deleteClassCourse(
|
||||
@MyRequestBody Long classId, @MyRequestBody Long courseId) {
|
||||
if (MyCommonUtil.existBlankArgument(classId, courseId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
if (!studentClassService.removeClassCourse(classId, courseId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出不与指定班级数据存在多对多关系的 [学生数据] 列表数据。通常用于查看添加新 [学生数据] 对象的候选列表。
|
||||
*
|
||||
* @param classId 主表关联字段。
|
||||
* @param studentDtoFilter [学生数据] 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,返回符合条件的数据列表。
|
||||
*/
|
||||
@PostMapping("/listNotInClassStudent")
|
||||
public ResponseResult<MyPageData<StudentVo>> listNotInClassStudent(
|
||||
@MyRequestBody Long classId,
|
||||
@MyRequestBody("studentFilter") StudentDto studentDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
ResponseResult<Void> verifyResult = this.doClassStudentVerify(classId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
Student filter = MyModelUtil.copyTo(studentDtoFilter, Student.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Student.class);
|
||||
List<Student> studentList =
|
||||
studentService.getNotInStudentListByClassId(classId, filter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(studentList, Student.INSTANCE));
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出与指定班级数据存在多对多关系的 [学生数据] 列表数据。
|
||||
*
|
||||
* @param classId 主表关联字段。
|
||||
* @param studentDtoFilter [学生数据] 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,返回符合条件的数据列表。
|
||||
*/
|
||||
@PostMapping("/listClassStudent")
|
||||
public ResponseResult<MyPageData<StudentVo>> listClassStudent(
|
||||
@MyRequestBody Long classId,
|
||||
@MyRequestBody("studentFilter") StudentDto studentDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
ResponseResult<Void> verifyResult = this.doClassStudentVerify(classId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
Student filter = MyModelUtil.copyTo(studentDtoFilter, Student.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Student.class);
|
||||
List<Student> studentList =
|
||||
studentService.getStudentListByClassId(classId, filter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(studentList, Student.INSTANCE));
|
||||
}
|
||||
|
||||
private ResponseResult<Void> doClassStudentVerify(Long classId) {
|
||||
if (MyCommonUtil.existBlankArgument(classId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
if (!studentClassService.existId(classId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加班级数据和 [学生数据] 对象的多对多关联关系数据。
|
||||
*
|
||||
* @param classId 主表主键Id。
|
||||
* @param classStudentDtoList 关联对象列表。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/addClassStudent")
|
||||
public ResponseResult<Void> addClassStudent(
|
||||
@MyRequestBody Long classId,
|
||||
@MyRequestBody(value = "classStudentList", elementType = ClassStudentDto.class) List<ClassStudentDto> classStudentDtoList) {
|
||||
if (MyCommonUtil.existBlankArgument(classId, classStudentDtoList)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
for (ClassStudentDto classStudent : classStudentDtoList) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(classStudent);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
}
|
||||
Set<Long> studentIdSet =
|
||||
classStudentDtoList.stream().map(ClassStudentDto::getStudentId).collect(Collectors.toSet());
|
||||
if (!studentClassService.existId(classId)
|
||||
|| !studentService.existUniqueKeyList("studentId", studentIdSet)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
||||
}
|
||||
List<ClassStudent> classStudentList =
|
||||
MyModelUtil.copyCollectionTo(classStudentDtoList, ClassStudent.class);
|
||||
studentClassService.addClassStudentList(classStudentList, classId);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除指定班级数据和指定 [学生数据] 的多对多关联关系。
|
||||
*
|
||||
* @param classId 主表主键Id。
|
||||
* @param studentId 从表主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/deleteClassStudent")
|
||||
public ResponseResult<Void> deleteClassStudent(
|
||||
@MyRequestBody Long classId, @MyRequestBody Long studentId) {
|
||||
if (MyCommonUtil.existBlankArgument(classId, studentId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
if (!studentClassService.removeClassStudent(classId, studentId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package com.orange.demo.webadmin.app.controller;
|
||||
|
||||
import cn.jimmyshi.beanquery.BeanQuery;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.orange.demo.webadmin.app.vo.*;
|
||||
import com.orange.demo.webadmin.app.dto.*;
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.webadmin.app.service.*;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.constant.*;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.groups.Default;
|
||||
|
||||
/**
|
||||
* 学生数据操作控制器类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/student")
|
||||
public class StudentController {
|
||||
|
||||
@Autowired
|
||||
private StudentService studentService;
|
||||
|
||||
/**
|
||||
* 新增学生数据数据。
|
||||
*
|
||||
* @param studentDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody("student") StudentDto studentDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(studentDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
Student student = MyModelUtil.copyTo(studentDto, Student.class);
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = studentService.verifyRelatedData(student, null);
|
||||
if (!callResult.isSuccess()) {
|
||||
errorMessage = callResult.getErrorMessage();
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
student = studentService.saveNew(student);
|
||||
return ResponseResult.success(student.getStudentId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新学生数据数据。
|
||||
*
|
||||
* @param studentDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody("student") StudentDto studentDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(studentDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
Student student = MyModelUtil.copyTo(studentDto, Student.class);
|
||||
Student originalStudent = studentService.getById(student.getStudentId());
|
||||
if (originalStudent == null) {
|
||||
// NOTE: 修改下面方括号中的话述
|
||||
errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = studentService.verifyRelatedData(student, originalStudent);
|
||||
if (!callResult.isSuccess()) {
|
||||
errorMessage = callResult.getErrorMessage();
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
if (!studentService.update(student, originalStudent)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除学生数据数据。
|
||||
*
|
||||
* @param studentId 删除对象主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long studentId) {
|
||||
String errorMessage;
|
||||
if (MyCommonUtil.existBlankArgument(studentId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
Student originalStudent = studentService.getById(studentId);
|
||||
if (originalStudent == null) {
|
||||
// NOTE: 修改下面方括号中的话述
|
||||
errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
if (!studentService.remove(studentId)) {
|
||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出符合过滤条件的学生数据列表。
|
||||
*
|
||||
* @param studentDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<StudentVo>> list(
|
||||
@MyRequestBody("studentFilter") StudentDto studentDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
Student studentFilter = MyModelUtil.copyTo(studentDtoFilter, Student.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Student.class);
|
||||
List<Student> studentList = studentService.getStudentListWithRelation(studentFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(studentList, Student.INSTANCE));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看指定学生数据对象详情。
|
||||
*
|
||||
* @param studentId 指定对象主键Id。
|
||||
* @return 应答结果对象,包含对象详情。
|
||||
*/
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<StudentVo> view(@RequestParam Long studentId) {
|
||||
if (MyCommonUtil.existBlankArgument(studentId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
Student student = studentService.getByIdWithRelation(studentId, MyRelationParam.full());
|
||||
if (student == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
StudentVo studentVo = Student.INSTANCE.fromModel(student);
|
||||
return ResponseResult.success(studentVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 以字典形式返回全部学生数据数据集合。字典的键值为[studentId, studentName]。
|
||||
* 白名单接口,登录用户均可访问。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @return 应答结果对象,包含的数据为 List<Map<String, String>>,map中包含两条记录,key的值分别是id和name,value对应具体数据。
|
||||
*/
|
||||
@GetMapping("/listDict")
|
||||
public ResponseResult<List<Map<String, Object>>> listDict(Student filter) {
|
||||
List<Student> resultList = studentService.getListByFilter(filter);
|
||||
return ResponseResult.success(BeanQuery.select(
|
||||
"studentId as id", "studentName as name").executeFrom(resultList));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.orange.demo.webadmin.app.dao;
|
||||
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.webadmin.app.model.AreaCode;
|
||||
|
||||
/**
|
||||
* 行政区划数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface AreaCodeMapper extends BaseDaoMapper<AreaCode> {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.orange.demo.webadmin.app.dao;
|
||||
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.webadmin.app.model.ClassCourse;
|
||||
|
||||
/**
|
||||
* 数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface ClassCourseMapper extends BaseDaoMapper<ClassCourse> {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.orange.demo.webadmin.app.dao;
|
||||
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.webadmin.app.model.ClassStudent;
|
||||
|
||||
/**
|
||||
* 数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface ClassStudentMapper extends BaseDaoMapper<ClassStudent> {
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.orange.demo.webadmin.app.dao;
|
||||
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.webadmin.app.model.Course;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 课程数据数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface CourseMapper extends BaseDaoMapper<Course> {
|
||||
|
||||
/**
|
||||
* 获取过滤后的对象列表。
|
||||
*
|
||||
* @param courseFilter 主表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<Course> getCourseList(
|
||||
@Param("courseFilter") Course courseFilter, @Param("orderBy") String orderBy);
|
||||
|
||||
/**
|
||||
* 根据关联主表Id,获取关联从表数据列表。
|
||||
*
|
||||
* @param classId 关联主表Id。
|
||||
* @param courseFilter 从表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 从表数据列表。
|
||||
*/
|
||||
List<Course> getCourseListByClassId(
|
||||
@Param("classId") Long classId,
|
||||
@Param("courseFilter") Course courseFilter,
|
||||
@Param("orderBy") String orderBy);
|
||||
|
||||
/**
|
||||
* 根据关联主表Id,获取关联从表中没有和主表建立关联关系的数据列表。
|
||||
*
|
||||
* @param classId 关联主表Id。
|
||||
* @param courseFilter 过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 与主表没有建立关联的从表数据列表。
|
||||
*/
|
||||
List<Course> getNotInCourseListByClassId(
|
||||
@Param("classId") Long classId,
|
||||
@Param("courseFilter") Course courseFilter,
|
||||
@Param("orderBy") String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.orange.demo.webadmin.app.dao;
|
||||
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.webadmin.app.model.CourseTransStats;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 课程统计数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface CourseTransStatsMapper extends BaseDaoMapper<CourseTransStats> {
|
||||
|
||||
/**
|
||||
* 获取分组计算后的数据对象列表。
|
||||
*
|
||||
* @param courseTransStatsFilter 主表过滤对象。
|
||||
* @param groupSelect 分组显示字段列表字符串,SELECT从句的参数。
|
||||
* @param groupBy 分组字段列表字符串,GROUP BY从句的参数。
|
||||
* @param orderBy 排序字符串,ORDER BY从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<CourseTransStats> getGroupedCourseTransStatsList(
|
||||
@Param("courseTransStatsFilter") CourseTransStats courseTransStatsFilter,
|
||||
@Param("groupSelect") String groupSelect,
|
||||
@Param("groupBy") String groupBy,
|
||||
@Param("orderBy") String orderBy);
|
||||
|
||||
/**
|
||||
* 获取过滤后的对象列表。
|
||||
*
|
||||
* @param courseTransStatsFilter 主表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<CourseTransStats> getCourseTransStatsList(
|
||||
@Param("courseTransStatsFilter") CourseTransStats courseTransStatsFilter, @Param("orderBy") String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.orange.demo.webadmin.app.dao;
|
||||
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.webadmin.app.model.Grade;
|
||||
|
||||
/**
|
||||
* 年级数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface GradeMapper extends BaseDaoMapper<Grade> {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.orange.demo.webadmin.app.dao;
|
||||
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.webadmin.app.model.MaterialEdition;
|
||||
|
||||
/**
|
||||
* 数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface MaterialEditionMapper extends BaseDaoMapper<MaterialEdition> {
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.orange.demo.webadmin.app.dao;
|
||||
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.webadmin.app.model.SchoolInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 校区数据数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface SchoolInfoMapper extends BaseDaoMapper<SchoolInfo> {
|
||||
|
||||
/**
|
||||
* 获取过滤后的对象列表。
|
||||
*
|
||||
* @param schoolInfoFilter 主表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<SchoolInfo> getSchoolInfoList(
|
||||
@Param("schoolInfoFilter") SchoolInfo schoolInfoFilter, @Param("orderBy") String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.orange.demo.webadmin.app.dao;
|
||||
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.webadmin.app.model.StudentActionStats;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生行为统计数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface StudentActionStatsMapper extends BaseDaoMapper<StudentActionStats> {
|
||||
|
||||
/**
|
||||
* 获取分组计算后的数据对象列表。
|
||||
*
|
||||
* @param studentActionStatsFilter 主表过滤对象。
|
||||
* @param groupSelect 分组显示字段列表字符串,SELECT从句的参数。
|
||||
* @param groupBy 分组字段列表字符串,GROUP BY从句的参数。
|
||||
* @param orderBy 排序字符串,ORDER BY从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<StudentActionStats> getGroupedStudentActionStatsList(
|
||||
@Param("studentActionStatsFilter") StudentActionStats studentActionStatsFilter,
|
||||
@Param("groupSelect") String groupSelect,
|
||||
@Param("groupBy") String groupBy,
|
||||
@Param("orderBy") String orderBy);
|
||||
|
||||
/**
|
||||
* 获取过滤后的对象列表。
|
||||
*
|
||||
* @param studentActionStatsFilter 主表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<StudentActionStats> getStudentActionStatsList(
|
||||
@Param("studentActionStatsFilter") StudentActionStats studentActionStatsFilter, @Param("orderBy") String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.orange.demo.webadmin.app.dao;
|
||||
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.webadmin.app.model.StudentActionTrans;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生行为流水数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface StudentActionTransMapper extends BaseDaoMapper<StudentActionTrans> {
|
||||
|
||||
/**
|
||||
* 获取过滤后的对象列表。
|
||||
*
|
||||
* @param studentActionTransFilter 主表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<StudentActionTrans> getStudentActionTransList(
|
||||
@Param("studentActionTransFilter") StudentActionTrans studentActionTransFilter, @Param("orderBy") String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.orange.demo.webadmin.app.dao;
|
||||
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.webadmin.app.model.StudentClass;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 班级数据数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface StudentClassMapper extends BaseDaoMapper<StudentClass> {
|
||||
|
||||
/**
|
||||
* 获取过滤后的对象列表。
|
||||
*
|
||||
* @param studentClassFilter 主表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<StudentClass> getStudentClassList(
|
||||
@Param("studentClassFilter") StudentClass studentClassFilter, @Param("orderBy") String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.orange.demo.webadmin.app.dao;
|
||||
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.webadmin.app.model.Student;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生数据数据操作访问接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface StudentMapper extends BaseDaoMapper<Student> {
|
||||
|
||||
/**
|
||||
* 获取过滤后的对象列表。
|
||||
*
|
||||
* @param studentFilter 主表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 对象列表。
|
||||
*/
|
||||
List<Student> getStudentList(
|
||||
@Param("studentFilter") Student studentFilter, @Param("orderBy") String orderBy);
|
||||
|
||||
/**
|
||||
* 根据关联主表Id,获取关联从表数据列表。
|
||||
*
|
||||
* @param classId 关联主表Id。
|
||||
* @param studentFilter 从表过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 从表数据列表。
|
||||
*/
|
||||
List<Student> getStudentListByClassId(
|
||||
@Param("classId") Long classId,
|
||||
@Param("studentFilter") Student studentFilter,
|
||||
@Param("orderBy") String orderBy);
|
||||
|
||||
/**
|
||||
* 根据关联主表Id,获取关联从表中没有和主表建立关联关系的数据列表。
|
||||
*
|
||||
* @param classId 关联主表Id。
|
||||
* @param studentFilter 过滤对象。
|
||||
* @param orderBy 排序字符串,order by从句的参数。
|
||||
* @return 与主表没有建立关联的从表数据列表。
|
||||
*/
|
||||
List<Student> getNotInStudentListByClassId(
|
||||
@Param("classId") Long classId,
|
||||
@Param("studentFilter") Student studentFilter,
|
||||
@Param("orderBy") String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orange.demo.webadmin.app.dao.AreaCodeMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orange.demo.webadmin.app.model.AreaCode">
|
||||
<id column="area_id" jdbcType="BIGINT" property="areaId"/>
|
||||
<result column="area_name" jdbcType="VARCHAR" property="areaName"/>
|
||||
<result column="area_level" jdbcType="INTEGER" property="areaLevel"/>
|
||||
<result column="parent_id" jdbcType="BIGINT" property="parentId"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orange.demo.webadmin.app.dao.ClassCourseMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orange.demo.webadmin.app.model.ClassCourse">
|
||||
<id column="class_id" jdbcType="BIGINT" property="classId"/>
|
||||
<id column="course_id" jdbcType="BIGINT" property="courseId"/>
|
||||
<result column="course_order" jdbcType="TINYINT" property="courseOrder"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orange.demo.webadmin.app.dao.ClassStudentMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orange.demo.webadmin.app.model.ClassStudent">
|
||||
<id column="class_id" jdbcType="BIGINT" property="classId"/>
|
||||
<id column="student_id" jdbcType="BIGINT" property="studentId"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orange.demo.webadmin.app.dao.CourseMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orange.demo.webadmin.app.model.Course">
|
||||
<id column="course_id" jdbcType="BIGINT" property="courseId"/>
|
||||
<result column="course_name" jdbcType="VARCHAR" property="courseName"/>
|
||||
<result column="price" jdbcType="DECIMAL" property="price"/>
|
||||
<result column="description" jdbcType="VARCHAR" property="description"/>
|
||||
<result column="difficulty" jdbcType="INTEGER" property="difficulty"/>
|
||||
<result column="grade_id" jdbcType="TINYINT" property="gradeId"/>
|
||||
<result column="subject_id" jdbcType="TINYINT" property="subjectId"/>
|
||||
<result column="class_hour" jdbcType="INTEGER" property="classHour"/>
|
||||
<result column="picture_url" jdbcType="VARCHAR" property="pictureUrl"/>
|
||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="BaseResultMapWithClassCourse" type="com.orange.demo.webadmin.app.model.Course" extends="BaseResultMap">
|
||||
<association property="classCourse" column="course_id" foreignColumn="course_id"
|
||||
notNullColumn="course_id" resultMap="com.orange.demo.webadmin.app.dao.ClassCourseMapper.BaseResultMap" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
||||
<sql id="filterRef">
|
||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
||||
<include refid="com.orange.demo.webadmin.app.dao.CourseMapper.inputFilterRef"/>
|
||||
</sql>
|
||||
|
||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
||||
<sql id="inputFilterRef">
|
||||
<if test="courseFilter != null">
|
||||
<if test="courseFilter.courseName != null and courseFilter.courseName != ''">
|
||||
<bind name = "safeCourseName" value = "'%' + courseFilter.courseName + '%'" />
|
||||
AND zz_course.course_name LIKE #{safeCourseName}
|
||||
</if>
|
||||
<if test="courseFilter.priceStart != null">
|
||||
AND zz_course.price >= #{courseFilter.priceStart}
|
||||
</if>
|
||||
<if test="courseFilter.priceEnd != null">
|
||||
AND zz_course.price <= #{courseFilter.priceEnd}
|
||||
</if>
|
||||
<if test="courseFilter.difficulty != null">
|
||||
AND zz_course.difficulty = #{courseFilter.difficulty}
|
||||
</if>
|
||||
<if test="courseFilter.gradeId != null">
|
||||
AND zz_course.grade_id = #{courseFilter.gradeId}
|
||||
</if>
|
||||
<if test="courseFilter.subjectId != null">
|
||||
AND zz_course.subject_id = #{courseFilter.subjectId}
|
||||
</if>
|
||||
<if test="courseFilter.classHourStart != null">
|
||||
AND zz_course.class_hour >= #{courseFilter.classHourStart}
|
||||
</if>
|
||||
<if test="courseFilter.classHourEnd != null">
|
||||
AND zz_course.class_hour <= #{courseFilter.classHourEnd}
|
||||
</if>
|
||||
<if test="courseFilter.createTimeStart != null and courseFilter.createTimeStart != ''">
|
||||
AND zz_course.create_time >= #{courseFilter.createTimeStart}
|
||||
</if>
|
||||
<if test="courseFilter.createTimeEnd != null and courseFilter.createTimeEnd != ''">
|
||||
AND zz_course.create_time <= #{courseFilter.createTimeEnd}
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getCourseList" resultMap="BaseResultMap" parameterType="com.orange.demo.webadmin.app.model.Course">
|
||||
SELECT * FROM zz_course
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getCourseListByClassId" resultMap="BaseResultMapWithClassCourse">
|
||||
SELECT
|
||||
zz_course.*,
|
||||
zz_class_course.*
|
||||
FROM
|
||||
zz_course,
|
||||
zz_class_course
|
||||
<where>
|
||||
AND zz_class_course.class_id = #{classId}
|
||||
AND zz_class_course.course_id = zz_course.course_id
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getNotInCourseListByClassId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
zz_course.*
|
||||
FROM
|
||||
zz_course
|
||||
<where>
|
||||
AND NOT EXISTS (SELECT * FROM zz_class_course
|
||||
WHERE zz_class_course.class_id = #{classId} AND zz_class_course.course_id = zz_course.course_id)
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orange.demo.webadmin.app.dao.CourseTransStatsMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orange.demo.webadmin.app.model.CourseTransStats">
|
||||
<id column="stats_id" jdbcType="BIGINT" property="statsId"/>
|
||||
<result column="stats_date" jdbcType="DATE" property="statsDate"/>
|
||||
<result column="subject_id" jdbcType="TINYINT" property="subjectId"/>
|
||||
<result column="grade_id" jdbcType="TINYINT" property="gradeId"/>
|
||||
<result column="grade_name" jdbcType="VARCHAR" property="gradeName"/>
|
||||
<result column="course_id" jdbcType="BIGINT" property="courseId"/>
|
||||
<result column="course_name" jdbcType="VARCHAR" property="courseName"/>
|
||||
<result column="student_attend_count" jdbcType="INTEGER" property="studentAttendCount"/>
|
||||
<result column="student_flower_amount" jdbcType="INTEGER" property="studentFlowerAmount"/>
|
||||
<result column="student_flower_count" jdbcType="INTEGER" property="studentFlowerCount"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
||||
<sql id="filterRef">
|
||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
||||
<include refid="com.orange.demo.webadmin.app.dao.CourseTransStatsMapper.inputFilterRef"/>
|
||||
</sql>
|
||||
|
||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
||||
<sql id="inputFilterRef">
|
||||
<if test="courseTransStatsFilter != null">
|
||||
<if test="courseTransStatsFilter.statsDateStart != null and courseTransStatsFilter.statsDateStart != ''">
|
||||
AND zz_course_trans_stats.stats_date >= #{courseTransStatsFilter.statsDateStart}
|
||||
</if>
|
||||
<if test="courseTransStatsFilter.statsDateEnd != null and courseTransStatsFilter.statsDateEnd != ''">
|
||||
AND zz_course_trans_stats.stats_date <= #{courseTransStatsFilter.statsDateEnd}
|
||||
</if>
|
||||
<if test="courseTransStatsFilter.subjectId != null">
|
||||
AND zz_course_trans_stats.subject_id = #{courseTransStatsFilter.subjectId}
|
||||
</if>
|
||||
<if test="courseTransStatsFilter.gradeId != null">
|
||||
AND zz_course_trans_stats.grade_id = #{courseTransStatsFilter.gradeId}
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getGroupedCourseTransStatsList" resultMap="BaseResultMap" parameterType="com.orange.demo.webadmin.app.model.CourseTransStats">
|
||||
SELECT * FROM
|
||||
(SELECT
|
||||
SUM(student_attend_count) student_attend_count,
|
||||
SUM(student_flower_amount) student_flower_amount,
|
||||
SUM(student_flower_count) student_flower_count,
|
||||
${groupSelect}
|
||||
FROM zz_course_trans_stats
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
GROUP BY ${groupBy}) zz_course_trans_stats
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getCourseTransStatsList" resultMap="BaseResultMap" parameterType="com.orange.demo.webadmin.app.model.CourseTransStats">
|
||||
SELECT * FROM zz_course_trans_stats
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orange.demo.webadmin.app.dao.GradeMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orange.demo.webadmin.app.model.Grade">
|
||||
<id column="grade_id" jdbcType="INTEGER" property="gradeId"/>
|
||||
<result column="grade_name" jdbcType="VARCHAR" property="gradeName"/>
|
||||
<result column="status" jdbcType="INTEGER" property="status"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orange.demo.webadmin.app.dao.MaterialEditionMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orange.demo.webadmin.app.model.MaterialEdition">
|
||||
<id column="edition_id" jdbcType="INTEGER" property="editionId"/>
|
||||
<result column="edition_name" jdbcType="VARCHAR" property="editionName"/>
|
||||
<result column="status" jdbcType="INTEGER" property="status"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orange.demo.webadmin.app.dao.SchoolInfoMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orange.demo.webadmin.app.model.SchoolInfo">
|
||||
<id column="school_id" jdbcType="BIGINT" property="schoolId"/>
|
||||
<result column="school_name" jdbcType="VARCHAR" property="schoolName"/>
|
||||
<result column="province_id" jdbcType="BIGINT" property="provinceId"/>
|
||||
<result column="city_id" jdbcType="BIGINT" property="cityId"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
||||
<sql id="filterRef">
|
||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
||||
<include refid="com.orange.demo.webadmin.app.dao.SchoolInfoMapper.inputFilterRef"/>
|
||||
</sql>
|
||||
|
||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
||||
<sql id="inputFilterRef">
|
||||
<if test="schoolInfoFilter != null">
|
||||
<if test="schoolInfoFilter.schoolName != null and schoolInfoFilter.schoolName != ''">
|
||||
<bind name = "safeSchoolName" value = "'%' + schoolInfoFilter.schoolName + '%'" />
|
||||
AND zz_school_info.school_name LIKE #{safeSchoolName}
|
||||
</if>
|
||||
<if test="schoolInfoFilter.provinceId != null">
|
||||
AND zz_school_info.province_id = #{schoolInfoFilter.provinceId}
|
||||
</if>
|
||||
<if test="schoolInfoFilter.cityId != null">
|
||||
AND zz_school_info.city_id = #{schoolInfoFilter.cityId}
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getSchoolInfoList" resultMap="BaseResultMap" parameterType="com.orange.demo.webadmin.app.model.SchoolInfo">
|
||||
SELECT * FROM zz_school_info
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orange.demo.webadmin.app.dao.StudentActionStatsMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orange.demo.webadmin.app.model.StudentActionStats">
|
||||
<id column="stats_id" jdbcType="BIGINT" property="statsId"/>
|
||||
<result column="stats_date" jdbcType="DATE" property="statsDate"/>
|
||||
<result column="stats_month" jdbcType="DATE" property="statsMonth"/>
|
||||
<result column="grade_id" jdbcType="INTEGER" property="gradeId"/>
|
||||
<result column="province_id" jdbcType="BIGINT" property="provinceId"/>
|
||||
<result column="city_id" jdbcType="BIGINT" property="cityId"/>
|
||||
<result column="buy_course_amount" jdbcType="INTEGER" property="buyCourseAmount"/>
|
||||
<result column="buy_course_count" jdbcType="INTEGER" property="buyCourseCount"/>
|
||||
<result column="buy_video_amount" jdbcType="INTEGER" property="buyVideoAmount"/>
|
||||
<result column="buy_video_count" jdbcType="INTEGER" property="buyVideoCount"/>
|
||||
<result column="buy_paper_amount" jdbcType="INTEGER" property="buyPaperAmount"/>
|
||||
<result column="buy_paper_count" jdbcType="INTEGER" property="buyPaperCount"/>
|
||||
<result column="buy_flower_amount" jdbcType="INTEGER" property="buyFlowerAmount"/>
|
||||
<result column="buy_flower_count" jdbcType="INTEGER" property="buyFlowerCount"/>
|
||||
<result column="recharge_coin_amount" jdbcType="INTEGER" property="rechargeCoinAmount"/>
|
||||
<result column="recharge_coin_count" jdbcType="INTEGER" property="rechargeCoinCount"/>
|
||||
<result column="do_course_count" jdbcType="INTEGER" property="doCourseCount"/>
|
||||
<result column="watch_video_count" jdbcType="INTEGER" property="watchVideoCount"/>
|
||||
<result column="watch_video_total_second" jdbcType="INTEGER" property="watchVideoTotalSecond"/>
|
||||
<result column="do_exercise_count" jdbcType="INTEGER" property="doExerciseCount"/>
|
||||
<result column="do_exercise_correct_count" jdbcType="INTEGER" property="doExerciseCorrectCount"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
||||
<sql id="filterRef">
|
||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
||||
<include refid="com.orange.demo.webadmin.app.dao.StudentActionStatsMapper.inputFilterRef"/>
|
||||
</sql>
|
||||
|
||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
||||
<sql id="inputFilterRef">
|
||||
<if test="studentActionStatsFilter != null">
|
||||
<if test="studentActionStatsFilter.statsDateStart != null and studentActionStatsFilter.statsDateStart != ''">
|
||||
AND zz_student_action_stats.stats_date >= #{studentActionStatsFilter.statsDateStart}
|
||||
</if>
|
||||
<if test="studentActionStatsFilter.statsDateEnd != null and studentActionStatsFilter.statsDateEnd != ''">
|
||||
AND zz_student_action_stats.stats_date <= #{studentActionStatsFilter.statsDateEnd}
|
||||
</if>
|
||||
<if test="studentActionStatsFilter.gradeId != null">
|
||||
AND zz_student_action_stats.grade_id = #{studentActionStatsFilter.gradeId}
|
||||
</if>
|
||||
<if test="studentActionStatsFilter.provinceId != null">
|
||||
AND zz_student_action_stats.province_id = #{studentActionStatsFilter.provinceId}
|
||||
</if>
|
||||
<if test="studentActionStatsFilter.cityId != null">
|
||||
AND zz_student_action_stats.city_id = #{studentActionStatsFilter.cityId}
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getGroupedStudentActionStatsList" resultMap="BaseResultMap" parameterType="com.orange.demo.webadmin.app.model.StudentActionStats">
|
||||
SELECT * FROM
|
||||
(SELECT
|
||||
SUM(buy_course_amount) buy_course_amount,
|
||||
COUNT(buy_course_count) buy_course_count,
|
||||
SUM(buy_video_amount) buy_video_amount,
|
||||
COUNT(buy_video_count) buy_video_count,
|
||||
SUM(buy_paper_amount) buy_paper_amount,
|
||||
COUNT(buy_paper_count) buy_paper_count,
|
||||
SUM(buy_flower_amount) buy_flower_amount,
|
||||
COUNT(buy_flower_count) buy_flower_count,
|
||||
SUM(recharge_coin_amount) recharge_coin_amount,
|
||||
COUNT(recharge_coin_count) recharge_coin_count,
|
||||
SUM(do_course_count) do_course_count,
|
||||
SUM(watch_video_count) watch_video_count,
|
||||
SUM(watch_video_total_second) watch_video_total_second,
|
||||
SUM(do_exercise_count) do_exercise_count,
|
||||
SUM(do_exercise_correct_count) do_exercise_correct_count,
|
||||
${groupSelect}
|
||||
FROM zz_student_action_stats
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
GROUP BY ${groupBy}) zz_student_action_stats
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getStudentActionStatsList" resultMap="BaseResultMap" parameterType="com.orange.demo.webadmin.app.model.StudentActionStats">
|
||||
SELECT * FROM zz_student_action_stats
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orange.demo.webadmin.app.dao.StudentActionTransMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orange.demo.webadmin.app.model.StudentActionTrans">
|
||||
<id column="trans_id" jdbcType="BIGINT" property="transId"/>
|
||||
<result column="student_id" jdbcType="BIGINT" property="studentId"/>
|
||||
<result column="student_name" jdbcType="VARCHAR" property="studentName"/>
|
||||
<result column="school_id" jdbcType="BIGINT" property="schoolId"/>
|
||||
<result column="grade_id" jdbcType="INTEGER" property="gradeId"/>
|
||||
<result column="action_type" jdbcType="TINYINT" property="actionType"/>
|
||||
<result column="device_type" jdbcType="TINYINT" property="deviceType"/>
|
||||
<result column="watch_video_seconds" jdbcType="INTEGER" property="watchVideoSeconds"/>
|
||||
<result column="flower_count" jdbcType="INTEGER" property="flowerCount"/>
|
||||
<result column="paper_count" jdbcType="INTEGER" property="paperCount"/>
|
||||
<result column="video_count" jdbcType="INTEGER" property="videoCount"/>
|
||||
<result column="course_count" jdbcType="INTEGER" property="courseCount"/>
|
||||
<result column="coin_count" jdbcType="INTEGER" property="coinCount"/>
|
||||
<result column="exercise_correct_flag" jdbcType="TINYINT" property="exerciseCorrectFlag"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
||||
<sql id="filterRef">
|
||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
||||
<include refid="com.orange.demo.webadmin.app.dao.StudentActionTransMapper.inputFilterRef"/>
|
||||
</sql>
|
||||
|
||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
||||
<sql id="inputFilterRef">
|
||||
<if test="studentActionTransFilter != null">
|
||||
<if test="studentActionTransFilter.studentId != null">
|
||||
AND zz_student_action_trans.student_id = #{studentActionTransFilter.studentId}
|
||||
</if>
|
||||
<if test="studentActionTransFilter.schoolId != null">
|
||||
AND zz_student_action_trans.school_id = #{studentActionTransFilter.schoolId}
|
||||
</if>
|
||||
<if test="studentActionTransFilter.gradeId != null">
|
||||
AND zz_student_action_trans.grade_id = #{studentActionTransFilter.gradeId}
|
||||
</if>
|
||||
<if test="studentActionTransFilter.actionType != null">
|
||||
AND zz_student_action_trans.action_type = #{studentActionTransFilter.actionType}
|
||||
</if>
|
||||
<if test="studentActionTransFilter.deviceType != null">
|
||||
AND zz_student_action_trans.device_type = #{studentActionTransFilter.deviceType}
|
||||
</if>
|
||||
<if test="studentActionTransFilter.createTimeStart != null and studentActionTransFilter.createTimeStart != ''">
|
||||
AND zz_student_action_trans.create_time >= #{studentActionTransFilter.createTimeStart}
|
||||
</if>
|
||||
<if test="studentActionTransFilter.createTimeEnd != null and studentActionTransFilter.createTimeEnd != ''">
|
||||
AND zz_student_action_trans.create_time <= #{studentActionTransFilter.createTimeEnd}
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getStudentActionTransList" resultMap="BaseResultMap" parameterType="com.orange.demo.webadmin.app.model.StudentActionTrans">
|
||||
SELECT * FROM zz_student_action_trans
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orange.demo.webadmin.app.dao.StudentClassMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orange.demo.webadmin.app.model.StudentClass">
|
||||
<id column="class_id" jdbcType="BIGINT" property="classId"/>
|
||||
<result column="class_name" jdbcType="VARCHAR" property="className"/>
|
||||
<result column="school_id" jdbcType="BIGINT" property="schoolId"/>
|
||||
<result column="leader_id" jdbcType="BIGINT" property="leaderId"/>
|
||||
<result column="finish_class_hour" jdbcType="INTEGER" property="finishClassHour"/>
|
||||
<result column="class_level" jdbcType="TINYINT" property="classLevel"/>
|
||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="status" jdbcType="TINYINT" property="status"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
||||
<sql id="filterRef">
|
||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
||||
<include refid="com.orange.demo.webadmin.app.dao.StudentClassMapper.inputFilterRef"/>
|
||||
AND zz_class.status = ${@com.orange.demo.common.core.constant.GlobalDeletedFlag@NORMAL}
|
||||
</sql>
|
||||
|
||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
||||
<sql id="inputFilterRef">
|
||||
<if test="studentClassFilter != null">
|
||||
<if test="studentClassFilter.className != null and studentClassFilter.className != ''">
|
||||
AND zz_class.class_name = #{studentClassFilter.className}
|
||||
</if>
|
||||
<if test="studentClassFilter.schoolId != null">
|
||||
AND zz_class.school_id = #{studentClassFilter.schoolId}
|
||||
</if>
|
||||
<if test="studentClassFilter.classLevel != null">
|
||||
AND zz_class.class_level = #{studentClassFilter.classLevel}
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getStudentClassList" resultMap="BaseResultMap" parameterType="com.orange.demo.webadmin.app.model.StudentClass">
|
||||
SELECT * FROM zz_class
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orange.demo.webadmin.app.dao.StudentMapper">
|
||||
<resultMap id="BaseResultMap" type="com.orange.demo.webadmin.app.model.Student">
|
||||
<id column="student_id" jdbcType="BIGINT" property="studentId"/>
|
||||
<result column="login_mobile" jdbcType="VARCHAR" property="loginMobile"/>
|
||||
<result column="student_name" jdbcType="VARCHAR" property="studentName"/>
|
||||
<result column="province_id" jdbcType="BIGINT" property="provinceId"/>
|
||||
<result column="city_id" jdbcType="BIGINT" property="cityId"/>
|
||||
<result column="district_id" jdbcType="BIGINT" property="districtId"/>
|
||||
<result column="gender" jdbcType="INTEGER" property="gender"/>
|
||||
<result column="birthday" jdbcType="DATE" property="birthday"/>
|
||||
<result column="experience_level" jdbcType="TINYINT" property="experienceLevel"/>
|
||||
<result column="total_coin" jdbcType="INTEGER" property="totalCoin"/>
|
||||
<result column="left_coin" jdbcType="INTEGER" property="leftCoin"/>
|
||||
<result column="grade_id" jdbcType="INTEGER" property="gradeId"/>
|
||||
<result column="school_id" jdbcType="BIGINT" property="schoolId"/>
|
||||
<result column="register_time" jdbcType="TIMESTAMP" property="registerTime"/>
|
||||
<result column="status" jdbcType="TINYINT" property="status"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
||||
<sql id="filterRef">
|
||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
||||
<include refid="com.orange.demo.webadmin.app.dao.StudentMapper.inputFilterRef"/>
|
||||
</sql>
|
||||
|
||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
||||
<sql id="inputFilterRef">
|
||||
<if test="studentFilter != null">
|
||||
<if test="studentFilter.provinceId != null">
|
||||
AND zz_student.province_id = #{studentFilter.provinceId}
|
||||
</if>
|
||||
<if test="studentFilter.cityId != null">
|
||||
AND zz_student.city_id = #{studentFilter.cityId}
|
||||
</if>
|
||||
<if test="studentFilter.districtId != null">
|
||||
AND zz_student.district_id = #{studentFilter.districtId}
|
||||
</if>
|
||||
<if test="studentFilter.birthdayStart != null and studentFilter.birthdayStart != ''">
|
||||
AND zz_student.birthday >= #{studentFilter.birthdayStart}
|
||||
</if>
|
||||
<if test="studentFilter.birthdayEnd != null and studentFilter.birthdayEnd != ''">
|
||||
AND zz_student.birthday <= #{studentFilter.birthdayEnd}
|
||||
</if>
|
||||
<if test="studentFilter.gradeId != null">
|
||||
AND zz_student.grade_id = #{studentFilter.gradeId}
|
||||
</if>
|
||||
<if test="studentFilter.schoolId != null">
|
||||
AND zz_student.school_id = #{studentFilter.schoolId}
|
||||
</if>
|
||||
<if test="studentFilter.registerTimeStart != null and studentFilter.registerTimeStart != ''">
|
||||
AND zz_student.register_time >= #{studentFilter.registerTimeStart}
|
||||
</if>
|
||||
<if test="studentFilter.registerTimeEnd != null and studentFilter.registerTimeEnd != ''">
|
||||
AND zz_student.register_time <= #{studentFilter.registerTimeEnd}
|
||||
</if>
|
||||
<if test="studentFilter.status != null">
|
||||
AND zz_student.status = #{studentFilter.status}
|
||||
</if>
|
||||
<if test="studentFilter.searchString != null and studentFilter.searchString != ''">
|
||||
<bind name = "safeSearchString" value = "'%' + studentFilter.searchString + '%'" />
|
||||
AND CONCAT(IFNULL(zz_student.login_mobile,''), IFNULL(zz_student.student_name,'')) LIKE #{safeSearchString}
|
||||
</if>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="getStudentList" resultMap="BaseResultMap" parameterType="com.orange.demo.webadmin.app.model.Student">
|
||||
SELECT * FROM zz_student
|
||||
<where>
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getStudentListByClassId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
zz_student.*
|
||||
FROM
|
||||
zz_student,
|
||||
zz_class_student
|
||||
<where>
|
||||
AND zz_class_student.class_id = #{classId}
|
||||
AND zz_class_student.student_id = zz_student.student_id
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getNotInStudentListByClassId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
zz_student.*
|
||||
FROM
|
||||
zz_student
|
||||
<where>
|
||||
AND NOT EXISTS (SELECT * FROM zz_class_student
|
||||
WHERE zz_class_student.class_id = #{classId} AND zz_class_student.student_id = zz_student.student_id)
|
||||
<include refid="filterRef"/>
|
||||
</where>
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.orange.demo.webadmin.app.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* ClassCourseDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class ClassCourseDto {
|
||||
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,班级Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long classId;
|
||||
|
||||
/**
|
||||
* 课程Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,课程Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 课程顺序(数值越小越靠前)。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,课程顺序(数值越小越靠前)不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer courseOrder;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.orange.demo.webadmin.app.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* ClassStudentDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class ClassStudentDto {
|
||||
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,班级Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long classId;
|
||||
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,学生Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long studentId;
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.orange.demo.webadmin.app.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.webadmin.app.model.constant.CourseDifficult;
|
||||
import com.orange.demo.application.common.constant.Subject;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* CourseDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class CourseDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 课程名称。
|
||||
*/
|
||||
@NotBlank(message = "数据验证失败,课程名称不能为空!")
|
||||
private String courseName;
|
||||
|
||||
/**
|
||||
* 课程价格。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,课程价格不能为空!")
|
||||
private BigDecimal price;
|
||||
|
||||
/**
|
||||
* 课程描述。
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 课程难度(0: 容易 1: 普通 2: 很难)。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,课程难度不能为空!")
|
||||
@ConstDictRef(constDictClass = CourseDifficult.class, message = "数据验证失败,课程难度为无效值!")
|
||||
private Integer difficulty;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所属年级不能为空!")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 学科Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所属学科不能为空!")
|
||||
@ConstDictRef(constDictClass = Subject.class, message = "数据验证失败,所属学科为无效值!")
|
||||
private Integer subjectId;
|
||||
|
||||
/**
|
||||
* 课时数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,课时数量不能为空!")
|
||||
private Integer classHour;
|
||||
|
||||
/**
|
||||
* 多张课程图片地址。
|
||||
*/
|
||||
@NotBlank(message = "数据验证失败,课程图片不能为空!")
|
||||
private String pictureUrl;
|
||||
|
||||
/**
|
||||
* price 范围过滤起始值(>=)。
|
||||
*/
|
||||
private BigDecimal priceStart;
|
||||
|
||||
/**
|
||||
* price 范围过滤结束值(<=)。
|
||||
*/
|
||||
private BigDecimal priceEnd;
|
||||
|
||||
/**
|
||||
* classHour 范围过滤起始值(>=)。
|
||||
*/
|
||||
private Integer classHourStart;
|
||||
|
||||
/**
|
||||
* classHour 范围过滤结束值(<=)。
|
||||
*/
|
||||
private Integer classHourEnd;
|
||||
|
||||
/**
|
||||
* createTime 范围过滤起始值(>=)。
|
||||
*/
|
||||
private String createTimeStart;
|
||||
|
||||
/**
|
||||
* createTime 范围过滤结束值(<=)。
|
||||
*/
|
||||
private String createTimeEnd;
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.orange.demo.webadmin.app.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.application.common.constant.Subject;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* CourseTransStatsDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class CourseTransStatsDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long statsId;
|
||||
|
||||
/**
|
||||
* 统计日期。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,统计日期不能为空!")
|
||||
private Date statsDate;
|
||||
|
||||
/**
|
||||
* 科目Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所属科目不能为空!")
|
||||
@ConstDictRef(constDictClass = Subject.class, message = "数据验证失败,所属科目为无效值!")
|
||||
private Integer subjectId;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所属年级不能为空!")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 年级名称。
|
||||
*/
|
||||
private String gradeName;
|
||||
|
||||
/**
|
||||
* 课程Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,课程Id不能为空!")
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 课程名称。
|
||||
*/
|
||||
private String courseName;
|
||||
|
||||
/**
|
||||
* 学生上课次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,上课次数不能为空!")
|
||||
private Integer studentAttendCount;
|
||||
|
||||
/**
|
||||
* 学生献花数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,献花数量不能为空!")
|
||||
private Integer studentFlowerAmount;
|
||||
|
||||
/**
|
||||
* 学生献花次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,献花次数不能为空!")
|
||||
private Integer studentFlowerCount;
|
||||
|
||||
/**
|
||||
* statsDate 范围过滤起始值(>=)。
|
||||
*/
|
||||
private String statsDateStart;
|
||||
|
||||
/**
|
||||
* statsDate 范围过滤结束值(<=)。
|
||||
*/
|
||||
private String statsDateEnd;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.orange.demo.webadmin.app.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* GradeDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class GradeDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 年级名称。
|
||||
*/
|
||||
@NotBlank(message = "数据验证失败,年级名称不能为空!")
|
||||
private String gradeName;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.orange.demo.webadmin.app.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* SchoolInfoDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class SchoolInfoDto {
|
||||
|
||||
/**
|
||||
* 学校Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,学校Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 学校名称。
|
||||
*/
|
||||
@NotBlank(message = "数据验证失败,学校名称不能为空!")
|
||||
private String schoolName;
|
||||
|
||||
/**
|
||||
* 所在省Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所在省份不能为空!")
|
||||
private Long provinceId;
|
||||
|
||||
/**
|
||||
* 所在城市Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所在城市不能为空!")
|
||||
private Long cityId;
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package com.orange.demo.webadmin.app.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* StudentActionStatsDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class StudentActionStatsDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long statsId;
|
||||
|
||||
/**
|
||||
* 统计日期。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,统计日期不能为空!")
|
||||
private Date statsDate;
|
||||
|
||||
/**
|
||||
* 统计小时。
|
||||
*/
|
||||
private Date statsMonth;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所属年级不能为空!")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 学生所在省Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所在省份不能为空!")
|
||||
private Long provinceId;
|
||||
|
||||
/**
|
||||
* 学生所在城市Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所在城市不能为空!", groups = {UpdateGroup.class})
|
||||
private Long cityId;
|
||||
|
||||
/**
|
||||
* 购课学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购课学币数量不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer buyCourseAmount;
|
||||
|
||||
/**
|
||||
* 购买课程次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买课程次数不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer buyCourseCount;
|
||||
|
||||
/**
|
||||
* 购买视频学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买视频学币数量不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer buyVideoAmount;
|
||||
|
||||
/**
|
||||
* 购买视频次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买视频次数不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer buyVideoCount;
|
||||
|
||||
/**
|
||||
* 购买作业学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买作业学币数量不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer buyPaperAmount;
|
||||
|
||||
/**
|
||||
* 购买作业次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买作业次数不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer buyPaperCount;
|
||||
|
||||
/**
|
||||
* 购买献花数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买献花数量不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer buyFlowerAmount;
|
||||
|
||||
/**
|
||||
* 购买献花次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买献花次数不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer buyFlowerCount;
|
||||
|
||||
/**
|
||||
* 充值学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,充值学币数量不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer rechargeCoinAmount;
|
||||
|
||||
/**
|
||||
* 充值学币次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,充值学币次数不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer rechargeCoinCount;
|
||||
|
||||
/**
|
||||
* 线下课程上课次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,线下课程上课次数不能为空!")
|
||||
private Integer doCourseCount;
|
||||
|
||||
/**
|
||||
* 观看视频次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,观看视频次数不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer watchVideoCount;
|
||||
|
||||
/**
|
||||
* 购买献花消费学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买献花消费学币数量不能为空!")
|
||||
private Integer watchVideoTotalSecond;
|
||||
|
||||
/**
|
||||
* 做题数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,做题数量不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer doExerciseCount;
|
||||
|
||||
/**
|
||||
* 做题正确的数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,做题正确的数量不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer doExerciseCorrectCount;
|
||||
|
||||
/**
|
||||
* statsDate 范围过滤起始值(>=)。
|
||||
*/
|
||||
private String statsDateStart;
|
||||
|
||||
/**
|
||||
* statsDate 范围过滤结束值(<=)。
|
||||
*/
|
||||
private String statsDateEnd;
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.orange.demo.webadmin.app.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.application.common.constant.StudentActionType;
|
||||
import com.orange.demo.application.common.constant.DeviceType;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* StudentActionTransDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class StudentActionTransDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long transId;
|
||||
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,学生Id不能为空!")
|
||||
private Long studentId;
|
||||
|
||||
/**
|
||||
* 学生名称。
|
||||
*/
|
||||
@NotBlank(message = "数据验证失败,学生名称不能为空!")
|
||||
private String studentName;
|
||||
|
||||
/**
|
||||
* 学生校区。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,学生校区不能为空!")
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,学生年级不能为空!")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 行为类型(0: 充值 1: 购课 2: 上课签到 3: 上课签退 4: 看视频课 5: 做作业 6: 刷题 7: 献花)。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,行为类型不能为空!")
|
||||
@ConstDictRef(constDictClass = StudentActionType.class, message = "数据验证失败,行为类型为无效值!")
|
||||
private Integer actionType;
|
||||
|
||||
/**
|
||||
* 设备类型(0: iOS 1: Android 2: PC)。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,设备类型不能为空!")
|
||||
@ConstDictRef(constDictClass = DeviceType.class, message = "数据验证失败,设备类型为无效值!")
|
||||
private Integer deviceType;
|
||||
|
||||
/**
|
||||
* 看视频秒数。
|
||||
*/
|
||||
private Integer watchVideoSeconds;
|
||||
|
||||
/**
|
||||
* 购买献花数量。
|
||||
*/
|
||||
private Integer flowerCount;
|
||||
|
||||
/**
|
||||
* 购买作业数量。
|
||||
*/
|
||||
private Integer paperCount;
|
||||
|
||||
/**
|
||||
* 购买视频数量。
|
||||
*/
|
||||
private Integer videoCount;
|
||||
|
||||
/**
|
||||
* 购买课程数量。
|
||||
*/
|
||||
private Integer courseCount;
|
||||
|
||||
/**
|
||||
* 充值学币数量。
|
||||
*/
|
||||
private Integer coinCount;
|
||||
|
||||
/**
|
||||
* 做题是否正确标记。
|
||||
*/
|
||||
private Integer exerciseCorrectFlag;
|
||||
|
||||
/**
|
||||
* 发生时间。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,发生时间不能为空!")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* createTime 范围过滤起始值(>=)。
|
||||
*/
|
||||
private String createTimeStart;
|
||||
|
||||
/**
|
||||
* createTime 范围过滤结束值(<=)。
|
||||
*/
|
||||
private String createTimeEnd;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.orange.demo.webadmin.app.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.webadmin.app.model.constant.ClassLevel;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* StudentClassDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class StudentClassDto {
|
||||
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,班级Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long classId;
|
||||
|
||||
/**
|
||||
* 班级名称。
|
||||
*/
|
||||
@NotBlank(message = "数据验证失败,班级名称不能为空!")
|
||||
private String className;
|
||||
|
||||
/**
|
||||
* 学校Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所属校区不能为空!")
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 学生班长Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,学生班长不能为空!")
|
||||
private Long leaderId;
|
||||
|
||||
/**
|
||||
* 已完成课时数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,已完成课时不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer finishClassHour;
|
||||
|
||||
/**
|
||||
* 班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,班级级别不能为空!")
|
||||
@ConstDictRef(constDictClass = ClassLevel.class, message = "数据验证失败,班级级别为无效值!")
|
||||
private Integer classLevel;
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.orange.demo.webadmin.app.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.application.common.constant.Gender;
|
||||
import com.orange.demo.application.common.constant.ExpLevel;
|
||||
import com.orange.demo.application.common.constant.StudentStatus;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* StudentDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class StudentDto {
|
||||
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,学生Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long studentId;
|
||||
|
||||
/**
|
||||
* 登录手机。
|
||||
*/
|
||||
@NotBlank(message = "数据验证失败,手机号码不能为空!")
|
||||
private String loginMobile;
|
||||
|
||||
/**
|
||||
* 学生姓名。
|
||||
*/
|
||||
@NotBlank(message = "数据验证失败,学生姓名不能为空!")
|
||||
private String studentName;
|
||||
|
||||
/**
|
||||
* 所在省份Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所在省份不能为空!")
|
||||
private Long provinceId;
|
||||
|
||||
/**
|
||||
* 所在城市Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所在城市不能为空!")
|
||||
private Long cityId;
|
||||
|
||||
/**
|
||||
* 区县Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所在区县不能为空!")
|
||||
private Long districtId;
|
||||
|
||||
/**
|
||||
* 学生性别 (0: 女生 1: 男生)。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,学生性别不能为空!")
|
||||
@ConstDictRef(constDictClass = Gender.class, message = "数据验证失败,学生性别为无效值!")
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 生日。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,出生日期不能为空!")
|
||||
private Date birthday;
|
||||
|
||||
/**
|
||||
* 经验等级 (0: 初级 1: 中级 2: 高级 3: 资深)。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,经验等级不能为空!")
|
||||
@ConstDictRef(constDictClass = ExpLevel.class, message = "数据验证失败,经验等级为无效值!")
|
||||
private Integer experienceLevel;
|
||||
|
||||
/**
|
||||
* 总共充值学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,充值学币不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer totalCoin;
|
||||
|
||||
/**
|
||||
* 可用学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,剩余学币不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer leftCoin;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,年级不能为空!")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 校区Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所属校区不能为空!")
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 学生状态 (0: 正常 1: 锁定 2: 注销)。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,学生状态不能为空!", groups = {UpdateGroup.class})
|
||||
@ConstDictRef(constDictClass = StudentStatus.class, message = "数据验证失败,学生状态为无效值!")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* birthday 范围过滤起始值(>=)。
|
||||
*/
|
||||
private String birthdayStart;
|
||||
|
||||
/**
|
||||
* birthday 范围过滤结束值(<=)。
|
||||
*/
|
||||
private String birthdayEnd;
|
||||
|
||||
/**
|
||||
* registerTime 范围过滤起始值(>=)。
|
||||
*/
|
||||
private String registerTimeStart;
|
||||
|
||||
/**
|
||||
* registerTime 范围过滤结束值(<=)。
|
||||
*/
|
||||
private String registerTimeEnd;
|
||||
|
||||
/**
|
||||
* login_mobile / student_name LIKE搜索字符串。
|
||||
*/
|
||||
private String searchString;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.orange.demo.webadmin.app.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* 行政区划实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
@Table(name = "zz_area_code")
|
||||
public class AreaCode {
|
||||
|
||||
/**
|
||||
* 行政区划主键Id
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "area_id")
|
||||
private Long areaId;
|
||||
|
||||
/**
|
||||
* 行政区划名称
|
||||
*/
|
||||
@Column(name = "area_name")
|
||||
private String areaName;
|
||||
|
||||
/**
|
||||
* 行政区划级别 (1: 省级别 2: 市级别 3: 区级别)
|
||||
*/
|
||||
@Column(name = "area_level")
|
||||
private Integer areaLevel;
|
||||
|
||||
/**
|
||||
* 父级行政区划Id
|
||||
*/
|
||||
@Column(name = "parent_id")
|
||||
private Long parentId;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.orange.demo.webadmin.app.model;
|
||||
|
||||
import lombok.Data;
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* ClassCourse实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
@Table(name = "zz_class_course")
|
||||
public class ClassCourse {
|
||||
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "class_id")
|
||||
private Long classId;
|
||||
|
||||
/**
|
||||
* 课程Id。
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "course_id")
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 课程顺序(数值越小越靠前)。
|
||||
*/
|
||||
@Column(name = "course_order")
|
||||
private Integer courseOrder;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.orange.demo.webadmin.app.model;
|
||||
|
||||
import lombok.Data;
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* ClassStudent实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
@Table(name = "zz_class_student")
|
||||
public class ClassStudent {
|
||||
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "class_id")
|
||||
private Long classId;
|
||||
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "student_id")
|
||||
private Long studentId;
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
package com.orange.demo.webadmin.app.model;
|
||||
|
||||
import com.orange.demo.webadmin.app.model.constant.CourseDifficult;
|
||||
import com.orange.demo.application.common.constant.Subject;
|
||||
import com.orange.demo.common.core.upload.UploadStoreTypeEnum;
|
||||
import com.orange.demo.common.core.annotation.UploadFlagColumn;
|
||||
import com.orange.demo.common.core.annotation.RelationDict;
|
||||
import com.orange.demo.common.core.annotation.RelationConstDict;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.webadmin.app.vo.CourseVo;
|
||||
import lombok.Data;
|
||||
import org.mapstruct.*;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import javax.persistence.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Course实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
@Table(name = "zz_course")
|
||||
public class Course {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "course_id")
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 课程名称。
|
||||
*/
|
||||
@Column(name = "course_name")
|
||||
private String courseName;
|
||||
|
||||
/**
|
||||
* 课程价格。
|
||||
*/
|
||||
private BigDecimal price;
|
||||
|
||||
/**
|
||||
* 课程描述。
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 课程难度(0: 容易 1: 普通 2: 很难)。
|
||||
*/
|
||||
private Integer difficulty;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@Column(name = "grade_id")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 学科Id。
|
||||
*/
|
||||
@Column(name = "subject_id")
|
||||
private Integer subjectId;
|
||||
|
||||
/**
|
||||
* 课时数量。
|
||||
*/
|
||||
@Column(name = "class_hour")
|
||||
private Integer classHour;
|
||||
|
||||
/**
|
||||
* 多张课程图片地址。
|
||||
*/
|
||||
@UploadFlagColumn(storeType = UploadStoreTypeEnum.LOCAL_SYSTEM)
|
||||
@Column(name = "picture_url")
|
||||
private String pictureUrl;
|
||||
|
||||
/**
|
||||
* 创建用户Id。
|
||||
*/
|
||||
@Column(name = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 最后修改时间。
|
||||
*/
|
||||
@Column(name = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* price 范围过滤起始值(>=)。
|
||||
*/
|
||||
@Transient
|
||||
private BigDecimal priceStart;
|
||||
|
||||
/**
|
||||
* price 范围过滤结束值(<=)。
|
||||
*/
|
||||
@Transient
|
||||
private BigDecimal priceEnd;
|
||||
|
||||
/**
|
||||
* classHour 范围过滤起始值(>=)。
|
||||
*/
|
||||
@Transient
|
||||
private Integer classHourStart;
|
||||
|
||||
/**
|
||||
* classHour 范围过滤结束值(<=)。
|
||||
*/
|
||||
@Transient
|
||||
private Integer classHourEnd;
|
||||
|
||||
/**
|
||||
* createTime 范围过滤起始值(>=)。
|
||||
*/
|
||||
@Transient
|
||||
private String createTimeStart;
|
||||
|
||||
/**
|
||||
* createTime 范围过滤结束值(<=)。
|
||||
*/
|
||||
@Transient
|
||||
private String createTimeEnd;
|
||||
|
||||
/**
|
||||
* courseId 的多对多关联表数据对象。
|
||||
*/
|
||||
@Transient
|
||||
private ClassCourse classCourse;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "gradeId",
|
||||
slaveServiceName = "gradeService",
|
||||
slaveModelClass = Grade.class,
|
||||
slaveIdField = "gradeId",
|
||||
slaveNameField = "gradeName")
|
||||
@Transient
|
||||
private Map<String, Object> gradeIdDictMap;
|
||||
|
||||
@RelationConstDict(
|
||||
masterIdField = "difficulty",
|
||||
constantDictClass = CourseDifficult.class)
|
||||
@Transient
|
||||
private Map<String, Object> difficultyDictMap;
|
||||
|
||||
@RelationConstDict(
|
||||
masterIdField = "subjectId",
|
||||
constantDictClass = Subject.class)
|
||||
@Transient
|
||||
private Map<String, Object> subjectIdDictMap;
|
||||
|
||||
@Mapper
|
||||
public interface CourseModelMapper extends BaseModelMapper<CourseVo, Course> {
|
||||
/**
|
||||
* 转换Vo对象到实体对象。
|
||||
*
|
||||
* @param courseVo 域对象。
|
||||
* @return 实体对象。
|
||||
*/
|
||||
@Mapping(target = "classCourse", expression = "java(mapToBean(courseVo.getClassCourse(), com.orange.demo.webadmin.app.model.ClassCourse.class))")
|
||||
@Override
|
||||
Course toModel(CourseVo courseVo);
|
||||
/**
|
||||
* 转换实体对象到VO对象。
|
||||
*
|
||||
* @param course 实体对象。
|
||||
* @return 域对象。
|
||||
*/
|
||||
@Mapping(target = "classCourse", expression = "java(beanToMap(course.getClassCourse(), false))")
|
||||
@Override
|
||||
CourseVo fromModel(Course course);
|
||||
}
|
||||
public static final CourseModelMapper INSTANCE = Mappers.getMapper(CourseModelMapper.class);
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.orange.demo.webadmin.app.model;
|
||||
|
||||
import com.orange.demo.application.common.constant.Subject;
|
||||
import com.orange.demo.common.core.annotation.RelationDict;
|
||||
import com.orange.demo.common.core.annotation.RelationConstDict;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.webadmin.app.vo.CourseTransStatsVo;
|
||||
import lombok.Data;
|
||||
import org.mapstruct.*;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import javax.persistence.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* CourseTransStats实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
@Table(name = "zz_course_trans_stats")
|
||||
public class CourseTransStats {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "stats_id")
|
||||
private Long statsId;
|
||||
|
||||
/**
|
||||
* 统计日期。
|
||||
*/
|
||||
@Column(name = "stats_date")
|
||||
private Date statsDate;
|
||||
|
||||
/**
|
||||
* 科目Id。
|
||||
*/
|
||||
@Column(name = "subject_id")
|
||||
private Integer subjectId;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@Column(name = "grade_id")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 年级名称。
|
||||
*/
|
||||
@Column(name = "grade_name")
|
||||
private String gradeName;
|
||||
|
||||
/**
|
||||
* 课程Id。
|
||||
*/
|
||||
@Column(name = "course_id")
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 课程名称。
|
||||
*/
|
||||
@Column(name = "course_name")
|
||||
private String courseName;
|
||||
|
||||
/**
|
||||
* 学生上课次数。
|
||||
*/
|
||||
@Column(name = "student_attend_count")
|
||||
private Integer studentAttendCount;
|
||||
|
||||
/**
|
||||
* 学生献花数量。
|
||||
*/
|
||||
@Column(name = "student_flower_amount")
|
||||
private Integer studentFlowerAmount;
|
||||
|
||||
/**
|
||||
* 学生献花次数。
|
||||
*/
|
||||
@Column(name = "student_flower_count")
|
||||
private Integer studentFlowerCount;
|
||||
|
||||
/**
|
||||
* statsDate 范围过滤起始值(>=)。
|
||||
*/
|
||||
@Transient
|
||||
private String statsDateStart;
|
||||
|
||||
/**
|
||||
* statsDate 范围过滤结束值(<=)。
|
||||
*/
|
||||
@Transient
|
||||
private String statsDateEnd;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "gradeId",
|
||||
slaveServiceName = "gradeService",
|
||||
slaveModelClass = Grade.class,
|
||||
slaveIdField = "gradeId",
|
||||
slaveNameField = "gradeName")
|
||||
@Transient
|
||||
private Map<String, Object> gradeIdDictMap;
|
||||
|
||||
@RelationConstDict(
|
||||
masterIdField = "subjectId",
|
||||
constantDictClass = Subject.class)
|
||||
@Transient
|
||||
private Map<String, Object> subjectIdDictMap;
|
||||
|
||||
@Mapper
|
||||
public interface CourseTransStatsModelMapper extends BaseModelMapper<CourseTransStatsVo, CourseTransStats> {
|
||||
/**
|
||||
* 转换Vo对象到实体对象。
|
||||
*
|
||||
* @param courseTransStatsVo 域对象。
|
||||
* @return 实体对象。
|
||||
*/
|
||||
@Override
|
||||
CourseTransStats toModel(CourseTransStatsVo courseTransStatsVo);
|
||||
/**
|
||||
* 转换实体对象到VO对象。
|
||||
*
|
||||
* @param courseTransStats 实体对象。
|
||||
* @return 域对象。
|
||||
*/
|
||||
@Override
|
||||
CourseTransStatsVo fromModel(CourseTransStats courseTransStats);
|
||||
}
|
||||
public static final CourseTransStatsModelMapper INSTANCE = Mappers.getMapper(CourseTransStatsModelMapper.class);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.orange.demo.webadmin.app.model;
|
||||
|
||||
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
|
||||
import lombok.Data;
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* Grade实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
@Table(name = "zz_grade")
|
||||
public class Grade {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "grade_id")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 年级名称。
|
||||
*/
|
||||
@Column(name = "grade_name")
|
||||
private String gradeName;
|
||||
|
||||
/**
|
||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
|
||||
*/
|
||||
@DeletedFlagColumn
|
||||
private Integer status;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.orange.demo.webadmin.app.model;
|
||||
|
||||
import lombok.Data;
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* MaterialEdition实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
@Table(name = "zz_material_edition")
|
||||
public class MaterialEdition {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "edition_id")
|
||||
private Integer editionId;
|
||||
|
||||
/**
|
||||
* 教材版本名称。
|
||||
*/
|
||||
@Column(name = "edition_name")
|
||||
private String editionName;
|
||||
|
||||
/**
|
||||
* 是否正在使用(0:不是,1:是)。
|
||||
*/
|
||||
private Integer status;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.orange.demo.webadmin.app.model;
|
||||
|
||||
import com.orange.demo.common.core.annotation.RelationDict;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.webadmin.app.vo.SchoolInfoVo;
|
||||
import lombok.Data;
|
||||
import org.mapstruct.*;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import javax.persistence.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* SchoolInfo实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
@Table(name = "zz_school_info")
|
||||
public class SchoolInfo {
|
||||
|
||||
/**
|
||||
* 学校Id。
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "school_id")
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 学校名称。
|
||||
*/
|
||||
@Column(name = "school_name")
|
||||
private String schoolName;
|
||||
|
||||
/**
|
||||
* 所在省Id。
|
||||
*/
|
||||
@Column(name = "province_id")
|
||||
private Long provinceId;
|
||||
|
||||
/**
|
||||
* 所在城市Id。
|
||||
*/
|
||||
@Column(name = "city_id")
|
||||
private Long cityId;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "provinceId",
|
||||
slaveServiceName = "areaCodeService",
|
||||
slaveModelClass = AreaCode.class,
|
||||
slaveIdField = "areaId",
|
||||
slaveNameField = "areaName")
|
||||
@Transient
|
||||
private Map<String, Object> provinceIdDictMap;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "cityId",
|
||||
slaveServiceName = "areaCodeService",
|
||||
slaveModelClass = AreaCode.class,
|
||||
slaveIdField = "areaId",
|
||||
slaveNameField = "areaName")
|
||||
@Transient
|
||||
private Map<String, Object> cityIdDictMap;
|
||||
|
||||
@Mapper
|
||||
public interface SchoolInfoModelMapper extends BaseModelMapper<SchoolInfoVo, SchoolInfo> {
|
||||
/**
|
||||
* 转换Vo对象到实体对象。
|
||||
*
|
||||
* @param schoolInfoVo 域对象。
|
||||
* @return 实体对象。
|
||||
*/
|
||||
@Override
|
||||
SchoolInfo toModel(SchoolInfoVo schoolInfoVo);
|
||||
/**
|
||||
* 转换实体对象到VO对象。
|
||||
*
|
||||
* @param schoolInfo 实体对象。
|
||||
* @return 域对象。
|
||||
*/
|
||||
@Override
|
||||
SchoolInfoVo fromModel(SchoolInfo schoolInfo);
|
||||
}
|
||||
public static final SchoolInfoModelMapper INSTANCE = Mappers.getMapper(SchoolInfoModelMapper.class);
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
package com.orange.demo.webadmin.app.model;
|
||||
|
||||
import com.orange.demo.application.common.constant.Gender;
|
||||
import com.orange.demo.application.common.constant.ExpLevel;
|
||||
import com.orange.demo.application.common.constant.StudentStatus;
|
||||
import com.orange.demo.common.core.util.MyCommonUtil;
|
||||
import com.orange.demo.common.core.annotation.RelationDict;
|
||||
import com.orange.demo.common.core.annotation.RelationConstDict;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.webadmin.app.vo.StudentVo;
|
||||
import lombok.Data;
|
||||
import org.mapstruct.*;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import javax.persistence.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Student实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
@Table(name = "zz_student")
|
||||
public class Student {
|
||||
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "student_id")
|
||||
private Long studentId;
|
||||
|
||||
/**
|
||||
* 登录手机。
|
||||
*/
|
||||
@Column(name = "login_mobile")
|
||||
private String loginMobile;
|
||||
|
||||
/**
|
||||
* 学生姓名。
|
||||
*/
|
||||
@Column(name = "student_name")
|
||||
private String studentName;
|
||||
|
||||
/**
|
||||
* 所在省份Id。
|
||||
*/
|
||||
@Column(name = "province_id")
|
||||
private Long provinceId;
|
||||
|
||||
/**
|
||||
* 所在城市Id。
|
||||
*/
|
||||
@Column(name = "city_id")
|
||||
private Long cityId;
|
||||
|
||||
/**
|
||||
* 区县Id。
|
||||
*/
|
||||
@Column(name = "district_id")
|
||||
private Long districtId;
|
||||
|
||||
/**
|
||||
* 学生性别 (0: 女生 1: 男生)。
|
||||
*/
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 生日。
|
||||
*/
|
||||
private Date birthday;
|
||||
|
||||
/**
|
||||
* 经验等级 (0: 初级 1: 中级 2: 高级 3: 资深)。
|
||||
*/
|
||||
@Column(name = "experience_level")
|
||||
private Integer experienceLevel;
|
||||
|
||||
/**
|
||||
* 总共充值学币数量。
|
||||
*/
|
||||
@Column(name = "total_coin")
|
||||
private Integer totalCoin;
|
||||
|
||||
/**
|
||||
* 可用学币数量。
|
||||
*/
|
||||
@Column(name = "left_coin")
|
||||
private Integer leftCoin;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@Column(name = "grade_id")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 校区Id。
|
||||
*/
|
||||
@Column(name = "school_id")
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 注册时间。
|
||||
*/
|
||||
@Column(name = "register_time")
|
||||
private Date registerTime;
|
||||
|
||||
/**
|
||||
* 学生状态 (0: 正常 1: 锁定 2: 注销)。
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* birthday 范围过滤起始值(>=)。
|
||||
*/
|
||||
@Transient
|
||||
private String birthdayStart;
|
||||
|
||||
/**
|
||||
* birthday 范围过滤结束值(<=)。
|
||||
*/
|
||||
@Transient
|
||||
private String birthdayEnd;
|
||||
|
||||
/**
|
||||
* registerTime 范围过滤起始值(>=)。
|
||||
*/
|
||||
@Transient
|
||||
private String registerTimeStart;
|
||||
|
||||
/**
|
||||
* registerTime 范围过滤结束值(<=)。
|
||||
*/
|
||||
@Transient
|
||||
private String registerTimeEnd;
|
||||
|
||||
/**
|
||||
* login_mobile / student_name LIKE搜索字符串。
|
||||
*/
|
||||
@Transient
|
||||
private String searchString;
|
||||
|
||||
public void setSearchString(String searchString) {
|
||||
this.searchString = MyCommonUtil.replaceSqlWildcard(searchString);
|
||||
}
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "provinceId",
|
||||
slaveServiceName = "areaCodeService",
|
||||
slaveModelClass = AreaCode.class,
|
||||
slaveIdField = "areaId",
|
||||
slaveNameField = "areaName")
|
||||
@Transient
|
||||
private Map<String, Object> provinceIdDictMap;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "cityId",
|
||||
slaveServiceName = "areaCodeService",
|
||||
slaveModelClass = AreaCode.class,
|
||||
slaveIdField = "areaId",
|
||||
slaveNameField = "areaName")
|
||||
@Transient
|
||||
private Map<String, Object> cityIdDictMap;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "districtId",
|
||||
slaveServiceName = "areaCodeService",
|
||||
slaveModelClass = AreaCode.class,
|
||||
slaveIdField = "areaId",
|
||||
slaveNameField = "areaName")
|
||||
@Transient
|
||||
private Map<String, Object> districtIdDictMap;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "gradeId",
|
||||
slaveServiceName = "gradeService",
|
||||
slaveModelClass = Grade.class,
|
||||
slaveIdField = "gradeId",
|
||||
slaveNameField = "gradeName")
|
||||
@Transient
|
||||
private Map<String, Object> gradeIdDictMap;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "schoolId",
|
||||
slaveServiceName = "schoolInfoService",
|
||||
slaveModelClass = SchoolInfo.class,
|
||||
slaveIdField = "schoolId",
|
||||
slaveNameField = "schoolName")
|
||||
@Transient
|
||||
private Map<String, Object> schoolIdDictMap;
|
||||
|
||||
@RelationConstDict(
|
||||
masterIdField = "gender",
|
||||
constantDictClass = Gender.class)
|
||||
@Transient
|
||||
private Map<String, Object> genderDictMap;
|
||||
|
||||
@RelationConstDict(
|
||||
masterIdField = "experienceLevel",
|
||||
constantDictClass = ExpLevel.class)
|
||||
@Transient
|
||||
private Map<String, Object> experienceLevelDictMap;
|
||||
|
||||
@RelationConstDict(
|
||||
masterIdField = "status",
|
||||
constantDictClass = StudentStatus.class)
|
||||
@Transient
|
||||
private Map<String, Object> statusDictMap;
|
||||
|
||||
@Mapper
|
||||
public interface StudentModelMapper extends BaseModelMapper<StudentVo, Student> {
|
||||
/**
|
||||
* 转换Vo对象到实体对象。
|
||||
*
|
||||
* @param studentVo 域对象。
|
||||
* @return 实体对象。
|
||||
*/
|
||||
@Override
|
||||
Student toModel(StudentVo studentVo);
|
||||
/**
|
||||
* 转换实体对象到VO对象。
|
||||
*
|
||||
* @param student 实体对象。
|
||||
* @return 域对象。
|
||||
*/
|
||||
@Override
|
||||
StudentVo fromModel(Student student);
|
||||
}
|
||||
public static final StudentModelMapper INSTANCE = Mappers.getMapper(StudentModelMapper.class);
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
package com.orange.demo.webadmin.app.model;
|
||||
|
||||
import com.orange.demo.common.core.annotation.RelationDict;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.webadmin.app.vo.StudentActionStatsVo;
|
||||
import lombok.Data;
|
||||
import org.mapstruct.*;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import javax.persistence.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* StudentActionStats实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
@Table(name = "zz_student_action_stats")
|
||||
public class StudentActionStats {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "stats_id")
|
||||
private Long statsId;
|
||||
|
||||
/**
|
||||
* 统计日期。
|
||||
*/
|
||||
@Column(name = "stats_date")
|
||||
private Date statsDate;
|
||||
|
||||
/**
|
||||
* 统计小时。
|
||||
*/
|
||||
@Column(name = "stats_month")
|
||||
private Date statsMonth;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@Column(name = "grade_id")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 学生所在省Id。
|
||||
*/
|
||||
@Column(name = "province_id")
|
||||
private Long provinceId;
|
||||
|
||||
/**
|
||||
* 学生所在城市Id。
|
||||
*/
|
||||
@Column(name = "city_id")
|
||||
private Long cityId;
|
||||
|
||||
/**
|
||||
* 购课学币数量。
|
||||
*/
|
||||
@Column(name = "buy_course_amount")
|
||||
private Integer buyCourseAmount;
|
||||
|
||||
/**
|
||||
* 购买课程次数。
|
||||
*/
|
||||
@Column(name = "buy_course_count")
|
||||
private Integer buyCourseCount;
|
||||
|
||||
/**
|
||||
* 购买视频学币数量。
|
||||
*/
|
||||
@Column(name = "buy_video_amount")
|
||||
private Integer buyVideoAmount;
|
||||
|
||||
/**
|
||||
* 购买视频次数。
|
||||
*/
|
||||
@Column(name = "buy_video_count")
|
||||
private Integer buyVideoCount;
|
||||
|
||||
/**
|
||||
* 购买作业学币数量。
|
||||
*/
|
||||
@Column(name = "buy_paper_amount")
|
||||
private Integer buyPaperAmount;
|
||||
|
||||
/**
|
||||
* 购买作业次数。
|
||||
*/
|
||||
@Column(name = "buy_paper_count")
|
||||
private Integer buyPaperCount;
|
||||
|
||||
/**
|
||||
* 购买献花数量。
|
||||
*/
|
||||
@Column(name = "buy_flower_amount")
|
||||
private Integer buyFlowerAmount;
|
||||
|
||||
/**
|
||||
* 购买献花次数。
|
||||
*/
|
||||
@Column(name = "buy_flower_count")
|
||||
private Integer buyFlowerCount;
|
||||
|
||||
/**
|
||||
* 充值学币数量。
|
||||
*/
|
||||
@Column(name = "recharge_coin_amount")
|
||||
private Integer rechargeCoinAmount;
|
||||
|
||||
/**
|
||||
* 充值学币次数。
|
||||
*/
|
||||
@Column(name = "recharge_coin_count")
|
||||
private Integer rechargeCoinCount;
|
||||
|
||||
/**
|
||||
* 线下课程上课次数。
|
||||
*/
|
||||
@Column(name = "do_course_count")
|
||||
private Integer doCourseCount;
|
||||
|
||||
/**
|
||||
* 观看视频次数。
|
||||
*/
|
||||
@Column(name = "watch_video_count")
|
||||
private Integer watchVideoCount;
|
||||
|
||||
/**
|
||||
* 购买献花消费学币数量。
|
||||
*/
|
||||
@Column(name = "watch_video_total_second")
|
||||
private Integer watchVideoTotalSecond;
|
||||
|
||||
/**
|
||||
* 做题数量。
|
||||
*/
|
||||
@Column(name = "do_exercise_count")
|
||||
private Integer doExerciseCount;
|
||||
|
||||
/**
|
||||
* 做题正确的数量。
|
||||
*/
|
||||
@Column(name = "do_exercise_correct_count")
|
||||
private Integer doExerciseCorrectCount;
|
||||
|
||||
/**
|
||||
* statsDate 范围过滤起始值(>=)。
|
||||
*/
|
||||
@Transient
|
||||
private String statsDateStart;
|
||||
|
||||
/**
|
||||
* statsDate 范围过滤结束值(<=)。
|
||||
*/
|
||||
@Transient
|
||||
private String statsDateEnd;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "gradeId",
|
||||
slaveServiceName = "gradeService",
|
||||
slaveModelClass = Grade.class,
|
||||
slaveIdField = "gradeId",
|
||||
slaveNameField = "gradeName")
|
||||
@Transient
|
||||
private Map<String, Object> gradeIdDictMap;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "provinceId",
|
||||
slaveServiceName = "areaCodeService",
|
||||
slaveModelClass = AreaCode.class,
|
||||
slaveIdField = "areaId",
|
||||
slaveNameField = "areaName")
|
||||
@Transient
|
||||
private Map<String, Object> provinceIdDictMap;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "cityId",
|
||||
slaveServiceName = "areaCodeService",
|
||||
slaveModelClass = AreaCode.class,
|
||||
slaveIdField = "areaId",
|
||||
slaveNameField = "areaName")
|
||||
@Transient
|
||||
private Map<String, Object> cityIdDictMap;
|
||||
|
||||
@Mapper
|
||||
public interface StudentActionStatsModelMapper extends BaseModelMapper<StudentActionStatsVo, StudentActionStats> {
|
||||
/**
|
||||
* 转换Vo对象到实体对象。
|
||||
*
|
||||
* @param studentActionStatsVo 域对象。
|
||||
* @return 实体对象。
|
||||
*/
|
||||
@Override
|
||||
StudentActionStats toModel(StudentActionStatsVo studentActionStatsVo);
|
||||
/**
|
||||
* 转换实体对象到VO对象。
|
||||
*
|
||||
* @param studentActionStats 实体对象。
|
||||
* @return 域对象。
|
||||
*/
|
||||
@Override
|
||||
StudentActionStatsVo fromModel(StudentActionStats studentActionStats);
|
||||
}
|
||||
public static final StudentActionStatsModelMapper INSTANCE = Mappers.getMapper(StudentActionStatsModelMapper.class);
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package com.orange.demo.webadmin.app.model;
|
||||
|
||||
import com.orange.demo.application.common.constant.StudentActionType;
|
||||
import com.orange.demo.application.common.constant.DeviceType;
|
||||
import com.orange.demo.common.core.annotation.RelationDict;
|
||||
import com.orange.demo.common.core.annotation.RelationConstDict;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.webadmin.app.vo.StudentActionTransVo;
|
||||
import lombok.Data;
|
||||
import org.mapstruct.*;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import javax.persistence.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* StudentActionTrans实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
@Table(name = "zz_student_action_trans")
|
||||
public class StudentActionTrans {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "trans_id")
|
||||
private Long transId;
|
||||
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
@Column(name = "student_id")
|
||||
private Long studentId;
|
||||
|
||||
/**
|
||||
* 学生名称。
|
||||
*/
|
||||
@Column(name = "student_name")
|
||||
private String studentName;
|
||||
|
||||
/**
|
||||
* 学生校区。
|
||||
*/
|
||||
@Column(name = "school_id")
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@Column(name = "grade_id")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 行为类型(0: 充值 1: 购课 2: 上课签到 3: 上课签退 4: 看视频课 5: 做作业 6: 刷题 7: 献花)。
|
||||
*/
|
||||
@Column(name = "action_type")
|
||||
private Integer actionType;
|
||||
|
||||
/**
|
||||
* 设备类型(0: iOS 1: Android 2: PC)。
|
||||
*/
|
||||
@Column(name = "device_type")
|
||||
private Integer deviceType;
|
||||
|
||||
/**
|
||||
* 看视频秒数。
|
||||
*/
|
||||
@Column(name = "watch_video_seconds")
|
||||
private Integer watchVideoSeconds;
|
||||
|
||||
/**
|
||||
* 购买献花数量。
|
||||
*/
|
||||
@Column(name = "flower_count")
|
||||
private Integer flowerCount;
|
||||
|
||||
/**
|
||||
* 购买作业数量。
|
||||
*/
|
||||
@Column(name = "paper_count")
|
||||
private Integer paperCount;
|
||||
|
||||
/**
|
||||
* 购买视频数量。
|
||||
*/
|
||||
@Column(name = "video_count")
|
||||
private Integer videoCount;
|
||||
|
||||
/**
|
||||
* 购买课程数量。
|
||||
*/
|
||||
@Column(name = "course_count")
|
||||
private Integer courseCount;
|
||||
|
||||
/**
|
||||
* 充值学币数量。
|
||||
*/
|
||||
@Column(name = "coin_count")
|
||||
private Integer coinCount;
|
||||
|
||||
/**
|
||||
* 做题是否正确标记。
|
||||
*/
|
||||
@Column(name = "exercise_correct_flag")
|
||||
private Integer exerciseCorrectFlag;
|
||||
|
||||
/**
|
||||
* 发生时间。
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* createTime 范围过滤起始值(>=)。
|
||||
*/
|
||||
@Transient
|
||||
private String createTimeStart;
|
||||
|
||||
/**
|
||||
* createTime 范围过滤结束值(<=)。
|
||||
*/
|
||||
@Transient
|
||||
private String createTimeEnd;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "schoolId",
|
||||
slaveServiceName = "schoolInfoService",
|
||||
slaveModelClass = SchoolInfo.class,
|
||||
slaveIdField = "schoolId",
|
||||
slaveNameField = "schoolName")
|
||||
@Transient
|
||||
private Map<String, Object> schoolIdDictMap;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "gradeId",
|
||||
slaveServiceName = "gradeService",
|
||||
slaveModelClass = Grade.class,
|
||||
slaveIdField = "gradeId",
|
||||
slaveNameField = "gradeName")
|
||||
@Transient
|
||||
private Map<String, Object> gradeIdDictMap;
|
||||
|
||||
@RelationConstDict(
|
||||
masterIdField = "actionType",
|
||||
constantDictClass = StudentActionType.class)
|
||||
@Transient
|
||||
private Map<String, Object> actionTypeDictMap;
|
||||
|
||||
@RelationConstDict(
|
||||
masterIdField = "deviceType",
|
||||
constantDictClass = DeviceType.class)
|
||||
@Transient
|
||||
private Map<String, Object> deviceTypeDictMap;
|
||||
|
||||
@Mapper
|
||||
public interface StudentActionTransModelMapper extends BaseModelMapper<StudentActionTransVo, StudentActionTrans> {
|
||||
/**
|
||||
* 转换Vo对象到实体对象。
|
||||
*
|
||||
* @param studentActionTransVo 域对象。
|
||||
* @return 实体对象。
|
||||
*/
|
||||
@Override
|
||||
StudentActionTrans toModel(StudentActionTransVo studentActionTransVo);
|
||||
/**
|
||||
* 转换实体对象到VO对象。
|
||||
*
|
||||
* @param studentActionTrans 实体对象。
|
||||
* @return 域对象。
|
||||
*/
|
||||
@Override
|
||||
StudentActionTransVo fromModel(StudentActionTrans studentActionTrans);
|
||||
}
|
||||
public static final StudentActionTransModelMapper INSTANCE = Mappers.getMapper(StudentActionTransModelMapper.class);
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.orange.demo.webadmin.app.model;
|
||||
|
||||
import com.orange.demo.webadmin.app.model.constant.ClassLevel;
|
||||
import com.orange.demo.common.core.annotation.RelationDict;
|
||||
import com.orange.demo.common.core.annotation.RelationConstDict;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
|
||||
import com.orange.demo.webadmin.app.vo.StudentClassVo;
|
||||
import lombok.Data;
|
||||
import org.mapstruct.*;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import javax.persistence.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* StudentClass实体对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
@Table(name = "zz_class")
|
||||
public class StudentClass {
|
||||
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
@Id
|
||||
@Column(name = "class_id")
|
||||
private Long classId;
|
||||
|
||||
/**
|
||||
* 班级名称。
|
||||
*/
|
||||
@Column(name = "class_name")
|
||||
private String className;
|
||||
|
||||
/**
|
||||
* 学校Id。
|
||||
*/
|
||||
@Column(name = "school_id")
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 学生班长Id。
|
||||
*/
|
||||
@Column(name = "leader_id")
|
||||
private Long leaderId;
|
||||
|
||||
/**
|
||||
* 已完成课时数量。
|
||||
*/
|
||||
@Column(name = "finish_class_hour")
|
||||
private Integer finishClassHour;
|
||||
|
||||
/**
|
||||
* 班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)。
|
||||
*/
|
||||
@Column(name = "class_level")
|
||||
private Integer classLevel;
|
||||
|
||||
/**
|
||||
* 创建用户。
|
||||
*/
|
||||
@Column(name = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 班级创建时间。
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
|
||||
*/
|
||||
@DeletedFlagColumn
|
||||
private Integer status;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "schoolId",
|
||||
slaveServiceName = "schoolInfoService",
|
||||
slaveModelClass = SchoolInfo.class,
|
||||
slaveIdField = "schoolId",
|
||||
slaveNameField = "schoolName")
|
||||
@Transient
|
||||
private Map<String, Object> schoolIdDictMap;
|
||||
|
||||
@RelationDict(
|
||||
masterIdField = "leaderId",
|
||||
slaveServiceName = "studentService",
|
||||
slaveModelClass = Student.class,
|
||||
slaveIdField = "studentId",
|
||||
slaveNameField = "studentName")
|
||||
@Transient
|
||||
private Map<String, Object> leaderIdDictMap;
|
||||
|
||||
@RelationConstDict(
|
||||
masterIdField = "classLevel",
|
||||
constantDictClass = ClassLevel.class)
|
||||
@Transient
|
||||
private Map<String, Object> classLevelDictMap;
|
||||
|
||||
@Mapper
|
||||
public interface StudentClassModelMapper extends BaseModelMapper<StudentClassVo, StudentClass> {
|
||||
/**
|
||||
* 转换Vo对象到实体对象。
|
||||
*
|
||||
* @param studentClassVo 域对象。
|
||||
* @return 实体对象。
|
||||
*/
|
||||
@Override
|
||||
StudentClass toModel(StudentClassVo studentClassVo);
|
||||
/**
|
||||
* 转换实体对象到VO对象。
|
||||
*
|
||||
* @param studentClass 实体对象。
|
||||
* @return 域对象。
|
||||
*/
|
||||
@Override
|
||||
StudentClassVo fromModel(StudentClass studentClass);
|
||||
}
|
||||
public static final StudentClassModelMapper INSTANCE = Mappers.getMapper(StudentClassModelMapper.class);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.orange.demo.webadmin.app.model.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 班级级别常量字典对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public final class ClassLevel {
|
||||
|
||||
/**
|
||||
* 初级班。
|
||||
*/
|
||||
public static final int NORMAL = 0;
|
||||
/**
|
||||
* 中级班。
|
||||
*/
|
||||
public static final int MIDDLE = 1;
|
||||
/**
|
||||
* 高级班。
|
||||
*/
|
||||
public static final int HIGH = 2;
|
||||
|
||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(3);
|
||||
static {
|
||||
DICT_MAP.put(NORMAL, "初级班");
|
||||
DICT_MAP.put(MIDDLE, "中级班");
|
||||
DICT_MAP.put(HIGH, "高级班");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断参数是否为当前常量字典的合法值。
|
||||
*
|
||||
* @param value 待验证的参数值。
|
||||
* @return 合法返回true,否则false。
|
||||
*/
|
||||
public static boolean isValid(Integer value) {
|
||||
return value != null && DICT_MAP.containsKey(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私有构造函数,明确标识该常量类的作用。
|
||||
*/
|
||||
private ClassLevel() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.orange.demo.webadmin.app.model.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 班级状态常量字典对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public final class ClassStatus {
|
||||
|
||||
/**
|
||||
* 正常。
|
||||
*/
|
||||
public static final int NORAML = 1;
|
||||
/**
|
||||
* 解散。
|
||||
*/
|
||||
public static final int DELETED = -1;
|
||||
|
||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(2);
|
||||
static {
|
||||
DICT_MAP.put(NORAML, "正常");
|
||||
DICT_MAP.put(DELETED, "解散");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断参数是否为当前常量字典的合法值。
|
||||
*
|
||||
* @param value 待验证的参数值。
|
||||
* @return 合法返回true,否则false。
|
||||
*/
|
||||
public static boolean isValid(Integer value) {
|
||||
return value != null && DICT_MAP.containsKey(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私有构造函数,明确标识该常量类的作用。
|
||||
*/
|
||||
private ClassStatus() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.orange.demo.webadmin.app.model.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 课程难度常量字典对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public final class CourseDifficult {
|
||||
|
||||
/**
|
||||
* 容易。
|
||||
*/
|
||||
public static final int NORMAL = 0;
|
||||
/**
|
||||
* 普通。
|
||||
*/
|
||||
public static final int MIDDLE = 1;
|
||||
/**
|
||||
* 困难。
|
||||
*/
|
||||
public static final int HIGH = 2;
|
||||
|
||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(3);
|
||||
static {
|
||||
DICT_MAP.put(NORMAL, "容易");
|
||||
DICT_MAP.put(MIDDLE, "普通");
|
||||
DICT_MAP.put(HIGH, "困难");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断参数是否为当前常量字典的合法值。
|
||||
*
|
||||
* @param value 待验证的参数值。
|
||||
* @return 合法返回true,否则false。
|
||||
*/
|
||||
public static boolean isValid(Integer value) {
|
||||
return value != null && DICT_MAP.containsKey(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 私有构造函数,明确标识该常量类的作用。
|
||||
*/
|
||||
private CourseDifficult() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.orange.demo.webadmin.app.service;
|
||||
|
||||
import com.orange.demo.common.core.base.service.IBaseDictService;
|
||||
import com.orange.demo.webadmin.app.model.AreaCode;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 行政区划的Service接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface AreaCodeService extends IBaseDictService<AreaCode, Long> {
|
||||
|
||||
/**
|
||||
* 根据上级行政区划Id,获取其下级行政区划列表。
|
||||
*
|
||||
* @param parentId 上级行政区划Id。
|
||||
* @return 下级行政区划列表。
|
||||
*/
|
||||
Collection<AreaCode> getListByParentId(Long parentId);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.orange.demo.webadmin.app.service;
|
||||
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 课程数据数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface CourseService extends IBaseService<Course, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param course 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
Course saveNew(Course course);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param course 更新的对象。
|
||||
* @param originalCourse 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean update(Course course, Course originalCourse);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param courseId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean remove(Long courseId);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getCourseListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<Course> getCourseList(Course filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getCourseList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<Course> getCourseListWithRelation(Course filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。
|
||||
*
|
||||
* @param classId 主表主键Id。
|
||||
* @param filter 从表的过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<Course> getNotInCourseListByClassId(
|
||||
Long classId, Course filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。
|
||||
*
|
||||
* @param classId 主表主键Id。
|
||||
* @param filter 从表的过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<Course> getCourseListByClassId(
|
||||
Long classId, Course filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param course 最新数据对象。
|
||||
* @param originalCourse 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
CallResult verifyRelatedData(Course course, Course originalCourse);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.orange.demo.webadmin.app.service;
|
||||
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 课程统计数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface CourseTransStatsService extends IBaseService<CourseTransStats, Long> {
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getCourseTransStatsListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<CourseTransStats> getCourseTransStatsList(CourseTransStats filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getCourseTransStatsList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<CourseTransStats> getCourseTransStatsListWithRelation(CourseTransStats filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取分组过滤后的数据查询结果,以及关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param groupSelect 分组显示列表参数。位于SQL语句SELECT的后面。
|
||||
* @param groupBy 分组参数。位于SQL语句的GROUP BY后面。
|
||||
* @param orderBy 排序字符串,ORDER BY从句的参数。
|
||||
* @return 分组过滤结果集。
|
||||
*/
|
||||
List<CourseTransStats> getGroupedCourseTransStatsListWithRelation(
|
||||
CourseTransStats filter, String groupSelect, String groupBy, String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.orange.demo.webadmin.app.service;
|
||||
|
||||
import com.orange.demo.common.core.base.service.IBaseDictService;
|
||||
import com.orange.demo.webadmin.app.model.Grade;
|
||||
|
||||
/**
|
||||
* 年级字典数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface GradeService extends IBaseDictService<Grade, Integer> {
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.orange.demo.webadmin.app.service;
|
||||
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 校区数据数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface SchoolInfoService extends IBaseService<SchoolInfo, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param schoolInfo 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
SchoolInfo saveNew(SchoolInfo schoolInfo);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param schoolInfo 更新的对象。
|
||||
* @param originalSchoolInfo 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean update(SchoolInfo schoolInfo, SchoolInfo originalSchoolInfo);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param schoolId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean remove(Long schoolId);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getSchoolInfoListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<SchoolInfo> getSchoolInfoList(SchoolInfo filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getSchoolInfoList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<SchoolInfo> getSchoolInfoListWithRelation(SchoolInfo filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param schoolInfo 最新数据对象。
|
||||
* @param originalSchoolInfo 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
CallResult verifyRelatedData(SchoolInfo schoolInfo, SchoolInfo originalSchoolInfo);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.orange.demo.webadmin.app.service;
|
||||
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生行为统计数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface StudentActionStatsService extends IBaseService<StudentActionStats, Long> {
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getStudentActionStatsListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<StudentActionStats> getStudentActionStatsList(StudentActionStats filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentActionStatsList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<StudentActionStats> getStudentActionStatsListWithRelation(StudentActionStats filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取分组过滤后的数据查询结果,以及关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param groupSelect 分组显示列表参数。位于SQL语句SELECT的后面。
|
||||
* @param groupBy 分组参数。位于SQL语句的GROUP BY后面。
|
||||
* @param orderBy 排序字符串,ORDER BY从句的参数。
|
||||
* @return 分组过滤结果集。
|
||||
*/
|
||||
List<StudentActionStats> getGroupedStudentActionStatsListWithRelation(
|
||||
StudentActionStats filter, String groupSelect, String groupBy, String orderBy);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.orange.demo.webadmin.app.service;
|
||||
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生行为流水数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface StudentActionTransService extends IBaseService<StudentActionTrans, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param studentActionTrans 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
StudentActionTrans saveNew(StudentActionTrans studentActionTrans);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param studentActionTrans 更新的对象。
|
||||
* @param originalStudentActionTrans 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean update(StudentActionTrans studentActionTrans, StudentActionTrans originalStudentActionTrans);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param transId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean remove(Long transId);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getStudentActionTransListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<StudentActionTrans> getStudentActionTransList(StudentActionTrans filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentActionTransList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<StudentActionTrans> getStudentActionTransListWithRelation(StudentActionTrans filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param studentActionTrans 最新数据对象。
|
||||
* @param originalStudentActionTrans 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
CallResult verifyRelatedData(StudentActionTrans studentActionTrans, StudentActionTrans originalStudentActionTrans);
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.orange.demo.webadmin.app.service;
|
||||
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 班级数据数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface StudentClassService extends IBaseService<StudentClass, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param studentClass 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
StudentClass saveNew(StudentClass studentClass);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param studentClass 更新的对象。
|
||||
* @param originalStudentClass 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean update(StudentClass studentClass, StudentClass originalStudentClass);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param classId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean remove(Long classId);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getStudentClassListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<StudentClass> getStudentClassList(StudentClass filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentClassList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<StudentClass> getStudentClassListWithRelation(StudentClass filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 批量添加多对多关联关系。
|
||||
*
|
||||
* @param classCourseList 多对多关联表对象集合。
|
||||
* @param classId 主表Id。
|
||||
*/
|
||||
void addClassCourseList(List<ClassCourse> classCourseList, Long classId);
|
||||
|
||||
/**
|
||||
* 更新中间表数据。
|
||||
*
|
||||
* @param classCourse 中间表对象。
|
||||
* @return 更新成功与否。
|
||||
*/
|
||||
boolean updateClassCourse(ClassCourse classCourse);
|
||||
|
||||
/**
|
||||
* 获取中间表数据。
|
||||
*
|
||||
* @param classId 主表Id。
|
||||
* @param courseId 从表Id。
|
||||
* @return 中间表对象。
|
||||
*/
|
||||
ClassCourse getClassCourse(Long classId, Long courseId);
|
||||
|
||||
/**
|
||||
* 移除单条多对多关系。
|
||||
*
|
||||
* @param classId 主表Id。
|
||||
* @param courseId 从表Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean removeClassCourse(Long classId, Long courseId);
|
||||
|
||||
/**
|
||||
* 批量添加多对多关联关系。
|
||||
*
|
||||
* @param classStudentList 多对多关联表对象集合。
|
||||
* @param classId 主表Id。
|
||||
*/
|
||||
void addClassStudentList(List<ClassStudent> classStudentList, Long classId);
|
||||
|
||||
/**
|
||||
* 移除单条多对多关系。
|
||||
*
|
||||
* @param classId 主表Id。
|
||||
* @param studentId 从表Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean removeClassStudent(Long classId, Long studentId);
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param studentClass 最新数据对象。
|
||||
* @param originalStudentClass 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
CallResult verifyRelatedData(StudentClass studentClass, StudentClass originalStudentClass);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.orange.demo.webadmin.app.service;
|
||||
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生数据数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
public interface StudentService extends IBaseService<Student, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param student 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
Student saveNew(Student student);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param student 更新的对象。
|
||||
* @param originalStudent 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean update(Student student, Student originalStudent);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param studentId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
boolean remove(Long studentId);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getStudentListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<Student> getStudentList(Student filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<Student> getStudentListWithRelation(Student filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。
|
||||
*
|
||||
* @param classId 主表主键Id。
|
||||
* @param filter 从表的过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<Student> getNotInStudentListByClassId(
|
||||
Long classId, Student filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。
|
||||
*
|
||||
* @param classId 主表主键Id。
|
||||
* @param filter 从表的过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
List<Student> getStudentListByClassId(
|
||||
Long classId, Student filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param student 最新数据对象。
|
||||
* @param originalStudent 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
CallResult verifyRelatedData(Student student, Student originalStudent);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.orange.demo.webadmin.app.service.impl;
|
||||
|
||||
import com.orange.demo.webadmin.app.service.AreaCodeService;
|
||||
import com.orange.demo.webadmin.app.dao.AreaCodeMapper;
|
||||
import com.orange.demo.webadmin.app.model.AreaCode;
|
||||
import com.orange.demo.common.core.cache.MapTreeDictionaryCache;
|
||||
import com.orange.demo.common.core.base.service.BaseDictService;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 行政区划的Service类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("areaCodeService")
|
||||
public class AreaCodeServiceImpl extends BaseDictService<AreaCode, Long> implements AreaCodeService {
|
||||
|
||||
@Autowired
|
||||
private AreaCodeMapper areaCodeMapper;
|
||||
|
||||
public AreaCodeServiceImpl() {
|
||||
super();
|
||||
this.dictionaryCache = MapTreeDictionaryCache.create(AreaCode::getAreaId, AreaCode::getParentId);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.reloadCachedData(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BaseDaoMapper<AreaCode> mapper() {
|
||||
return areaCodeMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据上级行政区划Id,获取其下级行政区划列表。
|
||||
*
|
||||
* @param parentId 上级行政区划Id。
|
||||
* @return 下级行政区划列表。
|
||||
*/
|
||||
@Override
|
||||
public Collection<AreaCode> getListByParentId(Long parentId) {
|
||||
return ((MapTreeDictionaryCache<Long, AreaCode>) dictionaryCache).getListByParentId(parentId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
package com.orange.demo.webadmin.app.service.impl;
|
||||
|
||||
import com.orange.demo.webadmin.app.service.*;
|
||||
import com.orange.demo.webadmin.app.dao.*;
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.TokenData;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.github.pagehelper.Page;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 课程数据数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("courseService")
|
||||
public class CourseServiceImpl extends BaseService<Course, Long> implements CourseService {
|
||||
|
||||
@Autowired
|
||||
private CourseMapper courseMapper;
|
||||
@Autowired
|
||||
private ClassCourseMapper classCourseMapper;
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<Course> mapper() {
|
||||
return courseMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param course 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public Course saveNew(Course course) {
|
||||
course.setCourseId(idGenerator.nextLongId());
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
course.setCreateUserId(tokenData.getUserId());
|
||||
Date now = new Date();
|
||||
course.setCreateTime(now);
|
||||
course.setUpdateTime(now);
|
||||
courseMapper.insert(course);
|
||||
return course;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param course 更新的对象。
|
||||
* @param originalCourse 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(Course course, Course originalCourse) {
|
||||
course.setCreateUserId(originalCourse.getCreateUserId());
|
||||
course.setCreateTime(originalCourse.getCreateTime());
|
||||
course.setUpdateTime(new Date());
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
return courseMapper.updateByPrimaryKey(course) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param courseId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long courseId) {
|
||||
// 这里先删除主数据
|
||||
if (!this.removeById(courseId)) {
|
||||
return false;
|
||||
}
|
||||
// 开始删除多对多父表的关联
|
||||
ClassCourse classCourse = new ClassCourse();
|
||||
classCourse.setCourseId(courseId);
|
||||
classCourseMapper.delete(classCourse);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getCourseListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<Course> getCourseList(Course filter, String orderBy) {
|
||||
return courseMapper.getCourseList(filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getCourseList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<Course> getCourseListWithRelation(Course filter, String orderBy) {
|
||||
List<Course> resultList = courseMapper.getCourseList(filter, orderBy);
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。
|
||||
*
|
||||
* @param classId 主表主键Id。
|
||||
* @param filter 从表的过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<Course> getNotInCourseListByClassId(
|
||||
Long classId, Course filter, String orderBy) {
|
||||
List<Course> resultList =
|
||||
courseMapper.getNotInCourseListByClassId(classId, filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。
|
||||
*
|
||||
* @param classId 主表主键Id。
|
||||
* @param filter 从表的过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<Course> getCourseListByClassId(
|
||||
Long classId, Course filter, String orderBy) {
|
||||
List<Course> resultList =
|
||||
courseMapper.getCourseListByClassId(classId, filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param course 最新数据对象。
|
||||
* @param originalCourse 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
@Override
|
||||
public CallResult verifyRelatedData(Course course, Course originalCourse) {
|
||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(course, originalCourse, Course::getGradeId)
|
||||
&& !gradeService.existId(course.getGradeId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "所属年级"));
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.orange.demo.webadmin.app.service.impl;
|
||||
|
||||
import com.orange.demo.webadmin.app.service.*;
|
||||
import com.orange.demo.webadmin.app.dao.*;
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.github.pagehelper.Page;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 课程统计数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("courseTransStatsService")
|
||||
public class CourseTransStatsServiceImpl extends BaseService<CourseTransStats, Long> implements CourseTransStatsService {
|
||||
|
||||
@Autowired
|
||||
private CourseTransStatsMapper courseTransStatsMapper;
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<CourseTransStats> mapper() {
|
||||
return courseTransStatsMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getCourseTransStatsListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<CourseTransStats> getCourseTransStatsList(CourseTransStats filter, String orderBy) {
|
||||
return courseTransStatsMapper.getCourseTransStatsList(filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getCourseTransStatsList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<CourseTransStats> getCourseTransStatsListWithRelation(CourseTransStats filter, String orderBy) {
|
||||
List<CourseTransStats> resultList = courseTransStatsMapper.getCourseTransStatsList(filter, orderBy);
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分组过滤后的数据查询结果,以及关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param groupSelect 分组显示列表参数。位于SQL语句SELECT的后面。
|
||||
* @param groupBy 分组参数。位于SQL语句的GROUP BY后面。
|
||||
* @param orderBy 排序字符串,ORDER BY从句的参数。
|
||||
* @return 分组过滤结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<CourseTransStats> getGroupedCourseTransStatsListWithRelation(
|
||||
CourseTransStats filter, String groupSelect, String groupBy, String orderBy) {
|
||||
List<CourseTransStats> resultList =
|
||||
courseTransStatsMapper.getGroupedCourseTransStatsList(filter, groupSelect, groupBy, orderBy);
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
||||
// NOTE: 这里只是包含了关联数据,聚合计算数据没有包含。
|
||||
// 主要原因是,由于聚合字段通常被视为普通字段使用,不会在group by的从句中出现,语义上也不会在此关联。
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.orange.demo.webadmin.app.service.impl;
|
||||
|
||||
import com.orange.demo.common.core.base.service.BaseDictService;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.redis.cache.RedisDictionaryCache;
|
||||
import com.orange.demo.webadmin.app.service.GradeService;
|
||||
import com.orange.demo.webadmin.app.dao.GradeMapper;
|
||||
import com.orange.demo.webadmin.app.model.Grade;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* 年级字典数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("gradeService")
|
||||
public class GradeServiceImpl extends BaseDictService<Grade, Integer> implements GradeService {
|
||||
|
||||
@Autowired
|
||||
private GradeMapper gradeMapper;
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
public GradeServiceImpl() {
|
||||
super();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.dictionaryCache = RedisDictionaryCache.create(
|
||||
redissonClient, "Grade", Grade.class, Grade::getGradeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<Grade> mapper() {
|
||||
return gradeMapper;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package com.orange.demo.webadmin.app.service.impl;
|
||||
|
||||
import com.orange.demo.webadmin.app.service.*;
|
||||
import com.orange.demo.webadmin.app.dao.*;
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.github.pagehelper.Page;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 校区数据数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("schoolInfoService")
|
||||
public class SchoolInfoServiceImpl extends BaseService<SchoolInfo, Long> implements SchoolInfoService {
|
||||
|
||||
@Autowired
|
||||
private SchoolInfoMapper schoolInfoMapper;
|
||||
@Autowired
|
||||
private AreaCodeService areaCodeService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<SchoolInfo> mapper() {
|
||||
return schoolInfoMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param schoolInfo 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public SchoolInfo saveNew(SchoolInfo schoolInfo) {
|
||||
schoolInfo.setSchoolId(idGenerator.nextLongId());
|
||||
schoolInfoMapper.insert(schoolInfo);
|
||||
return schoolInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param schoolInfo 更新的对象。
|
||||
* @param originalSchoolInfo 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(SchoolInfo schoolInfo, SchoolInfo originalSchoolInfo) {
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
return schoolInfoMapper.updateByPrimaryKey(schoolInfo) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param schoolId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long schoolId) {
|
||||
// 这里先删除主数据
|
||||
return this.removeById(schoolId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getSchoolInfoListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<SchoolInfo> getSchoolInfoList(SchoolInfo filter, String orderBy) {
|
||||
return schoolInfoMapper.getSchoolInfoList(filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getSchoolInfoList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<SchoolInfo> getSchoolInfoListWithRelation(SchoolInfo filter, String orderBy) {
|
||||
List<SchoolInfo> resultList = schoolInfoMapper.getSchoolInfoList(filter, orderBy);
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param schoolInfo 最新数据对象。
|
||||
* @param originalSchoolInfo 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
@Override
|
||||
public CallResult verifyRelatedData(SchoolInfo schoolInfo, SchoolInfo originalSchoolInfo) {
|
||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(schoolInfo, originalSchoolInfo, SchoolInfo::getProvinceId)
|
||||
&& !areaCodeService.existId(schoolInfo.getProvinceId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "所在省份"));
|
||||
}
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(schoolInfo, originalSchoolInfo, SchoolInfo::getCityId)
|
||||
&& !areaCodeService.existId(schoolInfo.getCityId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "所在城市"));
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.orange.demo.webadmin.app.service.impl;
|
||||
|
||||
import com.orange.demo.webadmin.app.service.*;
|
||||
import com.orange.demo.webadmin.app.dao.*;
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.core.util.MyModelUtil;
|
||||
import com.github.pagehelper.Page;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生行为统计数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("studentActionStatsService")
|
||||
public class StudentActionStatsServiceImpl extends BaseService<StudentActionStats, Long> implements StudentActionStatsService {
|
||||
|
||||
@Autowired
|
||||
private StudentActionStatsMapper studentActionStatsMapper;
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
@Autowired
|
||||
private AreaCodeService areaCodeService;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<StudentActionStats> mapper() {
|
||||
return studentActionStatsMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getStudentActionStatsListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<StudentActionStats> getStudentActionStatsList(StudentActionStats filter, String orderBy) {
|
||||
return studentActionStatsMapper.getStudentActionStatsList(filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentActionStatsList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<StudentActionStats> getStudentActionStatsListWithRelation(StudentActionStats filter, String orderBy) {
|
||||
List<StudentActionStats> resultList = studentActionStatsMapper.getStudentActionStatsList(filter, orderBy);
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分组过滤后的数据查询结果,以及关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param groupSelect 分组显示列表参数。位于SQL语句SELECT的后面。
|
||||
* @param groupBy 分组参数。位于SQL语句的GROUP BY后面。
|
||||
* @param orderBy 排序字符串,ORDER BY从句的参数。
|
||||
* @return 分组过滤结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<StudentActionStats> getGroupedStudentActionStatsListWithRelation(
|
||||
StudentActionStats filter, String groupSelect, String groupBy, String orderBy) {
|
||||
List<StudentActionStats> resultList =
|
||||
studentActionStatsMapper.getGroupedStudentActionStatsList(filter, groupSelect, groupBy, orderBy);
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
||||
// NOTE: 这里只是包含了关联数据,聚合计算数据没有包含。
|
||||
// 主要原因是,由于聚合字段通常被视为普通字段使用,不会在group by的从句中出现,语义上也不会在此关联。
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.orange.demo.webadmin.app.service.impl;
|
||||
|
||||
import com.orange.demo.webadmin.app.service.*;
|
||||
import com.orange.demo.webadmin.app.dao.*;
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.github.pagehelper.Page;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生行为流水数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("studentActionTransService")
|
||||
public class StudentActionTransServiceImpl extends BaseService<StudentActionTrans, Long> implements StudentActionTransService {
|
||||
|
||||
@Autowired
|
||||
private StudentActionTransMapper studentActionTransMapper;
|
||||
@Autowired
|
||||
private SchoolInfoService schoolInfoService;
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<StudentActionTrans> mapper() {
|
||||
return studentActionTransMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param studentActionTrans 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public StudentActionTrans saveNew(StudentActionTrans studentActionTrans) {
|
||||
studentActionTrans.setTransId(idGenerator.nextLongId());
|
||||
studentActionTransMapper.insert(studentActionTrans);
|
||||
return studentActionTrans;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param studentActionTrans 更新的对象。
|
||||
* @param originalStudentActionTrans 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(StudentActionTrans studentActionTrans, StudentActionTrans originalStudentActionTrans) {
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
return studentActionTransMapper.updateByPrimaryKey(studentActionTrans) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param transId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long transId) {
|
||||
// 这里先删除主数据
|
||||
return this.removeById(transId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getStudentActionTransListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<StudentActionTrans> getStudentActionTransList(StudentActionTrans filter, String orderBy) {
|
||||
return studentActionTransMapper.getStudentActionTransList(filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentActionTransList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<StudentActionTrans> getStudentActionTransListWithRelation(StudentActionTrans filter, String orderBy) {
|
||||
List<StudentActionTrans> resultList = studentActionTransMapper.getStudentActionTransList(filter, orderBy);
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param studentActionTrans 最新数据对象。
|
||||
* @param originalStudentActionTrans 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
@Override
|
||||
public CallResult verifyRelatedData(StudentActionTrans studentActionTrans, StudentActionTrans originalStudentActionTrans) {
|
||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(studentActionTrans, originalStudentActionTrans, StudentActionTrans::getSchoolId)
|
||||
&& !schoolInfoService.existId(studentActionTrans.getSchoolId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "学生校区"));
|
||||
}
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(studentActionTrans, originalStudentActionTrans, StudentActionTrans::getGradeId)
|
||||
&& !gradeService.existId(studentActionTrans.getGradeId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "学生年级"));
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
package com.orange.demo.webadmin.app.service.impl;
|
||||
|
||||
import com.orange.demo.webadmin.app.service.*;
|
||||
import com.orange.demo.webadmin.app.dao.*;
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
|
||||
import com.orange.demo.common.core.object.TokenData;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.core.util.MyModelUtil;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.github.pagehelper.Page;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 班级数据数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("studentClassService")
|
||||
public class StudentClassServiceImpl extends BaseService<StudentClass, Long> implements StudentClassService {
|
||||
|
||||
@Autowired
|
||||
private StudentClassMapper studentClassMapper;
|
||||
@Autowired
|
||||
private ClassCourseMapper classCourseMapper;
|
||||
@Autowired
|
||||
private ClassStudentMapper classStudentMapper;
|
||||
@Autowired
|
||||
private SchoolInfoService schoolInfoService;
|
||||
@Autowired
|
||||
private StudentService studentService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<StudentClass> mapper() {
|
||||
return studentClassMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param studentClass 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public StudentClass saveNew(StudentClass studentClass) {
|
||||
studentClass.setClassId(idGenerator.nextLongId());
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
studentClass.setCreateUserId(tokenData.getUserId());
|
||||
studentClass.setCreateTime(new Date());
|
||||
studentClass.setStatus(GlobalDeletedFlag.NORMAL);
|
||||
MyModelUtil.setDefaultValue(studentClass, "finishClassHour", 0);
|
||||
studentClassMapper.insert(studentClass);
|
||||
return studentClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param studentClass 更新的对象。
|
||||
* @param originalStudentClass 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(StudentClass studentClass, StudentClass originalStudentClass) {
|
||||
studentClass.setCreateUserId(originalStudentClass.getCreateUserId());
|
||||
studentClass.setCreateTime(originalStudentClass.getCreateTime());
|
||||
studentClass.setStatus(GlobalDeletedFlag.NORMAL);
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
return studentClassMapper.updateByPrimaryKey(studentClass) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param classId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long classId) {
|
||||
// 这里先删除主数据
|
||||
if (!this.removeById(classId)) {
|
||||
return false;
|
||||
}
|
||||
// 开始删除多对多子表的关联
|
||||
ClassCourse classCourse = new ClassCourse();
|
||||
classCourse.setClassId(classId);
|
||||
classCourseMapper.delete(classCourse);
|
||||
ClassStudent classStudent = new ClassStudent();
|
||||
classStudent.setClassId(classId);
|
||||
classStudentMapper.delete(classStudent);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getStudentClassListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<StudentClass> getStudentClassList(StudentClass filter, String orderBy) {
|
||||
return studentClassMapper.getStudentClassList(filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentClassList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<StudentClass> getStudentClassListWithRelation(StudentClass filter, String orderBy) {
|
||||
List<StudentClass> resultList = studentClassMapper.getStudentClassList(filter, orderBy);
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加多对多关联关系。
|
||||
*
|
||||
* @param classCourseList 多对多关联表对象集合。
|
||||
* @param classId 主表Id。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void addClassCourseList(List<ClassCourse> classCourseList, Long classId) {
|
||||
for (ClassCourse classCourse : classCourseList) {
|
||||
classCourse.setClassId(classId);
|
||||
MyModelUtil.setDefaultValue(classCourse, "courseOrder", 0);
|
||||
}
|
||||
classCourseMapper.insertList(classCourseList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新中间表数据。
|
||||
*
|
||||
* @param classCourse 中间表对象。
|
||||
* @return 更新成功与否。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean updateClassCourse(ClassCourse classCourse) {
|
||||
Example e = new Example(ClassCourse.class);
|
||||
e.createCriteria()
|
||||
.andEqualTo("classId", classCourse.getClassId())
|
||||
.andEqualTo("courseId", classCourse.getCourseId());
|
||||
return classCourseMapper.updateByExample(classCourse, e) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取中间表数据。
|
||||
*
|
||||
* @param classId 主表Id。
|
||||
* @param courseId 从表Id。
|
||||
* @return 中间表对象。
|
||||
*/
|
||||
@Override
|
||||
public ClassCourse getClassCourse(Long classId, Long courseId) {
|
||||
Example e = new Example(ClassCourse.class);
|
||||
e.createCriteria()
|
||||
.andEqualTo("classId", classId)
|
||||
.andEqualTo("courseId", courseId);
|
||||
return classCourseMapper.selectOneByExample(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除单条多对多关系。
|
||||
*
|
||||
* @param classId 主表Id。
|
||||
* @param courseId 从表Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean removeClassCourse(Long classId, Long courseId) {
|
||||
ClassCourse filter = new ClassCourse();
|
||||
filter.setClassId(classId);
|
||||
filter.setCourseId(courseId);
|
||||
return classCourseMapper.delete(filter) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加多对多关联关系。
|
||||
*
|
||||
* @param classStudentList 多对多关联表对象集合。
|
||||
* @param classId 主表Id。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void addClassStudentList(List<ClassStudent> classStudentList, Long classId) {
|
||||
for (ClassStudent classStudent : classStudentList) {
|
||||
classStudent.setClassId(classId);
|
||||
}
|
||||
classStudentMapper.insertList(classStudentList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除单条多对多关系。
|
||||
*
|
||||
* @param classId 主表Id。
|
||||
* @param studentId 从表Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean removeClassStudent(Long classId, Long studentId) {
|
||||
ClassStudent filter = new ClassStudent();
|
||||
filter.setClassId(classId);
|
||||
filter.setStudentId(studentId);
|
||||
return classStudentMapper.delete(filter) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param studentClass 最新数据对象。
|
||||
* @param originalStudentClass 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
@Override
|
||||
public CallResult verifyRelatedData(StudentClass studentClass, StudentClass originalStudentClass) {
|
||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(studentClass, originalStudentClass, StudentClass::getSchoolId)
|
||||
&& !schoolInfoService.existId(studentClass.getSchoolId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "所属校区"));
|
||||
}
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(studentClass, originalStudentClass, StudentClass::getLeaderId)
|
||||
&& !studentService.existId(studentClass.getLeaderId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "学生班长"));
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
package com.orange.demo.webadmin.app.service.impl;
|
||||
|
||||
import com.orange.demo.application.common.constant.StudentStatus;
|
||||
import com.orange.demo.webadmin.app.service.*;
|
||||
import com.orange.demo.webadmin.app.dao.*;
|
||||
import com.orange.demo.webadmin.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.core.util.MyModelUtil;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.github.pagehelper.Page;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生数据数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("studentService")
|
||||
public class StudentServiceImpl extends BaseService<Student, Long> implements StudentService {
|
||||
|
||||
@Autowired
|
||||
private StudentMapper studentMapper;
|
||||
@Autowired
|
||||
private ClassStudentMapper classStudentMapper;
|
||||
@Autowired
|
||||
private AreaCodeService areaCodeService;
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
@Autowired
|
||||
private SchoolInfoService schoolInfoService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<Student> mapper() {
|
||||
return studentMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param student 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public Student saveNew(Student student) {
|
||||
student.setStudentId(idGenerator.nextLongId());
|
||||
student.setRegisterTime(new Date());
|
||||
MyModelUtil.setDefaultValue(student, "totalCoin", 0);
|
||||
MyModelUtil.setDefaultValue(student, "leftCoin", 0);
|
||||
MyModelUtil.setDefaultValue(student, "status", StudentStatus.NORMAL);
|
||||
studentMapper.insert(student);
|
||||
return student;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param student 更新的对象。
|
||||
* @param originalStudent 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(Student student, Student originalStudent) {
|
||||
student.setRegisterTime(originalStudent.getRegisterTime());
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
return studentMapper.updateByPrimaryKey(student) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param studentId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long studentId) {
|
||||
// 这里先删除主数据
|
||||
if (!this.removeById(studentId)) {
|
||||
return false;
|
||||
}
|
||||
// 开始删除多对多父表的关联
|
||||
ClassStudent classStudent = new ClassStudent();
|
||||
classStudent.setStudentId(studentId);
|
||||
classStudentMapper.delete(classStudent);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getStudentListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<Student> getStudentList(Student filter, String orderBy) {
|
||||
return studentMapper.getStudentList(filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<Student> getStudentListWithRelation(Student filter, String orderBy) {
|
||||
List<Student> resultList = studentMapper.getStudentList(filter, orderBy);
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。
|
||||
*
|
||||
* @param classId 主表主键Id。
|
||||
* @param filter 从表的过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<Student> getNotInStudentListByClassId(
|
||||
Long classId, Student filter, String orderBy) {
|
||||
List<Student> resultList =
|
||||
studentMapper.getNotInStudentListByClassId(classId, filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。
|
||||
*
|
||||
* @param classId 主表主键Id。
|
||||
* @param filter 从表的过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<Student> getStudentListByClassId(
|
||||
Long classId, Student filter, String orderBy) {
|
||||
List<Student> resultList =
|
||||
studentMapper.getStudentListByClassId(classId, filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param student 最新数据对象。
|
||||
* @param originalStudent 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
@Override
|
||||
public CallResult verifyRelatedData(Student student, Student originalStudent) {
|
||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(student, originalStudent, Student::getProvinceId)
|
||||
&& !areaCodeService.existId(student.getProvinceId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "所在省份"));
|
||||
}
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(student, originalStudent, Student::getCityId)
|
||||
&& !areaCodeService.existId(student.getCityId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "所在城市"));
|
||||
}
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(student, originalStudent, Student::getDistrictId)
|
||||
&& !areaCodeService.existId(student.getDistrictId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "所在区县"));
|
||||
}
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(student, originalStudent, Student::getGradeId)
|
||||
&& !gradeService.existId(student.getGradeId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "年级"));
|
||||
}
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(student, originalStudent, Student::getSchoolId)
|
||||
&& !schoolInfoService.existId(student.getSchoolId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "所属校区"));
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.orange.demo.webadmin.app.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 行政区划DomainVO对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class AreaCodeVo {
|
||||
|
||||
/**
|
||||
* 行政区划主键Id
|
||||
*/
|
||||
private Long areaId;
|
||||
|
||||
/**
|
||||
* 行政区划名称
|
||||
*/
|
||||
private String areaName;
|
||||
|
||||
/**
|
||||
* 行政区划级别 (1: 省级别 2: 市级别 3: 区级别)
|
||||
*/
|
||||
private Integer areaLevel;
|
||||
|
||||
/**
|
||||
* 父级行政区划Id
|
||||
*/
|
||||
private Long parentId;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.orange.demo.webadmin.app.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* ClassCourseVO对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class ClassCourseVo {
|
||||
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
private Long classId;
|
||||
|
||||
/**
|
||||
* 课程Id。
|
||||
*/
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 课程顺序(数值越小越靠前)。
|
||||
*/
|
||||
private Integer courseOrder;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.orange.demo.webadmin.app.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* ClassStudentVO对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class ClassStudentVo {
|
||||
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
private Long classId;
|
||||
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
private Long studentId;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.orange.demo.webadmin.app.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* CourseTransStatsVO对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class CourseTransStatsVo {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
private Long statsId;
|
||||
|
||||
/**
|
||||
* 统计日期。
|
||||
*/
|
||||
private Date statsDate;
|
||||
|
||||
/**
|
||||
* 科目Id。
|
||||
*/
|
||||
private Integer subjectId;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 年级名称。
|
||||
*/
|
||||
private String gradeName;
|
||||
|
||||
/**
|
||||
* 课程Id。
|
||||
*/
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 课程名称。
|
||||
*/
|
||||
private String courseName;
|
||||
|
||||
/**
|
||||
* 学生上课次数。
|
||||
*/
|
||||
private Integer studentAttendCount;
|
||||
|
||||
/**
|
||||
* 学生献花数量。
|
||||
*/
|
||||
private Integer studentFlowerAmount;
|
||||
|
||||
/**
|
||||
* 学生献花次数。
|
||||
*/
|
||||
private Integer studentFlowerCount;
|
||||
|
||||
/**
|
||||
* gradeId 字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> gradeIdDictMap;
|
||||
|
||||
/**
|
||||
* subjectId 常量字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> subjectIdDictMap;
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.orange.demo.webadmin.app.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* CourseVO对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class CourseVo {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 课程名称。
|
||||
*/
|
||||
private String courseName;
|
||||
|
||||
/**
|
||||
* 课程价格。
|
||||
*/
|
||||
private BigDecimal price;
|
||||
|
||||
/**
|
||||
* 课程描述。
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 课程难度(0: 容易 1: 普通 2: 很难)。
|
||||
*/
|
||||
private Integer difficulty;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 学科Id。
|
||||
*/
|
||||
private Integer subjectId;
|
||||
|
||||
/**
|
||||
* 课时数量。
|
||||
*/
|
||||
private Integer classHour;
|
||||
|
||||
/**
|
||||
* 多张课程图片地址。
|
||||
*/
|
||||
private String pictureUrl;
|
||||
|
||||
/**
|
||||
* 创建用户Id。
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 最后修改时间。
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* courseId 的多对多关联表数据对象,数据对应类型为ClassCourseVo。
|
||||
*/
|
||||
private Map<String, Object> classCourse;
|
||||
|
||||
/**
|
||||
* gradeId 字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> gradeIdDictMap;
|
||||
|
||||
/**
|
||||
* difficulty 常量字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> difficultyDictMap;
|
||||
|
||||
/**
|
||||
* subjectId 常量字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> subjectIdDictMap;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.orange.demo.webadmin.app.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* GradeVO对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class GradeVo {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 年级名称。
|
||||
*/
|
||||
private String gradeName;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.orange.demo.webadmin.app.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* SchoolInfoVO对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class SchoolInfoVo {
|
||||
|
||||
/**
|
||||
* 学校Id。
|
||||
*/
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 学校名称。
|
||||
*/
|
||||
private String schoolName;
|
||||
|
||||
/**
|
||||
* 所在省Id。
|
||||
*/
|
||||
private Long provinceId;
|
||||
|
||||
/**
|
||||
* 所在城市Id。
|
||||
*/
|
||||
private Long cityId;
|
||||
|
||||
/**
|
||||
* provinceId 字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> provinceIdDictMap;
|
||||
|
||||
/**
|
||||
* cityId 字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> cityIdDictMap;
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.orange.demo.webadmin.app.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* StudentActionStatsVO对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class StudentActionStatsVo {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
private Long statsId;
|
||||
|
||||
/**
|
||||
* 统计日期。
|
||||
*/
|
||||
private Date statsDate;
|
||||
|
||||
/**
|
||||
* 统计小时。
|
||||
*/
|
||||
private Date statsMonth;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 学生所在省Id。
|
||||
*/
|
||||
private Long provinceId;
|
||||
|
||||
/**
|
||||
* 学生所在城市Id。
|
||||
*/
|
||||
private Long cityId;
|
||||
|
||||
/**
|
||||
* 购课学币数量。
|
||||
*/
|
||||
private Integer buyCourseAmount;
|
||||
|
||||
/**
|
||||
* 购买课程次数。
|
||||
*/
|
||||
private Integer buyCourseCount;
|
||||
|
||||
/**
|
||||
* 购买视频学币数量。
|
||||
*/
|
||||
private Integer buyVideoAmount;
|
||||
|
||||
/**
|
||||
* 购买视频次数。
|
||||
*/
|
||||
private Integer buyVideoCount;
|
||||
|
||||
/**
|
||||
* 购买作业学币数量。
|
||||
*/
|
||||
private Integer buyPaperAmount;
|
||||
|
||||
/**
|
||||
* 购买作业次数。
|
||||
*/
|
||||
private Integer buyPaperCount;
|
||||
|
||||
/**
|
||||
* 购买献花数量。
|
||||
*/
|
||||
private Integer buyFlowerAmount;
|
||||
|
||||
/**
|
||||
* 购买献花次数。
|
||||
*/
|
||||
private Integer buyFlowerCount;
|
||||
|
||||
/**
|
||||
* 充值学币数量。
|
||||
*/
|
||||
private Integer rechargeCoinAmount;
|
||||
|
||||
/**
|
||||
* 充值学币次数。
|
||||
*/
|
||||
private Integer rechargeCoinCount;
|
||||
|
||||
/**
|
||||
* 线下课程上课次数。
|
||||
*/
|
||||
private Integer doCourseCount;
|
||||
|
||||
/**
|
||||
* 观看视频次数。
|
||||
*/
|
||||
private Integer watchVideoCount;
|
||||
|
||||
/**
|
||||
* 购买献花消费学币数量。
|
||||
*/
|
||||
private Integer watchVideoTotalSecond;
|
||||
|
||||
/**
|
||||
* 做题数量。
|
||||
*/
|
||||
private Integer doExerciseCount;
|
||||
|
||||
/**
|
||||
* 做题正确的数量。
|
||||
*/
|
||||
private Integer doExerciseCorrectCount;
|
||||
|
||||
/**
|
||||
* gradeId 字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> gradeIdDictMap;
|
||||
|
||||
/**
|
||||
* provinceId 字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> provinceIdDictMap;
|
||||
|
||||
/**
|
||||
* cityId 字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> cityIdDictMap;
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.orange.demo.webadmin.app.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* StudentActionTransVO对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class StudentActionTransVo {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
private Long transId;
|
||||
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
private Long studentId;
|
||||
|
||||
/**
|
||||
* 学生名称。
|
||||
*/
|
||||
private String studentName;
|
||||
|
||||
/**
|
||||
* 学生校区。
|
||||
*/
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 行为类型(0: 充值 1: 购课 2: 上课签到 3: 上课签退 4: 看视频课 5: 做作业 6: 刷题 7: 献花)。
|
||||
*/
|
||||
private Integer actionType;
|
||||
|
||||
/**
|
||||
* 设备类型(0: iOS 1: Android 2: PC)。
|
||||
*/
|
||||
private Integer deviceType;
|
||||
|
||||
/**
|
||||
* 看视频秒数。
|
||||
*/
|
||||
private Integer watchVideoSeconds;
|
||||
|
||||
/**
|
||||
* 购买献花数量。
|
||||
*/
|
||||
private Integer flowerCount;
|
||||
|
||||
/**
|
||||
* 购买作业数量。
|
||||
*/
|
||||
private Integer paperCount;
|
||||
|
||||
/**
|
||||
* 购买视频数量。
|
||||
*/
|
||||
private Integer videoCount;
|
||||
|
||||
/**
|
||||
* 购买课程数量。
|
||||
*/
|
||||
private Integer courseCount;
|
||||
|
||||
/**
|
||||
* 充值学币数量。
|
||||
*/
|
||||
private Integer coinCount;
|
||||
|
||||
/**
|
||||
* 做题是否正确标记。
|
||||
*/
|
||||
private Integer exerciseCorrectFlag;
|
||||
|
||||
/**
|
||||
* 发生时间。
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* schoolId 字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> schoolIdDictMap;
|
||||
|
||||
/**
|
||||
* gradeId 字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> gradeIdDictMap;
|
||||
|
||||
/**
|
||||
* actionType 常量字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> actionTypeDictMap;
|
||||
|
||||
/**
|
||||
* deviceType 常量字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> deviceTypeDictMap;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.orange.demo.webadmin.app.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* StudentClassVO对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class StudentClassVo {
|
||||
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
private Long classId;
|
||||
|
||||
/**
|
||||
* 班级名称。
|
||||
*/
|
||||
private String className;
|
||||
|
||||
/**
|
||||
* 学校Id。
|
||||
*/
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 学生班长Id。
|
||||
*/
|
||||
private Long leaderId;
|
||||
|
||||
/**
|
||||
* 已完成课时数量。
|
||||
*/
|
||||
private Integer finishClassHour;
|
||||
|
||||
/**
|
||||
* 班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)。
|
||||
*/
|
||||
private Integer classLevel;
|
||||
|
||||
/**
|
||||
* 创建用户。
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 班级创建时间。
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* schoolId 字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> schoolIdDictMap;
|
||||
|
||||
/**
|
||||
* leaderId 字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> leaderIdDictMap;
|
||||
|
||||
/**
|
||||
* classLevel 常量字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> classLevelDictMap;
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.orange.demo.webadmin.app.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* StudentVO对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
public class StudentVo {
|
||||
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
private Long studentId;
|
||||
|
||||
/**
|
||||
* 登录手机。
|
||||
*/
|
||||
private String loginMobile;
|
||||
|
||||
/**
|
||||
* 学生姓名。
|
||||
*/
|
||||
private String studentName;
|
||||
|
||||
/**
|
||||
* 所在省份Id。
|
||||
*/
|
||||
private Long provinceId;
|
||||
|
||||
/**
|
||||
* 所在城市Id。
|
||||
*/
|
||||
private Long cityId;
|
||||
|
||||
/**
|
||||
* 区县Id。
|
||||
*/
|
||||
private Long districtId;
|
||||
|
||||
/**
|
||||
* 学生性别 (0: 女生 1: 男生)。
|
||||
*/
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 生日。
|
||||
*/
|
||||
private Date birthday;
|
||||
|
||||
/**
|
||||
* 经验等级 (0: 初级 1: 中级 2: 高级 3: 资深)。
|
||||
*/
|
||||
private Integer experienceLevel;
|
||||
|
||||
/**
|
||||
* 总共充值学币数量。
|
||||
*/
|
||||
private Integer totalCoin;
|
||||
|
||||
/**
|
||||
* 可用学币数量。
|
||||
*/
|
||||
private Integer leftCoin;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 校区Id。
|
||||
*/
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 注册时间。
|
||||
*/
|
||||
private Date registerTime;
|
||||
|
||||
/**
|
||||
* 学生状态 (0: 正常 1: 锁定 2: 注销)。
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* provinceId 字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> provinceIdDictMap;
|
||||
|
||||
/**
|
||||
* cityId 字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> cityIdDictMap;
|
||||
|
||||
/**
|
||||
* districtId 字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> districtIdDictMap;
|
||||
|
||||
/**
|
||||
* gradeId 字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> gradeIdDictMap;
|
||||
|
||||
/**
|
||||
* schoolId 字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> schoolIdDictMap;
|
||||
|
||||
/**
|
||||
* gender 常量字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> genderDictMap;
|
||||
|
||||
/**
|
||||
* experienceLevel 常量字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> experienceLevelDictMap;
|
||||
|
||||
/**
|
||||
* status 常量字典关联数据。
|
||||
*/
|
||||
private Map<String, Object> statusDictMap;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.orange.demo.webadmin.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 应用程序自定义的程序属性配置文件。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "application")
|
||||
public class ApplicationConfig {
|
||||
|
||||
/**
|
||||
* token的Http Request Header的key
|
||||
*/
|
||||
private String tokenHeaderKey;
|
||||
/**
|
||||
* token在过期之前,但是已经需要被刷新时,response返回的header信息的key。
|
||||
*/
|
||||
private String refreshedTokenHeaderKey;
|
||||
/**
|
||||
* token 加密用的密钥,该值的长度最少10个字符(过短会报错)。
|
||||
*/
|
||||
private String tokenSigningKey;
|
||||
/**
|
||||
* 令牌的过期时间,单位毫秒
|
||||
*/
|
||||
private Long expiration;
|
||||
/**
|
||||
* 用户密码被重置之后的缺省密码
|
||||
*/
|
||||
private String defaultUserPassword;
|
||||
/**
|
||||
* 上传文件的基础目录
|
||||
*/
|
||||
private String uploadFileBaseDir;
|
||||
/**
|
||||
* 授信ip列表,没有填写表示全部信任。多个ip之间逗号分隔,如: http://10.10.10.1:8080,http://10.10.10.2:8080
|
||||
*/
|
||||
private String credentialIpList;
|
||||
/**
|
||||
* Session的用户权限在Redis中的过期时间(秒)。
|
||||
* 缺省值是 one day
|
||||
*/
|
||||
private int permRedisExpiredSeconds = 86400;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.orange.demo.webadmin.config;
|
||||
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import tk.mybatis.spring.annotation.MapperScan;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* 数据源配置Bean对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Configuration
|
||||
@EnableTransactionManagement
|
||||
@MapperScan(value = {"com.orange.demo.webadmin.*.dao", "com.orange.demo.common.*.dao"})
|
||||
public class DataSourceConfig {
|
||||
|
||||
@Bean(initMethod = "init", destroyMethod = "close")
|
||||
@Primary
|
||||
@ConfigurationProperties(prefix = "spring.datasource.druid")
|
||||
public DataSource druidDataSource() {
|
||||
return DruidDataSourceBuilder.create().build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.orange.demo.webadmin.config;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* 这里主要配置Web的各种过滤器和监听器等Servlet容器组件。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Configuration
|
||||
public class FilterConfig {
|
||||
|
||||
/**
|
||||
* 配置Ajax跨域过滤器。
|
||||
*/
|
||||
@Bean
|
||||
public CorsFilter corsFilterRegistration(ApplicationConfig applicationConfig) {
|
||||
UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource();
|
||||
CorsConfiguration corsConfiguration = new CorsConfiguration();
|
||||
if (StringUtils.isNotBlank(applicationConfig.getCredentialIpList())) {
|
||||
String[] credentialIpList = StringUtils.split(applicationConfig.getCredentialIpList(), ",");
|
||||
if (credentialIpList.length > 0) {
|
||||
for (String ip : credentialIpList) {
|
||||
corsConfiguration.addAllowedOrigin(ip);
|
||||
}
|
||||
}
|
||||
corsConfiguration.addAllowedHeader("*");
|
||||
corsConfiguration.addAllowedMethod("*");
|
||||
corsConfiguration.addExposedHeader(applicationConfig.getRefreshedTokenHeaderKey());
|
||||
corsConfiguration.setAllowCredentials(true);
|
||||
configSource.registerCorsConfiguration("/**", corsConfiguration);
|
||||
}
|
||||
return new CorsFilter(configSource);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean<Filter> characterEncodingFilterRegistration() {
|
||||
FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>(
|
||||
new org.springframework.web.filter.CharacterEncodingFilter());
|
||||
filterRegistrationBean.addUrlPatterns("/*");
|
||||
filterRegistrationBean.addInitParameter("encoding", StandardCharsets.UTF_8.name());
|
||||
// forceEncoding强制response也被编码,另外即使request中已经设置encoding,forceEncoding也会重新设置
|
||||
filterRegistrationBean.addInitParameter("forceEncoding", "true");
|
||||
filterRegistrationBean.setAsyncSupported(true);
|
||||
return filterRegistrationBean;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.orange.demo.webadmin.config;
|
||||
|
||||
import com.orange.demo.webadmin.interceptor.AuthenticationInterceptor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* 所有的项目拦截器都在这里集中配置
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Configuration
|
||||
public class InterceptorConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new AuthenticationInterceptor()).addPathPatterns("/admin/**");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.orange.demo.webadmin.interceptor;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.orange.demo.webadmin.config.ApplicationConfig;
|
||||
import com.orange.demo.webadmin.upms.model.SysPermWhitelist;
|
||||
import com.orange.demo.webadmin.upms.service.SysPermWhitelistService;
|
||||
import com.orange.demo.webadmin.upms.service.SysPermService;
|
||||
import com.orange.demo.common.core.annotation.NoAuthInterface;
|
||||
import com.orange.demo.common.core.constant.ErrorCodeEnum;
|
||||
import com.orange.demo.common.core.object.ResponseResult;
|
||||
import com.orange.demo.common.core.object.TokenData;
|
||||
import com.orange.demo.common.core.util.ApplicationContextHolder;
|
||||
import com.orange.demo.common.core.util.JwtUtil;
|
||||
import com.orange.demo.common.core.util.RedisKeyUtil;
|
||||
import com.orange.demo.common.redis.cache.SessionCacheHelper;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 登录用户Token验证、生成和权限验证的拦截器。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Slf4j
|
||||
public class AuthenticationInterceptor implements HandlerInterceptor {
|
||||
|
||||
private final ApplicationConfig appConfig =
|
||||
ApplicationContextHolder.getBean("applicationConfig");
|
||||
|
||||
private final JedisPool jedisPool = ApplicationContextHolder.getBean(JedisPool.class);
|
||||
|
||||
private final SessionCacheHelper cacheHelper =
|
||||
ApplicationContextHolder.getBean("sessionCacheHelper");
|
||||
|
||||
private final SysPermService sysPermService =
|
||||
ApplicationContextHolder.getBean(SysPermService.class);
|
||||
|
||||
private static SysPermWhitelistService sysPermWhitelistService =
|
||||
ApplicationContextHolder.getBean(SysPermWhitelistService.class);
|
||||
|
||||
private static Set<String> whitelistPermSet;
|
||||
|
||||
static {
|
||||
List<SysPermWhitelist> sysPermWhitelistList = sysPermWhitelistService.getAllList();
|
||||
whitelistPermSet = sysPermWhitelistList.stream()
|
||||
.map(SysPermWhitelist::getPermUrl).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
String url = request.getRequestURI();
|
||||
// 如果接口方法标记NoAuthInterface注解,可以直接跳过Token鉴权验证,这里主要为了测试接口方便
|
||||
if (handler instanceof HandlerMethod) {
|
||||
HandlerMethod hm = (HandlerMethod) handler;
|
||||
if (hm.getBeanType().getAnnotation(NoAuthInterface.class) != null
|
||||
|| hm.getMethodAnnotation(NoAuthInterface.class) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
String token = request.getHeader(appConfig.getTokenHeaderKey());
|
||||
if (StringUtils.isBlank(token)) {
|
||||
token = request.getParameter(appConfig.getTokenHeaderKey());
|
||||
}
|
||||
Claims c = JwtUtil.parseToken(token, appConfig.getTokenSigningKey());
|
||||
if (JwtUtil.isNullOrExpired(c)) {
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
this.outputResponseMessage(response,
|
||||
ResponseResult.error(ErrorCodeEnum.UNAUTHORIZED_LOGIN, "用户会话已过期或尚未登录,请重新登录!"));
|
||||
return false;
|
||||
}
|
||||
String sessionId = (String) c.get("sessionId");
|
||||
TokenData tokenData = cacheHelper.getTokenData(sessionId);
|
||||
if (tokenData == null) {
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
this.outputResponseMessage(response,
|
||||
ResponseResult.error(ErrorCodeEnum.UNAUTHORIZED_LOGIN, "用户会话已失效,请重新登录!"));
|
||||
return false;
|
||||
}
|
||||
TokenData.addToRequest(tokenData);
|
||||
// 如果url在权限资源白名单中,则不需要进行鉴权操作
|
||||
if (Boolean.FALSE.equals(tokenData.getIsAdmin()) && !whitelistPermSet.contains(url)) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
if (!jedis.sismember(RedisKeyUtil.makeSessionPermIdKeyForRedis(tokenData.getSessionId()), url)) {
|
||||
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
|
||||
this.outputResponseMessage(response,
|
||||
ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (JwtUtil.needToRefresh(c)) {
|
||||
String refreshedToken = JwtUtil.generateToken(c, appConfig.getExpiration(), appConfig.getTokenSigningKey());
|
||||
response.addHeader(appConfig.getRefreshedTokenHeaderKey(), refreshedToken);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
|
||||
ModelAndView modelAndView) throws Exception {
|
||||
// 这里需要空注解,否则sonar会不happy。
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
|
||||
throws Exception {
|
||||
// 这里需要空注解,否则sonar会不happy。
|
||||
}
|
||||
|
||||
private void outputResponseMessage(HttpServletResponse response, ResponseResult<Object> respObj) {
|
||||
PrintWriter out;
|
||||
try {
|
||||
out = response.getWriter();
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to call OutputResponseMessage.", e);
|
||||
return;
|
||||
}
|
||||
response.setContentType("application/json; charset=utf-8");
|
||||
out.print(JSON.toJSONString(respObj));
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.orange.demo.webadmin.upms.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.orange.demo.webadmin.config.ApplicationConfig;
|
||||
import com.orange.demo.webadmin.upms.service.*;
|
||||
import com.orange.demo.webadmin.upms.model.SysMenu;
|
||||
import com.orange.demo.webadmin.upms.model.SysUser;
|
||||
import com.orange.demo.webadmin.upms.model.constant.SysUserStatus;
|
||||
import com.orange.demo.webadmin.upms.model.constant.SysUserType;
|
||||
import com.orange.demo.common.core.annotation.NoAuthInterface;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import com.orange.demo.common.core.constant.ApplicationConstant;
|
||||
import com.orange.demo.common.core.constant.ErrorCodeEnum;
|
||||
import com.orange.demo.common.core.object.ResponseResult;
|
||||
import com.orange.demo.common.core.object.TokenData;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.redis.cache.SessionCacheHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 登录接口控制器类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/upms/login")
|
||||
public class LoginController {
|
||||
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
@Autowired
|
||||
private SysMenuService sysMenuService;
|
||||
@Autowired
|
||||
private SysPermCodeService sysPermCodeService;
|
||||
@Autowired
|
||||
private SysPermService sysPermService;
|
||||
@Autowired
|
||||
private ApplicationConfig appConfig;
|
||||
@Autowired
|
||||
private SessionCacheHelper cacheHelper;
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
/**
|
||||
* 登录接口。
|
||||
*
|
||||
* @param loginName 登录名。
|
||||
* @param password 密码。
|
||||
* @return 应答结果对象,其中包括JWT的Token数据,以及菜单列表。
|
||||
*/
|
||||
@NoAuthInterface
|
||||
@PostMapping("/doLogin")
|
||||
public ResponseResult<JSONObject> doLogin(
|
||||
@MyRequestBody String loginName, @MyRequestBody String password) throws Exception {
|
||||
if (MyCommonUtil.existBlankArgument(loginName, password)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
SysUser user = sysUserService.getSysUserByLoginName(loginName);
|
||||
password = URLDecoder.decode(password, StandardCharsets.UTF_8.name());
|
||||
// NOTE: 第一次使用时,请务必阅读ApplicationConstant.PRIVATE_KEY的代码注释。
|
||||
// 执行RsaUtil工具类中的main函数,可以生成新的公钥和私钥。
|
||||
password = RsaUtil.decrypt(password, ApplicationConstant.PRIVATE_KEY);
|
||||
if (user == null || !passwordEncoder.matches(password, user.getPassword())) {
|
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_USERNAME_PASSWORD);
|
||||
}
|
||||
String errorMessage;
|
||||
if (user.getUserStatus() == SysUserStatus.STATUS_LOCKED) {
|
||||
errorMessage = "登录失败,用户账号被锁定!";
|
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_USER_STATUS, errorMessage);
|
||||
}
|
||||
boolean isAdmin = user.getUserType() == SysUserType.TYPE_ADMIN;
|
||||
Map<String, Object> claims = new HashMap<>(3);
|
||||
String sessionId = MyCommonUtil.generateUuid();
|
||||
claims.put("sessionId", sessionId);
|
||||
String token = JwtUtil.generateToken(claims, appConfig.getExpiration(), appConfig.getTokenSigningKey());
|
||||
JSONObject jsonData = new JSONObject();
|
||||
jsonData.put(TokenData.REQUEST_ATTRIBUTE_NAME, token);
|
||||
jsonData.put("showName", user.getShowName());
|
||||
jsonData.put("isAdmin", isAdmin);
|
||||
TokenData tokenData = new TokenData();
|
||||
tokenData.setSessionId(sessionId);
|
||||
tokenData.setUserId(user.getUserId());
|
||||
tokenData.setShowName(user.getShowName());
|
||||
tokenData.setIsAdmin(isAdmin);
|
||||
cacheHelper.putTokenData(sessionId, tokenData);
|
||||
// 这里手动将TokenData存入request,便于OperationLogAspect统一处理操作日志。
|
||||
TokenData.addToRequest(tokenData);
|
||||
Collection<SysMenu> menuList;
|
||||
Collection<String> permCodeList;
|
||||
if (isAdmin) {
|
||||
menuList = sysMenuService.getAllMenuList();
|
||||
permCodeList = sysPermCodeService.getAllPermCodeList();
|
||||
} else {
|
||||
menuList = sysMenuService.getMenuListByUserId(user.getUserId());
|
||||
permCodeList = sysPermCodeService.getPermCodeListByUserId(user.getUserId());
|
||||
}
|
||||
jsonData.put("menuList", menuList);
|
||||
jsonData.put("permCodeList", permCodeList);
|
||||
if (user.getUserType() != SysUserType.TYPE_ADMIN) {
|
||||
// 缓存用户的权限资源
|
||||
sysPermService.putUserSysPermCache(sessionId, user.getUserId());
|
||||
}
|
||||
return ResponseResult.success(jsonData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登出操作。同时将Session相关的信息从缓存中删除。
|
||||
*
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/doLogout")
|
||||
public ResponseResult<Void> doLogout() {
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
sysPermService.removeUserSysPermCache(tokenData.getSessionId());
|
||||
cacheHelper.removeAllSessionCache(tokenData.getSessionId());
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 在登录之后,通过token再次获取登录信息。
|
||||
* 用于在当前浏览器登录系统后,在新tab页中可以免密登录。
|
||||
*
|
||||
* @return 应答结果对象,其中包括JWT的Token数据,以及菜单列表。
|
||||
*/
|
||||
@GetMapping("/getLoginInfo")
|
||||
public ResponseResult<JSONObject> getLoginInfo() {
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
// 这里解释一下为什么没有缓存menuList和permCodeList。
|
||||
// 1. 该操作和权限验证不同,属于低频操作。
|
||||
// 2. 第一次登录和再次获取登录信息之间,如果修改了用户的权限,那么本次获取的是最新权限。
|
||||
// 3. 上一个问题无法避免,因为即便缓存也是有过期时间的,过期之后还是要从数据库获取的。
|
||||
JSONObject jsonData = new JSONObject();
|
||||
jsonData.put("showName", tokenData.getShowName());
|
||||
jsonData.put("isAdmin", tokenData.getIsAdmin());
|
||||
Collection<SysMenu> menuList;
|
||||
Collection<String> permCodeList;
|
||||
if (tokenData.getIsAdmin()) {
|
||||
menuList = sysMenuService.getAllMenuList();
|
||||
permCodeList = sysPermCodeService.getAllPermCodeList();
|
||||
} else {
|
||||
menuList = sysMenuService.getMenuListByUserId(tokenData.getUserId());
|
||||
permCodeList = sysPermCodeService.getPermCodeListByUserId(tokenData.getUserId());
|
||||
}
|
||||
jsonData.put("menuList", menuList);
|
||||
jsonData.put("permCodeList", permCodeList);
|
||||
return ResponseResult.success(jsonData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户修改自己的密码。
|
||||
*
|
||||
* @param oldPass 原有密码。
|
||||
* @param newPass 新密码。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/changePassword")
|
||||
public ResponseResult<Void> changePassword(
|
||||
@MyRequestBody String oldPass, @MyRequestBody String newPass) throws Exception {
|
||||
if (MyCommonUtil.existBlankArgument(oldPass, oldPass)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
SysUser user = sysUserService.getById(tokenData.getUserId());
|
||||
oldPass = URLDecoder.decode(oldPass, StandardCharsets.UTF_8.name());
|
||||
// NOTE: 第一次使用时,请务必阅读ApplicationConstant.PRIVATE_KEY的代码注释。
|
||||
// 执行RsaUtil工具类中的main函数,可以生成新的公钥和私钥。
|
||||
oldPass = RsaUtil.decrypt(oldPass, ApplicationConstant.PRIVATE_KEY);
|
||||
if (user == null || !passwordEncoder.matches(oldPass, user.getPassword())) {
|
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_USERNAME_PASSWORD);
|
||||
}
|
||||
newPass = URLDecoder.decode(newPass, StandardCharsets.UTF_8.name());
|
||||
newPass = RsaUtil.decrypt(newPass, ApplicationConstant.PRIVATE_KEY);
|
||||
if (!sysUserService.changePassword(tokenData.getUserId(), newPass)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
package com.orange.demo.webadmin.upms.controller;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.orange.demo.webadmin.upms.dto.SysMenuDto;
|
||||
import com.orange.demo.webadmin.upms.vo.SysMenuVo;
|
||||
import com.orange.demo.webadmin.upms.model.SysMenu;
|
||||
import com.orange.demo.webadmin.upms.service.SysMenuService;
|
||||
import com.orange.demo.common.core.constant.ErrorCodeEnum;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.groups.Default;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 菜单管理接口控制器类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/upms/sysMenu")
|
||||
public class SysMenuController {
|
||||
|
||||
@Autowired
|
||||
private SysMenuService sysMenuService;
|
||||
|
||||
/**
|
||||
* 添加新菜单操作。
|
||||
*
|
||||
* @param sysMenuDto 新菜单对象。
|
||||
* @param permCodeIdListString 与当前菜单Id绑定的权限Id列表,多个权限之间逗号分隔。
|
||||
* @return 应答结果对象,包含新增菜单的主键Id。
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(
|
||||
@MyRequestBody("sysMenu") SysMenuDto sysMenuDto, @MyRequestBody String permCodeIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysMenuDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysMenu sysMenu = MyModelUtil.copyTo(sysMenuDto, SysMenu.class);
|
||||
CallResult result = sysMenuService.verifyRelatedData(sysMenu, null, permCodeIdListString);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
}
|
||||
Set<Long> permCodeIdSet = null;
|
||||
if (result.getData() != null) {
|
||||
permCodeIdSet = (Set<Long>) result.getData().get("permCodeIdSet");
|
||||
}
|
||||
sysMenuService.saveNew(sysMenu, permCodeIdSet);
|
||||
return ResponseResult.success(sysMenu.getMenuId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新菜单数据操作。
|
||||
*
|
||||
* @param sysMenuDto 更新菜单对象。
|
||||
* @param permCodeIdListString 与当前菜单Id绑定的权限Id列表,多个权限之间逗号分隔。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(
|
||||
@MyRequestBody("sysMenu") SysMenuDto sysMenuDto, @MyRequestBody String permCodeIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysMenuDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysMenu originalSysMenu = sysMenuService.getById(sysMenuDto.getMenuId());
|
||||
if (originalSysMenu == null) {
|
||||
errorMessage = "数据验证失败,当前菜单并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
SysMenu sysMenu = MyModelUtil.copyTo(sysMenuDto, SysMenu.class);
|
||||
CallResult result = sysMenuService.verifyRelatedData(sysMenu, originalSysMenu, permCodeIdListString);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
}
|
||||
Set<Long> permCodeIdSet = null;
|
||||
if (result.getData() != null) {
|
||||
permCodeIdSet = (Set<Long>) result.getData().get("permCodeIdSet");
|
||||
}
|
||||
if (!sysMenuService.update(sysMenu, originalSysMenu, permCodeIdSet)) {
|
||||
errorMessage = "数据验证失败,当前权限字并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定菜单操作。
|
||||
*
|
||||
* @param menuId 指定菜单主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long menuId) {
|
||||
if (MyCommonUtil.existBlankArgument(menuId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
String errorMessage;
|
||||
if (sysMenuService.hasChildren(menuId)) {
|
||||
errorMessage = "数据验证失败,当前菜单存在下级菜单!";
|
||||
return ResponseResult.error(ErrorCodeEnum.HAS_CHILDREN_DATA, errorMessage);
|
||||
}
|
||||
if (!sysMenuService.remove(menuId)) {
|
||||
errorMessage = "数据操作失败,菜单不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部菜单列表。
|
||||
*
|
||||
* @return 应答结果对象,包含全部菜单数据列表。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<List<SysMenuVo>> list() {
|
||||
List<SysMenu> sysMenuList = sysMenuService.getAllListByOrder("showOrder");
|
||||
return ResponseResult.success(MyModelUtil.copyCollectionTo(sysMenuList, SysMenuVo.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看指定菜单数据详情。
|
||||
*
|
||||
* @param menuId 指定菜单主键Id。
|
||||
* @return 应答结果对象,包含菜单详情。
|
||||
*/
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<SysMenuVo> view(@RequestParam Long menuId) {
|
||||
if (MyCommonUtil.existBlankArgument(menuId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
SysMenu sysMenu = sysMenuService.getByIdWithRelation(menuId, MyRelationParam.full());
|
||||
if (sysMenu == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
SysMenuVo sysMenuVo = MyModelUtil.copyTo(sysMenu, SysMenuVo.class);
|
||||
return ResponseResult.success(sysMenuVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询菜单的权限资源地址列表。同时返回详细的分配路径。
|
||||
*
|
||||
* @param menuId 菜单Id。
|
||||
* @param url 权限资源地址过滤条件。
|
||||
* @return 应答对象,包含从菜单到权限资源的权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
@GetMapping("/listSysPermWithDetail")
|
||||
public ResponseResult<List<Map<String, Object>>> listSysPermWithDetail(Long menuId, String url) {
|
||||
if (MyCommonUtil.isBlankOrNull(menuId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
return ResponseResult.success(sysMenuService.getSysPermListWithDetail(menuId, url));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询菜单的用户列表。同时返回详细的分配路径。
|
||||
*
|
||||
* @param menuId 菜单Id。
|
||||
* @param loginName 登录名。
|
||||
* @return 应答对象,包含从菜单到用户的完整权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
@GetMapping("/listSysUserWithDetail")
|
||||
public ResponseResult<List<Map<String, Object>>> listSysUserWithDetail(Long menuId, String loginName) {
|
||||
if (MyCommonUtil.isBlankOrNull(menuId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
return ResponseResult.success(sysMenuService.getSysUserListWithDetail(menuId, loginName));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.orange.demo.webadmin.upms.controller;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.orange.demo.webadmin.upms.dto.SysPermCodeDto;
|
||||
import com.orange.demo.webadmin.upms.vo.SysPermCodeVo;
|
||||
import com.orange.demo.webadmin.upms.model.SysPermCode;
|
||||
import com.orange.demo.webadmin.upms.service.SysPermCodeService;
|
||||
import com.orange.demo.common.core.constant.ErrorCodeEnum;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.groups.Default;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 权限字管理接口控制器类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/upms/sysPermCode")
|
||||
public class SysPermCodeController {
|
||||
|
||||
@Autowired
|
||||
private SysPermCodeService sysPermCodeService;
|
||||
|
||||
/**
|
||||
* 新增权限字操作。
|
||||
*
|
||||
* @param sysPermCodeDto 新增权限字对象。
|
||||
* @param permIdListString 与当前权限Id绑定的权限资源Id列表,多个权限资源之间逗号分隔。
|
||||
* @return 应答结果对象,包含新增权限字的主键Id。
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(
|
||||
@MyRequestBody("sysPermCode") SysPermCodeDto sysPermCodeDto, @MyRequestBody String permIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermCodeDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED);
|
||||
}
|
||||
SysPermCode sysPermCode = MyModelUtil.copyTo(sysPermCodeDto, SysPermCode.class);
|
||||
CallResult result = sysPermCodeService.verifyRelatedData(sysPermCode, null, permIdListString);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
}
|
||||
Set<Long> permIdSet = null;
|
||||
if (result.getData() != null) {
|
||||
permIdSet = (Set<Long>) result.getData().get("permIdSet");
|
||||
}
|
||||
sysPermCode = sysPermCodeService.saveNew(sysPermCode, permIdSet);
|
||||
return ResponseResult.success(sysPermCode.getPermCodeId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新权限字操作。
|
||||
*
|
||||
* @param sysPermCodeDto 更新权限字对象。
|
||||
* @param permIdListString 与当前权限Id绑定的权限资源Id列表,多个权限资源之间逗号分隔。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(
|
||||
@MyRequestBody("sysPermCode") SysPermCodeDto sysPermCodeDto, @MyRequestBody String permIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermCodeDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysPermCode originalSysPermCode = sysPermCodeService.getById(sysPermCodeDto.getPermCodeId());
|
||||
if (originalSysPermCode == null) {
|
||||
errorMessage = "数据验证失败,当前权限字并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
SysPermCode sysPermCode = MyModelUtil.copyTo(sysPermCodeDto, SysPermCode.class);
|
||||
CallResult result = sysPermCodeService.verifyRelatedData(sysPermCode, originalSysPermCode, permIdListString);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
}
|
||||
Set<Long> permIdSet = null;
|
||||
if (result.getData() != null) {
|
||||
permIdSet = (Set<Long>) result.getData().get("permIdSet");
|
||||
}
|
||||
try {
|
||||
if (!sysPermCodeService.update(sysPermCode, originalSysPermCode, permIdSet)) {
|
||||
errorMessage = "数据验证失败,当前权限字并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
} catch (DuplicateKeyException e) {
|
||||
errorMessage = "数据操作失败,权限字编码已经存在!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DUPLICATED_UNIQUE_KEY, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定权限字操作。
|
||||
*
|
||||
* @param permCodeId 指定的权限字主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long permCodeId) {
|
||||
if (MyCommonUtil.existBlankArgument(permCodeId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
String errorMessage;
|
||||
if (sysPermCodeService.hasChildren(permCodeId)) {
|
||||
errorMessage = "数据验证失败,当前权限字存在下级权限字!";
|
||||
return ResponseResult.error(ErrorCodeEnum.HAS_CHILDREN_DATA, errorMessage);
|
||||
}
|
||||
if (!sysPermCodeService.remove(permCodeId)) {
|
||||
errorMessage = "数据操作失败,权限字不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看权限字列表。
|
||||
*
|
||||
* @return 应答结果对象,包含权限字列表。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<List<SysPermCodeVo>> list() {
|
||||
List<SysPermCode> sysPermCodeList =
|
||||
sysPermCodeService.getAllListByOrder("permCodeType", "showOrder");
|
||||
return ResponseResult.success(MyModelUtil.copyCollectionTo(sysPermCodeList, SysPermCodeVo.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看权限字对象详情。
|
||||
*
|
||||
* @param permCodeId 指定权限字主键Id。
|
||||
* @return 应答结果对象,包含权限字对象详情。
|
||||
*/
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<SysPermCodeVo> view(@RequestParam Long permCodeId) {
|
||||
if (MyCommonUtil.existBlankArgument(permCodeId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
SysPermCode sysPermCode =
|
||||
sysPermCodeService.getByIdWithRelation(permCodeId, MyRelationParam.full());
|
||||
if (sysPermCode == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
SysPermCodeVo sysPermCodeVo = MyModelUtil.copyTo(sysPermCode, SysPermCodeVo.class);
|
||||
return ResponseResult.success(sysPermCodeVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询权限字的用户列表。同时返回详细的分配路径。
|
||||
*
|
||||
* @param permCodeId 权限字Id。
|
||||
* @param loginName 登录名。
|
||||
* @return 应答对象。包含从权限字到用户的完整权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
@GetMapping("/listSysUserWithDetail")
|
||||
public ResponseResult<List<Map<String, Object>>> listSysUserWithDetail(Long permCodeId, String loginName) {
|
||||
if (MyCommonUtil.isBlankOrNull(permCodeId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
return ResponseResult.success(sysPermCodeService.getSysUserListWithDetail(permCodeId, loginName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询权限字的角色列表。同时返回详细的分配路径。
|
||||
*
|
||||
* @param permCodeId 权限字Id。
|
||||
* @param roleName 角色名。
|
||||
* @return 应答对象。包含从权限字到角色的权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
@GetMapping("/listSysRoleWithDetail")
|
||||
public ResponseResult<List<Map<String, Object>>> listSysRoleWithDetail(Long permCodeId, String roleName) {
|
||||
if (MyCommonUtil.isBlankOrNull(permCodeId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
return ResponseResult.success(sysPermCodeService.getSysRoleListWithDetail(permCodeId, roleName));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.orange.demo.webadmin.upms.controller;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.orange.demo.webadmin.upms.dto.SysPermDto;
|
||||
import com.orange.demo.webadmin.upms.vo.SysPermVo;
|
||||
import com.orange.demo.webadmin.upms.model.SysPerm;
|
||||
import com.orange.demo.webadmin.upms.service.SysPermService;
|
||||
import com.orange.demo.common.core.constant.ErrorCodeEnum;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.groups.Default;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 权限资源管理接口控制器类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/upms/sysPerm")
|
||||
public class SysPermController {
|
||||
|
||||
@Autowired
|
||||
private SysPermService sysPermService;
|
||||
|
||||
/**
|
||||
* 新增权限资源操作。
|
||||
*
|
||||
* @param sysPermDto 新增权限资源对象。
|
||||
* @return 应答结果对象,包含新增权限资源的主键Id。
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody("sysPerm") SysPermDto sysPermDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysPerm sysPerm = MyModelUtil.copyTo(sysPermDto, SysPerm.class);
|
||||
CallResult result = sysPermService.verifyRelatedData(sysPerm, null);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
}
|
||||
sysPerm = sysPermService.saveNew(sysPerm);
|
||||
return ResponseResult.success(sysPerm.getPermId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新权限资源操作。
|
||||
*
|
||||
* @param sysPermDto 更新权限资源对象。
|
||||
* @return 应答结果对象,包含更新权限资源的主键Id。
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody("sysPerm") SysPermDto sysPermDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysPerm originalPerm = sysPermService.getById(sysPermDto.getPermId());
|
||||
if (originalPerm == null) {
|
||||
errorMessage = "数据验证失败,当前权限资源并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
SysPerm sysPerm = MyModelUtil.copyTo(sysPermDto, SysPerm.class);
|
||||
CallResult result = sysPermService.verifyRelatedData(sysPerm, originalPerm);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
}
|
||||
sysPermService.update(sysPerm, originalPerm);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定权限资源操作。
|
||||
*
|
||||
* @param permId 指定的权限资源主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long permId) {
|
||||
if (MyCommonUtil.existBlankArgument(permId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
if (!sysPermService.remove(permId)) {
|
||||
String errorMessage = "数据操作失败,权限不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看权限资源对象详情。
|
||||
*
|
||||
* @param permId 指定权限资源主键Id。
|
||||
* @return 应答结果对象,包含权限资源对象详情。
|
||||
*/
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<SysPermVo> view(@RequestParam Long permId) {
|
||||
if (MyCommonUtil.existBlankArgument(permId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
SysPerm perm = sysPermService.getById(permId);
|
||||
if (perm == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
SysPermVo permVo = MyModelUtil.copyTo(perm, SysPermVo.class);
|
||||
return ResponseResult.success(permVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看权限资源列表。
|
||||
*
|
||||
* @param sysPermDtoFiltter 过滤对象。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含权限资源列表。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<SysPermVo>> list(
|
||||
@MyRequestBody("sysPermFilter") SysPermDto sysPermDtoFiltter, @MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
SysPerm filter = MyModelUtil.copyTo(sysPermDtoFiltter, SysPerm.class);
|
||||
List<SysPerm> permList = sysPermService.getPermListWithRelation(filter);
|
||||
List<SysPermVo> permVoList = MyModelUtil.copyCollectionTo(permList, SysPermVo.class);
|
||||
long totalCount = 0L;
|
||||
if (permList instanceof Page) {
|
||||
totalCount = ((Page<SysPerm>) permList).getTotal();
|
||||
}
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(permVoList, totalCount));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询权限资源地址的用户列表。同时返回详细的分配路径。
|
||||
*
|
||||
* @param permId 权限资源Id。
|
||||
* @param loginName 登录名。
|
||||
* @return 应答对象。包含从权限资源到用户的完整权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
@GetMapping("/listSysUserWithDetail")
|
||||
public ResponseResult<List<Map<String, Object>>> listSysUserWithDetail(Long permId, String loginName) {
|
||||
if (MyCommonUtil.isBlankOrNull(permId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
return ResponseResult.success(sysPermService.getSysUserListWithDetail(permId, loginName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询权限资源地址的角色列表。同时返回详细的分配路径。
|
||||
*
|
||||
* @param permId 权限资源Id。
|
||||
* @param roleName 角色名。
|
||||
* @return 应答对象。包含从权限资源到角色的权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
@GetMapping("/listSysRoleWithDetail")
|
||||
public ResponseResult<List<Map<String, Object>>> listSysRoleWithDetail(Long permId, String roleName) {
|
||||
if (MyCommonUtil.isBlankOrNull(permId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
return ResponseResult.success(sysPermService.getSysRoleListWithDetail(permId, roleName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询权限资源地址的菜单列表。同时返回详细的分配路径。
|
||||
*
|
||||
* @param permId 权限资源Id。
|
||||
* @param menuName 菜单名。
|
||||
* @return 应答对象。包含从权限资源到菜单的权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
@GetMapping("/listSysMenuWithDetail")
|
||||
public ResponseResult<List<Map<String, Object>>> listSysMenuWithDetail(Long permId, String menuName) {
|
||||
if (MyCommonUtil.isBlankOrNull(permId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
return ResponseResult.success(sysPermService.getSysMenuListWithDetail(permId, menuName));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package com.orange.demo.webadmin.upms.controller;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.orange.demo.webadmin.upms.dto.SysPermModuleDto;
|
||||
import com.orange.demo.webadmin.upms.vo.SysPermModuleVo;
|
||||
import com.orange.demo.webadmin.upms.model.SysPerm;
|
||||
import com.orange.demo.webadmin.upms.model.SysPermModule;
|
||||
import com.orange.demo.webadmin.upms.service.SysPermModuleService;
|
||||
import com.orange.demo.common.core.constant.ErrorCodeEnum;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.groups.Default;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 权限资源模块管理接口控制器类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/upms/sysPermModule")
|
||||
public class SysPermModuleController {
|
||||
|
||||
@Autowired
|
||||
private SysPermModuleService sysPermModuleService;
|
||||
|
||||
/**
|
||||
* 新增权限资源模块操作。
|
||||
*
|
||||
* @param sysPermModuleDto 新增权限资源模块对象。
|
||||
* @return 应答结果对象,包含新增权限资源模块的主键Id。
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody("sysPermModule") SysPermModuleDto sysPermModuleDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermModuleDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysPermModule sysPermModule = MyModelUtil.copyTo(sysPermModuleDto, SysPermModule.class);
|
||||
if (sysPermModule.getParentId() != null
|
||||
&& sysPermModuleService.getById(sysPermModule.getParentId()) == null) {
|
||||
errorMessage = "数据验证失败,关联的上级权限模块并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_PARENT_ID_NOT_EXIST, errorMessage);
|
||||
}
|
||||
sysPermModuleService.saveNew(sysPermModule);
|
||||
return ResponseResult.success(sysPermModule.getModuleId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新权限资源模块操作。
|
||||
*
|
||||
* @param sysPermModuleDto 更新权限资源模块对象。
|
||||
* @return 应答结果对象,包含新增权限资源模块的主键Id。
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody("sysPermModule") SysPermModuleDto sysPermModuleDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermModuleDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysPermModule sysPermModule = MyModelUtil.copyTo(sysPermModuleDto, SysPermModule.class);
|
||||
SysPermModule originalPermModule = sysPermModuleService.getById(sysPermModule.getModuleId());
|
||||
if (originalPermModule == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
if (sysPermModule.getParentId() != null
|
||||
&& !sysPermModule.getParentId().equals(originalPermModule.getParentId())) {
|
||||
if (sysPermModuleService.getById(sysPermModule.getParentId()) == null) {
|
||||
errorMessage = "数据验证失败,关联的上级权限模块并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_PARENT_ID_NOT_EXIST, errorMessage);
|
||||
}
|
||||
}
|
||||
if (!sysPermModuleService.update(sysPermModule, originalPermModule)) {
|
||||
errorMessage = "数据验证失败,当前模块并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定权限资源模块操作。
|
||||
*
|
||||
* @param moduleId 指定的权限资源模块主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long moduleId) {
|
||||
if (MyCommonUtil.existBlankArgument(moduleId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
String errorMessage;
|
||||
if (sysPermModuleService.hasChildren(moduleId)
|
||||
|| sysPermModuleService.hasModulePerms(moduleId)) {
|
||||
errorMessage = "数据验证失败,当前权限模块存在子模块或权限资源,请先删除关联数据!";
|
||||
return ResponseResult.error(ErrorCodeEnum.HAS_CHILDREN_DATA, errorMessage);
|
||||
}
|
||||
if (!sysPermModuleService.remove(moduleId)) {
|
||||
errorMessage = "数据操作失败,权限模块不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看全部权限资源模块列表。
|
||||
*
|
||||
* @return 应答结果对象,包含权限资源模块列表。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<List<SysPermModuleVo>> list() {
|
||||
List<SysPermModule> permModuleList = sysPermModuleService.getAllListByOrder("showOrder");
|
||||
return ResponseResult.success(MyModelUtil.copyCollectionTo(permModuleList, SysPermModuleVo.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出全部权限资源模块及其下级关联的权限资源列表。
|
||||
*
|
||||
* @return 应答结果对象,包含树状列表,结构为权限资源模块和权限资源之间的树状关系。
|
||||
*/
|
||||
@PostMapping("/listAll")
|
||||
public ResponseResult<List<Map<String, Object>>> listAll() {
|
||||
List<SysPermModule> sysPermModuleList = sysPermModuleService.getPermModuleAndPermList();
|
||||
List<Map<String, Object>> resultList = new LinkedList<>();
|
||||
for (SysPermModule sysPermModule : sysPermModuleList) {
|
||||
Map<String, Object> permModuleMap = new HashMap<>(5);
|
||||
permModuleMap.put("id", sysPermModule.getModuleId());
|
||||
permModuleMap.put("name", sysPermModule.getModuleName());
|
||||
permModuleMap.put("type", sysPermModule.getModuleType());
|
||||
permModuleMap.put("isPerm", false);
|
||||
if (MyCommonUtil.isNotBlankOrNull(sysPermModule.getParentId())) {
|
||||
permModuleMap.put("parentId", sysPermModule.getParentId());
|
||||
}
|
||||
resultList.add(permModuleMap);
|
||||
if (CollectionUtils.isNotEmpty(sysPermModule.getSysPermList())) {
|
||||
for (SysPerm sysPerm : sysPermModule.getSysPermList()) {
|
||||
Map<String, Object> permMap = new HashMap<>(4);
|
||||
permMap.put("id", sysPerm.getPermId());
|
||||
permMap.put("name", sysPerm.getPermName());
|
||||
permMap.put("isPerm", true);
|
||||
permMap.put("url", sysPerm.getUrl());
|
||||
permMap.put("parentId", sysPermModule.getModuleId());
|
||||
resultList.add(permMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ResponseResult.success(resultList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,318 @@
|
||||
package com.orange.demo.webadmin.upms.controller;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.orange.demo.webadmin.upms.dto.SysRoleDto;
|
||||
import com.orange.demo.webadmin.upms.dto.SysUserDto;
|
||||
import com.orange.demo.webadmin.upms.vo.SysRoleVo;
|
||||
import com.orange.demo.webadmin.upms.vo.SysUserVo;
|
||||
import com.orange.demo.webadmin.upms.model.SysRole;
|
||||
import com.orange.demo.webadmin.upms.model.SysUser;
|
||||
import com.orange.demo.webadmin.upms.model.SysUserRole;
|
||||
import com.orange.demo.webadmin.upms.service.SysRoleService;
|
||||
import com.orange.demo.webadmin.upms.service.SysUserService;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.constant.ErrorCodeEnum;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.groups.Default;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 角色管理接口控制器类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/upms/sysRole")
|
||||
public class SysRoleController {
|
||||
|
||||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
|
||||
/**
|
||||
* 新增角色操作。
|
||||
*
|
||||
* @param sysRoleDto 新增角色对象。
|
||||
* @param menuIdListString 与当前角色Id绑定的menuId列表,多个menuId之间逗号分隔。
|
||||
* @return 应答结果对象,包含新增角色的主键Id。
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(
|
||||
@MyRequestBody("sysRole") SysRoleDto sysRoleDto, @MyRequestBody String menuIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysRoleDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysRole sysRole = MyModelUtil.copyTo(sysRoleDto, SysRole.class);
|
||||
CallResult result = sysRoleService.verifyRelatedData(sysRole, null, menuIdListString);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
}
|
||||
Set<Long> menuIdSet = null;
|
||||
if (result.getData() != null) {
|
||||
menuIdSet = (Set<Long>) result.getData().get("menuIdSet");
|
||||
}
|
||||
sysRoleService.saveNew(sysRole, menuIdSet);
|
||||
return ResponseResult.success(sysRole.getRoleId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新角色操作。
|
||||
*
|
||||
* @param sysRoleDto 更新角色对象。
|
||||
* @param menuIdListString 与当前角色Id绑定的menuId列表,多个menuId之间逗号分隔。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(
|
||||
@MyRequestBody("sysRole") SysRoleDto sysRoleDto, @MyRequestBody String menuIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysRoleDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysRole originalSysRole = sysRoleService.getById(sysRoleDto.getRoleId());
|
||||
if (originalSysRole == null) {
|
||||
errorMessage = "数据验证失败,当前角色并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
SysRole sysRole = MyModelUtil.copyTo(sysRoleDto, SysRole.class);
|
||||
CallResult result = sysRoleService.verifyRelatedData(sysRole, originalSysRole, menuIdListString);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
}
|
||||
Set<Long> menuIdSet = null;
|
||||
if (result.getData() != null) {
|
||||
menuIdSet = (Set<Long>) result.getData().get("menuIdSet");
|
||||
}
|
||||
if (!sysRoleService.update(sysRole, originalSysRole, menuIdSet)) {
|
||||
errorMessage = "更新失败,数据不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定角色操作。
|
||||
*
|
||||
* @param roleId 指定角色主键Id。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public ResponseResult<Void> delete(@MyRequestBody Long roleId) {
|
||||
if (MyCommonUtil.existBlankArgument(roleId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
if (!sysRoleService.remove(roleId)) {
|
||||
String errorMessage = "数据操作失败,角色不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看角色列表。
|
||||
*
|
||||
* @param sysRoleDtoFilter 角色过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含角色列表。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<SysRoleVo>> list(
|
||||
@MyRequestBody("sysRoleFilter") SysRoleDto sysRoleDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
SysRole filter = MyModelUtil.copyTo(sysRoleDtoFilter, SysRole.class);
|
||||
List<SysRole> roleList = sysRoleService.getSysRoleList(
|
||||
filter, MyOrderParam.buildOrderBy(orderParam, SysRole.class));
|
||||
List<SysRoleVo> roleVoList = MyModelUtil.copyCollectionTo(roleList, SysRoleVo.class);
|
||||
long totalCount = 0L;
|
||||
if (roleList instanceof Page) {
|
||||
totalCount = ((Page<SysRole>) roleList).getTotal();
|
||||
}
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(roleVoList, totalCount));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看角色详情。
|
||||
*
|
||||
* @param roleId 指定角色主键Id。
|
||||
* @return 应答结果对象,包含角色详情对象。
|
||||
*/
|
||||
@GetMapping("/view")
|
||||
public ResponseResult<SysRoleVo> view(@RequestParam Long roleId) {
|
||||
if (MyCommonUtil.existBlankArgument(roleId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
SysRole sysRole = sysRoleService.getByIdWithRelation(roleId, MyRelationParam.full());
|
||||
if (sysRole == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
SysRoleVo sysRoleVo = MyModelUtil.copyTo(sysRole, SysRoleVo.class);
|
||||
return ResponseResult.success(sysRoleVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取不包含指定角色Id的用户列表。
|
||||
* 用户和角色是多对多关系,当前接口将返回没有赋值指定RoleId的用户列表。可用于给角色添加新用户。
|
||||
*
|
||||
* @param roleId 角色主键Id。
|
||||
* @param sysUserDtoFilter 用户过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含用户列表数据。
|
||||
*/
|
||||
@PostMapping("/listNotInUserRole")
|
||||
public ResponseResult<MyPageData<SysUserVo>> listNotInUserRole(
|
||||
@MyRequestBody Long roleId,
|
||||
@MyRequestBody("sysUserFilter") SysUserDto sysUserDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
ResponseResult<Void> verifyResult = this.doRoleUserVerify(roleId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
SysUser filter = MyModelUtil.copyTo(sysUserDtoFilter, SysUser.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysUser.class);
|
||||
List<SysUser> userList = sysUserService.getNotInSysUserListByRoleId(roleId, filter, orderBy);
|
||||
List<SysUserVo> userVoList = MyModelUtil.copyCollectionTo(userList, SysUserVo.class);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(userVoList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 拥有指定角色的用户列表。
|
||||
*
|
||||
* @param roleId 角色主键Id。
|
||||
* @param sysUserDtoFilter 用户过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含用户列表数据。
|
||||
*/
|
||||
@PostMapping("/listUserRole")
|
||||
public ResponseResult<MyPageData<SysUserVo>> listUserRole(
|
||||
@MyRequestBody Long roleId,
|
||||
@MyRequestBody("sysUserFilter") SysUserDto sysUserDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
ResponseResult<Void> verifyResult = this.doRoleUserVerify(roleId);
|
||||
if (!verifyResult.isSuccess()) {
|
||||
return ResponseResult.errorFrom(verifyResult);
|
||||
}
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
SysUser filter = MyModelUtil.copyTo(sysUserDtoFilter, SysUser.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysUser.class);
|
||||
List<SysUser> userList = sysUserService.getSysUserListByRoleId(roleId, filter, orderBy);
|
||||
List<SysUserVo> userVoList = MyModelUtil.copyCollectionTo(userList, SysUserVo.class);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(userVoList));
|
||||
}
|
||||
|
||||
private ResponseResult<Void> doRoleUserVerify(Long roleId) {
|
||||
if (MyCommonUtil.existBlankArgument(roleId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
if (!sysRoleService.existId(roleId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 为指定角色添加用户列表。该操作可同时给一批用户赋值角色,并在同一事务内完成。
|
||||
*
|
||||
* @param roleId 角色主键Id。
|
||||
* @param userIdListString 逗号分隔的用户Id列表。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/addUserRole")
|
||||
public ResponseResult<Void> addUserRole(
|
||||
@MyRequestBody Long roleId, @MyRequestBody String userIdListString) {
|
||||
if (MyCommonUtil.existBlankArgument(roleId, userIdListString)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
Set<Long> userIdSet = Arrays.stream(
|
||||
userIdListString.split(",")).map(Long::valueOf).collect(Collectors.toSet());
|
||||
if (!sysRoleService.existId(roleId)
|
||||
|| !sysUserService.existUniqueKeyList("userId", userIdSet)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
||||
}
|
||||
List<SysUserRole> userRoleList = new LinkedList<>();
|
||||
for (Long userId : userIdSet) {
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole.setRoleId(roleId);
|
||||
userRole.setUserId(userId);
|
||||
userRoleList.add(userRole);
|
||||
}
|
||||
sysRoleService.addUserRoleList(userRoleList);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 为指定用户移除指定角色。
|
||||
*
|
||||
* @param roleId 指定角色主键Id。
|
||||
* @param userId 指定用户主键Id。
|
||||
* @return 应答数据结果。
|
||||
*/
|
||||
@PostMapping("/deleteUserRole")
|
||||
public ResponseResult<Void> deleteUserRole(
|
||||
@MyRequestBody Long roleId, @MyRequestBody Long userId) {
|
||||
if (MyCommonUtil.existBlankArgument(roleId, userId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
if (!sysRoleService.removeUserRole(roleId, userId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询角色的权限资源地址列表。同时返回详细的分配路径。
|
||||
*
|
||||
* @param roleId 角色Id。
|
||||
* @param url url过滤条件。
|
||||
* @return 应答对象,包含从角色到权限资源的完整权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
@GetMapping("/listSysPermWithDetail")
|
||||
public ResponseResult<List<Map<String, Object>>> listSysPermByWithDetail(Long roleId, String url) {
|
||||
if (MyCommonUtil.isBlankOrNull(roleId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
return ResponseResult.success(sysRoleService.getSysPermListWithDetail(roleId, url));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询角色的权限字列表。同时返回详细的分配路径。
|
||||
*
|
||||
* @param roleId 角色Id。
|
||||
* @param permCode 权限字名称过滤条件。
|
||||
* @return 应答对象,包含从角色到权限字的权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
@GetMapping("/listSysPermCodeWithDetail")
|
||||
public ResponseResult<List<Map<String, Object>>> listSysPermCodeWithDetail(Long roleId, String permCode) {
|
||||
if (MyCommonUtil.isBlankOrNull(roleId)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
return ResponseResult.success(sysRoleService.getSysPermCodeListWithDetail(roleId, permCode));
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user