commit:同步1.3版本

This commit is contained in:
Jerry
2021-01-03 22:29:02 +08:00
parent ef316438da
commit 25023e29b5
706 changed files with 23404 additions and 14179 deletions

View File

@@ -85,12 +85,30 @@
<orderEntry type="library" name="Maven: tk.mybatis:mapper-spring:1.1.5" level="project" />
<orderEntry type="library" name="Maven: tk.mybatis:mapper-extra:1.1.5" level="project" />
<orderEntry type="library" name="Maven: tk.mybatis:mapper-spring-boot-autoconfigure:2.1.5" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.2.13" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.1" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.1.1" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.2.13" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.1.11" level="project" />
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:2.0" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.3.0" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.3" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.1.3" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.3.0" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.2.0" level="project" />
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:3.2" level="project" />
<orderEntry type="module" module-name="common-swagger" />
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-micro-spring-boot-starter:2.0.5" level="project" />
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring-boot-autoconfigure:2.0.5" level="project" />
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring:2.0.5" level="project" />
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-annotations:2.0.5" level="project" />
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-core:2.0.5" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.25.0-GA" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.22" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.22" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-core:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.9.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-bean-validators:2.9.2" level="project" />
<orderEntry type="library" name="Maven: com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery:2.2.1.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.alibaba.nacos:nacos-client:1.2.1" level="project" />
<orderEntry type="library" name="Maven: com.alibaba.nacos:nacos-common:1.2.1" level="project" />
@@ -247,7 +265,7 @@
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.13.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest:2.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:3.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy:1.10.8" level="project" />
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.10.8" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.10.8" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" />

View File

@@ -26,5 +26,11 @@
<artifactId>common-core</artifactId>
<version>1.0.0</version>
</dependency>
<!-- knife4j 接口文档框架 -->
<dependency>
<groupId>com.orange.demo</groupId>
<artifactId>common-swagger</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>

View File

@@ -1,5 +1,7 @@
package com.orange.demo.courseclassinterface.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -8,26 +10,31 @@ import lombok.Data;
* @author Jerry
* @date 2020-08-08
*/
@ApiModel("行政区划实体对象")
@Data
public class AreaCodeDto {
/**
* 行政区划主键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

@@ -2,6 +2,8 @@ package com.orange.demo.courseclassinterface.dto;
import com.orange.demo.common.core.validator.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
@@ -12,24 +14,28 @@ import javax.validation.constraints.*;
* @author Jerry
* @date 2020-08-08
*/
@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

@@ -2,6 +2,8 @@ package com.orange.demo.courseclassinterface.dto;
import com.orange.demo.common.core.validator.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
@@ -12,18 +14,21 @@ import javax.validation.constraints.*;
* @author Jerry
* @date 2020-08-08
*/
@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

@@ -5,12 +5,13 @@ import com.orange.demo.common.core.validator.ConstDictRef;
import com.orange.demo.courseclassinterface.constant.CourseDifficult;
import com.orange.demo.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对象。
@@ -18,35 +19,41 @@ import java.util.Date;
* @author Jerry
* @date 2020-08-08
*/
@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;
@@ -54,12 +61,14 @@ public class CourseDto {
/**
* 年级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;
@@ -67,57 +76,50 @@ public class CourseDto {
/**
* 课时数量。
*/
@ApiModelProperty(value = "课时数量", required = true)
@NotNull(message = "数据验证失败,课时数量不能为空!")
private Integer classHour;
/**
* 多张课程图片地址。
*/
@ApiModelProperty(value = "多张课程图片地址", required = true)
@NotBlank(message = "数据验证失败,课程图片不能为空!")
private String pictureUrl;
/**
* 创建用户Id。
*/
private Long createUserId;
/**
* 创建时间。
*/
private Date createTime;
/**
* 最后修改时间。
*/
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;
/**
* updateTime 范围过滤起始值(>=)。
*/
@ApiModelProperty(value = "updateTime 范围过滤起始值(>=)")
private String updateTimeStart;
/**
* updateTime 范围过滤结束值(<=)。
*/
@ApiModelProperty(value = "updateTime 范围过滤结束值(<=)")
private String updateTimeEnd;
}

View File

@@ -2,6 +2,8 @@ package com.orange.demo.courseclassinterface.dto;
import com.orange.demo.common.core.validator.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
@@ -12,18 +14,21 @@ import javax.validation.constraints.*;
* @author Jerry
* @date 2020-08-08
*/
@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

@@ -2,41 +2,47 @@ package com.orange.demo.courseclassinterface.dto;
import com.orange.demo.common.core.validator.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
/**
* SchoolInfoDto对象。
*
* @author Jerry
* @date 2020-08-08
*/
@ApiModel("SchoolInfoDto对象")
@Data
public class SchoolInfoDto {
/**
* 学校Id。
*/
@ApiModelProperty(value = "学校Id", required = true)
@NotNull(message = "数据验证失败学校Id不能为空", groups = {UpdateGroup.class})
private Long schoolId;
/**
* 学校名称。
*/
@ApiModelProperty(value = "学校名称", required = true)
@NotBlank(message = "数据验证失败,学校名称不能为空!")
private String schoolName;
/**
* 所在省Id。
*/
@ApiModelProperty(value = "所在省Id", required = true)
@NotNull(message = "数据验证失败,所在省份不能为空!")
private Long provinceId;
/**
* 所在城市Id。
*/
@ApiModelProperty(value = "所在城市Id", required = true)
@NotNull(message = "数据验证失败,所在城市不能为空!")
private Long cityId;
}

View File

@@ -4,65 +4,62 @@ import com.orange.demo.common.core.validator.UpdateGroup;
import com.orange.demo.common.core.validator.ConstDictRef;
import com.orange.demo.courseclassinterface.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-08-08
*/
@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 = "数据验证失败,已完成课时不能为空!")
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;
/**
* 创建用户。
*/
private Long createUserId;
/**
* 班级创建时间。
*/
private Date createTime;
}

View File

@@ -6,6 +6,8 @@ import com.orange.demo.application.common.constant.Gender;
import com.orange.demo.application.common.constant.ExpLevel;
import com.orange.demo.application.common.constant.StudentStatus;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.*;
@@ -18,48 +20,56 @@ import java.util.Date;
* @author Jerry
* @date 2020-08-08
*/
@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;
@@ -67,12 +77,14 @@ public class StudentDto {
/**
* 生日。
*/
@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;
@@ -80,35 +92,35 @@ public class StudentDto {
/**
* 总共充值学币数量。
*/
@ApiModelProperty(value = "总共充值学币数量", required = true)
@NotNull(message = "数据验证失败,充值学币不能为空!", groups = {UpdateGroup.class})
private Integer totalCoin;
/**
* 可用学币数量。
*/
@ApiModelProperty(value = "可用学币数量", required = true)
@NotNull(message = "数据验证失败,剩余学币不能为空!", groups = {UpdateGroup.class})
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;
/**
* 注册时间。
*/
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;
@@ -116,25 +128,30 @@ public class StudentDto {
/**
* 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;
/**
* true LIKE搜索字符串。
*/
@ApiModelProperty(value = "LIKE模糊搜索字符串")
private String searchString;
}

View File

@@ -1,5 +1,7 @@
package com.orange.demo.courseclassinterface.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -8,26 +10,31 @@ import lombok.Data;
* @author Jerry
* @date 2020-08-08
*/
@ApiModel("行政区划实体对象VO")
@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,5 +1,7 @@
package com.orange.demo.courseclassinterface.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -8,21 +10,25 @@ import lombok.Data;
* @author Jerry
* @date 2020-08-08
*/
@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,5 +1,7 @@
package com.orange.demo.courseclassinterface.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -8,16 +10,19 @@ import lombok.Data;
* @author Jerry
* @date 2020-08-08
*/
@ApiModel("ClassStudentVO实体对象")
@Data
public class ClassStudentVo {
/**
* 班级Id。
*/
@ApiModelProperty(value = "班级Id")
private Long classId;
/**
* 学生Id。
*/
@ApiModelProperty(value = "学生Id")
private Long studentId;
}

View File

@@ -1,5 +1,7 @@
package com.orange.demo.courseclassinterface.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@@ -12,86 +14,103 @@ import java.util.Map;
* @author Jerry
* @date 2020-08-08
*/
@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,5 +1,7 @@
package com.orange.demo.courseclassinterface.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -8,16 +10,19 @@ import lombok.Data;
* @author Jerry
* @date 2020-08-08
*/
@ApiModel("GradeVO实体对象")
@Data
public class GradeVo {
/**
* 主键Id。
*/
@ApiModelProperty(value = "主键Id")
private Integer gradeId;
/**
* 年级名称。
*/
@ApiModelProperty(value = "年级名称")
private String gradeName;
}

View File

@@ -1,5 +1,7 @@
package com.orange.demo.courseclassinterface.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Map;
@@ -10,36 +12,43 @@ import java.util.Map;
* @author Jerry
* @date 2020-08-08
*/
@ApiModel("SchoolInfoVO实体对象")
@Data
public class SchoolInfoVo {
/**
* 学校Id。
*/
@ApiModelProperty(value = "学校Id")
private Long schoolId;
/**
* 学校名称。
*/
@ApiModelProperty(value = "学校名称")
private String schoolName;
/**
* 所在省Id。
*/
@ApiModelProperty(value = "所在省Id")
private Long provinceId;
/**
* 所在城市Id。
*/
@ApiModelProperty(value = "所在城市Id")
private Long cityId;
/**
* provinceId 字典关联数据。
*/
@ApiModelProperty(value = "provinceId 字典关联数据")
private Map<String, Object> provinceIdDictMap;
/**
* cityId 字典关联数据。
*/
@ApiModelProperty(value = "cityId 字典关联数据")
private Map<String, Object> cityIdDictMap;
}

View File

@@ -1,5 +1,7 @@
package com.orange.demo.courseclassinterface.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@@ -11,61 +13,73 @@ import java.util.Map;
* @author Jerry
* @date 2020-08-08
*/
@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,5 +1,7 @@
package com.orange.demo.courseclassinterface.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@@ -11,121 +13,145 @@ import java.util.Map;
* @author Jerry
* @date 2020-08-08
*/
@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

@@ -83,12 +83,29 @@
<orderEntry type="library" name="Maven: tk.mybatis:mapper-spring:1.1.5" level="project" />
<orderEntry type="library" name="Maven: tk.mybatis:mapper-extra:1.1.5" level="project" />
<orderEntry type="library" name="Maven: tk.mybatis:mapper-spring-boot-autoconfigure:2.1.5" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.2.13" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.1" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.1.1" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.2.13" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.1.11" level="project" />
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:2.0" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.3.0" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.3" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.1.3" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.3.0" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.2.0" level="project" />
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:3.2" level="project" />
<orderEntry type="module" module-name="common-swagger" />
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-micro-spring-boot-starter:2.0.5" level="project" />
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring-boot-autoconfigure:2.0.5" level="project" />
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring:2.0.5" level="project" />
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-annotations:2.0.5" level="project" />
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-core:2.0.5" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.22" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.22" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-core:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.9.2" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.9.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: io.springfox:springfox-bean-validators:2.9.2" level="project" />
<orderEntry type="module" module-name="common-redis" />
<orderEntry type="library" name="Maven: redis.clients:jedis:3.1.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.7.0" level="project" />

View File

@@ -1,8 +1,9 @@
package com.orange.demo.courseclassservice.controller;
import io.swagger.annotations.Api;
import cn.jimmyshi.beanquery.BeanQuery;
import com.orange.demo.common.core.base.controller.BaseController;
import com.orange.demo.common.core.base.service.BaseService;
import com.orange.demo.common.core.base.service.IBaseDictService;
import com.orange.demo.common.core.util.MyModelUtil;
import com.orange.demo.common.core.object.*;
import com.orange.demo.courseclassinterface.vo.AreaCodeVo;
@@ -20,6 +21,7 @@ import java.util.*;
* @author Jerry
* @date 2020-08-08
*/
@Api(tags = "行政区划数据访问接口")
@RestController
@RequestMapping("/areaCode")
public class AreaCodeController extends BaseController<AreaCode, AreaCodeVo, Long> {
@@ -28,7 +30,7 @@ public class AreaCodeController extends BaseController<AreaCode, AreaCodeVo, Lon
private AreaCodeService areaCodeService;
@Override
protected BaseService<AreaCode, Long> service() {
protected IBaseDictService<AreaCode, Long> service() {
return areaCodeService;
}

View File

@@ -15,11 +15,13 @@ import com.orange.demo.common.core.object.*;
import com.orange.demo.common.core.util.*;
import com.orange.demo.common.core.constant.*;
import com.orange.demo.common.core.base.controller.BaseController;
import com.orange.demo.common.core.base.service.BaseService;
import com.orange.demo.common.core.base.service.IBaseService;
import com.orange.demo.common.core.annotation.MyRequestBody;
import com.orange.demo.common.core.validator.UpdateGroup;
import com.orange.demo.common.redis.cache.SessionCacheHelper;
import com.orange.demo.courseclassservice.config.ApplicationConfig;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -35,6 +37,7 @@ import java.util.*;
* @author Jerry
* @date 2020-08-08
*/
@Api(tags = "课程数据管理接口")
@Slf4j
@RestController
@RequestMapping("/course")
@@ -50,7 +53,7 @@ public class CourseController extends BaseController<Course, CourseVo, Long> {
private UpDownloaderFactory upDownloaderFactory;
@Override
protected BaseService<Course, Long> service() {
protected IBaseService<Course, Long> service() {
return courseService;
}
@@ -60,6 +63,14 @@ public class CourseController extends BaseController<Course, CourseVo, Long> {
* @param courseDto 新增对象。
* @return 应答结果对象包含新增对象主键Id。
*/
@ApiOperationSupport(ignoreParameters = {
"course.courseId",
"course.priceStart",
"course.priceEnd",
"course.classHourStart",
"course.classHourEnd",
"course.updateTimeStart",
"course.updateTimeEnd"})
@PostMapping("/add")
public ResponseResult<Long> add(@MyRequestBody("course") CourseDto courseDto) {
String errorMessage = MyCommonUtil.getModelValidationError(courseDto);
@@ -83,6 +94,13 @@ public class CourseController extends BaseController<Course, CourseVo, Long> {
* @param courseDto 更新对象。
* @return 应答结果对象。
*/
@ApiOperationSupport(ignoreParameters = {
"course.priceStart",
"course.priceEnd",
"course.classHourStart",
"course.classHourEnd",
"course.updateTimeStart",
"course.updateTimeEnd"})
@PostMapping("/update")
public ResponseResult<Void> update(@MyRequestBody("course") CourseDto courseDto) {
String errorMessage = MyCommonUtil.getModelValidationError(courseDto, Default.class, UpdateGroup.class);
@@ -279,7 +297,7 @@ public class CourseController extends BaseController<Course, CourseVo, Long> {
*/
@GetMapping("/listDict")
public ResponseResult<List<Map<String, Object>>> listDict(Course filter) {
List<Course> resultList = courseService.getListByFilter(filter, null);
List<Course> resultList = courseService.getListByFilter(filter);
return ResponseResult.success(
BeanQuery.select("courseId as id", "courseName as name").executeFrom(resultList));
}
@@ -291,6 +309,7 @@ public class CourseController extends BaseController<Course, CourseVo, Long> {
* @param withDict 是否包含字典关联。
* @return 应答结果对象,包含主对象集合。
*/
@ApiOperation(hidden = true, value = "listByIds")
@PostMapping("/listByIds")
public ResponseResult<List<CourseVo>> listByIds(
@RequestParam Set<Long> courseIds, @RequestParam Boolean withDict) {
@@ -304,6 +323,7 @@ public class CourseController extends BaseController<Course, CourseVo, Long> {
* @param withDict 是否包含字典关联。
* @return 应答结果对象,包含主对象数据。
*/
@ApiOperation(hidden = true, value = "getById")
@PostMapping("/getById")
public ResponseResult<CourseVo> getById(
@RequestParam Long courseId, @RequestParam Boolean withDict) {
@@ -316,6 +336,7 @@ public class CourseController extends BaseController<Course, CourseVo, Long> {
* @param courseIds 主键Id集合。
* @return 应答结果对象包含true全部存在否则false。
*/
@ApiOperation(hidden = true, value = "existIds")
@PostMapping("/existIds")
public ResponseResult<Boolean> existIds(@RequestParam Set<Long> courseIds) {
return super.baseExistIds(courseIds);
@@ -327,6 +348,7 @@ public class CourseController extends BaseController<Course, CourseVo, Long> {
* @param courseId 主键Id。
* @return 应答结果对象包含true表示存在否则false。
*/
@ApiOperation(hidden = true, value = "existId")
@PostMapping("/existId")
public ResponseResult<Boolean> existId(@RequestParam Long courseId) {
return super.baseExistId(courseId);
@@ -338,6 +360,7 @@ public class CourseController extends BaseController<Course, CourseVo, Long> {
* @param filter 过滤对象。
* @return 删除数量。
*/
@ApiOperation(hidden = true, value = "deleteBy")
@PostMapping("/deleteBy")
public ResponseResult<Integer> deleteBy(@RequestBody CourseDto filter) throws Exception {
return super.baseDeleteBy(MyModelUtil.copyTo(filter, Course.class));
@@ -349,6 +372,7 @@ public class CourseController extends BaseController<Course, CourseVo, Long> {
* @param queryParam 查询参数。
* @return 分页数据集合对象。如MyQueryParam参数的分页属性为空则不会执行分页操作只是基于MyPageData对象返回数据结果。
*/
@ApiOperation(hidden = true, value = "listBy")
@PostMapping("/listBy")
public ResponseResult<MyPageData<CourseVo>> listBy(@RequestBody MyQueryParam queryParam) {
return super.baseListBy(queryParam, Course.INSTANCE);
@@ -360,6 +384,7 @@ public class CourseController extends BaseController<Course, CourseVo, Long> {
* @param queryParam 查询参数。
* @return 分页数据集合对象。如MyQueryParam参数的分页属性为空则不会执行分页操作只是基于MyPageData对象返回数据结果。
*/
@ApiOperation(hidden = true, value = "listMapBy")
@PostMapping("/listMapBy")
public ResponseResult<MyPageData<Map<String, Object>>> listMapBy(@RequestBody MyQueryParam queryParam) {
return super.baseListMapBy(queryParam, Course.INSTANCE);
@@ -371,6 +396,7 @@ public class CourseController extends BaseController<Course, CourseVo, Long> {
* @param queryParam 查询参数。
* @return 应答结果对象,包含符合查询过滤条件的对象结果集。
*/
@ApiOperation(hidden = true, value = "getBy")
@PostMapping("/getBy")
public ResponseResult<CourseVo> getBy(@RequestBody MyQueryParam queryParam) {
return super.baseGetBy(queryParam, Course.INSTANCE);
@@ -382,6 +408,7 @@ public class CourseController extends BaseController<Course, CourseVo, Long> {
* @param queryParam 查询参数。
* @return 应答结果对象,包含结果数量。
*/
@ApiOperation(hidden = true, value = "countBy")
@PostMapping("/countBy")
public ResponseResult<Integer> countBy(@RequestBody MyQueryParam queryParam) {
return super.baseCountBy(queryParam);
@@ -393,6 +420,7 @@ public class CourseController extends BaseController<Course, CourseVo, Long> {
* @param aggregationParam 聚合参数。
* @return 应该结果对象包含聚合计算后的分组Map列表。
*/
@ApiOperation(hidden = true, value = "aggregateBy")
@PostMapping("/aggregateBy")
public ResponseResult<List<Map<String, Object>>> aggregateBy(@RequestBody MyAggregationParam aggregationParam) {
return super.baseAggregateBy(aggregationParam);

View File

@@ -1,9 +1,13 @@
package com.orange.demo.courseclassservice.controller;
import com.alibaba.fastjson.JSONObject;
import cn.jimmyshi.beanquery.BeanQuery;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import com.orange.demo.common.core.base.controller.BaseController;
import com.orange.demo.common.core.base.service.BaseDictService;
import com.orange.demo.common.core.base.service.IBaseDictService;
import com.orange.demo.common.core.constant.ErrorCodeEnum;
import com.orange.demo.common.core.object.*;
import com.orange.demo.common.core.util.MyModelUtil;
@@ -26,6 +30,7 @@ import java.util.*;
* @author Jerry
* @date 2020-08-08
*/
@Api(tags = "年级管理接口")
@Slf4j
@RestController
@RequestMapping("/grade")
@@ -35,7 +40,7 @@ public class GradeController extends BaseController<Grade, GradeVo, Integer> {
private GradeService gradeService;
@Override
protected BaseDictService<Grade, Integer> service() {
protected IBaseDictService<Grade, Integer> service() {
return gradeService;
}
@@ -45,6 +50,7 @@ public class GradeController extends BaseController<Grade, GradeVo, Integer> {
* @param gradeDto 新增对象。
* @return 应答结果对象包含新增对象主键Id。
*/
@ApiOperationSupport(ignoreParameters = {"grade.gradeId"})
@PostMapping("/add")
public ResponseResult<Integer> add(@MyRequestBody("grade") GradeDto gradeDto) {
String errorMessage = MyCommonUtil.getModelValidationError(gradeDto);
@@ -116,18 +122,34 @@ public class GradeController extends BaseController<Grade, GradeVo, Integer> {
}
/**
* 以字典形式返回全部年级数据集合。
* 白名单接口,登录用户均可访问
* 白名单接口,登录用户均可访问。以字典形式返回全部年级数据集合。
* 所有数据全部取自于缓存,对于数据库中存在,但是缓存中不存在的数据,不会返回
*
* @return 应答结果对象,包含字典形式的数据集合。
*/
@GetMapping("/listDict")
public ResponseResult<List<Map<String, Object>>> listDict() {
List<Grade> resultList = gradeService.getAllList();
List<Grade> resultList = gradeService.getAllListFromCache();
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集合获取数据对象集合。仅限于微服务间远程接口调用。
*
@@ -135,6 +157,7 @@ public class GradeController extends BaseController<Grade, GradeVo, Integer> {
* @param withDict 是否包含字典关联。
* @return 应答结果对象,包含主对象集合。
*/
@ApiOperation(hidden = true, value = "listByIds")
@PostMapping("/listByIds")
public ResponseResult<List<GradeVo>> listByIds(
@RequestParam Set<Integer> gradeIds, @RequestParam Boolean withDict) {
@@ -148,6 +171,7 @@ public class GradeController extends BaseController<Grade, GradeVo, Integer> {
* @param withDict 是否包含字典关联。
* @return 应答结果对象,包含主对象数据。
*/
@ApiOperation(hidden = true, value = "getById")
@PostMapping("/getById")
public ResponseResult<GradeVo> getById(
@RequestParam Integer gradeId, @RequestParam Boolean withDict) {
@@ -160,6 +184,7 @@ public class GradeController extends BaseController<Grade, GradeVo, Integer> {
* @param gradeIds 主键Id集合。
* @return 应答结果对象包含true全部存在否则false。
*/
@ApiOperation(hidden = true, value = "existIds")
@PostMapping("/existIds")
public ResponseResult<Boolean> existIds(@RequestParam Set<Integer> gradeIds) {
return super.baseExistIds(gradeIds);
@@ -171,6 +196,7 @@ public class GradeController extends BaseController<Grade, GradeVo, Integer> {
* @param gradeId 主键Id。
* @return 应答结果对象包含true全部存在否则false。
*/
@ApiOperation(hidden = true, value = "existId")
@PostMapping("/existId")
public ResponseResult<Boolean> existId(@RequestParam Integer gradeId) {
return super.baseExistId(gradeId);
@@ -182,6 +208,7 @@ public class GradeController extends BaseController<Grade, GradeVo, Integer> {
* @param filter 过滤对象。
* @return 删除数量。
*/
@ApiOperation(hidden = true, value = "deleteBy")
@PostMapping("/deleteBy")
public ResponseResult<Integer> deleteBy(@RequestBody GradeDto filter) throws Exception {
return super.baseDeleteBy(MyModelUtil.copyTo(filter, Grade.class));
@@ -193,6 +220,7 @@ public class GradeController extends BaseController<Grade, GradeVo, Integer> {
* @param queryParam 查询参数。
* @return 应答结果对象,包含符合查询过滤条件的对象结果集。
*/
@ApiOperation(hidden = true, value = "listBy")
@PostMapping("/listBy")
public ResponseResult<MyPageData<GradeVo>> listBy(@RequestBody MyQueryParam queryParam) {
return super.baseListBy(queryParam, null);
@@ -204,6 +232,7 @@ public class GradeController extends BaseController<Grade, GradeVo, Integer> {
* @param queryParam 查询参数。
* @return 应答结果对象,包含符合查询过滤条件的对象结果集。
*/
@ApiOperation(hidden = true, value = "getBy")
@PostMapping("/getBy")
public ResponseResult<GradeVo> getBy(@RequestBody MyQueryParam queryParam) {
return super.baseGetBy(queryParam, null);

View File

@@ -10,9 +10,11 @@ import com.orange.demo.common.core.object.*;
import com.orange.demo.common.core.util.*;
import com.orange.demo.common.core.constant.*;
import com.orange.demo.common.core.base.controller.BaseController;
import com.orange.demo.common.core.base.service.BaseService;
import com.orange.demo.common.core.base.service.IBaseService;
import com.orange.demo.common.core.annotation.MyRequestBody;
import com.orange.demo.common.core.validator.UpdateGroup;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -26,6 +28,7 @@ import java.util.*;
* @author Jerry
* @date 2020-08-08
*/
@Api(tags = "校区数据管理接口")
@Slf4j
@RestController
@RequestMapping("/schoolInfo")
@@ -35,7 +38,7 @@ public class SchoolInfoController extends BaseController<SchoolInfo, SchoolInfoV
private SchoolInfoService schoolInfoService;
@Override
protected BaseService<SchoolInfo, Long> service() {
protected IBaseService<SchoolInfo, Long> service() {
return schoolInfoService;
}
@@ -45,6 +48,7 @@ public class SchoolInfoController extends BaseController<SchoolInfo, SchoolInfoV
* @param schoolInfoDto 新增对象。
* @return 应答结果对象包含新增对象主键Id。
*/
@ApiOperationSupport(ignoreParameters = {"schoolInfo.schoolId"})
@PostMapping("/add")
public ResponseResult<Long> add(@MyRequestBody("schoolInfo") SchoolInfoDto schoolInfoDto) {
String errorMessage = MyCommonUtil.getModelValidationError(schoolInfoDto);
@@ -171,7 +175,7 @@ public class SchoolInfoController extends BaseController<SchoolInfo, SchoolInfoV
*/
@GetMapping("/listDict")
public ResponseResult<List<Map<String, Object>>> listDict(SchoolInfo filter) {
List<SchoolInfo> resultList = schoolInfoService.getListByFilter(filter, null);
List<SchoolInfo> resultList = schoolInfoService.getListByFilter(filter);
return ResponseResult.success(
BeanQuery.select("schoolId as id", "schoolName as name").executeFrom(resultList));
}
@@ -183,6 +187,7 @@ public class SchoolInfoController extends BaseController<SchoolInfo, SchoolInfoV
* @param withDict 是否包含字典关联。
* @return 应答结果对象,包含主对象集合。
*/
@ApiOperation(hidden = true, value = "listByIds")
@PostMapping("/listByIds")
public ResponseResult<List<SchoolInfoVo>> listByIds(
@RequestParam Set<Long> schoolIds, @RequestParam Boolean withDict) {
@@ -196,6 +201,7 @@ public class SchoolInfoController extends BaseController<SchoolInfo, SchoolInfoV
* @param withDict 是否包含字典关联。
* @return 应答结果对象,包含主对象数据。
*/
@ApiOperation(hidden = true, value = "getById")
@PostMapping("/getById")
public ResponseResult<SchoolInfoVo> getById(
@RequestParam Long schoolId, @RequestParam Boolean withDict) {
@@ -208,6 +214,7 @@ public class SchoolInfoController extends BaseController<SchoolInfo, SchoolInfoV
* @param schoolIds 主键Id集合。
* @return 应答结果对象包含true全部存在否则false。
*/
@ApiOperation(hidden = true, value = "existIds")
@PostMapping("/existIds")
public ResponseResult<Boolean> existIds(@RequestParam Set<Long> schoolIds) {
return super.baseExistIds(schoolIds);
@@ -219,6 +226,7 @@ public class SchoolInfoController extends BaseController<SchoolInfo, SchoolInfoV
* @param schoolId 主键Id。
* @return 应答结果对象包含true表示存在否则false。
*/
@ApiOperation(hidden = true, value = "existId")
@PostMapping("/existId")
public ResponseResult<Boolean> existId(@RequestParam Long schoolId) {
return super.baseExistId(schoolId);
@@ -230,6 +238,7 @@ public class SchoolInfoController extends BaseController<SchoolInfo, SchoolInfoV
* @param filter 过滤对象。
* @return 删除数量。
*/
@ApiOperation(hidden = true, value = "deleteBy")
@PostMapping("/deleteBy")
public ResponseResult<Integer> deleteBy(@RequestBody SchoolInfoDto filter) throws Exception {
return super.baseDeleteBy(MyModelUtil.copyTo(filter, SchoolInfo.class));
@@ -241,6 +250,7 @@ public class SchoolInfoController extends BaseController<SchoolInfo, SchoolInfoV
* @param queryParam 查询参数。
* @return 分页数据集合对象。如MyQueryParam参数的分页属性为空则不会执行分页操作只是基于MyPageData对象返回数据结果。
*/
@ApiOperation(hidden = true, value = "listBy")
@PostMapping("/listBy")
public ResponseResult<MyPageData<SchoolInfoVo>> listBy(@RequestBody MyQueryParam queryParam) {
return super.baseListBy(queryParam, SchoolInfo.INSTANCE);
@@ -252,6 +262,7 @@ public class SchoolInfoController extends BaseController<SchoolInfo, SchoolInfoV
* @param queryParam 查询参数。
* @return 分页数据集合对象。如MyQueryParam参数的分页属性为空则不会执行分页操作只是基于MyPageData对象返回数据结果。
*/
@ApiOperation(hidden = true, value = "listMapBy")
@PostMapping("/listMapBy")
public ResponseResult<MyPageData<Map<String, Object>>> listMapBy(@RequestBody MyQueryParam queryParam) {
return super.baseListMapBy(queryParam, SchoolInfo.INSTANCE);
@@ -263,6 +274,7 @@ public class SchoolInfoController extends BaseController<SchoolInfo, SchoolInfoV
* @param queryParam 查询参数。
* @return 应答结果对象,包含符合查询过滤条件的对象结果集。
*/
@ApiOperation(hidden = true, value = "getBy")
@PostMapping("/getBy")
public ResponseResult<SchoolInfoVo> getBy(@RequestBody MyQueryParam queryParam) {
return super.baseGetBy(queryParam, SchoolInfo.INSTANCE);
@@ -274,6 +286,7 @@ public class SchoolInfoController extends BaseController<SchoolInfo, SchoolInfoV
* @param queryParam 查询参数。
* @return 应答结果对象,包含结果数量。
*/
@ApiOperation(hidden = true, value = "countBy")
@PostMapping("/countBy")
public ResponseResult<Integer> countBy(@RequestBody MyQueryParam queryParam) {
return super.baseCountBy(queryParam);
@@ -285,6 +298,7 @@ public class SchoolInfoController extends BaseController<SchoolInfo, SchoolInfoV
* @param aggregationParam 聚合参数。
* @return 应该结果对象包含聚合计算后的分组Map列表。
*/
@ApiOperation(hidden = true, value = "aggregateBy")
@PostMapping("/aggregateBy")
public ResponseResult<List<Map<String, Object>>> aggregateBy(@RequestBody MyAggregationParam aggregationParam) {
return super.baseAggregateBy(aggregationParam);

View File

@@ -9,9 +9,11 @@ import com.orange.demo.common.core.object.*;
import com.orange.demo.common.core.util.*;
import com.orange.demo.common.core.constant.*;
import com.orange.demo.common.core.base.controller.BaseController;
import com.orange.demo.common.core.base.service.BaseService;
import com.orange.demo.common.core.base.service.IBaseService;
import com.orange.demo.common.core.annotation.MyRequestBody;
import com.orange.demo.common.core.validator.UpdateGroup;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -26,6 +28,7 @@ import java.util.stream.Collectors;
* @author Jerry
* @date 2020-08-08
*/
@Api(tags = "班级数据管理接口")
@Slf4j
@RestController
@RequestMapping("/studentClass")
@@ -39,7 +42,7 @@ public class StudentClassController extends BaseController<StudentClass, Student
private StudentService studentService;
@Override
protected BaseService<StudentClass, Long> service() {
protected IBaseService<StudentClass, Long> service() {
return studentClassService;
}
@@ -49,6 +52,7 @@ public class StudentClassController extends BaseController<StudentClass, Student
* @param studentClassDto 新增对象。
* @return 应答结果对象包含新增对象主键Id。
*/
@ApiOperationSupport(ignoreParameters = {"studentClass.classId"})
@PostMapping("/add")
public ResponseResult<Long> add(@MyRequestBody("studentClass") StudentClassDto studentClassDto) {
String errorMessage = MyCommonUtil.getModelValidationError(studentClassDto);
@@ -182,11 +186,9 @@ public class StudentClassController extends BaseController<StudentClass, Student
@MyRequestBody("courseFilter") CourseDto courseDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (MyCommonUtil.existBlankArgument(classId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
if (!studentClassService.existId(classId)) {
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
ResponseResult<Void> verifyResult = this.doClassCourseVerify(classId);
if (!verifyResult.isSuccess()) {
return ResponseResult.errorFrom(verifyResult);
}
if (pageParam != null) {
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
@@ -213,11 +215,9 @@ public class StudentClassController extends BaseController<StudentClass, Student
@MyRequestBody("courseFilter") CourseDto courseDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (MyCommonUtil.existBlankArgument(classId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
if (!studentClassService.existId(classId)) {
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
ResponseResult<Void> verifyResult = this.doClassCourseVerify(classId);
if (!verifyResult.isSuccess()) {
return ResponseResult.errorFrom(verifyResult);
}
if (pageParam != null) {
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
@@ -229,6 +229,16 @@ public class StudentClassController extends BaseController<StudentClass, Student
return ResponseResult.success(MyPageUtil.makeResponseData(courseList, Course.INSTANCE));
}
private ResponseResult<Void> doClassCourseVerify(Long classId) {
if (MyCommonUtil.existBlankArgument(classId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
if (!studentClassService.existId(classId)) {
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
}
return ResponseResult.success();
}
/**
* 批量添加班级数据和 [课程数据] 对象的多对多关联关系数据。
*
@@ -337,11 +347,9 @@ public class StudentClassController extends BaseController<StudentClass, Student
@MyRequestBody("studentFilter") StudentDto studentDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (MyCommonUtil.existBlankArgument(classId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
if (!studentClassService.existId(classId)) {
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
ResponseResult<Void> verifyResult = this.doClassStudentVerify(classId);
if (!verifyResult.isSuccess()) {
return ResponseResult.errorFrom(verifyResult);
}
if (pageParam != null) {
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
@@ -368,11 +376,9 @@ public class StudentClassController extends BaseController<StudentClass, Student
@MyRequestBody("studentFilter") StudentDto studentDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (MyCommonUtil.existBlankArgument(classId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
if (!studentClassService.existId(classId)) {
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
ResponseResult<Void> verifyResult = this.doClassStudentVerify(classId);
if (!verifyResult.isSuccess()) {
return ResponseResult.errorFrom(verifyResult);
}
if (pageParam != null) {
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
@@ -384,6 +390,16 @@ public class StudentClassController extends BaseController<StudentClass, Student
return ResponseResult.success(MyPageUtil.makeResponseData(studentList, Student.INSTANCE));
}
private ResponseResult<Void> doClassStudentVerify(Long classId) {
if (MyCommonUtil.existBlankArgument(classId)) {
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
}
if (!studentClassService.existId(classId)) {
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
}
return ResponseResult.success();
}
/**
* 批量添加班级数据和 [学生数据] 对象的多对多关联关系数据。
*
@@ -442,6 +458,7 @@ public class StudentClassController extends BaseController<StudentClass, Student
* @param withDict 是否包含字典关联。
* @return 应答结果对象,包含主对象集合。
*/
@ApiOperation(hidden = true, value = "listByIds")
@PostMapping("/listByIds")
public ResponseResult<List<StudentClassVo>> listByIds(
@RequestParam Set<Long> classIds, @RequestParam Boolean withDict) {
@@ -455,6 +472,7 @@ public class StudentClassController extends BaseController<StudentClass, Student
* @param withDict 是否包含字典关联。
* @return 应答结果对象,包含主对象数据。
*/
@ApiOperation(hidden = true, value = "getById")
@PostMapping("/getById")
public ResponseResult<StudentClassVo> getById(
@RequestParam Long classId, @RequestParam Boolean withDict) {
@@ -467,6 +485,7 @@ public class StudentClassController extends BaseController<StudentClass, Student
* @param classIds 主键Id集合。
* @return 应答结果对象包含true全部存在否则false。
*/
@ApiOperation(hidden = true, value = "existIds")
@PostMapping("/existIds")
public ResponseResult<Boolean> existIds(@RequestParam Set<Long> classIds) {
return super.baseExistIds(classIds);
@@ -478,6 +497,7 @@ public class StudentClassController extends BaseController<StudentClass, Student
* @param classId 主键Id。
* @return 应答结果对象包含true表示存在否则false。
*/
@ApiOperation(hidden = true, value = "existId")
@PostMapping("/existId")
public ResponseResult<Boolean> existId(@RequestParam Long classId) {
return super.baseExistId(classId);
@@ -489,6 +509,7 @@ public class StudentClassController extends BaseController<StudentClass, Student
* @param filter 过滤对象。
* @return 删除数量。
*/
@ApiOperation(hidden = true, value = "deleteBy")
@PostMapping("/deleteBy")
public ResponseResult<Integer> deleteBy(@RequestBody StudentClassDto filter) throws Exception {
return super.baseDeleteBy(MyModelUtil.copyTo(filter, StudentClass.class));
@@ -500,6 +521,7 @@ public class StudentClassController extends BaseController<StudentClass, Student
* @param queryParam 查询参数。
* @return 分页数据集合对象。如MyQueryParam参数的分页属性为空则不会执行分页操作只是基于MyPageData对象返回数据结果。
*/
@ApiOperation(hidden = true, value = "listBy")
@PostMapping("/listBy")
public ResponseResult<MyPageData<StudentClassVo>> listBy(@RequestBody MyQueryParam queryParam) {
return super.baseListBy(queryParam, StudentClass.INSTANCE);
@@ -511,6 +533,7 @@ public class StudentClassController extends BaseController<StudentClass, Student
* @param queryParam 查询参数。
* @return 分页数据集合对象。如MyQueryParam参数的分页属性为空则不会执行分页操作只是基于MyPageData对象返回数据结果。
*/
@ApiOperation(hidden = true, value = "listMapBy")
@PostMapping("/listMapBy")
public ResponseResult<MyPageData<Map<String, Object>>> listMapBy(@RequestBody MyQueryParam queryParam) {
return super.baseListMapBy(queryParam, StudentClass.INSTANCE);
@@ -522,6 +545,7 @@ public class StudentClassController extends BaseController<StudentClass, Student
* @param queryParam 查询参数。
* @return 应答结果对象,包含符合查询过滤条件的对象结果集。
*/
@ApiOperation(hidden = true, value = "getBy")
@PostMapping("/getBy")
public ResponseResult<StudentClassVo> getBy(@RequestBody MyQueryParam queryParam) {
return super.baseGetBy(queryParam, StudentClass.INSTANCE);
@@ -533,6 +557,7 @@ public class StudentClassController extends BaseController<StudentClass, Student
* @param queryParam 查询参数。
* @return 应答结果对象,包含结果数量。
*/
@ApiOperation(hidden = true, value = "countBy")
@PostMapping("/countBy")
public ResponseResult<Integer> countBy(@RequestBody MyQueryParam queryParam) {
return super.baseCountBy(queryParam);
@@ -544,6 +569,7 @@ public class StudentClassController extends BaseController<StudentClass, Student
* @param aggregationParam 聚合参数。
* @return 应该结果对象包含聚合计算后的分组Map列表。
*/
@ApiOperation(hidden = true, value = "aggregateBy")
@PostMapping("/aggregateBy")
public ResponseResult<List<Map<String, Object>>> aggregateBy(@RequestBody MyAggregationParam aggregationParam) {
return super.baseAggregateBy(aggregationParam);

View File

@@ -10,9 +10,11 @@ import com.orange.demo.common.core.object.*;
import com.orange.demo.common.core.util.*;
import com.orange.demo.common.core.constant.*;
import com.orange.demo.common.core.base.controller.BaseController;
import com.orange.demo.common.core.base.service.BaseService;
import com.orange.demo.common.core.base.service.IBaseService;
import com.orange.demo.common.core.annotation.MyRequestBody;
import com.orange.demo.common.core.validator.UpdateGroup;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -26,6 +28,7 @@ import java.util.*;
* @author Jerry
* @date 2020-08-08
*/
@Api(tags = "学生数据管理接口")
@Slf4j
@RestController
@RequestMapping("/student")
@@ -35,7 +38,7 @@ public class StudentController extends BaseController<Student, StudentVo, Long>
private StudentService studentService;
@Override
protected BaseService<Student, Long> service() {
protected IBaseService<Student, Long> service() {
return studentService;
}
@@ -45,6 +48,13 @@ public class StudentController extends BaseController<Student, StudentVo, Long>
* @param studentDto 新增对象。
* @return 应答结果对象包含新增对象主键Id。
*/
@ApiOperationSupport(ignoreParameters = {
"student.studentId",
"student.searchString",
"student.birthdayStart",
"student.birthdayEnd",
"student.registerTimeStart",
"student.registerTimeEnd"})
@PostMapping("/add")
public ResponseResult<Long> add(@MyRequestBody("student") StudentDto studentDto) {
String errorMessage = MyCommonUtil.getModelValidationError(studentDto);
@@ -68,6 +78,12 @@ public class StudentController extends BaseController<Student, StudentVo, Long>
* @param studentDto 更新对象。
* @return 应答结果对象。
*/
@ApiOperationSupport(ignoreParameters = {
"student.searchString",
"student.birthdayStart",
"student.birthdayEnd",
"student.registerTimeStart",
"student.registerTimeEnd"})
@PostMapping("/update")
public ResponseResult<Void> update(@MyRequestBody("student") StudentDto studentDto) {
String errorMessage = MyCommonUtil.getModelValidationError(studentDto, Default.class, UpdateGroup.class);
@@ -171,7 +187,7 @@ public class StudentController extends BaseController<Student, StudentVo, Long>
*/
@GetMapping("/listDict")
public ResponseResult<List<Map<String, Object>>> listDict(Student filter) {
List<Student> resultList = studentService.getListByFilter(filter, null);
List<Student> resultList = studentService.getListByFilter(filter);
return ResponseResult.success(
BeanQuery.select("studentId as id", "studentName as name").executeFrom(resultList));
}
@@ -183,6 +199,7 @@ public class StudentController extends BaseController<Student, StudentVo, Long>
* @param withDict 是否包含字典关联。
* @return 应答结果对象,包含主对象集合。
*/
@ApiOperation(hidden = true, value = "listByIds")
@PostMapping("/listByIds")
public ResponseResult<List<StudentVo>> listByIds(
@RequestParam Set<Long> studentIds, @RequestParam Boolean withDict) {
@@ -196,6 +213,7 @@ public class StudentController extends BaseController<Student, StudentVo, Long>
* @param withDict 是否包含字典关联。
* @return 应答结果对象,包含主对象数据。
*/
@ApiOperation(hidden = true, value = "getById")
@PostMapping("/getById")
public ResponseResult<StudentVo> getById(
@RequestParam Long studentId, @RequestParam Boolean withDict) {
@@ -208,6 +226,7 @@ public class StudentController extends BaseController<Student, StudentVo, Long>
* @param studentIds 主键Id集合。
* @return 应答结果对象包含true全部存在否则false。
*/
@ApiOperation(hidden = true, value = "existIds")
@PostMapping("/existIds")
public ResponseResult<Boolean> existIds(@RequestParam Set<Long> studentIds) {
return super.baseExistIds(studentIds);
@@ -219,6 +238,7 @@ public class StudentController extends BaseController<Student, StudentVo, Long>
* @param studentId 主键Id。
* @return 应答结果对象包含true表示存在否则false。
*/
@ApiOperation(hidden = true, value = "existId")
@PostMapping("/existId")
public ResponseResult<Boolean> existId(@RequestParam Long studentId) {
return super.baseExistId(studentId);
@@ -230,6 +250,7 @@ public class StudentController extends BaseController<Student, StudentVo, Long>
* @param filter 过滤对象。
* @return 删除数量。
*/
@ApiOperation(hidden = true, value = "deleteBy")
@PostMapping("/deleteBy")
public ResponseResult<Integer> deleteBy(@RequestBody StudentDto filter) throws Exception {
return super.baseDeleteBy(MyModelUtil.copyTo(filter, Student.class));
@@ -241,6 +262,7 @@ public class StudentController extends BaseController<Student, StudentVo, Long>
* @param queryParam 查询参数。
* @return 分页数据集合对象。如MyQueryParam参数的分页属性为空则不会执行分页操作只是基于MyPageData对象返回数据结果。
*/
@ApiOperation(hidden = true, value = "listBy")
@PostMapping("/listBy")
public ResponseResult<MyPageData<StudentVo>> listBy(@RequestBody MyQueryParam queryParam) {
return super.baseListBy(queryParam, Student.INSTANCE);
@@ -252,6 +274,7 @@ public class StudentController extends BaseController<Student, StudentVo, Long>
* @param queryParam 查询参数。
* @return 分页数据集合对象。如MyQueryParam参数的分页属性为空则不会执行分页操作只是基于MyPageData对象返回数据结果。
*/
@ApiOperation(hidden = true, value = "listMapBy")
@PostMapping("/listMapBy")
public ResponseResult<MyPageData<Map<String, Object>>> listMapBy(@RequestBody MyQueryParam queryParam) {
return super.baseListMapBy(queryParam, Student.INSTANCE);
@@ -263,6 +286,7 @@ public class StudentController extends BaseController<Student, StudentVo, Long>
* @param queryParam 查询参数。
* @return 应答结果对象,包含符合查询过滤条件的对象结果集。
*/
@ApiOperation(hidden = true, value = "getBy")
@PostMapping("/getBy")
public ResponseResult<StudentVo> getBy(@RequestBody MyQueryParam queryParam) {
return super.baseGetBy(queryParam, Student.INSTANCE);
@@ -274,6 +298,7 @@ public class StudentController extends BaseController<Student, StudentVo, Long>
* @param queryParam 查询参数。
* @return 应答结果对象,包含结果数量。
*/
@ApiOperation(hidden = true, value = "countBy")
@PostMapping("/countBy")
public ResponseResult<Integer> countBy(@RequestBody MyQueryParam queryParam) {
return super.baseCountBy(queryParam);
@@ -285,6 +310,7 @@ public class StudentController extends BaseController<Student, StudentVo, Long>
* @param aggregationParam 聚合参数。
* @return 应该结果对象包含聚合计算后的分组Map列表。
*/
@ApiOperation(hidden = true, value = "aggregateBy")
@PostMapping("/aggregateBy")
public ResponseResult<List<Map<String, Object>>> aggregateBy(@RequestBody MyAggregationParam aggregationParam) {
return super.baseAggregateBy(aggregationParam);

View File

@@ -38,4 +38,4 @@ public class AreaCode {
*/
@Column(name = "parent_id")
private Long parentId;
}
}

View File

@@ -2,7 +2,6 @@ package com.orange.demo.courseclassservice.model;
import lombok.Data;
import javax.persistence.*;
import javax.validation.constraints.*;
/**
* ClassCourse实体对象。
@@ -17,7 +16,6 @@ public class ClassCourse {
/**
* 班级Id。
*/
@NotNull(message = "数据验证失败班级Id不能为空")
@Id
@Column(name = "class_id")
private Long classId;
@@ -25,7 +23,6 @@ public class ClassCourse {
/**
* 课程Id。
*/
@NotNull(message = "数据验证失败课程Id不能为空")
@Id
@Column(name = "course_id")
private Long courseId;
@@ -33,7 +30,6 @@ public class ClassCourse {
/**
* 课程顺序(数值越小越靠前)。
*/
@NotNull(message = "数据验证失败,课程顺序(数值越小越靠前)不能为空!")
@Column(name = "course_order")
private Integer courseOrder;
}

View File

@@ -2,7 +2,6 @@ package com.orange.demo.courseclassservice.model;
import lombok.Data;
import javax.persistence.*;
import javax.validation.constraints.*;
/**
* ClassStudent实体对象。
@@ -17,7 +16,6 @@ public class ClassStudent {
/**
* 班级Id。
*/
@NotNull(message = "数据验证失败班级Id不能为空")
@Id
@Column(name = "class_id")
private Long classId;
@@ -25,7 +23,6 @@ public class ClassStudent {
/**
* 学生Id。
*/
@NotNull(message = "数据验证失败学生Id不能为空")
@Id
@Column(name = "student_id")
private Long studentId;

View File

@@ -7,13 +7,11 @@ import com.orange.demo.common.core.annotation.UploadFlagColumn;
import com.orange.demo.common.core.annotation.RelationDict;
import com.orange.demo.common.core.annotation.RelationConstDict;
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
import com.orange.demo.common.core.validator.ConstDictRef;
import com.orange.demo.courseclassinterface.vo.CourseVo;
import lombok.Data;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.util.Date;
@@ -32,7 +30,6 @@ public class Course {
/**
* 主键Id。
*/
@NotNull(message = "数据验证失败主键Id不能为空")
@Id
@Column(name = "course_id")
private Long courseId;
@@ -40,14 +37,12 @@ public class Course {
/**
* 课程名称。
*/
@NotBlank(message = "数据验证失败,课程名称不能为空!")
@Column(name = "course_name")
private String courseName;
/**
* 课程价格。
*/
@NotNull(message = "数据验证失败,课程价格不能为空!")
private BigDecimal price;
/**
@@ -58,29 +53,23 @@ public class Course {
/**
* 课程难度(0: 容易 1: 普通 2: 很难)。
*/
@NotNull(message = "数据验证失败,课程难度不能为空!")
@ConstDictRef(constDictClass = CourseDifficult.class, message = "数据验证失败,课程难度为无效值!")
private Integer difficulty;
/**
* 年级Id。
*/
@NotNull(message = "数据验证失败,所属年级不能为空!")
@Column(name = "grade_id")
private Integer gradeId;
/**
* 学科Id。
*/
@NotNull(message = "数据验证失败,所属学科不能为空!")
@ConstDictRef(constDictClass = Subject.class, message = "数据验证失败,所属学科为无效值!")
@Column(name = "subject_id")
private Integer subjectId;
/**
* 课时数量。
*/
@NotNull(message = "数据验证失败,课时数量不能为空!")
@Column(name = "class_hour")
private Integer classHour;
@@ -88,7 +77,6 @@ public class Course {
* 多张课程图片地址。
*/
@UploadFlagColumn(storeType = UploadStoreTypeEnum.LOCAL_SYSTEM)
@NotBlank(message = "数据验证失败,课程图片不能为空!")
@Column(name = "picture_url")
private String pictureUrl;

View File

@@ -4,7 +4,6 @@ import com.alibaba.fastjson.annotation.JSONField;
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
import lombok.Data;
import javax.persistence.*;
import javax.validation.constraints.*;
/**
* Grade实体对象。
@@ -19,7 +18,6 @@ public class Grade {
/**
* 主键Id。
*/
@NotNull(message = "数据验证失败主键Id不能为空")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "grade_id")
@@ -28,7 +26,6 @@ public class Grade {
/**
* 年级名称。
*/
@NotBlank(message = "数据验证失败,年级名称不能为空!")
@Column(name = "grade_name")
private String gradeName;

View File

@@ -2,7 +2,6 @@ package com.orange.demo.courseclassservice.model;
import lombok.Data;
import javax.persistence.*;
import javax.validation.constraints.*;
/**
* MaterialEdition实体对象。
@@ -17,7 +16,6 @@ public class MaterialEdition {
/**
* 主键Id。
*/
@NotNull(message = "数据验证失败主键Id不能为空")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "edition_id")
@@ -26,13 +24,11 @@ public class MaterialEdition {
/**
* 教材版本名称。
*/
@NotBlank(message = "数据验证失败,教材版本名称不能为空!")
@Column(name = "edition_name")
private String editionName;
/**
* 是否正在使用0不是1
*/
@NotNull(message = "数据验证失败是否正在使用0不是1不能为空")
private Integer status;
}

View File

@@ -7,7 +7,6 @@ import lombok.Data;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.util.Map;
@@ -24,7 +23,6 @@ public class SchoolInfo {
/**
* 学校Id。
*/
@NotNull(message = "数据验证失败学校Id不能为空")
@Id
@Column(name = "school_id")
private Long schoolId;
@@ -32,21 +30,18 @@ public class SchoolInfo {
/**
* 学校名称。
*/
@NotBlank(message = "数据验证失败,学校名称不能为空!")
@Column(name = "school_name")
private String schoolName;
/**
* 所在省Id。
*/
@NotNull(message = "数据验证失败,所在省份不能为空!")
@Column(name = "province_id")
private Long provinceId;
/**
* 所在城市Id。
*/
@NotNull(message = "数据验证失败,所在城市不能为空!")
@Column(name = "city_id")
private Long cityId;

View File

@@ -6,13 +6,12 @@ import com.orange.demo.application.common.constant.StudentStatus;
import com.orange.demo.common.core.annotation.RelationDict;
import com.orange.demo.common.core.annotation.RelationConstDict;
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
import com.orange.demo.common.core.validator.ConstDictRef;
import com.orange.demo.common.core.util.MyCommonUtil;
import com.orange.demo.courseclassinterface.vo.StudentVo;
import lombok.Data;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.util.Date;
import java.util.Map;
@@ -30,7 +29,6 @@ public class Student {
/**
* 学生Id。
*/
@NotNull(message = "数据验证失败学生Id不能为空")
@Id
@Column(name = "student_id")
private Long studentId;
@@ -38,84 +36,70 @@ public class Student {
/**
* 登录手机。
*/
@NotBlank(message = "数据验证失败,手机号码不能为空!")
@Column(name = "login_mobile")
private String loginMobile;
/**
* 学生姓名。
*/
@NotBlank(message = "数据验证失败,姓名不能为空!")
@Column(name = "student_name")
private String studentName;
/**
* 所在省份Id。
*/
@NotNull(message = "数据验证失败,所在省份不能为空!")
@Column(name = "province_id")
private Long provinceId;
/**
* 所在城市Id。
*/
@NotNull(message = "数据验证失败,所在城市不能为空!")
@Column(name = "city_id")
private Long cityId;
/**
* 区县Id。
*/
@NotNull(message = "数据验证失败,所在区县不能为空!")
@Column(name = "district_id")
private Long districtId;
/**
* 学生性别 (0: 女生 1: 男生)。
*/
@NotNull(message = "数据验证失败,性别不能为空!")
@ConstDictRef(constDictClass = Gender.class, message = "数据验证失败,性别为无效值!")
private Integer gender;
/**
* 生日。
*/
@NotNull(message = "数据验证失败,生日不能为空!")
private Date birthday;
/**
* 经验等级 (0: 初级 1: 中级 2: 高级 3: 资深)。
*/
@NotNull(message = "数据验证失败,经验等级不能为空!")
@ConstDictRef(constDictClass = ExpLevel.class, message = "数据验证失败,经验等级为无效值!")
@Column(name = "experience_level")
private Integer experienceLevel;
/**
* 总共充值学币数量。
*/
@NotNull(message = "数据验证失败,充值学币不能为空!")
@Column(name = "total_coin")
private Integer totalCoin;
/**
* 可用学币数量。
*/
@NotNull(message = "数据验证失败,剩余学币不能为空!")
@Column(name = "left_coin")
private Integer leftCoin;
/**
* 年级Id。
*/
@NotNull(message = "数据验证失败,年级不能为空!")
@Column(name = "grade_id")
private Integer gradeId;
/**
* 校区Id。
*/
@NotNull(message = "数据验证失败,所属校区不能为空!")
@Column(name = "school_id")
private Long schoolId;
@@ -128,8 +112,6 @@ public class Student {
/**
* 学生状态 (0: 正常 1: 锁定 2: 注销)。
*/
@NotNull(message = "数据验证失败,状态 不能为空!")
@ConstDictRef(constDictClass = StudentStatus.class, message = "数据验证失败,状态 为无效值!")
private Integer status;
/**
@@ -162,6 +144,10 @@ public class Student {
@Transient
private String searchString;
public void setSearchString(String searchString) {
this.searchString = MyCommonUtil.replaceSqlWildcard(searchString);
}
@RelationDict(
masterIdField = "provinceId",
slaveServiceName = "areaCodeService",

View File

@@ -6,13 +6,11 @@ import com.orange.demo.common.core.annotation.RelationDict;
import com.orange.demo.common.core.annotation.RelationConstDict;
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
import com.orange.demo.common.core.validator.ConstDictRef;
import com.orange.demo.courseclassinterface.vo.StudentClassVo;
import lombok.Data;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.util.Date;
import java.util.Map;
@@ -30,7 +28,6 @@ public class StudentClass {
/**
* 班级Id。
*/
@NotNull(message = "数据验证失败班级Id不能为空")
@Id
@Column(name = "class_id")
private Long classId;
@@ -38,36 +35,30 @@ public class StudentClass {
/**
* 班级名称。
*/
@NotBlank(message = "数据验证失败,班级名称不能为空!")
@Column(name = "class_name")
private String className;
/**
* 学校Id。
*/
@NotNull(message = "数据验证失败,所属校区不能为空!")
@Column(name = "school_id")
private Long schoolId;
/**
* 学生班长Id。
*/
@NotNull(message = "数据验证失败,班长不能为空!")
@Column(name = "leader_id")
private Long leaderId;
/**
* 已完成课时数量。
*/
@NotNull(message = "数据验证失败,已完成课时不能为空!")
@Column(name = "finish_class_hour")
private Integer finishClassHour;
/**
* 班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)。
*/
@NotNull(message = "数据验证失败,班级级别不能为空!")
@ConstDictRef(constDictClass = ClassLevel.class, message = "数据验证失败,班级级别为无效值!")
@Column(name = "class_level")
private Integer classLevel;

View File

@@ -1,49 +1,17 @@
package com.orange.demo.courseclassservice.service;
import com.orange.demo.courseclassservice.dao.AreaCodeMapper;
import com.orange.demo.courseclassservice.model.AreaCode;
import com.orange.demo.common.core.cache.MapTreeDictionaryCache;
import com.orange.demo.common.core.base.service.BaseDictService;
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import com.orange.demo.common.core.base.service.IBaseDictService;
import java.util.Collection;
import java.util.List;
/**
* 行政区划的Service
* 行政区划的Service接口
*
* @author Jerry
* @date 2020-08-08
*/
@Service
public class AreaCodeService extends BaseDictService<AreaCode, Long> {
@Autowired
private AreaCodeMapper areaCodeMapper;
public AreaCodeService() {
super();
this.dictionaryCache = MapTreeDictionaryCache.create(AreaCode::getAreaId, AreaCode::getParentId);
}
@Override
protected BaseDaoMapper<AreaCode> mapper() {
return areaCodeMapper;
}
/**
* 加载数据库数据到内存缓存。
*/
@Override
public void loadCachedData() {
Example e = new Example(AreaCode.class);
e.orderBy("areaLevel");
List<AreaCode> areaCodeList = areaCodeMapper.selectByExample(e);
dictionaryCache.putAll(areaCodeList);
}
public interface AreaCodeService extends IBaseDictService<AreaCode, Long> {
/**
* 根据上级行政区划Id获取其下级行政区划列表。
@@ -51,7 +19,5 @@ public class AreaCodeService extends BaseDictService<AreaCode, Long> {
* @param parentId 上级行政区划Id。
* @return 下级行政区划列表。
*/
public Collection<AreaCode> getListByParentId(Long parentId) {
return ((MapTreeDictionaryCache<Long, AreaCode>) dictionaryCache).getListByParentId(parentId);
}
Collection<AreaCode> getListByParentId(Long parentId);
}

View File

@@ -1,48 +1,18 @@
package com.orange.demo.courseclassservice.service;
import com.orange.demo.courseclassservice.dao.*;
import com.orange.demo.courseclassservice.model.*;
import com.orange.demo.common.core.util.*;
import com.orange.demo.common.core.object.MyRelationParam;
import com.orange.demo.common.core.object.CallResult;
import com.orange.demo.common.core.object.TokenData;
import com.orange.demo.common.core.object.MyWhereCriteria;
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
import com.orange.demo.common.core.base.service.BaseService;
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.orange.demo.common.core.base.service.IBaseService;
import java.util.*;
/**
* 课程数据数据操作服务
* 课程数据数据操作服务接口
*
* @author Jerry
* @date 2020-08-08
*/
@Service
public class CourseService extends BaseService<Course, Long> {
@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;
}
public interface CourseService extends IBaseService<Course, Long> {
/**
* 保存新增对象。
@@ -50,17 +20,7 @@ public class CourseService extends BaseService<Course, Long> {
* @param course 新增对象。
* @return 返回新增对象。
*/
@Transactional(rollbackFor = Exception.class)
public Course saveNew(Course course) {
course.setCourseId(idGenerator.nextLongId());
TokenData tokenData = TokenData.takeFromRequest();
course.setCreateUserId(tokenData.getUserId());
Date now = new Date();
course.setCreateTime(now);
course.setUpdateTime(now);
courseMapper.insert(course);
return course;
}
Course saveNew(Course course);
/**
* 更新数据对象。
@@ -69,14 +29,7 @@ public class CourseService extends BaseService<Course, Long> {
* @param originalCourse 原有数据对象。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
public boolean update(Course course, Course originalCourse) {
course.setCreateUserId(originalCourse.getCreateUserId());
course.setCreateTime(originalCourse.getCreateTime());
course.setUpdateTime(new Date());
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
return courseMapper.updateByPrimaryKey(course) == 1;
}
boolean update(Course course, Course originalCourse);
/**
* 删除指定数据。
@@ -84,19 +37,7 @@ public class CourseService extends BaseService<Course, Long> {
* @param courseId 主键Id。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
public boolean remove(Long courseId) {
// 这里先删除主数据
if (courseMapper.deleteByPrimaryKey(courseId) == 0) {
return false;
}
// 这里可继续删除关联数据。
// 开始删除与本地多对多父表的关联
ClassCourse classCourse = new ClassCourse();
classCourse.setCourseId(courseId);
classCourseMapper.delete(classCourse);
return true;
}
boolean remove(Long courseId);
/**
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
@@ -106,9 +47,7 @@ public class CourseService extends BaseService<Course, Long> {
* @param orderBy 排序参数。
* @return 查询结果集。
*/
public List<Course> getCourseList(Course filter, String orderBy) {
return courseMapper.getCourseList(null, null, filter, orderBy);
}
List<Course> getCourseList(Course filter, String orderBy);
/**
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
@@ -121,11 +60,7 @@ public class CourseService extends BaseService<Course, Long> {
* @param orderBy 排序参数。
* @return 查询结果集。
*/
public <M> List<Course> getCourseList(
String inFilterField, Set<M> inFilterValues, Course filter, String orderBy) {
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, Course.class);
return courseMapper.getCourseList(inFilterColumn, inFilterValues, filter, orderBy);
}
<M> List<Course> getCourseList(String inFilterField, Set<M> inFilterValues, Course filter, String orderBy);
/**
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
@@ -135,12 +70,7 @@ public class CourseService extends BaseService<Course, Long> {
* @param orderBy 排序对象。
* @return 查询结果集。
*/
public List<Course> getCourseListWithRelation(Course filter, String orderBy) {
List<Course> resultList = courseMapper.getCourseList(null, null, filter, orderBy);
Map<String, List<MyWhereCriteria>> criteriaMap = buildAggregationAdditionalWhereCriteria();
this.buildRelationForDataList(resultList, MyRelationParam.normal(), criteriaMap);
return resultList;
}
List<Course> getCourseListWithRelation(Course filter, String orderBy);
/**
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
@@ -153,13 +83,8 @@ public class CourseService extends BaseService<Course, Long> {
* @param orderBy 排序对象。
* @return 查询结果集。
*/
public <M> List<Course> getCourseListWithRelation(
String inFilterField, Set<M> inFilterValues, Course filter, String orderBy) {
List<Course> resultList =
courseMapper.getCourseList(inFilterField, inFilterValues, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly(), null);
return resultList;
}
<M> List<Course> getCourseListWithRelation(
String inFilterField, Set<M> inFilterValues, Course filter, String orderBy);
/**
* 在多对多关系中当前Service的数据表为从表返回不与指定主表主键Id存在对多对关系的列表。
@@ -169,13 +94,8 @@ public class CourseService extends BaseService<Course, Long> {
* @param orderBy 排序参数。
* @return 查询结果集。
*/
public List<Course> getNotInCourseListByClassId(
Long classId, Course filter, String orderBy) {
List<Course> resultList =
courseMapper.getNotInCourseListByClassId(classId, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly(), null);
return resultList;
}
List<Course> getNotInCourseListByClassId(
Long classId, Course filter, String orderBy);
/**
* 在多对多关系中当前Service的数据表为从表返回与指定主表主键Id存在对多对关系的列表。
@@ -185,13 +105,8 @@ public class CourseService extends BaseService<Course, Long> {
* @param orderBy 排序参数。
* @return 查询结果集。
*/
public List<Course> getCourseListByClassId(
Long classId, Course filter, String orderBy) {
List<Course> resultList =
courseMapper.getCourseListByClassId(classId, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly(), null);
return resultList;
}
List<Course> getCourseListByClassId(
Long classId, Course filter, String orderBy);
/**
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
@@ -200,12 +115,5 @@ public class CourseService extends BaseService<Course, Long> {
* @param originalCourse 原有数据对象。
* @return 数据全部正确返回true否则false同时返回具体的错误信息。
*/
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();
}
CallResult verifyRelatedData(Course course, Course originalCourse);
}

View File

@@ -1,98 +1,13 @@
package com.orange.demo.courseclassservice.service;
import com.orange.demo.common.redis.cache.RedisDictionaryCache;
import com.orange.demo.common.core.base.service.BaseDictService;
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
import com.orange.demo.courseclassservice.dao.GradeMapper;
import com.orange.demo.common.core.base.service.IBaseDictService;
import com.orange.demo.courseclassservice.model.Grade;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
/**
* 年级数据操作服务
* 年级字典数据操作服务接口
*
* @author Jerry
* @date 2020-08-08
*/
@Service
public class GradeService extends BaseDictService<Grade, Integer> {
@Autowired
private GradeMapper gradeMapper;
@Autowired
private RedissonClient redissonClient;
public GradeService() {
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;
}
/**
* 保存新增对象。
*
* @param grade 新增对象。
* @return 返回新增对象。
*/
@Transactional(rollbackFor = Exception.class)
public Grade saveNew(Grade grade) {
grade.setStatus(GlobalDeletedFlag.NORMAL);
gradeMapper.insert(grade);
dictionaryCache.put(grade.getGradeId(), grade);
return grade;
}
/**
* 更新数据对象。
*
* @param grade 更新的对象。
* @param originalGrade 原有数据对象。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
public boolean update(Grade grade, Grade originalGrade) {
grade.setStatus(GlobalDeletedFlag.NORMAL);
if (gradeMapper.updateByPrimaryKey(grade) != 1) {
return false;
}
dictionaryCache.put(grade.getGradeId(), grade);
return true;
}
/**
* 删除指定数据。
*
* @param gradeId 主键Id。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
public boolean remove(Integer gradeId) {
Grade deletedObject = new Grade();
deletedObject.setGradeId(gradeId);
deletedObject.setStatus(GlobalDeletedFlag.DELETED);
if (gradeMapper.updateByPrimaryKeySelective(deletedObject) != 1) {
return false;
}
dictionaryCache.invalidate(gradeId);
return true;
}
public interface GradeService extends IBaseDictService<Grade, Integer> {
}

View File

@@ -1,45 +1,18 @@
package com.orange.demo.courseclassservice.service;
import com.orange.demo.courseclassservice.dao.*;
import com.orange.demo.courseclassservice.model.*;
import com.orange.demo.common.core.util.*;
import com.orange.demo.common.core.object.MyRelationParam;
import com.orange.demo.common.core.object.CallResult;
import com.orange.demo.common.core.object.MyWhereCriteria;
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
import com.orange.demo.common.core.base.service.BaseService;
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.orange.demo.common.core.base.service.IBaseService;
import java.util.*;
/**
* 校区数据数据操作服务
* 校区数据数据操作服务接口
*
* @author Jerry
* @date 2020-08-08
*/
@Service
public class SchoolInfoService extends BaseService<SchoolInfo, Long> {
@Autowired
private SchoolInfoMapper schoolInfoMapper;
@Autowired
private AreaCodeService areaCodeService;
@Autowired
private IdGeneratorWrapper idGenerator;
/**
* 返回当前Service的主表Mapper对象。
*
* @return 主表Mapper对象。
*/
@Override
protected BaseDaoMapper<SchoolInfo> mapper() {
return schoolInfoMapper;
}
public interface SchoolInfoService extends IBaseService<SchoolInfo, Long> {
/**
* 保存新增对象。
@@ -47,12 +20,7 @@ public class SchoolInfoService extends BaseService<SchoolInfo, Long> {
* @param schoolInfo 新增对象。
* @return 返回新增对象。
*/
@Transactional(rollbackFor = Exception.class)
public SchoolInfo saveNew(SchoolInfo schoolInfo) {
schoolInfo.setSchoolId(idGenerator.nextLongId());
schoolInfoMapper.insert(schoolInfo);
return schoolInfo;
}
SchoolInfo saveNew(SchoolInfo schoolInfo);
/**
* 更新数据对象。
@@ -61,11 +29,7 @@ public class SchoolInfoService extends BaseService<SchoolInfo, Long> {
* @param originalSchoolInfo 原有数据对象。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
public boolean update(SchoolInfo schoolInfo, SchoolInfo originalSchoolInfo) {
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
return schoolInfoMapper.updateByPrimaryKey(schoolInfo) == 1;
}
boolean update(SchoolInfo schoolInfo, SchoolInfo originalSchoolInfo);
/**
* 删除指定数据。
@@ -73,10 +37,7 @@ public class SchoolInfoService extends BaseService<SchoolInfo, Long> {
* @param schoolId 主键Id。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
public boolean remove(Long schoolId) {
return schoolInfoMapper.deleteByPrimaryKey(schoolId) != 0;
}
boolean remove(Long schoolId);
/**
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
@@ -86,9 +47,7 @@ public class SchoolInfoService extends BaseService<SchoolInfo, Long> {
* @param orderBy 排序参数。
* @return 查询结果集。
*/
public List<SchoolInfo> getSchoolInfoList(SchoolInfo filter, String orderBy) {
return schoolInfoMapper.getSchoolInfoList(null, null, filter, orderBy);
}
List<SchoolInfo> getSchoolInfoList(SchoolInfo filter, String orderBy);
/**
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
@@ -101,11 +60,7 @@ public class SchoolInfoService extends BaseService<SchoolInfo, Long> {
* @param orderBy 排序参数。
* @return 查询结果集。
*/
public <M> List<SchoolInfo> getSchoolInfoList(
String inFilterField, Set<M> inFilterValues, SchoolInfo filter, String orderBy) {
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, SchoolInfo.class);
return schoolInfoMapper.getSchoolInfoList(inFilterColumn, inFilterValues, filter, orderBy);
}
<M> List<SchoolInfo> getSchoolInfoList(String inFilterField, Set<M> inFilterValues, SchoolInfo filter, String orderBy);
/**
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
@@ -115,12 +70,7 @@ public class SchoolInfoService extends BaseService<SchoolInfo, Long> {
* @param orderBy 排序对象。
* @return 查询结果集。
*/
public List<SchoolInfo> getSchoolInfoListWithRelation(SchoolInfo filter, String orderBy) {
List<SchoolInfo> resultList = schoolInfoMapper.getSchoolInfoList(null, null, filter, orderBy);
Map<String, List<MyWhereCriteria>> criteriaMap = buildAggregationAdditionalWhereCriteria();
this.buildRelationForDataList(resultList, MyRelationParam.normal(), criteriaMap);
return resultList;
}
List<SchoolInfo> getSchoolInfoListWithRelation(SchoolInfo filter, String orderBy);
/**
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
@@ -133,13 +83,8 @@ public class SchoolInfoService extends BaseService<SchoolInfo, Long> {
* @param orderBy 排序对象。
* @return 查询结果集。
*/
public <M> List<SchoolInfo> getSchoolInfoListWithRelation(
String inFilterField, Set<M> inFilterValues, SchoolInfo filter, String orderBy) {
List<SchoolInfo> resultList =
schoolInfoMapper.getSchoolInfoList(inFilterField, inFilterValues, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly(), null);
return resultList;
}
<M> List<SchoolInfo> getSchoolInfoListWithRelation(
String inFilterField, Set<M> inFilterValues, SchoolInfo filter, String orderBy);
/**
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
@@ -148,16 +93,5 @@ public class SchoolInfoService extends BaseService<SchoolInfo, Long> {
* @param originalSchoolInfo 原有数据对象。
* @return 数据全部正确返回true否则false同时返回具体的错误信息。
*/
public CallResult verifyRelatedData(SchoolInfo schoolInfo, SchoolInfo originalSchoolInfo) {
String errorMessageFormat = "数据验证失败,关联的%s并不存在请刷新后重试";
if (this.needToVerify(schoolInfo, originalSchoolInfo, SchoolInfo::getProvinceId)
&& !areaCodeService.existId(schoolInfo.getProvinceId())) {
return CallResult.error(String.format(errorMessageFormat, "所在省份"));
}
if (this.needToVerify(schoolInfo, originalSchoolInfo, SchoolInfo::getCityId)
&& !areaCodeService.existId(schoolInfo.getCityId())) {
return CallResult.error(String.format(errorMessageFormat, "所在城市"));
}
return CallResult.ok();
}
CallResult verifyRelatedData(SchoolInfo schoolInfo, SchoolInfo originalSchoolInfo);
}

View File

@@ -1,54 +1,18 @@
package com.orange.demo.courseclassservice.service;
import com.orange.demo.courseclassservice.dao.*;
import com.orange.demo.courseclassservice.model.*;
import com.orange.demo.common.core.util.*;
import com.orange.demo.common.core.object.MyRelationParam;
import com.orange.demo.common.core.object.CallResult;
import com.orange.demo.common.core.object.TokenData;
import com.orange.demo.common.core.object.MyWhereCriteria;
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
import com.orange.demo.common.core.base.service.BaseService;
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import com.orange.demo.common.core.base.service.IBaseService;
import java.util.*;
/**
* 班级数据数据操作服务
* 班级数据数据操作服务接口
*
* @author Jerry
* @date 2020-08-08
*/
@Service
public class StudentClassService extends BaseService<StudentClass, Long> {
@Autowired
private StudentClassMapper studentClassMapper;
@Autowired
private ClassCourseMapper classCourseMapper;
@Autowired
private ClassStudentMapper classStudentMapper;
@Autowired
private SchoolInfoService schoolInfoService;
@Autowired
private StudentService studentService;
@Autowired
private IdGeneratorWrapper idGenerator;
/**
* 返回当前Service的主表Mapper对象。
*
* @return 主表Mapper对象。
*/
@Override
protected BaseDaoMapper<StudentClass> mapper() {
return studentClassMapper;
}
public interface StudentClassService extends IBaseService<StudentClass, Long> {
/**
* 保存新增对象。
@@ -56,16 +20,7 @@ public class StudentClassService extends BaseService<StudentClass, Long> {
* @param studentClass 新增对象。
* @return 返回新增对象。
*/
@Transactional(rollbackFor = Exception.class)
public StudentClass saveNew(StudentClass studentClass) {
studentClass.setClassId(idGenerator.nextLongId());
TokenData tokenData = TokenData.takeFromRequest();
studentClass.setCreateUserId(tokenData.getUserId());
studentClass.setCreateTime(new Date());
studentClass.setStatus(GlobalDeletedFlag.NORMAL);
studentClassMapper.insert(studentClass);
return studentClass;
}
StudentClass saveNew(StudentClass studentClass);
/**
* 更新数据对象。
@@ -74,14 +29,7 @@ public class StudentClassService extends BaseService<StudentClass, Long> {
* @param originalStudentClass 原有数据对象。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
public boolean update(StudentClass studentClass, StudentClass originalStudentClass) {
studentClass.setCreateUserId(originalStudentClass.getCreateUserId());
studentClass.setCreateTime(originalStudentClass.getCreateTime());
studentClass.setStatus(GlobalDeletedFlag.NORMAL);
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
return studentClassMapper.updateByPrimaryKey(studentClass) == 1;
}
boolean update(StudentClass studentClass, StudentClass originalStudentClass);
/**
* 删除指定数据。
@@ -89,27 +37,7 @@ public class StudentClassService extends BaseService<StudentClass, Long> {
* @param classId 主键Id。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
public boolean remove(Long classId) {
Example studentClassExample = new Example(StudentClass.class);
Example.Criteria c = studentClassExample.createCriteria();
c.andEqualTo(super.idFieldName, classId);
c.andEqualTo(super.deletedFlagFieldName, GlobalDeletedFlag.NORMAL);
// 这里先删除主数据
StudentClass deletedObject = new StudentClass();
deletedObject.setStatus(GlobalDeletedFlag.DELETED);
if (studentClassMapper.updateByExampleSelective(deletedObject, studentClassExample) == 0) {
return false;
}
// 开始删除多对多中间表的关联
ClassCourse classCourse = new ClassCourse();
classCourse.setClassId(classId);
classCourseMapper.delete(classCourse);
ClassStudent classStudent = new ClassStudent();
classStudent.setClassId(classId);
classStudentMapper.delete(classStudent);
return true;
}
boolean remove(Long classId);
/**
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
@@ -119,9 +47,7 @@ public class StudentClassService extends BaseService<StudentClass, Long> {
* @param orderBy 排序参数。
* @return 查询结果集。
*/
public List<StudentClass> getStudentClassList(StudentClass filter, String orderBy) {
return studentClassMapper.getStudentClassList(null, null, filter, orderBy);
}
List<StudentClass> getStudentClassList(StudentClass filter, String orderBy);
/**
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
@@ -134,11 +60,7 @@ public class StudentClassService extends BaseService<StudentClass, Long> {
* @param orderBy 排序参数。
* @return 查询结果集。
*/
public <M> List<StudentClass> getStudentClassList(
String inFilterField, Set<M> inFilterValues, StudentClass filter, String orderBy) {
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, StudentClass.class);
return studentClassMapper.getStudentClassList(inFilterColumn, inFilterValues, filter, orderBy);
}
<M> List<StudentClass> getStudentClassList(String inFilterField, Set<M> inFilterValues, StudentClass filter, String orderBy);
/**
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
@@ -148,12 +70,7 @@ public class StudentClassService extends BaseService<StudentClass, Long> {
* @param orderBy 排序对象。
* @return 查询结果集。
*/
public List<StudentClass> getStudentClassListWithRelation(StudentClass filter, String orderBy) {
List<StudentClass> resultList = studentClassMapper.getStudentClassList(null, null, filter, orderBy);
Map<String, List<MyWhereCriteria>> criteriaMap = buildAggregationAdditionalWhereCriteria();
this.buildRelationForDataList(resultList, MyRelationParam.normal(), criteriaMap);
return resultList;
}
List<StudentClass> getStudentClassListWithRelation(StudentClass filter, String orderBy);
/**
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
@@ -166,13 +83,8 @@ public class StudentClassService extends BaseService<StudentClass, Long> {
* @param orderBy 排序对象。
* @return 查询结果集。
*/
public <M> List<StudentClass> getStudentClassListWithRelation(
String inFilterField, Set<M> inFilterValues, StudentClass filter, String orderBy) {
List<StudentClass> resultList =
studentClassMapper.getStudentClassList(inFilterField, inFilterValues, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly(), null);
return resultList;
}
<M> List<StudentClass> getStudentClassListWithRelation(
String inFilterField, Set<M> inFilterValues, StudentClass filter, String orderBy);
/**
* 批量添加多对多关联关系。
@@ -180,16 +92,7 @@ public class StudentClassService extends BaseService<StudentClass, Long> {
* @param classCourseList 多对多关联表对象集合。
* @param classId 主表Id。
*/
@Transactional(rollbackFor = Exception.class)
public void addClassCourseList(List<ClassCourse> classCourseList, Long classId) {
for (ClassCourse classCourse : classCourseList) {
classCourse.setClassId(classId);
if (classCourse.getCourseOrder() == null) {
classCourse.setCourseOrder(0);
}
}
classCourseMapper.insertList(classCourseList);
}
void addClassCourseList(List<ClassCourse> classCourseList, Long classId);
/**
* 更新中间表数据。
@@ -197,14 +100,7 @@ public class StudentClassService extends BaseService<StudentClass, Long> {
* @param classCourse 中间表对象。
* @return 更新成功与否。
*/
@Transactional(rollbackFor = Exception.class)
public boolean updateClassCourse(ClassCourse classCourse) {
Example e = new Example(ClassCourse.class);
e.createCriteria()
.andEqualTo("classId", classCourse.getClassId())
.andEqualTo("courseId", classCourse.getCourseId());
return classCourseMapper.updateByExample(classCourse, e) > 0;
}
boolean updateClassCourse(ClassCourse classCourse);
/**
* 获取中间表数据。
@@ -213,13 +109,7 @@ public class StudentClassService extends BaseService<StudentClass, Long> {
* @param courseId 从表Id。
* @return 中间表对象。
*/
public ClassCourse getClassCourse(Long classId, Long courseId) {
Example e = new Example(ClassCourse.class);
e.createCriteria()
.andEqualTo("classId", classId)
.andEqualTo("courseId", courseId);
return classCourseMapper.selectOneByExample(e);
}
ClassCourse getClassCourse(Long classId, Long courseId);
/**
* 移除单条多对多关系。
@@ -228,13 +118,7 @@ public class StudentClassService extends BaseService<StudentClass, Long> {
* @param courseId 从表Id。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
public boolean removeClassCourse(Long classId, Long courseId) {
ClassCourse classCourse = new ClassCourse();
classCourse.setClassId(classId);
classCourse.setCourseId(courseId);
return classCourseMapper.delete(classCourse) > 0;
}
boolean removeClassCourse(Long classId, Long courseId);
/**
* 批量添加多对多关联关系。
@@ -242,13 +126,7 @@ public class StudentClassService extends BaseService<StudentClass, Long> {
* @param classStudentList 多对多关联表对象集合。
* @param classId 主表Id。
*/
@Transactional(rollbackFor = Exception.class)
public void addClassStudentList(List<ClassStudent> classStudentList, Long classId) {
for (ClassStudent classStudent : classStudentList) {
classStudent.setClassId(classId);
}
classStudentMapper.insertList(classStudentList);
}
void addClassStudentList(List<ClassStudent> classStudentList, Long classId);
/**
* 移除单条多对多关系。
@@ -257,13 +135,7 @@ public class StudentClassService extends BaseService<StudentClass, Long> {
* @param studentId 从表Id。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
public boolean removeClassStudent(Long classId, Long studentId) {
ClassStudent classStudent = new ClassStudent();
classStudent.setClassId(classId);
classStudent.setStudentId(studentId);
return classStudentMapper.delete(classStudent) > 0;
}
boolean removeClassStudent(Long classId, Long studentId);
/**
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
@@ -272,16 +144,5 @@ public class StudentClassService extends BaseService<StudentClass, Long> {
* @param originalStudentClass 原有数据对象。
* @return 数据全部正确返回true否则false同时返回具体的错误信息。
*/
public CallResult verifyRelatedData(StudentClass studentClass, StudentClass originalStudentClass) {
String errorMessageFormat = "数据验证失败,关联的%s并不存在请刷新后重试";
if (this.needToVerify(studentClass, originalStudentClass, StudentClass::getSchoolId)
&& !schoolInfoService.existId(studentClass.getSchoolId())) {
return CallResult.error(String.format(errorMessageFormat, "所属校区"));
}
if (this.needToVerify(studentClass, originalStudentClass, StudentClass::getLeaderId)
&& !studentService.existId(studentClass.getLeaderId())) {
return CallResult.error(String.format(errorMessageFormat, "班长"));
}
return CallResult.ok();
}
CallResult verifyRelatedData(StudentClass studentClass, StudentClass originalStudentClass);
}

View File

@@ -1,52 +1,18 @@
package com.orange.demo.courseclassservice.service;
import com.orange.demo.application.common.constant.StudentStatus;
import com.orange.demo.courseclassservice.dao.*;
import com.orange.demo.courseclassservice.model.*;
import com.orange.demo.common.core.util.*;
import com.orange.demo.common.core.object.MyRelationParam;
import com.orange.demo.common.core.object.CallResult;
import com.orange.demo.common.core.object.MyWhereCriteria;
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
import com.orange.demo.common.core.base.service.BaseService;
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.orange.demo.common.core.base.service.IBaseService;
import java.util.*;
/**
* 学生数据数据操作服务
* 学生数据数据操作服务接口
*
* @author Jerry
* @date 2020-08-08
*/
@Service
public class StudentService extends BaseService<Student, Long> {
@Autowired
private StudentMapper studentMapper;
@Autowired
private ClassStudentMapper classStudentMapper;
@Autowired
private SchoolInfoService schoolInfoService;
@Autowired
private AreaCodeService areaCodeService;
@Autowired
private GradeService gradeService;
@Autowired
private IdGeneratorWrapper idGenerator;
/**
* 返回当前Service的主表Mapper对象。
*
* @return 主表Mapper对象。
*/
@Override
protected BaseDaoMapper<Student> mapper() {
return studentMapper;
}
public interface StudentService extends IBaseService<Student, Long> {
/**
* 保存新增对象。
@@ -54,22 +20,7 @@ public class StudentService extends BaseService<Student, Long> {
* @param student 新增对象。
* @return 返回新增对象。
*/
@Transactional(rollbackFor = Exception.class)
public Student saveNew(Student student) {
student.setStudentId(idGenerator.nextLongId());
student.setRegisterTime(new Date());
if (student.getTotalCoin() == null) {
student.setTotalCoin(0);
}
if (student.getLeftCoin() == null) {
student.setLeftCoin(0);
}
if (student.getStatus() == null) {
student.setStatus(StudentStatus.NORMAL);
}
studentMapper.insert(student);
return student;
}
Student saveNew(Student student);
/**
* 更新数据对象。
@@ -78,12 +29,7 @@ public class StudentService extends BaseService<Student, Long> {
* @param originalStudent 原有数据对象。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
public boolean update(Student student, Student originalStudent) {
student.setRegisterTime(originalStudent.getRegisterTime());
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
return studentMapper.updateByPrimaryKey(student) == 1;
}
boolean update(Student student, Student originalStudent);
/**
* 删除指定数据。
@@ -91,19 +37,7 @@ public class StudentService extends BaseService<Student, Long> {
* @param studentId 主键Id。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
public boolean remove(Long studentId) {
// 这里先删除主数据
if (studentMapper.deleteByPrimaryKey(studentId) == 0) {
return false;
}
// 这里可继续删除关联数据。
// 开始删除与本地多对多父表的关联
ClassStudent classStudent = new ClassStudent();
classStudent.setStudentId(studentId);
classStudentMapper.delete(classStudent);
return true;
}
boolean remove(Long studentId);
/**
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
@@ -113,9 +47,7 @@ public class StudentService extends BaseService<Student, Long> {
* @param orderBy 排序参数。
* @return 查询结果集。
*/
public List<Student> getStudentList(Student filter, String orderBy) {
return studentMapper.getStudentList(null, null, filter, orderBy);
}
List<Student> getStudentList(Student filter, String orderBy);
/**
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
@@ -128,11 +60,7 @@ public class StudentService extends BaseService<Student, Long> {
* @param orderBy 排序参数。
* @return 查询结果集。
*/
public <M> List<Student> getStudentList(
String inFilterField, Set<M> inFilterValues, Student filter, String orderBy) {
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, Student.class);
return studentMapper.getStudentList(inFilterColumn, inFilterValues, filter, orderBy);
}
<M> List<Student> getStudentList(String inFilterField, Set<M> inFilterValues, Student filter, String orderBy);
/**
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
@@ -142,12 +70,7 @@ public class StudentService extends BaseService<Student, Long> {
* @param orderBy 排序对象。
* @return 查询结果集。
*/
public List<Student> getStudentListWithRelation(Student filter, String orderBy) {
List<Student> resultList = studentMapper.getStudentList(null, null, filter, orderBy);
Map<String, List<MyWhereCriteria>> criteriaMap = buildAggregationAdditionalWhereCriteria();
this.buildRelationForDataList(resultList, MyRelationParam.normal(), criteriaMap);
return resultList;
}
List<Student> getStudentListWithRelation(Student filter, String orderBy);
/**
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
@@ -160,13 +83,8 @@ public class StudentService extends BaseService<Student, Long> {
* @param orderBy 排序对象。
* @return 查询结果集。
*/
public <M> List<Student> getStudentListWithRelation(
String inFilterField, Set<M> inFilterValues, Student filter, String orderBy) {
List<Student> resultList =
studentMapper.getStudentList(inFilterField, inFilterValues, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly(), null);
return resultList;
}
<M> List<Student> getStudentListWithRelation(
String inFilterField, Set<M> inFilterValues, Student filter, String orderBy);
/**
* 在多对多关系中当前Service的数据表为从表返回不与指定主表主键Id存在对多对关系的列表。
@@ -176,13 +94,8 @@ public class StudentService extends BaseService<Student, Long> {
* @param orderBy 排序参数。
* @return 查询结果集。
*/
public List<Student> getNotInStudentListByClassId(
Long classId, Student filter, String orderBy) {
List<Student> resultList =
studentMapper.getNotInStudentListByClassId(classId, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly(), null);
return resultList;
}
List<Student> getNotInStudentListByClassId(
Long classId, Student filter, String orderBy);
/**
* 在多对多关系中当前Service的数据表为从表返回与指定主表主键Id存在对多对关系的列表。
@@ -192,13 +105,8 @@ public class StudentService extends BaseService<Student, Long> {
* @param orderBy 排序参数。
* @return 查询结果集。
*/
public List<Student> getStudentListByClassId(
Long classId, Student filter, String orderBy) {
List<Student> resultList =
studentMapper.getStudentListByClassId(classId, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly(), null);
return resultList;
}
List<Student> getStudentListByClassId(
Long classId, Student filter, String orderBy);
/**
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
@@ -207,28 +115,5 @@ public class StudentService extends BaseService<Student, Long> {
* @param originalStudent 原有数据对象。
* @return 数据全部正确返回true否则false同时返回具体的错误信息。
*/
public CallResult verifyRelatedData(Student student, Student originalStudent) {
String errorMessageFormat = "数据验证失败,关联的%s并不存在请刷新后重试";
if (this.needToVerify(student, originalStudent, Student::getProvinceId)
&& !areaCodeService.existId(student.getProvinceId())) {
return CallResult.error(String.format(errorMessageFormat, "所在省份"));
}
if (this.needToVerify(student, originalStudent, Student::getCityId)
&& !areaCodeService.existId(student.getCityId())) {
return CallResult.error(String.format(errorMessageFormat, "所在城市"));
}
if (this.needToVerify(student, originalStudent, Student::getDistrictId)
&& !areaCodeService.existId(student.getDistrictId())) {
return CallResult.error(String.format(errorMessageFormat, "所在区县"));
}
if (this.needToVerify(student, originalStudent, Student::getGradeId)
&& !gradeService.existId(student.getGradeId())) {
return CallResult.error(String.format(errorMessageFormat, "年级"));
}
if (this.needToVerify(student, originalStudent, Student::getSchoolId)
&& !schoolInfoService.existId(student.getSchoolId())) {
return CallResult.error(String.format(errorMessageFormat, "所属校区"));
}
return CallResult.ok();
}
CallResult verifyRelatedData(Student student, Student originalStudent);
}

View File

@@ -0,0 +1,59 @@
package com.orange.demo.courseclassservice.service.impl;
import com.orange.demo.courseclassservice.service.AreaCodeService;
import com.orange.demo.courseclassservice.dao.AreaCodeMapper;
import com.orange.demo.courseclassservice.model.AreaCode;
import com.orange.demo.common.core.cache.MapTreeDictionaryCache;
import com.orange.demo.common.core.base.service.BaseDictService;
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.Collection;
import java.util.List;
/**
* 行政区划的Service类。
*
* @author Jerry
* @date 2020-08-08
*/
@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);
}
@Override
protected BaseDaoMapper<AreaCode> mapper() {
return areaCodeMapper;
}
/**
* 加载数据库数据到内存缓存。
*/
@Override
public void loadCachedData() {
Example e = new Example(AreaCode.class);
e.orderBy("areaLevel");
List<AreaCode> areaCodeList = areaCodeMapper.selectByExample(e);
dictionaryCache.putAll(areaCodeList);
}
/**
* 根据上级行政区划Id获取其下级行政区划列表。
*
* @param parentId 上级行政区划Id。
* @return 下级行政区划列表。
*/
@Override
public Collection<AreaCode> getListByParentId(Long parentId) {
return ((MapTreeDictionaryCache<Long, AreaCode>) dictionaryCache).getListByParentId(parentId);
}
}

View File

@@ -0,0 +1,220 @@
package com.orange.demo.courseclassservice.service.impl;
import com.orange.demo.courseclassservice.service.*;
import com.orange.demo.courseclassservice.dao.*;
import com.orange.demo.courseclassservice.model.*;
import com.orange.demo.common.core.util.*;
import com.orange.demo.common.core.object.MyRelationParam;
import com.orange.demo.common.core.object.CallResult;
import com.orange.demo.common.core.object.TokenData;
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
import com.orange.demo.common.core.base.service.BaseService;
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/**
* 课程数据数据操作服务类。
*
* @author Jerry
* @date 2020-08-08
*/
@Service("courseService")
public class CourseServiceImpl extends BaseService<Course, Long> implements CourseService {
@Autowired
private CourseMapper courseMapper;
@Autowired
private ClassCourseMapper classCourseMapper;
@Autowired
private GradeService gradeService;
@Autowired
private IdGeneratorWrapper idGenerator;
/**
* 返回当前Service的主表Mapper对象。
*
* @return 主表Mapper对象。
*/
@Override
protected BaseDaoMapper<Course> mapper() {
return courseMapper;
}
/**
* 保存新增对象。
*
* @param course 新增对象。
* @return 返回新增对象。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public Course saveNew(Course course) {
course.setCourseId(idGenerator.nextLongId());
TokenData tokenData = TokenData.takeFromRequest();
course.setCreateUserId(tokenData.getUserId());
Date now = new Date();
course.setCreateTime(now);
course.setUpdateTime(now);
courseMapper.insert(course);
return course;
}
/**
* 更新数据对象。
*
* @param course 更新的对象。
* @param originalCourse 原有数据对象。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean update(Course course, Course originalCourse) {
course.setCreateUserId(originalCourse.getCreateUserId());
course.setCreateTime(originalCourse.getCreateTime());
course.setUpdateTime(new Date());
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
return courseMapper.updateByPrimaryKey(course) == 1;
}
/**
* 删除指定数据。
*
* @param courseId 主键Id。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean remove(Long courseId) {
// 这里先删除主数据
if (!this.removeById(courseId)) {
return false;
}
// 开始删除与本地多对多父表的关联
ClassCourse classCourse = new ClassCourse();
classCourse.setCourseId(courseId);
classCourseMapper.delete(classCourse);
return true;
}
/**
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getCourseListWithRelation)方法。
*
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public List<Course> getCourseList(Course filter, String orderBy) {
return courseMapper.getCourseList(null, null, filter, orderBy);
}
/**
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
* 由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getCourseListWithRelation)方法。
*
* @param inFilterField (In-list)指定的字段(Java成员字段而非数据列名)。
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public <M> List<Course> getCourseList(
String inFilterField, Set<M> inFilterValues, Course filter, String orderBy) {
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, Course.class);
return courseMapper.getCourseList(inFilterColumn, inFilterValues, filter, orderBy);
}
/**
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
* 如果仅仅需要获取主表数据,请移步(getCourseList),以便获取更好的查询性能。
*
* @param filter 主表过滤对象。
* @param orderBy 排序对象。
* @return 查询结果集。
*/
@Override
public List<Course> getCourseListWithRelation(Course filter, String orderBy) {
List<Course> resultList = courseMapper.getCourseList(null, null, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.normal());
return resultList;
}
/**
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
* 同时还包含主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
* 如果仅仅需要获取主表数据,请移步(getCourseList),以便获取更好的查询性能。
*
* @param inFilterField (In-list)指定的字段(Java成员字段而非数据列名)。
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
* @param filter 主表过滤对象。
* @param orderBy 排序对象。
* @return 查询结果集。
*/
@Override
public <M> List<Course> getCourseListWithRelation(
String inFilterField, Set<M> inFilterValues, Course filter, String orderBy) {
List<Course> resultList =
courseMapper.getCourseList(inFilterField, inFilterValues, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
return resultList;
}
/**
* 在多对多关系中当前Service的数据表为从表返回不与指定主表主键Id存在对多对关系的列表。
*
* @param classId 主表的关联键Id。
* @param filter 从表的过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public List<Course> getNotInCourseListByClassId(
Long classId, Course filter, String orderBy) {
List<Course> resultList =
courseMapper.getNotInCourseListByClassId(classId, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
return resultList;
}
/**
* 在多对多关系中当前Service的数据表为从表返回与指定主表主键Id存在对多对关系的列表。
*
* @param classId 主表的关联键Id。
* @param filter 从表的过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public List<Course> getCourseListByClassId(
Long classId, Course filter, String orderBy) {
List<Course> resultList =
courseMapper.getCourseListByClassId(classId, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
return resultList;
}
/**
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
*
* @param course 最新数据对象。
* @param originalCourse 原有数据对象。
* @return 数据全部正确返回true否则false同时返回具体的错误信息。
*/
@Override
public CallResult verifyRelatedData(Course course, Course originalCourse) {
String errorMessageFormat = "数据验证失败,关联的%s并不存在请刷新后重试";
if (this.needToVerify(course, originalCourse, Course::getGradeId)
&& !gradeService.existId(course.getGradeId())) {
return CallResult.error(String.format(errorMessageFormat, "所属年级"));
}
return CallResult.ok();
}
}

View File

@@ -0,0 +1,48 @@
package com.orange.demo.courseclassservice.service.impl;
import com.orange.demo.common.redis.cache.RedisDictionaryCache;
import com.orange.demo.common.core.base.service.BaseDictService;
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
import com.orange.demo.courseclassservice.service.GradeService;
import com.orange.demo.courseclassservice.dao.GradeMapper;
import com.orange.demo.courseclassservice.model.Grade;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
/**
* 年级字典数据操作服务类。
*
* @author Jerry
* @date 2020-08-08
*/
@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

@@ -0,0 +1,172 @@
package com.orange.demo.courseclassservice.service.impl;
import com.orange.demo.courseclassservice.service.*;
import com.orange.demo.courseclassservice.dao.*;
import com.orange.demo.courseclassservice.model.*;
import com.orange.demo.common.core.util.*;
import com.orange.demo.common.core.object.MyRelationParam;
import com.orange.demo.common.core.object.CallResult;
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
import com.orange.demo.common.core.base.service.BaseService;
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/**
* 校区数据数据操作服务类。
*
* @author Jerry
* @date 2020-08-08
*/
@Service("schoolInfoService")
public class SchoolInfoServiceImpl extends BaseService<SchoolInfo, Long> implements SchoolInfoService {
@Autowired
private SchoolInfoMapper schoolInfoMapper;
@Autowired
private AreaCodeService areaCodeService;
@Autowired
private IdGeneratorWrapper idGenerator;
/**
* 返回当前Service的主表Mapper对象。
*
* @return 主表Mapper对象。
*/
@Override
protected BaseDaoMapper<SchoolInfo> mapper() {
return schoolInfoMapper;
}
/**
* 保存新增对象。
*
* @param schoolInfo 新增对象。
* @return 返回新增对象。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public SchoolInfo saveNew(SchoolInfo schoolInfo) {
schoolInfo.setSchoolId(idGenerator.nextLongId());
schoolInfoMapper.insert(schoolInfo);
return schoolInfo;
}
/**
* 更新数据对象。
*
* @param schoolInfo 更新的对象。
* @param originalSchoolInfo 原有数据对象。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean update(SchoolInfo schoolInfo, SchoolInfo originalSchoolInfo) {
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
return schoolInfoMapper.updateByPrimaryKey(schoolInfo) == 1;
}
/**
* 删除指定数据。
*
* @param schoolId 主键Id。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean remove(Long schoolId) {
// 这里先删除主数据
return this.removeById(schoolId);
}
/**
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getSchoolInfoListWithRelation)方法。
*
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public List<SchoolInfo> getSchoolInfoList(SchoolInfo filter, String orderBy) {
return schoolInfoMapper.getSchoolInfoList(null, null, filter, orderBy);
}
/**
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
* 由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getSchoolInfoListWithRelation)方法。
*
* @param inFilterField (In-list)指定的字段(Java成员字段而非数据列名)。
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public <M> List<SchoolInfo> getSchoolInfoList(
String inFilterField, Set<M> inFilterValues, SchoolInfo filter, String orderBy) {
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, SchoolInfo.class);
return schoolInfoMapper.getSchoolInfoList(inFilterColumn, inFilterValues, filter, orderBy);
}
/**
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
* 如果仅仅需要获取主表数据,请移步(getSchoolInfoList),以便获取更好的查询性能。
*
* @param filter 主表过滤对象。
* @param orderBy 排序对象。
* @return 查询结果集。
*/
@Override
public List<SchoolInfo> getSchoolInfoListWithRelation(SchoolInfo filter, String orderBy) {
List<SchoolInfo> resultList = schoolInfoMapper.getSchoolInfoList(null, null, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.normal());
return resultList;
}
/**
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
* 同时还包含主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
* 如果仅仅需要获取主表数据,请移步(getSchoolInfoList),以便获取更好的查询性能。
*
* @param inFilterField (In-list)指定的字段(Java成员字段而非数据列名)。
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
* @param filter 主表过滤对象。
* @param orderBy 排序对象。
* @return 查询结果集。
*/
@Override
public <M> List<SchoolInfo> getSchoolInfoListWithRelation(
String inFilterField, Set<M> inFilterValues, SchoolInfo filter, String orderBy) {
List<SchoolInfo> resultList =
schoolInfoMapper.getSchoolInfoList(inFilterField, inFilterValues, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
return resultList;
}
/**
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
*
* @param schoolInfo 最新数据对象。
* @param originalSchoolInfo 原有数据对象。
* @return 数据全部正确返回true否则false同时返回具体的错误信息。
*/
@Override
public CallResult verifyRelatedData(SchoolInfo schoolInfo, SchoolInfo originalSchoolInfo) {
String errorMessageFormat = "数据验证失败,关联的%s并不存在请刷新后重试";
if (this.needToVerify(schoolInfo, originalSchoolInfo, SchoolInfo::getProvinceId)
&& !areaCodeService.existId(schoolInfo.getProvinceId())) {
return CallResult.error(String.format(errorMessageFormat, "所在省份"));
}
if (this.needToVerify(schoolInfo, originalSchoolInfo, SchoolInfo::getCityId)
&& !areaCodeService.existId(schoolInfo.getCityId())) {
return CallResult.error(String.format(errorMessageFormat, "所在城市"));
}
return CallResult.ok();
}
}

View File

@@ -0,0 +1,293 @@
package com.orange.demo.courseclassservice.service.impl;
import com.orange.demo.courseclassservice.service.*;
import com.orange.demo.courseclassservice.dao.*;
import com.orange.demo.courseclassservice.model.*;
import com.orange.demo.common.core.util.*;
import com.orange.demo.common.core.object.MyRelationParam;
import com.orange.demo.common.core.object.CallResult;
import com.orange.demo.common.core.object.TokenData;
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
import com.orange.demo.common.core.base.service.BaseService;
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.util.*;
/**
* 班级数据数据操作服务类。
*
* @author Jerry
* @date 2020-08-08
*/
@Service("studentClassService")
public class StudentClassServiceImpl extends BaseService<StudentClass, Long> implements StudentClassService {
@Autowired
private StudentClassMapper studentClassMapper;
@Autowired
private ClassCourseMapper classCourseMapper;
@Autowired
private ClassStudentMapper classStudentMapper;
@Autowired
private SchoolInfoService schoolInfoService;
@Autowired
private StudentService studentService;
@Autowired
private IdGeneratorWrapper idGenerator;
/**
* 返回当前Service的主表Mapper对象。
*
* @return 主表Mapper对象。
*/
@Override
protected BaseDaoMapper<StudentClass> mapper() {
return studentClassMapper;
}
/**
* 保存新增对象。
*
* @param studentClass 新增对象。
* @return 返回新增对象。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public StudentClass saveNew(StudentClass studentClass) {
studentClass.setClassId(idGenerator.nextLongId());
TokenData tokenData = TokenData.takeFromRequest();
studentClass.setCreateUserId(tokenData.getUserId());
studentClass.setCreateTime(new Date());
studentClass.setStatus(GlobalDeletedFlag.NORMAL);
studentClassMapper.insert(studentClass);
return studentClass;
}
/**
* 更新数据对象。
*
* @param studentClass 更新的对象。
* @param originalStudentClass 原有数据对象。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean update(StudentClass studentClass, StudentClass originalStudentClass) {
studentClass.setCreateUserId(originalStudentClass.getCreateUserId());
studentClass.setCreateTime(originalStudentClass.getCreateTime());
studentClass.setStatus(GlobalDeletedFlag.NORMAL);
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
return studentClassMapper.updateByPrimaryKey(studentClass) == 1;
}
/**
* 删除指定数据。
*
* @param classId 主键Id。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean remove(Long classId) {
// 这里先删除主数据
if (!this.removeById(classId)) {
return false;
}
// 开始删除多对多中间表的关联
ClassCourse classCourse = new ClassCourse();
classCourse.setClassId(classId);
classCourseMapper.delete(classCourse);
ClassStudent classStudent = new ClassStudent();
classStudent.setClassId(classId);
classStudentMapper.delete(classStudent);
return true;
}
/**
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getStudentClassListWithRelation)方法。
*
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public List<StudentClass> getStudentClassList(StudentClass filter, String orderBy) {
return studentClassMapper.getStudentClassList(null, null, filter, orderBy);
}
/**
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
* 由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getStudentClassListWithRelation)方法。
*
* @param inFilterField (In-list)指定的字段(Java成员字段而非数据列名)。
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public <M> List<StudentClass> getStudentClassList(
String inFilterField, Set<M> inFilterValues, StudentClass filter, String orderBy) {
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, StudentClass.class);
return studentClassMapper.getStudentClassList(inFilterColumn, inFilterValues, filter, orderBy);
}
/**
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
* 如果仅仅需要获取主表数据,请移步(getStudentClassList),以便获取更好的查询性能。
*
* @param filter 主表过滤对象。
* @param orderBy 排序对象。
* @return 查询结果集。
*/
@Override
public List<StudentClass> getStudentClassListWithRelation(StudentClass filter, String orderBy) {
List<StudentClass> resultList = studentClassMapper.getStudentClassList(null, null, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.normal());
return resultList;
}
/**
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
* 同时还包含主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
* 如果仅仅需要获取主表数据,请移步(getStudentClassList),以便获取更好的查询性能。
*
* @param inFilterField (In-list)指定的字段(Java成员字段而非数据列名)。
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
* @param filter 主表过滤对象。
* @param orderBy 排序对象。
* @return 查询结果集。
*/
@Override
public <M> List<StudentClass> getStudentClassListWithRelation(
String inFilterField, Set<M> inFilterValues, StudentClass filter, String orderBy) {
List<StudentClass> resultList =
studentClassMapper.getStudentClassList(inFilterField, inFilterValues, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
return resultList;
}
/**
* 批量添加多对多关联关系。
*
* @param classCourseList 多对多关联表对象集合。
* @param classId 主表Id。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void addClassCourseList(List<ClassCourse> classCourseList, Long classId) {
for (ClassCourse classCourse : classCourseList) {
classCourse.setClassId(classId);
MyModelUtil.setDefaultValue(classCourse, "courseOrder", 0);
}
classCourseMapper.insertList(classCourseList);
}
/**
* 更新中间表数据。
*
* @param classCourse 中间表对象。
* @return 更新成功与否。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateClassCourse(ClassCourse classCourse) {
Example e = new Example(ClassCourse.class);
e.createCriteria()
.andEqualTo("classId", classCourse.getClassId())
.andEqualTo("courseId", classCourse.getCourseId());
return classCourseMapper.updateByExample(classCourse, e) > 0;
}
/**
* 获取中间表数据。
*
* @param classId 主表Id。
* @param courseId 从表Id。
* @return 中间表对象。
*/
@Override
public ClassCourse getClassCourse(Long classId, Long courseId) {
Example e = new Example(ClassCourse.class);
e.createCriteria()
.andEqualTo("classId", classId)
.andEqualTo("courseId", courseId);
return classCourseMapper.selectOneByExample(e);
}
/**
* 移除单条多对多关系。
*
* @param classId 主表Id。
* @param courseId 从表Id。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean removeClassCourse(Long classId, Long courseId) {
ClassCourse filter = new ClassCourse();
filter.setClassId(classId);
filter.setCourseId(courseId);
return classCourseMapper.delete(filter) > 0;
}
/**
* 批量添加多对多关联关系。
*
* @param classStudentList 多对多关联表对象集合。
* @param classId 主表Id。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void addClassStudentList(List<ClassStudent> classStudentList, Long classId) {
for (ClassStudent classStudent : classStudentList) {
classStudent.setClassId(classId);
}
classStudentMapper.insertList(classStudentList);
}
/**
* 移除单条多对多关系。
*
* @param classId 主表Id。
* @param studentId 从表Id。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean removeClassStudent(Long classId, Long studentId) {
ClassStudent filter = new ClassStudent();
filter.setClassId(classId);
filter.setStudentId(studentId);
return classStudentMapper.delete(filter) > 0;
}
/**
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
*
* @param studentClass 最新数据对象。
* @param originalStudentClass 原有数据对象。
* @return 数据全部正确返回true否则false同时返回具体的错误信息。
*/
@Override
public CallResult verifyRelatedData(StudentClass studentClass, StudentClass originalStudentClass) {
String errorMessageFormat = "数据验证失败,关联的%s并不存在请刷新后重试";
if (this.needToVerify(studentClass, originalStudentClass, StudentClass::getSchoolId)
&& !schoolInfoService.existId(studentClass.getSchoolId())) {
return CallResult.error(String.format(errorMessageFormat, "所属校区"));
}
if (this.needToVerify(studentClass, originalStudentClass, StudentClass::getLeaderId)
&& !studentService.existId(studentClass.getLeaderId())) {
return CallResult.error(String.format(errorMessageFormat, "班长"));
}
return CallResult.ok();
}
}

View File

@@ -0,0 +1,237 @@
package com.orange.demo.courseclassservice.service.impl;
import com.orange.demo.application.common.constant.StudentStatus;
import com.orange.demo.courseclassservice.service.*;
import com.orange.demo.courseclassservice.dao.*;
import com.orange.demo.courseclassservice.model.*;
import com.orange.demo.common.core.util.*;
import com.orange.demo.common.core.object.MyRelationParam;
import com.orange.demo.common.core.object.CallResult;
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
import com.orange.demo.common.core.base.service.BaseService;
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/**
* 学生数据数据操作服务类。
*
* @author Jerry
* @date 2020-08-08
*/
@Service("studentService")
public class StudentServiceImpl extends BaseService<Student, Long> implements StudentService {
@Autowired
private StudentMapper studentMapper;
@Autowired
private ClassStudentMapper classStudentMapper;
@Autowired
private SchoolInfoService schoolInfoService;
@Autowired
private AreaCodeService areaCodeService;
@Autowired
private GradeService gradeService;
@Autowired
private IdGeneratorWrapper idGenerator;
/**
* 返回当前Service的主表Mapper对象。
*
* @return 主表Mapper对象。
*/
@Override
protected BaseDaoMapper<Student> mapper() {
return studentMapper;
}
/**
* 保存新增对象。
*
* @param student 新增对象。
* @return 返回新增对象。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public Student saveNew(Student student) {
student.setStudentId(idGenerator.nextLongId());
student.setRegisterTime(new Date());
MyModelUtil.setDefaultValue(student, "totalCoin", 0);
MyModelUtil.setDefaultValue(student, "leftCoin", 0);
MyModelUtil.setDefaultValue(student, "status", StudentStatus.NORMAL);
studentMapper.insert(student);
return student;
}
/**
* 更新数据对象。
*
* @param student 更新的对象。
* @param originalStudent 原有数据对象。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean update(Student student, Student originalStudent) {
student.setRegisterTime(originalStudent.getRegisterTime());
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
return studentMapper.updateByPrimaryKey(student) == 1;
}
/**
* 删除指定数据。
*
* @param studentId 主键Id。
* @return 成功返回true否则false。
*/
@Transactional(rollbackFor = Exception.class)
@Override
public boolean remove(Long studentId) {
// 这里先删除主数据
if (!this.removeById(studentId)) {
return false;
}
// 开始删除与本地多对多父表的关联
ClassStudent classStudent = new ClassStudent();
classStudent.setStudentId(studentId);
classStudentMapper.delete(classStudent);
return true;
}
/**
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getStudentListWithRelation)方法。
*
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public List<Student> getStudentList(Student filter, String orderBy) {
return studentMapper.getStudentList(null, null, filter, orderBy);
}
/**
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
* 由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getStudentListWithRelation)方法。
*
* @param inFilterField (In-list)指定的字段(Java成员字段而非数据列名)。
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public <M> List<Student> getStudentList(
String inFilterField, Set<M> inFilterValues, Student filter, String orderBy) {
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, Student.class);
return studentMapper.getStudentList(inFilterColumn, inFilterValues, filter, orderBy);
}
/**
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
* 如果仅仅需要获取主表数据,请移步(getStudentList),以便获取更好的查询性能。
*
* @param filter 主表过滤对象。
* @param orderBy 排序对象。
* @return 查询结果集。
*/
@Override
public List<Student> getStudentListWithRelation(Student filter, String orderBy) {
List<Student> resultList = studentMapper.getStudentList(null, null, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.normal());
return resultList;
}
/**
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
* 同时还包含主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
* 如果仅仅需要获取主表数据,请移步(getStudentList),以便获取更好的查询性能。
*
* @param inFilterField (In-list)指定的字段(Java成员字段而非数据列名)。
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
* @param filter 主表过滤对象。
* @param orderBy 排序对象。
* @return 查询结果集。
*/
@Override
public <M> List<Student> getStudentListWithRelation(
String inFilterField, Set<M> inFilterValues, Student filter, String orderBy) {
List<Student> resultList =
studentMapper.getStudentList(inFilterField, inFilterValues, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
return resultList;
}
/**
* 在多对多关系中当前Service的数据表为从表返回不与指定主表主键Id存在对多对关系的列表。
*
* @param classId 主表的关联键Id。
* @param filter 从表的过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public List<Student> getNotInStudentListByClassId(
Long classId, Student filter, String orderBy) {
List<Student> resultList =
studentMapper.getNotInStudentListByClassId(classId, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
return resultList;
}
/**
* 在多对多关系中当前Service的数据表为从表返回与指定主表主键Id存在对多对关系的列表。
*
* @param classId 主表的关联键Id。
* @param filter 从表的过滤对象。
* @param orderBy 排序参数。
* @return 查询结果集。
*/
@Override
public List<Student> getStudentListByClassId(
Long classId, Student filter, String orderBy) {
List<Student> resultList =
studentMapper.getStudentListByClassId(classId, filter, orderBy);
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
return resultList;
}
/**
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
*
* @param student 最新数据对象。
* @param originalStudent 原有数据对象。
* @return 数据全部正确返回true否则false同时返回具体的错误信息。
*/
@Override
public CallResult verifyRelatedData(Student student, Student originalStudent) {
String errorMessageFormat = "数据验证失败,关联的%s并不存在请刷新后重试";
if (this.needToVerify(student, originalStudent, Student::getProvinceId)
&& !areaCodeService.existId(student.getProvinceId())) {
return CallResult.error(String.format(errorMessageFormat, "所在省份"));
}
if (this.needToVerify(student, originalStudent, Student::getCityId)
&& !areaCodeService.existId(student.getCityId())) {
return CallResult.error(String.format(errorMessageFormat, "所在城市"));
}
if (this.needToVerify(student, originalStudent, Student::getDistrictId)
&& !areaCodeService.existId(student.getDistrictId())) {
return CallResult.error(String.format(errorMessageFormat, "所在区县"));
}
if (this.needToVerify(student, originalStudent, Student::getGradeId)
&& !gradeService.existId(student.getGradeId())) {
return CallResult.error(String.format(errorMessageFormat, "年级"));
}
if (this.needToVerify(student, originalStudent, Student::getSchoolId)
&& !schoolInfoService.existId(student.getSchoolId())) {
return CallResult.error(String.format(errorMessageFormat, "所属校区"));
}
return CallResult.ok();
}
}

View File

@@ -59,6 +59,9 @@
<Root level="${OUTPUT_LOG_LEVEL}">
<AppenderRef ref="console"/>
</Root>
<Logger name="springfox.documentation" additivity="false" level="error">
<AppenderRef ref="console"/>
</Logger>
<!-- AsyncLogger 是基于Disruptor的全量异步队列性能极高队列默认大小4096。-->
<!-- 队列默认值可通过JVM参数设置参考博客https://www.jianshu.com/p/82469047acbf -->
<AsyncLogger name="com.orange.demo" additivity="false" level="info">