mirror of
https://gitee.com/orangeform/orange-admin.git
synced 2026-01-17 18:46:36 +08:00
commit:同步1.3版本
This commit is contained in:
@@ -30,6 +30,11 @@
|
||||
<artifactId>application-common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.orange.demo</groupId>
|
||||
<artifactId>common-swagger</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.orange.demo.app.controller;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import cn.jimmyshi.beanquery.BeanQuery;
|
||||
import com.orange.demo.app.model.AreaCode;
|
||||
import com.orange.demo.app.service.AreaCodeService;
|
||||
@@ -19,6 +20,7 @@ import java.util.*;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Api(tags = "行政区划数据访问接口")
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/areaCode")
|
||||
public class AreaCodeController {
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.orange.demo.common.core.upload.UploadResponseInfo;
|
||||
import com.orange.demo.common.core.upload.UploadStoreInfo;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.orange.demo.app.vo.*;
|
||||
import com.orange.demo.app.dto.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.app.service.*;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
@@ -17,6 +18,8 @@ import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.cache.SessionCacheHelper;
|
||||
import com.orange.demo.config.ApplicationConfig;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -32,6 +35,7 @@ import javax.validation.groups.Default;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Api(tags = "课程数据管理接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/course")
|
||||
@@ -49,15 +53,24 @@ public class CourseController {
|
||||
/**
|
||||
* 新增课程数据数据。
|
||||
*
|
||||
* @param course 新增对象。
|
||||
* @param courseDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@ApiOperationSupport(ignoreParameters = {
|
||||
"course.courseId",
|
||||
"course.priceStart",
|
||||
"course.priceEnd",
|
||||
"course.classHourStart",
|
||||
"course.classHourEnd",
|
||||
"course.createTimeStart",
|
||||
"course.createTimeEnd"})
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody Course course) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(course);
|
||||
public ResponseResult<Long> add(@MyRequestBody("course") CourseDto courseDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(courseDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
Course course = MyModelUtil.copyTo(courseDto, Course.class);
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = courseService.verifyRelatedData(course, null);
|
||||
if (!callResult.isSuccess()) {
|
||||
@@ -71,16 +84,23 @@ public class CourseController {
|
||||
/**
|
||||
* 更新课程数据数据。
|
||||
*
|
||||
* @param course 更新对象。
|
||||
* @param courseDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@ApiOperationSupport(ignoreParameters = {
|
||||
"course.priceStart",
|
||||
"course.priceEnd",
|
||||
"course.classHourStart",
|
||||
"course.classHourEnd",
|
||||
"course.createTimeStart",
|
||||
"course.createTimeEnd"})
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody Course course) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(course, Default.class, UpdateGroup.class);
|
||||
public ResponseResult<Void> update(@MyRequestBody("course") CourseDto courseDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(courseDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
Course course = MyModelUtil.copyTo(courseDto, Course.class);
|
||||
Course originalCourse = courseService.getById(course.getCourseId());
|
||||
if (originalCourse == null) {
|
||||
// NOTE: 修改下面方括号中的话述
|
||||
@@ -128,19 +148,20 @@ public class CourseController {
|
||||
/**
|
||||
* 列出符合过滤条件的课程数据列表。
|
||||
*
|
||||
* @param courseFilter 过滤对象。
|
||||
* @param courseDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<CourseVo>> list(
|
||||
@MyRequestBody Course courseFilter,
|
||||
@MyRequestBody("courseFilter") CourseDto courseDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
Course courseFilter = MyModelUtil.copyTo(courseDtoFilter, Course.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Course.class);
|
||||
List<Course> courseList = courseService.getCourseListWithRelation(courseFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(courseList, Course.INSTANCE));
|
||||
@@ -267,7 +288,7 @@ public class CourseController {
|
||||
*/
|
||||
@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));
|
||||
}
|
||||
|
||||
@@ -2,12 +2,14 @@ package com.orange.demo.app.controller;
|
||||
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.orange.demo.app.vo.*;
|
||||
import com.orange.demo.app.dto.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.app.service.*;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.constant.*;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -20,6 +22,7 @@ import java.util.*;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Api(tags = "课程统计管理接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/courseTransStats")
|
||||
@@ -31,19 +34,20 @@ public class CourseTransStatsController {
|
||||
/**
|
||||
* 列出符合过滤条件的课程统计列表。
|
||||
*
|
||||
* @param courseTransStatsFilter 过滤对象。
|
||||
* @param courseTransStatsDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<CourseTransStatsVo>> list(
|
||||
@MyRequestBody CourseTransStats courseTransStatsFilter,
|
||||
@MyRequestBody("courseTransStatsFilter") CourseTransStatsDto courseTransStatsDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
CourseTransStats courseTransStatsFilter = MyModelUtil.copyTo(courseTransStatsDtoFilter, CourseTransStats.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, CourseTransStats.class);
|
||||
List<CourseTransStats> courseTransStatsList = courseTransStatsService.getCourseTransStatsListWithRelation(courseTransStatsFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(courseTransStatsList, CourseTransStats.INSTANCE));
|
||||
@@ -52,7 +56,7 @@ public class CourseTransStatsController {
|
||||
/**
|
||||
* 分组列出符合过滤条件的课程统计列表。
|
||||
*
|
||||
* @param courseTransStatsFilter 过滤对象。
|
||||
* @param courseTransStatsDtoFilter 过滤对象。
|
||||
* @param groupParam 分组参数。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
@@ -60,7 +64,7 @@ public class CourseTransStatsController {
|
||||
*/
|
||||
@PostMapping("/listWithGroup")
|
||||
public ResponseResult<MyPageData<CourseTransStatsVo>> listWithGroup(
|
||||
@MyRequestBody CourseTransStats courseTransStatsFilter,
|
||||
@MyRequestBody("courseTransStatsFilter") CourseTransStatsDto courseTransStatsDtoFilter,
|
||||
@MyRequestBody(required = true) MyGroupParam groupParam,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
@@ -73,9 +77,10 @@ public class CourseTransStatsController {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
CourseTransStats filter = MyModelUtil.copyTo(courseTransStatsDtoFilter, CourseTransStats.class);
|
||||
MyGroupCriteria criteria = groupParam.getGroupCriteria();
|
||||
List<CourseTransStats> resultList = courseTransStatsService.getGroupedCourseTransStatsListWithRelation(
|
||||
courseTransStatsFilter, criteria.getGroupSelect(), criteria.getGroupBy(), orderBy);
|
||||
filter, criteria.getGroupSelect(), criteria.getGroupBy(), orderBy);
|
||||
// 分页连同对象数据转换copy工作,下面的方法一并完成。
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(resultList, CourseTransStats.INSTANCE));
|
||||
}
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
package com.orange.demo.app.controller;
|
||||
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.app.service.*;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import cn.jimmyshi.beanquery.BeanQuery;
|
||||
import com.orange.demo.app.dto.GradeDto;
|
||||
import com.orange.demo.app.model.Grade;
|
||||
import com.orange.demo.app.service.GradeService;
|
||||
import com.orange.demo.common.core.constant.ErrorCodeEnum;
|
||||
import com.orange.demo.common.core.util.MyModelUtil;
|
||||
import com.orange.demo.common.core.util.MyCommonUtil;
|
||||
import com.orange.demo.common.core.object.ResponseResult;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import cn.jimmyshi.beanquery.BeanQuery;
|
||||
|
||||
import javax.validation.groups.Default;
|
||||
import java.util.*;
|
||||
@@ -22,6 +27,7 @@ import java.util.*;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Api(tags = "年级管理接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/grade")
|
||||
@@ -33,15 +39,17 @@ public class GradeController {
|
||||
/**
|
||||
* 新增年级数据。
|
||||
*
|
||||
* @param grade 新增对象。
|
||||
* @param gradeDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@ApiOperationSupport(ignoreParameters = {"grade.gradeId"})
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Integer> add(@MyRequestBody Grade grade) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(grade);
|
||||
public ResponseResult<Integer> add(@MyRequestBody("grade") GradeDto gradeDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(gradeDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
Grade grade = MyModelUtil.copyTo(gradeDto, Grade.class);
|
||||
grade = gradeService.saveNew(grade);
|
||||
return ResponseResult.success(grade.getGradeId());
|
||||
}
|
||||
@@ -49,15 +57,16 @@ public class GradeController {
|
||||
/**
|
||||
* 更新年级数据。
|
||||
*
|
||||
* @param grade 更新对象。
|
||||
* @param gradeDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody Grade grade) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(grade, Default.class, UpdateGroup.class);
|
||||
public ResponseResult<Void> update(@MyRequestBody("grade") GradeDto gradeDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(gradeDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
Grade grade = MyModelUtil.copyTo(gradeDto, Grade.class);
|
||||
Grade originalGrade = gradeService.getById(grade.getGradeId());
|
||||
if (originalGrade == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
@@ -86,18 +95,34 @@ public class GradeController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 以字典形式返回全部年级数据集合。
|
||||
* 白名单接口,登录用户均可访问。
|
||||
* 白名单接口,登录用户均可访问。以字典形式返回全部年级数据集合。
|
||||
* 所有数据全部取自于缓存,对于数据库中存在,但是缓存中不存在的数据,不会返回。
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将当前字典表的数据重新加载到缓存中。
|
||||
* 由于缓存的数据更新,在add/update/delete等接口均有同步处理。因此该接口仅当同步过程中出现问题时,
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.orange.demo.app.controller;
|
||||
import cn.jimmyshi.beanquery.BeanQuery;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.orange.demo.app.vo.*;
|
||||
import com.orange.demo.app.dto.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.app.service.*;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
@@ -10,6 +11,8 @@ import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.constant.*;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -23,6 +26,7 @@ import javax.validation.groups.Default;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Api(tags = "校区数据管理接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/schoolInfo")
|
||||
@@ -34,15 +38,17 @@ public class SchoolInfoController {
|
||||
/**
|
||||
* 新增校区数据数据。
|
||||
*
|
||||
* @param schoolInfo 新增对象。
|
||||
* @param schoolInfoDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@ApiOperationSupport(ignoreParameters = {"schoolInfo.schoolId"})
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody SchoolInfo schoolInfo) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(schoolInfo);
|
||||
public ResponseResult<Long> add(@MyRequestBody("schoolInfo") SchoolInfoDto schoolInfoDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(schoolInfoDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SchoolInfo schoolInfo = MyModelUtil.copyTo(schoolInfoDto, SchoolInfo.class);
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = schoolInfoService.verifyRelatedData(schoolInfo, null);
|
||||
if (!callResult.isSuccess()) {
|
||||
@@ -56,16 +62,16 @@ public class SchoolInfoController {
|
||||
/**
|
||||
* 更新校区数据数据。
|
||||
*
|
||||
* @param schoolInfo 更新对象。
|
||||
* @param schoolInfoDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody SchoolInfo schoolInfo) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(schoolInfo, Default.class, UpdateGroup.class);
|
||||
public ResponseResult<Void> update(@MyRequestBody("schoolInfo") SchoolInfoDto schoolInfoDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(schoolInfoDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
SchoolInfo schoolInfo = MyModelUtil.copyTo(schoolInfoDto, SchoolInfo.class);
|
||||
SchoolInfo originalSchoolInfo = schoolInfoService.getById(schoolInfo.getSchoolId());
|
||||
if (originalSchoolInfo == null) {
|
||||
// NOTE: 修改下面方括号中的话述
|
||||
@@ -113,19 +119,20 @@ public class SchoolInfoController {
|
||||
/**
|
||||
* 列出符合过滤条件的校区数据列表。
|
||||
*
|
||||
* @param schoolInfoFilter 过滤对象。
|
||||
* @param schoolInfoDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<SchoolInfoVo>> list(
|
||||
@MyRequestBody SchoolInfo schoolInfoFilter,
|
||||
@MyRequestBody("schoolInfoFilter") SchoolInfoDto schoolInfoDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
SchoolInfo schoolInfoFilter = MyModelUtil.copyTo(schoolInfoDtoFilter, SchoolInfo.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, SchoolInfo.class);
|
||||
List<SchoolInfo> schoolInfoList = schoolInfoService.getSchoolInfoListWithRelation(schoolInfoFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(schoolInfoList, SchoolInfo.INSTANCE));
|
||||
@@ -159,7 +166,7 @@ public class SchoolInfoController {
|
||||
*/
|
||||
@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));
|
||||
}
|
||||
|
||||
@@ -2,12 +2,14 @@ package com.orange.demo.app.controller;
|
||||
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.orange.demo.app.vo.*;
|
||||
import com.orange.demo.app.dto.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.app.service.*;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.constant.*;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -20,6 +22,7 @@ import java.util.*;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Api(tags = "学生行为统计管理接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/studentActionStats")
|
||||
@@ -31,19 +34,20 @@ public class StudentActionStatsController {
|
||||
/**
|
||||
* 列出符合过滤条件的学生行为统计列表。
|
||||
*
|
||||
* @param studentActionStatsFilter 过滤对象。
|
||||
* @param studentActionStatsDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<StudentActionStatsVo>> list(
|
||||
@MyRequestBody StudentActionStats studentActionStatsFilter,
|
||||
@MyRequestBody("studentActionStatsFilter") StudentActionStatsDto studentActionStatsDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
StudentActionStats studentActionStatsFilter = MyModelUtil.copyTo(studentActionStatsDtoFilter, StudentActionStats.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, StudentActionStats.class);
|
||||
List<StudentActionStats> studentActionStatsList = studentActionStatsService.getStudentActionStatsListWithRelation(studentActionStatsFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(studentActionStatsList, StudentActionStats.INSTANCE));
|
||||
@@ -52,7 +56,7 @@ public class StudentActionStatsController {
|
||||
/**
|
||||
* 分组列出符合过滤条件的学生行为统计列表。
|
||||
*
|
||||
* @param studentActionStatsFilter 过滤对象。
|
||||
* @param studentActionStatsDtoFilter 过滤对象。
|
||||
* @param groupParam 分组参数。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
@@ -60,7 +64,7 @@ public class StudentActionStatsController {
|
||||
*/
|
||||
@PostMapping("/listWithGroup")
|
||||
public ResponseResult<MyPageData<StudentActionStatsVo>> listWithGroup(
|
||||
@MyRequestBody StudentActionStats studentActionStatsFilter,
|
||||
@MyRequestBody("studentActionStatsFilter") StudentActionStatsDto studentActionStatsDtoFilter,
|
||||
@MyRequestBody(required = true) MyGroupParam groupParam,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
@@ -73,9 +77,10 @@ public class StudentActionStatsController {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
StudentActionStats filter = MyModelUtil.copyTo(studentActionStatsDtoFilter, StudentActionStats.class);
|
||||
MyGroupCriteria criteria = groupParam.getGroupCriteria();
|
||||
List<StudentActionStats> resultList = studentActionStatsService.getGroupedStudentActionStatsListWithRelation(
|
||||
studentActionStatsFilter, criteria.getGroupSelect(), criteria.getGroupBy(), orderBy);
|
||||
filter, criteria.getGroupSelect(), criteria.getGroupBy(), orderBy);
|
||||
// 分页连同对象数据转换copy工作,下面的方法一并完成。
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(resultList, StudentActionStats.INSTANCE));
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.orange.demo.app.controller;
|
||||
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.orange.demo.app.vo.*;
|
||||
import com.orange.demo.app.dto.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.app.service.*;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
@@ -9,6 +10,8 @@ import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.constant.*;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -22,6 +25,7 @@ import javax.validation.groups.Default;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Api(tags = "学生行为流水管理接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/studentActionTrans")
|
||||
@@ -33,15 +37,20 @@ public class StudentActionTransController {
|
||||
/**
|
||||
* 新增学生行为流水数据。
|
||||
*
|
||||
* @param studentActionTrans 新增对象。
|
||||
* @param studentActionTransDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@ApiOperationSupport(ignoreParameters = {
|
||||
"studentActionTrans.transId",
|
||||
"studentActionTrans.createTimeStart",
|
||||
"studentActionTrans.createTimeEnd"})
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody StudentActionTrans studentActionTrans) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(studentActionTrans);
|
||||
public ResponseResult<Long> add(@MyRequestBody("studentActionTrans") StudentActionTransDto studentActionTransDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(studentActionTransDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
StudentActionTrans studentActionTrans = MyModelUtil.copyTo(studentActionTransDto, StudentActionTrans.class);
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = studentActionTransService.verifyRelatedData(studentActionTrans, null);
|
||||
if (!callResult.isSuccess()) {
|
||||
@@ -55,16 +64,19 @@ public class StudentActionTransController {
|
||||
/**
|
||||
* 更新学生行为流水数据。
|
||||
*
|
||||
* @param studentActionTrans 更新对象。
|
||||
* @param studentActionTransDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@ApiOperationSupport(ignoreParameters = {
|
||||
"studentActionTrans.createTimeStart",
|
||||
"studentActionTrans.createTimeEnd"})
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody StudentActionTrans studentActionTrans) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(studentActionTrans, Default.class, UpdateGroup.class);
|
||||
public ResponseResult<Void> update(@MyRequestBody("studentActionTrans") StudentActionTransDto studentActionTransDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(studentActionTransDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
StudentActionTrans studentActionTrans = MyModelUtil.copyTo(studentActionTransDto, StudentActionTrans.class);
|
||||
StudentActionTrans originalStudentActionTrans = studentActionTransService.getById(studentActionTrans.getTransId());
|
||||
if (originalStudentActionTrans == null) {
|
||||
// NOTE: 修改下面方括号中的话述
|
||||
@@ -112,19 +124,20 @@ public class StudentActionTransController {
|
||||
/**
|
||||
* 列出符合过滤条件的学生行为流水列表。
|
||||
*
|
||||
* @param studentActionTransFilter 过滤对象。
|
||||
* @param studentActionTransDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<StudentActionTransVo>> list(
|
||||
@MyRequestBody StudentActionTrans studentActionTransFilter,
|
||||
@MyRequestBody("studentActionTransFilter") StudentActionTransDto studentActionTransDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
StudentActionTrans studentActionTransFilter = MyModelUtil.copyTo(studentActionTransDtoFilter, StudentActionTrans.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, StudentActionTrans.class);
|
||||
List<StudentActionTrans> studentActionTransList = studentActionTransService.getStudentActionTransListWithRelation(studentActionTransFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(studentActionTransList, StudentActionTrans.INSTANCE));
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.orange.demo.app.controller;
|
||||
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.orange.demo.app.vo.*;
|
||||
import com.orange.demo.app.dto.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.app.service.*;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
@@ -9,6 +10,8 @@ import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.constant.*;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -23,6 +26,7 @@ import java.util.stream.Collectors;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Api(tags = "班级数据管理接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/studentClass")
|
||||
@@ -38,15 +42,17 @@ public class StudentClassController {
|
||||
/**
|
||||
* 新增班级数据数据。
|
||||
*
|
||||
* @param studentClass 新增对象。
|
||||
* @param studentClassDto 新增对象。
|
||||
* @return 应答结果对象,包含新增对象主键Id。
|
||||
*/
|
||||
@ApiOperationSupport(ignoreParameters = {"studentClass.classId"})
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody StudentClass studentClass) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(studentClass);
|
||||
public ResponseResult<Long> add(@MyRequestBody("studentClass") StudentClassDto studentClassDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(studentClassDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
StudentClass studentClass = MyModelUtil.copyTo(studentClassDto, StudentClass.class);
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = studentClassService.verifyRelatedData(studentClass, null);
|
||||
if (!callResult.isSuccess()) {
|
||||
@@ -60,16 +66,16 @@ public class StudentClassController {
|
||||
/**
|
||||
* 更新班级数据数据。
|
||||
*
|
||||
* @param studentClass 更新对象。
|
||||
* @param studentClassDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody StudentClass studentClass) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(studentClass, Default.class, UpdateGroup.class);
|
||||
public ResponseResult<Void> update(@MyRequestBody("studentClass") StudentClassDto studentClassDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(studentClassDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
StudentClass studentClass = MyModelUtil.copyTo(studentClassDto, StudentClass.class);
|
||||
StudentClass originalStudentClass = studentClassService.getById(studentClass.getClassId());
|
||||
if (originalStudentClass == null) {
|
||||
// NOTE: 修改下面方括号中的话述
|
||||
@@ -117,19 +123,20 @@ public class StudentClassController {
|
||||
/**
|
||||
* 列出符合过滤条件的班级数据列表。
|
||||
*
|
||||
* @param studentClassFilter 过滤对象。
|
||||
* @param studentClassDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<StudentClassVo>> list(
|
||||
@MyRequestBody StudentClass studentClassFilter,
|
||||
@MyRequestBody("studentClassFilter") StudentClassDto studentClassDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
StudentClass studentClassFilter = MyModelUtil.copyTo(studentClassDtoFilter, StudentClass.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, StudentClass.class);
|
||||
List<StudentClass> studentClassList = studentClassService.getStudentClassListWithRelation(studentClassFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(studentClassList, StudentClass.INSTANCE));
|
||||
@@ -158,7 +165,7 @@ public class StudentClassController {
|
||||
* 列出不与指定班级数据存在多对多关系的 [课程数据] 列表数据。通常用于查看添加新 [课程数据] 对象的候选列表。
|
||||
*
|
||||
* @param classId 主表关联字段。
|
||||
* @param courseFilter [课程数据] 过滤对象。
|
||||
* @param courseDtoFilter [课程数据] 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,返回符合条件的数据列表。
|
||||
@@ -166,7 +173,7 @@ public class StudentClassController {
|
||||
@PostMapping("/listNotInClassCourse")
|
||||
public ResponseResult<MyPageData<CourseVo>> listNotInClassCourse(
|
||||
@MyRequestBody Long classId,
|
||||
@MyRequestBody Course courseFilter,
|
||||
@MyRequestBody("courseFilter") CourseDto courseDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
ResponseResult<Void> verifyResult = this.doClassCourseVerify(classId);
|
||||
@@ -176,9 +183,10 @@ public class StudentClassController {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
Course filter = MyModelUtil.copyTo(courseDtoFilter, Course.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Course.class);
|
||||
List<Course> courseList =
|
||||
courseService.getNotInCourseListByClassId(classId, courseFilter, orderBy);
|
||||
courseService.getNotInCourseListByClassId(classId, filter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(courseList, Course.INSTANCE));
|
||||
}
|
||||
|
||||
@@ -186,7 +194,7 @@ public class StudentClassController {
|
||||
* 列出与指定班级数据存在多对多关系的 [课程数据] 列表数据。
|
||||
*
|
||||
* @param classId 主表关联字段。
|
||||
* @param courseFilter [课程数据] 过滤对象。
|
||||
* @param courseDtoFilter [课程数据] 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,返回符合条件的数据列表。
|
||||
@@ -194,7 +202,7 @@ public class StudentClassController {
|
||||
@PostMapping("/listClassCourse")
|
||||
public ResponseResult<MyPageData<CourseVo>> listClassCourse(
|
||||
@MyRequestBody Long classId,
|
||||
@MyRequestBody Course courseFilter,
|
||||
@MyRequestBody("courseFilter") CourseDto courseDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
ResponseResult<Void> verifyResult = this.doClassCourseVerify(classId);
|
||||
@@ -204,9 +212,10 @@ public class StudentClassController {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
Course filter = MyModelUtil.copyTo(courseDtoFilter, Course.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Course.class);
|
||||
List<Course> courseList =
|
||||
courseService.getCourseListByClassId(classId, courseFilter, orderBy);
|
||||
courseService.getCourseListByClassId(classId, filter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(courseList, Course.INSTANCE));
|
||||
}
|
||||
|
||||
@@ -224,28 +233,30 @@ public class StudentClassController {
|
||||
* 批量添加班级数据和 [课程数据] 对象的多对多关联关系数据。
|
||||
*
|
||||
* @param classId 主表主键Id。
|
||||
* @param classCourseList 关联对象列表。
|
||||
* @param classCourseDtoList 关联对象列表。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/addClassCourse")
|
||||
public ResponseResult<Void> addClassCourse(
|
||||
@MyRequestBody Long classId,
|
||||
@MyRequestBody(elementType = ClassCourse.class) List<ClassCourse> classCourseList) {
|
||||
if (MyCommonUtil.existBlankArgument(classId, classCourseList)) {
|
||||
@MyRequestBody(value = "classCourseList", elementType = ClassCourseDto.class) List<ClassCourseDto> classCourseDtoList) {
|
||||
if (MyCommonUtil.existBlankArgument(classId, classCourseDtoList)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
for (ClassCourse classCourse : classCourseList) {
|
||||
for (ClassCourseDto classCourse : classCourseDtoList) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(classCourse);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
}
|
||||
Set<Long> courseIdSet =
|
||||
classCourseList.stream().map(ClassCourse::getCourseId).collect(Collectors.toSet());
|
||||
classCourseDtoList.stream().map(ClassCourseDto::getCourseId).collect(Collectors.toSet());
|
||||
if (!studentClassService.existId(classId)
|
||||
|| !courseService.existUniqueKeyList("courseId", courseIdSet)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
||||
}
|
||||
List<ClassCourse> classCourseList =
|
||||
MyModelUtil.copyCollectionTo(classCourseDtoList, ClassCourse.class);
|
||||
studentClassService.addClassCourseList(classCourseList, classId);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
@@ -253,15 +264,17 @@ public class StudentClassController {
|
||||
/**
|
||||
* 更新指定班级数据和指定 [课程数据] 的多对多关联数据。
|
||||
*
|
||||
* @param classCourse 对多对中间表对象。
|
||||
* @param classCourseDto 对多对中间表对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/updateClassCourse")
|
||||
public ResponseResult<Void> updateClassCourse(@MyRequestBody ClassCourse classCourse) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(classCourse);
|
||||
public ResponseResult<Void> updateClassCourse(
|
||||
@MyRequestBody("classCourse") ClassCourseDto classCourseDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(classCourseDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
ClassCourse classCourse = MyModelUtil.copyTo(classCourseDto, ClassCourse.class);
|
||||
if (!studentClassService.updateClassCourse(classCourse)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
@@ -312,7 +325,7 @@ public class StudentClassController {
|
||||
* 列出不与指定班级数据存在多对多关系的 [学生数据] 列表数据。通常用于查看添加新 [学生数据] 对象的候选列表。
|
||||
*
|
||||
* @param classId 主表关联字段。
|
||||
* @param studentFilter [学生数据] 过滤对象。
|
||||
* @param studentDtoFilter [学生数据] 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,返回符合条件的数据列表。
|
||||
@@ -320,7 +333,7 @@ public class StudentClassController {
|
||||
@PostMapping("/listNotInClassStudent")
|
||||
public ResponseResult<MyPageData<StudentVo>> listNotInClassStudent(
|
||||
@MyRequestBody Long classId,
|
||||
@MyRequestBody Student studentFilter,
|
||||
@MyRequestBody("studentFilter") StudentDto studentDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
ResponseResult<Void> verifyResult = this.doClassStudentVerify(classId);
|
||||
@@ -330,9 +343,10 @@ public class StudentClassController {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
Student filter = MyModelUtil.copyTo(studentDtoFilter, Student.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Student.class);
|
||||
List<Student> studentList =
|
||||
studentService.getNotInStudentListByClassId(classId, studentFilter, orderBy);
|
||||
studentService.getNotInStudentListByClassId(classId, filter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(studentList, Student.INSTANCE));
|
||||
}
|
||||
|
||||
@@ -340,7 +354,7 @@ public class StudentClassController {
|
||||
* 列出与指定班级数据存在多对多关系的 [学生数据] 列表数据。
|
||||
*
|
||||
* @param classId 主表关联字段。
|
||||
* @param studentFilter [学生数据] 过滤对象。
|
||||
* @param studentDtoFilter [学生数据] 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,返回符合条件的数据列表。
|
||||
@@ -348,7 +362,7 @@ public class StudentClassController {
|
||||
@PostMapping("/listClassStudent")
|
||||
public ResponseResult<MyPageData<StudentVo>> listClassStudent(
|
||||
@MyRequestBody Long classId,
|
||||
@MyRequestBody Student studentFilter,
|
||||
@MyRequestBody("studentFilter") StudentDto studentDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
ResponseResult<Void> verifyResult = this.doClassStudentVerify(classId);
|
||||
@@ -358,9 +372,10 @@ public class StudentClassController {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
Student filter = MyModelUtil.copyTo(studentDtoFilter, Student.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Student.class);
|
||||
List<Student> studentList =
|
||||
studentService.getStudentListByClassId(classId, studentFilter, orderBy);
|
||||
studentService.getStudentListByClassId(classId, filter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(studentList, Student.INSTANCE));
|
||||
}
|
||||
|
||||
@@ -378,28 +393,30 @@ public class StudentClassController {
|
||||
* 批量添加班级数据和 [学生数据] 对象的多对多关联关系数据。
|
||||
*
|
||||
* @param classId 主表主键Id。
|
||||
* @param classStudentList 关联对象列表。
|
||||
* @param classStudentDtoList 关联对象列表。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@PostMapping("/addClassStudent")
|
||||
public ResponseResult<Void> addClassStudent(
|
||||
@MyRequestBody Long classId,
|
||||
@MyRequestBody(elementType = ClassStudent.class) List<ClassStudent> classStudentList) {
|
||||
if (MyCommonUtil.existBlankArgument(classId, classStudentList)) {
|
||||
@MyRequestBody(value = "classStudentList", elementType = ClassStudentDto.class) List<ClassStudentDto> classStudentDtoList) {
|
||||
if (MyCommonUtil.existBlankArgument(classId, classStudentDtoList)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
for (ClassStudent classStudent : classStudentList) {
|
||||
for (ClassStudentDto classStudent : classStudentDtoList) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(classStudent);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
}
|
||||
Set<Long> studentIdSet =
|
||||
classStudentList.stream().map(ClassStudent::getStudentId).collect(Collectors.toSet());
|
||||
classStudentDtoList.stream().map(ClassStudentDto::getStudentId).collect(Collectors.toSet());
|
||||
if (!studentClassService.existId(classId)
|
||||
|| !studentService.existUniqueKeyList("studentId", studentIdSet)) {
|
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
||||
}
|
||||
List<ClassStudent> classStudentList =
|
||||
MyModelUtil.copyCollectionTo(classStudentDtoList, ClassStudent.class);
|
||||
studentClassService.addClassStudentList(classStudentList, classId);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.orange.demo.app.controller;
|
||||
import cn.jimmyshi.beanquery.BeanQuery;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.orange.demo.app.vo.*;
|
||||
import com.orange.demo.app.dto.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.app.service.*;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
@@ -10,6 +11,8 @@ import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.constant.*;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -23,6 +26,7 @@ import javax.validation.groups.Default;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Api(tags = "学生数据管理接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/app/student")
|
||||
@@ -34,15 +38,23 @@ public class StudentController {
|
||||
/**
|
||||
* 新增学生数据数据。
|
||||
*
|
||||
* @param student 新增对象。
|
||||
* @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 student) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(student);
|
||||
public ResponseResult<Long> add(@MyRequestBody("student") StudentDto studentDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(studentDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
Student student = MyModelUtil.copyTo(studentDto, Student.class);
|
||||
// 验证关联Id的数据合法性
|
||||
CallResult callResult = studentService.verifyRelatedData(student, null);
|
||||
if (!callResult.isSuccess()) {
|
||||
@@ -56,16 +68,22 @@ public class StudentController {
|
||||
/**
|
||||
* 更新学生数据数据。
|
||||
*
|
||||
* @param student 更新对象。
|
||||
* @param studentDto 更新对象。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@ApiOperationSupport(ignoreParameters = {
|
||||
"student.searchString",
|
||||
"student.birthdayStart",
|
||||
"student.birthdayEnd",
|
||||
"student.registerTimeStart",
|
||||
"student.registerTimeEnd"})
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody Student student) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(student, Default.class, UpdateGroup.class);
|
||||
public ResponseResult<Void> update(@MyRequestBody("student") StudentDto studentDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(studentDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
// 验证关联Id的数据合法性
|
||||
Student student = MyModelUtil.copyTo(studentDto, Student.class);
|
||||
Student originalStudent = studentService.getById(student.getStudentId());
|
||||
if (originalStudent == null) {
|
||||
// NOTE: 修改下面方括号中的话述
|
||||
@@ -113,19 +131,20 @@ public class StudentController {
|
||||
/**
|
||||
* 列出符合过滤条件的学生数据列表。
|
||||
*
|
||||
* @param studentFilter 过滤对象。
|
||||
* @param studentDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<StudentVo>> list(
|
||||
@MyRequestBody Student studentFilter,
|
||||
@MyRequestBody("studentFilter") StudentDto studentDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
Student studentFilter = MyModelUtil.copyTo(studentDtoFilter, Student.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Student.class);
|
||||
List<Student> studentList = studentService.getStudentListWithRelation(studentFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(studentList, Student.INSTANCE));
|
||||
@@ -159,7 +178,7 @@ public class StudentController {
|
||||
*/
|
||||
@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));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.orange.demo.app.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.*;
|
||||
|
||||
/**
|
||||
* ClassCourseDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("ClassCourseDto对象")
|
||||
@Data
|
||||
public class ClassCourseDto {
|
||||
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "班级Id", required = true)
|
||||
@NotNull(message = "数据验证失败,班级Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long classId;
|
||||
|
||||
/**
|
||||
* 课程Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "课程Id", required = true)
|
||||
@NotNull(message = "数据验证失败,课程Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 课程顺序(数值越小越靠前)。
|
||||
*/
|
||||
@ApiModelProperty(value = "课程顺序(数值越小越靠前)", required = true)
|
||||
@NotNull(message = "数据验证失败,课程顺序(数值越小越靠前)不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer courseOrder;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.orange.demo.app.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.*;
|
||||
|
||||
/**
|
||||
* ClassStudentDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("ClassStudentDto对象")
|
||||
@Data
|
||||
public class ClassStudentDto {
|
||||
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "班级Id", required = true)
|
||||
@NotNull(message = "数据验证失败,班级Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long classId;
|
||||
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生Id", required = true)
|
||||
@NotNull(message = "数据验证失败,学生Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long studentId;
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.orange.demo.app.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.app.model.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;
|
||||
|
||||
/**
|
||||
* CourseDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("CourseDto对象")
|
||||
@Data
|
||||
public class CourseDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "主键Id", required = true)
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 课程名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "课程名称", required = true)
|
||||
@NotBlank(message = "数据验证失败,课程名称不能为空!")
|
||||
private String courseName;
|
||||
|
||||
/**
|
||||
* 课程价格。
|
||||
*/
|
||||
@ApiModelProperty(value = "课程价格", required = true)
|
||||
@NotNull(message = "数据验证失败,课程价格不能为空!")
|
||||
private BigDecimal price;
|
||||
|
||||
/**
|
||||
* 课程描述。
|
||||
*/
|
||||
@ApiModelProperty(value = "课程描述")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 课程难度(0: 容易 1: 普通 2: 很难)。
|
||||
*/
|
||||
@ApiModelProperty(value = "课程难度(0: 容易 1: 普通 2: 很难)", required = true)
|
||||
@NotNull(message = "数据验证失败,课程难度不能为空!")
|
||||
@ConstDictRef(constDictClass = CourseDifficult.class, message = "数据验证失败,课程难度为无效值!")
|
||||
private Integer difficulty;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "年级Id", required = true)
|
||||
@NotNull(message = "数据验证失败,所属年级不能为空!")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 学科Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "学科Id", required = true)
|
||||
@NotNull(message = "数据验证失败,所属学科不能为空!")
|
||||
@ConstDictRef(constDictClass = Subject.class, message = "数据验证失败,所属学科为无效值!")
|
||||
private Integer subjectId;
|
||||
|
||||
/**
|
||||
* 课时数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "课时数量", required = true)
|
||||
@NotNull(message = "数据验证失败,课时数量不能为空!")
|
||||
private Integer classHour;
|
||||
|
||||
/**
|
||||
* 多张课程图片地址。
|
||||
*/
|
||||
@ApiModelProperty(value = "多张课程图片地址", required = true)
|
||||
@NotBlank(message = "数据验证失败,课程图片不能为空!")
|
||||
private String pictureUrl;
|
||||
|
||||
/**
|
||||
* price 范围过滤起始值(>=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "price 范围过滤起始值(>=)")
|
||||
private BigDecimal priceStart;
|
||||
|
||||
/**
|
||||
* price 范围过滤结束值(<=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "price 范围过滤结束值(<=)")
|
||||
private BigDecimal priceEnd;
|
||||
|
||||
/**
|
||||
* classHour 范围过滤起始值(>=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "classHour 范围过滤起始值(>=)")
|
||||
private Integer classHourStart;
|
||||
|
||||
/**
|
||||
* classHour 范围过滤结束值(<=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "classHour 范围过滤结束值(<=)")
|
||||
private Integer classHourEnd;
|
||||
|
||||
/**
|
||||
* createTime 范围过滤起始值(>=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "createTime 范围过滤起始值(>=)")
|
||||
private String createTimeStart;
|
||||
|
||||
/**
|
||||
* createTime 范围过滤结束值(<=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "createTime 范围过滤结束值(<=)")
|
||||
private String createTimeEnd;
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.orange.demo.app.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.application.common.constant.Subject;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* CourseTransStatsDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("CourseTransStatsDto对象")
|
||||
@Data
|
||||
public class CourseTransStatsDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "主键Id", required = true)
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long statsId;
|
||||
|
||||
/**
|
||||
* 统计日期。
|
||||
*/
|
||||
@ApiModelProperty(value = "统计日期", required = true)
|
||||
@NotNull(message = "数据验证失败,统计日期不能为空!")
|
||||
private Date statsDate;
|
||||
|
||||
/**
|
||||
* 科目Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "科目Id", required = true)
|
||||
@NotNull(message = "数据验证失败,所属科目不能为空!")
|
||||
@ConstDictRef(constDictClass = Subject.class, message = "数据验证失败,所属科目为无效值!")
|
||||
private Integer subjectId;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "年级Id", required = true)
|
||||
@NotNull(message = "数据验证失败,所属年级不能为空!")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 年级名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "年级名称")
|
||||
private String gradeName;
|
||||
|
||||
/**
|
||||
* 课程Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "课程Id", required = true)
|
||||
@NotNull(message = "数据验证失败,课程Id不能为空!")
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 课程名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "课程名称")
|
||||
private String courseName;
|
||||
|
||||
/**
|
||||
* 学生上课次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生上课次数", required = true)
|
||||
@NotNull(message = "数据验证失败,上课次数不能为空!")
|
||||
private Integer studentAttendCount;
|
||||
|
||||
/**
|
||||
* 学生献花数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生献花数量", required = true)
|
||||
@NotNull(message = "数据验证失败,献花数量不能为空!")
|
||||
private Integer studentFlowerAmount;
|
||||
|
||||
/**
|
||||
* 学生献花次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生献花次数", required = true)
|
||||
@NotNull(message = "数据验证失败,献花次数不能为空!")
|
||||
private Integer studentFlowerCount;
|
||||
|
||||
/**
|
||||
* statsDate 范围过滤起始值(>=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "statsDate 范围过滤起始值(>=)")
|
||||
private String statsDateStart;
|
||||
|
||||
/**
|
||||
* statsDate 范围过滤结束值(<=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "statsDate 范围过滤结束值(<=)")
|
||||
private String statsDateEnd;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.orange.demo.app.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.*;
|
||||
|
||||
/**
|
||||
* GradeDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("GradeDto对象")
|
||||
@Data
|
||||
public class GradeDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "主键Id", required = true)
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 年级名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "年级名称", required = true)
|
||||
@NotBlank(message = "数据验证失败,年级名称不能为空!")
|
||||
private String gradeName;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.orange.demo.app.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-09-24
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package com.orange.demo.app.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.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* StudentActionStatsDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("StudentActionStatsDto对象")
|
||||
@Data
|
||||
public class StudentActionStatsDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "主键Id", required = true)
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long statsId;
|
||||
|
||||
/**
|
||||
* 统计日期。
|
||||
*/
|
||||
@ApiModelProperty(value = "统计日期", required = true)
|
||||
@NotNull(message = "数据验证失败,统计日期不能为空!")
|
||||
private Date statsDate;
|
||||
|
||||
/**
|
||||
* 统计小时。
|
||||
*/
|
||||
@ApiModelProperty(value = "统计小时")
|
||||
private Date statsMonth;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "年级Id", required = true)
|
||||
@NotNull(message = "数据验证失败,所属年级不能为空!")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 学生所在省Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生所在省Id", required = true)
|
||||
@NotNull(message = "数据验证失败,所在省份不能为空!")
|
||||
private Long provinceId;
|
||||
|
||||
/**
|
||||
* 学生所在城市Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生所在城市Id", required = true)
|
||||
@NotNull(message = "数据验证失败,所在城市不能为空!", groups = {UpdateGroup.class})
|
||||
private Long cityId;
|
||||
|
||||
/**
|
||||
* 购课学币数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购课学币数量", required = true)
|
||||
@NotNull(message = "数据验证失败,购课学币数量不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer buyCourseAmount;
|
||||
|
||||
/**
|
||||
* 购买课程次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买课程次数", required = true)
|
||||
@NotNull(message = "数据验证失败,购买课程次数不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer buyCourseCount;
|
||||
|
||||
/**
|
||||
* 购买视频学币数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买视频学币数量", required = true)
|
||||
@NotNull(message = "数据验证失败,购买视频学币数量不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer buyVideoAmount;
|
||||
|
||||
/**
|
||||
* 购买视频次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买视频次数", required = true)
|
||||
@NotNull(message = "数据验证失败,购买视频次数不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer buyVideoCount;
|
||||
|
||||
/**
|
||||
* 购买作业学币数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买作业学币数量", required = true)
|
||||
@NotNull(message = "数据验证失败,购买作业学币数量不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer buyPaperAmount;
|
||||
|
||||
/**
|
||||
* 购买作业次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买作业次数", required = true)
|
||||
@NotNull(message = "数据验证失败,购买作业次数不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer buyPaperCount;
|
||||
|
||||
/**
|
||||
* 购买献花数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买献花数量", required = true)
|
||||
@NotNull(message = "数据验证失败,购买献花数量不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer buyFlowerAmount;
|
||||
|
||||
/**
|
||||
* 购买献花次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买献花次数", required = true)
|
||||
@NotNull(message = "数据验证失败,购买献花次数不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer buyFlowerCount;
|
||||
|
||||
/**
|
||||
* 充值学币数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "充值学币数量", required = true)
|
||||
@NotNull(message = "数据验证失败,充值学币数量不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer rechargeCoinAmount;
|
||||
|
||||
/**
|
||||
* 充值学币次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "充值学币次数", required = true)
|
||||
@NotNull(message = "数据验证失败,充值学币次数不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer rechargeCoinCount;
|
||||
|
||||
/**
|
||||
* 线下课程上课次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "线下课程上课次数", required = true)
|
||||
@NotNull(message = "数据验证失败,线下课程上课次数不能为空!")
|
||||
private Integer doCourseCount;
|
||||
|
||||
/**
|
||||
* 观看视频次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "观看视频次数", required = true)
|
||||
@NotNull(message = "数据验证失败,观看视频次数不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer watchVideoCount;
|
||||
|
||||
/**
|
||||
* 购买献花消费学币数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买献花消费学币数量", required = true)
|
||||
@NotNull(message = "数据验证失败,购买献花消费学币数量不能为空!")
|
||||
private Integer watchVideoTotalSecond;
|
||||
|
||||
/**
|
||||
* 做题数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "做题数量", required = true)
|
||||
@NotNull(message = "数据验证失败,做题数量不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer doExerciseCount;
|
||||
|
||||
/**
|
||||
* 做题正确的数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "做题正确的数量", required = true)
|
||||
@NotNull(message = "数据验证失败,做题正确的数量不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer doExerciseCorrectCount;
|
||||
|
||||
/**
|
||||
* statsDate 范围过滤起始值(>=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "statsDate 范围过滤起始值(>=)")
|
||||
private String statsDateStart;
|
||||
|
||||
/**
|
||||
* statsDate 范围过滤结束值(<=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "statsDate 范围过滤结束值(<=)")
|
||||
private String statsDateEnd;
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package com.orange.demo.app.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.application.common.constant.StudentActionType;
|
||||
import com.orange.demo.application.common.constant.DeviceType;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* StudentActionTransDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("StudentActionTransDto对象")
|
||||
@Data
|
||||
public class StudentActionTransDto {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "主键Id", required = true)
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long transId;
|
||||
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生Id", required = true)
|
||||
@NotNull(message = "数据验证失败,学生Id不能为空!")
|
||||
private Long studentId;
|
||||
|
||||
/**
|
||||
* 学生名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生名称", required = true)
|
||||
@NotBlank(message = "数据验证失败,学生名称不能为空!")
|
||||
private String studentName;
|
||||
|
||||
/**
|
||||
* 学生校区。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生校区", required = true)
|
||||
@NotNull(message = "数据验证失败,学生校区不能为空!")
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "年级Id", required = true)
|
||||
@NotNull(message = "数据验证失败,学生年级不能为空!")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 行为类型(0: 充值 1: 购课 2: 上课签到 3: 上课签退 4: 看视频课 5: 做作业 6: 刷题 7: 献花)。
|
||||
*/
|
||||
@ApiModelProperty(value = "行为类型(0: 充值 1: 购课 2: 上课签到 3: 上课签退 4: 看视频课 5: 做作业 6: 刷题 7: 献花)", required = true)
|
||||
@NotNull(message = "数据验证失败,行为类型不能为空!")
|
||||
@ConstDictRef(constDictClass = StudentActionType.class, message = "数据验证失败,行为类型为无效值!")
|
||||
private Integer actionType;
|
||||
|
||||
/**
|
||||
* 设备类型(0: iOS 1: Android 2: PC)。
|
||||
*/
|
||||
@ApiModelProperty(value = "设备类型(0: iOS 1: Android 2: PC)", required = true)
|
||||
@NotNull(message = "数据验证失败,设备类型不能为空!")
|
||||
@ConstDictRef(constDictClass = DeviceType.class, message = "数据验证失败,设备类型为无效值!")
|
||||
private Integer deviceType;
|
||||
|
||||
/**
|
||||
* 看视频秒数。
|
||||
*/
|
||||
@ApiModelProperty(value = "看视频秒数")
|
||||
private Integer watchVideoSeconds;
|
||||
|
||||
/**
|
||||
* 购买献花数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买献花数量")
|
||||
private Integer flowerCount;
|
||||
|
||||
/**
|
||||
* 购买作业数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买作业数量")
|
||||
private Integer paperCount;
|
||||
|
||||
/**
|
||||
* 购买视频数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买视频数量")
|
||||
private Integer videoCount;
|
||||
|
||||
/**
|
||||
* 购买课程数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买课程数量")
|
||||
private Integer courseCount;
|
||||
|
||||
/**
|
||||
* 充值学币数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "充值学币数量")
|
||||
private Integer coinCount;
|
||||
|
||||
/**
|
||||
* 做题是否正确标记。
|
||||
*/
|
||||
@ApiModelProperty(value = "做题是否正确标记")
|
||||
private Integer exerciseCorrectFlag;
|
||||
|
||||
/**
|
||||
* 发生时间。
|
||||
*/
|
||||
@ApiModelProperty(value = "发生时间", required = true)
|
||||
@NotNull(message = "数据验证失败,发生时间不能为空!")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* createTime 范围过滤起始值(>=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "createTime 范围过滤起始值(>=)")
|
||||
private String createTimeStart;
|
||||
|
||||
/**
|
||||
* createTime 范围过滤结束值(<=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "createTime 范围过滤结束值(<=)")
|
||||
private String createTimeEnd;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.orange.demo.app.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.app.model.constant.ClassLevel;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* StudentClassDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("StudentClassDto对象")
|
||||
@Data
|
||||
public class StudentClassDto {
|
||||
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "班级Id", required = true)
|
||||
@NotNull(message = "数据验证失败,班级Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long classId;
|
||||
|
||||
/**
|
||||
* 班级名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "班级名称", required = true)
|
||||
@NotBlank(message = "数据验证失败,班级名称不能为空!")
|
||||
private String className;
|
||||
|
||||
/**
|
||||
* 学校Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "学校Id", required = true)
|
||||
@NotNull(message = "数据验证失败,所属校区不能为空!")
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 学生班长Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生班长Id", required = true)
|
||||
@NotNull(message = "数据验证失败,学生班长不能为空!")
|
||||
private Long leaderId;
|
||||
|
||||
/**
|
||||
* 已完成课时数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "已完成课时数量", required = true)
|
||||
@NotNull(message = "数据验证失败,已完成课时不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer finishClassHour;
|
||||
|
||||
/**
|
||||
* 班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)。
|
||||
*/
|
||||
@ApiModelProperty(value = "班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)", required = true)
|
||||
@NotNull(message = "数据验证失败,班级级别不能为空!")
|
||||
@ConstDictRef(constDictClass = ClassLevel.class, message = "数据验证失败,班级级别为无效值!")
|
||||
private Integer classLevel;
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package com.orange.demo.app.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.application.common.constant.Gender;
|
||||
import com.orange.demo.application.common.constant.ExpLevel;
|
||||
import com.orange.demo.application.common.constant.StudentStatus;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* StudentDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("StudentDto对象")
|
||||
@Data
|
||||
public class StudentDto {
|
||||
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生Id", required = true)
|
||||
@NotNull(message = "数据验证失败,学生Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long studentId;
|
||||
|
||||
/**
|
||||
* 登录手机。
|
||||
*/
|
||||
@ApiModelProperty(value = "登录手机", required = true)
|
||||
@NotBlank(message = "数据验证失败,手机号码不能为空!")
|
||||
private String loginMobile;
|
||||
|
||||
/**
|
||||
* 学生姓名。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生姓名", required = true)
|
||||
@NotBlank(message = "数据验证失败,学生姓名不能为空!")
|
||||
private String studentName;
|
||||
|
||||
/**
|
||||
* 所在省份Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "所在省份Id", required = true)
|
||||
@NotNull(message = "数据验证失败,所在省份不能为空!")
|
||||
private Long provinceId;
|
||||
|
||||
/**
|
||||
* 所在城市Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "所在城市Id", required = true)
|
||||
@NotNull(message = "数据验证失败,所在城市不能为空!")
|
||||
private Long cityId;
|
||||
|
||||
/**
|
||||
* 区县Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "区县Id", required = true)
|
||||
@NotNull(message = "数据验证失败,所在区县不能为空!")
|
||||
private Long districtId;
|
||||
|
||||
/**
|
||||
* 学生性别 (0: 女生 1: 男生)。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生性别 (0: 女生 1: 男生)", required = true)
|
||||
@NotNull(message = "数据验证失败,学生性别不能为空!")
|
||||
@ConstDictRef(constDictClass = Gender.class, message = "数据验证失败,学生性别为无效值!")
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 生日。
|
||||
*/
|
||||
@ApiModelProperty(value = "生日", required = true)
|
||||
@NotNull(message = "数据验证失败,出生日期不能为空!")
|
||||
private Date birthday;
|
||||
|
||||
/**
|
||||
* 经验等级 (0: 初级 1: 中级 2: 高级 3: 资深)。
|
||||
*/
|
||||
@ApiModelProperty(value = "经验等级 (0: 初级 1: 中级 2: 高级 3: 资深)", required = true)
|
||||
@NotNull(message = "数据验证失败,经验等级不能为空!")
|
||||
@ConstDictRef(constDictClass = ExpLevel.class, message = "数据验证失败,经验等级为无效值!")
|
||||
private Integer experienceLevel;
|
||||
|
||||
/**
|
||||
* 总共充值学币数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "总共充值学币数量", required = true)
|
||||
@NotNull(message = "数据验证失败,充值学币不能为空!", groups = {UpdateGroup.class})
|
||||
private Integer totalCoin;
|
||||
|
||||
/**
|
||||
* 可用学币数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "可用学币数量", 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;
|
||||
|
||||
/**
|
||||
* 学生状态 (0: 正常 1: 锁定 2: 注销)。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生状态 (0: 正常 1: 锁定 2: 注销)", required = true)
|
||||
@NotNull(message = "数据验证失败,学生状态不能为空!", groups = {UpdateGroup.class})
|
||||
@ConstDictRef(constDictClass = StudentStatus.class, message = "数据验证失败,学生状态为无效值!")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* birthday 范围过滤起始值(>=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "birthday 范围过滤起始值(>=)")
|
||||
private String birthdayStart;
|
||||
|
||||
/**
|
||||
* birthday 范围过滤结束值(<=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "birthday 范围过滤结束值(<=)")
|
||||
private String birthdayEnd;
|
||||
|
||||
/**
|
||||
* registerTime 范围过滤起始值(>=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "registerTime 范围过滤起始值(>=)")
|
||||
private String registerTimeStart;
|
||||
|
||||
/**
|
||||
* registerTime 范围过滤结束值(<=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "registerTime 范围过滤结束值(<=)")
|
||||
private String registerTimeEnd;
|
||||
|
||||
/**
|
||||
* login_mobile / student_name LIKE搜索字符串。
|
||||
*/
|
||||
@ApiModelProperty(value = "LIKE模糊搜索字符串")
|
||||
private String searchString;
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.orange.demo.app.model;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import lombok.Data;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* ClassCourse实体对象。
|
||||
@@ -18,7 +16,6 @@ public class ClassCourse {
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,班级Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@Column(name = "class_id")
|
||||
private Long classId;
|
||||
@@ -26,7 +23,6 @@ public class ClassCourse {
|
||||
/**
|
||||
* 课程Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,课程Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@Column(name = "course_id")
|
||||
private Long courseId;
|
||||
@@ -34,7 +30,6 @@ public class ClassCourse {
|
||||
/**
|
||||
* 课程顺序(数值越小越靠前)。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,课程顺序(数值越小越靠前)不能为空!", groups = {UpdateGroup.class})
|
||||
@Column(name = "course_order")
|
||||
private Integer courseOrder;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.orange.demo.app.model;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import lombok.Data;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* ClassStudent实体对象。
|
||||
@@ -18,7 +16,6 @@ public class ClassStudent {
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,班级Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@Column(name = "class_id")
|
||||
private Long classId;
|
||||
@@ -26,7 +23,6 @@ public class ClassStudent {
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,学生Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@Column(name = "student_id")
|
||||
private Long studentId;
|
||||
|
||||
@@ -7,14 +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.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.app.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;
|
||||
@@ -33,7 +30,6 @@ public class Course {
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@Column(name = "course_id")
|
||||
private Long courseId;
|
||||
@@ -41,14 +37,12 @@ public class Course {
|
||||
/**
|
||||
* 课程名称。
|
||||
*/
|
||||
@NotBlank(message = "数据验证失败,课程名称不能为空!")
|
||||
@Column(name = "course_name")
|
||||
private String courseName;
|
||||
|
||||
/**
|
||||
* 课程价格。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,课程价格不能为空!")
|
||||
private BigDecimal price;
|
||||
|
||||
/**
|
||||
@@ -59,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;
|
||||
|
||||
@@ -89,7 +77,6 @@ public class Course {
|
||||
* 多张课程图片地址。
|
||||
*/
|
||||
@UploadFlagColumn(storeType = UploadStoreTypeEnum.LOCAL_SYSTEM)
|
||||
@NotBlank(message = "数据验证失败,课程图片不能为空!")
|
||||
@Column(name = "picture_url")
|
||||
private String pictureUrl;
|
||||
|
||||
|
||||
@@ -4,14 +4,11 @@ import com.orange.demo.application.common.constant.Subject;
|
||||
import com.orange.demo.common.core.annotation.RelationDict;
|
||||
import com.orange.demo.common.core.annotation.RelationConstDict;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.app.vo.CourseTransStatsVo;
|
||||
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;
|
||||
@@ -29,7 +26,6 @@ public class CourseTransStats {
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "stats_id")
|
||||
@@ -38,22 +34,18 @@ public class CourseTransStats {
|
||||
/**
|
||||
* 统计日期。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,统计日期不能为空!")
|
||||
@Column(name = "stats_date")
|
||||
private Date statsDate;
|
||||
|
||||
/**
|
||||
* 科目Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所属科目不能为空!")
|
||||
@ConstDictRef(constDictClass = Subject.class, message = "数据验证失败,所属科目为无效值!")
|
||||
@Column(name = "subject_id")
|
||||
private Integer subjectId;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所属年级不能为空!")
|
||||
@Column(name = "grade_id")
|
||||
private Integer gradeId;
|
||||
|
||||
@@ -66,7 +58,6 @@ public class CourseTransStats {
|
||||
/**
|
||||
* 课程Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,课程Id不能为空!")
|
||||
@Column(name = "course_id")
|
||||
private Long courseId;
|
||||
|
||||
@@ -79,21 +70,18 @@ public class CourseTransStats {
|
||||
/**
|
||||
* 学生上课次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,上课次数不能为空!")
|
||||
@Column(name = "student_attend_count")
|
||||
private Integer studentAttendCount;
|
||||
|
||||
/**
|
||||
* 学生献花数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,献花数量不能为空!")
|
||||
@Column(name = "student_flower_amount")
|
||||
private Integer studentFlowerAmount;
|
||||
|
||||
/**
|
||||
* 学生献花次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,献花次数不能为空!")
|
||||
@Column(name = "student_flower_count")
|
||||
private Integer studentFlowerCount;
|
||||
|
||||
|
||||
@@ -2,10 +2,8 @@ package com.orange.demo.app.model;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import lombok.Data;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* Grade实体对象。
|
||||
@@ -20,7 +18,6 @@ public class Grade {
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "grade_id")
|
||||
@@ -29,7 +26,6 @@ public class Grade {
|
||||
/**
|
||||
* 年级名称。
|
||||
*/
|
||||
@NotBlank(message = "数据验证失败,年级名称不能为空!")
|
||||
@Column(name = "grade_name")
|
||||
private String gradeName;
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.orange.demo.app.model;
|
||||
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import lombok.Data;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* MaterialEdition实体对象。
|
||||
@@ -18,7 +16,6 @@ public class MaterialEdition {
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "edition_id")
|
||||
@@ -27,13 +24,11 @@ public class MaterialEdition {
|
||||
/**
|
||||
* 教材版本名称。
|
||||
*/
|
||||
@NotBlank(message = "数据验证失败,教材版本名称不能为空!")
|
||||
@Column(name = "edition_name")
|
||||
private String editionName;
|
||||
|
||||
/**
|
||||
* 是否正在使用(0:不是,1:是)。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,是否正在使用(0:不是,1:是)不能为空!")
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
@@ -2,13 +2,11 @@ package com.orange.demo.app.model;
|
||||
|
||||
import com.orange.demo.common.core.annotation.RelationDict;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.app.vo.SchoolInfoVo;
|
||||
import lombok.Data;
|
||||
import org.mapstruct.*;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -25,7 +23,6 @@ public class SchoolInfo {
|
||||
/**
|
||||
* 学校Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,学校Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@Column(name = "school_id")
|
||||
private Long schoolId;
|
||||
@@ -33,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;
|
||||
|
||||
|
||||
@@ -3,17 +3,15 @@ package com.orange.demo.app.model;
|
||||
import com.orange.demo.application.common.constant.Gender;
|
||||
import com.orange.demo.application.common.constant.ExpLevel;
|
||||
import com.orange.demo.application.common.constant.StudentStatus;
|
||||
import com.orange.demo.common.core.util.MyCommonUtil;
|
||||
import com.orange.demo.common.core.annotation.RelationDict;
|
||||
import com.orange.demo.common.core.annotation.RelationConstDict;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.app.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;
|
||||
@@ -31,7 +29,6 @@ public class Student {
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,学生Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@Column(name = "student_id")
|
||||
private Long studentId;
|
||||
@@ -39,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 = "数据验证失败,充值学币不能为空!", groups = {UpdateGroup.class})
|
||||
@Column(name = "total_coin")
|
||||
private Integer totalCoin;
|
||||
|
||||
/**
|
||||
* 可用学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,剩余学币不能为空!", groups = {UpdateGroup.class})
|
||||
@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;
|
||||
|
||||
@@ -129,8 +112,6 @@ public class Student {
|
||||
/**
|
||||
* 学生状态 (0: 正常 1: 锁定 2: 注销)。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,学生状态不能为空!", groups = {UpdateGroup.class})
|
||||
@ConstDictRef(constDictClass = StudentStatus.class, message = "数据验证失败,学生状态为无效值!")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
@@ -163,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",
|
||||
|
||||
@@ -2,13 +2,11 @@ package com.orange.demo.app.model;
|
||||
|
||||
import com.orange.demo.common.core.annotation.RelationDict;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.app.vo.StudentActionStatsVo;
|
||||
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;
|
||||
@@ -26,7 +24,6 @@ public class StudentActionStats {
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@Column(name = "stats_id")
|
||||
private Long statsId;
|
||||
@@ -34,7 +31,6 @@ public class StudentActionStats {
|
||||
/**
|
||||
* 统计日期。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,统计日期不能为空!")
|
||||
@Column(name = "stats_date")
|
||||
private Date statsDate;
|
||||
|
||||
@@ -47,126 +43,108 @@ public class StudentActionStats {
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所属年级不能为空!")
|
||||
@Column(name = "grade_id")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 学生所在省Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所在省份不能为空!")
|
||||
@Column(name = "province_id")
|
||||
private Long provinceId;
|
||||
|
||||
/**
|
||||
* 学生所在城市Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所在城市不能为空!", groups = {UpdateGroup.class})
|
||||
@Column(name = "city_id")
|
||||
private Long cityId;
|
||||
|
||||
/**
|
||||
* 购课学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购课学币数量不能为空!", groups = {UpdateGroup.class})
|
||||
@Column(name = "buy_course_amount")
|
||||
private Integer buyCourseAmount;
|
||||
|
||||
/**
|
||||
* 购买课程次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买课程次数不能为空!", groups = {UpdateGroup.class})
|
||||
@Column(name = "buy_course_count")
|
||||
private Integer buyCourseCount;
|
||||
|
||||
/**
|
||||
* 购买视频学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买视频学币数量不能为空!", groups = {UpdateGroup.class})
|
||||
@Column(name = "buy_video_amount")
|
||||
private Integer buyVideoAmount;
|
||||
|
||||
/**
|
||||
* 购买视频次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买视频次数不能为空!", groups = {UpdateGroup.class})
|
||||
@Column(name = "buy_video_count")
|
||||
private Integer buyVideoCount;
|
||||
|
||||
/**
|
||||
* 购买作业学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买作业学币数量不能为空!", groups = {UpdateGroup.class})
|
||||
@Column(name = "buy_paper_amount")
|
||||
private Integer buyPaperAmount;
|
||||
|
||||
/**
|
||||
* 购买作业次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买作业次数不能为空!", groups = {UpdateGroup.class})
|
||||
@Column(name = "buy_paper_count")
|
||||
private Integer buyPaperCount;
|
||||
|
||||
/**
|
||||
* 购买献花数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买献花数量不能为空!", groups = {UpdateGroup.class})
|
||||
@Column(name = "buy_flower_amount")
|
||||
private Integer buyFlowerAmount;
|
||||
|
||||
/**
|
||||
* 购买献花次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买献花次数不能为空!", groups = {UpdateGroup.class})
|
||||
@Column(name = "buy_flower_count")
|
||||
private Integer buyFlowerCount;
|
||||
|
||||
/**
|
||||
* 充值学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,充值学币数量不能为空!", groups = {UpdateGroup.class})
|
||||
@Column(name = "recharge_coin_amount")
|
||||
private Integer rechargeCoinAmount;
|
||||
|
||||
/**
|
||||
* 充值学币次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,充值学币次数不能为空!", groups = {UpdateGroup.class})
|
||||
@Column(name = "recharge_coin_count")
|
||||
private Integer rechargeCoinCount;
|
||||
|
||||
/**
|
||||
* 线下课程上课次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,线下课程上课次数不能为空!")
|
||||
@Column(name = "do_course_count")
|
||||
private Integer doCourseCount;
|
||||
|
||||
/**
|
||||
* 观看视频次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,观看视频次数不能为空!", groups = {UpdateGroup.class})
|
||||
@Column(name = "watch_video_count")
|
||||
private Integer watchVideoCount;
|
||||
|
||||
/**
|
||||
* 购买献花消费学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买献花消费学币数量不能为空!")
|
||||
@Column(name = "watch_video_total_second")
|
||||
private Integer watchVideoTotalSecond;
|
||||
|
||||
/**
|
||||
* 做题数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,做题数量不能为空!", groups = {UpdateGroup.class})
|
||||
@Column(name = "do_exercise_count")
|
||||
private Integer doExerciseCount;
|
||||
|
||||
/**
|
||||
* 做题正确的数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,做题正确的数量不能为空!", groups = {UpdateGroup.class})
|
||||
@Column(name = "do_exercise_correct_count")
|
||||
private Integer doExerciseCorrectCount;
|
||||
|
||||
|
||||
@@ -5,14 +5,11 @@ import com.orange.demo.application.common.constant.DeviceType;
|
||||
import com.orange.demo.common.core.annotation.RelationDict;
|
||||
import com.orange.demo.common.core.annotation.RelationConstDict;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.app.vo.StudentActionTransVo;
|
||||
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 +27,6 @@ public class StudentActionTrans {
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@Column(name = "trans_id")
|
||||
private Long transId;
|
||||
@@ -38,44 +34,36 @@ public class StudentActionTrans {
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,学生Id不能为空!")
|
||||
@Column(name = "student_id")
|
||||
private Long studentId;
|
||||
|
||||
/**
|
||||
* 学生名称。
|
||||
*/
|
||||
@NotBlank(message = "数据验证失败,学生名称不能为空!")
|
||||
@Column(name = "student_name")
|
||||
private String studentName;
|
||||
|
||||
/**
|
||||
* 学生校区。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,学生校区不能为空!")
|
||||
@Column(name = "school_id")
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,学生年级不能为空!")
|
||||
@Column(name = "grade_id")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 行为类型(0: 充值 1: 购课 2: 上课签到 3: 上课签退 4: 看视频课 5: 做作业 6: 刷题 7: 献花)。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,行为类型不能为空!")
|
||||
@ConstDictRef(constDictClass = StudentActionType.class, message = "数据验证失败,行为类型为无效值!")
|
||||
@Column(name = "action_type")
|
||||
private Integer actionType;
|
||||
|
||||
/**
|
||||
* 设备类型(0: iOS 1: Android 2: PC)。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,设备类型不能为空!")
|
||||
@ConstDictRef(constDictClass = DeviceType.class, message = "数据验证失败,设备类型为无效值!")
|
||||
@Column(name = "device_type")
|
||||
private Integer deviceType;
|
||||
|
||||
@@ -124,7 +112,6 @@ public class StudentActionTrans {
|
||||
/**
|
||||
* 发生时间。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,发生时间不能为空!")
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
|
||||
@@ -6,14 +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.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.app.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;
|
||||
@@ -31,7 +28,6 @@ public class StudentClass {
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,班级Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@Column(name = "class_id")
|
||||
private Long classId;
|
||||
@@ -39,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 = "数据验证失败,已完成课时不能为空!", groups = {UpdateGroup.class})
|
||||
@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;
|
||||
|
||||
|
||||
@@ -1,49 +1,17 @@
|
||||
package com.orange.demo.app.service;
|
||||
|
||||
import com.orange.demo.app.dao.AreaCodeMapper;
|
||||
import com.orange.demo.common.core.base.service.IBaseDictService;
|
||||
import com.orange.demo.app.model.AreaCode;
|
||||
import com.orange.demo.common.core.cache.MapTreeDictionaryCache;
|
||||
import com.orange.demo.common.core.base.service.BaseDictService;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 行政区划的Service类。
|
||||
* 行政区划的Service接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
|
||||
@@ -1,47 +1,18 @@
|
||||
package com.orange.demo.app.service;
|
||||
|
||||
import com.orange.demo.app.dao.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.TokenData;
|
||||
import com.orange.demo.common.core.object.MyWhereCriteria;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 课程数据数据操作服务类。
|
||||
* 课程数据数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@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> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
@@ -49,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);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
@@ -68,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);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
@@ -83,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);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
@@ -105,24 +47,18 @@ public class CourseService extends BaseService<Course, Long> {
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<Course> getCourseList(Course filter, String orderBy) {
|
||||
return courseMapper.getCourseList(filter, orderBy);
|
||||
}
|
||||
List<Course> getCourseList(Course filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getCourseList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<Course> getCourseListWithRelation(Course filter, String orderBy) {
|
||||
List<Course> resultList = courseMapper.getCourseList(filter, orderBy);
|
||||
Map<String, List<MyWhereCriteria>> criteriaMap = buildAggregationAdditionalWhereCriteria();
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), criteriaMap);
|
||||
return resultList;
|
||||
}
|
||||
List<Course> getCourseListWithRelation(Course filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。
|
||||
@@ -132,13 +68,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存在对多对关系的列表。
|
||||
@@ -148,13 +79,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);
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
@@ -163,13 +89,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);
|
||||
}
|
||||
|
||||
@@ -1,39 +1,17 @@
|
||||
package com.orange.demo.app.service;
|
||||
|
||||
import com.orange.demo.app.dao.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.MyWhereCriteria;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 课程统计数据操作服务类。
|
||||
* 课程统计数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service
|
||||
public class CourseTransStatsService extends BaseService<CourseTransStats, Long> {
|
||||
|
||||
@Autowired
|
||||
private CourseTransStatsMapper courseTransStatsMapper;
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<CourseTransStats> mapper() {
|
||||
return courseTransStatsMapper;
|
||||
}
|
||||
public interface CourseTransStatsService extends IBaseService<CourseTransStats, Long> {
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
@@ -43,24 +21,18 @@ public class CourseTransStatsService extends BaseService<CourseTransStats, Long>
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<CourseTransStats> getCourseTransStatsList(CourseTransStats filter, String orderBy) {
|
||||
return courseTransStatsMapper.getCourseTransStatsList(filter, orderBy);
|
||||
}
|
||||
List<CourseTransStats> getCourseTransStatsList(CourseTransStats filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getCourseTransStatsList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<CourseTransStats> getCourseTransStatsListWithRelation(CourseTransStats filter, String orderBy) {
|
||||
List<CourseTransStats> resultList = courseTransStatsMapper.getCourseTransStatsList(filter, orderBy);
|
||||
Map<String, List<MyWhereCriteria>> criteriaMap = buildAggregationAdditionalWhereCriteria();
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), criteriaMap);
|
||||
return resultList;
|
||||
}
|
||||
List<CourseTransStats> getCourseTransStatsListWithRelation(CourseTransStats filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取分组过滤后的数据查询结果,以及关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
@@ -71,13 +43,6 @@ public class CourseTransStatsService extends BaseService<CourseTransStats, Long>
|
||||
* @param orderBy 排序字符串,ORDER BY从句的参数。
|
||||
* @return 分组过滤结果集。
|
||||
*/
|
||||
public List<CourseTransStats> getGroupedCourseTransStatsListWithRelation(
|
||||
CourseTransStats filter, String groupSelect, String groupBy, String orderBy) {
|
||||
List<CourseTransStats> resultList =
|
||||
courseTransStatsMapper.getGroupedCourseTransStatsList(filter, groupSelect, groupBy, orderBy);
|
||||
// NOTE: 这里只是包含了关联数据,聚合计算数据没有包含。
|
||||
// 主要原因是,由于聚合字段通常被视为普通字段使用,不会在group by的从句中出现,语义上也不会在此关联。
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), null);
|
||||
return resultList;
|
||||
}
|
||||
List<CourseTransStats> getGroupedCourseTransStatsListWithRelation(
|
||||
CourseTransStats filter, String groupSelect, String groupBy, String orderBy);
|
||||
}
|
||||
|
||||
@@ -1,88 +1,13 @@
|
||||
package com.orange.demo.app.service;
|
||||
|
||||
import com.orange.demo.common.core.base.service.BaseDictService;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.cache.MapDictionaryCache;
|
||||
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
|
||||
import com.orange.demo.app.dao.GradeMapper;
|
||||
import com.orange.demo.common.core.base.service.IBaseDictService;
|
||||
import com.orange.demo.app.model.Grade;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 年级数据操作服务类。
|
||||
* 年级字典数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service
|
||||
public class GradeService extends BaseDictService<Grade, Integer> {
|
||||
|
||||
@Autowired
|
||||
private GradeMapper gradeMapper;
|
||||
|
||||
public GradeService() {
|
||||
super();
|
||||
this.dictionaryCache = MapDictionaryCache.create(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> {
|
||||
}
|
||||
|
||||
@@ -1,44 +1,18 @@
|
||||
package com.orange.demo.app.service;
|
||||
|
||||
import com.orange.demo.app.dao.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.MyWhereCriteria;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 校区数据数据操作服务类。
|
||||
* 校区数据数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@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> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
@@ -46,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);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
@@ -60,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);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
@@ -72,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);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
@@ -85,24 +47,18 @@ public class SchoolInfoService extends BaseService<SchoolInfo, Long> {
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<SchoolInfo> getSchoolInfoList(SchoolInfo filter, String orderBy) {
|
||||
return schoolInfoMapper.getSchoolInfoList(filter, orderBy);
|
||||
}
|
||||
List<SchoolInfo> getSchoolInfoList(SchoolInfo filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getSchoolInfoList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<SchoolInfo> getSchoolInfoListWithRelation(SchoolInfo filter, String orderBy) {
|
||||
List<SchoolInfo> resultList = schoolInfoMapper.getSchoolInfoList(filter, orderBy);
|
||||
Map<String, List<MyWhereCriteria>> criteriaMap = buildAggregationAdditionalWhereCriteria();
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), criteriaMap);
|
||||
return resultList;
|
||||
}
|
||||
List<SchoolInfo> getSchoolInfoListWithRelation(SchoolInfo filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
@@ -111,18 +67,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);
|
||||
}
|
||||
|
||||
@@ -1,41 +1,17 @@
|
||||
package com.orange.demo.app.service;
|
||||
|
||||
import com.orange.demo.app.dao.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.MyWhereCriteria;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生行为统计数据操作服务类。
|
||||
* 学生行为统计数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service
|
||||
public class StudentActionStatsService extends BaseService<StudentActionStats, Long> {
|
||||
|
||||
@Autowired
|
||||
private StudentActionStatsMapper studentActionStatsMapper;
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
@Autowired
|
||||
private AreaCodeService areaCodeService;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<StudentActionStats> mapper() {
|
||||
return studentActionStatsMapper;
|
||||
}
|
||||
public interface StudentActionStatsService extends IBaseService<StudentActionStats, Long> {
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
@@ -45,24 +21,18 @@ public class StudentActionStatsService extends BaseService<StudentActionStats, L
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<StudentActionStats> getStudentActionStatsList(StudentActionStats filter, String orderBy) {
|
||||
return studentActionStatsMapper.getStudentActionStatsList(filter, orderBy);
|
||||
}
|
||||
List<StudentActionStats> getStudentActionStatsList(StudentActionStats filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentActionStatsList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<StudentActionStats> getStudentActionStatsListWithRelation(StudentActionStats filter, String orderBy) {
|
||||
List<StudentActionStats> resultList = studentActionStatsMapper.getStudentActionStatsList(filter, orderBy);
|
||||
Map<String, List<MyWhereCriteria>> criteriaMap = buildAggregationAdditionalWhereCriteria();
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), criteriaMap);
|
||||
return resultList;
|
||||
}
|
||||
List<StudentActionStats> getStudentActionStatsListWithRelation(StudentActionStats filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取分组过滤后的数据查询结果,以及关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
@@ -73,13 +43,6 @@ public class StudentActionStatsService extends BaseService<StudentActionStats, L
|
||||
* @param orderBy 排序字符串,ORDER BY从句的参数。
|
||||
* @return 分组过滤结果集。
|
||||
*/
|
||||
public List<StudentActionStats> getGroupedStudentActionStatsListWithRelation(
|
||||
StudentActionStats filter, String groupSelect, String groupBy, String orderBy) {
|
||||
List<StudentActionStats> resultList =
|
||||
studentActionStatsMapper.getGroupedStudentActionStatsList(filter, groupSelect, groupBy, orderBy);
|
||||
// NOTE: 这里只是包含了关联数据,聚合计算数据没有包含。
|
||||
// 主要原因是,由于聚合字段通常被视为普通字段使用,不会在group by的从句中出现,语义上也不会在此关联。
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), null);
|
||||
return resultList;
|
||||
}
|
||||
List<StudentActionStats> getGroupedStudentActionStatsListWithRelation(
|
||||
StudentActionStats filter, String groupSelect, String groupBy, String orderBy);
|
||||
}
|
||||
|
||||
@@ -1,46 +1,18 @@
|
||||
package com.orange.demo.app.service;
|
||||
|
||||
import com.orange.demo.app.dao.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.MyWhereCriteria;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生行为流水数据操作服务类。
|
||||
* 学生行为流水数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service
|
||||
public class StudentActionTransService extends BaseService<StudentActionTrans, Long> {
|
||||
|
||||
@Autowired
|
||||
private StudentActionTransMapper studentActionTransMapper;
|
||||
@Autowired
|
||||
private SchoolInfoService schoolInfoService;
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<StudentActionTrans> mapper() {
|
||||
return studentActionTransMapper;
|
||||
}
|
||||
public interface StudentActionTransService extends IBaseService<StudentActionTrans, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
@@ -48,12 +20,7 @@ public class StudentActionTransService extends BaseService<StudentActionTrans, L
|
||||
* @param studentActionTrans 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public StudentActionTrans saveNew(StudentActionTrans studentActionTrans) {
|
||||
studentActionTrans.setTransId(idGenerator.nextLongId());
|
||||
studentActionTransMapper.insert(studentActionTrans);
|
||||
return studentActionTrans;
|
||||
}
|
||||
StudentActionTrans saveNew(StudentActionTrans studentActionTrans);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
@@ -62,11 +29,7 @@ public class StudentActionTransService extends BaseService<StudentActionTrans, L
|
||||
* @param originalStudentActionTrans 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean update(StudentActionTrans studentActionTrans, StudentActionTrans originalStudentActionTrans) {
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
return studentActionTransMapper.updateByPrimaryKey(studentActionTrans) == 1;
|
||||
}
|
||||
boolean update(StudentActionTrans studentActionTrans, StudentActionTrans originalStudentActionTrans);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
@@ -74,10 +37,7 @@ public class StudentActionTransService extends BaseService<StudentActionTrans, L
|
||||
* @param transId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean remove(Long transId) {
|
||||
return studentActionTransMapper.deleteByPrimaryKey(transId) != 0;
|
||||
}
|
||||
boolean remove(Long transId);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
@@ -87,24 +47,18 @@ public class StudentActionTransService extends BaseService<StudentActionTrans, L
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<StudentActionTrans> getStudentActionTransList(StudentActionTrans filter, String orderBy) {
|
||||
return studentActionTransMapper.getStudentActionTransList(filter, orderBy);
|
||||
}
|
||||
List<StudentActionTrans> getStudentActionTransList(StudentActionTrans filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentActionTransList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<StudentActionTrans> getStudentActionTransListWithRelation(StudentActionTrans filter, String orderBy) {
|
||||
List<StudentActionTrans> resultList = studentActionTransMapper.getStudentActionTransList(filter, orderBy);
|
||||
Map<String, List<MyWhereCriteria>> criteriaMap = buildAggregationAdditionalWhereCriteria();
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), criteriaMap);
|
||||
return resultList;
|
||||
}
|
||||
List<StudentActionTrans> getStudentActionTransListWithRelation(StudentActionTrans filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
@@ -113,18 +67,5 @@ public class StudentActionTransService extends BaseService<StudentActionTrans, L
|
||||
* @param originalStudentActionTrans 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
public CallResult verifyRelatedData(StudentActionTrans studentActionTrans, StudentActionTrans originalStudentActionTrans) {
|
||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(studentActionTrans, originalStudentActionTrans, StudentActionTrans::getSchoolId)
|
||||
&& !schoolInfoService.existId(studentActionTrans.getSchoolId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "学生校区"));
|
||||
}
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(studentActionTrans, originalStudentActionTrans, StudentActionTrans::getGradeId)
|
||||
&& !gradeService.existId(studentActionTrans.getGradeId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "学生年级"));
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
CallResult verifyRelatedData(StudentActionTrans studentActionTrans, StudentActionTrans originalStudentActionTrans);
|
||||
}
|
||||
|
||||
@@ -1,53 +1,18 @@
|
||||
package com.orange.demo.app.service;
|
||||
|
||||
import com.orange.demo.app.dao.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
|
||||
import com.orange.demo.common.core.object.TokenData;
|
||||
import com.orange.demo.common.core.object.MyWhereCriteria;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
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.IBaseService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 班级数据数据操作服务类。
|
||||
* 班级数据数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@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> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
@@ -55,19 +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);
|
||||
if (studentClass.getFinishClassHour() == null) {
|
||||
studentClass.setFinishClassHour(0);
|
||||
}
|
||||
studentClassMapper.insert(studentClass);
|
||||
return studentClass;
|
||||
}
|
||||
StudentClass saveNew(StudentClass studentClass);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
@@ -76,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);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
@@ -91,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);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
@@ -121,24 +47,18 @@ public class StudentClassService extends BaseService<StudentClass, Long> {
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<StudentClass> getStudentClassList(StudentClass filter, String orderBy) {
|
||||
return studentClassMapper.getStudentClassList(filter, orderBy);
|
||||
}
|
||||
List<StudentClass> getStudentClassList(StudentClass filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentClassList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<StudentClass> getStudentClassListWithRelation(StudentClass filter, String orderBy) {
|
||||
List<StudentClass> resultList = studentClassMapper.getStudentClassList(filter, orderBy);
|
||||
Map<String, List<MyWhereCriteria>> criteriaMap = buildAggregationAdditionalWhereCriteria();
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), criteriaMap);
|
||||
return resultList;
|
||||
}
|
||||
List<StudentClass> getStudentClassListWithRelation(StudentClass filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 批量添加多对多关联关系。
|
||||
@@ -146,16 +66,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);
|
||||
|
||||
/**
|
||||
* 更新中间表数据。
|
||||
@@ -163,14 +74,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);
|
||||
|
||||
/**
|
||||
* 获取中间表数据。
|
||||
@@ -179,13 +83,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);
|
||||
|
||||
/**
|
||||
* 移除单条多对多关系。
|
||||
@@ -194,13 +92,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);
|
||||
|
||||
/**
|
||||
* 批量添加多对多关联关系。
|
||||
@@ -208,13 +100,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);
|
||||
|
||||
/**
|
||||
* 移除单条多对多关系。
|
||||
@@ -223,13 +109,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);
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
@@ -238,18 +118,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);
|
||||
}
|
||||
|
||||
@@ -1,51 +1,18 @@
|
||||
package com.orange.demo.app.service;
|
||||
|
||||
import com.orange.demo.application.common.constant.StudentStatus;
|
||||
import com.orange.demo.app.dao.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.MyWhereCriteria;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生数据数据操作服务类。
|
||||
* 学生数据数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service
|
||||
public class StudentService extends BaseService<Student, Long> {
|
||||
|
||||
@Autowired
|
||||
private StudentMapper studentMapper;
|
||||
@Autowired
|
||||
private ClassStudentMapper classStudentMapper;
|
||||
@Autowired
|
||||
private AreaCodeService areaCodeService;
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
@Autowired
|
||||
private SchoolInfoService schoolInfoService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<Student> mapper() {
|
||||
return studentMapper;
|
||||
}
|
||||
public interface StudentService extends IBaseService<Student, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
@@ -53,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);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
@@ -77,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);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
@@ -90,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);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
@@ -112,24 +47,18 @@ public class StudentService extends BaseService<Student, Long> {
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<Student> getStudentList(Student filter, String orderBy) {
|
||||
return studentMapper.getStudentList(filter, orderBy);
|
||||
}
|
||||
List<Student> getStudentList(Student filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<Student> getStudentListWithRelation(Student filter, String orderBy) {
|
||||
List<Student> resultList = studentMapper.getStudentList(filter, orderBy);
|
||||
Map<String, List<MyWhereCriteria>> criteriaMap = buildAggregationAdditionalWhereCriteria();
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), criteriaMap);
|
||||
return resultList;
|
||||
}
|
||||
List<Student> getStudentListWithRelation(Student filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。
|
||||
@@ -139,13 +68,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存在对多对关系的列表。
|
||||
@@ -155,13 +79,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);
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
@@ -170,33 +89,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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.orange.demo.app.service.impl;
|
||||
|
||||
import com.orange.demo.app.service.AreaCodeService;
|
||||
import com.orange.demo.app.dao.AreaCodeMapper;
|
||||
import com.orange.demo.app.model.AreaCode;
|
||||
import com.orange.demo.common.core.cache.MapTreeDictionaryCache;
|
||||
import com.orange.demo.common.core.base.service.BaseDictService;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 行政区划的Service类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("areaCodeService")
|
||||
public class AreaCodeServiceImpl extends BaseDictService<AreaCode, Long> implements AreaCodeService {
|
||||
|
||||
@Autowired
|
||||
private AreaCodeMapper areaCodeMapper;
|
||||
|
||||
public AreaCodeServiceImpl() {
|
||||
super();
|
||||
this.dictionaryCache = MapTreeDictionaryCache.create(AreaCode::getAreaId, AreaCode::getParentId);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
package com.orange.demo.app.service.impl;
|
||||
|
||||
import com.orange.demo.app.service.*;
|
||||
import com.orange.demo.app.dao.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.TokenData;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 课程数据数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("courseService")
|
||||
public class CourseServiceImpl extends BaseService<Course, Long> implements CourseService {
|
||||
|
||||
@Autowired
|
||||
private CourseMapper courseMapper;
|
||||
@Autowired
|
||||
private ClassCourseMapper classCourseMapper;
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<Course> mapper() {
|
||||
return courseMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param course 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public Course saveNew(Course course) {
|
||||
course.setCourseId(idGenerator.nextLongId());
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
course.setCreateUserId(tokenData.getUserId());
|
||||
Date now = new Date();
|
||||
course.setCreateTime(now);
|
||||
course.setUpdateTime(now);
|
||||
courseMapper.insert(course);
|
||||
return course;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param course 更新的对象。
|
||||
* @param originalCourse 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(Course course, Course originalCourse) {
|
||||
course.setCreateUserId(originalCourse.getCreateUserId());
|
||||
course.setCreateTime(originalCourse.getCreateTime());
|
||||
course.setUpdateTime(new Date());
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
return courseMapper.updateByPrimaryKey(course) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param courseId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long courseId) {
|
||||
// 这里先删除主数据
|
||||
if (!this.removeById(courseId)) {
|
||||
return false;
|
||||
}
|
||||
// 开始删除多对多父表的关联
|
||||
ClassCourse classCourse = new ClassCourse();
|
||||
classCourse.setCourseId(courseId);
|
||||
classCourseMapper.delete(classCourse);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getCourseListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<Course> getCourseList(Course filter, String orderBy) {
|
||||
return courseMapper.getCourseList(filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getCourseList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<Course> getCourseListWithRelation(Course filter, String orderBy) {
|
||||
List<Course> resultList = courseMapper.getCourseList(filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。
|
||||
*
|
||||
* @param classId 主表主键Id。
|
||||
* @param filter 从表的过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<Course> getNotInCourseListByClassId(
|
||||
Long classId, Course filter, String orderBy) {
|
||||
List<Course> resultList =
|
||||
courseMapper.getNotInCourseListByClassId(classId, filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。
|
||||
*
|
||||
* @param classId 主表主键Id。
|
||||
* @param filter 从表的过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<Course> getCourseListByClassId(
|
||||
Long classId, Course filter, String orderBy) {
|
||||
List<Course> resultList =
|
||||
courseMapper.getCourseListByClassId(classId, filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param course 最新数据对象。
|
||||
* @param originalCourse 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
@Override
|
||||
public CallResult verifyRelatedData(Course course, Course originalCourse) {
|
||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(course, originalCourse, Course::getGradeId)
|
||||
&& !gradeService.existId(course.getGradeId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "所属年级"));
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.orange.demo.app.service.impl;
|
||||
|
||||
import com.orange.demo.app.service.*;
|
||||
import com.orange.demo.app.dao.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 课程统计数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("courseTransStatsService")
|
||||
public class CourseTransStatsServiceImpl extends BaseService<CourseTransStats, Long> implements CourseTransStatsService {
|
||||
|
||||
@Autowired
|
||||
private CourseTransStatsMapper courseTransStatsMapper;
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<CourseTransStats> mapper() {
|
||||
return courseTransStatsMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getCourseTransStatsListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<CourseTransStats> getCourseTransStatsList(CourseTransStats filter, String orderBy) {
|
||||
return courseTransStatsMapper.getCourseTransStatsList(filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getCourseTransStatsList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<CourseTransStats> getCourseTransStatsListWithRelation(CourseTransStats filter, String orderBy) {
|
||||
List<CourseTransStats> resultList = courseTransStatsMapper.getCourseTransStatsList(filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分组过滤后的数据查询结果,以及关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param groupSelect 分组显示列表参数。位于SQL语句SELECT的后面。
|
||||
* @param groupBy 分组参数。位于SQL语句的GROUP BY后面。
|
||||
* @param orderBy 排序字符串,ORDER BY从句的参数。
|
||||
* @return 分组过滤结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<CourseTransStats> getGroupedCourseTransStatsListWithRelation(
|
||||
CourseTransStats filter, String groupSelect, String groupBy, String orderBy) {
|
||||
List<CourseTransStats> resultList =
|
||||
courseTransStatsMapper.getGroupedCourseTransStatsList(filter, groupSelect, groupBy, orderBy);
|
||||
// NOTE: 这里只是包含了关联数据,聚合计算数据没有包含。
|
||||
// 主要原因是,由于聚合字段通常被视为普通字段使用,不会在group by的从句中出现,语义上也不会在此关联。
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal());
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.orange.demo.app.service.impl;
|
||||
|
||||
import com.orange.demo.common.core.base.service.BaseDictService;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.cache.MapDictionaryCache;
|
||||
import com.orange.demo.app.service.GradeService;
|
||||
import com.orange.demo.app.dao.GradeMapper;
|
||||
import com.orange.demo.app.model.Grade;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 年级字典数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("gradeService")
|
||||
public class GradeServiceImpl extends BaseDictService<Grade, Integer> implements GradeService {
|
||||
|
||||
@Autowired
|
||||
private GradeMapper gradeMapper;
|
||||
|
||||
public GradeServiceImpl() {
|
||||
super();
|
||||
this.dictionaryCache = MapDictionaryCache.create(Grade::getGradeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<Grade> mapper() {
|
||||
return gradeMapper;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.orange.demo.app.service.impl;
|
||||
|
||||
import com.orange.demo.app.service.*;
|
||||
import com.orange.demo.app.dao.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 校区数据数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("schoolInfoService")
|
||||
public class SchoolInfoServiceImpl extends BaseService<SchoolInfo, Long> implements SchoolInfoService {
|
||||
|
||||
@Autowired
|
||||
private SchoolInfoMapper schoolInfoMapper;
|
||||
@Autowired
|
||||
private AreaCodeService areaCodeService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<SchoolInfo> mapper() {
|
||||
return schoolInfoMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param schoolInfo 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public SchoolInfo saveNew(SchoolInfo schoolInfo) {
|
||||
schoolInfo.setSchoolId(idGenerator.nextLongId());
|
||||
schoolInfoMapper.insert(schoolInfo);
|
||||
return schoolInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param schoolInfo 更新的对象。
|
||||
* @param originalSchoolInfo 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(SchoolInfo schoolInfo, SchoolInfo originalSchoolInfo) {
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
return schoolInfoMapper.updateByPrimaryKey(schoolInfo) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param schoolId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long schoolId) {
|
||||
// 这里先删除主数据
|
||||
return this.removeById(schoolId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getSchoolInfoListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<SchoolInfo> getSchoolInfoList(SchoolInfo filter, String orderBy) {
|
||||
return schoolInfoMapper.getSchoolInfoList(filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getSchoolInfoList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<SchoolInfo> getSchoolInfoListWithRelation(SchoolInfo filter, String orderBy) {
|
||||
List<SchoolInfo> resultList = schoolInfoMapper.getSchoolInfoList(filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param schoolInfo 最新数据对象。
|
||||
* @param originalSchoolInfo 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
@Override
|
||||
public CallResult verifyRelatedData(SchoolInfo schoolInfo, SchoolInfo originalSchoolInfo) {
|
||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(schoolInfo, originalSchoolInfo, SchoolInfo::getProvinceId)
|
||||
&& !areaCodeService.existId(schoolInfo.getProvinceId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "所在省份"));
|
||||
}
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(schoolInfo, originalSchoolInfo, SchoolInfo::getCityId)
|
||||
&& !areaCodeService.existId(schoolInfo.getCityId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "所在城市"));
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.orange.demo.app.service.impl;
|
||||
|
||||
import com.orange.demo.app.service.*;
|
||||
import com.orange.demo.app.dao.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.core.util.MyModelUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生行为统计数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("studentActionStatsService")
|
||||
public class StudentActionStatsServiceImpl extends BaseService<StudentActionStats, Long> implements StudentActionStatsService {
|
||||
|
||||
@Autowired
|
||||
private StudentActionStatsMapper studentActionStatsMapper;
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
@Autowired
|
||||
private AreaCodeService areaCodeService;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<StudentActionStats> mapper() {
|
||||
return studentActionStatsMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getStudentActionStatsListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<StudentActionStats> getStudentActionStatsList(StudentActionStats filter, String orderBy) {
|
||||
return studentActionStatsMapper.getStudentActionStatsList(filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentActionStatsList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<StudentActionStats> getStudentActionStatsListWithRelation(StudentActionStats filter, String orderBy) {
|
||||
List<StudentActionStats> resultList = studentActionStatsMapper.getStudentActionStatsList(filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分组过滤后的数据查询结果,以及关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param groupSelect 分组显示列表参数。位于SQL语句SELECT的后面。
|
||||
* @param groupBy 分组参数。位于SQL语句的GROUP BY后面。
|
||||
* @param orderBy 排序字符串,ORDER BY从句的参数。
|
||||
* @return 分组过滤结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<StudentActionStats> getGroupedStudentActionStatsListWithRelation(
|
||||
StudentActionStats filter, String groupSelect, String groupBy, String orderBy) {
|
||||
List<StudentActionStats> resultList =
|
||||
studentActionStatsMapper.getGroupedStudentActionStatsList(filter, groupSelect, groupBy, orderBy);
|
||||
// NOTE: 这里只是包含了关联数据,聚合计算数据没有包含。
|
||||
// 主要原因是,由于聚合字段通常被视为普通字段使用,不会在group by的从句中出现,语义上也不会在此关联。
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal());
|
||||
return resultList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package com.orange.demo.app.service.impl;
|
||||
|
||||
import com.orange.demo.app.service.*;
|
||||
import com.orange.demo.app.dao.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生行为流水数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("studentActionTransService")
|
||||
public class StudentActionTransServiceImpl extends BaseService<StudentActionTrans, Long> implements StudentActionTransService {
|
||||
|
||||
@Autowired
|
||||
private StudentActionTransMapper studentActionTransMapper;
|
||||
@Autowired
|
||||
private SchoolInfoService schoolInfoService;
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<StudentActionTrans> mapper() {
|
||||
return studentActionTransMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param studentActionTrans 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public StudentActionTrans saveNew(StudentActionTrans studentActionTrans) {
|
||||
studentActionTrans.setTransId(idGenerator.nextLongId());
|
||||
studentActionTransMapper.insert(studentActionTrans);
|
||||
return studentActionTrans;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param studentActionTrans 更新的对象。
|
||||
* @param originalStudentActionTrans 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(StudentActionTrans studentActionTrans, StudentActionTrans originalStudentActionTrans) {
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
return studentActionTransMapper.updateByPrimaryKey(studentActionTrans) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param transId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long transId) {
|
||||
// 这里先删除主数据
|
||||
return this.removeById(transId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getStudentActionTransListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<StudentActionTrans> getStudentActionTransList(StudentActionTrans filter, String orderBy) {
|
||||
return studentActionTransMapper.getStudentActionTransList(filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentActionTransList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<StudentActionTrans> getStudentActionTransListWithRelation(StudentActionTrans filter, String orderBy) {
|
||||
List<StudentActionTrans> resultList = studentActionTransMapper.getStudentActionTransList(filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param studentActionTrans 最新数据对象。
|
||||
* @param originalStudentActionTrans 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
@Override
|
||||
public CallResult verifyRelatedData(StudentActionTrans studentActionTrans, StudentActionTrans originalStudentActionTrans) {
|
||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(studentActionTrans, originalStudentActionTrans, StudentActionTrans::getSchoolId)
|
||||
&& !schoolInfoService.existId(studentActionTrans.getSchoolId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "学生校区"));
|
||||
}
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(studentActionTrans, originalStudentActionTrans, StudentActionTrans::getGradeId)
|
||||
&& !gradeService.existId(studentActionTrans.getGradeId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "学生年级"));
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
package com.orange.demo.app.service.impl;
|
||||
|
||||
import com.orange.demo.app.service.*;
|
||||
import com.orange.demo.app.dao.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
|
||||
import com.orange.demo.common.core.object.TokenData;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.core.util.MyModelUtil;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 班级数据数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("studentClassService")
|
||||
public class StudentClassServiceImpl extends BaseService<StudentClass, Long> implements StudentClassService {
|
||||
|
||||
@Autowired
|
||||
private StudentClassMapper studentClassMapper;
|
||||
@Autowired
|
||||
private ClassCourseMapper classCourseMapper;
|
||||
@Autowired
|
||||
private ClassStudentMapper classStudentMapper;
|
||||
@Autowired
|
||||
private SchoolInfoService schoolInfoService;
|
||||
@Autowired
|
||||
private StudentService studentService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<StudentClass> mapper() {
|
||||
return studentClassMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param studentClass 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public StudentClass saveNew(StudentClass studentClass) {
|
||||
studentClass.setClassId(idGenerator.nextLongId());
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
studentClass.setCreateUserId(tokenData.getUserId());
|
||||
studentClass.setCreateTime(new Date());
|
||||
studentClass.setStatus(GlobalDeletedFlag.NORMAL);
|
||||
MyModelUtil.setDefaultValue(studentClass, "finishClassHour", 0);
|
||||
studentClassMapper.insert(studentClass);
|
||||
return studentClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param studentClass 更新的对象。
|
||||
* @param originalStudentClass 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(StudentClass studentClass, StudentClass originalStudentClass) {
|
||||
studentClass.setCreateUserId(originalStudentClass.getCreateUserId());
|
||||
studentClass.setCreateTime(originalStudentClass.getCreateTime());
|
||||
studentClass.setStatus(GlobalDeletedFlag.NORMAL);
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
return studentClassMapper.updateByPrimaryKey(studentClass) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param classId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long classId) {
|
||||
// 这里先删除主数据
|
||||
if (!this.removeById(classId)) {
|
||||
return false;
|
||||
}
|
||||
// 开始删除多对多子表的关联
|
||||
ClassCourse classCourse = new ClassCourse();
|
||||
classCourse.setClassId(classId);
|
||||
classCourseMapper.delete(classCourse);
|
||||
ClassStudent classStudent = new ClassStudent();
|
||||
classStudent.setClassId(classId);
|
||||
classStudentMapper.delete(classStudent);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getStudentClassListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<StudentClass> getStudentClassList(StudentClass filter, String orderBy) {
|
||||
return studentClassMapper.getStudentClassList(filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentClassList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<StudentClass> getStudentClassListWithRelation(StudentClass filter, String orderBy) {
|
||||
List<StudentClass> resultList = studentClassMapper.getStudentClassList(filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加多对多关联关系。
|
||||
*
|
||||
* @param classCourseList 多对多关联表对象集合。
|
||||
* @param classId 主表Id。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void addClassCourseList(List<ClassCourse> classCourseList, Long classId) {
|
||||
for (ClassCourse classCourse : classCourseList) {
|
||||
classCourse.setClassId(classId);
|
||||
MyModelUtil.setDefaultValue(classCourse, "courseOrder", 0);
|
||||
}
|
||||
classCourseMapper.insertList(classCourseList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新中间表数据。
|
||||
*
|
||||
* @param classCourse 中间表对象。
|
||||
* @return 更新成功与否。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean updateClassCourse(ClassCourse classCourse) {
|
||||
Example e = new Example(ClassCourse.class);
|
||||
e.createCriteria()
|
||||
.andEqualTo("classId", classCourse.getClassId())
|
||||
.andEqualTo("courseId", classCourse.getCourseId());
|
||||
return classCourseMapper.updateByExample(classCourse, e) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取中间表数据。
|
||||
*
|
||||
* @param classId 主表Id。
|
||||
* @param courseId 从表Id。
|
||||
* @return 中间表对象。
|
||||
*/
|
||||
@Override
|
||||
public ClassCourse getClassCourse(Long classId, Long courseId) {
|
||||
Example e = new Example(ClassCourse.class);
|
||||
e.createCriteria()
|
||||
.andEqualTo("classId", classId)
|
||||
.andEqualTo("courseId", courseId);
|
||||
return classCourseMapper.selectOneByExample(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除单条多对多关系。
|
||||
*
|
||||
* @param classId 主表Id。
|
||||
* @param courseId 从表Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean removeClassCourse(Long classId, Long courseId) {
|
||||
ClassCourse filter = new ClassCourse();
|
||||
filter.setClassId(classId);
|
||||
filter.setCourseId(courseId);
|
||||
return classCourseMapper.delete(filter) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加多对多关联关系。
|
||||
*
|
||||
* @param classStudentList 多对多关联表对象集合。
|
||||
* @param classId 主表Id。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void addClassStudentList(List<ClassStudent> classStudentList, Long classId) {
|
||||
for (ClassStudent classStudent : classStudentList) {
|
||||
classStudent.setClassId(classId);
|
||||
}
|
||||
classStudentMapper.insertList(classStudentList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除单条多对多关系。
|
||||
*
|
||||
* @param classId 主表Id。
|
||||
* @param studentId 从表Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean removeClassStudent(Long classId, Long studentId) {
|
||||
ClassStudent filter = new ClassStudent();
|
||||
filter.setClassId(classId);
|
||||
filter.setStudentId(studentId);
|
||||
return classStudentMapper.delete(filter) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param studentClass 最新数据对象。
|
||||
* @param originalStudentClass 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false。
|
||||
*/
|
||||
@Override
|
||||
public CallResult verifyRelatedData(StudentClass studentClass, StudentClass originalStudentClass) {
|
||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(studentClass, originalStudentClass, StudentClass::getSchoolId)
|
||||
&& !schoolInfoService.existId(studentClass.getSchoolId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "所属校区"));
|
||||
}
|
||||
//这里是基于字典的验证。
|
||||
if (this.needToVerify(studentClass, originalStudentClass, StudentClass::getLeaderId)
|
||||
&& !studentService.existId(studentClass.getLeaderId())) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "学生班长"));
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
package com.orange.demo.app.service.impl;
|
||||
|
||||
import com.orange.demo.application.common.constant.StudentStatus;
|
||||
import com.orange.demo.app.service.*;
|
||||
import com.orange.demo.app.dao.*;
|
||||
import com.orange.demo.app.model.*;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.core.util.MyModelUtil;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生数据数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("studentService")
|
||||
public class StudentServiceImpl extends BaseService<Student, Long> implements StudentService {
|
||||
|
||||
@Autowired
|
||||
private StudentMapper studentMapper;
|
||||
@Autowired
|
||||
private ClassStudentMapper classStudentMapper;
|
||||
@Autowired
|
||||
private AreaCodeService areaCodeService;
|
||||
@Autowired
|
||||
private GradeService gradeService;
|
||||
@Autowired
|
||||
private SchoolInfoService schoolInfoService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<Student> mapper() {
|
||||
return studentMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
*
|
||||
* @param student 新增对象。
|
||||
* @return 返回新增对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public Student saveNew(Student student) {
|
||||
student.setStudentId(idGenerator.nextLongId());
|
||||
student.setRegisterTime(new Date());
|
||||
MyModelUtil.setDefaultValue(student, "totalCoin", 0);
|
||||
MyModelUtil.setDefaultValue(student, "leftCoin", 0);
|
||||
MyModelUtil.setDefaultValue(student, "status", StudentStatus.NORMAL);
|
||||
studentMapper.insert(student);
|
||||
return student;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
*
|
||||
* @param student 更新的对象。
|
||||
* @param originalStudent 原有数据对象。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(Student student, Student originalStudent) {
|
||||
student.setRegisterTime(originalStudent.getRegisterTime());
|
||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
||||
return studentMapper.updateByPrimaryKey(student) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
*
|
||||
* @param studentId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long studentId) {
|
||||
// 这里先删除主数据
|
||||
if (!this.removeById(studentId)) {
|
||||
return false;
|
||||
}
|
||||
// 开始删除多对多父表的关联
|
||||
ClassStudent classStudent = new ClassStudent();
|
||||
classStudent.setStudentId(studentId);
|
||||
classStudentMapper.delete(classStudent);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getStudentListWithRelation)方法。
|
||||
*
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<Student> getStudentList(Student filter, String orderBy) {
|
||||
return studentMapper.getStudentList(filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<Student> getStudentListWithRelation(Student filter, String orderBy) {
|
||||
List<Student> resultList = studentMapper.getStudentList(filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal());
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.orange.demo.app.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-09-24
|
||||
*/
|
||||
@ApiModel("行政区划实体对象")
|
||||
@Data
|
||||
public class AreaCodeVo {
|
||||
|
||||
/**
|
||||
* 行政区划主键Id
|
||||
*/
|
||||
@ApiModelProperty(value = "行政区划主键Id", required = true)
|
||||
private Long areaId;
|
||||
|
||||
/**
|
||||
* 行政区划名称
|
||||
*/
|
||||
@ApiModelProperty(value = "行政区划名称")
|
||||
private String areaName;
|
||||
|
||||
/**
|
||||
* 行政区划级别 (1: 省级别 2: 市级别 3: 区级别)
|
||||
*/
|
||||
@ApiModelProperty(value = "行政区划级别")
|
||||
private Integer areaLevel;
|
||||
|
||||
/**
|
||||
* 父级行政区划Id
|
||||
*/
|
||||
@ApiModelProperty(value = "父级行政区划Id")
|
||||
private Long parentId;
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.orange.demo.app.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-09-24
|
||||
*/
|
||||
@ApiModel("ClassCourseVO实体对象")
|
||||
@Data
|
||||
public class ClassCourseVo {
|
||||
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "班级Id")
|
||||
private Long classId;
|
||||
|
||||
/**
|
||||
* 课程Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "课程Id")
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 课程顺序(数值越小越靠前)。
|
||||
*/
|
||||
@ApiModelProperty(value = "课程顺序(数值越小越靠前)")
|
||||
private Integer courseOrder;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.orange.demo.app.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-09-24
|
||||
*/
|
||||
@ApiModel("ClassStudentVO实体对象")
|
||||
@Data
|
||||
public class ClassStudentVo {
|
||||
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "班级Id")
|
||||
private Long classId;
|
||||
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生Id")
|
||||
private Long studentId;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.orange.demo.app.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -11,66 +13,79 @@ import java.util.Map;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("CourseTransStatsVO实体对象")
|
||||
@Data
|
||||
public class CourseTransStatsVo {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "主键Id")
|
||||
private Long statsId;
|
||||
|
||||
/**
|
||||
* 统计日期。
|
||||
*/
|
||||
@ApiModelProperty(value = "统计日期")
|
||||
private Date statsDate;
|
||||
|
||||
/**
|
||||
* 科目Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "科目Id")
|
||||
private Integer subjectId;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "年级Id")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 年级名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "年级名称")
|
||||
private String gradeName;
|
||||
|
||||
/**
|
||||
* 课程Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "课程Id")
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 课程名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "课程名称")
|
||||
private String courseName;
|
||||
|
||||
/**
|
||||
* 学生上课次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生上课次数")
|
||||
private Integer studentAttendCount;
|
||||
|
||||
/**
|
||||
* 学生献花数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生献花数量")
|
||||
private Integer studentFlowerAmount;
|
||||
|
||||
/**
|
||||
* 学生献花次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生献花次数")
|
||||
private Integer studentFlowerCount;
|
||||
|
||||
/**
|
||||
* gradeId 字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "gradeId 字典关联数据")
|
||||
private Map<String, Object> gradeIdDictMap;
|
||||
|
||||
/**
|
||||
* subjectId 常量字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "subjectId 常量字典关联数据")
|
||||
private Map<String, Object> subjectIdDictMap;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.orange.demo.app.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-09-24
|
||||
*/
|
||||
@ApiModel("CourseVO实体对象")
|
||||
@Data
|
||||
public class CourseVo {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "主键Id")
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 课程名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "课程名称")
|
||||
private String courseName;
|
||||
|
||||
/**
|
||||
* 课程价格。
|
||||
*/
|
||||
@ApiModelProperty(value = "课程价格")
|
||||
private BigDecimal price;
|
||||
|
||||
/**
|
||||
* 课程描述。
|
||||
*/
|
||||
@ApiModelProperty(value = "课程描述")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 课程难度(0: 容易 1: 普通 2: 很难)。
|
||||
*/
|
||||
@ApiModelProperty(value = "课程难度(0: 容易 1: 普通 2: 很难)")
|
||||
private Integer difficulty;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "年级Id")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 学科Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "学科Id")
|
||||
private Integer subjectId;
|
||||
|
||||
/**
|
||||
* 课时数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "课时数量")
|
||||
private Integer classHour;
|
||||
|
||||
/**
|
||||
* 多张课程图片地址。
|
||||
*/
|
||||
@ApiModelProperty(value = "多张课程图片地址")
|
||||
private String pictureUrl;
|
||||
|
||||
/**
|
||||
* 创建用户Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "创建用户Id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 最后修改时间。
|
||||
*/
|
||||
@ApiModelProperty(value = "最后修改时间")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* courseId 的多对多关联表数据对象,数据对应类型为ClassCourseVo。
|
||||
*/
|
||||
@ApiModelProperty(value = "courseId 的多对多关联表数据对象,数据对应类型为ClassCourseVo")
|
||||
private Map<String, Object> classCourse;
|
||||
|
||||
/**
|
||||
* gradeId 字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "gradeId 字典关联数据")
|
||||
private Map<String, Object> gradeIdDictMap;
|
||||
|
||||
/**
|
||||
* difficulty 常量字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "difficulty 常量字典关联数据")
|
||||
private Map<String, Object> difficultyDictMap;
|
||||
|
||||
/**
|
||||
* subjectId 常量字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "subjectId 常量字典关联数据")
|
||||
private Map<String, Object> subjectIdDictMap;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.orange.demo.app.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-09-24
|
||||
*/
|
||||
@ApiModel("GradeVO实体对象")
|
||||
@Data
|
||||
public class GradeVo {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "主键Id")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 年级名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "年级名称")
|
||||
private String gradeName;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.orange.demo.app.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-09-24
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.orange.demo.app.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -11,126 +13,151 @@ import java.util.Map;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("StudentActionStatsVO实体对象")
|
||||
@Data
|
||||
public class StudentActionStatsVo {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "主键Id")
|
||||
private Long statsId;
|
||||
|
||||
/**
|
||||
* 统计日期。
|
||||
*/
|
||||
@ApiModelProperty(value = "统计日期")
|
||||
private Date statsDate;
|
||||
|
||||
/**
|
||||
* 统计小时。
|
||||
*/
|
||||
@ApiModelProperty(value = "统计小时")
|
||||
private Date statsMonth;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "年级Id")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 学生所在省Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生所在省Id")
|
||||
private Long provinceId;
|
||||
|
||||
/**
|
||||
* 学生所在城市Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生所在城市Id")
|
||||
private Long cityId;
|
||||
|
||||
/**
|
||||
* 购课学币数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购课学币数量")
|
||||
private Integer buyCourseAmount;
|
||||
|
||||
/**
|
||||
* 购买课程次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买课程次数")
|
||||
private Integer buyCourseCount;
|
||||
|
||||
/**
|
||||
* 购买视频学币数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买视频学币数量")
|
||||
private Integer buyVideoAmount;
|
||||
|
||||
/**
|
||||
* 购买视频次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买视频次数")
|
||||
private Integer buyVideoCount;
|
||||
|
||||
/**
|
||||
* 购买作业学币数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买作业学币数量")
|
||||
private Integer buyPaperAmount;
|
||||
|
||||
/**
|
||||
* 购买作业次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买作业次数")
|
||||
private Integer buyPaperCount;
|
||||
|
||||
/**
|
||||
* 购买献花数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买献花数量")
|
||||
private Integer buyFlowerAmount;
|
||||
|
||||
/**
|
||||
* 购买献花次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买献花次数")
|
||||
private Integer buyFlowerCount;
|
||||
|
||||
/**
|
||||
* 充值学币数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "充值学币数量")
|
||||
private Integer rechargeCoinAmount;
|
||||
|
||||
/**
|
||||
* 充值学币次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "充值学币次数")
|
||||
private Integer rechargeCoinCount;
|
||||
|
||||
/**
|
||||
* 线下课程上课次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "线下课程上课次数")
|
||||
private Integer doCourseCount;
|
||||
|
||||
/**
|
||||
* 观看视频次数。
|
||||
*/
|
||||
@ApiModelProperty(value = "观看视频次数")
|
||||
private Integer watchVideoCount;
|
||||
|
||||
/**
|
||||
* 购买献花消费学币数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买献花消费学币数量")
|
||||
private Integer watchVideoTotalSecond;
|
||||
|
||||
/**
|
||||
* 做题数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "做题数量")
|
||||
private Integer doExerciseCount;
|
||||
|
||||
/**
|
||||
* 做题正确的数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "做题正确的数量")
|
||||
private Integer doExerciseCorrectCount;
|
||||
|
||||
/**
|
||||
* gradeId 字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "gradeId 字典关联数据")
|
||||
private Map<String, Object> gradeIdDictMap;
|
||||
|
||||
/**
|
||||
* provinceId 字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "provinceId 字典关联数据")
|
||||
private Map<String, Object> provinceIdDictMap;
|
||||
|
||||
/**
|
||||
* cityId 字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "cityId 字典关联数据")
|
||||
private Map<String, Object> cityIdDictMap;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.orange.demo.app.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -11,101 +13,121 @@ import java.util.Map;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("StudentActionTransVO实体对象")
|
||||
@Data
|
||||
public class StudentActionTransVo {
|
||||
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "主键Id")
|
||||
private Long transId;
|
||||
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生Id")
|
||||
private Long studentId;
|
||||
|
||||
/**
|
||||
* 学生名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生名称")
|
||||
private String studentName;
|
||||
|
||||
/**
|
||||
* 学生校区。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生校区")
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "年级Id")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 行为类型(0: 充值 1: 购课 2: 上课签到 3: 上课签退 4: 看视频课 5: 做作业 6: 刷题 7: 献花)。
|
||||
*/
|
||||
@ApiModelProperty(value = "行为类型(0: 充值 1: 购课 2: 上课签到 3: 上课签退 4: 看视频课 5: 做作业 6: 刷题 7: 献花)")
|
||||
private Integer actionType;
|
||||
|
||||
/**
|
||||
* 设备类型(0: iOS 1: Android 2: PC)。
|
||||
*/
|
||||
@ApiModelProperty(value = "设备类型(0: iOS 1: Android 2: PC)")
|
||||
private Integer deviceType;
|
||||
|
||||
/**
|
||||
* 看视频秒数。
|
||||
*/
|
||||
@ApiModelProperty(value = "看视频秒数")
|
||||
private Integer watchVideoSeconds;
|
||||
|
||||
/**
|
||||
* 购买献花数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买献花数量")
|
||||
private Integer flowerCount;
|
||||
|
||||
/**
|
||||
* 购买作业数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买作业数量")
|
||||
private Integer paperCount;
|
||||
|
||||
/**
|
||||
* 购买视频数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买视频数量")
|
||||
private Integer videoCount;
|
||||
|
||||
/**
|
||||
* 购买课程数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "购买课程数量")
|
||||
private Integer courseCount;
|
||||
|
||||
/**
|
||||
* 充值学币数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "充值学币数量")
|
||||
private Integer coinCount;
|
||||
|
||||
/**
|
||||
* 做题是否正确标记。
|
||||
*/
|
||||
@ApiModelProperty(value = "做题是否正确标记")
|
||||
private Integer exerciseCorrectFlag;
|
||||
|
||||
/**
|
||||
* 发生时间。
|
||||
*/
|
||||
@ApiModelProperty(value = "发生时间")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* schoolId 字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "schoolId 字典关联数据")
|
||||
private Map<String, Object> schoolIdDictMap;
|
||||
|
||||
/**
|
||||
* gradeId 字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "gradeId 字典关联数据")
|
||||
private Map<String, Object> gradeIdDictMap;
|
||||
|
||||
/**
|
||||
* actionType 常量字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "actionType 常量字典关联数据")
|
||||
private Map<String, Object> actionTypeDictMap;
|
||||
|
||||
/**
|
||||
* deviceType 常量字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "deviceType 常量字典关联数据")
|
||||
private Map<String, Object> deviceTypeDictMap;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.orange.demo.app.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-09-24
|
||||
*/
|
||||
@ApiModel("StudentClassVO实体对象")
|
||||
@Data
|
||||
public class StudentClassVo {
|
||||
|
||||
/**
|
||||
* 班级Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "班级Id")
|
||||
private Long classId;
|
||||
|
||||
/**
|
||||
* 班级名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "班级名称")
|
||||
private String className;
|
||||
|
||||
/**
|
||||
* 学校Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "学校Id")
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 学生班长Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生班长Id")
|
||||
private Long leaderId;
|
||||
|
||||
/**
|
||||
* 已完成课时数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "已完成课时数量")
|
||||
private Integer finishClassHour;
|
||||
|
||||
/**
|
||||
* 班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)。
|
||||
*/
|
||||
@ApiModelProperty(value = "班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)")
|
||||
private Integer classLevel;
|
||||
|
||||
/**
|
||||
* 创建用户。
|
||||
*/
|
||||
@ApiModelProperty(value = "创建用户")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 班级创建时间。
|
||||
*/
|
||||
@ApiModelProperty(value = "班级创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* schoolId 字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "schoolId 字典关联数据")
|
||||
private Map<String, Object> schoolIdDictMap;
|
||||
|
||||
/**
|
||||
* leaderId 字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "leaderId 字典关联数据")
|
||||
private Map<String, Object> leaderIdDictMap;
|
||||
|
||||
/**
|
||||
* classLevel 常量字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "classLevel 常量字典关联数据")
|
||||
private Map<String, Object> classLevelDictMap;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.orange.demo.app.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-09-24
|
||||
*/
|
||||
@ApiModel("StudentVO实体对象")
|
||||
@Data
|
||||
public class StudentVo {
|
||||
|
||||
/**
|
||||
* 学生Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生Id")
|
||||
private Long studentId;
|
||||
|
||||
/**
|
||||
* 登录手机。
|
||||
*/
|
||||
@ApiModelProperty(value = "登录手机")
|
||||
private String loginMobile;
|
||||
|
||||
/**
|
||||
* 学生姓名。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生姓名")
|
||||
private String studentName;
|
||||
|
||||
/**
|
||||
* 所在省份Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "所在省份Id")
|
||||
private Long provinceId;
|
||||
|
||||
/**
|
||||
* 所在城市Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "所在城市Id")
|
||||
private Long cityId;
|
||||
|
||||
/**
|
||||
* 区县Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "区县Id")
|
||||
private Long districtId;
|
||||
|
||||
/**
|
||||
* 学生性别 (0: 女生 1: 男生)。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生性别 (0: 女生 1: 男生)")
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 生日。
|
||||
*/
|
||||
@ApiModelProperty(value = "生日")
|
||||
private Date birthday;
|
||||
|
||||
/**
|
||||
* 经验等级 (0: 初级 1: 中级 2: 高级 3: 资深)。
|
||||
*/
|
||||
@ApiModelProperty(value = "经验等级 (0: 初级 1: 中级 2: 高级 3: 资深)")
|
||||
private Integer experienceLevel;
|
||||
|
||||
/**
|
||||
* 总共充值学币数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "总共充值学币数量")
|
||||
private Integer totalCoin;
|
||||
|
||||
/**
|
||||
* 可用学币数量。
|
||||
*/
|
||||
@ApiModelProperty(value = "可用学币数量")
|
||||
private Integer leftCoin;
|
||||
|
||||
/**
|
||||
* 年级Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "年级Id")
|
||||
private Integer gradeId;
|
||||
|
||||
/**
|
||||
* 校区Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "校区Id")
|
||||
private Long schoolId;
|
||||
|
||||
/**
|
||||
* 注册时间。
|
||||
*/
|
||||
@ApiModelProperty(value = "注册时间")
|
||||
private Date registerTime;
|
||||
|
||||
/**
|
||||
* 学生状态 (0: 正常 1: 锁定 2: 注销)。
|
||||
*/
|
||||
@ApiModelProperty(value = "学生状态 (0: 正常 1: 锁定 2: 注销)")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* provinceId 字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "provinceId 字典关联数据")
|
||||
private Map<String, Object> provinceIdDictMap;
|
||||
|
||||
/**
|
||||
* cityId 字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "cityId 字典关联数据")
|
||||
private Map<String, Object> cityIdDictMap;
|
||||
|
||||
/**
|
||||
* districtId 字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "districtId 字典关联数据")
|
||||
private Map<String, Object> districtIdDictMap;
|
||||
|
||||
/**
|
||||
* gradeId 字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "gradeId 字典关联数据")
|
||||
private Map<String, Object> gradeIdDictMap;
|
||||
|
||||
/**
|
||||
* schoolId 字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "schoolId 字典关联数据")
|
||||
private Map<String, Object> schoolIdDictMap;
|
||||
|
||||
/**
|
||||
* gender 常量字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "gender 常量字典关联数据")
|
||||
private Map<String, Object> genderDictMap;
|
||||
|
||||
/**
|
||||
* experienceLevel 常量字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "experienceLevel 常量字典关联数据")
|
||||
private Map<String, Object> experienceLevelDictMap;
|
||||
|
||||
/**
|
||||
* status 常量字典关联数据。
|
||||
*/
|
||||
@ApiModelProperty(value = "status 常量字典关联数据")
|
||||
private Map<String, Object> statusDictMap;
|
||||
}
|
||||
|
||||
@@ -43,10 +43,10 @@ public class AuthenticationInterceptor implements HandlerInterceptor {
|
||||
ApplicationContextHolder.getBean("sessionCacheHelper");
|
||||
|
||||
private SysPermService sysPermService =
|
||||
ApplicationContextHolder.getBean("sysPermService");
|
||||
ApplicationContextHolder.getBean(SysPermService.class);
|
||||
|
||||
private static SysPermWhitelistService sysPermWhitelistService =
|
||||
ApplicationContextHolder.getBean("sysPermWhitelistService");
|
||||
ApplicationContextHolder.getBean(SysPermWhitelistService.class);
|
||||
|
||||
private static Set<String> whitelistPermSet;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.orange.demo.upms.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.orange.demo.config.ApplicationConfig;
|
||||
import com.orange.demo.upms.service.*;
|
||||
@@ -30,6 +34,8 @@ import java.util.*;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiSupport(order = 1)
|
||||
@Api(tags = "用户登录接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/upms/login")
|
||||
@@ -57,6 +63,12 @@ public class LoginController {
|
||||
* @param password 密码。
|
||||
* @return 应答结果对象,其中包括JWT的Token数据,以及菜单列表。
|
||||
*/
|
||||
@ApiImplicitParams({
|
||||
// 这里包含密码密文,仅用于方便开发期间的接口测试,集成测试和发布阶段,需要将当前注解去掉。
|
||||
// 如果您重新生成了公钥和私钥,请替换password的缺省值。
|
||||
@ApiImplicitParam(name = "loginName", defaultValue = "admin"),
|
||||
@ApiImplicitParam(name = "password", defaultValue = "IP3ccke3GhH45iGHB5qP9p7iZw6xUyj28Ju10rnBiPKOI35sc%2BjI7%2FdsjOkHWMfUwGYGfz8ik31HC2Ruk%2Fhkd9f6RPULTHj7VpFdNdde2P9M4mQQnFBAiPM7VT9iW3RyCtPlJexQ3nAiA09OqG%2F0sIf1kcyveSrulxembARDbDo%3D")
|
||||
})
|
||||
@NoAuthInterface
|
||||
@PostMapping("/doLogin")
|
||||
public ResponseResult<JSONObject> doLogin(
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.orange.demo.upms.controller;
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.orange.demo.upms.dto.SysMenuDto;
|
||||
import com.orange.demo.upms.vo.SysMenuVo;
|
||||
import com.orange.demo.upms.model.SysMenu;
|
||||
import com.orange.demo.upms.service.SysMenuService;
|
||||
@@ -21,6 +24,7 @@ import java.util.*;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Api(tags = "菜单管理接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/upms/sysMenu")
|
||||
@@ -32,17 +36,20 @@ public class SysMenuController {
|
||||
/**
|
||||
* 添加新菜单操作。
|
||||
*
|
||||
* @param sysMenu 新菜单对象。
|
||||
* @param sysMenuDto 新菜单对象。
|
||||
* @param permCodeIdListString 与当前菜单Id绑定的权限Id列表,多个权限之间逗号分隔。
|
||||
* @return 应答结果对象,包含新增菜单的主键Id。
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@ApiOperationSupport(ignoreParameters = {"sysMenu.menuId"})
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody SysMenu sysMenu, @MyRequestBody String permCodeIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysMenu);
|
||||
public ResponseResult<Long> add(
|
||||
@MyRequestBody("sysMenu") SysMenuDto sysMenuDto, @MyRequestBody String permCodeIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysMenuDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysMenu sysMenu = MyModelUtil.copyTo(sysMenuDto, SysMenu.class);
|
||||
CallResult result = sysMenuService.verifyRelatedData(sysMenu, null, permCodeIdListString);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
@@ -58,22 +65,24 @@ public class SysMenuController {
|
||||
/**
|
||||
* 更新菜单数据操作。
|
||||
*
|
||||
* @param sysMenu 更新菜单对象。
|
||||
* @param sysMenuDto 更新菜单对象。
|
||||
* @param permCodeIdListString 与当前菜单Id绑定的权限Id列表,多个权限之间逗号分隔。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody SysMenu sysMenu, @MyRequestBody String permCodeIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysMenu, Default.class, UpdateGroup.class);
|
||||
public ResponseResult<Void> update(
|
||||
@MyRequestBody("sysMenu") SysMenuDto sysMenuDto, @MyRequestBody String permCodeIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysMenuDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysMenu originalSysMenu = sysMenuService.getById(sysMenu.getMenuId());
|
||||
SysMenu originalSysMenu = sysMenuService.getById(sysMenuDto.getMenuId());
|
||||
if (originalSysMenu == null) {
|
||||
errorMessage = "数据验证失败,当前菜单并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
SysMenu sysMenu = MyModelUtil.copyTo(sysMenuDto, SysMenu.class);
|
||||
CallResult result = sysMenuService.verifyRelatedData(sysMenu, originalSysMenu, permCodeIdListString);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.orange.demo.upms.controller;
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.orange.demo.upms.dto.SysPermCodeDto;
|
||||
import com.orange.demo.upms.vo.SysPermCodeVo;
|
||||
import com.orange.demo.upms.model.SysPermCode;
|
||||
import com.orange.demo.upms.service.SysPermCodeService;
|
||||
@@ -22,6 +25,7 @@ import java.util.*;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Api(tags = "权限字管理接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/upms/sysPermCode")
|
||||
@@ -33,17 +37,20 @@ public class SysPermCodeController {
|
||||
/**
|
||||
* 新增权限字操作。
|
||||
*
|
||||
* @param sysPermCode 新增权限字对象。
|
||||
* @param sysPermCodeDto 新增权限字对象。
|
||||
* @param permIdListString 与当前权限Id绑定的权限资源Id列表,多个权限资源之间逗号分隔。
|
||||
* @return 应答结果对象,包含新增权限字的主键Id。
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@ApiOperationSupport(ignoreParameters = {"sysPermCode.permCodeId"})
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody SysPermCode sysPermCode, @MyRequestBody String permIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermCode);
|
||||
public ResponseResult<Long> add(
|
||||
@MyRequestBody("sysPermCode") SysPermCodeDto sysPermCodeDto, @MyRequestBody String permIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermCodeDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED);
|
||||
}
|
||||
SysPermCode sysPermCode = MyModelUtil.copyTo(sysPermCodeDto, SysPermCode.class);
|
||||
CallResult result = sysPermCodeService.verifyRelatedData(sysPermCode, null, permIdListString);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
@@ -59,22 +66,24 @@ public class SysPermCodeController {
|
||||
/**
|
||||
* 更新权限字操作。
|
||||
*
|
||||
* @param sysPermCode 更新权限字对象。
|
||||
* @param sysPermCodeDto 更新权限字对象。
|
||||
* @param permIdListString 与当前权限Id绑定的权限资源Id列表,多个权限资源之间逗号分隔。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody SysPermCode sysPermCode, @MyRequestBody String permIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermCode, Default.class, UpdateGroup.class);
|
||||
public ResponseResult<Void> update(
|
||||
@MyRequestBody("sysPermCode") SysPermCodeDto sysPermCodeDto, @MyRequestBody String permIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermCodeDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysPermCode originalSysPermCode = sysPermCodeService.getById(sysPermCode.getPermCodeId());
|
||||
SysPermCode originalSysPermCode = sysPermCodeService.getById(sysPermCodeDto.getPermCodeId());
|
||||
if (originalSysPermCode == null) {
|
||||
errorMessage = "数据验证失败,当前权限字并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
SysPermCode sysPermCode = MyModelUtil.copyTo(sysPermCodeDto, SysPermCode.class);
|
||||
CallResult result = sysPermCodeService.verifyRelatedData(sysPermCode, originalSysPermCode, permIdListString);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
@@ -178,5 +187,5 @@ public class SysPermCodeController {
|
||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
||||
}
|
||||
return ResponseResult.success(sysPermCodeService.getSysRoleListWithDetail(permCodeId, roleName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.orange.demo.upms.controller;
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.orange.demo.upms.dto.SysPermDto;
|
||||
import com.orange.demo.upms.vo.SysPermVo;
|
||||
import com.orange.demo.upms.model.SysPerm;
|
||||
import com.orange.demo.upms.service.SysPermService;
|
||||
@@ -24,6 +27,7 @@ import java.util.Map;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Api(tags = "权限资源管理接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/upms/sysPerm")
|
||||
@@ -35,15 +39,17 @@ public class SysPermController {
|
||||
/**
|
||||
* 新增权限资源操作。
|
||||
*
|
||||
* @param sysPerm 新增权限资源对象。
|
||||
* @param sysPermDto 新增权限资源对象。
|
||||
* @return 应答结果对象,包含新增权限资源的主键Id。
|
||||
*/
|
||||
@ApiOperationSupport(ignoreParameters = {"sysPerm.permId"})
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody SysPerm sysPerm) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPerm);
|
||||
public ResponseResult<Long> add(@MyRequestBody("sysPerm") SysPermDto sysPermDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysPerm sysPerm = MyModelUtil.copyTo(sysPermDto, SysPerm.class);
|
||||
CallResult result = sysPermService.verifyRelatedData(sysPerm, null);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
@@ -55,20 +61,21 @@ public class SysPermController {
|
||||
/**
|
||||
* 更新权限资源操作。
|
||||
*
|
||||
* @param sysPerm 更新权限资源对象。
|
||||
* @param sysPermDto 更新权限资源对象。
|
||||
* @return 应答结果对象,包含更新权限资源的主键Id。
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody SysPerm sysPerm) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPerm, Default.class, UpdateGroup.class);
|
||||
public ResponseResult<Void> update(@MyRequestBody("sysPerm") SysPermDto sysPermDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysPerm originalPerm = sysPermService.getById(sysPerm.getPermId());
|
||||
SysPerm originalPerm = sysPermService.getById(sysPermDto.getPermId());
|
||||
if (originalPerm == null) {
|
||||
errorMessage = "数据验证失败,当前权限资源并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
SysPerm sysPerm = MyModelUtil.copyTo(sysPermDto, SysPerm.class);
|
||||
CallResult result = sysPermService.verifyRelatedData(sysPerm, originalPerm);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
@@ -117,17 +124,18 @@ public class SysPermController {
|
||||
/**
|
||||
* 查看权限资源列表。
|
||||
*
|
||||
* @param sysPermFilter 过滤对象。
|
||||
* @param pageParam 分页参数。
|
||||
* @param sysPermDtoFiltter 过滤对象。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含权限资源列表。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<SysPermVo>> list(
|
||||
@MyRequestBody SysPerm sysPermFilter, @MyRequestBody MyPageParam pageParam) {
|
||||
@MyRequestBody("sysPermFilter") SysPermDto sysPermDtoFiltter, @MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
List<SysPerm> permList = sysPermService.getPermListWithRelation(sysPermFilter);
|
||||
SysPerm filter = MyModelUtil.copyTo(sysPermDtoFiltter, SysPerm.class);
|
||||
List<SysPerm> permList = sysPermService.getPermListWithRelation(filter);
|
||||
List<SysPermVo> permVoList = MyModelUtil.copyCollectionTo(permList, SysPermVo.class);
|
||||
long totalCount = 0L;
|
||||
if (permList instanceof Page) {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.orange.demo.upms.controller;
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.orange.demo.upms.dto.SysPermModuleDto;
|
||||
import com.orange.demo.upms.vo.SysPermModuleVo;
|
||||
import com.orange.demo.upms.model.SysPerm;
|
||||
import com.orange.demo.upms.model.SysPermModule;
|
||||
@@ -26,6 +29,7 @@ import java.util.Map;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Api(tags = "权限资源模块管理接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/upms/sysPermModule")
|
||||
@@ -37,15 +41,17 @@ public class SysPermModuleController {
|
||||
/**
|
||||
* 新增权限资源模块操作。
|
||||
*
|
||||
* @param sysPermModule 新增权限资源模块对象。
|
||||
* @param sysPermModuleDto 新增权限资源模块对象。
|
||||
* @return 应答结果对象,包含新增权限资源模块的主键Id。
|
||||
*/
|
||||
@ApiOperationSupport(ignoreParameters = {"sysPermModule.moduleId"})
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody SysPermModule sysPermModule) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermModule);
|
||||
public ResponseResult<Long> add(@MyRequestBody("sysPermModule") SysPermModuleDto sysPermModuleDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermModuleDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysPermModule sysPermModule = MyModelUtil.copyTo(sysPermModuleDto, SysPermModule.class);
|
||||
if (sysPermModule.getParentId() != null
|
||||
&& sysPermModuleService.getById(sysPermModule.getParentId()) == null) {
|
||||
errorMessage = "数据验证失败,关联的上级权限模块并不存在,请刷新后重试!";
|
||||
@@ -58,15 +64,16 @@ public class SysPermModuleController {
|
||||
/**
|
||||
* 更新权限资源模块操作。
|
||||
*
|
||||
* @param sysPermModule 更新权限资源模块对象。
|
||||
* @param sysPermModuleDto 更新权限资源模块对象。
|
||||
* @return 应答结果对象,包含新增权限资源模块的主键Id。
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody SysPermModule sysPermModule) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermModule, Default.class, UpdateGroup.class);
|
||||
public ResponseResult<Void> update(@MyRequestBody("sysPermModule") SysPermModuleDto sysPermModuleDto) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysPermModuleDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysPermModule sysPermModule = MyModelUtil.copyTo(sysPermModuleDto, SysPermModule.class);
|
||||
SysPermModule originalPermModule = sysPermModuleService.getById(sysPermModule.getModuleId());
|
||||
if (originalPermModule == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package com.orange.demo.upms.controller;
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.orange.demo.upms.dto.SysRoleDto;
|
||||
import com.orange.demo.upms.dto.SysUserDto;
|
||||
import com.orange.demo.upms.vo.SysRoleVo;
|
||||
import com.orange.demo.upms.vo.SysUserVo;
|
||||
import com.orange.demo.upms.model.SysRole;
|
||||
@@ -28,6 +32,7 @@ import java.util.stream.Collectors;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Api(tags = "角色管理接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/upms/sysRole")
|
||||
@@ -41,17 +46,20 @@ public class SysRoleController {
|
||||
/**
|
||||
* 新增角色操作。
|
||||
*
|
||||
* @param sysRole 新增角色对象。
|
||||
* @param sysRoleDto 新增角色对象。
|
||||
* @param menuIdListString 与当前角色Id绑定的menuId列表,多个menuId之间逗号分隔。
|
||||
* @return 应答结果对象,包含新增角色的主键Id。
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@ApiOperationSupport(ignoreParameters = {"sysRole.roleId", "sysRole.createTimeStart", "sysRole.createTimeEnd"})
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody SysRole sysRole, @MyRequestBody String menuIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysRole);
|
||||
public ResponseResult<Long> add(
|
||||
@MyRequestBody("sysRole") SysRoleDto sysRoleDto, @MyRequestBody String menuIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysRoleDto);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysRole sysRole = MyModelUtil.copyTo(sysRoleDto, SysRole.class);
|
||||
CallResult result = sysRoleService.verifyRelatedData(sysRole, null, menuIdListString);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
@@ -67,22 +75,25 @@ public class SysRoleController {
|
||||
/**
|
||||
* 更新角色操作。
|
||||
*
|
||||
* @param sysRole 更新角色对象。
|
||||
* @param sysRoleDto 更新角色对象。
|
||||
* @param menuIdListString 与当前角色Id绑定的menuId列表,多个menuId之间逗号分隔。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@ApiOperationSupport(ignoreParameters = {"sysRole.createTimeStart", "sysRole.createTimeEnd"})
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody SysRole sysRole, @MyRequestBody String menuIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysRole, Default.class, UpdateGroup.class);
|
||||
public ResponseResult<Void> update(
|
||||
@MyRequestBody("sysRole") SysRoleDto sysRoleDto, @MyRequestBody String menuIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysRoleDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysRole originalSysRole = sysRoleService.getById(sysRole.getRoleId());
|
||||
SysRole originalSysRole = sysRoleService.getById(sysRoleDto.getRoleId());
|
||||
if (originalSysRole == null) {
|
||||
errorMessage = "数据验证失败,当前角色并不存在,请刷新后重试!";
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
||||
}
|
||||
SysRole sysRole = MyModelUtil.copyTo(sysRoleDto, SysRole.class);
|
||||
CallResult result = sysRoleService.verifyRelatedData(sysRole, originalSysRole, menuIdListString);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
@@ -119,21 +130,22 @@ public class SysRoleController {
|
||||
/**
|
||||
* 查看角色列表。
|
||||
*
|
||||
* @param sysRoleFilter 角色过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @param sysRoleDtoFilter 角色过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含角色列表。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<SysRoleVo>> list(
|
||||
@MyRequestBody SysRole sysRoleFilter,
|
||||
@MyRequestBody("sysRoleFilter") SysRoleDto sysRoleDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
SysRole filter = MyModelUtil.copyTo(sysRoleDtoFilter, SysRole.class);
|
||||
List<SysRole> roleList = sysRoleService.getSysRoleList(
|
||||
sysRoleFilter, MyOrderParam.buildOrderBy(orderParam, SysRole.class));
|
||||
filter, MyOrderParam.buildOrderBy(orderParam, SysRole.class));
|
||||
List<SysRoleVo> roleVoList = MyModelUtil.copyCollectionTo(roleList, SysRoleVo.class);
|
||||
long totalCount = 0L;
|
||||
if (roleList instanceof Page) {
|
||||
@@ -165,16 +177,16 @@ public class SysRoleController {
|
||||
* 获取不包含指定角色Id的用户列表。
|
||||
* 用户和角色是多对多关系,当前接口将返回没有赋值指定RoleId的用户列表。可用于给角色添加新用户。
|
||||
*
|
||||
* @param roleId 角色主键Id。
|
||||
* @param sysUserFilter 用户过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @param roleId 角色主键Id。
|
||||
* @param sysUserDtoFilter 用户过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含用户列表数据。
|
||||
*/
|
||||
@PostMapping("/listNotInUserRole")
|
||||
public ResponseResult<MyPageData<SysUserVo>> listNotInUserRole(
|
||||
@MyRequestBody Long roleId,
|
||||
@MyRequestBody SysUser sysUserFilter,
|
||||
@MyRequestBody("sysUserFilter") SysUserDto sysUserDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
ResponseResult<Void> verifyResult = this.doRoleUserVerify(roleId);
|
||||
@@ -184,9 +196,9 @@ public class SysRoleController {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
SysUser filter = MyModelUtil.copyTo(sysUserDtoFilter, SysUser.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysUser.class);
|
||||
List<SysUser> userList =
|
||||
sysUserService.getNotInSysUserListByRoleId(roleId, sysUserFilter, orderBy);
|
||||
List<SysUser> userList = sysUserService.getNotInSysUserListByRoleId(roleId, filter, orderBy);
|
||||
List<SysUserVo> userVoList = MyModelUtil.copyCollectionTo(userList, SysUserVo.class);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(userVoList));
|
||||
}
|
||||
@@ -194,16 +206,16 @@ public class SysRoleController {
|
||||
/**
|
||||
* 拥有指定角色的用户列表。
|
||||
*
|
||||
* @param roleId 角色主键Id。
|
||||
* @param sysUserFilter 用户过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @param roleId 角色主键Id。
|
||||
* @param sysUserDtoFilter 用户过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含用户列表数据。
|
||||
*/
|
||||
@PostMapping("/listUserRole")
|
||||
public ResponseResult<MyPageData<SysUserVo>> listUserRole(
|
||||
@MyRequestBody Long roleId,
|
||||
@MyRequestBody SysUser sysUserFilter,
|
||||
@MyRequestBody("sysUserFilter") SysUserDto sysUserDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
ResponseResult<Void> verifyResult = this.doRoleUserVerify(roleId);
|
||||
@@ -213,8 +225,9 @@ public class SysRoleController {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
SysUser filter = MyModelUtil.copyTo(sysUserDtoFilter, SysUser.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysUser.class);
|
||||
List<SysUser> userList = sysUserService.getSysUserListByRoleId(roleId, sysUserFilter, orderBy);
|
||||
List<SysUser> userList = sysUserService.getSysUserListByRoleId(roleId, filter, orderBy);
|
||||
List<SysUserVo> userVoList = MyModelUtil.copyCollectionTo(userList, SysUserVo.class);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(userVoList));
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.orange.demo.upms.controller;
|
||||
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import com.orange.demo.upms.vo.*;
|
||||
import com.orange.demo.upms.dto.*;
|
||||
import com.orange.demo.upms.model.*;
|
||||
import com.orange.demo.upms.service.*;
|
||||
import com.orange.demo.common.core.object.*;
|
||||
@@ -11,6 +12,8 @@ import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import com.orange.demo.common.core.validator.AddGroup;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.config.ApplicationConfig;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -25,6 +28,7 @@ import javax.validation.groups.Default;
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Api(tags = "用户管理管理接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/upms/sysUser")
|
||||
@@ -40,17 +44,23 @@ public class SysUserController {
|
||||
/**
|
||||
* 新增用户操作。
|
||||
*
|
||||
* @param sysUser 新增用户对象。
|
||||
* @param sysUserDto 新增用户对象。
|
||||
* @param roleIdListString 逗号分隔的角色Id列表。
|
||||
* @return 应答结果对象,包含新增用户的主键Id。
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@ApiOperationSupport(ignoreParameters = {
|
||||
"sysUser.userId",
|
||||
"sysUser.createTimeStart",
|
||||
"sysUser.createTimeEnd"})
|
||||
@PostMapping("/add")
|
||||
public ResponseResult<Long> add(@MyRequestBody SysUser sysUser, @MyRequestBody String roleIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysUser, Default.class, AddGroup.class);
|
||||
public ResponseResult<Long> add(
|
||||
@MyRequestBody("sysUser") SysUserDto sysUserDto, @MyRequestBody String roleIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysUserDto, Default.class, AddGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysUser sysUser = MyModelUtil.copyTo(sysUserDto, SysUser.class);
|
||||
CallResult result = sysUserService.verifyRelatedData(sysUser, null, roleIdListString);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
@@ -63,21 +73,26 @@ public class SysUserController {
|
||||
/**
|
||||
* 更新用户操作。
|
||||
*
|
||||
* @param sysUser 更新用户对象。
|
||||
* @param sysUserDto 更新用户对象。
|
||||
* @param roleIdListString 逗号分隔的角色Id列表。
|
||||
* @return 应答结果对象。
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@ApiOperationSupport(ignoreParameters = {
|
||||
"sysUser.createTimeStart",
|
||||
"sysUser.createTimeEnd"})
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Void> update(@MyRequestBody SysUser sysUser, @MyRequestBody String roleIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysUser, Default.class, UpdateGroup.class);
|
||||
public ResponseResult<Void> update(
|
||||
@MyRequestBody("sysUser") SysUserDto sysUserDto, @MyRequestBody String roleIdListString) {
|
||||
String errorMessage = MyCommonUtil.getModelValidationError(sysUserDto, Default.class, UpdateGroup.class);
|
||||
if (errorMessage != null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
||||
}
|
||||
SysUser originalUser = sysUserService.getById(sysUser.getUserId());
|
||||
SysUser originalUser = sysUserService.getById(sysUserDto.getUserId());
|
||||
if (originalUser == null) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
||||
}
|
||||
SysUser sysUser = MyModelUtil.copyTo(sysUserDto, SysUser.class);
|
||||
CallResult result = sysUserService.verifyRelatedData(sysUser, originalUser, roleIdListString);
|
||||
if (!result.isSuccess()) {
|
||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage());
|
||||
@@ -135,19 +150,20 @@ public class SysUserController {
|
||||
/**
|
||||
* 列出符合过滤条件的用户管理列表。
|
||||
*
|
||||
* @param sysUserFilter 过滤对象。
|
||||
* @param sysUserDtoFilter 过滤对象。
|
||||
* @param orderParam 排序参数。
|
||||
* @param pageParam 分页参数。
|
||||
* @return 应答结果对象,包含查询结果集。
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public ResponseResult<MyPageData<SysUserVo>> list(
|
||||
@MyRequestBody SysUser sysUserFilter,
|
||||
@MyRequestBody("sysUserFilter") SysUserDto sysUserDtoFilter,
|
||||
@MyRequestBody MyOrderParam orderParam,
|
||||
@MyRequestBody MyPageParam pageParam) {
|
||||
if (pageParam != null) {
|
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
}
|
||||
SysUser sysUserFilter = MyModelUtil.copyTo(sysUserDtoFilter, SysUser.class);
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, SysUser.class);
|
||||
List<SysUser> sysUserList = sysUserService.getSysUserListWithRelation(sysUserFilter, orderBy);
|
||||
return ResponseResult.success(MyPageUtil.makeResponseData(sysUserList, SysUser.INSTANCE));
|
||||
|
||||
@@ -9,7 +9,10 @@
|
||||
<result column="form_router_name" jdbcType="VARCHAR" property="formRouterName"/>
|
||||
<result column="show_order" jdbcType="INTEGER" property="showOrder"/>
|
||||
<result column="icon" jdbcType="VARCHAR" property="icon"/>
|
||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="deleted_flag" jdbcType="INTEGER" property="deletedFlag"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
@@ -8,7 +8,10 @@
|
||||
<result column="perm_code_type" jdbcType="INTEGER" property="permCodeType"/>
|
||||
<result column="show_name" jdbcType="VARCHAR" property="showName"/>
|
||||
<result column="show_order" jdbcType="INTEGER" property="showOrder"/>
|
||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="deleted_flag" jdbcType="INTEGER" property="deletedFlag"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
<result column="perm_name" jdbcType="VARCHAR" property="permName"/>
|
||||
<result column="url" jdbcType="VARCHAR" property="url"/>
|
||||
<result column="show_order" jdbcType="INTEGER" property="showOrder"/>
|
||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="deleted_flag" jdbcType="INTEGER" property="deletedFlag"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
<result column="module_name" jdbcType="VARCHAR" property="moduleName"/>
|
||||
<result column="module_type" jdbcType="INTEGER" property="moduleType"/>
|
||||
<result column="show_order" jdbcType="INTEGER" property="showOrder"/>
|
||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="deleted_flag" jdbcType="INTEGER" property="deletedFlag"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<id column="role_id" jdbcType="BIGINT" property="roleId"/>
|
||||
<result column="role_name" jdbcType="VARCHAR" property="roleName"/>
|
||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
||||
<result column="create_username" jdbcType="VARCHAR" property="createUsername"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="deleted_flag" jdbcType="INTEGER" property="deletedFlag"/>
|
||||
</resultMap>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<result column="user_status" jdbcType="INTEGER" property="userStatus"/>
|
||||
<result column="deleted_flag" jdbcType="INTEGER" property="deletedFlag"/>
|
||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
||||
<result column="create_username" jdbcType="VARCHAR" property="createUsername"/>
|
||||
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.orange.demo.upms.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.upms.model.constant.SysMenuType;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 菜单Dto。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("菜单Dto")
|
||||
@Data
|
||||
public class SysMenuDto {
|
||||
|
||||
/**
|
||||
* 菜单Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "菜单Id", required = true)
|
||||
@NotNull(message = "菜单Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
* 父菜单Id,目录菜单的父菜单为null
|
||||
*/
|
||||
@ApiModelProperty(value = "父菜单Id")
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 菜单显示名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "菜单显示名称", required = true)
|
||||
@NotBlank(message = "菜单显示名称不能为空!")
|
||||
private String menuName;
|
||||
|
||||
/**
|
||||
* 菜单类型 (0: 目录 1: 菜单 2: 按钮 3: UI片段)。
|
||||
*/
|
||||
@ApiModelProperty(value = "菜单类型", required = true)
|
||||
@NotNull(message = "菜单类型不能为空!")
|
||||
@ConstDictRef(constDictClass = SysMenuType.class, message = "数据验证失败,菜单类型为无效值!")
|
||||
private Integer menuType;
|
||||
|
||||
/**
|
||||
* 前端表单路由名称,仅用于menu_type为1的菜单类型。
|
||||
*/
|
||||
@ApiModelProperty(value = "前端表单路由名称")
|
||||
private String formRouterName;
|
||||
|
||||
/**
|
||||
* 菜单显示顺序 (值越小,排序越靠前)。
|
||||
*/
|
||||
@ApiModelProperty(value = "菜单显示顺序", required = true)
|
||||
@NotNull(message = "菜单显示顺序不能为空!")
|
||||
private Integer showOrder;
|
||||
|
||||
/**
|
||||
* 菜单图标。
|
||||
*/
|
||||
@ApiModelProperty(value = "菜单显示顺序")
|
||||
private String icon;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.orange.demo.upms.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.upms.model.constant.SysPermCodeType;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 权限字Dto。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("权限字Dto")
|
||||
@Data
|
||||
public class SysPermCodeDto {
|
||||
|
||||
/**
|
||||
* 权限字Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "权限字Id", required = true)
|
||||
@NotNull(message = "权限字Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long permCodeId;
|
||||
|
||||
/**
|
||||
* 权限字标识(一般为有含义的英文字符串)。
|
||||
*/
|
||||
@ApiModelProperty(value = "权限字标识", required = true)
|
||||
@NotBlank(message = "权限字编码不能为空!")
|
||||
private String permCode;
|
||||
|
||||
/**
|
||||
* 上级权限字Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "上级权限字Id")
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 权限字类型(0: 表单 1: UI片段 2: 操作)。
|
||||
*/
|
||||
@ApiModelProperty(value = "权限字类型", required = true)
|
||||
@NotNull(message = "权限字类型不能为空!")
|
||||
@ConstDictRef(constDictClass = SysPermCodeType.class, message = "数据验证失败,权限类型为无效值!")
|
||||
private Integer permCodeType;
|
||||
|
||||
/**
|
||||
* 显示名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "显示名称", required = true)
|
||||
@NotBlank(message = "权限字显示名称不能为空!")
|
||||
private String showName;
|
||||
|
||||
/**
|
||||
* 显示顺序(数值越小,越靠前)。
|
||||
*/
|
||||
@ApiModelProperty(value = "显示顺序", required = true)
|
||||
@NotNull(message = "权限字显示顺序不能为空!")
|
||||
private Integer showOrder;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.orange.demo.upms.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.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 权限资源Dto。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("权限资源Dto")
|
||||
@Data
|
||||
public class SysPermDto {
|
||||
|
||||
/**
|
||||
* 权限资源Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "权限资源Id", required = true)
|
||||
@NotNull(message = "权限Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long permId;
|
||||
|
||||
/**
|
||||
* 权限资源名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "权限资源名称", required = true)
|
||||
@NotBlank(message = "权限资源名称不能为空!")
|
||||
private String permName;
|
||||
|
||||
/**
|
||||
* shiro格式的权限字,如(upms:sysUser:add)。
|
||||
*/
|
||||
@ApiModelProperty(value = "权限字")
|
||||
private String permCode;
|
||||
|
||||
/**
|
||||
* 权限所在的权限模块Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "权限所在的权限模块Id")
|
||||
@NotNull(message = "权限模块Id不能为空!")
|
||||
private Long moduleId;
|
||||
|
||||
/**
|
||||
* 关联的URL。
|
||||
*/
|
||||
@ApiModelProperty(value = "关联的URL", required = true)
|
||||
@NotBlank(message = "权限关联的url不能为空!")
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 权限在当前模块下的顺序,由小到大。
|
||||
*/
|
||||
@ApiModelProperty(value = "显示顺序", required = true)
|
||||
@NotNull(message = "权限显示顺序不能为空!")
|
||||
private Integer showOrder;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.orange.demo.upms.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.upms.model.constant.SysPermModuleType;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 权限资源模块Dto。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("权限资源模块Dto")
|
||||
@Data
|
||||
public class SysPermModuleDto {
|
||||
|
||||
/**
|
||||
* 权限模块Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "权限模块Id", required = true)
|
||||
@NotNull(message = "权限模块Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long moduleId;
|
||||
|
||||
/**
|
||||
* 权限模块名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "权限模块名称", required = true)
|
||||
@NotBlank(message = "权限模块名称不能为空!")
|
||||
private String moduleName;
|
||||
|
||||
/**
|
||||
* 上级权限模块Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "上级权限模块Id")
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 权限模块类型(0: 普通模块 1: Controller模块)。
|
||||
*/
|
||||
@ApiModelProperty(value = "权限模块类型", required = true)
|
||||
@NotNull(message = "模块类型不能为空!")
|
||||
@ConstDictRef(constDictClass = SysPermModuleType.class, message = "数据验证失败,权限模块类型为无效值!")
|
||||
private Integer moduleType;
|
||||
|
||||
/**
|
||||
* 权限模块在当前层级下的顺序,由小到大。
|
||||
*/
|
||||
@ApiModelProperty(value = "显示顺序", required = true)
|
||||
@NotNull(message = "权限模块显示顺序不能为空!")
|
||||
private Integer showOrder;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.orange.demo.upms.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.*;
|
||||
|
||||
/**
|
||||
* 角色Dto。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("角色Dto")
|
||||
@Data
|
||||
public class SysRoleDto {
|
||||
|
||||
/**
|
||||
* 角色Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "角色Id", required = true)
|
||||
@NotNull(message = "角色Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 角色名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "角色名称", required = true)
|
||||
@NotBlank(message = "角色名称不能为空!")
|
||||
private String roleName;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.orange.demo.upms.dto;
|
||||
|
||||
import com.orange.demo.common.core.validator.AddGroup;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.upms.model.constant.SysUserType;
|
||||
import com.orange.demo.upms.model.constant.SysUserStatus;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* SysUserDto对象。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@ApiModel("SysUserDto对象")
|
||||
@Data
|
||||
public class SysUserDto {
|
||||
|
||||
/**
|
||||
* 用户Id。
|
||||
*/
|
||||
@ApiModelProperty(value = "用户Id", required = true)
|
||||
@NotNull(message = "数据验证失败,用户Id不能为空!", groups = {UpdateGroup.class})
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 登录用户名。
|
||||
*/
|
||||
@ApiModelProperty(value = "登录用户名", required = true)
|
||||
@NotBlank(message = "数据验证失败,登录用户名不能为空!")
|
||||
private String loginName;
|
||||
|
||||
/**
|
||||
* 用户密码。
|
||||
*/
|
||||
@ApiModelProperty(value = "用户密码", required = true)
|
||||
@NotBlank(message = "数据验证失败,用户密码不能为空!", groups = {AddGroup.class})
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 用户显示名称。
|
||||
*/
|
||||
@ApiModelProperty(value = "用户显示名称", required = true)
|
||||
@NotBlank(message = "数据验证失败,用户显示名称不能为空!")
|
||||
private String showName;
|
||||
|
||||
/**
|
||||
* 用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)。
|
||||
*/
|
||||
@ApiModelProperty(value = "用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)", required = true)
|
||||
@NotNull(message = "数据验证失败,用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)不能为空!")
|
||||
@ConstDictRef(constDictClass = SysUserType.class, message = "数据验证失败,用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)为无效值!")
|
||||
private Integer userType;
|
||||
|
||||
/**
|
||||
* 用户头像的Url。
|
||||
*/
|
||||
@ApiModelProperty(value = "用户头像的Url")
|
||||
private String headImageUrl;
|
||||
|
||||
/**
|
||||
* 用户状态(0: 正常 1: 锁定)。
|
||||
*/
|
||||
@ApiModelProperty(value = "用户状态(0: 正常 1: 锁定)", required = true)
|
||||
@NotNull(message = "数据验证失败,用户状态(0: 正常 1: 锁定)不能为空!")
|
||||
@ConstDictRef(constDictClass = SysUserStatus.class, message = "数据验证失败,用户状态(0: 正常 1: 锁定)为无效值!")
|
||||
private Integer userStatus;
|
||||
|
||||
/**
|
||||
* createTime 范围过滤起始值(>=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "createTime 范围过滤起始值(>=)")
|
||||
private String createTimeStart;
|
||||
|
||||
/**
|
||||
* createTime 范围过滤结束值(<=)。
|
||||
*/
|
||||
@ApiModelProperty(value = "createTime 范围过滤结束值(<=)")
|
||||
private String createTimeEnd;
|
||||
}
|
||||
@@ -4,9 +4,6 @@ import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
|
||||
import com.orange.demo.common.core.annotation.RelationManyToMany;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.upms.model.constant.SysMenuType;
|
||||
import com.orange.demo.upms.vo.SysMenuVo;
|
||||
import lombok.Data;
|
||||
import org.mapstruct.Mapper;
|
||||
@@ -14,9 +11,7 @@ import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 菜单实体对象。
|
||||
@@ -31,7 +26,6 @@ public class SysMenu {
|
||||
/**
|
||||
* 菜单Id。
|
||||
*/
|
||||
@NotNull(message = "菜单Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@Column(name = "menu_id")
|
||||
private Long menuId;
|
||||
@@ -45,15 +39,12 @@ public class SysMenu {
|
||||
/**
|
||||
* 菜单显示名称。
|
||||
*/
|
||||
@NotBlank(message = "菜单显示名称不能为空!")
|
||||
@Column(name = "menu_name")
|
||||
private String menuName;
|
||||
|
||||
/**
|
||||
* 菜单类型(0: 目录 1: 菜单 2: 按钮 3: UI片段)。
|
||||
*/
|
||||
@NotNull(message = "菜单类型不能为空!")
|
||||
@ConstDictRef(constDictClass = SysMenuType.class, message = "数据验证失败,菜单类型为无效值!")
|
||||
@Column(name = "menu_type")
|
||||
private Integer menuType;
|
||||
|
||||
@@ -66,7 +57,6 @@ public class SysMenu {
|
||||
/**
|
||||
* 菜单显示顺序 (值越小,排序越靠前)。
|
||||
*/
|
||||
@NotNull(message = "菜单显示顺序不能为空!")
|
||||
@Column(name = "show_order")
|
||||
private Integer showOrder;
|
||||
|
||||
@@ -75,12 +65,30 @@ public class SysMenu {
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 创建者Id。
|
||||
*/
|
||||
@Column(name = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新者Id。
|
||||
*/
|
||||
@Column(name = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(name = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
|
||||
*/
|
||||
|
||||
@@ -27,4 +27,4 @@ public class SysMenuPermCode {
|
||||
@Id
|
||||
@Column(name = "perm_code_id")
|
||||
private Long permCodeId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,10 @@ package com.orange.demo.upms.model;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
|
||||
import com.orange.demo.common.core.annotation.RelationDict;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 权限资源实体对象。
|
||||
@@ -24,7 +21,6 @@ public class SysPerm {
|
||||
/**
|
||||
* 权限资源Id。
|
||||
*/
|
||||
@NotNull(message = "权限Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@Column(name = "perm_id")
|
||||
private Long permId;
|
||||
@@ -32,36 +28,50 @@ public class SysPerm {
|
||||
/**
|
||||
* 权限所在的权限模块Id。
|
||||
*/
|
||||
@NotNull(message = "权限模块Id不能为空!")
|
||||
@Column(name = "module_id")
|
||||
private Long moduleId;
|
||||
|
||||
/**
|
||||
* 权限名称。
|
||||
*/
|
||||
@NotBlank(message = "权限名称不能为空!")
|
||||
@Column(name = "perm_name")
|
||||
private String permName;
|
||||
|
||||
/**
|
||||
* 关联的URL。
|
||||
*/
|
||||
@NotBlank(message = "权限关联的url不能为空!")
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 权限在当前模块下的顺序,由小到大。
|
||||
*/
|
||||
@NotNull(message = "权限显示顺序不能为空!")
|
||||
@Column(name = "show_order")
|
||||
private Integer showOrder;
|
||||
|
||||
/**
|
||||
* 创建者Id。
|
||||
*/
|
||||
@Column(name = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新者Id。
|
||||
*/
|
||||
@Column(name = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(name = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
|
||||
*/
|
||||
@@ -78,4 +88,4 @@ public class SysPerm {
|
||||
slaveNameField = "moduleName")
|
||||
@Transient
|
||||
private Map<String, Object> moduleIdDictMap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,6 @@ import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
|
||||
import com.orange.demo.common.core.annotation.RelationManyToMany;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.upms.model.constant.SysPermCodeType;
|
||||
import com.orange.demo.upms.vo.SysPermCodeVo;
|
||||
import lombok.Data;
|
||||
import org.mapstruct.Mapper;
|
||||
@@ -14,9 +11,7 @@ import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 权限字实体对象。
|
||||
@@ -31,7 +26,6 @@ public class SysPermCode {
|
||||
/**
|
||||
* 权限字Id。
|
||||
*/
|
||||
@NotNull(message = "权限字Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@Column(name = "perm_code_id")
|
||||
private Long permCodeId;
|
||||
@@ -45,38 +39,51 @@ public class SysPermCode {
|
||||
/**
|
||||
* 权限字标识(一般为有含义的英文字符串)。
|
||||
*/
|
||||
@NotBlank(message = "权限字编码不能为空!")
|
||||
@Column(name = "perm_code")
|
||||
private String permCode;
|
||||
|
||||
/**
|
||||
* 权限类型(0: 表单 1: UI片段 2: 操作)。
|
||||
*/
|
||||
@NotNull(message = "权限字类型不能为空!")
|
||||
@ConstDictRef(constDictClass = SysPermCodeType.class, message = "数据验证失败,权限类型为无效值!")
|
||||
@Column(name = "perm_code_type")
|
||||
private Integer permCodeType;
|
||||
|
||||
/**
|
||||
* 显示名称。
|
||||
*/
|
||||
@NotBlank(message = "权限字显示名称不能为空!")
|
||||
@Column(name = "show_name")
|
||||
private String showName;
|
||||
|
||||
/**
|
||||
* 显示顺序(数值越小,越靠前)。
|
||||
*/
|
||||
@NotNull(message = "权限字显示顺序不能为空!")
|
||||
@Column(name = "show_order")
|
||||
private Integer showOrder;
|
||||
|
||||
/**
|
||||
* 创建者Id。
|
||||
*/
|
||||
@Column(name = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新者Id。
|
||||
*/
|
||||
@Column(name = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(name = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
|
||||
*/
|
||||
@@ -114,4 +121,4 @@ public class SysPermCode {
|
||||
SysPermCodeVo fromModel(SysPermCode sysPermCode);
|
||||
}
|
||||
public static final SysPermCodeModelMapper INSTANCE = Mappers.getMapper(SysPermCode.SysPermCodeModelMapper.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +27,4 @@ public class SysPermCodePerm {
|
||||
@Id
|
||||
@Column(name = "perm_id")
|
||||
private Long permId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,10 @@ package com.orange.demo.upms.model;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.upms.model.constant.SysPermModuleType;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 权限模块实体对象。
|
||||
@@ -25,7 +20,6 @@ public class SysPermModule {
|
||||
/**
|
||||
* 权限模块Id。
|
||||
*/
|
||||
@NotNull(message = "权限模块Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@Column(name = "module_id")
|
||||
private Long moduleId;
|
||||
@@ -39,31 +33,45 @@ public class SysPermModule {
|
||||
/**
|
||||
* 权限模块名称。
|
||||
*/
|
||||
@NotBlank(message = "权限模块名称不能为空!")
|
||||
@Column(name = "module_name")
|
||||
private String moduleName;
|
||||
|
||||
/**
|
||||
* 权限模块类型(0: 普通模块 1: Controller模块)。
|
||||
*/
|
||||
@NotNull(message = "模块类型不能为空!")
|
||||
@ConstDictRef(constDictClass = SysPermModuleType.class, message = "数据验证失败,权限模块类型为无效值!")
|
||||
@Column(name = "module_type")
|
||||
private Integer moduleType;
|
||||
|
||||
/**
|
||||
* 权限模块在当前层级下的顺序,由小到大。
|
||||
*/
|
||||
@NotNull(message = "权限模块显示顺序不能为空!")
|
||||
@Column(name = "show_order")
|
||||
private Integer showOrder;
|
||||
|
||||
/**
|
||||
* 创建者Id。
|
||||
*/
|
||||
@Column(name = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新者Id。
|
||||
*/
|
||||
@Column(name = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
@Column(name = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
|
||||
*/
|
||||
@@ -74,4 +82,4 @@ public class SysPermModule {
|
||||
|
||||
@Transient
|
||||
private List<SysPerm> sysPermList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,4 +32,4 @@ public class SysPermWhitelist {
|
||||
*/
|
||||
@Column(name = "perm_name")
|
||||
private String permName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
|
||||
import com.orange.demo.common.core.annotation.RelationManyToMany;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.upms.vo.SysRoleVo;
|
||||
import lombok.Data;
|
||||
import org.mapstruct.Mapper;
|
||||
@@ -12,9 +11,7 @@ import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 角色实体对象。
|
||||
@@ -29,7 +26,6 @@ public class SysRole {
|
||||
/**
|
||||
* 角色Id。
|
||||
*/
|
||||
@NotNull(message = "角色Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@Column(name = "role_id")
|
||||
private Long roleId;
|
||||
@@ -37,7 +33,6 @@ public class SysRole {
|
||||
/**
|
||||
* 角色名称。
|
||||
*/
|
||||
@NotBlank(message = "角色名称不能为空!")
|
||||
@Column(name = "role_name")
|
||||
private String roleName;
|
||||
|
||||
@@ -47,18 +42,18 @@ public class SysRole {
|
||||
@Column(name = "create_user_id")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建者显示名称。
|
||||
*/
|
||||
@Column(name = "create_username")
|
||||
private String createUsername;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
*/
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新者Id。
|
||||
*/
|
||||
@Column(name = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* 更新时间。
|
||||
*/
|
||||
|
||||
@@ -7,15 +7,11 @@ import com.orange.demo.common.core.annotation.RelationConstDict;
|
||||
import com.orange.demo.common.core.annotation.RelationManyToMany;
|
||||
import com.orange.demo.common.core.base.mapper.BaseModelMapper;
|
||||
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
|
||||
import com.orange.demo.common.core.validator.AddGroup;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.orange.demo.common.core.validator.ConstDictRef;
|
||||
import com.orange.demo.upms.vo.SysUserVo;
|
||||
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;
|
||||
@@ -34,7 +30,6 @@ public class SysUser {
|
||||
/**
|
||||
* 用户Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,用户Id不能为空!", groups = {UpdateGroup.class})
|
||||
@Id
|
||||
@Column(name = "user_id")
|
||||
private Long userId;
|
||||
@@ -42,28 +37,23 @@ public class SysUser {
|
||||
/**
|
||||
* 登录用户名。
|
||||
*/
|
||||
@NotBlank(message = "数据验证失败,登录用户名不能为空!")
|
||||
@Column(name = "login_name")
|
||||
private String loginName;
|
||||
|
||||
/**
|
||||
* 用户密码。
|
||||
*/
|
||||
@NotBlank(message = "数据验证失败,用户密码不能为空!", groups = {AddGroup.class})
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 用户显示名称。
|
||||
*/
|
||||
@NotBlank(message = "数据验证失败,用户显示名称不能为空!")
|
||||
@Column(name = "show_name")
|
||||
private String showName;
|
||||
|
||||
/**
|
||||
* 用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)不能为空!")
|
||||
@ConstDictRef(constDictClass = SysUserType.class, message = "数据验证失败,用户类型(0: 管理员 1: 系统管理用户 2: 系统业务用户)为无效值!")
|
||||
@Column(name = "user_type")
|
||||
private Integer userType;
|
||||
|
||||
@@ -76,8 +66,6 @@ public class SysUser {
|
||||
/**
|
||||
* 用户状态(0: 正常 1: 锁定)。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,用户状态(0: 正常 1: 锁定)不能为空!")
|
||||
@ConstDictRef(constDictClass = SysUserStatus.class, message = "数据验证失败,用户状态(0: 正常 1: 锁定)为无效值!")
|
||||
@Column(name = "user_status")
|
||||
private Integer userStatus;
|
||||
|
||||
@@ -96,10 +84,10 @@ public class SysUser {
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建用户名。
|
||||
* 更新者Id。
|
||||
*/
|
||||
@Column(name = "create_username")
|
||||
private String createUsername;
|
||||
@Column(name = "update_user_id")
|
||||
private Long updateUserId;
|
||||
|
||||
/**
|
||||
* 创建时间。
|
||||
|
||||
@@ -1,56 +1,18 @@
|
||||
package com.orange.demo.upms.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.upms.dao.SysMenuMapper;
|
||||
import com.orange.demo.upms.dao.SysMenuPermCodeMapper;
|
||||
import com.orange.demo.upms.dao.SysRoleMenuMapper;
|
||||
import com.orange.demo.upms.model.SysMenu;
|
||||
import com.orange.demo.upms.model.SysMenuPermCode;
|
||||
import com.orange.demo.upms.model.SysRoleMenu;
|
||||
import com.orange.demo.upms.model.constant.SysMenuType;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
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.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 菜单数据服务类。
|
||||
* 菜单数据服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service
|
||||
public class SysMenuService extends BaseService<SysMenu, Long> {
|
||||
|
||||
@Autowired
|
||||
private SysMenuMapper sysMenuMapper;
|
||||
@Autowired
|
||||
private SysRoleMenuMapper sysRoleMenuMapper;
|
||||
@Autowired
|
||||
private SysMenuPermCodeMapper sysMenuPermCodeMapper;
|
||||
@Autowired
|
||||
private SysPermCodeService sysPermCodeService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回主对象的Mapper对象。
|
||||
*
|
||||
* @return 主对象的Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<SysMenu> mapper() {
|
||||
return sysMenuMapper;
|
||||
}
|
||||
public interface SysMenuService extends IBaseService<SysMenu, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增的菜单对象。
|
||||
@@ -59,24 +21,7 @@ public class SysMenuService extends BaseService<SysMenu, Long> {
|
||||
* @param permCodeIdSet 权限字Id列表。
|
||||
* @return 新增后的菜单对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SysMenu saveNew(SysMenu sysMenu, Set<Long> permCodeIdSet) {
|
||||
sysMenu.setMenuId(idGenerator.nextLongId());
|
||||
sysMenu.setCreateTime(new Date());
|
||||
sysMenu.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
sysMenuMapper.insert(sysMenu);
|
||||
if (permCodeIdSet != null) {
|
||||
List<SysMenuPermCode> sysMenuPermCodeList = new LinkedList<>();
|
||||
for (Long permCodeId : permCodeIdSet) {
|
||||
SysMenuPermCode menuPermCode = new SysMenuPermCode();
|
||||
menuPermCode.setMenuId(sysMenu.getMenuId());
|
||||
menuPermCode.setPermCodeId(permCodeId);
|
||||
sysMenuPermCodeList.add(menuPermCode);
|
||||
}
|
||||
sysMenuPermCodeMapper.insertList(sysMenuPermCodeList);
|
||||
}
|
||||
return sysMenu;
|
||||
}
|
||||
SysMenu saveNew(SysMenu sysMenu, Set<Long> permCodeIdSet);
|
||||
|
||||
/**
|
||||
* 更新菜单对象。
|
||||
@@ -86,29 +31,7 @@ public class SysMenuService extends BaseService<SysMenu, Long> {
|
||||
* @param permCodeIdSet 权限字Id列表。
|
||||
* @return 更新成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean update(SysMenu sysMenu, SysMenu originalSysMenu, Set<Long> permCodeIdSet) {
|
||||
sysMenu.setCreateTime(originalSysMenu.getCreateTime());
|
||||
sysMenu.setMenuType(originalSysMenu.getMenuType());
|
||||
sysMenu.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
if (sysMenuMapper.updateByPrimaryKey(sysMenu) != 1) {
|
||||
return false;
|
||||
}
|
||||
SysMenuPermCode deletedMenuPermCode = new SysMenuPermCode();
|
||||
deletedMenuPermCode.setMenuId(sysMenu.getMenuId());
|
||||
sysMenuPermCodeMapper.delete(deletedMenuPermCode);
|
||||
if (permCodeIdSet != null) {
|
||||
List<SysMenuPermCode> sysMenuPermCodeList = new LinkedList<>();
|
||||
for (Long permCodeId : permCodeIdSet) {
|
||||
SysMenuPermCode menuPermCode = new SysMenuPermCode();
|
||||
menuPermCode.setMenuId(sysMenu.getMenuId());
|
||||
menuPermCode.setPermCodeId(permCodeId);
|
||||
sysMenuPermCodeList.add(menuPermCode);
|
||||
}
|
||||
sysMenuPermCodeMapper.insertList(sysMenuPermCodeList);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
boolean update(SysMenu sysMenu, SysMenu originalSysMenu, Set<Long> permCodeIdSet);
|
||||
|
||||
/**
|
||||
* 删除指定的菜单。
|
||||
@@ -116,36 +39,14 @@ public class SysMenuService extends BaseService<SysMenu, Long> {
|
||||
* @param menuId 菜单主键Id。
|
||||
* @return 删除成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean remove(Long menuId) {
|
||||
SysMenu menu = new SysMenu();
|
||||
menu.setMenuId(menuId);
|
||||
menu.setDeletedFlag(GlobalDeletedFlag.DELETED);
|
||||
if (sysMenuMapper.updateByPrimaryKeySelective(menu) != 1) {
|
||||
return false;
|
||||
}
|
||||
SysRoleMenu roleMenu = new SysRoleMenu();
|
||||
roleMenu.setMenuId(menuId);
|
||||
sysRoleMenuMapper.delete(roleMenu);
|
||||
SysMenuPermCode menuPermCode = new SysMenuPermCode();
|
||||
menuPermCode.setMenuId(menuId);
|
||||
sysMenuPermCodeMapper.delete(menuPermCode);
|
||||
return true;
|
||||
}
|
||||
boolean remove(Long menuId);
|
||||
|
||||
/**
|
||||
* 获取全部菜单列表。
|
||||
*
|
||||
* @return 全部菜单列表。
|
||||
*/
|
||||
public List<SysMenu> getAllMenuList() {
|
||||
Example e = new Example(SysMenu.class);
|
||||
e.orderBy("showOrder");
|
||||
Example.Criteria c = e.createCriteria();
|
||||
c.andIn("menuType", Arrays.asList(SysMenuType.TYPE_MENU, SysMenuType.TYPE_DIRECTORY));
|
||||
c.andEqualTo("deletedFlag", GlobalDeletedFlag.NORMAL);
|
||||
return sysMenuMapper.selectByExample(e);
|
||||
}
|
||||
List<SysMenu> getAllMenuList();
|
||||
|
||||
/**
|
||||
* 获取指定用户Id的菜单列表。
|
||||
@@ -153,9 +54,7 @@ public class SysMenuService extends BaseService<SysMenu, Long> {
|
||||
* @param userId 用户主键Id。
|
||||
* @return 用户关联的菜单列表。
|
||||
*/
|
||||
public List<SysMenu> getMenuListByUserId(Long userId) {
|
||||
return sysMenuMapper.getMenuListByUserId(userId);
|
||||
}
|
||||
List<SysMenu> getMenuListByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 判断当前菜单是否存在子菜单。
|
||||
@@ -163,11 +62,7 @@ public class SysMenuService extends BaseService<SysMenu, Long> {
|
||||
* @param menuId 菜单主键Id。
|
||||
* @return 存在返回true,否则false。
|
||||
*/
|
||||
public boolean hasChildren(Long menuId) {
|
||||
SysMenu menu = new SysMenu();
|
||||
menu.setParentId(menuId);
|
||||
return this.getCountByFilter(menu) > 0;
|
||||
}
|
||||
boolean hasChildren(Long menuId);
|
||||
|
||||
/**
|
||||
* 验证菜单对象关联的数据是否都合法。
|
||||
@@ -177,31 +72,7 @@ public class SysMenuService extends BaseService<SysMenu, Long> {
|
||||
* @param permCodeIdListString 逗号分隔的权限Id列表。
|
||||
* @return 验证结果。
|
||||
*/
|
||||
public CallResult verifyRelatedData(SysMenu sysMenu, SysMenu originalSysMenu, String permCodeIdListString) {
|
||||
// menu、ui fragment和button类型的menu不能没有parentId
|
||||
if (sysMenu.getParentId() == null) {
|
||||
if (sysMenu.getMenuType() != SysMenuType.TYPE_DIRECTORY) {
|
||||
return CallResult.error("数据验证失败,当前类型菜单项的上级菜单不能为空!");
|
||||
}
|
||||
}
|
||||
if (this.needToVerify(sysMenu, originalSysMenu, SysMenu::getParentId)) {
|
||||
String errorMessage = checkErrorOfNonDirectoryMenu(sysMenu);
|
||||
if (errorMessage != null) {
|
||||
return CallResult.error(errorMessage);
|
||||
}
|
||||
}
|
||||
JSONObject jsonObject = null;
|
||||
if (StringUtils.isNotBlank(permCodeIdListString)) {
|
||||
Set<Long> permCodeIdSet = Arrays.stream(
|
||||
permCodeIdListString.split(",")).map(Long::valueOf).collect(Collectors.toSet());
|
||||
if (!sysPermCodeService.existAllPrimaryKeys(permCodeIdSet)) {
|
||||
return CallResult.error("数据验证失败,存在不合法的权限字,请刷新后重试!");
|
||||
}
|
||||
jsonObject = new JSONObject();
|
||||
jsonObject.put("permCodeIdSet", permCodeIdSet);
|
||||
}
|
||||
return CallResult.ok(jsonObject);
|
||||
}
|
||||
CallResult verifyRelatedData(SysMenu sysMenu, SysMenu originalSysMenu, String permCodeIdListString);
|
||||
|
||||
/**
|
||||
* 查询菜单的权限资源地址列表。同时返回详细的分配路径。
|
||||
@@ -210,9 +81,7 @@ public class SysMenuService extends BaseService<SysMenu, Long> {
|
||||
* @param url 权限资源地址过滤条件。
|
||||
* @return 包含从菜单到权限资源的权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
public List<Map<String, Object>> getSysPermListWithDetail(Long menuId, String url) {
|
||||
return sysMenuMapper.getSysPermListWithDetail(menuId, url);
|
||||
}
|
||||
List<Map<String, Object>> getSysPermListWithDetail(Long menuId, String url);
|
||||
|
||||
/**
|
||||
* 查询菜单的用户列表。同时返回详细的分配路径。
|
||||
@@ -221,35 +90,5 @@ public class SysMenuService extends BaseService<SysMenu, Long> {
|
||||
* @param loginName 登录名。
|
||||
* @return 包含从菜单到用户的完整权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
public List<Map<String, Object>> getSysUserListWithDetail(Long menuId, String loginName) {
|
||||
return sysMenuMapper.getSysUserListWithDetail(menuId, loginName);
|
||||
}
|
||||
|
||||
private String checkErrorOfNonDirectoryMenu(SysMenu sysMenu) {
|
||||
// 判断父节点是否存在
|
||||
SysMenu parentSysMenu = getById(sysMenu.getParentId());
|
||||
if (parentSysMenu == null) {
|
||||
return "数据验证失败,关联的上级菜单并不存在,请刷新后重试!";
|
||||
}
|
||||
// 逐个判断每种类型的菜单,他的父菜单的合法性,先从目录类型和菜单类型开始
|
||||
if (sysMenu.getMenuType() == SysMenuType.TYPE_DIRECTORY
|
||||
|| sysMenu.getMenuType() == SysMenuType.TYPE_MENU) {
|
||||
// 他们的上级只能是目录
|
||||
if (parentSysMenu.getMenuType() != SysMenuType.TYPE_DIRECTORY) {
|
||||
return "数据验证失败,当前类型菜单项的上级菜单只能是目录类型!";
|
||||
}
|
||||
} else if (sysMenu.getMenuType() == SysMenuType.TYPE_UI_FRAGMENT) {
|
||||
// ui fragment的上级只能是menu类型
|
||||
if (parentSysMenu.getMenuType() != SysMenuType.TYPE_MENU) {
|
||||
return "数据验证失败,当前类型菜单项的上级菜单只能是菜单类型和按钮类型!";
|
||||
}
|
||||
} else if (sysMenu.getMenuType() == SysMenuType.TYPE_BUTTON) {
|
||||
// button的上级只能是menu和ui fragment
|
||||
if (parentSysMenu.getMenuType() != SysMenuType.TYPE_MENU
|
||||
&& parentSysMenu.getMenuType() != SysMenuType.TYPE_UI_FRAGMENT) {
|
||||
return "数据验证失败,当前类型菜单项的上级菜单只能是菜单类型和UI片段类型!";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
List<Map<String, Object>> getSysUserListWithDetail(Long menuId, String loginName);
|
||||
}
|
||||
|
||||
@@ -1,54 +1,18 @@
|
||||
package com.orange.demo.upms.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.upms.dao.SysMenuPermCodeMapper;
|
||||
import com.orange.demo.upms.dao.SysPermCodeMapper;
|
||||
import com.orange.demo.upms.dao.SysPermCodePermMapper;
|
||||
import com.orange.demo.upms.model.SysMenuPermCode;
|
||||
import com.orange.demo.upms.model.SysPermCode;
|
||||
import com.orange.demo.upms.model.SysPermCodePerm;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 权限字数据服务类。
|
||||
* 权限字数据服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service
|
||||
public class SysPermCodeService extends BaseService<SysPermCode, Long> {
|
||||
|
||||
@Autowired
|
||||
private SysPermCodeMapper sysPermCodeMapper;
|
||||
@Autowired
|
||||
private SysPermCodePermMapper sysPermCodePermMapper;
|
||||
@Autowired
|
||||
private SysMenuPermCodeMapper sysMenuPermCodeMapper;
|
||||
@Autowired
|
||||
private SysPermService sysPermService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回主对象的Mapper对象。
|
||||
*
|
||||
* @return 主对象的Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<SysPermCode> mapper() {
|
||||
return sysPermCodeMapper;
|
||||
}
|
||||
public interface SysPermCodeService extends IBaseService<SysPermCode, Long> {
|
||||
|
||||
/**
|
||||
* 获取指定用户的权限字列表。
|
||||
@@ -56,9 +20,7 @@ public class SysPermCodeService extends BaseService<SysPermCode, Long> {
|
||||
* @param userId 用户主键Id。
|
||||
* @return 用户关联的权限字列表。
|
||||
*/
|
||||
public List<String> getPermCodeListByUserId(Long userId) {
|
||||
return sysPermCodeMapper.getPermCodeListByUserId(userId);
|
||||
}
|
||||
List<String> getPermCodeListByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 保存新增的权限字对象。
|
||||
@@ -67,24 +29,7 @@ public class SysPermCodeService extends BaseService<SysPermCode, Long> {
|
||||
* @param permIdSet 权限资源Id列表。
|
||||
* @return 新增后的权限字对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SysPermCode saveNew(SysPermCode sysPermCode, Set<Long> permIdSet) {
|
||||
sysPermCode.setPermCodeId(idGenerator.nextLongId());
|
||||
sysPermCode.setCreateTime(new Date());
|
||||
sysPermCode.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
sysPermCodeMapper.insert(sysPermCode);
|
||||
if (permIdSet != null) {
|
||||
List<SysPermCodePerm> sysPermCodePermList = new LinkedList<>();
|
||||
for (Long permId : permIdSet) {
|
||||
SysPermCodePerm permCodePerm = new SysPermCodePerm();
|
||||
permCodePerm.setPermCodeId(sysPermCode.getPermCodeId());
|
||||
permCodePerm.setPermId(permId);
|
||||
sysPermCodePermList.add(permCodePerm);
|
||||
}
|
||||
sysPermCodePermMapper.insertList(sysPermCodePermList);
|
||||
}
|
||||
return sysPermCode;
|
||||
}
|
||||
SysPermCode saveNew(SysPermCode sysPermCode, Set<Long> permIdSet);
|
||||
|
||||
/**
|
||||
* 更新权限字对象。
|
||||
@@ -94,29 +39,7 @@ public class SysPermCodeService extends BaseService<SysPermCode, Long> {
|
||||
* @param permIdSet 权限资源Id列表。
|
||||
* @return 更新成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean update(SysPermCode sysPermCode, SysPermCode originalSysPermCode, Set<Long> permIdSet) {
|
||||
sysPermCode.setCreateTime(originalSysPermCode.getCreateTime());
|
||||
sysPermCode.setParentId(originalSysPermCode.getParentId());
|
||||
sysPermCode.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
if (sysPermCodeMapper.updateByPrimaryKey(sysPermCode) != 1) {
|
||||
return false;
|
||||
}
|
||||
SysPermCodePerm deletedPermCodePerm = new SysPermCodePerm();
|
||||
deletedPermCodePerm.setPermCodeId(sysPermCode.getPermCodeId());
|
||||
sysPermCodePermMapper.delete(deletedPermCodePerm);
|
||||
if (permIdSet != null) {
|
||||
List<SysPermCodePerm> sysPermCodePermList = new LinkedList<>();
|
||||
for (Long permId : permIdSet) {
|
||||
SysPermCodePerm permCodePerm = new SysPermCodePerm();
|
||||
permCodePerm.setPermCodeId(sysPermCode.getPermCodeId());
|
||||
permCodePerm.setPermId(permId);
|
||||
sysPermCodePermList.add(permCodePerm);
|
||||
}
|
||||
sysPermCodePermMapper.insertList(sysPermCodePermList);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
boolean update(SysPermCode sysPermCode, SysPermCode originalSysPermCode, Set<Long> permIdSet);
|
||||
|
||||
/**
|
||||
* 删除指定的权限字。
|
||||
@@ -124,22 +47,7 @@ public class SysPermCodeService extends BaseService<SysPermCode, Long> {
|
||||
* @param permCodeId 权限字主键Id。
|
||||
* @return 删除成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean remove(Long permCodeId) {
|
||||
SysPermCode permCode = new SysPermCode();
|
||||
permCode.setPermCodeId(permCodeId);
|
||||
permCode.setDeletedFlag(GlobalDeletedFlag.DELETED);
|
||||
if (sysPermCodeMapper.updateByPrimaryKeySelective(permCode) != 1) {
|
||||
return false;
|
||||
}
|
||||
SysMenuPermCode menuPermCode = new SysMenuPermCode();
|
||||
menuPermCode.setPermCodeId(permCodeId);
|
||||
sysMenuPermCodeMapper.delete(menuPermCode);
|
||||
SysPermCodePerm permCodePerm = new SysPermCodePerm();
|
||||
permCodePerm.setPermCodeId(permCodeId);
|
||||
sysPermCodePermMapper.delete(permCodePerm);
|
||||
return true;
|
||||
}
|
||||
boolean remove(Long permCodeId);
|
||||
|
||||
/**
|
||||
* 判断当前权限字是否存在下级权限字对象。
|
||||
@@ -147,11 +55,7 @@ public class SysPermCodeService extends BaseService<SysPermCode, Long> {
|
||||
* @param permCodeId 权限字主键Id。
|
||||
* @return 存在返回true,否则false。
|
||||
*/
|
||||
public boolean hasChildren(Long permCodeId) {
|
||||
SysPermCode permCode = new SysPermCode();
|
||||
permCode.setParentId(permCodeId);
|
||||
return this.getCountByFilter(permCode) > 0;
|
||||
}
|
||||
boolean hasChildren(Long permCodeId);
|
||||
|
||||
/**
|
||||
* 验证权限字对象关联的数据是否都合法。
|
||||
@@ -161,25 +65,7 @@ public class SysPermCodeService extends BaseService<SysPermCode, Long> {
|
||||
* @param permIdListString 逗号分隔的权限资源Id列表。
|
||||
* @return 验证结果。
|
||||
*/
|
||||
public CallResult verifyRelatedData(
|
||||
SysPermCode sysPermCode, SysPermCode originalSysPermCode, String permIdListString) {
|
||||
if (this.needToVerify(sysPermCode, originalSysPermCode, SysPermCode::getParentId)) {
|
||||
if (getById(sysPermCode.getParentId()) == null) {
|
||||
return CallResult.error("数据验证失败,关联的上级权限字并不存在,请刷新后重试!");
|
||||
}
|
||||
}
|
||||
JSONObject jsonObject = null;
|
||||
if (StringUtils.isNotBlank(permIdListString)) {
|
||||
Set<Long> permIdSet = Arrays.stream(
|
||||
permIdListString.split(",")).map(Long::valueOf).collect(Collectors.toSet());
|
||||
if (!sysPermService.existAllPrimaryKeys(permIdSet)) {
|
||||
return CallResult.error("数据验证失败,存在不合法的权限资源,请刷新后重试!");
|
||||
}
|
||||
jsonObject = new JSONObject();
|
||||
jsonObject.put("permIdSet", permIdSet);
|
||||
}
|
||||
return CallResult.ok(jsonObject);
|
||||
}
|
||||
CallResult verifyRelatedData(SysPermCode sysPermCode, SysPermCode originalSysPermCode, String permIdListString);
|
||||
|
||||
/**
|
||||
* 查询权限字的用户列表。同时返回详细的分配路径。
|
||||
@@ -188,9 +74,7 @@ public class SysPermCodeService extends BaseService<SysPermCode, Long> {
|
||||
* @param loginName 登录名。
|
||||
* @return 包含从权限字到用户的完整权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
public List<Map<String, Object>> getSysUserListWithDetail(Long permCodeId, String loginName) {
|
||||
return sysPermCodeMapper.getSysUserListWithDetail(permCodeId, loginName);
|
||||
}
|
||||
List<Map<String, Object>> getSysUserListWithDetail(Long permCodeId, String loginName);
|
||||
|
||||
/**
|
||||
* 查询权限字的角色列表。同时返回详细的分配路径。
|
||||
@@ -199,7 +83,5 @@ public class SysPermCodeService extends BaseService<SysPermCode, Long> {
|
||||
* @param roleName 角色名。
|
||||
* @return 包含从权限字到角色的权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
public List<Map<String, Object>> getSysRoleListWithDetail(Long permCodeId, String roleName) {
|
||||
return sysPermCodeMapper.getSysRoleListWithDetail(permCodeId, roleName);
|
||||
}
|
||||
List<Map<String, Object>> getSysRoleListWithDetail(Long permCodeId, String roleName);
|
||||
}
|
||||
|
||||
@@ -1,44 +1,17 @@
|
||||
package com.orange.demo.upms.service;
|
||||
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
|
||||
import com.orange.demo.upms.dao.SysPermModuleMapper;
|
||||
import com.orange.demo.upms.model.SysPerm;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
import com.orange.demo.upms.model.SysPermModule;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 权限资源模块数据服务类。
|
||||
* 权限资源模块数据服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service
|
||||
public class SysPermModuleService extends BaseService<SysPermModule, Long> {
|
||||
|
||||
@Autowired
|
||||
private SysPermModuleMapper sysPermModuleMapper;
|
||||
@Autowired
|
||||
private SysPermService sysPermService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回主对象的Mapper对象。
|
||||
*
|
||||
* @return 主对象的Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<SysPermModule> mapper() {
|
||||
return sysPermModuleMapper;
|
||||
}
|
||||
public interface SysPermModuleService extends IBaseService<SysPermModule, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增的权限资源模块对象。
|
||||
@@ -46,14 +19,7 @@ public class SysPermModuleService extends BaseService<SysPermModule, Long> {
|
||||
* @param sysPermModule 新增的权限资源模块对象。
|
||||
* @return 新增后的权限资源模块对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SysPermModule saveNew(SysPermModule sysPermModule) {
|
||||
sysPermModule.setModuleId(idGenerator.nextLongId());
|
||||
sysPermModule.setCreateTime(new Date());
|
||||
sysPermModule.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
sysPermModuleMapper.insert(sysPermModule);
|
||||
return sysPermModule;
|
||||
}
|
||||
SysPermModule saveNew(SysPermModule sysPermModule);
|
||||
|
||||
/**
|
||||
* 更新权限资源模块对象。
|
||||
@@ -62,12 +28,7 @@ public class SysPermModuleService extends BaseService<SysPermModule, Long> {
|
||||
* @param originalSysPermModule 原有的权限资源模块对象。
|
||||
* @return 更新成功返回true,否则false
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean update(SysPermModule sysPermModule, SysPermModule originalSysPermModule) {
|
||||
sysPermModule.setCreateTime(originalSysPermModule.getCreateTime());
|
||||
sysPermModule.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
return sysPermModuleMapper.updateByPrimaryKey(sysPermModule) != 0;
|
||||
}
|
||||
boolean update(SysPermModule sysPermModule, SysPermModule originalSysPermModule);
|
||||
|
||||
/**
|
||||
* 删除指定的权限资源模块。
|
||||
@@ -75,22 +36,14 @@ public class SysPermModuleService extends BaseService<SysPermModule, Long> {
|
||||
* @param moduleId 权限资源模块主键Id。
|
||||
* @return 删除成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean remove(Long moduleId) {
|
||||
SysPermModule permModule = new SysPermModule();
|
||||
permModule.setModuleId(moduleId);
|
||||
permModule.setDeletedFlag(GlobalDeletedFlag.DELETED);
|
||||
return sysPermModuleMapper.updateByPrimaryKeySelective(permModule) != 0;
|
||||
}
|
||||
boolean remove(Long moduleId);
|
||||
|
||||
/**
|
||||
* 获取权限模块资源及其关联的权限资源列表。
|
||||
*
|
||||
* @return 权限资源模块及其关联的权限资源列表。
|
||||
*/
|
||||
public List<SysPermModule> getPermModuleAndPermList() {
|
||||
return sysPermModuleMapper.getPermModuleAndPermList();
|
||||
}
|
||||
List<SysPermModule> getPermModuleAndPermList();
|
||||
|
||||
/**
|
||||
* 判断是否存在下级权限资源模块。
|
||||
@@ -98,11 +51,7 @@ public class SysPermModuleService extends BaseService<SysPermModule, Long> {
|
||||
* @param moduleId 权限资源模块主键Id。
|
||||
* @return 存在返回true,否则false。
|
||||
*/
|
||||
public boolean hasChildren(Long moduleId) {
|
||||
SysPermModule permModule = new SysPermModule();
|
||||
permModule.setParentId(moduleId);
|
||||
return this.getCountByFilter(permModule) > 0;
|
||||
}
|
||||
boolean hasChildren(Long moduleId);
|
||||
|
||||
/**
|
||||
* 判断是否存在权限数据。
|
||||
@@ -110,9 +59,5 @@ public class SysPermModuleService extends BaseService<SysPermModule, Long> {
|
||||
* @param moduleId 权限资源模块主键Id。
|
||||
* @return 存在返回true,否则false。
|
||||
*/
|
||||
public boolean hasModulePerms(Long moduleId) {
|
||||
SysPerm filter = new SysPerm();
|
||||
filter.setModuleId(moduleId);
|
||||
return sysPermService.getCountByFilter(filter) > 0;
|
||||
}
|
||||
boolean hasModulePerms(Long moduleId);
|
||||
}
|
||||
|
||||
@@ -1,59 +1,18 @@
|
||||
package com.orange.demo.upms.service;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.upms.dao.SysPermCodePermMapper;
|
||||
import com.orange.demo.upms.dao.SysPermMapper;
|
||||
import com.orange.demo.upms.model.SysPerm;
|
||||
import com.orange.demo.upms.model.SysPermCodePerm;
|
||||
import com.orange.demo.upms.model.SysPermModule;
|
||||
import com.orange.demo.upms.model.SysUser;
|
||||
import com.orange.demo.upms.model.constant.SysUserType;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
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.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 权限资源数据服务类。
|
||||
* 权限资源数据服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service
|
||||
public class SysPermService extends BaseService<SysPerm, Long> {
|
||||
|
||||
@Autowired
|
||||
private SysPermMapper sysPermMapper;
|
||||
@Autowired
|
||||
private SysPermCodePermMapper sysPermCodePermMapper;
|
||||
@Autowired
|
||||
private SysPermModuleService sysPermModuleService;
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回主对象的Mapper对象。
|
||||
*
|
||||
* @return 主对象的Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<SysPerm> mapper() {
|
||||
return sysPermMapper;
|
||||
}
|
||||
public interface SysPermService extends IBaseService<SysPerm, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增的权限资源对象。
|
||||
@@ -61,14 +20,7 @@ public class SysPermService extends BaseService<SysPerm, Long> {
|
||||
* @param perm 新增的权限资源对象。
|
||||
* @return 新增后的权限资源对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SysPerm saveNew(SysPerm perm) {
|
||||
perm.setPermId(idGenerator.nextLongId());
|
||||
perm.setCreateTime(new Date());
|
||||
perm.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
sysPermMapper.insert(perm);
|
||||
return perm;
|
||||
}
|
||||
SysPerm saveNew(SysPerm perm);
|
||||
|
||||
/**
|
||||
* 更新权限资源对象。
|
||||
@@ -77,12 +29,7 @@ public class SysPermService extends BaseService<SysPerm, Long> {
|
||||
* @param originalPerm 原有的权限资源对象。
|
||||
* @return 更新成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean update(SysPerm perm, SysPerm originalPerm) {
|
||||
perm.setCreateTime(originalPerm.getCreateTime());
|
||||
perm.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
return sysPermMapper.updateByPrimaryKeySelective(perm) != 0;
|
||||
}
|
||||
boolean update(SysPerm perm, SysPerm originalPerm);
|
||||
|
||||
/**
|
||||
* 删除权限资源。
|
||||
@@ -90,19 +37,7 @@ public class SysPermService extends BaseService<SysPerm, Long> {
|
||||
* @param permId 权限资源主键Id。
|
||||
* @return 删除成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean remove(Long permId) {
|
||||
SysPerm perm = new SysPerm();
|
||||
perm.setPermId(permId);
|
||||
perm.setDeletedFlag(GlobalDeletedFlag.DELETED);
|
||||
if (sysPermMapper.updateByPrimaryKeySelective(perm) != 1) {
|
||||
return false;
|
||||
}
|
||||
SysPermCodePerm permCodePerm = new SysPermCodePerm();
|
||||
permCodePerm.setPermId(permId);
|
||||
sysPermCodePermMapper.delete(permCodePerm);
|
||||
return true;
|
||||
}
|
||||
boolean remove(Long permId);
|
||||
|
||||
/**
|
||||
* 获取权限数据列表。
|
||||
@@ -110,22 +45,7 @@ public class SysPermService extends BaseService<SysPerm, Long> {
|
||||
* @param sysPermFilter 过滤对象。
|
||||
* @return 权限列表。
|
||||
*/
|
||||
public List<SysPerm> getPermListWithRelation(SysPerm sysPermFilter) {
|
||||
Example e = new Example(SysPerm.class);
|
||||
e.orderBy("showOrder");
|
||||
Example.Criteria c = e.createCriteria();
|
||||
if (ObjectUtil.isNotNull(sysPermFilter.getModuleId())) {
|
||||
c.andEqualTo("moduleId", sysPermFilter.getModuleId());
|
||||
}
|
||||
if (ObjectUtil.isNotNull(sysPermFilter.getUrl())) {
|
||||
c.andLike("url", "%" + sysPermFilter.getUrl() + "%");
|
||||
}
|
||||
c.andEqualTo("deletedFlag", GlobalDeletedFlag.NORMAL);
|
||||
List<SysPerm> permList = sysPermMapper.selectByExample(e);
|
||||
// 这里因为权限只有字典数据,所以仅仅做字典关联。
|
||||
this.buildRelationForDataList(permList, MyRelationParam.dictOnly(), null);
|
||||
return permList;
|
||||
}
|
||||
List<SysPerm> getPermListWithRelation(SysPerm sysPermFilter);
|
||||
|
||||
/**
|
||||
* 获取指定用户的权限资源集合,并存储于缓存,从而提升后续读取效率。
|
||||
@@ -134,17 +54,7 @@ public class SysPermService extends BaseService<SysPerm, Long> {
|
||||
* @param userId 用户主键Id。
|
||||
* @return 当前用户权限集合。
|
||||
*/
|
||||
@Cacheable(value = "USER_PERMISSION_CACHE", key = "#sessionId", unless = "#result == null")
|
||||
public Set<String> getCacheableSysPermSetByUserId(String sessionId, Long userId) {
|
||||
// 这里可以防止非法的userId直接访问权限受限的url
|
||||
SysUser user = sysUserService.getById(userId);
|
||||
if (user == null) {
|
||||
return new HashSet<>(1);
|
||||
}
|
||||
// 管理员账户返回空对象,便于缓存的统一处理。
|
||||
return user.getUserType() == SysUserType.TYPE_ADMIN
|
||||
? new HashSet<>(1) : this.getSysPermSetByUserId(userId);
|
||||
}
|
||||
Set<String> getCacheableSysPermSetByUserId(String sessionId, Long userId);
|
||||
|
||||
/**
|
||||
* 将指定用户的指定会话的权限集合存入缓存。
|
||||
@@ -154,21 +64,14 @@ public class SysPermService extends BaseService<SysPerm, Long> {
|
||||
* @param isAdmin 是否是管理员。
|
||||
* @return 查询并缓存后的权限集合。
|
||||
*/
|
||||
@CachePut(value = "USER_PERMISSION_CACHE", key = "#sessionId")
|
||||
public Set<String> putUserSysPermCache(String sessionId, Long userId, boolean isAdmin) {
|
||||
// 管理员账户返回空对象,便于缓存的统一处理。
|
||||
return isAdmin ? new HashSet<>(1) : this.getSysPermSetByUserId(userId);
|
||||
}
|
||||
Set<String> putUserSysPermCache(String sessionId, Long userId, boolean isAdmin);
|
||||
|
||||
/**
|
||||
* 将指定会话的权限集合从缓存中移除。
|
||||
*
|
||||
* @param sessionId 会话Id。
|
||||
*/
|
||||
@CacheEvict(value = "USER_PERMISSION_CACHE", key = "#sessionId")
|
||||
public void removeUserSysPermCache(String sessionId) {
|
||||
// 空实现即可,只是通过注解将当前sessionId从cache中删除。
|
||||
}
|
||||
void removeUserSysPermCache(String sessionId);
|
||||
|
||||
/**
|
||||
* 获取指定用户的权限集合,这里之所以为公有方法,因为spring cache的技术要求,私有方法数据不能缓存。
|
||||
@@ -176,10 +79,7 @@ public class SysPermService extends BaseService<SysPerm, Long> {
|
||||
* @param userId 用户主键Id。
|
||||
* @return 用户权限集合。
|
||||
*/
|
||||
public Set<String> getSysPermSetByUserId(Long userId) {
|
||||
List<SysPerm> permList = this.getPermListByUserId(userId);
|
||||
return permList.stream().map(SysPerm::getUrl).collect(Collectors.toSet());
|
||||
}
|
||||
Set<String> getSysPermSetByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 获取与指定用户关联的权限资源列表。
|
||||
@@ -187,9 +87,7 @@ public class SysPermService extends BaseService<SysPerm, Long> {
|
||||
* @param userId 关联的用户主键Id。
|
||||
* @return 与指定用户Id关联的权限资源列表。
|
||||
*/
|
||||
public List<SysPerm> getPermListByUserId(Long userId) {
|
||||
return sysPermMapper.getPermListByUserId(userId);
|
||||
}
|
||||
List<SysPerm> getPermListByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 验证权限资源对象关联的数据是否都合法。
|
||||
@@ -198,15 +96,7 @@ public class SysPermService extends BaseService<SysPerm, Long> {
|
||||
* @param originalSysPerm 原有对象。
|
||||
* @return 验证结果。
|
||||
*/
|
||||
public CallResult verifyRelatedData(SysPerm sysPerm, SysPerm originalSysPerm) {
|
||||
if (this.needToVerify(sysPerm, originalSysPerm, SysPerm::getModuleId)) {
|
||||
SysPermModule permModule = sysPermModuleService.getById(sysPerm.getModuleId());
|
||||
if (permModule == null) {
|
||||
return CallResult.error("数据验证失败,关联的权限模块Id并不存在,请刷新后重试!");
|
||||
}
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
CallResult verifyRelatedData(SysPerm sysPerm, SysPerm originalSysPerm);
|
||||
|
||||
/**
|
||||
* 查询权限资源地址的用户列表。同时返回详细的分配路径。
|
||||
@@ -215,9 +105,7 @@ public class SysPermService extends BaseService<SysPerm, Long> {
|
||||
* @param loginName 登录名。
|
||||
* @return 包含从权限资源到用户的完整权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
public List<Map<String, Object>> getSysUserListWithDetail(Long permId, String loginName) {
|
||||
return sysPermMapper.getSysUserListWithDetail(permId, loginName);
|
||||
}
|
||||
List<Map<String, Object>> getSysUserListWithDetail(Long permId, String loginName);
|
||||
|
||||
/**
|
||||
* 查询权限资源地址的角色列表。同时返回详细的分配路径。
|
||||
@@ -226,9 +114,7 @@ public class SysPermService extends BaseService<SysPerm, Long> {
|
||||
* @param roleName 角色名。
|
||||
* @return 包含从权限资源到角色的权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
public List<Map<String, Object>> getSysRoleListWithDetail(Long permId, String roleName) {
|
||||
return sysPermMapper.getSysRoleListWithDetail(permId, roleName);
|
||||
}
|
||||
List<Map<String, Object>> getSysRoleListWithDetail(Long permId, String roleName);
|
||||
|
||||
/**
|
||||
* 查询权限资源地址的菜单列表。同时返回详细的分配路径。
|
||||
@@ -237,7 +123,5 @@ public class SysPermService extends BaseService<SysPerm, Long> {
|
||||
* @param menuName 菜单名。
|
||||
* @return 包含从权限资源到菜单的权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
public List<Map<String, Object>> getSysMenuListWithDetail(Long permId, String menuName) {
|
||||
return sysPermMapper.getSysMenuListWithDetail(permId, menuName);
|
||||
}
|
||||
List<Map<String, Object>> getSysMenuListWithDetail(Long permId, String menuName);
|
||||
}
|
||||
|
||||
@@ -1,32 +1,23 @@
|
||||
package com.orange.demo.upms.service;
|
||||
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.upms.dao.SysPermWhitelistMapper;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
import com.orange.demo.upms.model.SysPermWhitelist;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 权限资源白名单数据服务类。
|
||||
* 权限资源白名单数据服务接口。
|
||||
* 白名单中的权限资源,可以不受权限控制,任何用户皆可访问,一般用于常用的字典数据列表接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service
|
||||
public class SysPermWhitelistService extends BaseService<SysPermWhitelist, String> {
|
||||
|
||||
@Autowired
|
||||
private SysPermWhitelistMapper sysPermWhitelistMapper;
|
||||
public interface SysPermWhitelistService extends IBaseService<SysPermWhitelist, String> {
|
||||
|
||||
/**
|
||||
* 返回主对象的Mapper对象。
|
||||
* 获取白名单权限资源的列表。
|
||||
*
|
||||
* @return 主对象的Mapper对象。
|
||||
* @return 白名单权限资源地址列表。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<SysPermWhitelist> mapper() {
|
||||
return sysPermWhitelistMapper;
|
||||
}
|
||||
List<String> getWhitelistPermList();
|
||||
}
|
||||
|
||||
@@ -1,55 +1,19 @@
|
||||
package com.orange.demo.upms.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
|
||||
import com.orange.demo.common.core.object.TokenData;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.upms.dao.SysRoleMapper;
|
||||
import com.orange.demo.upms.dao.SysRoleMenuMapper;
|
||||
import com.orange.demo.upms.dao.SysUserRoleMapper;
|
||||
import com.orange.demo.upms.model.SysRole;
|
||||
import com.orange.demo.upms.model.SysRoleMenu;
|
||||
import com.orange.demo.upms.model.SysUserRole;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 角色数据服务类。
|
||||
* 角色数据服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleService extends BaseService<SysRole, Long> {
|
||||
|
||||
@Autowired
|
||||
private SysRoleMapper sysRoleMapper;
|
||||
@Autowired
|
||||
private SysRoleMenuMapper sysRoleMenuMapper;
|
||||
@Autowired
|
||||
private SysUserRoleMapper sysUserRoleMapper;
|
||||
@Autowired
|
||||
private SysMenuService sysMenuService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回主对象的Mapper对象。
|
||||
*
|
||||
* @return 主对象的Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<SysRole> mapper() {
|
||||
return sysRoleMapper;
|
||||
}
|
||||
public interface SysRoleService extends IBaseService<SysRole, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增的角色对象。
|
||||
@@ -58,29 +22,7 @@ public class SysRoleService extends BaseService<SysRole, Long> {
|
||||
* @param menuIdSet 菜单Id列表。
|
||||
* @return 新增后的角色对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SysRole saveNew(SysRole role, Set<Long> menuIdSet) {
|
||||
role.setRoleId(idGenerator.nextLongId());
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
role.setCreateUserId(tokenData.getUserId());
|
||||
role.setCreateUsername(tokenData.getShowName());
|
||||
Date now = new Date();
|
||||
role.setCreateTime(now);
|
||||
role.setUpdateTime(now);
|
||||
role.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
sysRoleMapper.insert(role);
|
||||
if (menuIdSet != null) {
|
||||
List<SysRoleMenu> roleMenuList = new LinkedList<>();
|
||||
for (Long menuId : menuIdSet) {
|
||||
SysRoleMenu roleMenu = new SysRoleMenu();
|
||||
roleMenu.setRoleId(role.getRoleId());
|
||||
roleMenu.setMenuId(menuId);
|
||||
roleMenuList.add(roleMenu);
|
||||
}
|
||||
sysRoleMenuMapper.insertList(roleMenuList);
|
||||
}
|
||||
return role;
|
||||
}
|
||||
SysRole saveNew(SysRole role, Set<Long> menuIdSet);
|
||||
|
||||
/**
|
||||
* 更新角色对象。
|
||||
@@ -90,30 +32,7 @@ public class SysRoleService extends BaseService<SysRole, Long> {
|
||||
* @param menuIdSet 菜单Id列表。
|
||||
* @return 更新成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean update(SysRole role, SysRole originalRole, Set<Long> menuIdSet) {
|
||||
role.setCreateUserId(originalRole.getCreateUserId());
|
||||
role.setCreateTime(originalRole.getCreateTime());
|
||||
role.setUpdateTime(new Date());
|
||||
role.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
if (sysRoleMapper.updateByPrimaryKey(role) != 1) {
|
||||
return false;
|
||||
}
|
||||
SysRoleMenu deletedRoleMenu = new SysRoleMenu();
|
||||
deletedRoleMenu.setRoleId(role.getRoleId());
|
||||
sysRoleMenuMapper.delete(deletedRoleMenu);
|
||||
if (menuIdSet != null) {
|
||||
List<SysRoleMenu> roleMenuList = new LinkedList<>();
|
||||
for (Long menuId : menuIdSet) {
|
||||
SysRoleMenu roleMenu = new SysRoleMenu();
|
||||
roleMenu.setRoleId(role.getRoleId());
|
||||
roleMenu.setMenuId(menuId);
|
||||
roleMenuList.add(roleMenu);
|
||||
}
|
||||
sysRoleMenuMapper.insertList(roleMenuList);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
boolean update(SysRole role, SysRole originalRole, Set<Long> menuIdSet);
|
||||
|
||||
/**
|
||||
* 删除指定角色。
|
||||
@@ -121,22 +40,7 @@ public class SysRoleService extends BaseService<SysRole, Long> {
|
||||
* @param roleId 角色主键Id。
|
||||
* @return 删除成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean remove(Long roleId) {
|
||||
SysRole role = new SysRole();
|
||||
role.setRoleId(roleId);
|
||||
role.setDeletedFlag(GlobalDeletedFlag.DELETED);
|
||||
if (sysRoleMapper.updateByPrimaryKeySelective(role) != 1) {
|
||||
return false;
|
||||
}
|
||||
SysRoleMenu roleMenu = new SysRoleMenu();
|
||||
roleMenu.setRoleId(roleId);
|
||||
sysRoleMenuMapper.delete(roleMenu);
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole.setRoleId(roleId);
|
||||
sysUserRoleMapper.delete(userRole);
|
||||
return true;
|
||||
}
|
||||
boolean remove(Long roleId);
|
||||
|
||||
/**
|
||||
* 获取角色列表。
|
||||
@@ -145,19 +49,14 @@ public class SysRoleService extends BaseService<SysRole, Long> {
|
||||
* @param orderBy 排序参数。
|
||||
* @return 角色列表。
|
||||
*/
|
||||
public List<SysRole> getSysRoleList(SysRole filter, String orderBy) {
|
||||
return sysRoleMapper.getSysRoleList(filter, orderBy);
|
||||
}
|
||||
List<SysRole> getSysRoleList(SysRole filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 批量新增用户角色关联。
|
||||
*
|
||||
* @param userRoleList 用户角色关系数据列表。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addUserRoleList(List<SysUserRole> userRoleList) {
|
||||
sysUserRoleMapper.insertList(userRoleList);
|
||||
}
|
||||
void addUserRoleList(List<SysUserRole> userRoleList);
|
||||
|
||||
/**
|
||||
* 移除指定用户和指定角色的关联关系。
|
||||
@@ -166,13 +65,7 @@ public class SysRoleService extends BaseService<SysRole, Long> {
|
||||
* @param userId 用户主键Id。
|
||||
* @return 移除成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean removeUserRole(Long roleId, Long userId) {
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole.setRoleId(roleId);
|
||||
userRole.setUserId(userId);
|
||||
return sysUserRoleMapper.delete(userRole) == 1;
|
||||
}
|
||||
boolean removeUserRole(Long roleId, Long userId);
|
||||
|
||||
/**
|
||||
* 验证角色对象关联的数据是否都合法。
|
||||
@@ -182,19 +75,7 @@ public class SysRoleService extends BaseService<SysRole, Long> {
|
||||
* @param menuIdListString 逗号分隔的menuId列表。
|
||||
* @return 验证结果。
|
||||
*/
|
||||
public CallResult verifyRelatedData(SysRole sysRole, SysRole originalSysRole, String menuIdListString) {
|
||||
JSONObject jsonObject = null;
|
||||
if (StringUtils.isNotBlank(menuIdListString)) {
|
||||
Set<Long> menuIdSet = Arrays.stream(
|
||||
menuIdListString.split(",")).map(Long::valueOf).collect(Collectors.toSet());
|
||||
if (!sysMenuService.existAllPrimaryKeys(menuIdSet)) {
|
||||
return CallResult.error("数据验证失败,存在不合法的菜单权限,请刷新后重试!");
|
||||
}
|
||||
jsonObject = new JSONObject();
|
||||
jsonObject.put("menuIdSet", menuIdSet);
|
||||
}
|
||||
return CallResult.ok(jsonObject);
|
||||
}
|
||||
CallResult verifyRelatedData(SysRole sysRole, SysRole originalSysRole, String menuIdListString);
|
||||
|
||||
/**
|
||||
* 查询角色的权限资源地址列表。同时返回详细的分配路径。
|
||||
@@ -203,9 +84,7 @@ public class SysRoleService extends BaseService<SysRole, Long> {
|
||||
* @param url url过滤条件。
|
||||
* @return 包含从角色到权限资源的完整权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
public List<Map<String, Object>> getSysPermListWithDetail(Long roleId, String url) {
|
||||
return sysRoleMapper.getSysPermListWithDetail(roleId, url);
|
||||
}
|
||||
List<Map<String, Object>> getSysPermListWithDetail(Long roleId, String url);
|
||||
|
||||
/**
|
||||
* 查询角色的权限字列表。同时返回详细的分配路径。
|
||||
@@ -214,7 +93,5 @@ public class SysRoleService extends BaseService<SysRole, Long> {
|
||||
* @param permCode 权限字名称过滤条件。
|
||||
* @return 包含从角色到权限字的权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
public List<Map<String, Object>> getSysPermCodeListWithDetail(Long roleId, String permCode) {
|
||||
return sysRoleMapper.getSysPermCodeListWithDetail(roleId, permCode);
|
||||
}
|
||||
List<Map<String, Object>> getSysPermCodeListWithDetail(Long roleId, String permCode);
|
||||
}
|
||||
|
||||
@@ -1,57 +1,18 @@
|
||||
package com.orange.demo.upms.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.orange.demo.upms.dao.*;
|
||||
import com.orange.demo.upms.model.*;
|
||||
import com.orange.demo.upms.model.constant.SysUserStatus;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
|
||||
import com.orange.demo.common.core.object.TokenData;
|
||||
import com.orange.demo.common.core.object.MyWhereCriteria;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
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.IBaseService;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户管理数据操作服务类。
|
||||
* 用户管理数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service
|
||||
public class SysUserService extends BaseService<SysUser, Long> {
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
@Autowired
|
||||
private SysUserRoleMapper sysUserRoleMapper;
|
||||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<SysUser> mapper() {
|
||||
return sysUserMapper;
|
||||
}
|
||||
public interface SysUserService extends IBaseService<SysUser, Long> {
|
||||
|
||||
/**
|
||||
* 获取指定登录名的用户对象。
|
||||
@@ -59,13 +20,7 @@ public class SysUserService extends BaseService<SysUser, Long> {
|
||||
* @param loginName 指定登录用户名。
|
||||
* @return 用户对象。
|
||||
*/
|
||||
public SysUser getSysUserByLoginName(String loginName) {
|
||||
Example e = new Example(SysUser.class);
|
||||
Example.Criteria c = e.createCriteria();
|
||||
c.andEqualTo("loginName", loginName);
|
||||
c.andEqualTo("deletedFlag", GlobalDeletedFlag.NORMAL);
|
||||
return sysUserMapper.selectOneByExample(e);
|
||||
}
|
||||
SysUser getSysUserByLoginName(String loginName);
|
||||
|
||||
/**
|
||||
* 保存新增的用户对象。
|
||||
@@ -74,31 +29,7 @@ public class SysUserService extends BaseService<SysUser, Long> {
|
||||
* @param roleIdSet 用户角色Id集合。
|
||||
* @return 新增后的用户对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public SysUser saveNew(SysUser user, Set<Long> roleIdSet) {
|
||||
user.setUserId(idGenerator.nextLongId());
|
||||
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
||||
user.setUserStatus(SysUserStatus.STATUS_NORMAL);
|
||||
user.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
TokenData tokenData = TokenData.takeFromRequest();
|
||||
user.setCreateUserId(tokenData.getUserId());
|
||||
user.setCreateUsername(tokenData.getShowName());
|
||||
Date now = new Date();
|
||||
user.setCreateTime(now);
|
||||
user.setUpdateTime(now);
|
||||
sysUserMapper.insert(user);
|
||||
if (CollectionUtils.isNotEmpty(roleIdSet)) {
|
||||
List<SysUserRole> userRoleList = new LinkedList<>();
|
||||
for (Long roleId : roleIdSet) {
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole.setUserId(user.getUserId());
|
||||
userRole.setRoleId(roleId);
|
||||
userRoleList.add(userRole);
|
||||
}
|
||||
sysUserRoleMapper.insertList(userRoleList);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
SysUser saveNew(SysUser user, Set<Long> roleIdSet);
|
||||
|
||||
/**
|
||||
* 更新用户对象。
|
||||
@@ -108,33 +39,7 @@ public class SysUserService extends BaseService<SysUser, Long> {
|
||||
* @param roleIdSet 用户角色Id列表。
|
||||
* @return 更新成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean update(SysUser user, SysUser originalUser, Set<Long> roleIdSet) {
|
||||
user.setLoginName(originalUser.getLoginName());
|
||||
user.setPassword(originalUser.getPassword());
|
||||
user.setCreateUserId(originalUser.getCreateUserId());
|
||||
user.setCreateUsername(originalUser.getCreateUsername());
|
||||
user.setCreateTime(originalUser.getCreateTime());
|
||||
user.setUpdateTime(new Date());
|
||||
if (sysUserMapper.updateByPrimaryKeySelective(user) != 1) {
|
||||
return false;
|
||||
}
|
||||
// 先删除原有的User-Role关联关系,再重新插入新的关联关系
|
||||
SysUserRole deletedUserRole = new SysUserRole();
|
||||
deletedUserRole.setUserId(user.getUserId());
|
||||
sysUserRoleMapper.delete(deletedUserRole);
|
||||
if (CollectionUtils.isNotEmpty(roleIdSet)) {
|
||||
List<SysUserRole> userRoleList = new LinkedList<>();
|
||||
for (Long roleId : roleIdSet) {
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole.setUserId(user.getUserId());
|
||||
userRole.setRoleId(roleId);
|
||||
userRoleList.add(userRole);
|
||||
}
|
||||
sysUserRoleMapper.insertList(userRoleList);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
boolean update(SysUser user, SysUser originalUser, Set<Long> roleIdSet);
|
||||
|
||||
/**
|
||||
* 修改用户密码。
|
||||
@@ -142,16 +47,7 @@ public class SysUserService extends BaseService<SysUser, Long> {
|
||||
* @param newPass 新密码。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean changePassword(Long userId, String newPass) {
|
||||
Example e = new Example(SysUser.class);
|
||||
e.createCriteria()
|
||||
.andEqualTo(super.idFieldName, userId)
|
||||
.andEqualTo(super.deletedFlagFieldName, GlobalDeletedFlag.NORMAL);
|
||||
SysUser updatedUser = new SysUser();
|
||||
updatedUser.setPassword(passwordEncoder.encode(newPass));
|
||||
return sysUserMapper.updateByExampleSelective(updatedUser, e) == 1;
|
||||
}
|
||||
boolean changePassword(Long userId, String newPass);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
@@ -159,23 +55,7 @@ public class SysUserService extends BaseService<SysUser, Long> {
|
||||
* @param userId 主键Id。
|
||||
* @return 成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean remove(Long userId) {
|
||||
Example sysUserExample = new Example(SysUser.class);
|
||||
Example.Criteria c = sysUserExample.createCriteria();
|
||||
c.andEqualTo(super.idFieldName, userId);
|
||||
c.andEqualTo(super.deletedFlagFieldName, GlobalDeletedFlag.NORMAL);
|
||||
// 这里先删除主数据
|
||||
SysUser deletedObject = new SysUser();
|
||||
deletedObject.setDeletedFlag(GlobalDeletedFlag.DELETED);
|
||||
if (sysUserMapper.updateByExampleSelective(deletedObject, sysUserExample) == 0) {
|
||||
return false;
|
||||
}
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole.setUserId(userId);
|
||||
sysUserRoleMapper.delete(userRole);
|
||||
return true;
|
||||
}
|
||||
boolean remove(Long userId);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
@@ -185,24 +65,18 @@ public class SysUserService extends BaseService<SysUser, Long> {
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<SysUser> getSysUserList(SysUser filter, String orderBy) {
|
||||
return sysUserMapper.getSysUserList(filter, orderBy);
|
||||
}
|
||||
List<SysUser> getSysUserList(SysUser filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getSysUserList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<SysUser> getSysUserListWithRelation(SysUser filter, String orderBy) {
|
||||
List<SysUser> resultList = sysUserMapper.getSysUserList(filter, orderBy);
|
||||
Map<String, List<MyWhereCriteria>> criteriaMap = buildAggregationAdditionalWhereCriteria();
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), criteriaMap);
|
||||
return resultList;
|
||||
}
|
||||
List<SysUser> getSysUserListWithRelation(SysUser filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取指定角色的用户列表。
|
||||
@@ -212,9 +86,7 @@ public class SysUserService extends BaseService<SysUser, Long> {
|
||||
* @param orderBy 排序参数。
|
||||
* @return 用户列表。
|
||||
*/
|
||||
public List<SysUser> getSysUserListByRoleId(Long roleId, SysUser filter, String orderBy) {
|
||||
return sysUserMapper.getSysUserListByRoleId(roleId, filter, orderBy);
|
||||
}
|
||||
List<SysUser> getSysUserListByRoleId(Long roleId, SysUser filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取不属于指定角色的用户列表。
|
||||
@@ -224,9 +96,7 @@ public class SysUserService extends BaseService<SysUser, Long> {
|
||||
* @param orderBy 排序参数。
|
||||
* @return 用户列表。
|
||||
*/
|
||||
public List<SysUser> getNotInSysUserListByRoleId(Long roleId, SysUser filter, String orderBy) {
|
||||
return sysUserMapper.getNotInSysUserListByRoleId(roleId, filter, orderBy);
|
||||
}
|
||||
List<SysUser> getNotInSysUserListByRoleId(Long roleId, SysUser filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 查询用户的权限资源地址列表。同时返回详细的分配路径。
|
||||
@@ -235,9 +105,7 @@ public class SysUserService extends BaseService<SysUser, Long> {
|
||||
* @param url url过滤条件。
|
||||
* @return 包含从用户到权限资源的完整权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
public List<Map<String, Object>> getSysPermListWithDetail(Long userId, String url) {
|
||||
return sysUserMapper.getSysPermListWithDetail(userId, url);
|
||||
}
|
||||
List<Map<String, Object>> getSysPermListWithDetail(Long userId, String url);
|
||||
|
||||
/**
|
||||
* 查询用户的权限字列表。同时返回详细的分配路径。
|
||||
@@ -246,9 +114,7 @@ public class SysUserService extends BaseService<SysUser, Long> {
|
||||
* @param permCode 权限字名称过滤条件。
|
||||
* @return 包含从用户到权限字的权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
public List<Map<String, Object>> getSysPermCodeListWithDetail(Long userId, String permCode) {
|
||||
return sysUserMapper.getSysPermCodeListWithDetail(userId, permCode);
|
||||
}
|
||||
List<Map<String, Object>> getSysPermCodeListWithDetail(Long userId, String permCode);
|
||||
|
||||
/**
|
||||
* 查询用户的菜单列表。同时返回详细的分配路径。
|
||||
@@ -257,9 +123,7 @@ public class SysUserService extends BaseService<SysUser, Long> {
|
||||
* @param menuName 菜单名称过滤条件。
|
||||
* @return 包含从用户到菜单的权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
public List<Map<String, Object>> getSysMenuListWithDetail(Long userId, String menuName) {
|
||||
return sysUserMapper.getSysMenuListWithDetail(userId, menuName);
|
||||
}
|
||||
List<Map<String, Object>> getSysMenuListWithDetail(Long userId, String menuName);
|
||||
|
||||
/**
|
||||
* 验证用户对象关联的数据是否都合法。
|
||||
@@ -269,17 +133,5 @@ public class SysUserService extends BaseService<SysUser, Long> {
|
||||
* @param roleIdListString 逗号分隔的角色Id列表字符串。
|
||||
* @return 验证结果。
|
||||
*/
|
||||
public CallResult verifyRelatedData(SysUser sysUser, SysUser originalSysUser, String roleIdListString) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if (StringUtils.isBlank(roleIdListString)) {
|
||||
return CallResult.error("数据验证失败,用户的角色数据不能为空!");
|
||||
}
|
||||
Set<Long> roleIdSet = Arrays.stream(
|
||||
roleIdListString.split(",")).map(Long::valueOf).collect(Collectors.toSet());
|
||||
if (!sysRoleService.existAllPrimaryKeys(roleIdSet)) {
|
||||
return CallResult.error("数据验证失败,存在不合法的用户角色,请刷新后重试!");
|
||||
}
|
||||
jsonObject.put("roleIdSet", roleIdSet);
|
||||
return CallResult.ok(jsonObject);
|
||||
}
|
||||
CallResult verifyRelatedData(SysUser sysUser, SysUser originalSysUser, String roleIdListString);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,264 @@
|
||||
package com.orange.demo.upms.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
|
||||
import com.orange.demo.common.core.util.MyModelUtil;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.upms.dao.SysMenuMapper;
|
||||
import com.orange.demo.upms.dao.SysMenuPermCodeMapper;
|
||||
import com.orange.demo.upms.dao.SysRoleMenuMapper;
|
||||
import com.orange.demo.upms.model.SysMenu;
|
||||
import com.orange.demo.upms.model.SysMenuPermCode;
|
||||
import com.orange.demo.upms.model.SysRoleMenu;
|
||||
import com.orange.demo.upms.model.constant.SysMenuType;
|
||||
import com.orange.demo.upms.service.SysMenuService;
|
||||
import com.orange.demo.upms.service.SysPermCodeService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
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.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 菜单数据服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("sysMenuService")
|
||||
public class SysMenuServiceImpl extends BaseService<SysMenu, Long> implements SysMenuService {
|
||||
|
||||
@Autowired
|
||||
private SysMenuMapper sysMenuMapper;
|
||||
@Autowired
|
||||
private SysRoleMenuMapper sysRoleMenuMapper;
|
||||
@Autowired
|
||||
private SysMenuPermCodeMapper sysMenuPermCodeMapper;
|
||||
@Autowired
|
||||
private SysPermCodeService sysPermCodeService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回主对象的Mapper对象。
|
||||
*
|
||||
* @return 主对象的Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<SysMenu> mapper() {
|
||||
return sysMenuMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增的菜单对象。
|
||||
*
|
||||
* @param sysMenu 新增的菜单对象。
|
||||
* @param permCodeIdSet 权限字Id列表。
|
||||
* @return 新增后的菜单对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public SysMenu saveNew(SysMenu sysMenu, Set<Long> permCodeIdSet) {
|
||||
sysMenu.setMenuId(idGenerator.nextLongId());
|
||||
MyModelUtil.fillCommonsForInsert(sysMenu);
|
||||
sysMenu.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
sysMenuMapper.insert(sysMenu);
|
||||
if (permCodeIdSet != null) {
|
||||
List<SysMenuPermCode> sysMenuPermCodeList = new LinkedList<>();
|
||||
for (Long permCodeId : permCodeIdSet) {
|
||||
SysMenuPermCode menuPermCode = new SysMenuPermCode();
|
||||
menuPermCode.setMenuId(sysMenu.getMenuId());
|
||||
menuPermCode.setPermCodeId(permCodeId);
|
||||
sysMenuPermCodeList.add(menuPermCode);
|
||||
}
|
||||
sysMenuPermCodeMapper.insertList(sysMenuPermCodeList);
|
||||
}
|
||||
return sysMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新菜单对象。
|
||||
*
|
||||
* @param sysMenu 更新的菜单对象。
|
||||
* @param originalSysMenu 原有的菜单对象。
|
||||
* @param permCodeIdSet 权限字Id列表。
|
||||
* @return 更新成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(SysMenu sysMenu, SysMenu originalSysMenu, Set<Long> permCodeIdSet) {
|
||||
MyModelUtil.fillCommonsForUpdate(sysMenu, originalSysMenu);
|
||||
sysMenu.setMenuType(originalSysMenu.getMenuType());
|
||||
sysMenu.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
if (sysMenuMapper.updateByPrimaryKey(sysMenu) != 1) {
|
||||
return false;
|
||||
}
|
||||
SysMenuPermCode deletedMenuPermCode = new SysMenuPermCode();
|
||||
deletedMenuPermCode.setMenuId(sysMenu.getMenuId());
|
||||
sysMenuPermCodeMapper.delete(deletedMenuPermCode);
|
||||
if (permCodeIdSet != null) {
|
||||
List<SysMenuPermCode> sysMenuPermCodeList = new LinkedList<>();
|
||||
for (Long permCodeId : permCodeIdSet) {
|
||||
SysMenuPermCode menuPermCode = new SysMenuPermCode();
|
||||
menuPermCode.setMenuId(sysMenu.getMenuId());
|
||||
menuPermCode.setPermCodeId(permCodeId);
|
||||
sysMenuPermCodeList.add(menuPermCode);
|
||||
}
|
||||
sysMenuPermCodeMapper.insertList(sysMenuPermCodeList);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定的菜单。
|
||||
*
|
||||
* @param menuId 菜单主键Id。
|
||||
* @return 删除成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long menuId) {
|
||||
if (!this.removeById(menuId)) {
|
||||
return false;
|
||||
}
|
||||
SysRoleMenu roleMenu = new SysRoleMenu();
|
||||
roleMenu.setMenuId(menuId);
|
||||
sysRoleMenuMapper.delete(roleMenu);
|
||||
SysMenuPermCode menuPermCode = new SysMenuPermCode();
|
||||
menuPermCode.setMenuId(menuId);
|
||||
sysMenuPermCodeMapper.delete(menuPermCode);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部菜单列表。
|
||||
*
|
||||
* @return 全部菜单列表。
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> getAllMenuList() {
|
||||
Example e = new Example(SysMenu.class);
|
||||
e.orderBy("showOrder");
|
||||
Example.Criteria c = e.createCriteria();
|
||||
c.andIn("menuType", Arrays.asList(SysMenuType.TYPE_MENU, SysMenuType.TYPE_DIRECTORY));
|
||||
c.andEqualTo("deletedFlag", GlobalDeletedFlag.NORMAL);
|
||||
return sysMenuMapper.selectByExample(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定用户Id的菜单列表。
|
||||
*
|
||||
* @param userId 用户主键Id。
|
||||
* @return 用户关联的菜单列表。
|
||||
*/
|
||||
@Override
|
||||
public List<SysMenu> getMenuListByUserId(Long userId) {
|
||||
return sysMenuMapper.getMenuListByUserId(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前菜单是否存在子菜单。
|
||||
*
|
||||
* @param menuId 菜单主键Id。
|
||||
* @return 存在返回true,否则false。
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildren(Long menuId) {
|
||||
SysMenu menu = new SysMenu();
|
||||
menu.setParentId(menuId);
|
||||
return this.getCountByFilter(menu) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证菜单对象关联的数据是否都合法。
|
||||
*
|
||||
* @param sysMenu 当前操作的对象。
|
||||
* @param originalSysMenu 原有对象。
|
||||
* @param permCodeIdListString 逗号分隔的权限Id列表。
|
||||
* @return 验证结果。
|
||||
*/
|
||||
@Override
|
||||
public CallResult verifyRelatedData(SysMenu sysMenu, SysMenu originalSysMenu, String permCodeIdListString) {
|
||||
// menu、ui fragment和button类型的menu不能没有parentId
|
||||
if (sysMenu.getParentId() == null) {
|
||||
if (sysMenu.getMenuType() != SysMenuType.TYPE_DIRECTORY) {
|
||||
return CallResult.error("数据验证失败,当前类型菜单项的上级菜单不能为空!");
|
||||
}
|
||||
}
|
||||
if (this.needToVerify(sysMenu, originalSysMenu, SysMenu::getParentId)) {
|
||||
String errorMessage = checkErrorOfNonDirectoryMenu(sysMenu);
|
||||
if (errorMessage != null) {
|
||||
return CallResult.error(errorMessage);
|
||||
}
|
||||
}
|
||||
JSONObject jsonObject = null;
|
||||
if (StringUtils.isNotBlank(permCodeIdListString)) {
|
||||
Set<Long> permCodeIdSet = Arrays.stream(
|
||||
permCodeIdListString.split(",")).map(Long::valueOf).collect(Collectors.toSet());
|
||||
if (!sysPermCodeService.existAllPrimaryKeys(permCodeIdSet)) {
|
||||
return CallResult.error("数据验证失败,存在不合法的权限字,请刷新后重试!");
|
||||
}
|
||||
jsonObject = new JSONObject();
|
||||
jsonObject.put("permCodeIdSet", permCodeIdSet);
|
||||
}
|
||||
return CallResult.ok(jsonObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询菜单的权限资源地址列表。同时返回详细的分配路径。
|
||||
*
|
||||
* @param menuId 菜单Id。
|
||||
* @param url 权限资源地址过滤条件。
|
||||
* @return 包含从菜单到权限资源的权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> getSysPermListWithDetail(Long menuId, String url) {
|
||||
return sysMenuMapper.getSysPermListWithDetail(menuId, url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询菜单的用户列表。同时返回详细的分配路径。
|
||||
*
|
||||
* @param menuId 菜单Id。
|
||||
* @param loginName 登录名。
|
||||
* @return 包含从菜单到用户的完整权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> getSysUserListWithDetail(Long menuId, String loginName) {
|
||||
return sysMenuMapper.getSysUserListWithDetail(menuId, loginName);
|
||||
}
|
||||
|
||||
private String checkErrorOfNonDirectoryMenu(SysMenu sysMenu) {
|
||||
// 判断父节点是否存在
|
||||
SysMenu parentSysMenu = getById(sysMenu.getParentId());
|
||||
if (parentSysMenu == null) {
|
||||
return "数据验证失败,关联的上级菜单并不存在,请刷新后重试!";
|
||||
}
|
||||
// 逐个判断每种类型的菜单,他的父菜单的合法性,先从目录类型和菜单类型开始
|
||||
if (sysMenu.getMenuType() == SysMenuType.TYPE_DIRECTORY
|
||||
|| sysMenu.getMenuType() == SysMenuType.TYPE_MENU) {
|
||||
// 他们的上级只能是目录
|
||||
if (parentSysMenu.getMenuType() != SysMenuType.TYPE_DIRECTORY) {
|
||||
return "数据验证失败,当前类型菜单项的上级菜单只能是目录类型!";
|
||||
}
|
||||
} else if (sysMenu.getMenuType() == SysMenuType.TYPE_UI_FRAGMENT) {
|
||||
// ui fragment的上级只能是menu类型
|
||||
if (parentSysMenu.getMenuType() != SysMenuType.TYPE_MENU) {
|
||||
return "数据验证失败,当前类型菜单项的上级菜单只能是菜单类型和按钮类型!";
|
||||
}
|
||||
} else if (sysMenu.getMenuType() == SysMenuType.TYPE_BUTTON) {
|
||||
// button的上级只能是menu和ui fragment
|
||||
if (parentSysMenu.getMenuType() != SysMenuType.TYPE_MENU
|
||||
&& parentSysMenu.getMenuType() != SysMenuType.TYPE_UI_FRAGMENT) {
|
||||
return "数据验证失败,当前类型菜单项的上级菜单只能是菜单类型和UI片段类型!";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package com.orange.demo.upms.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
|
||||
import com.orange.demo.common.core.util.MyModelUtil;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.upms.dao.SysMenuPermCodeMapper;
|
||||
import com.orange.demo.upms.dao.SysPermCodeMapper;
|
||||
import com.orange.demo.upms.dao.SysPermCodePermMapper;
|
||||
import com.orange.demo.upms.model.SysMenuPermCode;
|
||||
import com.orange.demo.upms.model.SysPermCode;
|
||||
import com.orange.demo.upms.model.SysPermCodePerm;
|
||||
import com.orange.demo.upms.service.SysPermCodeService;
|
||||
import com.orange.demo.upms.service.SysPermService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 权限字数据服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("sysPermCodeService")
|
||||
public class SysPermCodeServiceImpl extends BaseService<SysPermCode, Long> implements SysPermCodeService {
|
||||
|
||||
@Autowired
|
||||
private SysPermCodeMapper sysPermCodeMapper;
|
||||
@Autowired
|
||||
private SysPermCodePermMapper sysPermCodePermMapper;
|
||||
@Autowired
|
||||
private SysMenuPermCodeMapper sysMenuPermCodeMapper;
|
||||
@Autowired
|
||||
private SysPermService sysPermService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回主对象的Mapper对象。
|
||||
*
|
||||
* @return 主对象的Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<SysPermCode> mapper() {
|
||||
return sysPermCodeMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定用户的权限字列表。
|
||||
*
|
||||
* @param userId 用户主键Id。
|
||||
* @return 用户关联的权限字列表。
|
||||
*/
|
||||
@Override
|
||||
public List<String> getPermCodeListByUserId(Long userId) {
|
||||
return sysPermCodeMapper.getPermCodeListByUserId(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增的权限字对象。
|
||||
*
|
||||
* @param sysPermCode 新增的权限字对象。
|
||||
* @param permIdSet 权限资源Id列表。
|
||||
* @return 新增后的权限字对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public SysPermCode saveNew(SysPermCode sysPermCode, Set<Long> permIdSet) {
|
||||
sysPermCode.setPermCodeId(idGenerator.nextLongId());
|
||||
MyModelUtil.fillCommonsForInsert(sysPermCode);
|
||||
sysPermCode.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
sysPermCodeMapper.insert(sysPermCode);
|
||||
if (permIdSet != null) {
|
||||
List<SysPermCodePerm> sysPermCodePermList = new LinkedList<>();
|
||||
for (Long permId : permIdSet) {
|
||||
SysPermCodePerm permCodePerm = new SysPermCodePerm();
|
||||
permCodePerm.setPermCodeId(sysPermCode.getPermCodeId());
|
||||
permCodePerm.setPermId(permId);
|
||||
sysPermCodePermList.add(permCodePerm);
|
||||
}
|
||||
sysPermCodePermMapper.insertList(sysPermCodePermList);
|
||||
}
|
||||
return sysPermCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新权限字对象。
|
||||
*
|
||||
* @param sysPermCode 更新的权限字对象。
|
||||
* @param originalSysPermCode 原有的权限字对象。
|
||||
* @param permIdSet 权限资源Id列表。
|
||||
* @return 更新成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(SysPermCode sysPermCode, SysPermCode originalSysPermCode, Set<Long> permIdSet) {
|
||||
MyModelUtil.fillCommonsForUpdate(sysPermCode, originalSysPermCode);
|
||||
sysPermCode.setParentId(originalSysPermCode.getParentId());
|
||||
sysPermCode.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
if (sysPermCodeMapper.updateByPrimaryKey(sysPermCode) != 1) {
|
||||
return false;
|
||||
}
|
||||
SysPermCodePerm deletedPermCodePerm = new SysPermCodePerm();
|
||||
deletedPermCodePerm.setPermCodeId(sysPermCode.getPermCodeId());
|
||||
sysPermCodePermMapper.delete(deletedPermCodePerm);
|
||||
if (permIdSet != null) {
|
||||
List<SysPermCodePerm> sysPermCodePermList = new LinkedList<>();
|
||||
for (Long permId : permIdSet) {
|
||||
SysPermCodePerm permCodePerm = new SysPermCodePerm();
|
||||
permCodePerm.setPermCodeId(sysPermCode.getPermCodeId());
|
||||
permCodePerm.setPermId(permId);
|
||||
sysPermCodePermList.add(permCodePerm);
|
||||
}
|
||||
sysPermCodePermMapper.insertList(sysPermCodePermList);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定的权限字。
|
||||
*
|
||||
* @param permCodeId 权限字主键Id。
|
||||
* @return 删除成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long permCodeId) {
|
||||
if (!this.removeById(permCodeId)) {
|
||||
return false;
|
||||
}
|
||||
SysMenuPermCode menuPermCode = new SysMenuPermCode();
|
||||
menuPermCode.setPermCodeId(permCodeId);
|
||||
sysMenuPermCodeMapper.delete(menuPermCode);
|
||||
SysPermCodePerm permCodePerm = new SysPermCodePerm();
|
||||
permCodePerm.setPermCodeId(permCodeId);
|
||||
sysPermCodePermMapper.delete(permCodePerm);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前权限字是否存在下级权限字对象。
|
||||
*
|
||||
* @param permCodeId 权限字主键Id。
|
||||
* @return 存在返回true,否则false。
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildren(Long permCodeId) {
|
||||
SysPermCode permCode = new SysPermCode();
|
||||
permCode.setParentId(permCodeId);
|
||||
return this.getCountByFilter(permCode) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证权限字对象关联的数据是否都合法。
|
||||
*
|
||||
* @param sysPermCode 当前操作的对象。
|
||||
* @param originalSysPermCode 原有对象。
|
||||
* @param permIdListString 逗号分隔的权限资源Id列表。
|
||||
* @return 验证结果。
|
||||
*/
|
||||
@Override
|
||||
public CallResult verifyRelatedData(
|
||||
SysPermCode sysPermCode, SysPermCode originalSysPermCode, String permIdListString) {
|
||||
if (this.needToVerify(sysPermCode, originalSysPermCode, SysPermCode::getParentId)) {
|
||||
if (getById(sysPermCode.getParentId()) == null) {
|
||||
return CallResult.error("数据验证失败,关联的上级权限字并不存在,请刷新后重试!");
|
||||
}
|
||||
}
|
||||
JSONObject jsonObject = null;
|
||||
if (StringUtils.isNotBlank(permIdListString)) {
|
||||
Set<Long> permIdSet = Arrays.stream(
|
||||
permIdListString.split(",")).map(Long::valueOf).collect(Collectors.toSet());
|
||||
if (!sysPermService.existAllPrimaryKeys(permIdSet)) {
|
||||
return CallResult.error("数据验证失败,存在不合法的权限资源,请刷新后重试!");
|
||||
}
|
||||
jsonObject = new JSONObject();
|
||||
jsonObject.put("permIdSet", permIdSet);
|
||||
}
|
||||
return CallResult.ok(jsonObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询权限字的用户列表。同时返回详细的分配路径。
|
||||
*
|
||||
* @param permCodeId 权限字Id。
|
||||
* @param loginName 登录名。
|
||||
* @return 包含从权限字到用户的完整权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> getSysUserListWithDetail(Long permCodeId, String loginName) {
|
||||
return sysPermCodeMapper.getSysUserListWithDetail(permCodeId, loginName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询权限字的角色列表。同时返回详细的分配路径。
|
||||
*
|
||||
* @param permCodeId 权限字Id。
|
||||
* @param roleName 角色名。
|
||||
* @return 包含从权限字到角色的权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> getSysRoleListWithDetail(Long permCodeId, String roleName) {
|
||||
return sysPermCodeMapper.getSysRoleListWithDetail(permCodeId, roleName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.orange.demo.upms.service.impl;
|
||||
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
|
||||
import com.orange.demo.common.core.util.MyModelUtil;
|
||||
import com.orange.demo.upms.dao.SysPermModuleMapper;
|
||||
import com.orange.demo.upms.model.SysPerm;
|
||||
import com.orange.demo.upms.model.SysPermModule;
|
||||
import com.orange.demo.upms.service.SysPermModuleService;
|
||||
import com.orange.demo.upms.service.SysPermService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 权限资源模块数据服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("sysPermModuleService")
|
||||
public class SysPermModuleServiceImpl extends BaseService<SysPermModule, Long> implements SysPermModuleService {
|
||||
|
||||
@Autowired
|
||||
private SysPermModuleMapper sysPermModuleMapper;
|
||||
@Autowired
|
||||
private SysPermService sysPermService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回主对象的Mapper对象。
|
||||
*
|
||||
* @return 主对象的Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<SysPermModule> mapper() {
|
||||
return sysPermModuleMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增的权限资源模块对象。
|
||||
*
|
||||
* @param sysPermModule 新增的权限资源模块对象。
|
||||
* @return 新增后的权限资源模块对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public SysPermModule saveNew(SysPermModule sysPermModule) {
|
||||
sysPermModule.setModuleId(idGenerator.nextLongId());
|
||||
MyModelUtil.fillCommonsForInsert(sysPermModule);
|
||||
sysPermModule.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
sysPermModuleMapper.insert(sysPermModule);
|
||||
return sysPermModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新权限资源模块对象。
|
||||
*
|
||||
* @param sysPermModule 更新的权限资源模块对象。
|
||||
* @param originalSysPermModule 原有的权限资源模块对象。
|
||||
* @return 更新成功返回true,否则false
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(SysPermModule sysPermModule, SysPermModule originalSysPermModule) {
|
||||
MyModelUtil.fillCommonsForUpdate(sysPermModule, originalSysPermModule);
|
||||
sysPermModule.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
return sysPermModuleMapper.updateByPrimaryKey(sysPermModule) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定的权限资源模块。
|
||||
*
|
||||
* @param moduleId 权限资源模块主键Id。
|
||||
* @return 删除成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long moduleId) {
|
||||
return this.removeById(moduleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限模块资源及其关联的权限资源列表。
|
||||
*
|
||||
* @return 权限资源模块及其关联的权限资源列表。
|
||||
*/
|
||||
@Override
|
||||
public List<SysPermModule> getPermModuleAndPermList() {
|
||||
return sysPermModuleMapper.getPermModuleAndPermList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否存在下级权限资源模块。
|
||||
*
|
||||
* @param moduleId 权限资源模块主键Id。
|
||||
* @return 存在返回true,否则false。
|
||||
*/
|
||||
@Override
|
||||
public boolean hasChildren(Long moduleId) {
|
||||
SysPermModule permModule = new SysPermModule();
|
||||
permModule.setParentId(moduleId);
|
||||
return this.getCountByFilter(permModule) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否存在权限数据。
|
||||
*
|
||||
* @param moduleId 权限资源模块主键Id。
|
||||
* @return 存在返回true,否则false。
|
||||
*/
|
||||
@Override
|
||||
public boolean hasModulePerms(Long moduleId) {
|
||||
SysPerm filter = new SysPerm();
|
||||
filter.setModuleId(moduleId);
|
||||
return sysPermService.getCountByFilter(filter) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
package com.orange.demo.upms.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.constant.GlobalDeletedFlag;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.util.MyModelUtil;
|
||||
import com.orange.demo.upms.service.*;
|
||||
import com.orange.demo.upms.dao.SysPermCodePermMapper;
|
||||
import com.orange.demo.upms.dao.SysPermMapper;
|
||||
import com.orange.demo.upms.model.SysPerm;
|
||||
import com.orange.demo.upms.model.SysPermCodePerm;
|
||||
import com.orange.demo.upms.model.SysPermModule;
|
||||
import com.orange.demo.upms.model.SysUser;
|
||||
import com.orange.demo.upms.model.constant.SysUserType;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
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.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 权限资源数据服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-09-24
|
||||
*/
|
||||
@Service("sysPermService")
|
||||
public class SysPermServiceImpl extends BaseService<SysPerm, Long> implements SysPermService {
|
||||
|
||||
@Autowired
|
||||
private SysPermMapper sysPermMapper;
|
||||
@Autowired
|
||||
private SysPermCodePermMapper sysPermCodePermMapper;
|
||||
@Autowired
|
||||
private SysPermModuleService sysPermModuleService;
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回主对象的Mapper对象。
|
||||
*
|
||||
* @return 主对象的Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<SysPerm> mapper() {
|
||||
return sysPermMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存新增的权限资源对象。
|
||||
*
|
||||
* @param perm 新增的权限资源对象。
|
||||
* @return 新增后的权限资源对象。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public SysPerm saveNew(SysPerm perm) {
|
||||
perm.setPermId(idGenerator.nextLongId());
|
||||
MyModelUtil.fillCommonsForInsert(perm);
|
||||
perm.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
sysPermMapper.insert(perm);
|
||||
return perm;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新权限资源对象。
|
||||
*
|
||||
* @param perm 更新的权限资源对象。
|
||||
* @param originalPerm 原有的权限资源对象。
|
||||
* @return 更新成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean update(SysPerm perm, SysPerm originalPerm) {
|
||||
MyModelUtil.fillCommonsForUpdate(perm, originalPerm);
|
||||
perm.setDeletedFlag(GlobalDeletedFlag.NORMAL);
|
||||
return sysPermMapper.updateByPrimaryKeySelective(perm) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除权限资源。
|
||||
*
|
||||
* @param permId 权限资源主键Id。
|
||||
* @return 删除成功返回true,否则false。
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean remove(Long permId) {
|
||||
if (!this.removeById(permId)) {
|
||||
return false;
|
||||
}
|
||||
SysPermCodePerm permCodePerm = new SysPermCodePerm();
|
||||
permCodePerm.setPermId(permId);
|
||||
sysPermCodePermMapper.delete(permCodePerm);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限数据列表。
|
||||
*
|
||||
* @param sysPermFilter 过滤对象。
|
||||
* @return 权限列表。
|
||||
*/
|
||||
@Override
|
||||
public List<SysPerm> getPermListWithRelation(SysPerm sysPermFilter) {
|
||||
Example e = new Example(SysPerm.class);
|
||||
e.orderBy("showOrder");
|
||||
Example.Criteria c = e.createCriteria();
|
||||
if (ObjectUtil.isNotNull(sysPermFilter.getModuleId())) {
|
||||
c.andEqualTo("moduleId", sysPermFilter.getModuleId());
|
||||
}
|
||||
if (ObjectUtil.isNotNull(sysPermFilter.getUrl())) {
|
||||
c.andLike("url", "%" + sysPermFilter.getUrl() + "%");
|
||||
}
|
||||
c.andEqualTo("deletedFlag", GlobalDeletedFlag.NORMAL);
|
||||
List<SysPerm> permList = sysPermMapper.selectByExample(e);
|
||||
// 这里因为权限只有字典数据,所以仅仅做字典关联。
|
||||
this.buildRelationForDataList(permList, MyRelationParam.dictOnly());
|
||||
return permList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定用户的权限资源集合,并存储于缓存,从而提升后续读取效率。
|
||||
*
|
||||
* @param sessionId 用户会话Id。
|
||||
* @param userId 用户主键Id。
|
||||
* @return 当前用户权限集合。
|
||||
*/
|
||||
@Cacheable(value = "USER_PERMISSION_CACHE", key = "#sessionId", unless = "#result == null")
|
||||
@Override
|
||||
public Set<String> getCacheableSysPermSetByUserId(String sessionId, Long userId) {
|
||||
// 这里可以防止非法的userId直接访问权限受限的url
|
||||
SysUser user = sysUserService.getById(userId);
|
||||
if (user == null) {
|
||||
return new HashSet<>(1);
|
||||
}
|
||||
// 管理员账户返回空对象,便于缓存的统一处理。
|
||||
return user.getUserType() == SysUserType.TYPE_ADMIN
|
||||
? new HashSet<>(1) : this.getSysPermSetByUserId(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将指定用户的指定会话的权限集合存入缓存。
|
||||
*
|
||||
* @param sessionId 会话Id。
|
||||
* @param userId 用户主键Id。
|
||||
* @param isAdmin 是否是管理员。
|
||||
* @return 查询并缓存后的权限集合。
|
||||
*/
|
||||
@CachePut(value = "USER_PERMISSION_CACHE", key = "#sessionId")
|
||||
@Override
|
||||
public Set<String> putUserSysPermCache(String sessionId, Long userId, boolean isAdmin) {
|
||||
// 管理员账户返回空对象,便于缓存的统一处理。
|
||||
return isAdmin ? new HashSet<>(1) : this.getSysPermSetByUserId(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将指定会话的权限集合从缓存中移除。
|
||||
*
|
||||
* @param sessionId 会话Id。
|
||||
*/
|
||||
@CacheEvict(value = "USER_PERMISSION_CACHE", key = "#sessionId")
|
||||
@Override
|
||||
public void removeUserSysPermCache(String sessionId) {
|
||||
// 空实现即可,只是通过注解将当前sessionId从cache中删除。
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定用户的权限集合,这里之所以为公有方法,因为spring cache的技术要求,私有方法数据不能缓存。
|
||||
*
|
||||
* @param userId 用户主键Id。
|
||||
* @return 用户权限集合。
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getSysPermSetByUserId(Long userId) {
|
||||
List<SysPerm> permList = this.getPermListByUserId(userId);
|
||||
return permList.stream().map(SysPerm::getUrl).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取与指定用户关联的权限资源列表。
|
||||
*
|
||||
* @param userId 关联的用户主键Id。
|
||||
* @return 与指定用户Id关联的权限资源列表。
|
||||
*/
|
||||
@Override
|
||||
public List<SysPerm> getPermListByUserId(Long userId) {
|
||||
return sysPermMapper.getPermListByUserId(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证权限资源对象关联的数据是否都合法。
|
||||
*
|
||||
* @param sysPerm 当前操作的对象。
|
||||
* @param originalSysPerm 原有对象。
|
||||
* @return 验证结果。
|
||||
*/
|
||||
@Override
|
||||
public CallResult verifyRelatedData(SysPerm sysPerm, SysPerm originalSysPerm) {
|
||||
if (this.needToVerify(sysPerm, originalSysPerm, SysPerm::getModuleId)) {
|
||||
SysPermModule permModule = sysPermModuleService.getById(sysPerm.getModuleId());
|
||||
if (permModule == null) {
|
||||
return CallResult.error("数据验证失败,关联的权限模块Id并不存在,请刷新后重试!");
|
||||
}
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询权限资源地址的用户列表。同时返回详细的分配路径。
|
||||
*
|
||||
* @param permId 权限资源Id。
|
||||
* @param loginName 登录名。
|
||||
* @return 包含从权限资源到用户的完整权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> getSysUserListWithDetail(Long permId, String loginName) {
|
||||
return sysPermMapper.getSysUserListWithDetail(permId, loginName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询权限资源地址的角色列表。同时返回详细的分配路径。
|
||||
*
|
||||
* @param permId 权限资源Id。
|
||||
* @param roleName 角色名。
|
||||
* @return 包含从权限资源到角色的权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> getSysRoleListWithDetail(Long permId, String roleName) {
|
||||
return sysPermMapper.getSysRoleListWithDetail(permId, roleName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询权限资源地址的菜单列表。同时返回详细的分配路径。
|
||||
*
|
||||
* @param permId 权限资源Id。
|
||||
* @param menuName 菜单名。
|
||||
* @return 包含从权限资源到菜单的权限分配路径信息的查询结果列表。
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> getSysMenuListWithDetail(Long permId, String menuName) {
|
||||
return sysPermMapper.getSysMenuListWithDetail(permId, menuName);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user