删除文件 orange-demo-single

This commit is contained in:
orange-form
2024-07-05 14:31:57 +00:00
committed by Gitee
parent f8fb18aa6c
commit 73edb28fae
668 changed files with 0 additions and 186753 deletions

View File

@@ -1,26 +0,0 @@
target/
!.mvn/wrapper/maven-wrapper.jar
/.mvn/*
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/build/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

View File

@@ -1,17 +0,0 @@
### 服务接口文档
---
- Knife4j
- 服务启动后Knife4j的文档入口地址 [http://localhost:8082/doc.html#/plus](http://localhost:8082/doc.html#/plus)
- Postman
- 无需启动服务即可将当前工程的接口导出成Postman格式。在工程的common/common-tools/模块下找到ExportApiApp文件并执行main函数。
### 服务启动环境依赖
---
执行docker-compose up -d 命令启动下面依赖的服务。
执行docker-compose down 命令停止下面服务。
- Redis
- 版本4
- 端口: 6379
- 推荐客户端工具 [AnotherRedisDesktopManager](https://github.com/qishibo/AnotherRedisDesktopManager)

View File

@@ -1,16 +0,0 @@
<?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.orangeforms</groupId>
<artifactId>OrangeSingleDemo</artifactId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>application-common</artifactId>
<version>1.0.0</version>
<name>application-common</name>
<packaging>jar</packaging>
</project>

View File

@@ -1,49 +0,0 @@
package com.orangeforms.application.common.constant;
import java.util.HashMap;
import java.util.Map;
/**
* 设备类型常量字典对象。
*
* @author Jerry
* @date 2020-09-24
*/
public final class DeviceType {
/**
* iOS。
*/
public static final int IOS = 0;
/**
* Android。
*/
public static final int ANDROID = 1;
/**
* PC。
*/
public static final int PC = 2;
private static final Map<Object, String> DICT_MAP = new HashMap<>(3);
static {
DICT_MAP.put(IOS, "iOS");
DICT_MAP.put(ANDROID, "Android");
DICT_MAP.put(PC, "PC");
}
/**
* 判断参数是否为当前常量字典的合法值。
*
* @param value 待验证的参数值。
* @return 合法返回true否则false。
*/
public static boolean isValid(Integer value) {
return value != null && DICT_MAP.containsKey(value);
}
/**
* 私有构造函数,明确标识该常量类的作用。
*/
private DeviceType() {
}
}

View File

@@ -1,49 +0,0 @@
package com.orangeforms.application.common.constant;
import java.util.HashMap;
import java.util.Map;
/**
* 经验等级常量字典对象。
*
* @author Jerry
* @date 2020-09-24
*/
public final class ExpLevel {
/**
* 初级学员。
*/
public static final int LOWER = 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(LOWER, "初级学员");
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 ExpLevel() {
}
}

View File

@@ -1,44 +0,0 @@
package com.orangeforms.application.common.constant;
import java.util.HashMap;
import java.util.Map;
/**
* 性别常量字典对象。
*
* @author Jerry
* @date 2020-09-24
*/
public final class Gender {
/**
* 男。
*/
public static final int MALE = 1;
/**
* 女。
*/
public static final int FEMALE = 0;
private static final Map<Object, String> DICT_MAP = new HashMap<>(2);
static {
DICT_MAP.put(MALE, "");
DICT_MAP.put(FEMALE, "");
}
/**
* 判断参数是否为当前常量字典的合法值。
*
* @param value 待验证的参数值。
* @return 合法返回true否则false。
*/
public static boolean isValid(Integer value) {
return value != null && DICT_MAP.containsKey(value);
}
/**
* 私有构造函数,明确标识该常量类的作用。
*/
private Gender() {
}
}

View File

@@ -1,89 +0,0 @@
package com.orangeforms.application.common.constant;
import java.util.HashMap;
import java.util.Map;
/**
* 学生行为常量字典对象。
*
* @author Jerry
* @date 2020-09-24
*/
public final class StudentActionType {
/**
* 充值。
*/
public static final int RECHARGE = 0;
/**
* 购课。
*/
public static final int BUY_COURSE = 1;
/**
* 上课签到。
*/
public static final int SIGNIN_COURSE = 2;
/**
* 上课签退。
*/
public static final int SIGNOUT_COURSE = 3;
/**
* 看视频课。
*/
public static final int WATCH_VIDEO = 4;
/**
* 做作业。
*/
public static final int DO_PAPER = 5;
/**
* 刷题。
*/
public static final int REFRESH_EXERCISE = 6;
/**
* 献花。
*/
public static final int PRESENT_FLOWER = 7;
/**
* 购买视频。
*/
public static final int BUY_VIDEO_COURSE = 8;
/**
* 购买鲜花。
*/
public static final int BUY_FLOWER = 9;
/**
* 购买作业。
*/
public static final int BUY_PAPER = 10;
private static final Map<Object, String> DICT_MAP = new HashMap<>(11);
static {
DICT_MAP.put(RECHARGE, "充值");
DICT_MAP.put(BUY_COURSE, "购课");
DICT_MAP.put(SIGNIN_COURSE, "上课签到");
DICT_MAP.put(SIGNOUT_COURSE, "上课签退");
DICT_MAP.put(WATCH_VIDEO, "看视频课");
DICT_MAP.put(DO_PAPER, "做作业");
DICT_MAP.put(REFRESH_EXERCISE, "刷题");
DICT_MAP.put(PRESENT_FLOWER, "献花");
DICT_MAP.put(BUY_VIDEO_COURSE, "购买视频");
DICT_MAP.put(BUY_FLOWER, "购买鲜花");
DICT_MAP.put(BUY_PAPER, "购买作业");
}
/**
* 判断参数是否为当前常量字典的合法值。
*
* @param value 待验证的参数值。
* @return 合法返回true否则false。
*/
public static boolean isValid(Integer value) {
return value != null && DICT_MAP.containsKey(value);
}
/**
* 私有构造函数,明确标识该常量类的作用。
*/
private StudentActionType() {
}
}

View File

@@ -1,49 +0,0 @@
package com.orangeforms.application.common.constant;
import java.util.HashMap;
import java.util.Map;
/**
* 学生状态常量字典对象。
*
* @author Jerry
* @date 2020-09-24
*/
public final class StudentStatus {
/**
* 正常。
*/
public static final int NORMAL = 0;
/**
* 锁定。
*/
public static final int LOCKED = 1;
/**
* 注销。
*/
public static final int DELETED = 2;
private static final Map<Object, String> DICT_MAP = new HashMap<>(3);
static {
DICT_MAP.put(NORMAL, "正常");
DICT_MAP.put(LOCKED, "锁定");
DICT_MAP.put(DELETED, "注销");
}
/**
* 判断参数是否为当前常量字典的合法值。
*
* @param value 待验证的参数值。
* @return 合法返回true否则false。
*/
public static boolean isValid(Integer value) {
return value != null && DICT_MAP.containsKey(value);
}
/**
* 私有构造函数,明确标识该常量类的作用。
*/
private StudentStatus() {
}
}

View File

@@ -1,49 +0,0 @@
package com.orangeforms.application.common.constant;
import java.util.HashMap;
import java.util.Map;
/**
* 学科常量字典对象。
*
* @author Jerry
* @date 2020-09-24
*/
public final class Subject {
/**
* 语文。
*/
public static final int CHINESE = 0;
/**
* 数学。
*/
public static final int MATCH = 1;
/**
* 英语。
*/
public static final int ENGLISH = 2;
private static final Map<Object, String> DICT_MAP = new HashMap<>(3);
static {
DICT_MAP.put(CHINESE, "语文");
DICT_MAP.put(MATCH, "数学");
DICT_MAP.put(ENGLISH, "英语");
}
/**
* 判断参数是否为当前常量字典的合法值。
*
* @param value 待验证的参数值。
* @return 合法返回true否则false。
*/
public static boolean isValid(Integer value) {
return value != null && DICT_MAP.containsKey(value);
}
/**
* 私有构造函数,明确标识该常量类的作用。
*/
private Subject() {
}
}

View File

@@ -1,98 +0,0 @@
<?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.orangeforms</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.anji-plus</groupId>
<artifactId>spring-boot-starter-captcha</artifactId>
<version>${ajcaptcha.version}</version>
</dependency>
<!-- aj-captcha 依赖data-redis作为缓存 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-logging</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- 业务组件依赖 -->
<dependency>
<groupId>com.orangeforms</groupId>
<artifactId>common-redis</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.orangeforms</groupId>
<artifactId>common-log</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.orangeforms</groupId>
<artifactId>common-sequence</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.orangeforms</groupId>
<artifactId>common-datafilter</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.orangeforms</groupId>
<artifactId>application-common</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.orangeforms</groupId>
<artifactId>common-swagger</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>

View File

@@ -1,22 +0,0 @@
package com.orangeforms.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.orangeforms")
public class WebAdminApplication {
public static void main(String[] args) {
SpringApplication.run(WebAdminApplication.class, args);
}
}

View File

@@ -1,74 +0,0 @@
package com.orangeforms.webadmin.app.controller;
import io.swagger.annotations.Api;
import cn.jimmyshi.beanquery.BeanQuery;
import com.orangeforms.webadmin.app.model.AreaCode;
import com.orangeforms.webadmin.app.service.AreaCodeService;
import com.orangeforms.common.core.object.ResponseResult;
import com.orangeforms.common.core.annotation.MyRequestBody;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
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
*/
@Api(tags = "行政区划数据访问接口")
@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));
}
/**
* 根据字典Id集合获取查询后的字典数据。
*
* @param dictIds 字典Id集合。
* @return 字典形式的行政区划列表。
*/
@PostMapping("/listDictByIds")
public ResponseResult<List<Map<String, Object>>> listDictByIds(
@MyRequestBody(elementType = Long.class) List<Long> dictIds) {
List<AreaCode> resultList = areaCodeService.getInList(new HashSet<>(dictIds));
return ResponseResult.success(BeanQuery.select(
"parentId as parentId", "areaId as id", "areaName as name").executeFrom(resultList));
}
}

View File

@@ -1,317 +0,0 @@
package com.orangeforms.webadmin.app.controller;
import cn.jimmyshi.beanquery.BeanQuery;
import cn.hutool.core.util.ReflectUtil;
import com.orangeforms.common.core.upload.BaseUpDownloader;
import com.orangeforms.common.core.upload.UpDownloaderFactory;
import com.orangeforms.common.core.upload.UploadResponseInfo;
import com.orangeforms.common.core.upload.UploadStoreInfo;
import com.orangeforms.common.log.annotation.OperationLog;
import com.orangeforms.common.log.model.constant.SysOperationLogType;
import com.github.pagehelper.page.PageMethod;
import com.orangeforms.webadmin.app.vo.*;
import com.orangeforms.webadmin.app.dto.*;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.webadmin.app.service.*;
import com.orangeforms.common.core.object.*;
import com.orangeforms.common.core.util.*;
import com.orangeforms.common.core.constant.*;
import com.orangeforms.common.core.annotation.MyRequestBody;
import com.orangeforms.common.redis.cache.SessionCacheHelper;
import com.orangeforms.webadmin.config.ApplicationConfig;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
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.*;
/**
* 课程数据操作控制器类。
*
* @author Jerry
* @date 2020-09-24
*/
@Api(tags = "课程数据管理接口")
@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。
*/
@ApiOperationSupport(ignoreParameters = {
"courseDto.courseId",
"courseDto.priceStart",
"courseDto.priceEnd",
"courseDto.classHourStart",
"courseDto.classHourEnd",
"courseDto.createTimeStart",
"courseDto.createTimeEnd"})
@OperationLog(type = SysOperationLogType.ADD)
@PostMapping("/add")
public ResponseResult<Long> add(@MyRequestBody CourseDto courseDto) {
String errorMessage = MyCommonUtil.getModelValidationError(courseDto, false);
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()) {
return ResponseResult.errorFrom(callResult);
}
course = courseService.saveNew(course);
return ResponseResult.success(course.getCourseId());
}
/**
* 更新课程数据数据。
*
* @param courseDto 更新对象。
* @return 应答结果对象。
*/
@ApiOperationSupport(ignoreParameters = {
"courseDto.priceStart",
"courseDto.priceEnd",
"courseDto.classHourStart",
"courseDto.classHourEnd",
"courseDto.createTimeStart",
"courseDto.createTimeEnd"})
@OperationLog(type = SysOperationLogType.UPDATE)
@PostMapping("/update")
public ResponseResult<Void> update(@MyRequestBody CourseDto courseDto) {
String errorMessage = MyCommonUtil.getModelValidationError(courseDto, true);
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()) {
return ResponseResult.errorFrom(callResult);
}
if (!courseService.update(course, originalCourse)) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
return ResponseResult.success();
}
/**
* 删除课程数据数据。
*
* @param courseId 删除对象主键Id。
* @return 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.DELETE)
@PostMapping("/delete")
public ResponseResult<Void> delete(@MyRequestBody Long courseId) {
String errorMessage;
if (MyCommonUtil.existBlankArgument(courseId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
return this.doDelete(courseId);
}
/**
* 列出符合过滤条件的课程数据列表。
*
* @param courseDtoFilter 过滤对象。
* @param orderParam 排序参数。
* @param pageParam 分页参数。
* @return 应答结果对象,包含查询结果集。
*/
@PostMapping("/list")
public ResponseResult<MyPageData<CourseVo>> list(
@MyRequestBody 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 应答对象。
*/
@OperationLog(type = SysOperationLogType.DOWNLOAD, saveResponse = false)
@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 上传文件对象。
*/
@OperationLog(type = SysOperationLogType.UPLOAD, saveResponse = false)
@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和namevalue对应具体数据。
*/
@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));
}
/**
* 根据字典Id集合获取查询后的字典数据。
*
* @param dictIds 字典Id集合。
* @return 应答结果对象,包含字典形式的数据集合。
*/
@PostMapping("/listDictByIds")
public ResponseResult<List<Map<String, Object>>> listDictByIds(
@MyRequestBody(elementType = Long.class) List<Long> dictIds) {
List<Course> resultList = courseService.getInList(new HashSet<>(dictIds));
return ResponseResult.success(BeanQuery.select(
"courseId as id", "courseName as name").executeFrom(resultList));
}
private ResponseResult<Void> doDelete(Long courseId) {
String errorMessage;
// 验证关联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();
}
}

View File

@@ -1,107 +0,0 @@
package com.orangeforms.webadmin.app.controller;
import com.github.pagehelper.page.PageMethod;
import com.orangeforms.webadmin.app.vo.*;
import com.orangeforms.webadmin.app.dto.*;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.webadmin.app.service.*;
import com.orangeforms.common.core.object.*;
import com.orangeforms.common.core.util.*;
import com.orangeforms.common.core.constant.*;
import com.orangeforms.common.core.annotation.MyRequestBody;
import io.swagger.annotations.Api;
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
*/
@Api(tags = "课程统计管理接口")
@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 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 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);
}
}

View File

@@ -1,160 +0,0 @@
package com.orangeforms.webadmin.app.controller;
import com.alibaba.fastjson.JSONObject;
import cn.jimmyshi.beanquery.BeanQuery;
import com.orangeforms.webadmin.app.dto.GradeDto;
import com.orangeforms.webadmin.app.model.Grade;
import com.orangeforms.webadmin.app.service.GradeService;
import com.orangeforms.common.core.constant.ErrorCodeEnum;
import com.orangeforms.common.core.util.MyModelUtil;
import com.orangeforms.common.core.util.MyCommonUtil;
import com.orangeforms.common.core.object.ResponseResult;
import com.orangeforms.common.core.annotation.MyRequestBody;
import com.orangeforms.common.core.validator.UpdateGroup;
import com.orangeforms.common.log.annotation.OperationLog;
import com.orangeforms.common.log.model.constant.SysOperationLogType;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
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
*/
@Api(tags = "年级管理接口")
@Slf4j
@RestController
@RequestMapping("/admin/app/grade")
public class GradeController {
@Autowired
private GradeService gradeService;
/**
* 新增年级数据。
*
* @param gradeDto 新增对象。
* @return 应答结果对象包含新增对象主键Id。
*/
@ApiOperationSupport(ignoreParameters = {"gradeDto.gradeId"})
@OperationLog(type = SysOperationLogType.ADD)
@PostMapping("/add")
public ResponseResult<Integer> add(@MyRequestBody 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 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.UPDATE)
@PostMapping("/update")
public ResponseResult<Void> update(@MyRequestBody 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 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.DELETE)
@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.isEmpty(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);
}
/**
* 根据字典Id集合获取查询后的字典数据。
*
* @param dictIds 字典Id集合。
* @return 应答结果对象,包含字典形式的数据集合。
*/
@PostMapping("/listDictByIds")
public ResponseResult<List<Map<String, Object>>> listDictByIds(
@MyRequestBody(elementType = Integer.class) List<Integer> dictIds) {
List<Grade> resultList = gradeService.getInList(new HashSet<>(dictIds));
return ResponseResult.success(BeanQuery.select(
"gradeId as id", "gradeName as name").executeFrom(resultList));
}
/**
* 将当前字典表的数据重新加载到缓存中。
* 由于缓存的数据更新在add/update/delete等接口均有同步处理。因此该接口仅当同步过程中出现问题时
* 可手工调用,或者每天晚上定时同步一次。
*/
@OperationLog(type = SysOperationLogType.RELOAD_CACHE)
@GetMapping("/reloadCachedData")
public ResponseResult<Boolean> reloadCachedData() {
gradeService.reloadCachedData(true);
return ResponseResult.success(true);
}
}

View File

@@ -1,107 +0,0 @@
package com.orangeforms.webadmin.app.controller;
import com.github.pagehelper.page.PageMethod;
import com.orangeforms.webadmin.app.vo.*;
import com.orangeforms.webadmin.app.dto.*;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.webadmin.app.service.*;
import com.orangeforms.common.core.object.*;
import com.orangeforms.common.core.util.*;
import com.orangeforms.common.core.constant.*;
import com.orangeforms.common.core.annotation.MyRequestBody;
import io.swagger.annotations.Api;
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
*/
@Api(tags = "学生行为统计管理接口")
@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 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 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);
}
}

View File

@@ -1,171 +0,0 @@
package com.orangeforms.webadmin.app.controller;
import com.orangeforms.common.log.annotation.OperationLog;
import com.orangeforms.common.log.model.constant.SysOperationLogType;
import com.github.pagehelper.page.PageMethod;
import com.orangeforms.webadmin.app.vo.*;
import com.orangeforms.webadmin.app.dto.*;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.webadmin.app.service.*;
import com.orangeforms.common.core.object.*;
import com.orangeforms.common.core.util.*;
import com.orangeforms.common.core.constant.*;
import com.orangeforms.common.core.annotation.MyRequestBody;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
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
*/
@Api(tags = "学生行为流水管理接口")
@Slf4j
@RestController
@RequestMapping("/admin/app/studentActionTrans")
public class StudentActionTransController {
@Autowired
private StudentActionTransService studentActionTransService;
/**
* 新增学生行为流水数据。
*
* @param studentActionTransDto 新增对象。
* @return 应答结果对象包含新增对象主键Id。
*/
@ApiOperationSupport(ignoreParameters = {
"studentActionTransDto.transId",
"studentActionTransDto.createTimeStart",
"studentActionTransDto.createTimeEnd"})
@OperationLog(type = SysOperationLogType.ADD)
@PostMapping("/add")
public ResponseResult<Long> add(@MyRequestBody StudentActionTransDto studentActionTransDto) {
String errorMessage = MyCommonUtil.getModelValidationError(studentActionTransDto, false);
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()) {
return ResponseResult.errorFrom(callResult);
}
studentActionTrans = studentActionTransService.saveNew(studentActionTrans);
return ResponseResult.success(studentActionTrans.getTransId());
}
/**
* 更新学生行为流水数据。
*
* @param studentActionTransDto 更新对象。
* @return 应答结果对象。
*/
@ApiOperationSupport(ignoreParameters = {
"studentActionTransDto.createTimeStart",
"studentActionTransDto.createTimeEnd"})
@OperationLog(type = SysOperationLogType.UPDATE)
@PostMapping("/update")
public ResponseResult<Void> update(@MyRequestBody StudentActionTransDto studentActionTransDto) {
String errorMessage = MyCommonUtil.getModelValidationError(studentActionTransDto, true);
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()) {
return ResponseResult.errorFrom(callResult);
}
if (!studentActionTransService.update(studentActionTrans, originalStudentActionTrans)) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
return ResponseResult.success();
}
/**
* 删除学生行为流水数据。
*
* @param transId 删除对象主键Id。
* @return 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.DELETE)
@PostMapping("/delete")
public ResponseResult<Void> delete(@MyRequestBody Long transId) {
String errorMessage;
if (MyCommonUtil.existBlankArgument(transId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
return this.doDelete(transId);
}
/**
* 列出符合过滤条件的学生行为流水列表。
*
* @param studentActionTransDtoFilter 过滤对象。
* @param orderParam 排序参数。
* @param pageParam 分页参数。
* @return 应答结果对象,包含查询结果集。
*/
@PostMapping("/list")
public ResponseResult<MyPageData<StudentActionTransVo>> list(
@MyRequestBody 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);
}
private ResponseResult<Void> doDelete(Long transId) {
String errorMessage;
// 验证关联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();
}
}

View File

@@ -1,426 +0,0 @@
package com.orangeforms.webadmin.app.controller;
import com.orangeforms.common.log.annotation.OperationLog;
import com.orangeforms.common.log.model.constant.SysOperationLogType;
import com.github.pagehelper.page.PageMethod;
import com.orangeforms.webadmin.app.vo.*;
import com.orangeforms.webadmin.app.dto.*;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.webadmin.app.service.*;
import com.orangeforms.common.core.object.*;
import com.orangeforms.common.core.util.*;
import com.orangeforms.common.core.constant.*;
import com.orangeforms.common.core.annotation.MyRequestBody;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
import java.util.stream.Collectors;
/**
* 班级数据操作控制器类。
*
* @author Jerry
* @date 2020-09-24
*/
@Api(tags = "班级数据管理接口")
@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。
*/
@ApiOperationSupport(ignoreParameters = {"studentClassDto.classId"})
@OperationLog(type = SysOperationLogType.ADD)
@PostMapping("/add")
public ResponseResult<Long> add(@MyRequestBody StudentClassDto studentClassDto) {
String errorMessage = MyCommonUtil.getModelValidationError(studentClassDto, false);
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()) {
return ResponseResult.errorFrom(callResult);
}
studentClass = studentClassService.saveNew(studentClass);
return ResponseResult.success(studentClass.getClassId());
}
/**
* 更新班级数据数据。
*
* @param studentClassDto 更新对象。
* @return 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.UPDATE)
@PostMapping("/update")
public ResponseResult<Void> update(@MyRequestBody StudentClassDto studentClassDto) {
String errorMessage = MyCommonUtil.getModelValidationError(studentClassDto, true);
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()) {
return ResponseResult.errorFrom(callResult);
}
if (!studentClassService.update(studentClass, originalStudentClass)) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
return ResponseResult.success();
}
/**
* 删除班级数据数据。
*
* @param classId 删除对象主键Id。
* @return 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.DELETE)
@PostMapping("/delete")
public ResponseResult<Void> delete(@MyRequestBody Long classId) {
String errorMessage;
if (MyCommonUtil.existBlankArgument(classId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
return this.doDelete(classId);
}
/**
* 列出符合过滤条件的班级数据列表。
*
* @param studentClassDtoFilter 过滤对象。
* @param orderParam 排序参数。
* @param pageParam 分页参数。
* @return 应答结果对象,包含查询结果集。
*/
@PostMapping("/list")
public ResponseResult<MyPageData<StudentClassVo>> list(
@MyRequestBody 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 CourseDto courseDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (MyCommonUtil.isNotBlankOrNull(classId) && !studentClassService.existId(classId)) {
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
}
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(required = true) Long classId,
@MyRequestBody CourseDto courseDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (!studentClassService.existId(classId)) {
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
}
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));
}
/**
* 批量添加班级数据和 [课程数据] 对象的多对多关联关系数据。
*
* @param classId 主表主键Id。
* @param classCourseDtoList 关联对象列表。
* @return 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.ADD_M2M)
@PostMapping("/addClassCourse")
public ResponseResult<Void> addClassCourse(
@MyRequestBody Long classId,
@MyRequestBody(elementType = ClassCourseDto.class) List<ClassCourseDto> classCourseDtoList) {
if (MyCommonUtil.existBlankArgument(classId, classCourseDtoList)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
String errorMessage = MyCommonUtil.getModelValidationError(classCourseDtoList);
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 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.UPDATE)
@PostMapping("/updateClassCourse")
public ResponseResult<Void> updateClassCourse(
@MyRequestBody 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 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.DELETE_M2M)
@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 StudentDto studentDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (MyCommonUtil.isNotBlankOrNull(classId) && !studentClassService.existId(classId)) {
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
}
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(required = true) Long classId,
@MyRequestBody StudentDto studentDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (!studentClassService.existId(classId)) {
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
}
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));
}
/**
* 批量添加班级数据和 [学生数据] 对象的多对多关联关系数据。
*
* @param classId 主表主键Id。
* @param classStudentDtoList 关联对象列表。
* @return 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.ADD_M2M)
@PostMapping("/addClassStudent")
public ResponseResult<Void> addClassStudent(
@MyRequestBody Long classId,
@MyRequestBody(elementType = ClassStudentDto.class) List<ClassStudentDto> classStudentDtoList) {
if (MyCommonUtil.existBlankArgument(classId, classStudentDtoList)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
String errorMessage = MyCommonUtil.getModelValidationError(classStudentDtoList);
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 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.DELETE_M2M)
@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();
}
private ResponseResult<Void> doDelete(Long classId) {
String errorMessage;
// 验证关联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();
}
}

View File

@@ -1,205 +0,0 @@
package com.orangeforms.webadmin.app.controller;
import cn.jimmyshi.beanquery.BeanQuery;
import com.orangeforms.common.log.annotation.OperationLog;
import com.orangeforms.common.log.model.constant.SysOperationLogType;
import com.github.pagehelper.page.PageMethod;
import com.orangeforms.webadmin.app.vo.*;
import com.orangeforms.webadmin.app.dto.*;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.webadmin.app.service.*;
import com.orangeforms.common.core.object.*;
import com.orangeforms.common.core.util.*;
import com.orangeforms.common.core.constant.*;
import com.orangeforms.common.core.annotation.MyRequestBody;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
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
*/
@Api(tags = "学生数据管理接口")
@Slf4j
@RestController
@RequestMapping("/admin/app/student")
public class StudentController {
@Autowired
private StudentService studentService;
/**
* 新增学生数据数据。
*
* @param studentDto 新增对象。
* @return 应答结果对象包含新增对象主键Id。
*/
@ApiOperationSupport(ignoreParameters = {
"studentDto.studentId",
"studentDto.searchString",
"studentDto.birthdayStart",
"studentDto.birthdayEnd",
"studentDto.registerTimeStart",
"studentDto.registerTimeEnd"})
@OperationLog(type = SysOperationLogType.ADD)
@PostMapping("/add")
public ResponseResult<Long> add(@MyRequestBody StudentDto studentDto) {
String errorMessage = MyCommonUtil.getModelValidationError(studentDto, false);
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()) {
return ResponseResult.errorFrom(callResult);
}
student = studentService.saveNew(student);
return ResponseResult.success(student.getStudentId());
}
/**
* 更新学生数据数据。
*
* @param studentDto 更新对象。
* @return 应答结果对象。
*/
@ApiOperationSupport(ignoreParameters = {
"studentDto.searchString",
"studentDto.birthdayStart",
"studentDto.birthdayEnd",
"studentDto.registerTimeStart",
"studentDto.registerTimeEnd"})
@OperationLog(type = SysOperationLogType.UPDATE)
@PostMapping("/update")
public ResponseResult<Void> update(@MyRequestBody StudentDto studentDto) {
String errorMessage = MyCommonUtil.getModelValidationError(studentDto, true);
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()) {
return ResponseResult.errorFrom(callResult);
}
if (!studentService.update(student, originalStudent)) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
return ResponseResult.success();
}
/**
* 删除学生数据数据。
*
* @param studentId 删除对象主键Id。
* @return 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.DELETE)
@PostMapping("/delete")
public ResponseResult<Void> delete(@MyRequestBody Long studentId) {
String errorMessage;
if (MyCommonUtil.existBlankArgument(studentId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
return this.doDelete(studentId);
}
/**
* 列出符合过滤条件的学生数据列表。
*
* @param studentDtoFilter 过滤对象。
* @param orderParam 排序参数。
* @param pageParam 分页参数。
* @return 应答结果对象,包含查询结果集。
*/
@PostMapping("/list")
public ResponseResult<MyPageData<StudentVo>> list(
@MyRequestBody 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和namevalue对应具体数据。
*/
@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));
}
/**
* 根据字典Id集合获取查询后的字典数据。
*
* @param dictIds 字典Id集合。
* @return 应答结果对象,包含字典形式的数据集合。
*/
@PostMapping("/listDictByIds")
public ResponseResult<List<Map<String, Object>>> listDictByIds(
@MyRequestBody(elementType = Long.class) List<Long> dictIds) {
List<Student> resultList = studentService.getInList(new HashSet<>(dictIds));
return ResponseResult.success(BeanQuery.select(
"studentId as id", "studentName as name").executeFrom(resultList));
}
private ResponseResult<Void> doDelete(Long studentId) {
String errorMessage;
// 验证关联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();
}
}

View File

@@ -1,13 +0,0 @@
package com.orangeforms.webadmin.app.dao;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.webadmin.app.model.AreaCode;
/**
* 行政区划数据操作访问接口。
*
* @author Jerry
* @date 2020-09-24
*/
public interface AreaCodeMapper extends BaseDaoMapper<AreaCode> {
}

View File

@@ -1,22 +0,0 @@
package com.orangeforms.webadmin.app.dao;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.webadmin.app.model.ClassCourse;
import java.util.*;
/**
* 数据操作访问接口。
*
* @author Jerry
* @date 2020-09-24
*/
public interface ClassCourseMapper extends BaseDaoMapper<ClassCourse> {
/**
* 批量插入对象列表。
*
* @param classCourseList 新增对象列表。
*/
void insertList(List<ClassCourse> classCourseList);
}

View File

@@ -1,22 +0,0 @@
package com.orangeforms.webadmin.app.dao;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.webadmin.app.model.ClassStudent;
import java.util.*;
/**
* 数据操作访问接口。
*
* @author Jerry
* @date 2020-09-24
*/
public interface ClassStudentMapper extends BaseDaoMapper<ClassStudent> {
/**
* 批量插入对象列表。
*
* @param classStudentList 新增对象列表。
*/
void insertList(List<ClassStudent> classStudentList);
}

View File

@@ -1,59 +0,0 @@
package com.orangeforms.webadmin.app.dao;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.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 courseList 新增对象列表。
*/
void insertList(List<Course> courseList);
/**
* 获取过滤后的对象列表。
*
* @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);
}

View File

@@ -1,48 +0,0 @@
package com.orangeforms.webadmin.app.dao;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.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 courseTransStatsList 新增对象列表。
*/
void insertList(List<CourseTransStats> courseTransStatsList);
/**
* 获取分组计算后的数据对象列表。
*
* @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);
}

View File

@@ -1,22 +0,0 @@
package com.orangeforms.webadmin.app.dao;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.webadmin.app.model.Grade;
import java.util.*;
/**
* 年级数据操作访问接口。
*
* @author Jerry
* @date 2020-09-24
*/
public interface GradeMapper extends BaseDaoMapper<Grade> {
/**
* 批量插入对象列表。
*
* @param gradeList 新增对象列表。
*/
void insertList(List<Grade> gradeList);
}

View File

@@ -1,22 +0,0 @@
package com.orangeforms.webadmin.app.dao;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.webadmin.app.model.MaterialEdition;
import java.util.*;
/**
* 数据操作访问接口。
*
* @author Jerry
* @date 2020-09-24
*/
public interface MaterialEditionMapper extends BaseDaoMapper<MaterialEdition> {
/**
* 批量插入对象列表。
*
* @param materialEditionList 新增对象列表。
*/
void insertList(List<MaterialEdition> materialEditionList);
}

View File

@@ -1,48 +0,0 @@
package com.orangeforms.webadmin.app.dao;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.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 studentActionStatsList 新增对象列表。
*/
void insertList(List<StudentActionStats> studentActionStatsList);
/**
* 获取分组计算后的数据对象列表。
*
* @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);
}

View File

@@ -1,33 +0,0 @@
package com.orangeforms.webadmin.app.dao;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.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 studentActionTransList 新增对象列表。
*/
void insertList(List<StudentActionTrans> studentActionTransList);
/**
* 获取过滤后的对象列表。
*
* @param studentActionTransFilter 主表过滤对象。
* @param orderBy 排序字符串order by从句的参数。
* @return 对象列表。
*/
List<StudentActionTrans> getStudentActionTransList(
@Param("studentActionTransFilter") StudentActionTrans studentActionTransFilter, @Param("orderBy") String orderBy);
}

View File

@@ -1,33 +0,0 @@
package com.orangeforms.webadmin.app.dao;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.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 studentClassList 新增对象列表。
*/
void insertList(List<StudentClass> studentClassList);
/**
* 获取过滤后的对象列表。
*
* @param studentClassFilter 主表过滤对象。
* @param orderBy 排序字符串order by从句的参数。
* @return 对象列表。
*/
List<StudentClass> getStudentClassList(
@Param("studentClassFilter") StudentClass studentClassFilter, @Param("orderBy") String orderBy);
}

View File

@@ -1,59 +0,0 @@
package com.orangeforms.webadmin.app.dao;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.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 studentList 新增对象列表。
*/
void insertList(List<Student> studentList);
/**
* 获取过滤后的对象列表。
*
* @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);
}

View File

@@ -1,10 +0,0 @@
<?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.orangeforms.webadmin.app.dao.AreaCodeMapper">
<resultMap id="BaseResultMap" type="com.orangeforms.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>

View File

@@ -1,22 +0,0 @@
<?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.orangeforms.webadmin.app.dao.ClassCourseMapper">
<resultMap id="BaseResultMap" type="com.orangeforms.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>
<insert id="insertList">
INSERT INTO zz_class_course
(class_id,
course_id,
course_order)
VALUES
<foreach collection="list" index="index" item="item" separator="," >
(#{item.classId},
#{item.courseId},
#{item.courseOrder})
</foreach>
</insert>
</mapper>

View File

@@ -1,19 +0,0 @@
<?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.orangeforms.webadmin.app.dao.ClassStudentMapper">
<resultMap id="BaseResultMap" type="com.orangeforms.webadmin.app.model.ClassStudent">
<id column="class_id" jdbcType="BIGINT" property="classId"/>
<id column="student_id" jdbcType="BIGINT" property="studentId"/>
</resultMap>
<insert id="insertList">
INSERT INTO zz_class_student
(class_id,
student_id)
VALUES
<foreach collection="list" index="index" item="item" separator="," >
(#{item.classId},
#{item.studentId})
</foreach>
</insert>
</mapper>

View File

@@ -1,139 +0,0 @@
<?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.orangeforms.webadmin.app.dao.CourseMapper">
<resultMap id="BaseResultMap" type="com.orangeforms.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.orangeforms.webadmin.app.model.Course" extends="BaseResultMap">
<association property="classCourse" column="course_id" foreignColumn="course_id"
notNullColumn="course_id" resultMap="com.orangeforms.webadmin.app.dao.ClassCourseMapper.BaseResultMap" />
</resultMap>
<insert id="insertList">
INSERT INTO zz_course
(course_id,
course_name,
price,
description,
difficulty,
grade_id,
subject_id,
class_hour,
picture_url,
create_user_id,
create_time,
update_time)
VALUES
<foreach collection="list" index="index" item="item" separator="," >
(#{item.courseId},
#{item.courseName},
#{item.price},
#{item.description},
#{item.difficulty},
#{item.gradeId},
#{item.subjectId},
#{item.classHour},
#{item.pictureUrl},
#{item.createUserId},
#{item.createTime},
#{item.updateTime})
</foreach>
</insert>
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
<sql id="filterRef">
<!-- 这里必须加上全包名否则当filterRef被其他Mapper.xml包含引用的时候就会调用Mapper.xml中的该SQL片段 -->
<include refid="com.orangeforms.webadmin.app.dao.CourseMapper.inputFilterRef"/>
</sql>
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
<sql id="inputFilterRef">
<if test="courseFilter != null">
<if test="courseFilter.courseName != null and courseFilter.courseName != ''">
<bind name = "safeCourseCourseName" value = "'%' + courseFilter.courseName + '%'" />
AND zz_course.course_name LIKE #{safeCourseCourseName}
</if>
<if test="courseFilter.priceStart != null">
AND zz_course.price &gt;= #{courseFilter.priceStart}
</if>
<if test="courseFilter.priceEnd != null">
AND zz_course.price &lt;= #{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 &gt;= #{courseFilter.classHourStart}
</if>
<if test="courseFilter.classHourEnd != null">
AND zz_course.class_hour &lt;= #{courseFilter.classHourEnd}
</if>
<if test="courseFilter.createTimeStart != null and courseFilter.createTimeStart != ''">
AND zz_course.create_time &gt;= #{courseFilter.createTimeStart}
</if>
<if test="courseFilter.createTimeEnd != null and courseFilter.createTimeEnd != ''">
AND zz_course.create_time &lt;= #{courseFilter.createTimeEnd}
</if>
</if>
</sql>
<select id="getCourseList" resultMap="BaseResultMap" parameterType="com.orangeforms.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>

View File

@@ -1,94 +0,0 @@
<?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.orangeforms.webadmin.app.dao.CourseTransStatsMapper">
<resultMap id="BaseResultMap" type="com.orangeforms.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>
<insert id="insertList">
INSERT INTO zz_course_trans_stats
(stats_id,
stats_date,
subject_id,
grade_id,
grade_name,
course_id,
course_name,
student_attend_count,
student_flower_amount,
student_flower_count)
VALUES
<foreach collection="list" index="index" item="item" separator="," >
(#{item.statsId},
#{item.statsDate},
#{item.subjectId},
#{item.gradeId},
#{item.gradeName},
#{item.courseId},
#{item.courseName},
#{item.studentAttendCount},
#{item.studentFlowerAmount},
#{item.studentFlowerCount})
</foreach>
</insert>
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
<sql id="filterRef">
<!-- 这里必须加上全包名否则当filterRef被其他Mapper.xml包含引用的时候就会调用Mapper.xml中的该SQL片段 -->
<include refid="com.orangeforms.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 &gt;= #{courseTransStatsFilter.statsDateStart}
</if>
<if test="courseTransStatsFilter.statsDateEnd != null and courseTransStatsFilter.statsDateEnd != ''">
AND zz_course_trans_stats.stats_date &lt;= #{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.orangeforms.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.orangeforms.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>

View File

@@ -1,22 +0,0 @@
<?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.orangeforms.webadmin.app.dao.GradeMapper">
<resultMap id="BaseResultMap" type="com.orangeforms.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>
<insert id="insertList">
INSERT INTO zz_grade
(grade_id,
grade_name,
status)
VALUES
<foreach collection="list" index="index" item="item" separator="," >
(#{item.gradeId},
#{item.gradeName},
#{item.status})
</foreach>
</insert>
</mapper>

View File

@@ -1,22 +0,0 @@
<?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.orangeforms.webadmin.app.dao.MaterialEditionMapper">
<resultMap id="BaseResultMap" type="com.orangeforms.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>
<insert id="insertList">
INSERT INTO zz_material_edition
(edition_id,
edition_name,
status)
VALUES
<foreach collection="list" index="index" item="item" separator="," >
(#{item.editionId},
#{item.editionName},
#{item.status})
</foreach>
</insert>
</mapper>

View File

@@ -1,142 +0,0 @@
<?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.orangeforms.webadmin.app.dao.StudentActionStatsMapper">
<resultMap id="BaseResultMap" type="com.orangeforms.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>
<insert id="insertList">
INSERT INTO zz_student_action_stats
(stats_id,
stats_date,
stats_month,
grade_id,
province_id,
city_id,
buy_course_amount,
buy_course_count,
buy_video_amount,
buy_video_count,
buy_paper_amount,
buy_paper_count,
buy_flower_amount,
buy_flower_count,
recharge_coin_amount,
recharge_coin_count,
do_course_count,
watch_video_count,
watch_video_total_second,
do_exercise_count,
do_exercise_correct_count)
VALUES
<foreach collection="list" index="index" item="item" separator="," >
(#{item.statsId},
#{item.statsDate},
#{item.statsMonth},
#{item.gradeId},
#{item.provinceId},
#{item.cityId},
#{item.buyCourseAmount},
#{item.buyCourseCount},
#{item.buyVideoAmount},
#{item.buyVideoCount},
#{item.buyPaperAmount},
#{item.buyPaperCount},
#{item.buyFlowerAmount},
#{item.buyFlowerCount},
#{item.rechargeCoinAmount},
#{item.rechargeCoinCount},
#{item.doCourseCount},
#{item.watchVideoCount},
#{item.watchVideoTotalSecond},
#{item.doExerciseCount},
#{item.doExerciseCorrectCount})
</foreach>
</insert>
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
<sql id="filterRef">
<!-- 这里必须加上全包名否则当filterRef被其他Mapper.xml包含引用的时候就会调用Mapper.xml中的该SQL片段 -->
<include refid="com.orangeforms.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 &gt;= #{studentActionStatsFilter.statsDateStart}
</if>
<if test="studentActionStatsFilter.statsDateEnd != null and studentActionStatsFilter.statsDateEnd != ''">
AND zz_student_action_stats.stats_date &lt;= #{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.orangeforms.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.orangeforms.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>

View File

@@ -1,101 +0,0 @@
<?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.orangeforms.webadmin.app.dao.StudentActionTransMapper">
<resultMap id="BaseResultMap" type="com.orangeforms.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>
<insert id="insertList">
INSERT INTO zz_student_action_trans
(trans_id,
student_id,
student_name,
school_id,
grade_id,
action_type,
device_type,
watch_video_seconds,
flower_count,
paper_count,
video_count,
course_count,
coin_count,
exercise_correct_flag,
create_time)
VALUES
<foreach collection="list" index="index" item="item" separator="," >
(#{item.transId},
#{item.studentId},
#{item.studentName},
#{item.schoolId},
#{item.gradeId},
#{item.actionType},
#{item.deviceType},
#{item.watchVideoSeconds},
#{item.flowerCount},
#{item.paperCount},
#{item.videoCount},
#{item.courseCount},
#{item.coinCount},
#{item.exerciseCorrectFlag},
#{item.createTime})
</foreach>
</insert>
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
<sql id="filterRef">
<!-- 这里必须加上全包名否则当filterRef被其他Mapper.xml包含引用的时候就会调用Mapper.xml中的该SQL片段 -->
<include refid="com.orangeforms.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 &gt;= #{studentActionTransFilter.createTimeStart}
</if>
<if test="studentActionTransFilter.createTimeEnd != null and studentActionTransFilter.createTimeEnd != ''">
AND zz_student_action_trans.create_time &lt;= #{studentActionTransFilter.createTimeEnd}
</if>
</if>
</sql>
<select id="getStudentActionTransList" resultMap="BaseResultMap" parameterType="com.orangeforms.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>

View File

@@ -1,72 +0,0 @@
<?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.orangeforms.webadmin.app.dao.StudentClassMapper">
<resultMap id="BaseResultMap" type="com.orangeforms.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>
<insert id="insertList">
INSERT INTO zz_class
(class_id,
class_name,
school_id,
leader_id,
finish_class_hour,
class_level,
create_user_id,
create_time,
status)
VALUES
<foreach collection="list" index="index" item="item" separator="," >
(#{item.classId},
#{item.className},
#{item.schoolId},
#{item.leaderId},
#{item.finishClassHour},
#{item.classLevel},
#{item.createUserId},
#{item.createTime},
#{item.status})
</foreach>
</insert>
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
<sql id="filterRef">
<!-- 这里必须加上全包名否则当filterRef被其他Mapper.xml包含引用的时候就会调用Mapper.xml中的该SQL片段 -->
<include refid="com.orangeforms.webadmin.app.dao.StudentClassMapper.inputFilterRef"/>
AND zz_class.status = ${@com.orangeforms.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.orangeforms.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>

View File

@@ -1,145 +0,0 @@
<?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.orangeforms.webadmin.app.dao.StudentMapper">
<resultMap id="BaseResultMap" type="com.orangeforms.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>
<insert id="insertList">
INSERT INTO zz_student
(student_id,
login_mobile,
student_name,
province_id,
city_id,
district_id,
gender,
birthday,
experience_level,
total_coin,
left_coin,
grade_id,
school_id,
register_time,
status)
VALUES
<foreach collection="list" index="index" item="item" separator="," >
(#{item.studentId},
#{item.loginMobile},
#{item.studentName},
#{item.provinceId},
#{item.cityId},
#{item.districtId},
#{item.gender},
#{item.birthday},
#{item.experienceLevel},
#{item.totalCoin},
#{item.leftCoin},
#{item.gradeId},
#{item.schoolId},
#{item.registerTime},
#{item.status})
</foreach>
</insert>
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
<sql id="filterRef">
<!-- 这里必须加上全包名否则当filterRef被其他Mapper.xml包含引用的时候就会调用Mapper.xml中的该SQL片段 -->
<include refid="com.orangeforms.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 &gt;= #{studentFilter.birthdayStart}
</if>
<if test="studentFilter.birthdayEnd != null and studentFilter.birthdayEnd != ''">
AND zz_student.birthday &lt;= #{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 &gt;= #{studentFilter.registerTimeStart}
</if>
<if test="studentFilter.registerTimeEnd != null and studentFilter.registerTimeEnd != ''">
AND zz_student.register_time &lt;= #{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 = "safeStudentSearchString" value = "'%' + studentFilter.searchString + '%'" />
AND CONCAT(IFNULL(zz_student.login_mobile,''), IFNULL(zz_student.student_name,'')) LIKE #{safeStudentSearchString}
</if>
</if>
</sql>
<select id="getStudentList" resultMap="BaseResultMap" parameterType="com.orangeforms.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>

View File

@@ -1,41 +0,0 @@
package com.orangeforms.webadmin.app.dto;
import com.orangeforms.common.core.validator.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
/**
* ClassCourseDto对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("ClassCourseDto对象")
@Data
public class ClassCourseDto {
/**
* 班级Id。
*/
@ApiModelProperty(value = "班级Id", required = true)
@NotNull(message = "数据验证失败班级Id不能为空", groups = {UpdateGroup.class})
private Long classId;
/**
* 课程Id。
*/
@ApiModelProperty(value = "课程Id", required = true)
@NotNull(message = "数据验证失败课程Id不能为空", groups = {UpdateGroup.class})
private Long courseId;
/**
* 课程顺序(数值越小越靠前)。
*/
@ApiModelProperty(value = "课程顺序(数值越小越靠前)", required = true)
@NotNull(message = "数据验证失败,课程顺序(数值越小越靠前)不能为空!", groups = {UpdateGroup.class})
private Integer courseOrder;
}

View File

@@ -1,34 +0,0 @@
package com.orangeforms.webadmin.app.dto;
import com.orangeforms.common.core.validator.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
/**
* ClassStudentDto对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("ClassStudentDto对象")
@Data
public class ClassStudentDto {
/**
* 班级Id。
*/
@ApiModelProperty(value = "班级Id", required = true)
@NotNull(message = "数据验证失败班级Id不能为空", groups = {UpdateGroup.class})
private Long classId;
/**
* 学生Id。
*/
@ApiModelProperty(value = "学生Id", required = true)
@NotNull(message = "数据验证失败学生Id不能为空", groups = {UpdateGroup.class})
private Long studentId;
}

View File

@@ -1,144 +0,0 @@
package com.orangeforms.webadmin.app.dto;
import com.orangeforms.common.core.validator.UpdateGroup;
import com.orangeforms.common.core.validator.ConstDictRef;
import com.orangeforms.webadmin.app.model.constant.CourseDifficult;
import com.orangeforms.application.common.constant.Subject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.util.Date;
/**
* CourseDto对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("CourseDto对象")
@Data
public class CourseDto {
/**
* 主键Id。
*/
@ApiModelProperty(value = "主键Id", required = true)
@NotNull(message = "数据验证失败主键Id不能为空", groups = {UpdateGroup.class})
private Long courseId;
/**
* 课程名称。
*/
@ApiModelProperty(value = "课程名称", required = true)
@NotBlank(message = "数据验证失败,课程名称不能为空!")
private String courseName;
/**
* 课程价格。
*/
@ApiModelProperty(value = "课程价格", required = true)
@NotNull(message = "数据验证失败,课程价格不能为空!")
private BigDecimal price;
/**
* 课程描述。
*/
@ApiModelProperty(value = "课程描述")
private String description;
/**
* 课程难度(0: 容易 1: 普通 2: 很难)。
*/
@ApiModelProperty(value = "课程难度(0: 容易 1: 普通 2: 很难)", required = true)
@NotNull(message = "数据验证失败,课程难度不能为空!")
@ConstDictRef(constDictClass = CourseDifficult.class, message = "数据验证失败,课程难度为无效值!")
private Integer difficulty;
/**
* 年级Id。
*/
@ApiModelProperty(value = "年级Id", required = true)
@NotNull(message = "数据验证失败,所属年级不能为空!")
private Integer gradeId;
/**
* 学科Id。
*/
@ApiModelProperty(value = "学科Id", required = true)
@NotNull(message = "数据验证失败,所属学科不能为空!")
@ConstDictRef(constDictClass = Subject.class, message = "数据验证失败,所属学科为无效值!")
private Integer subjectId;
/**
* 课时数量。
*/
@ApiModelProperty(value = "课时数量", required = true)
@NotNull(message = "数据验证失败,课时数量不能为空!")
private Integer classHour;
/**
* 多张课程图片地址。
*/
@ApiModelProperty(value = "多张课程图片地址", required = true)
@NotBlank(message = "数据验证失败,课程图片不能为空!")
private String pictureUrl;
/**
* 创建用户Id。
*/
@ApiModelProperty(value = "创建用户Id")
private Long createUserId;
/**
* 创建时间。
*/
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**
* 最后修改时间。
*/
@ApiModelProperty(value = "最后修改时间")
private Date updateTime;
/**
* price 范围过滤起始值(>=)。
*/
@ApiModelProperty(value = "price 范围过滤起始值(>=)")
private BigDecimal priceStart;
/**
* price 范围过滤结束值(<=)。
*/
@ApiModelProperty(value = "price 范围过滤结束值(<=)")
private BigDecimal priceEnd;
/**
* classHour 范围过滤起始值(>=)。
*/
@ApiModelProperty(value = "classHour 范围过滤起始值(>=)")
private Integer classHourStart;
/**
* classHour 范围过滤结束值(<=)。
*/
@ApiModelProperty(value = "classHour 范围过滤结束值(<=)")
private Integer classHourEnd;
/**
* createTime 范围过滤起始值(>=)。
*/
@ApiModelProperty(value = "createTime 范围过滤起始值(>=)")
private String createTimeStart;
/**
* createTime 范围过滤结束值(<=)。
*/
@ApiModelProperty(value = "createTime 范围过滤结束值(<=)")
private String createTimeEnd;
}

View File

@@ -1,105 +0,0 @@
package com.orangeforms.webadmin.app.dto;
import com.orangeforms.common.core.validator.UpdateGroup;
import com.orangeforms.common.core.validator.ConstDictRef;
import com.orangeforms.application.common.constant.Subject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
import java.util.Date;
/**
* CourseTransStatsDto对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("CourseTransStatsDto对象")
@Data
public class CourseTransStatsDto {
/**
* 主键Id。
*/
@ApiModelProperty(value = "主键Id", required = true)
@NotNull(message = "数据验证失败主键Id不能为空", groups = {UpdateGroup.class})
private Long statsId;
/**
* 统计日期。
*/
@ApiModelProperty(value = "统计日期", required = true)
@NotNull(message = "数据验证失败,统计日期不能为空!")
private Date statsDate;
/**
* 科目Id。
*/
@ApiModelProperty(value = "科目Id", required = true)
@NotNull(message = "数据验证失败,所属科目不能为空!")
@ConstDictRef(constDictClass = Subject.class, message = "数据验证失败,所属科目为无效值!")
private Integer subjectId;
/**
* 年级Id。
*/
@ApiModelProperty(value = "年级Id", required = true)
@NotNull(message = "数据验证失败,所属年级不能为空!")
private Integer gradeId;
/**
* 年级名称。
*/
@ApiModelProperty(value = "年级名称")
private String gradeName;
/**
* 课程Id。
*/
@ApiModelProperty(value = "课程Id", required = true)
@NotNull(message = "数据验证失败课程Id不能为空")
private Long courseId;
/**
* 课程名称。
*/
@ApiModelProperty(value = "课程名称")
private String courseName;
/**
* 学生上课次数。
*/
@ApiModelProperty(value = "学生上课次数", required = true)
@NotNull(message = "数据验证失败,上课次数不能为空!")
private Integer studentAttendCount;
/**
* 学生献花数量。
*/
@ApiModelProperty(value = "学生献花数量", required = true)
@NotNull(message = "数据验证失败,献花数量不能为空!")
private Integer studentFlowerAmount;
/**
* 学生献花次数。
*/
@ApiModelProperty(value = "学生献花次数", required = true)
@NotNull(message = "数据验证失败,献花次数不能为空!")
private Integer studentFlowerCount;
/**
* statsDate 范围过滤起始值(>=)。
*/
@ApiModelProperty(value = "statsDate 范围过滤起始值(>=)")
private String statsDateStart;
/**
* statsDate 范围过滤结束值(<=)。
*/
@ApiModelProperty(value = "statsDate 范围过滤结束值(<=)")
private String statsDateEnd;
}

View File

@@ -1,34 +0,0 @@
package com.orangeforms.webadmin.app.dto;
import com.orangeforms.common.core.validator.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
/**
* GradeDto对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("GradeDto对象")
@Data
public class GradeDto {
/**
* 主键Id。
*/
@ApiModelProperty(value = "主键Id", required = true)
@NotNull(message = "数据验证失败主键Id不能为空", groups = {UpdateGroup.class})
private Integer gradeId;
/**
* 年级名称。
*/
@ApiModelProperty(value = "年级名称", required = true)
@NotBlank(message = "数据验证失败,年级名称不能为空!")
private String gradeName;
}

View File

@@ -1,180 +0,0 @@
package com.orangeforms.webadmin.app.dto;
import com.orangeforms.common.core.validator.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
import java.util.Date;
/**
* StudentActionStatsDto对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("StudentActionStatsDto对象")
@Data
public class StudentActionStatsDto {
/**
* 主键Id。
*/
@ApiModelProperty(value = "主键Id", required = true)
@NotNull(message = "数据验证失败主键Id不能为空", groups = {UpdateGroup.class})
private Long statsId;
/**
* 统计日期。
*/
@ApiModelProperty(value = "统计日期", required = true)
@NotNull(message = "数据验证失败,统计日期不能为空!")
private Date statsDate;
/**
* 统计小时。
*/
@ApiModelProperty(value = "统计小时")
private Date statsMonth;
/**
* 年级Id。
*/
@ApiModelProperty(value = "年级Id", required = true)
@NotNull(message = "数据验证失败,所属年级不能为空!")
private Integer gradeId;
/**
* 学生所在省Id。
*/
@ApiModelProperty(value = "学生所在省Id", required = true)
@NotNull(message = "数据验证失败,所在省份不能为空!")
private Long provinceId;
/**
* 学生所在城市Id。
*/
@ApiModelProperty(value = "学生所在城市Id", required = true)
@NotNull(message = "数据验证失败,所在城市不能为空!", groups = {UpdateGroup.class})
private Long cityId;
/**
* 购课学币数量。
*/
@ApiModelProperty(value = "购课学币数量", required = true)
@NotNull(message = "数据验证失败,购课学币数量不能为空!", groups = {UpdateGroup.class})
private Integer buyCourseAmount;
/**
* 购买课程次数。
*/
@ApiModelProperty(value = "购买课程次数", required = true)
@NotNull(message = "数据验证失败,购买课程次数不能为空!", groups = {UpdateGroup.class})
private Integer buyCourseCount;
/**
* 购买视频学币数量。
*/
@ApiModelProperty(value = "购买视频学币数量", required = true)
@NotNull(message = "数据验证失败,购买视频学币数量不能为空!", groups = {UpdateGroup.class})
private Integer buyVideoAmount;
/**
* 购买视频次数。
*/
@ApiModelProperty(value = "购买视频次数", required = true)
@NotNull(message = "数据验证失败,购买视频次数不能为空!", groups = {UpdateGroup.class})
private Integer buyVideoCount;
/**
* 购买作业学币数量。
*/
@ApiModelProperty(value = "购买作业学币数量", required = true)
@NotNull(message = "数据验证失败,购买作业学币数量不能为空!", groups = {UpdateGroup.class})
private Integer buyPaperAmount;
/**
* 购买作业次数。
*/
@ApiModelProperty(value = "购买作业次数", required = true)
@NotNull(message = "数据验证失败,购买作业次数不能为空!", groups = {UpdateGroup.class})
private Integer buyPaperCount;
/**
* 购买献花数量。
*/
@ApiModelProperty(value = "购买献花数量", required = true)
@NotNull(message = "数据验证失败,购买献花数量不能为空!", groups = {UpdateGroup.class})
private Integer buyFlowerAmount;
/**
* 购买献花次数。
*/
@ApiModelProperty(value = "购买献花次数", required = true)
@NotNull(message = "数据验证失败,购买献花次数不能为空!", groups = {UpdateGroup.class})
private Integer buyFlowerCount;
/**
* 充值学币数量。
*/
@ApiModelProperty(value = "充值学币数量", required = true)
@NotNull(message = "数据验证失败,充值学币数量不能为空!", groups = {UpdateGroup.class})
private Integer rechargeCoinAmount;
/**
* 充值学币次数。
*/
@ApiModelProperty(value = "充值学币次数", required = true)
@NotNull(message = "数据验证失败,充值学币次数不能为空!", groups = {UpdateGroup.class})
private Integer rechargeCoinCount;
/**
* 线下课程上课次数。
*/
@ApiModelProperty(value = "线下课程上课次数", required = true)
@NotNull(message = "数据验证失败,线下课程上课次数不能为空!")
private Integer doCourseCount;
/**
* 观看视频次数。
*/
@ApiModelProperty(value = "观看视频次数", required = true)
@NotNull(message = "数据验证失败,观看视频次数不能为空!", groups = {UpdateGroup.class})
private Integer watchVideoCount;
/**
* 购买献花消费学币数量。
*/
@ApiModelProperty(value = "购买献花消费学币数量", required = true)
@NotNull(message = "数据验证失败,购买献花消费学币数量不能为空!")
private Integer watchVideoTotalSecond;
/**
* 做题数量。
*/
@ApiModelProperty(value = "做题数量", required = true)
@NotNull(message = "数据验证失败,做题数量不能为空!", groups = {UpdateGroup.class})
private Integer doExerciseCount;
/**
* 做题正确的数量。
*/
@ApiModelProperty(value = "做题正确的数量", required = true)
@NotNull(message = "数据验证失败,做题正确的数量不能为空!", groups = {UpdateGroup.class})
private Integer doExerciseCorrectCount;
/**
* statsDate 范围过滤起始值(>=)。
*/
@ApiModelProperty(value = "statsDate 范围过滤起始值(>=)")
private String statsDateStart;
/**
* statsDate 范围过滤结束值(<=)。
*/
@ApiModelProperty(value = "statsDate 范围过滤结束值(<=)")
private String statsDateEnd;
}

View File

@@ -1,136 +0,0 @@
package com.orangeforms.webadmin.app.dto;
import com.orangeforms.common.core.validator.UpdateGroup;
import com.orangeforms.common.core.validator.ConstDictRef;
import com.orangeforms.application.common.constant.StudentActionType;
import com.orangeforms.application.common.constant.DeviceType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
import java.util.Date;
/**
* StudentActionTransDto对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("StudentActionTransDto对象")
@Data
public class StudentActionTransDto {
/**
* 主键Id。
*/
@ApiModelProperty(value = "主键Id", required = true)
@NotNull(message = "数据验证失败主键Id不能为空", groups = {UpdateGroup.class})
private Long transId;
/**
* 学生Id。
*/
@ApiModelProperty(value = "学生Id", required = true)
@NotNull(message = "数据验证失败学生Id不能为空")
private Long studentId;
/**
* 学生名称。
*/
@ApiModelProperty(value = "学生名称", required = true)
@NotBlank(message = "数据验证失败,学生名称不能为空!")
private String studentName;
/**
* 学生校区。
*/
@ApiModelProperty(value = "学生校区", required = true)
@NotNull(message = "数据验证失败,学生校区不能为空!")
private Long schoolId;
/**
* 年级Id。
*/
@ApiModelProperty(value = "年级Id", required = true)
@NotNull(message = "数据验证失败,学生年级不能为空!")
private Integer gradeId;
/**
* 行为类型(0: 充值 1: 购课 2: 上课签到 3: 上课签退 4: 看视频课 5: 做作业 6: 刷题 7: 献花)。
*/
@ApiModelProperty(value = "行为类型(0: 充值 1: 购课 2: 上课签到 3: 上课签退 4: 看视频课 5: 做作业 6: 刷题 7: 献花)", required = true)
@NotNull(message = "数据验证失败,行为类型不能为空!")
@ConstDictRef(constDictClass = StudentActionType.class, message = "数据验证失败,行为类型为无效值!")
private Integer actionType;
/**
* 设备类型(0: iOS 1: Android 2: PC)。
*/
@ApiModelProperty(value = "设备类型(0: iOS 1: Android 2: PC)", required = true)
@NotNull(message = "数据验证失败,设备类型不能为空!")
@ConstDictRef(constDictClass = DeviceType.class, message = "数据验证失败,设备类型为无效值!")
private Integer deviceType;
/**
* 看视频秒数。
*/
@ApiModelProperty(value = "看视频秒数")
private Integer watchVideoSeconds;
/**
* 购买献花数量。
*/
@ApiModelProperty(value = "购买献花数量")
private Integer flowerCount;
/**
* 购买作业数量。
*/
@ApiModelProperty(value = "购买作业数量")
private Integer paperCount;
/**
* 购买视频数量。
*/
@ApiModelProperty(value = "购买视频数量")
private Integer videoCount;
/**
* 购买课程数量。
*/
@ApiModelProperty(value = "购买课程数量")
private Integer courseCount;
/**
* 充值学币数量。
*/
@ApiModelProperty(value = "充值学币数量")
private Integer coinCount;
/**
* 做题是否正确标记。
*/
@ApiModelProperty(value = "做题是否正确标记")
private Integer exerciseCorrectFlag;
/**
* 发生时间。
*/
@ApiModelProperty(value = "发生时间")
private Date createTime;
/**
* createTime 范围过滤起始值(>=)。
*/
@ApiModelProperty(value = "createTime 范围过滤起始值(>=)")
private String createTimeStart;
/**
* createTime 范围过滤结束值(<=)。
*/
@ApiModelProperty(value = "createTime 范围过滤结束值(<=)")
private String createTimeEnd;
}

View File

@@ -1,79 +0,0 @@
package com.orangeforms.webadmin.app.dto;
import com.orangeforms.common.core.validator.UpdateGroup;
import com.orangeforms.common.core.validator.ConstDictRef;
import com.orangeforms.webadmin.app.model.constant.ClassLevel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
import java.util.Date;
/**
* StudentClassDto对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("StudentClassDto对象")
@Data
public class StudentClassDto {
/**
* 班级Id。
*/
@ApiModelProperty(value = "班级Id", required = true)
@NotNull(message = "数据验证失败班级Id不能为空", groups = {UpdateGroup.class})
private Long classId;
/**
* 班级名称。
*/
@ApiModelProperty(value = "班级名称", required = true)
@NotBlank(message = "数据验证失败,班级名称不能为空!")
private String className;
/**
* 学校Id。
*/
@ApiModelProperty(value = "学校Id", required = true)
@NotNull(message = "数据验证失败,所属校区不能为空!")
private Long schoolId;
/**
* 学生班长Id。
*/
@ApiModelProperty(value = "学生班长Id", required = true)
@NotNull(message = "数据验证失败,学生班长不能为空!")
private Long leaderId;
/**
* 已完成课时数量。
*/
@ApiModelProperty(value = "已完成课时数量", required = true)
@NotNull(message = "数据验证失败,已完成课时不能为空!", groups = {UpdateGroup.class})
private Integer finishClassHour;
/**
* 班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)。
*/
@ApiModelProperty(value = "班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)", required = true)
@NotNull(message = "数据验证失败,班级级别不能为空!")
@ConstDictRef(constDictClass = ClassLevel.class, message = "数据验证失败,班级级别为无效值!")
private Integer classLevel;
/**
* 创建用户。
*/
@ApiModelProperty(value = "创建用户")
private Long createUserId;
/**
* 班级创建时间。
*/
@ApiModelProperty(value = "班级创建时间")
private Date createTime;
}

View File

@@ -1,162 +0,0 @@
package com.orangeforms.webadmin.app.dto;
import com.orangeforms.common.core.validator.UpdateGroup;
import com.orangeforms.common.core.validator.ConstDictRef;
import com.orangeforms.application.common.constant.Gender;
import com.orangeforms.application.common.constant.ExpLevel;
import com.orangeforms.application.common.constant.StudentStatus;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
import java.util.Date;
/**
* StudentDto对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("StudentDto对象")
@Data
public class StudentDto {
/**
* 学生Id。
*/
@ApiModelProperty(value = "学生Id", required = true)
@NotNull(message = "数据验证失败学生Id不能为空", groups = {UpdateGroup.class})
private Long studentId;
/**
* 登录手机。
*/
@ApiModelProperty(value = "登录手机", required = true)
@NotBlank(message = "数据验证失败,手机号码不能为空!")
private String loginMobile;
/**
* 学生姓名。
*/
@ApiModelProperty(value = "学生姓名", required = true)
@NotBlank(message = "数据验证失败,学生姓名不能为空!")
private String studentName;
/**
* 所在省份Id。
*/
@ApiModelProperty(value = "所在省份Id", required = true)
@NotNull(message = "数据验证失败,所在省份不能为空!")
private Long provinceId;
/**
* 所在城市Id。
*/
@ApiModelProperty(value = "所在城市Id", required = true)
@NotNull(message = "数据验证失败,所在城市不能为空!")
private Long cityId;
/**
* 区县Id。
*/
@ApiModelProperty(value = "区县Id", required = true)
@NotNull(message = "数据验证失败,所在区县不能为空!")
private Long districtId;
/**
* 学生性别 (0: 女生 1: 男生)。
*/
@ApiModelProperty(value = "学生性别 (0: 女生 1: 男生)", required = true)
@NotNull(message = "数据验证失败,学生性别不能为空!")
@ConstDictRef(constDictClass = Gender.class, message = "数据验证失败,学生性别为无效值!")
private Integer gender;
/**
* 生日。
*/
@ApiModelProperty(value = "生日", required = true)
@NotNull(message = "数据验证失败,出生日期不能为空!")
private Date birthday;
/**
* 经验等级 (0: 初级 1: 中级 2: 高级 3: 资深)。
*/
@ApiModelProperty(value = "经验等级 (0: 初级 1: 中级 2: 高级 3: 资深)", required = true)
@NotNull(message = "数据验证失败,经验等级不能为空!")
@ConstDictRef(constDictClass = ExpLevel.class, message = "数据验证失败,经验等级为无效值!")
private Integer experienceLevel;
/**
* 总共充值学币数量。
*/
@ApiModelProperty(value = "总共充值学币数量", required = true)
@NotNull(message = "数据验证失败,充值学币不能为空!", groups = {UpdateGroup.class})
private Integer totalCoin;
/**
* 可用学币数量。
*/
@ApiModelProperty(value = "可用学币数量")
private Integer leftCoin;
/**
* 年级Id。
*/
@ApiModelProperty(value = "年级Id", required = true)
@NotNull(message = "数据验证失败,年级不能为空!")
private Integer gradeId;
/**
* 校区Id。
*/
@ApiModelProperty(value = "校区Id", required = true)
@NotNull(message = "数据验证失败,所属校区不能为空!")
private Long schoolId;
/**
* 注册时间。
*/
@ApiModelProperty(value = "注册时间", required = true)
private Date registerTime;
/**
* 学生状态 (0: 正常 1: 锁定 2: 注销)。
*/
@ApiModelProperty(value = "学生状态 (0: 正常 1: 锁定 2: 注销)", required = true)
@NotNull(message = "数据验证失败,学生状态不能为空!", groups = {UpdateGroup.class})
@ConstDictRef(constDictClass = StudentStatus.class, message = "数据验证失败,学生状态为无效值!")
private Integer status;
/**
* birthday 范围过滤起始值(>=)。
*/
@ApiModelProperty(value = "birthday 范围过滤起始值(>=)")
private String birthdayStart;
/**
* birthday 范围过滤结束值(<=)。
*/
@ApiModelProperty(value = "birthday 范围过滤结束值(<=)")
private String birthdayEnd;
/**
* registerTime 范围过滤起始值(>=)。
*/
@ApiModelProperty(value = "registerTime 范围过滤起始值(>=)")
private String registerTimeStart;
/**
* registerTime 范围过滤结束值(<=)。
*/
@ApiModelProperty(value = "registerTime 范围过滤结束值(<=)")
private String registerTimeEnd;
/**
* login_mobile / student_name LIKE搜索字符串。
*/
@ApiModelProperty(value = "LIKE模糊搜索字符串")
private String searchString;
}

View File

@@ -1,39 +0,0 @@
package com.orangeforms.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
/**
* 行政区划实体对象。
*
* @author Jerry
* @date 2020-09-24
*/
@Data
@TableName(value = "zz_area_code")
public class AreaCode {
/**
* 行政区划主键Id
*/
@TableId(value = "area_id")
private Long areaId;
/**
* 行政区划名称
*/
@TableField(value = "area_name")
private String areaName;
/**
* 行政区划级别 (1: 省级别 2: 市级别 3: 区级别)
*/
@TableField(value = "area_level")
private Integer areaLevel;
/**
* 父级行政区划Id
*/
@TableField(value = "parent_id")
private Long parentId;
}

View File

@@ -1,33 +0,0 @@
package com.orangeforms.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
/**
* ClassCourse实体对象。
*
* @author Jerry
* @date 2020-09-24
*/
@Data
@TableName(value = "zz_class_course")
public class ClassCourse {
/**
* 班级Id。
*/
@TableField(value = "class_id")
private Long classId;
/**
* 课程Id。
*/
@TableField(value = "course_id")
private Long courseId;
/**
* 课程顺序(数值越小越靠前)。
*/
@TableField(value = "course_order")
private Integer courseOrder;
}

View File

@@ -1,27 +0,0 @@
package com.orangeforms.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
/**
* ClassStudent实体对象。
*
* @author Jerry
* @date 2020-09-24
*/
@Data
@TableName(value = "zz_class_student")
public class ClassStudent {
/**
* 班级Id。
*/
@TableField(value = "class_id")
private Long classId;
/**
* 学生Id。
*/
@TableField(value = "student_id")
private Long studentId;
}

View File

@@ -1,183 +0,0 @@
package com.orangeforms.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.*;
import com.orangeforms.webadmin.app.model.constant.CourseDifficult;
import com.orangeforms.application.common.constant.Subject;
import com.orangeforms.common.core.upload.UploadStoreTypeEnum;
import com.orangeforms.common.core.annotation.*;
import com.orangeforms.common.core.base.mapper.BaseModelMapper;
import com.orangeforms.webadmin.app.vo.CourseVo;
import lombok.Data;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;
/**
* Course实体对象。
*
* @author Jerry
* @date 2020-09-24
*/
@Data
@TableName(value = "zz_course")
public class Course {
/**
* 主键Id。
*/
@TableId(value = "course_id")
private Long courseId;
/**
* 课程名称。
*/
@TableField(value = "course_name")
private String courseName;
/**
* 课程价格。
*/
private BigDecimal price;
/**
* 课程描述。
*/
private String description;
/**
* 课程难度(0: 容易 1: 普通 2: 很难)。
*/
private Integer difficulty;
/**
* 年级Id。
*/
@TableField(value = "grade_id")
private Integer gradeId;
/**
* 学科Id。
*/
@TableField(value = "subject_id")
private Integer subjectId;
/**
* 课时数量。
*/
@TableField(value = "class_hour")
private Integer classHour;
/**
* 多张课程图片地址。
*/
@UploadFlagColumn(storeType = UploadStoreTypeEnum.LOCAL_SYSTEM)
@TableField(value = "picture_url")
private String pictureUrl;
/**
* 创建用户Id。
*/
@TableField(value = "create_user_id")
private Long createUserId;
/**
* 创建时间。
*/
@TableField(value = "create_time")
private Date createTime;
/**
* 最后修改时间。
*/
@TableField(value = "update_time")
private Date updateTime;
/**
* price 范围过滤起始值(>=)。
*/
@TableField(exist = false)
private BigDecimal priceStart;
/**
* price 范围过滤结束值(<=)。
*/
@TableField(exist = false)
private BigDecimal priceEnd;
/**
* classHour 范围过滤起始值(>=)。
*/
@TableField(exist = false)
private Integer classHourStart;
/**
* classHour 范围过滤结束值(<=)。
*/
@TableField(exist = false)
private Integer classHourEnd;
/**
* createTime 范围过滤起始值(>=)。
*/
@TableField(exist = false)
private String createTimeStart;
/**
* createTime 范围过滤结束值(<=)。
*/
@TableField(exist = false)
private String createTimeEnd;
/**
* courseId 的多对多关联表数据对象。
*/
@TableField(exist = false)
private ClassCourse classCourse;
@RelationDict(
masterIdField = "gradeId",
slaveServiceName = "gradeService",
slaveModelClass = Grade.class,
slaveIdField = "gradeId",
slaveNameField = "gradeName")
@TableField(exist = false)
private Map<String, Object> gradeIdDictMap;
@RelationConstDict(
masterIdField = "difficulty",
constantDictClass = CourseDifficult.class)
@TableField(exist = false)
private Map<String, Object> difficultyDictMap;
@RelationConstDict(
masterIdField = "subjectId",
constantDictClass = Subject.class)
@TableField(exist = false)
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.orangeforms.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);
}

View File

@@ -1,132 +0,0 @@
package com.orangeforms.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.*;
import com.orangeforms.application.common.constant.Subject;
import com.orangeforms.common.core.annotation.*;
import com.orangeforms.common.core.base.mapper.BaseModelMapper;
import com.orangeforms.webadmin.app.vo.CourseTransStatsVo;
import lombok.Data;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
import java.util.Date;
import java.util.Map;
/**
* CourseTransStats实体对象。
*
* @author Jerry
* @date 2020-09-24
*/
@Data
@TableName(value = "zz_course_trans_stats")
public class CourseTransStats {
/**
* 主键Id。
*/
@TableId(value = "stats_id", type = IdType.AUTO)
private Long statsId;
/**
* 统计日期。
*/
@TableField(value = "stats_date")
private Date statsDate;
/**
* 科目Id。
*/
@TableField(value = "subject_id")
private Integer subjectId;
/**
* 年级Id。
*/
@TableField(value = "grade_id")
private Integer gradeId;
/**
* 年级名称。
*/
@TableField(value = "grade_name")
private String gradeName;
/**
* 课程Id。
*/
@TableField(value = "course_id")
private Long courseId;
/**
* 课程名称。
*/
@TableField(value = "course_name")
private String courseName;
/**
* 学生上课次数。
*/
@TableField(value = "student_attend_count")
private Integer studentAttendCount;
/**
* 学生献花数量。
*/
@TableField(value = "student_flower_amount")
private Integer studentFlowerAmount;
/**
* 学生献花次数。
*/
@TableField(value = "student_flower_count")
private Integer studentFlowerCount;
/**
* statsDate 范围过滤起始值(>=)。
*/
@TableField(exist = false)
private String statsDateStart;
/**
* statsDate 范围过滤结束值(<=)。
*/
@TableField(exist = false)
private String statsDateEnd;
@RelationDict(
masterIdField = "gradeId",
slaveServiceName = "gradeService",
slaveModelClass = Grade.class,
slaveIdField = "gradeId",
slaveNameField = "gradeName")
@TableField(exist = false)
private Map<String, Object> gradeIdDictMap;
@RelationConstDict(
masterIdField = "subjectId",
constantDictClass = Subject.class)
@TableField(exist = false)
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);
}

View File

@@ -1,33 +0,0 @@
package com.orangeforms.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
/**
* Grade实体对象。
*
* @author Jerry
* @date 2020-09-24
*/
@Data
@TableName(value = "zz_grade")
public class Grade {
/**
* 主键Id。
*/
@TableId(value = "grade_id", type = IdType.AUTO)
private Integer gradeId;
/**
* 年级名称。
*/
@TableField(value = "grade_name")
private String gradeName;
/**
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
*/
@TableLogic
private Integer status;
}

View File

@@ -1,32 +0,0 @@
package com.orangeforms.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
/**
* MaterialEdition实体对象。
*
* @author Jerry
* @date 2020-09-24
*/
@Data
@TableName(value = "zz_material_edition")
public class MaterialEdition {
/**
* 主键Id。
*/
@TableId(value = "edition_id", type = IdType.AUTO)
private Integer editionId;
/**
* 教材版本名称。
*/
@TableField(value = "edition_name")
private String editionName;
/**
* 是否正在使用0不是1
*/
private Integer status;
}

View File

@@ -1,233 +0,0 @@
package com.orangeforms.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.*;
import com.orangeforms.webadmin.upms.model.SysDept;
import com.orangeforms.application.common.constant.Gender;
import com.orangeforms.application.common.constant.ExpLevel;
import com.orangeforms.application.common.constant.StudentStatus;
import com.orangeforms.common.core.util.MyCommonUtil;
import com.orangeforms.common.core.annotation.*;
import com.orangeforms.common.core.base.mapper.BaseModelMapper;
import com.orangeforms.webadmin.app.vo.StudentVo;
import lombok.Data;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
import java.util.Date;
import java.util.Map;
/**
* Student实体对象。
*
* @author Jerry
* @date 2020-09-24
*/
@Data
@TableName(value = "zz_student")
public class Student {
/**
* 学生Id。
*/
@TableId(value = "student_id")
private Long studentId;
/**
* 登录手机。
*/
@TableField(value = "login_mobile")
private String loginMobile;
/**
* 学生姓名。
*/
@TableField(value = "student_name")
private String studentName;
/**
* 所在省份Id。
*/
@TableField(value = "province_id")
private Long provinceId;
/**
* 所在城市Id。
*/
@TableField(value = "city_id")
private Long cityId;
/**
* 区县Id。
*/
@TableField(value = "district_id")
private Long districtId;
/**
* 学生性别 (0: 女生 1: 男生)。
*/
private Integer gender;
/**
* 生日。
*/
private Date birthday;
/**
* 经验等级 (0: 初级 1: 中级 2: 高级 3: 资深)。
*/
@TableField(value = "experience_level")
private Integer experienceLevel;
/**
* 总共充值学币数量。
*/
@TableField(value = "total_coin")
private Integer totalCoin;
/**
* 可用学币数量。
*/
@TableField(value = "left_coin")
private Integer leftCoin;
/**
* 年级Id。
*/
@TableField(value = "grade_id")
private Integer gradeId;
/**
* 校区Id。
*/
@TableField(value = "school_id")
private Long schoolId;
/**
* 注册时间。
*/
@TableField(value = "register_time")
private Date registerTime;
/**
* 学生状态 (0: 正常 1: 锁定 2: 注销)。
*/
private Integer status;
/**
* birthday 范围过滤起始值(>=)。
*/
@TableField(exist = false)
private String birthdayStart;
/**
* birthday 范围过滤结束值(<=)。
*/
@TableField(exist = false)
private String birthdayEnd;
/**
* registerTime 范围过滤起始值(>=)。
*/
@TableField(exist = false)
private String registerTimeStart;
/**
* registerTime 范围过滤结束值(<=)。
*/
@TableField(exist = false)
private String registerTimeEnd;
/**
* login_mobile / student_name LIKE搜索字符串。
*/
@TableField(exist = false)
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")
@TableField(exist = false)
private Map<String, Object> provinceIdDictMap;
@RelationDict(
masterIdField = "cityId",
slaveServiceName = "areaCodeService",
slaveModelClass = AreaCode.class,
slaveIdField = "areaId",
slaveNameField = "areaName")
@TableField(exist = false)
private Map<String, Object> cityIdDictMap;
@RelationDict(
masterIdField = "districtId",
slaveServiceName = "areaCodeService",
slaveModelClass = AreaCode.class,
slaveIdField = "areaId",
slaveNameField = "areaName")
@TableField(exist = false)
private Map<String, Object> districtIdDictMap;
@RelationDict(
masterIdField = "gradeId",
slaveServiceName = "gradeService",
slaveModelClass = Grade.class,
slaveIdField = "gradeId",
slaveNameField = "gradeName")
@TableField(exist = false)
private Map<String, Object> gradeIdDictMap;
@RelationDict(
masterIdField = "schoolId",
slaveServiceName = "sysDeptService",
slaveModelClass = SysDept.class,
slaveIdField = "deptId",
slaveNameField = "deptName")
@TableField(exist = false)
private Map<String, Object> schoolIdDictMap;
@RelationConstDict(
masterIdField = "gender",
constantDictClass = Gender.class)
@TableField(exist = false)
private Map<String, Object> genderDictMap;
@RelationConstDict(
masterIdField = "experienceLevel",
constantDictClass = ExpLevel.class)
@TableField(exist = false)
private Map<String, Object> experienceLevelDictMap;
@RelationConstDict(
masterIdField = "status",
constantDictClass = StudentStatus.class)
@TableField(exist = false)
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);
}

View File

@@ -1,209 +0,0 @@
package com.orangeforms.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.*;
import com.orangeforms.common.core.annotation.*;
import com.orangeforms.common.core.base.mapper.BaseModelMapper;
import com.orangeforms.webadmin.app.vo.StudentActionStatsVo;
import lombok.Data;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
import java.util.Date;
import java.util.Map;
/**
* StudentActionStats实体对象。
*
* @author Jerry
* @date 2020-09-24
*/
@Data
@TableName(value = "zz_student_action_stats")
public class StudentActionStats {
/**
* 主键Id。
*/
@TableId(value = "stats_id")
private Long statsId;
/**
* 统计日期。
*/
@TableField(value = "stats_date")
private Date statsDate;
/**
* 统计小时。
*/
@TableField(value = "stats_month")
private Date statsMonth;
/**
* 年级Id。
*/
@TableField(value = "grade_id")
private Integer gradeId;
/**
* 学生所在省Id。
*/
@TableField(value = "province_id")
private Long provinceId;
/**
* 学生所在城市Id。
*/
@TableField(value = "city_id")
private Long cityId;
/**
* 购课学币数量。
*/
@TableField(value = "buy_course_amount")
private Integer buyCourseAmount;
/**
* 购买课程次数。
*/
@TableField(value = "buy_course_count")
private Integer buyCourseCount;
/**
* 购买视频学币数量。
*/
@TableField(value = "buy_video_amount")
private Integer buyVideoAmount;
/**
* 购买视频次数。
*/
@TableField(value = "buy_video_count")
private Integer buyVideoCount;
/**
* 购买作业学币数量。
*/
@TableField(value = "buy_paper_amount")
private Integer buyPaperAmount;
/**
* 购买作业次数。
*/
@TableField(value = "buy_paper_count")
private Integer buyPaperCount;
/**
* 购买献花数量。
*/
@TableField(value = "buy_flower_amount")
private Integer buyFlowerAmount;
/**
* 购买献花次数。
*/
@TableField(value = "buy_flower_count")
private Integer buyFlowerCount;
/**
* 充值学币数量。
*/
@TableField(value = "recharge_coin_amount")
private Integer rechargeCoinAmount;
/**
* 充值学币次数。
*/
@TableField(value = "recharge_coin_count")
private Integer rechargeCoinCount;
/**
* 线下课程上课次数。
*/
@TableField(value = "do_course_count")
private Integer doCourseCount;
/**
* 观看视频次数。
*/
@TableField(value = "watch_video_count")
private Integer watchVideoCount;
/**
* 购买献花消费学币数量。
*/
@TableField(value = "watch_video_total_second")
private Integer watchVideoTotalSecond;
/**
* 做题数量。
*/
@TableField(value = "do_exercise_count")
private Integer doExerciseCount;
/**
* 做题正确的数量。
*/
@TableField(value = "do_exercise_correct_count")
private Integer doExerciseCorrectCount;
/**
* statsDate 范围过滤起始值(>=)。
*/
@TableField(exist = false)
private String statsDateStart;
/**
* statsDate 范围过滤结束值(<=)。
*/
@TableField(exist = false)
private String statsDateEnd;
@RelationDict(
masterIdField = "gradeId",
slaveServiceName = "gradeService",
slaveModelClass = Grade.class,
slaveIdField = "gradeId",
slaveNameField = "gradeName")
@TableField(exist = false)
private Map<String, Object> gradeIdDictMap;
@RelationDict(
masterIdField = "provinceId",
slaveServiceName = "areaCodeService",
slaveModelClass = AreaCode.class,
slaveIdField = "areaId",
slaveNameField = "areaName")
@TableField(exist = false)
private Map<String, Object> provinceIdDictMap;
@RelationDict(
masterIdField = "cityId",
slaveServiceName = "areaCodeService",
slaveModelClass = AreaCode.class,
slaveIdField = "areaId",
slaveNameField = "areaName")
@TableField(exist = false)
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);
}

View File

@@ -1,179 +0,0 @@
package com.orangeforms.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.*;
import com.orangeforms.webadmin.upms.model.SysDept;
import com.orangeforms.application.common.constant.StudentActionType;
import com.orangeforms.application.common.constant.DeviceType;
import com.orangeforms.common.core.annotation.*;
import com.orangeforms.common.core.base.mapper.BaseModelMapper;
import com.orangeforms.webadmin.app.vo.StudentActionTransVo;
import lombok.Data;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
import java.util.Date;
import java.util.Map;
/**
* StudentActionTrans实体对象。
*
* @author Jerry
* @date 2020-09-24
*/
@Data
@TableName(value = "zz_student_action_trans")
public class StudentActionTrans {
/**
* 主键Id。
*/
@TableId(value = "trans_id")
private Long transId;
/**
* 学生Id。
*/
@TableField(value = "student_id")
private Long studentId;
/**
* 学生名称。
*/
@TableField(value = "student_name")
private String studentName;
/**
* 学生校区。
*/
@TableField(value = "school_id")
private Long schoolId;
/**
* 年级Id。
*/
@TableField(value = "grade_id")
private Integer gradeId;
/**
* 行为类型(0: 充值 1: 购课 2: 上课签到 3: 上课签退 4: 看视频课 5: 做作业 6: 刷题 7: 献花)。
*/
@TableField(value = "action_type")
private Integer actionType;
/**
* 设备类型(0: iOS 1: Android 2: PC)。
*/
@TableField(value = "device_type")
private Integer deviceType;
/**
* 看视频秒数。
*/
@TableField(value = "watch_video_seconds")
private Integer watchVideoSeconds;
/**
* 购买献花数量。
*/
@TableField(value = "flower_count")
private Integer flowerCount;
/**
* 购买作业数量。
*/
@TableField(value = "paper_count")
private Integer paperCount;
/**
* 购买视频数量。
*/
@TableField(value = "video_count")
private Integer videoCount;
/**
* 购买课程数量。
*/
@TableField(value = "course_count")
private Integer courseCount;
/**
* 充值学币数量。
*/
@TableField(value = "coin_count")
private Integer coinCount;
/**
* 做题是否正确标记。
*/
@TableField(value = "exercise_correct_flag")
private Integer exerciseCorrectFlag;
/**
* 发生时间。
*/
@TableField(value = "create_time")
private Date createTime;
/**
* createTime 范围过滤起始值(>=)。
*/
@TableField(exist = false)
private String createTimeStart;
/**
* createTime 范围过滤结束值(<=)。
*/
@TableField(exist = false)
private String createTimeEnd;
@RelationDict(
masterIdField = "schoolId",
slaveServiceName = "sysDeptService",
slaveModelClass = SysDept.class,
slaveIdField = "deptId",
slaveNameField = "deptName")
@TableField(exist = false)
private Map<String, Object> schoolIdDictMap;
@RelationDict(
masterIdField = "gradeId",
slaveServiceName = "gradeService",
slaveModelClass = Grade.class,
slaveIdField = "gradeId",
slaveNameField = "gradeName")
@TableField(exist = false)
private Map<String, Object> gradeIdDictMap;
@RelationConstDict(
masterIdField = "actionType",
constantDictClass = StudentActionType.class)
@TableField(exist = false)
private Map<String, Object> actionTypeDictMap;
@RelationConstDict(
masterIdField = "deviceType",
constantDictClass = DeviceType.class)
@TableField(exist = false)
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);
}

View File

@@ -1,124 +0,0 @@
package com.orangeforms.webadmin.app.model;
import com.baomidou.mybatisplus.annotation.*;
import com.orangeforms.webadmin.upms.model.SysDept;
import com.orangeforms.webadmin.app.model.constant.ClassLevel;
import com.orangeforms.common.core.annotation.*;
import com.orangeforms.common.core.base.mapper.BaseModelMapper;
import com.orangeforms.webadmin.app.vo.StudentClassVo;
import lombok.Data;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
import java.util.Date;
import java.util.Map;
/**
* StudentClass实体对象。
*
* @author Jerry
* @date 2020-09-24
*/
@Data
@TableName(value = "zz_class")
public class StudentClass {
/**
* 班级Id。
*/
@TableId(value = "class_id")
private Long classId;
/**
* 班级名称。
*/
@TableField(value = "class_name")
private String className;
/**
* 学校Id。
*/
@TableField(value = "school_id")
private Long schoolId;
/**
* 学生班长Id。
*/
@TableField(value = "leader_id")
private Long leaderId;
/**
* 已完成课时数量。
*/
@TableField(value = "finish_class_hour")
private Integer finishClassHour;
/**
* 班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)。
*/
@TableField(value = "class_level")
private Integer classLevel;
/**
* 创建用户。
*/
@TableField(value = "create_user_id")
private Long createUserId;
/**
* 班级创建时间。
*/
@TableField(value = "create_time")
private Date createTime;
/**
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
*/
@TableLogic
private Integer status;
@RelationDict(
masterIdField = "schoolId",
slaveServiceName = "sysDeptService",
slaveModelClass = SysDept.class,
slaveIdField = "deptId",
slaveNameField = "deptName")
@TableField(exist = false)
private Map<String, Object> schoolIdDictMap;
@RelationDict(
masterIdField = "leaderId",
slaveServiceName = "studentService",
slaveModelClass = Student.class,
slaveIdField = "studentId",
slaveNameField = "studentName")
@TableField(exist = false)
private Map<String, Object> leaderIdDictMap;
@RelationConstDict(
masterIdField = "classLevel",
constantDictClass = ClassLevel.class)
@TableField(exist = false)
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);
}

View File

@@ -1,49 +0,0 @@
package com.orangeforms.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() {
}
}

View File

@@ -1,44 +0,0 @@
package com.orangeforms.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() {
}
}

View File

@@ -1,49 +0,0 @@
package com.orangeforms.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() {
}
}

View File

@@ -1,23 +0,0 @@
package com.orangeforms.webadmin.app.service;
import com.orangeforms.common.core.base.service.IBaseDictService;
import com.orangeforms.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);
}

View File

@@ -1,88 +0,0 @@
package com.orangeforms.webadmin.app.service;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.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);
/**
* 利用数据库的insertList语法批量插入对象列表。
*
* @param courseList 新增对象列表。
*/
void saveNewBatch(List<Course> courseList);
/**
* 更新数据对象。
*
* @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);
}

View File

@@ -1,48 +0,0 @@
package com.orangeforms.webadmin.app.service;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.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);
}

View File

@@ -1,13 +0,0 @@
package com.orangeforms.webadmin.app.service;
import com.orangeforms.common.core.base.service.IBaseDictService;
import com.orangeforms.webadmin.app.model.Grade;
/**
* 年级字典数据操作服务接口。
*
* @author Jerry
* @date 2020-09-24
*/
public interface GradeService extends IBaseDictService<Grade, Integer> {
}

View File

@@ -1,48 +0,0 @@
package com.orangeforms.webadmin.app.service;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.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);
}

View File

@@ -1,68 +0,0 @@
package com.orangeforms.webadmin.app.service;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.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);
/**
* 利用数据库的insertList语法批量插入对象列表。
*
* @param studentActionTransList 新增对象列表。
*/
void saveNewBatch(List<StudentActionTrans> studentActionTransList);
/**
* 更新数据对象。
*
* @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);
}

View File

@@ -1,119 +0,0 @@
package com.orangeforms.webadmin.app.service;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.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);
/**
* 利用数据库的insertList语法批量插入对象列表。
*
* @param studentClassList 新增对象列表。
*/
void saveNewBatch(List<StudentClass> studentClassList);
/**
* 更新数据对象。
*
* @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);
}

View File

@@ -1,88 +0,0 @@
package com.orangeforms.webadmin.app.service;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.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);
/**
* 利用数据库的insertList语法批量插入对象列表。
*
* @param studentList 新增对象列表。
*/
void saveNewBatch(List<Student> studentList);
/**
* 更新数据对象。
*
* @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);
}

View File

@@ -1,52 +0,0 @@
package com.orangeforms.webadmin.app.service.impl;
import com.orangeforms.webadmin.app.service.AreaCodeService;
import com.orangeforms.webadmin.app.dao.AreaCodeMapper;
import com.orangeforms.webadmin.app.model.AreaCode;
import com.orangeforms.common.core.cache.MapTreeDictionaryCache;
import com.orangeforms.common.core.base.service.BaseDictService;
import com.orangeforms.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);
}
}

View File

@@ -1,211 +0,0 @@
package com.orangeforms.webadmin.app.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.*;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.orangeforms.webadmin.app.service.*;
import com.orangeforms.webadmin.app.dao.*;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.common.core.object.TokenData;
import com.orangeforms.common.core.object.MyRelationParam;
import com.orangeforms.common.core.object.CallResult;
import com.orangeforms.common.core.base.service.BaseService;
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j;
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
*/
@Slf4j
@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) {
courseMapper.insert(this.buildDefaultValue(course));
return course;
}
/**
* 利用数据库的insertList语法批量插入对象列表。
*
* @param courseList 新增对象列表。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void saveNewBatch(List<Course> courseList) {
if (CollUtil.isNotEmpty(courseList)) {
courseList.forEach(this::buildDefaultValue);
courseMapper.insertList(courseList);
}
}
/**
* 更新数据对象。
*
* @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());
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
UpdateWrapper<Course> uw = this.createUpdateQueryForNullValue(course, course.getCourseId());
return courseMapper.update(course, uw) == 1;
}
/**
* 删除指定数据。
*
* @param courseId 主键Id。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean remove(Long courseId) {
if (courseMapper.deleteById(courseId) == 0) {
return false;
}
// 开始删除多对多父表的关联
ClassCourse classCourse = new ClassCourse();
classCourse.setCourseId(courseId);
classCourseMapper.delete(new QueryWrapper<>(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);
// 在缺省生成的代码中如果查询结果resultList不是Page对象说明没有分页那么就很可能是数据导出接口调用了当前方法。
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
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;
if (classId != null) {
resultList = courseMapper.getNotInCourseListByClassId(classId, filter, orderBy);
} else {
resultList = getCourseList(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();
}
private Course buildDefaultValue(Course course) {
course.setCourseId(idGenerator.nextLongId());
TokenData tokenData = TokenData.takeFromRequest();
course.setCreateUserId(tokenData.getUserId());
Date now = new Date();
course.setCreateTime(now);
course.setUpdateTime(now);
return course;
}
}

View File

@@ -1,95 +0,0 @@
package com.orangeforms.webadmin.app.service.impl;
import com.orangeforms.webadmin.app.service.*;
import com.orangeforms.webadmin.app.dao.*;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.common.core.object.MyRelationParam;
import com.orangeforms.common.core.base.service.BaseService;
import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* 课程统计数据操作服务类。
*
* @author Jerry
* @date 2020-09-24
*/
@Slf4j
@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);
// 在缺省生成的代码中如果查询结果resultList不是Page对象说明没有分页那么就很可能是数据导出接口调用了当前方法。
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
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);
// 在缺省生成的代码中如果查询结果resultList不是Page对象说明没有分页那么就很可能是数据导出接口调用了当前方法。
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
int batchSize = resultList instanceof Page ? 0 : 1000;
// NOTE: 这里只是包含了关联数据,聚合计算数据没有包含。
// 主要原因是由于聚合字段通常被视为普通字段使用不会在group by的从句中出现语义上也不会在此关联。
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
return resultList;
}
}

View File

@@ -1,49 +0,0 @@
package com.orangeforms.webadmin.app.service.impl;
import com.orangeforms.common.core.base.service.BaseDictService;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.common.redis.cache.RedisDictionaryCache;
import com.orangeforms.webadmin.app.service.GradeService;
import com.orangeforms.webadmin.app.dao.GradeMapper;
import com.orangeforms.webadmin.app.model.Grade;
import lombok.extern.slf4j.Slf4j;
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
*/
@Slf4j
@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;
}
}

View File

@@ -1,97 +0,0 @@
package com.orangeforms.webadmin.app.service.impl;
import com.orangeforms.webadmin.app.service.*;
import com.orangeforms.webadmin.app.dao.*;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.common.core.object.MyRelationParam;
import com.orangeforms.common.core.base.service.BaseService;
import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* 学生行为统计数据操作服务类。
*
* @author Jerry
* @date 2020-09-24
*/
@Slf4j
@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);
// 在缺省生成的代码中如果查询结果resultList不是Page对象说明没有分页那么就很可能是数据导出接口调用了当前方法。
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
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);
// 在缺省生成的代码中如果查询结果resultList不是Page对象说明没有分页那么就很可能是数据导出接口调用了当前方法。
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
int batchSize = resultList instanceof Page ? 0 : 1000;
// NOTE: 这里只是包含了关联数据,聚合计算数据没有包含。
// 主要原因是由于聚合字段通常被视为普通字段使用不会在group by的从句中出现语义上也不会在此关联。
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
return resultList;
}
}

View File

@@ -1,164 +0,0 @@
package com.orangeforms.webadmin.app.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.orangeforms.webadmin.app.service.*;
import com.orangeforms.webadmin.app.dao.*;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.webadmin.upms.service.SysDeptService;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.common.core.object.MyRelationParam;
import com.orangeforms.common.core.object.CallResult;
import com.orangeforms.common.core.base.service.BaseService;
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j;
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
*/
@Slf4j
@Service("studentActionTransService")
public class StudentActionTransServiceImpl extends BaseService<StudentActionTrans, Long> implements StudentActionTransService {
@Autowired
private StudentActionTransMapper studentActionTransMapper;
@Autowired
private SysDeptService sysDeptService;
@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) {
studentActionTransMapper.insert(this.buildDefaultValue(studentActionTrans));
return studentActionTrans;
}
/**
* 利用数据库的insertList语法批量插入对象列表。
*
* @param studentActionTransList 新增对象列表。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void saveNewBatch(List<StudentActionTrans> studentActionTransList) {
if (CollUtil.isNotEmpty(studentActionTransList)) {
studentActionTransList.forEach(this::buildDefaultValue);
studentActionTransMapper.insertList(studentActionTransList);
}
}
/**
* 更新数据对象。
*
* @param studentActionTrans 更新的对象。
* @param originalStudentActionTrans 原有数据对象。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean update(StudentActionTrans studentActionTrans, StudentActionTrans originalStudentActionTrans) {
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
UpdateWrapper<StudentActionTrans> uw = this.createUpdateQueryForNullValue(studentActionTrans, studentActionTrans.getTransId());
return studentActionTransMapper.update(studentActionTrans, uw) == 1;
}
/**
* 删除指定数据。
*
* @param transId 主键Id。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean remove(Long transId) {
return studentActionTransMapper.deleteById(transId) == 1;
}
/**
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(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);
// 在缺省生成的代码中如果查询结果resultList不是Page对象说明没有分页那么就很可能是数据导出接口调用了当前方法。
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
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)
&& !sysDeptService.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();
}
private StudentActionTrans buildDefaultValue(StudentActionTrans studentActionTrans) {
studentActionTrans.setTransId(idGenerator.nextLongId());
return studentActionTrans;
}
}

View File

@@ -1,285 +0,0 @@
package com.orangeforms.webadmin.app.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.*;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.orangeforms.webadmin.app.service.*;
import com.orangeforms.webadmin.app.dao.*;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.webadmin.upms.service.SysDeptService;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.common.core.constant.GlobalDeletedFlag;
import com.orangeforms.common.core.object.TokenData;
import com.orangeforms.common.core.object.MyRelationParam;
import com.orangeforms.common.core.object.CallResult;
import com.orangeforms.common.core.base.service.BaseService;
import com.orangeforms.common.core.util.MyModelUtil;
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j;
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
*/
@Slf4j
@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 SysDeptService sysDeptService;
@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) {
studentClassMapper.insert(this.buildDefaultValue(studentClass));
return studentClass;
}
/**
* 利用数据库的insertList语法批量插入对象列表。
*
* @param studentClassList 新增对象列表。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void saveNewBatch(List<StudentClass> studentClassList) {
if (CollUtil.isNotEmpty(studentClassList)) {
studentClassList.forEach(this::buildDefaultValue);
studentClassMapper.insertList(studentClassList);
}
}
/**
* 更新数据对象。
*
* @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());
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
UpdateWrapper<StudentClass> uw = this.createUpdateQueryForNullValue(studentClass, studentClass.getClassId());
return studentClassMapper.update(studentClass, uw) == 1;
}
/**
* 删除指定数据。
*
* @param classId 主键Id。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean remove(Long classId) {
if (studentClassMapper.deleteById(classId) == 0) {
return false;
}
// 开始删除多对多子表的关联
ClassCourse classCourse = new ClassCourse();
classCourse.setClassId(classId);
classCourseMapper.delete(new QueryWrapper<>(classCourse));
ClassStudent classStudent = new ClassStudent();
classStudent.setClassId(classId);
classStudentMapper.delete(new QueryWrapper<>(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);
// 在缺省生成的代码中如果查询结果resultList不是Page对象说明没有分页那么就很可能是数据导出接口调用了当前方法。
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
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.insert(classCourse);
}
}
/**
* 更新中间表数据。
*
* @param classCourse 中间表对象。
* @return 更新成功与否。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateClassCourse(ClassCourse classCourse) {
ClassCourse filter = new ClassCourse();
filter.setClassId(classCourse.getClassId());
filter.setCourseId(classCourse.getCourseId());
UpdateWrapper<ClassCourse> uw =
BaseService.createUpdateQueryForNullValue(classCourse, ClassCourse.class);
uw.setEntity(filter);
return classCourseMapper.update(classCourse, uw) > 0;
}
/**
* 获取中间表数据。
*
* @param classId 主表Id。
* @param courseId 从表Id。
* @return 中间表对象。
*/
@Override
public ClassCourse getClassCourse(Long classId, Long courseId) {
ClassCourse filter = new ClassCourse();
filter.setClassId(classId);
filter.setCourseId(courseId);
return classCourseMapper.selectOne(new QueryWrapper<>(filter));
}
/**
* 移除单条多对多关系。
*
* @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(new QueryWrapper<>(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.insert(classStudent);
}
}
/**
* 移除单条多对多关系。
*
* @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(new QueryWrapper<>(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)
&& !sysDeptService.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();
}
private StudentClass buildDefaultValue(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);
return studentClass;
}
}

View File

@@ -1,234 +0,0 @@
package com.orangeforms.webadmin.app.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.*;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.orangeforms.application.common.constant.StudentStatus;
import com.orangeforms.webadmin.app.service.*;
import com.orangeforms.webadmin.app.dao.*;
import com.orangeforms.webadmin.app.model.*;
import com.orangeforms.webadmin.upms.service.SysDeptService;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.common.core.object.MyRelationParam;
import com.orangeforms.common.core.object.CallResult;
import com.orangeforms.common.core.base.service.BaseService;
import com.orangeforms.common.core.util.MyModelUtil;
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j;
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
*/
@Slf4j
@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 SysDeptService sysDeptService;
@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) {
studentMapper.insert(this.buildDefaultValue(student));
return student;
}
/**
* 利用数据库的insertList语法批量插入对象列表。
*
* @param studentList 新增对象列表。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void saveNewBatch(List<Student> studentList) {
if (CollUtil.isNotEmpty(studentList)) {
studentList.forEach(this::buildDefaultValue);
studentMapper.insertList(studentList);
}
}
/**
* 更新数据对象。
*
* @param student 更新的对象。
* @param originalStudent 原有数据对象。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean update(Student student, Student originalStudent) {
student.setRegisterTime(originalStudent.getRegisterTime());
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
UpdateWrapper<Student> uw = this.createUpdateQueryForNullValue(student, student.getStudentId());
return studentMapper.update(student, uw) == 1;
}
/**
* 删除指定数据。
*
* @param studentId 主键Id。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean remove(Long studentId) {
if (studentMapper.deleteById(studentId) == 0) {
return false;
}
// 开始删除多对多父表的关联
ClassStudent classStudent = new ClassStudent();
classStudent.setStudentId(studentId);
classStudentMapper.delete(new QueryWrapper<>(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);
// 在缺省生成的代码中如果查询结果resultList不是Page对象说明没有分页那么就很可能是数据导出接口调用了当前方法。
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
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;
if (classId != null) {
resultList = studentMapper.getNotInStudentListByClassId(classId, filter, orderBy);
} else {
resultList = getStudentList(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)
&& !sysDeptService.existId(student.getSchoolId())) {
return CallResult.error(String.format(errorMessageFormat, "所属校区"));
}
return CallResult.ok();
}
private Student buildDefaultValue(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);
return student;
}
}

View File

@@ -1,52 +0,0 @@
package com.orangeforms.webadmin.app.util;
import com.anji.captcha.service.CaptchaCacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import java.util.concurrent.TimeUnit;
/**
* 对于分布式部署的应用我们建议应用自己实现CaptchaCacheService比如用Redis参考service/spring-boot代码示例。
* 如果应用是单点的也没有使用redis那默认使用内存。
* 内存缓存只适合单节点部署的应用,否则验证码生产与验证在节点之间信息不同步,导致失败。
*
* ☆☆☆ SPI 在resources目录新建META-INF.services文件夹(两层)参考当前服务resources。
* @author lide1202@hotmail.com
* @date 2020-05-12
*/
public class CaptchaCacheServiceRedisImpl implements CaptchaCacheService {
@Override
public String type() {
return "redis";
}
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Override
public void set(String key, String value, long expiresInSeconds) {
stringRedisTemplate.opsForValue().set(key, value, expiresInSeconds, TimeUnit.SECONDS);
}
@Override
public boolean exists(String key) {
return stringRedisTemplate.hasKey(key);
}
@Override
public void delete(String key) {
stringRedisTemplate.delete(key);
}
@Override
public String get(String key) {
return stringRedisTemplate.opsForValue().get(key);
}
@Override
public Long increment(String key, long val) {
return stringRedisTemplate.opsForValue().increment(key,val);
}
}

View File

@@ -1,40 +0,0 @@
package com.orangeforms.webadmin.app.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 行政区划DomainVO对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("行政区划实体对象")
@Data
public class AreaCodeVo {
/**
* 行政区划主键Id
*/
@ApiModelProperty(value = "行政区划主键Id", required = true)
private Long areaId;
/**
* 行政区划名称
*/
@ApiModelProperty(value = "行政区划名称")
private String areaName;
/**
* 行政区划级别 (1: 省级别 2: 市级别 3: 区级别)
*/
@ApiModelProperty(value = "行政区划级别")
private Integer areaLevel;
/**
* 父级行政区划Id
*/
@ApiModelProperty(value = "父级行政区划Id")
private Long parentId;
}

View File

@@ -1,34 +0,0 @@
package com.orangeforms.webadmin.app.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* ClassCourseVO视图对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("ClassCourseVO视图对象")
@Data
public class ClassCourseVo {
/**
* 班级Id。
*/
@ApiModelProperty(value = "班级Id")
private Long classId;
/**
* 课程Id。
*/
@ApiModelProperty(value = "课程Id")
private Long courseId;
/**
* 课程顺序(数值越小越靠前)。
*/
@ApiModelProperty(value = "课程顺序(数值越小越靠前)")
private Integer courseOrder;
}

View File

@@ -1,28 +0,0 @@
package com.orangeforms.webadmin.app.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* ClassStudentVO视图对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("ClassStudentVO视图对象")
@Data
public class ClassStudentVo {
/**
* 班级Id。
*/
@ApiModelProperty(value = "班级Id")
private Long classId;
/**
* 学生Id。
*/
@ApiModelProperty(value = "学生Id")
private Long studentId;
}

View File

@@ -1,91 +0,0 @@
package com.orangeforms.webadmin.app.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.Map;
/**
* CourseTransStatsVO视图对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("CourseTransStatsVO视图对象")
@Data
public class CourseTransStatsVo {
/**
* 主键Id。
*/
@ApiModelProperty(value = "主键Id")
private Long statsId;
/**
* 统计日期。
*/
@ApiModelProperty(value = "统计日期")
private Date statsDate;
/**
* 科目Id。
*/
@ApiModelProperty(value = "科目Id")
private Integer subjectId;
/**
* 年级Id。
*/
@ApiModelProperty(value = "年级Id")
private Integer gradeId;
/**
* 年级名称。
*/
@ApiModelProperty(value = "年级名称")
private String gradeName;
/**
* 课程Id。
*/
@ApiModelProperty(value = "课程Id")
private Long courseId;
/**
* 课程名称。
*/
@ApiModelProperty(value = "课程名称")
private String courseName;
/**
* 学生上课次数。
*/
@ApiModelProperty(value = "学生上课次数")
private Integer studentAttendCount;
/**
* 学生献花数量。
*/
@ApiModelProperty(value = "学生献花数量")
private Integer studentFlowerAmount;
/**
* 学生献花次数。
*/
@ApiModelProperty(value = "学生献花次数")
private Integer studentFlowerCount;
/**
* gradeId 字典关联数据。
*/
@ApiModelProperty(value = "gradeId 字典关联数据")
private Map<String, Object> gradeIdDictMap;
/**
* subjectId 常量字典关联数据。
*/
@ApiModelProperty(value = "subjectId 常量字典关联数据")
private Map<String, Object> subjectIdDictMap;
}

View File

@@ -1,116 +0,0 @@
package com.orangeforms.webadmin.app.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;
/**
* CourseVO视图对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("CourseVO视图对象")
@Data
public class CourseVo {
/**
* 主键Id。
*/
@ApiModelProperty(value = "主键Id")
private Long courseId;
/**
* 课程名称。
*/
@ApiModelProperty(value = "课程名称")
private String courseName;
/**
* 课程价格。
*/
@ApiModelProperty(value = "课程价格")
private BigDecimal price;
/**
* 课程描述。
*/
@ApiModelProperty(value = "课程描述")
private String description;
/**
* 课程难度(0: 容易 1: 普通 2: 很难)。
*/
@ApiModelProperty(value = "课程难度(0: 容易 1: 普通 2: 很难)")
private Integer difficulty;
/**
* 年级Id。
*/
@ApiModelProperty(value = "年级Id")
private Integer gradeId;
/**
* 学科Id。
*/
@ApiModelProperty(value = "学科Id")
private Integer subjectId;
/**
* 课时数量。
*/
@ApiModelProperty(value = "课时数量")
private Integer classHour;
/**
* 多张课程图片地址。
*/
@ApiModelProperty(value = "多张课程图片地址")
private String pictureUrl;
/**
* 创建用户Id。
*/
@ApiModelProperty(value = "创建用户Id")
private Long createUserId;
/**
* 创建时间。
*/
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**
* 最后修改时间。
*/
@ApiModelProperty(value = "最后修改时间")
private Date updateTime;
/**
* courseId 的多对多关联表数据对象数据对应类型为ClassCourseVo。
*/
@ApiModelProperty(value = "courseId 的多对多关联表数据对象数据对应类型为ClassCourseVo")
private Map<String, Object> classCourse;
/**
* gradeId 字典关联数据。
*/
@ApiModelProperty(value = "gradeId 字典关联数据")
private Map<String, Object> gradeIdDictMap;
/**
* difficulty 常量字典关联数据。
*/
@ApiModelProperty(value = "difficulty 常量字典关联数据")
private Map<String, Object> difficultyDictMap;
/**
* subjectId 常量字典关联数据。
*/
@ApiModelProperty(value = "subjectId 常量字典关联数据")
private Map<String, Object> subjectIdDictMap;
}

View File

@@ -1,28 +0,0 @@
package com.orangeforms.webadmin.app.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* GradeVO视图对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("GradeVO视图对象")
@Data
public class GradeVo {
/**
* 主键Id。
*/
@ApiModelProperty(value = "主键Id")
private Integer gradeId;
/**
* 年级名称。
*/
@ApiModelProperty(value = "年级名称")
private String gradeName;
}

View File

@@ -1,163 +0,0 @@
package com.orangeforms.webadmin.app.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.Map;
/**
* StudentActionStatsVO视图对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("StudentActionStatsVO视图对象")
@Data
public class StudentActionStatsVo {
/**
* 主键Id。
*/
@ApiModelProperty(value = "主键Id")
private Long statsId;
/**
* 统计日期。
*/
@ApiModelProperty(value = "统计日期")
private Date statsDate;
/**
* 统计小时。
*/
@ApiModelProperty(value = "统计小时")
private Date statsMonth;
/**
* 年级Id。
*/
@ApiModelProperty(value = "年级Id")
private Integer gradeId;
/**
* 学生所在省Id。
*/
@ApiModelProperty(value = "学生所在省Id")
private Long provinceId;
/**
* 学生所在城市Id。
*/
@ApiModelProperty(value = "学生所在城市Id")
private Long cityId;
/**
* 购课学币数量。
*/
@ApiModelProperty(value = "购课学币数量")
private Integer buyCourseAmount;
/**
* 购买课程次数。
*/
@ApiModelProperty(value = "购买课程次数")
private Integer buyCourseCount;
/**
* 购买视频学币数量。
*/
@ApiModelProperty(value = "购买视频学币数量")
private Integer buyVideoAmount;
/**
* 购买视频次数。
*/
@ApiModelProperty(value = "购买视频次数")
private Integer buyVideoCount;
/**
* 购买作业学币数量。
*/
@ApiModelProperty(value = "购买作业学币数量")
private Integer buyPaperAmount;
/**
* 购买作业次数。
*/
@ApiModelProperty(value = "购买作业次数")
private Integer buyPaperCount;
/**
* 购买献花数量。
*/
@ApiModelProperty(value = "购买献花数量")
private Integer buyFlowerAmount;
/**
* 购买献花次数。
*/
@ApiModelProperty(value = "购买献花次数")
private Integer buyFlowerCount;
/**
* 充值学币数量。
*/
@ApiModelProperty(value = "充值学币数量")
private Integer rechargeCoinAmount;
/**
* 充值学币次数。
*/
@ApiModelProperty(value = "充值学币次数")
private Integer rechargeCoinCount;
/**
* 线下课程上课次数。
*/
@ApiModelProperty(value = "线下课程上课次数")
private Integer doCourseCount;
/**
* 观看视频次数。
*/
@ApiModelProperty(value = "观看视频次数")
private Integer watchVideoCount;
/**
* 购买献花消费学币数量。
*/
@ApiModelProperty(value = "购买献花消费学币数量")
private Integer watchVideoTotalSecond;
/**
* 做题数量。
*/
@ApiModelProperty(value = "做题数量")
private Integer doExerciseCount;
/**
* 做题正确的数量。
*/
@ApiModelProperty(value = "做题正确的数量")
private Integer doExerciseCorrectCount;
/**
* gradeId 字典关联数据。
*/
@ApiModelProperty(value = "gradeId 字典关联数据")
private Map<String, Object> gradeIdDictMap;
/**
* provinceId 字典关联数据。
*/
@ApiModelProperty(value = "provinceId 字典关联数据")
private Map<String, Object> provinceIdDictMap;
/**
* cityId 字典关联数据。
*/
@ApiModelProperty(value = "cityId 字典关联数据")
private Map<String, Object> cityIdDictMap;
}

View File

@@ -1,133 +0,0 @@
package com.orangeforms.webadmin.app.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.Map;
/**
* StudentActionTransVO视图对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("StudentActionTransVO视图对象")
@Data
public class StudentActionTransVo {
/**
* 主键Id。
*/
@ApiModelProperty(value = "主键Id")
private Long transId;
/**
* 学生Id。
*/
@ApiModelProperty(value = "学生Id")
private Long studentId;
/**
* 学生名称。
*/
@ApiModelProperty(value = "学生名称")
private String studentName;
/**
* 学生校区。
*/
@ApiModelProperty(value = "学生校区")
private Long schoolId;
/**
* 年级Id。
*/
@ApiModelProperty(value = "年级Id")
private Integer gradeId;
/**
* 行为类型(0: 充值 1: 购课 2: 上课签到 3: 上课签退 4: 看视频课 5: 做作业 6: 刷题 7: 献花)。
*/
@ApiModelProperty(value = "行为类型(0: 充值 1: 购课 2: 上课签到 3: 上课签退 4: 看视频课 5: 做作业 6: 刷题 7: 献花)")
private Integer actionType;
/**
* 设备类型(0: iOS 1: Android 2: PC)。
*/
@ApiModelProperty(value = "设备类型(0: iOS 1: Android 2: PC)")
private Integer deviceType;
/**
* 看视频秒数。
*/
@ApiModelProperty(value = "看视频秒数")
private Integer watchVideoSeconds;
/**
* 购买献花数量。
*/
@ApiModelProperty(value = "购买献花数量")
private Integer flowerCount;
/**
* 购买作业数量。
*/
@ApiModelProperty(value = "购买作业数量")
private Integer paperCount;
/**
* 购买视频数量。
*/
@ApiModelProperty(value = "购买视频数量")
private Integer videoCount;
/**
* 购买课程数量。
*/
@ApiModelProperty(value = "购买课程数量")
private Integer courseCount;
/**
* 充值学币数量。
*/
@ApiModelProperty(value = "充值学币数量")
private Integer coinCount;
/**
* 做题是否正确标记。
*/
@ApiModelProperty(value = "做题是否正确标记")
private Integer exerciseCorrectFlag;
/**
* 发生时间。
*/
@ApiModelProperty(value = "发生时间")
private Date createTime;
/**
* schoolId 字典关联数据。
*/
@ApiModelProperty(value = "schoolId 字典关联数据")
private Map<String, Object> schoolIdDictMap;
/**
* gradeId 字典关联数据。
*/
@ApiModelProperty(value = "gradeId 字典关联数据")
private Map<String, Object> gradeIdDictMap;
/**
* actionType 常量字典关联数据。
*/
@ApiModelProperty(value = "actionType 常量字典关联数据")
private Map<String, Object> actionTypeDictMap;
/**
* deviceType 常量字典关联数据。
*/
@ApiModelProperty(value = "deviceType 常量字典关联数据")
private Map<String, Object> deviceTypeDictMap;
}

View File

@@ -1,85 +0,0 @@
package com.orangeforms.webadmin.app.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.Map;
/**
* StudentClassVO视图对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("StudentClassVO视图对象")
@Data
public class StudentClassVo {
/**
* 班级Id。
*/
@ApiModelProperty(value = "班级Id")
private Long classId;
/**
* 班级名称。
*/
@ApiModelProperty(value = "班级名称")
private String className;
/**
* 学校Id。
*/
@ApiModelProperty(value = "学校Id")
private Long schoolId;
/**
* 学生班长Id。
*/
@ApiModelProperty(value = "学生班长Id")
private Long leaderId;
/**
* 已完成课时数量。
*/
@ApiModelProperty(value = "已完成课时数量")
private Integer finishClassHour;
/**
* 班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)。
*/
@ApiModelProperty(value = "班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)")
private Integer classLevel;
/**
* 创建用户。
*/
@ApiModelProperty(value = "创建用户")
private Long createUserId;
/**
* 班级创建时间。
*/
@ApiModelProperty(value = "班级创建时间")
private Date createTime;
/**
* schoolId 字典关联数据。
*/
@ApiModelProperty(value = "schoolId 字典关联数据")
private Map<String, Object> schoolIdDictMap;
/**
* leaderId 字典关联数据。
*/
@ApiModelProperty(value = "leaderId 字典关联数据")
private Map<String, Object> leaderIdDictMap;
/**
* classLevel 常量字典关联数据。
*/
@ApiModelProperty(value = "classLevel 常量字典关联数据")
private Map<String, Object> classLevelDictMap;
}

View File

@@ -1,157 +0,0 @@
package com.orangeforms.webadmin.app.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.Map;
/**
* StudentVO视图对象。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiModel("StudentVO视图对象")
@Data
public class StudentVo {
/**
* 学生Id。
*/
@ApiModelProperty(value = "学生Id")
private Long studentId;
/**
* 登录手机。
*/
@ApiModelProperty(value = "登录手机")
private String loginMobile;
/**
* 学生姓名。
*/
@ApiModelProperty(value = "学生姓名")
private String studentName;
/**
* 所在省份Id。
*/
@ApiModelProperty(value = "所在省份Id")
private Long provinceId;
/**
* 所在城市Id。
*/
@ApiModelProperty(value = "所在城市Id")
private Long cityId;
/**
* 区县Id。
*/
@ApiModelProperty(value = "区县Id")
private Long districtId;
/**
* 学生性别 (0: 女生 1: 男生)。
*/
@ApiModelProperty(value = "学生性别 (0: 女生 1: 男生)")
private Integer gender;
/**
* 生日。
*/
@ApiModelProperty(value = "生日")
private Date birthday;
/**
* 经验等级 (0: 初级 1: 中级 2: 高级 3: 资深)。
*/
@ApiModelProperty(value = "经验等级 (0: 初级 1: 中级 2: 高级 3: 资深)")
private Integer experienceLevel;
/**
* 总共充值学币数量。
*/
@ApiModelProperty(value = "总共充值学币数量")
private Integer totalCoin;
/**
* 可用学币数量。
*/
@ApiModelProperty(value = "可用学币数量")
private Integer leftCoin;
/**
* 年级Id。
*/
@ApiModelProperty(value = "年级Id")
private Integer gradeId;
/**
* 校区Id。
*/
@ApiModelProperty(value = "校区Id")
private Long schoolId;
/**
* 注册时间。
*/
@ApiModelProperty(value = "注册时间")
private Date registerTime;
/**
* 学生状态 (0: 正常 1: 锁定 2: 注销)。
*/
@ApiModelProperty(value = "学生状态 (0: 正常 1: 锁定 2: 注销)")
private Integer status;
/**
* provinceId 字典关联数据。
*/
@ApiModelProperty(value = "provinceId 字典关联数据")
private Map<String, Object> provinceIdDictMap;
/**
* cityId 字典关联数据。
*/
@ApiModelProperty(value = "cityId 字典关联数据")
private Map<String, Object> cityIdDictMap;
/**
* districtId 字典关联数据。
*/
@ApiModelProperty(value = "districtId 字典关联数据")
private Map<String, Object> districtIdDictMap;
/**
* gradeId 字典关联数据。
*/
@ApiModelProperty(value = "gradeId 字典关联数据")
private Map<String, Object> gradeIdDictMap;
/**
* schoolId 字典关联数据。
*/
@ApiModelProperty(value = "schoolId 字典关联数据")
private Map<String, Object> schoolIdDictMap;
/**
* gender 常量字典关联数据。
*/
@ApiModelProperty(value = "gender 常量字典关联数据")
private Map<String, Object> genderDictMap;
/**
* experienceLevel 常量字典关联数据。
*/
@ApiModelProperty(value = "experienceLevel 常量字典关联数据")
private Map<String, Object> experienceLevelDictMap;
/**
* status 常量字典关联数据。
*/
@ApiModelProperty(value = "status 常量字典关联数据")
private Map<String, Object> statusDictMap;
}

View File

@@ -1,51 +0,0 @@
package com.orangeforms.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 sessionExpiredSeconds = 86400;
}

View File

@@ -1,30 +0,0 @@
package com.orangeforms.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 org.mybatis.spring.annotation.MapperScan;
import javax.sql.DataSource;
/**
* 数据源配置Bean对象。
*
* @author Jerry
* @date 2020-09-24
*/
@Configuration
@EnableTransactionManagement
@MapperScan(value = {"com.orangeforms.webadmin.*.dao", "com.orangeforms.common.*.dao"})
public class DataSourceConfig {
@Bean(initMethod = "init", destroyMethod = "close")
@Primary
@ConfigurationProperties(prefix = "spring.datasource.druid")
public DataSource druidDataSource() {
return DruidDataSourceBuilder.create().build();
}
}

View File

@@ -1,61 +0,0 @@
package com.orangeforms.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())) {
if ("*".equals(applicationConfig.getCredentialIpList())) {
corsConfiguration.addAllowedOriginPattern("*");
} else {
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中已经设置encodingforceEncoding也会重新设置
filterRegistrationBean.addInitParameter("forceEncoding", "true");
filterRegistrationBean.setAsyncSupported(true);
return filterRegistrationBean;
}
}

View File

@@ -1,21 +0,0 @@
package com.orangeforms.webadmin.config;
import com.orangeforms.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/**");
}
}

View File

@@ -1,143 +0,0 @@
package com.orangeforms.webadmin.interceptor;
import com.alibaba.fastjson.JSON;
import com.orangeforms.webadmin.config.ApplicationConfig;
import com.orangeforms.webadmin.upms.model.SysPermWhitelist;
import com.orangeforms.webadmin.upms.service.SysPermWhitelistService;
import com.orangeforms.webadmin.upms.service.SysPermService;
import com.orangeforms.common.core.annotation.NoAuthInterface;
import com.orangeforms.common.core.constant.ErrorCodeEnum;
import com.orangeforms.common.core.object.ResponseResult;
import com.orangeforms.common.core.object.TokenData;
import com.orangeforms.common.core.util.ApplicationContextHolder;
import com.orangeforms.common.core.util.JwtUtil;
import com.orangeforms.common.core.util.RedisKeyUtil;
import io.jsonwebtoken.Claims;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.redisson.api.RBucket;
import org.redisson.api.RSet;
import org.redisson.api.RedissonClient;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
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 RedissonClient redissonClient = ApplicationContextHolder.getBean(RedissonClient.class);
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();
String token = request.getHeader(appConfig.getTokenHeaderKey());
boolean noLoginUrl = false;
// 如果接口方法标记NoAuthInterface注解可以直接跳过Token鉴权验证这里主要为了测试接口方便
if (handler instanceof HandlerMethod) {
HandlerMethod hm = (HandlerMethod) handler;
if (hm.getBeanType().getAnnotation(NoAuthInterface.class) != null
|| hm.getMethodAnnotation(NoAuthInterface.class) != null) {
noLoginUrl = true;
if (StringUtils.isBlank(token)) {
return true;
}
}
}
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");
String sessionIdKey = RedisKeyUtil.makeSessionIdKey(sessionId);
RBucket<String> sessionData = redissonClient.getBucket(sessionIdKey);
TokenData tokenData = null;
if (sessionData.isExists()) {
tokenData = JSON.parseObject(sessionData.get(), TokenData.class);
}
if (tokenData == null) {
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
this.outputResponseMessage(response,
ResponseResult.error(ErrorCodeEnum.UNAUTHORIZED_LOGIN, "用户会话已失效,请重新登录!"));
return false;
}
TokenData.addToRequest(tokenData);
// 如果url是免登陆、白名单中则不需要进行鉴权操作
if (!noLoginUrl && Boolean.FALSE.equals(tokenData.getIsAdmin()) && !whitelistPermSet.contains(url)) {
RSet<String> permSet = redissonClient.getSet(RedisKeyUtil.makeSessionPermIdKey(sessionId));
if (!permSet.contains(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();
}
}

View File

@@ -1,344 +0,0 @@
package com.orangeforms.webadmin.upms.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.anji.captcha.model.common.ResponseModel;
import com.anji.captcha.model.vo.CaptchaVO;
import com.anji.captcha.service.CaptchaService;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import lombok.extern.slf4j.Slf4j;
import com.orangeforms.webadmin.config.ApplicationConfig;
import com.orangeforms.webadmin.upms.service.*;
import com.orangeforms.webadmin.upms.model.*;
import com.orangeforms.webadmin.upms.model.constant.SysUserStatus;
import com.orangeforms.webadmin.upms.model.constant.SysUserType;
import com.orangeforms.common.core.annotation.NoAuthInterface;
import com.orangeforms.common.core.annotation.MyRequestBody;
import com.orangeforms.common.core.constant.ApplicationConstant;
import com.orangeforms.common.core.constant.ErrorCodeEnum;
import com.orangeforms.common.core.object.*;
import com.orangeforms.common.core.util.*;
import com.orangeforms.common.core.upload.*;
import com.orangeforms.common.redis.cache.SessionCacheHelper;
import com.orangeforms.common.log.annotation.OperationLog;
import com.orangeforms.common.log.model.constant.SysOperationLogType;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.redisson.api.RBucket;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* 登录接口控制器类。
*
* @author Jerry
* @date 2020-09-24
*/
@ApiSupport(order = 1)
@Api(tags = "用户登录接口")
@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 SysRoleService sysRoleService;
@Autowired
private SysDataPermService sysDataPermService;
@Autowired
private ApplicationConfig appConfig;
@Autowired
private RedissonClient redissonClient;
@Autowired
private SessionCacheHelper cacheHelper;
@Autowired
private PasswordEncoder passwordEncoder;
@Autowired
private CaptchaService captchaService;
@Autowired
private UpDownloaderFactory upDownloaderFactory;
/**
* 登录接口。
*
* @param loginName 登录名。
* @param password 密码。
* @param captchaVerification 验证码。
* @return 应答结果对象其中包括JWT的Token数据以及菜单列表。
*/
@ApiImplicitParams({
// 这里包含密码密文,仅用于方便开发期间的接口测试,集成测试和发布阶段,需要将当前注解去掉。
// 如果您重新生成了公钥和私钥请替换password的缺省值。
@ApiImplicitParam(name = "loginName", defaultValue = "admin"),
@ApiImplicitParam(name = "password", defaultValue = "IP3ccke3GhH45iGHB5qP9p7iZw6xUyj28Ju10rnBiPKOI35sc%2BjI7%2FdsjOkHWMfUwGYGfz8ik31HC2Ruk%2Fhkd9f6RPULTHj7VpFdNdde2P9M4mQQnFBAiPM7VT9iW3RyCtPlJexQ3nAiA09OqG%2F0sIf1kcyveSrulxembARDbDo%3D"),
@ApiImplicitParam(name = "captchaVerification", defaultValue = "为了方便测试这里可以修改一下代码hardcode一个每次都ok的验证码")
})
@NoAuthInterface
@OperationLog(type = SysOperationLogType.LOGIN, saveResponse = false)
@PostMapping("/doLogin")
public ResponseResult<JSONObject> doLogin(
@MyRequestBody String loginName,
@MyRequestBody String password,
@MyRequestBody String captchaVerification) throws Exception {
if (MyCommonUtil.existBlankArgument(loginName, password, captchaVerification)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
String errorMessage;
CaptchaVO captchaVO = new CaptchaVO();
captchaVO.setCaptchaVerification(captchaVerification);
ResponseModel response = captchaService.verification(captchaVO);
if (!response.isSuccess()) {
//验证码校验失败,返回信息告诉前端
//repCode 0000 无异常,代表成功
//repCode 9999 服务器内部异常
//repCode 0011 参数不能为空
//repCode 6110 验证码已失效,请重新获取
//repCode 6111 验证失败
//repCode 6112 获取验证码失败,请联系管理员
errorMessage = String.format("数据验证失败,验证码错误,错误码 [%s] 错误信息 [%s]",
response.getRepCode(), response.getRepMsg());
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
}
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);
}
if (user.getUserStatus() == SysUserStatus.STATUS_LOCKED) {
errorMessage = "登录失败,用户账号被锁定!";
return ResponseResult.error(ErrorCodeEnum.INVALID_USER_STATUS, errorMessage);
}
String patternKey = RedisKeyUtil.getSessionIdPrefix(user.getLoginName(), MyCommonUtil.getDeviceType()) + "*";
redissonClient.getKeys().deleteByPatternAsync(patternKey);
JSONObject jsonData = this.buildLoginData(user);
return ResponseResult.success(jsonData);
}
/**
* 登出操作。同时将Session相关的信息从缓存中删除。
*
* @return 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.LOGOUT)
@PostMapping("/doLogout")
public ResponseResult<Void> doLogout() {
TokenData tokenData = TokenData.takeFromRequest();
String sessionIdKey = RedisKeyUtil.makeSessionIdKey(tokenData.getSessionId());
redissonClient.getBucket(sessionIdKey).delete();
sysPermService.removeUserSysPermCache(tokenData.getSessionId());
sysDataPermService.removeDataPermCache(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());
if (StrUtil.isNotBlank(tokenData.getHeadImageUrl())) {
jsonData.put("headImageUrl", tokenData.getHeadImageUrl());
}
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(newPass, 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();
}
/**
* 上传并修改用户头像。
*
* @param uploadFile 上传的头像文件。
*/
@PostMapping("/changeHeadImage")
public void changeHeadImage(
@RequestParam("uploadFile") MultipartFile uploadFile) throws Exception {
String fieldName = "headImageUrl";
UploadStoreInfo storeInfo = MyModelUtil.getUploadStoreInfo(SysUser.class, fieldName);
BaseUpDownloader upDownloader = upDownloaderFactory.get(storeInfo.getStoreType());
UploadResponseInfo responseInfo = upDownloader.doUpload(null,
appConfig.getUploadFileBaseDir(), SysUser.class.getSimpleName(), fieldName, true, uploadFile);
if (responseInfo.getUploadFailed()) {
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN,
ResponseResult.error(ErrorCodeEnum.UPLOAD_FAILED, responseInfo.getErrorMessage()));
return;
}
responseInfo.setDownloadUri("/admin/upms/login/downloadHeadImage");
String newHeadImage = JSONArray.toJSONString(CollUtil.newArrayList(responseInfo));
if (!sysUserService.changeHeadImage(TokenData.takeFromRequest().getUserId(), newHeadImage)) {
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN,
ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST));
return;
}
ResponseResult.output(ResponseResult.success(responseInfo));
}
/**
* 下载用户头像。
*
* @param filename 文件名。如果没有提供该参数,就从当前记录的指定字段中读取。
* @param response Http 应答对象。
*/
@GetMapping("/downloadHeadImage")
public void downloadHeadImage(String filename, HttpServletResponse response) {
try {
SysUser user = sysUserService.getById(TokenData.takeFromRequest().getUserId());
if (user == null) {
ResponseResult.output(HttpServletResponse.SC_NOT_FOUND);
return;
}
if (StrUtil.isBlank(user.getHeadImageUrl())) {
ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST);
return;
}
if (!BaseUpDownloader.containFile(user.getHeadImageUrl(), filename)) {
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN);
return;
}
String fieldName = "headImageUrl";
UploadStoreInfo storeInfo = MyModelUtil.getUploadStoreInfo(SysUser.class, fieldName);
BaseUpDownloader upDownloader = upDownloaderFactory.get(storeInfo.getStoreType());
upDownloader.doDownload(appConfig.getUploadFileBaseDir(),
SysUser.class.getSimpleName(), fieldName, filename, true, response);
} catch (Exception e) {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
log.error(e.getMessage(), e);
}
}
private JSONObject buildLoginData(SysUser user) {
int deviceType = MyCommonUtil.getDeviceType();
boolean isAdmin = user.getUserType() == SysUserType.TYPE_ADMIN;
String headImageUrl = user.getHeadImageUrl();
Map<String, Object> claims = new HashMap<>(3);
String sessionId = user.getLoginName() + "_" + deviceType + "_" + 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);
if (StrUtil.isNotBlank(headImageUrl)) {
jsonData.put("headImageUrl", headImageUrl);
}
TokenData tokenData = new TokenData();
tokenData.setSessionId(sessionId);
tokenData.setUserId(user.getUserId());
tokenData.setDeptId(user.getDeptId());
tokenData.setLoginName(user.getLoginName());
tokenData.setShowName(user.getShowName());
tokenData.setIsAdmin(isAdmin);
tokenData.setLoginIp(IpUtil.getRemoteIpAddress(ContextUtil.getHttpRequest()));
tokenData.setLoginTime(new Date());
tokenData.setDeviceType(deviceType);
if (StrUtil.isNotBlank(headImageUrl)) {
tokenData.setHeadImageUrl(headImageUrl);
}
List<SysUserRole> userRoleList = sysRoleService.getSysUserRoleListByUserId(user.getUserId());
if (CollectionUtils.isNotEmpty(userRoleList)) {
Set<Long> userRoleIdSet = userRoleList.stream().map(SysUserRole::getRoleId).collect(Collectors.toSet());
tokenData.setRoleIds(StringUtils.join(userRoleIdSet, ","));
}
String sessionIdKey = RedisKeyUtil.makeSessionIdKey(sessionId);
String sessionData = JSON.toJSONString(tokenData, SerializerFeature.WriteNonStringValueAsString);
RBucket<String> bucket = redissonClient.getBucket(sessionIdKey);
bucket.set(sessionData);
bucket.expire(appConfig.getSessionExpiredSeconds(), TimeUnit.SECONDS);
// 这里手动将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());
sysDataPermService.putDataPermCache(sessionId, user.getUserId(), user.getDeptId());
}
return jsonData;
}
}

View File

@@ -1,83 +0,0 @@
package com.orangeforms.webadmin.upms.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.orangeforms.common.core.annotation.MyRequestBody;
import com.orangeforms.common.core.object.*;
import com.orangeforms.common.core.util.RedisKeyUtil;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RBucket;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
/**
* 在线用户控制器对象。
*
* @author Jerry
* @date 2020-09-24
*/
@Api(tags = "在线用户接口")
@Slf4j
@RestController
@RequestMapping("/admin/upms/loginUser")
public class LoginUserController {
@Autowired
private RedissonClient redissonClient;
/**
* 显示在线用户列表。
*
* @param loginName 登录名过滤。
* @param pageParam 分页参数。
* @return 登录用户信息列表。
*/
@PostMapping("/list")
public ResponseResult<MyPageData<LoginUserInfo>> list(
@MyRequestBody String loginName, @MyRequestBody MyPageParam pageParam) {
int queryCount = pageParam.getPageNum() * pageParam.getPageSize();
int skipCount = (pageParam.getPageNum() - 1) * pageParam.getPageSize();
String patternKey;
if (StrUtil.isBlank(loginName)) {
patternKey = RedisKeyUtil.getSessionIdPrefix() + "*";
} else {
patternKey = RedisKeyUtil.getSessionIdPrefix(loginName) + "*";
}
List<LoginUserInfo> loginUserInfoList = new LinkedList<>();
Iterable<String> keys = redissonClient.getKeys().getKeysByPattern(patternKey);
for (String key : keys) {
loginUserInfoList.add(this.buildTokenDataByRedisKey(key));
}
loginUserInfoList.sort((o1, o2) -> (int) (o2.getLoginTime().getTime() - o1.getLoginTime().getTime()));
int toIndex = Math.min(skipCount + pageParam.getPageSize(), loginUserInfoList.size());
List<LoginUserInfo> resultList = loginUserInfoList.subList(skipCount, toIndex);
return ResponseResult.success(new MyPageData<>(resultList, (long) loginUserInfoList.size()));
}
/**
* 强制下线指定登录会话。
*
* @param sessionId 待强制下线的SessionId。
* @return 应答结果对象。
*/
@PostMapping("/delete")
public ResponseResult<Void> delete(@MyRequestBody String sessionId) {
// 为了保证被剔除用户正在进行的操作不被干扰这里只是删除sessionIdKey即可这样可以使强制下线操作更加平滑。
// 比如如果删除操作权限或数据权限的redis session key那么正在请求数据的操作就会报错。
redissonClient.getBucket(RedisKeyUtil.makeSessionIdKey(sessionId)).delete();
return ResponseResult.success();
}
private LoginUserInfo buildTokenDataByRedisKey(String key) {
RBucket<String> sessionData = redissonClient.getBucket(key);
TokenData tokenData = JSON.parseObject(sessionData.get(), TokenData.class);
return BeanUtil.copyProperties(tokenData, LoginUserInfo.class);
}
}

View File

@@ -1,300 +0,0 @@
package com.orangeforms.webadmin.upms.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import com.alibaba.fastjson.TypeReference;
import com.github.pagehelper.Page;
import com.github.pagehelper.page.PageMethod;
import lombok.extern.slf4j.Slf4j;
import com.orangeforms.webadmin.upms.dto.SysDataPermDto;
import com.orangeforms.webadmin.upms.dto.SysUserDto;
import com.orangeforms.webadmin.upms.vo.SysDataPermVo;
import com.orangeforms.webadmin.upms.vo.SysUserVo;
import com.orangeforms.webadmin.upms.model.SysDataPerm;
import com.orangeforms.webadmin.upms.model.SysUser;
import com.orangeforms.webadmin.upms.service.SysDataPermService;
import com.orangeforms.webadmin.upms.service.SysUserService;
import com.orangeforms.common.core.validator.UpdateGroup;
import com.orangeforms.common.core.constant.ErrorCodeEnum;
import com.orangeforms.common.core.object.*;
import com.orangeforms.common.core.util.*;
import com.orangeforms.common.core.annotation.MyRequestBody;
import com.orangeforms.common.log.annotation.OperationLog;
import com.orangeforms.common.log.model.constant.SysOperationLogType;
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
*/
@Api(tags = "数据权限管理接口")
@Slf4j
@RestController
@RequestMapping("/admin/upms/sysDataPerm")
public class SysDataPermController {
@Autowired
private SysDataPermService sysDataPermService;
@Autowired
private SysUserService sysUserService;
/**
* 添加新数据权限操作。
*
* @param sysDataPermDto 新增对象。
* @param deptIdListString 数据权限关联的部门Id列表多个之间逗号分隔。
* @return 应答结果对象。包含新增数据权限对象的主键Id。
*/
@ApiOperationSupport(ignoreParameters = {
"sysDataPermDto.dataPermId",
"sysDataPermDto.createTimeStart",
"sysDataPermDto.createTimeEnd",
"sysDataPermDto.searchString"})
@OperationLog(type = SysOperationLogType.ADD)
@PostMapping("/add")
public ResponseResult<Long> add(
@MyRequestBody SysDataPermDto sysDataPermDto, @MyRequestBody String deptIdListString) {
String errorMessage = MyCommonUtil.getModelValidationError(sysDataPermDto);
if (errorMessage != null) {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
}
SysDataPerm sysDataPerm = MyModelUtil.copyTo(sysDataPermDto, SysDataPerm.class);
CallResult result = sysDataPermService.verifyRelatedData(sysDataPerm, deptIdListString);
if (!result.isSuccess()) {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
}
Set<Long> deptIdSet = null;
if (result.getData() != null) {
deptIdSet = result.getData().getObject("deptIdSet", new TypeReference<Set<Long>>(){});
}
sysDataPermService.saveNew(sysDataPerm, deptIdSet);
return ResponseResult.success(sysDataPerm.getDataPermId());
}
/**
* 更新数据权限操作。
*
* @param sysDataPermDto 更新的数据权限对象。
* @param deptIdListString 数据权限关联的部门Id列表多个之间逗号分隔。
* @return 应答结果对象。
*/
@ApiOperationSupport(ignoreParameters = {
"sysDataPermDto.createTimeStart",
"sysDataPermDto.createTimeEnd",
"sysDataPermDto.searchString"})
@OperationLog(type = SysOperationLogType.UPDATE)
@PostMapping("/update")
public ResponseResult<Void> update(
@MyRequestBody SysDataPermDto sysDataPermDto, @MyRequestBody String deptIdListString) {
String errorMessage = MyCommonUtil.getModelValidationError(sysDataPermDto, Default.class, UpdateGroup.class);
if (errorMessage != null) {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
}
SysDataPerm originalSysDataPerm = sysDataPermService.getById(sysDataPermDto.getDataPermId());
if (originalSysDataPerm == null) {
errorMessage = "数据验证失败,当前数据权限并不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
SysDataPerm sysDataPerm = MyModelUtil.copyTo(sysDataPermDto, SysDataPerm.class);
CallResult result = sysDataPermService.verifyRelatedData(sysDataPerm, deptIdListString);
if (!result.isSuccess()) {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
}
Set<Long> deptIdSet = null;
if (result.getData() != null) {
deptIdSet = result.getData().getObject("deptIdSet", new TypeReference<Set<Long>>(){});
}
if (!sysDataPermService.update(sysDataPerm, originalSysDataPerm, deptIdSet)) {
errorMessage = "更新失败,数据不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
return ResponseResult.success();
}
/**
* 删除数据权限操作。
*
* @param dataPermId 待删除数据权限主键Id。
* @return 应答数据结果。
*/
@OperationLog(type = SysOperationLogType.DELETE)
@PostMapping("/delete")
public ResponseResult<Void> delete(@MyRequestBody Long dataPermId) {
if (MyCommonUtil.existBlankArgument(dataPermId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
if (!sysDataPermService.remove(dataPermId)) {
String errorMessage = "数据操作失败,数据权限不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
return ResponseResult.success();
}
/**
* 查看数据权限列表。
*
* @param sysDataPermDtoFilter 数据权限查询过滤对象。
* @param orderParam 排序参数。
* @param pageParam 分页参数。
* @return 应答结果对象。包含数据权限列表。
*/
@PostMapping("/list")
public ResponseResult<MyPageData<SysDataPermVo>> list(
@MyRequestBody SysDataPermDto sysDataPermDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (pageParam != null) {
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
}
SysDataPerm filter = MyModelUtil.copyTo(sysDataPermDtoFilter, SysDataPerm.class);
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysDataPerm.class);
List<SysDataPerm> dataPermList = sysDataPermService.getSysDataPermList(filter, orderBy);
List<SysDataPermVo> dataPermVoList = MyModelUtil.copyCollectionTo(dataPermList, SysDataPermVo.class);
long totalCount = 0L;
if (dataPermList instanceof Page) {
totalCount = ((Page<SysDataPerm>) dataPermList).getTotal();
}
return ResponseResult.success(MyPageUtil.makeResponseData(dataPermVoList, totalCount));
}
/**
* 查看单条数据权限详情。
*
* @param dataPermId 数据权限的主键Id。
* @return 应答结果对象,包含数据权限的详情。
*/
@GetMapping("/view")
public ResponseResult<SysDataPermVo> view(@RequestParam Long dataPermId) {
if (MyCommonUtil.existBlankArgument(dataPermId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
SysDataPerm dataPerm = sysDataPermService.getByIdWithRelation(dataPermId, MyRelationParam.full());
if (dataPerm == null) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
SysDataPermVo dataPermVo = MyModelUtil.copyTo(dataPerm, SysDataPermVo.class);
return ResponseResult.success(dataPermVo);
}
/**
* 获取不包含指定数据权限Id的用户列表。
* 用户和数据权限是多对多关系当前接口将返回没有赋值指定DataPermId的用户列表。可用于给数据权限添加新用户。
*
* @param dataPermId 数据权限主键Id。
* @param sysUserDtoFilter 用户数据的过滤对象。
* @param orderParam 排序参数。
* @param pageParam 分页参数。
* @return 应答结果对象,包含用户列表数据。
*/
@PostMapping("/listNotInDataPermUser")
public ResponseResult<MyPageData<SysUserVo>> listNotInDataPermUser(
@MyRequestBody Long dataPermId,
@MyRequestBody SysUserDto sysUserDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
ResponseResult<Void> verifyResult = this.doDataPermUserVerify(dataPermId);
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.getNotInSysUserListByDataPermId(dataPermId, filter, orderBy);
List<SysUserVo> userVoList = MyModelUtil.copyCollectionTo(userList, SysUserVo.class);
return ResponseResult.success(MyPageUtil.makeResponseData(userVoList));
}
/**
* 拥有指定数据权限的用户列表。
*
* @param dataPermId 数据权限Id。
* @param sysUserDtoFilter 用户过滤对象。
* @param orderParam 排序参数。
* @param pageParam 分页参数。
* @return 应答结果对象,包含用户列表数据。
*/
@PostMapping("/listDataPermUser")
public ResponseResult<MyPageData<SysUserVo>> listDataPermUser(
@MyRequestBody Long dataPermId,
@MyRequestBody SysUserDto sysUserDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
ResponseResult<Void> verifyResult = this.doDataPermUserVerify(dataPermId);
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.getSysUserListByDataPermId(dataPermId, filter, orderBy);
List<SysUserVo> userVoList = MyModelUtil.copyCollectionTo(userList, SysUserVo.class);
return ResponseResult.success(MyPageUtil.makeResponseData(userVoList));
}
private ResponseResult<Void> doDataPermUserVerify(Long dataPermId) {
if (MyCommonUtil.existBlankArgument(dataPermId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
if (!sysDataPermService.existId(dataPermId)) {
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
}
return ResponseResult.success();
}
/**
* 为指定数据权限添加用户列表。该操作可同时给一批用户赋值数据权限,并在同一事务内完成。
*
* @param dataPermId 数据权限主键Id。
* @param userIdListString 逗号分隔的用户Id列表。
* @return 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.ADD_M2M)
@PostMapping("/addDataPermUser")
public ResponseResult<Void> addDataPermUser(
@MyRequestBody Long dataPermId, @MyRequestBody String userIdListString) {
if (MyCommonUtil.existBlankArgument(dataPermId, userIdListString)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
Set<Long> userIdSet =
Arrays.stream(userIdListString.split(",")).map(Long::valueOf).collect(Collectors.toSet());
if (!sysDataPermService.existId(dataPermId)
|| !sysUserService.existUniqueKeyList("userId", userIdSet)) {
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
}
sysDataPermService.addDataPermUserList(dataPermId, userIdSet);
return ResponseResult.success();
}
/**
* 为指定用户移除指定数据权限。
*
* @param dataPermId 指定数据权限主键Id。
* @param userId 指定用户主键Id。
* @return 应答数据结果。
*/
@OperationLog(type = SysOperationLogType.DELETE_M2M)
@PostMapping("/deleteDataPermUser")
public ResponseResult<Void> deleteDataPermUser(
@MyRequestBody Long dataPermId, @MyRequestBody Long userId) {
if (MyCommonUtil.existBlankArgument(dataPermId, userId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
if (!sysDataPermService.removeDataPermUser(dataPermId, userId)) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
return ResponseResult.success();
}
}

View File

@@ -1,226 +0,0 @@
package com.orangeforms.webadmin.upms.controller;
import cn.jimmyshi.beanquery.BeanQuery;
import com.orangeforms.common.log.annotation.OperationLog;
import com.orangeforms.common.log.model.constant.SysOperationLogType;
import com.github.pagehelper.page.PageMethod;
import com.orangeforms.webadmin.upms.vo.*;
import com.orangeforms.webadmin.upms.dto.*;
import com.orangeforms.webadmin.upms.model.*;
import com.orangeforms.webadmin.upms.service.*;
import com.orangeforms.common.core.object.*;
import com.orangeforms.common.core.util.*;
import com.orangeforms.common.core.constant.*;
import com.orangeforms.common.core.annotation.MyRequestBody;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* 部门管理操作控制器类。
*
* @author Jerry
* @date 2020-09-24
*/
@Api(tags = "部门管理管理接口")
@Slf4j
@RestController
@RequestMapping("/admin/upms/sysDept")
public class SysDeptController {
@Autowired
private SysDeptService sysDeptService;
/**
* 新增部门管理数据。
*
* @param sysDeptDto 新增对象。
* @return 应答结果对象包含新增对象主键Id。
*/
@ApiOperationSupport(ignoreParameters = {"sysDeptDto.deptId"})
@OperationLog(type = SysOperationLogType.ADD)
@PostMapping("/add")
public ResponseResult<Long> add(@MyRequestBody SysDeptDto sysDeptDto) {
String errorMessage = MyCommonUtil.getModelValidationError(sysDeptDto, false);
if (errorMessage != null) {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
}
SysDept sysDept = MyModelUtil.copyTo(sysDeptDto, SysDept.class);
// 验证父Id的数据合法性
SysDept parentSysDept = null;
if (MyCommonUtil.isNotBlankOrNull(sysDept.getParentId())) {
parentSysDept = sysDeptService.getById(sysDept.getParentId());
if (parentSysDept == null) {
errorMessage = "数据验证失败,关联的父节点并不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_PARENT_ID_NOT_EXIST, errorMessage);
}
}
sysDept = sysDeptService.saveNew(sysDept, parentSysDept);
return ResponseResult.success(sysDept.getDeptId());
}
/**
* 更新部门管理数据。
*
* @param sysDeptDto 更新对象。
* @return 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.UPDATE)
@PostMapping("/update")
public ResponseResult<Void> update(@MyRequestBody SysDeptDto sysDeptDto) {
String errorMessage = MyCommonUtil.getModelValidationError(sysDeptDto, true);
if (errorMessage != null) {
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
}
SysDept sysDept = MyModelUtil.copyTo(sysDeptDto, SysDept.class);
SysDept originalSysDept = sysDeptService.getById(sysDept.getDeptId());
if (originalSysDept == null) {
// NOTE: 修改下面方括号中的话述
errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
// 验证父Id的数据合法性
if (MyCommonUtil.isNotBlankOrNull(sysDept.getParentId())
&& ObjectUtils.notEqual(sysDept.getParentId(), originalSysDept.getParentId())) {
SysDept parentSysDept = sysDeptService.getById(sysDept.getParentId());
if (parentSysDept == null) {
// NOTE: 修改下面方括号中的话述
errorMessage = "数据验证失败,关联的 [父节点] 并不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_PARENT_ID_NOT_EXIST, errorMessage);
}
}
if (!sysDeptService.update(sysDept, originalSysDept)) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
return ResponseResult.success();
}
/**
* 删除部门管理数据。
*
* @param deptId 删除对象主键Id。
* @return 应答结果对象。
*/
@OperationLog(type = SysOperationLogType.DELETE)
@PostMapping("/delete")
public ResponseResult<Void> delete(@MyRequestBody Long deptId) {
String errorMessage;
if (MyCommonUtil.existBlankArgument(deptId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
return this.doDelete(deptId);
}
/**
* 列出符合过滤条件的部门管理列表。
*
* @param sysDeptDtoFilter 过滤对象。
* @param orderParam 排序参数。
* @param pageParam 分页参数。
* @return 应答结果对象,包含查询结果集。
*/
@PostMapping("/list")
public ResponseResult<MyPageData<SysDeptVo>> list(
@MyRequestBody SysDeptDto sysDeptDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (pageParam != null) {
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
}
SysDept sysDeptFilter = MyModelUtil.copyTo(sysDeptDtoFilter, SysDept.class);
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysDept.class);
List<SysDept> sysDeptList = sysDeptService.getSysDeptListWithRelation(sysDeptFilter, orderBy);
return ResponseResult.success(MyPageUtil.makeResponseData(sysDeptList, SysDept.INSTANCE));
}
/**
* 查看指定部门管理对象详情。
*
* @param deptId 指定对象主键Id。
* @return 应答结果对象,包含对象详情。
*/
@GetMapping("/view")
public ResponseResult<SysDeptVo> view(@RequestParam Long deptId) {
if (MyCommonUtil.existBlankArgument(deptId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
SysDept sysDept = sysDeptService.getByIdWithRelation(deptId, MyRelationParam.full());
if (sysDept == null) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
SysDeptVo sysDeptVo = SysDept.INSTANCE.fromModel(sysDept);
return ResponseResult.success(sysDeptVo);
}
/**
* 以字典形式返回全部部门管理数据集合。字典的键值为[deptId, deptName]。
* 白名单接口,登录用户均可访问。
*
* @param filter 过滤对象。
* @return 应答结果对象,包含的数据为 List<Map<String, String>>map中包含两条记录key的值分别是id和namevalue对应具体数据。
*/
@GetMapping("/listDict")
public ResponseResult<List<Map<String, Object>>> listDict(SysDept filter) {
List<SysDept> resultList = sysDeptService.getListByFilter(filter);
return ResponseResult.success(BeanQuery.select(
"parentId as parentId", "deptId as id", "deptName as name").executeFrom(resultList));
}
/**
* 根据字典Id集合获取查询后的字典数据。
*
* @param dictIds 字典Id集合。
* @return 应答结果对象,包含字典形式的数据集合。
*/
@PostMapping("/listDictByIds")
public ResponseResult<List<Map<String, Object>>> listDictByIds(
@MyRequestBody(elementType = Long.class) List<Long> dictIds) {
List<SysDept> resultList = sysDeptService.getInList(new HashSet<>(dictIds));
return ResponseResult.success(BeanQuery.select(
"parentId as parentId", "deptId as id", "deptName as name").executeFrom(resultList));
}
/**
* 根据父主键Id以字典的形式返回其下级数据列表。
* 白名单接口,登录用户均可访问。
*
* @param parentId 父主键Id。
* @return 按照字典的形式返回下级数据列表。
*/
@GetMapping("/listDictByParentId")
public ResponseResult<List<Map<String, Object>>> listDictByParentId(@RequestParam(required = false) Long parentId) {
List<SysDept> resultList = sysDeptService.getListByParentId("parentId", parentId);
return ResponseResult.success(BeanQuery.select(
"parentId as parentId", "deptId as id", "deptName as name").executeFrom(resultList));
}
private ResponseResult<Void> doDelete(Long deptId) {
String errorMessage;
// 验证关联Id的数据合法性
SysDept originalSysDept = sysDeptService.getById(deptId);
if (originalSysDept == null) {
// NOTE: 修改下面方括号中的话述
errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
if (sysDeptService.hasChildren(deptId)) {
// NOTE: 修改下面方括号中的话述
errorMessage = "数据验证失败,当前 [对象存在子对象] ,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.HAS_CHILDREN_DATA, errorMessage);
}
if (sysDeptService.hasChildrenUser(deptId)) {
errorMessage = "数据验证失败,请先移除部门用户数据后,再删除当前部门!";
return ResponseResult.error(ErrorCodeEnum.HAS_CHILDREN_DATA, errorMessage);
}
if (!sysDeptService.remove(deptId)) {
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
}
return ResponseResult.success();
}
}

Some files were not shown because too many files have changed in this diff Show More