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:
@@ -9,10 +9,9 @@ import com.orange.demo.common.core.object.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.constant.*;
|
||||
import com.orange.demo.common.core.base.controller.BaseController;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -35,7 +34,7 @@ public class CourseTransStatsController extends BaseController<CourseTransStats,
|
||||
private CourseTransStatsService courseTransStatsService;
|
||||
|
||||
@Override
|
||||
protected BaseService<CourseTransStats, Long> service() {
|
||||
protected IBaseService<CourseTransStats, Long> service() {
|
||||
return courseTransStatsService;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,9 @@ import com.orange.demo.common.core.object.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.constant.*;
|
||||
import com.orange.demo.common.core.base.controller.BaseController;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -35,7 +34,7 @@ public class StudentActionStatsController extends BaseController<StudentActionSt
|
||||
private StudentActionStatsService studentActionStatsService;
|
||||
|
||||
@Override
|
||||
protected BaseService<StudentActionStats, Long> service() {
|
||||
protected IBaseService<StudentActionStats, Long> service() {
|
||||
return studentActionStatsService;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,11 @@ import com.orange.demo.common.core.object.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.constant.*;
|
||||
import com.orange.demo.common.core.base.controller.BaseController;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
import com.orange.demo.common.core.annotation.MyRequestBody;
|
||||
import com.orange.demo.common.core.validator.UpdateGroup;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -38,7 +37,7 @@ public class StudentActionTransController extends BaseController<StudentActionTr
|
||||
private StudentActionTransService studentActionTransService;
|
||||
|
||||
@Override
|
||||
protected BaseService<StudentActionTrans, Long> service() {
|
||||
protected IBaseService<StudentActionTrans, Long> service() {
|
||||
return studentActionTransService;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,13 +8,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.ConstDictRef;
|
||||
import com.orange.demo.statsinterface.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;
|
||||
@@ -32,7 +30,6 @@ public class CourseTransStats {
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!")
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "stats_id")
|
||||
@@ -41,22 +38,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;
|
||||
|
||||
@@ -69,7 +62,6 @@ public class CourseTransStats {
|
||||
/**
|
||||
* 课程Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,课程ID不能为空!")
|
||||
@Column(name = "course_id")
|
||||
private Long courseId;
|
||||
|
||||
@@ -82,21 +74,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;
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.orange.demo.common.core.annotation.DeletedFlagColumn;
|
||||
import lombok.Data;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* Grade实体对象。
|
||||
@@ -19,7 +18,6 @@ public class Grade {
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!")
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "grade_id")
|
||||
@@ -28,7 +26,6 @@ public class Grade {
|
||||
/**
|
||||
* 年级名称。
|
||||
*/
|
||||
@NotBlank(message = "数据验证失败,年级名称不能为空!")
|
||||
@Column(name = "grade_name")
|
||||
private String gradeName;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.orange.demo.statsservice.model;
|
||||
|
||||
import lombok.Data;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* SchoolInfo实体对象。
|
||||
@@ -17,7 +16,6 @@ public class SchoolInfo {
|
||||
/**
|
||||
* 学校Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,学校Id不能为空!")
|
||||
@Id
|
||||
@Column(name = "school_id")
|
||||
private Long schoolId;
|
||||
@@ -25,21 +23,18 @@ public class SchoolInfo {
|
||||
/**
|
||||
* 学校名称。
|
||||
*/
|
||||
@NotBlank(message = "数据验证失败,学校名称不能为空!")
|
||||
@Column(name = "school_name")
|
||||
private String schoolName;
|
||||
|
||||
/**
|
||||
* 所在省Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所在省Id不能为空!")
|
||||
@Column(name = "province_id")
|
||||
private Long provinceId;
|
||||
|
||||
/**
|
||||
* 所在城市Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,所在城市Id不能为空!")
|
||||
@Column(name = "city_id")
|
||||
private Long cityId;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ 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 +28,6 @@ public class StudentActionStats {
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!")
|
||||
@Id
|
||||
@Column(name = "stats_id")
|
||||
private Long statsId;
|
||||
@@ -37,7 +35,6 @@ public class StudentActionStats {
|
||||
/**
|
||||
* 统计日期。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,统计日期不能为空!")
|
||||
@Column(name = "stats_date")
|
||||
private Date statsDate;
|
||||
|
||||
@@ -50,126 +47,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 = "数据验证失败,所在城市不能为空!")
|
||||
@Column(name = "city_id")
|
||||
private Long cityId;
|
||||
|
||||
/**
|
||||
* 购课学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购课学币数量不能为空!")
|
||||
@Column(name = "buy_course_amount")
|
||||
private Integer buyCourseAmount;
|
||||
|
||||
/**
|
||||
* 购买课程次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买课程次数不能为空!")
|
||||
@Column(name = "buy_course_count")
|
||||
private Integer buyCourseCount;
|
||||
|
||||
/**
|
||||
* 购买视频学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买视频学币数量不能为空!")
|
||||
@Column(name = "buy_video_amount")
|
||||
private Integer buyVideoAmount;
|
||||
|
||||
/**
|
||||
* 购买视频次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买视频次数不能为空!")
|
||||
@Column(name = "buy_video_count")
|
||||
private Integer buyVideoCount;
|
||||
|
||||
/**
|
||||
* 购买作业学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买作业学币数量不能为空!")
|
||||
@Column(name = "buy_paper_amount")
|
||||
private Integer buyPaperAmount;
|
||||
|
||||
/**
|
||||
* 购买作业次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买作业次数不能为空!")
|
||||
@Column(name = "buy_paper_count")
|
||||
private Integer buyPaperCount;
|
||||
|
||||
/**
|
||||
* 购买献花数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买献花数量不能为空!")
|
||||
@Column(name = "buy_flower_amount")
|
||||
private Integer buyFlowerAmount;
|
||||
|
||||
/**
|
||||
* 购买献花次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买献花次数不能为空!")
|
||||
@Column(name = "buy_flower_count")
|
||||
private Integer buyFlowerCount;
|
||||
|
||||
/**
|
||||
* 充值学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,充值学币数量不能为空!")
|
||||
@Column(name = "recharge_coin_amount")
|
||||
private Integer rechargeCoinAmount;
|
||||
|
||||
/**
|
||||
* 充值学币次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,充值学币次数不能为空!")
|
||||
@Column(name = "recharge_coin_count")
|
||||
private Integer rechargeCoinCount;
|
||||
|
||||
/**
|
||||
* 线下课程上课次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,线下课程上课次数不能为空!")
|
||||
@Column(name = "do_course_count")
|
||||
private Integer doCourseCount;
|
||||
|
||||
/**
|
||||
* 观看视频次数。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,观看视频次数不能为空!")
|
||||
@Column(name = "watch_video_count")
|
||||
private Integer watchVideoCount;
|
||||
|
||||
/**
|
||||
* 购买献花消费学币数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,购买献花消费学币数量不能为空!")
|
||||
@Column(name = "watch_video_total_second")
|
||||
private Integer watchVideoTotalSecond;
|
||||
|
||||
/**
|
||||
* 做题数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,做题数量不能为空!")
|
||||
@Column(name = "do_exercise_count")
|
||||
private Integer doExerciseCount;
|
||||
|
||||
/**
|
||||
* 做题正确的数量。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,做题正确的数量不能为空!")
|
||||
@Column(name = "do_exercise_correct_count")
|
||||
private Integer doExerciseCorrectCount;
|
||||
|
||||
|
||||
@@ -9,13 +9,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.ConstDictRef;
|
||||
import com.orange.demo.statsinterface.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;
|
||||
@@ -33,7 +31,6 @@ public class StudentActionTrans {
|
||||
/**
|
||||
* 主键Id。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,主键Id不能为空!")
|
||||
@Id
|
||||
@Column(name = "trans_id")
|
||||
private Long transId;
|
||||
@@ -41,44 +38,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;
|
||||
|
||||
@@ -127,7 +116,6 @@ public class StudentActionTrans {
|
||||
/**
|
||||
* 发生时间。
|
||||
*/
|
||||
@NotNull(message = "数据验证失败,发生时间不能为空!")
|
||||
@Column(name = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
|
||||
@@ -1,38 +1,17 @@
|
||||
package com.orange.demo.statsservice.service;
|
||||
|
||||
import com.orange.demo.statsservice.dao.*;
|
||||
import com.orange.demo.statsservice.model.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.MyWhereCriteria;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import 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-08-08
|
||||
*/
|
||||
@Service
|
||||
public class CourseTransStatsService extends BaseService<CourseTransStats, Long> {
|
||||
|
||||
@Autowired
|
||||
private CourseTransStatsMapper courseTransStatsMapper;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<CourseTransStats> mapper() {
|
||||
return courseTransStatsMapper;
|
||||
}
|
||||
public interface CourseTransStatsService extends IBaseService<CourseTransStats, Long> {
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
@@ -42,9 +21,7 @@ public class CourseTransStatsService extends BaseService<CourseTransStats, Long>
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<CourseTransStats> getCourseTransStatsList(CourseTransStats filter, String orderBy) {
|
||||
return courseTransStatsMapper.getCourseTransStatsList(null, null, filter, orderBy);
|
||||
}
|
||||
List<CourseTransStats> getCourseTransStatsList(CourseTransStats filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
||||
@@ -57,11 +34,7 @@ public class CourseTransStatsService extends BaseService<CourseTransStats, Long>
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public <M> List<CourseTransStats> getCourseTransStatsList(
|
||||
String inFilterField, Set<M> inFilterValues, CourseTransStats filter, String orderBy) {
|
||||
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, CourseTransStats.class);
|
||||
return courseTransStatsMapper.getCourseTransStatsList(inFilterColumn, inFilterValues, filter, orderBy);
|
||||
}
|
||||
<M> List<CourseTransStats> getCourseTransStatsList(String inFilterField, Set<M> inFilterValues, CourseTransStats filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
@@ -71,12 +44,7 @@ public class CourseTransStatsService extends BaseService<CourseTransStats, Long>
|
||||
* @param orderBy 排序对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<CourseTransStats> getCourseTransStatsListWithRelation(CourseTransStats filter, String orderBy) {
|
||||
List<CourseTransStats> resultList = courseTransStatsMapper.getCourseTransStatsList(null, null, filter, orderBy);
|
||||
Map<String, List<MyWhereCriteria>> criteriaMap = buildAggregationAdditionalWhereCriteria();
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), criteriaMap);
|
||||
return resultList;
|
||||
}
|
||||
List<CourseTransStats> getCourseTransStatsListWithRelation(CourseTransStats filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
||||
@@ -89,13 +57,8 @@ public class CourseTransStatsService extends BaseService<CourseTransStats, Long>
|
||||
* @param orderBy 排序对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public <M> List<CourseTransStats> getCourseTransStatsListWithRelation(
|
||||
String inFilterField, Set<M> inFilterValues, CourseTransStats filter, String orderBy) {
|
||||
List<CourseTransStats> resultList =
|
||||
courseTransStatsMapper.getCourseTransStatsList(inFilterField, inFilterValues, filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly(), null);
|
||||
return resultList;
|
||||
}
|
||||
<M> List<CourseTransStats> getCourseTransStatsListWithRelation(
|
||||
String inFilterField, Set<M> inFilterValues, CourseTransStats filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取分组过滤后的数据查询结果,以及关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
@@ -106,13 +69,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,38 +1,17 @@
|
||||
package com.orange.demo.statsservice.service;
|
||||
|
||||
import com.orange.demo.statsservice.dao.*;
|
||||
import com.orange.demo.statsservice.model.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.MyWhereCriteria;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import 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-08-08
|
||||
*/
|
||||
@Service
|
||||
public class StudentActionStatsService extends BaseService<StudentActionStats, Long> {
|
||||
|
||||
@Autowired
|
||||
private StudentActionStatsMapper studentActionStatsMapper;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<StudentActionStats> mapper() {
|
||||
return studentActionStatsMapper;
|
||||
}
|
||||
public interface StudentActionStatsService extends IBaseService<StudentActionStats, Long> {
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
@@ -42,9 +21,7 @@ public class StudentActionStatsService extends BaseService<StudentActionStats, L
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<StudentActionStats> getStudentActionStatsList(StudentActionStats filter, String orderBy) {
|
||||
return studentActionStatsMapper.getStudentActionStatsList(null, null, filter, orderBy);
|
||||
}
|
||||
List<StudentActionStats> getStudentActionStatsList(StudentActionStats filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
||||
@@ -57,11 +34,7 @@ public class StudentActionStatsService extends BaseService<StudentActionStats, L
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public <M> List<StudentActionStats> getStudentActionStatsList(
|
||||
String inFilterField, Set<M> inFilterValues, StudentActionStats filter, String orderBy) {
|
||||
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, StudentActionStats.class);
|
||||
return studentActionStatsMapper.getStudentActionStatsList(inFilterColumn, inFilterValues, filter, orderBy);
|
||||
}
|
||||
<M> List<StudentActionStats> getStudentActionStatsList(String inFilterField, Set<M> inFilterValues, StudentActionStats filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
@@ -71,12 +44,7 @@ public class StudentActionStatsService extends BaseService<StudentActionStats, L
|
||||
* @param orderBy 排序对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<StudentActionStats> getStudentActionStatsListWithRelation(StudentActionStats filter, String orderBy) {
|
||||
List<StudentActionStats> resultList = studentActionStatsMapper.getStudentActionStatsList(null, null, filter, orderBy);
|
||||
Map<String, List<MyWhereCriteria>> criteriaMap = buildAggregationAdditionalWhereCriteria();
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), criteriaMap);
|
||||
return resultList;
|
||||
}
|
||||
List<StudentActionStats> getStudentActionStatsListWithRelation(StudentActionStats filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
||||
@@ -89,13 +57,8 @@ public class StudentActionStatsService extends BaseService<StudentActionStats, L
|
||||
* @param orderBy 排序对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public <M> List<StudentActionStats> getStudentActionStatsListWithRelation(
|
||||
String inFilterField, Set<M> inFilterValues, StudentActionStats filter, String orderBy) {
|
||||
List<StudentActionStats> resultList =
|
||||
studentActionStatsMapper.getStudentActionStatsList(inFilterField, inFilterValues, filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly(), null);
|
||||
return resultList;
|
||||
}
|
||||
<M> List<StudentActionStats> getStudentActionStatsListWithRelation(
|
||||
String inFilterField, Set<M> inFilterValues, StudentActionStats filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取分组过滤后的数据查询结果,以及关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
@@ -106,13 +69,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,49 +1,18 @@
|
||||
package com.orange.demo.statsservice.service;
|
||||
|
||||
import com.orange.demo.statsservice.dao.*;
|
||||
import com.orange.demo.statsservice.model.*;
|
||||
import com.orange.demo.courseclassinterface.client.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.ResponseResult;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.object.MyWhereCriteria;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.orange.demo.common.core.base.service.IBaseService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生行为流水数据操作服务类。
|
||||
* 学生行为流水数据操作服务接口。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Service
|
||||
public class StudentActionTransService extends BaseService<StudentActionTrans, Long> {
|
||||
|
||||
@Autowired
|
||||
private StudentActionTransMapper studentActionTransMapper;
|
||||
@Autowired
|
||||
private SchoolInfoClient schoolInfoClient;
|
||||
@Autowired
|
||||
private GradeClient gradeClient;
|
||||
@Autowired
|
||||
private IdGeneratorWrapper idGenerator;
|
||||
|
||||
/**
|
||||
* 返回当前Service的主表Mapper对象。
|
||||
*
|
||||
* @return 主表Mapper对象。
|
||||
*/
|
||||
@Override
|
||||
protected BaseDaoMapper<StudentActionTrans> mapper() {
|
||||
return studentActionTransMapper;
|
||||
}
|
||||
public interface StudentActionTransService extends IBaseService<StudentActionTrans, Long> {
|
||||
|
||||
/**
|
||||
* 保存新增对象。
|
||||
@@ -51,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);
|
||||
|
||||
/**
|
||||
* 更新数据对象。
|
||||
@@ -65,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);
|
||||
|
||||
/**
|
||||
* 删除指定数据。
|
||||
@@ -77,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);
|
||||
|
||||
/**
|
||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
@@ -90,9 +47,7 @@ public class StudentActionTransService extends BaseService<StudentActionTrans, L
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<StudentActionTrans> getStudentActionTransList(StudentActionTrans filter, String orderBy) {
|
||||
return studentActionTransMapper.getStudentActionTransList(null, null, filter, orderBy);
|
||||
}
|
||||
List<StudentActionTrans> getStudentActionTransList(StudentActionTrans filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
||||
@@ -105,11 +60,7 @@ public class StudentActionTransService extends BaseService<StudentActionTrans, L
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public <M> List<StudentActionTrans> getStudentActionTransList(
|
||||
String inFilterField, Set<M> inFilterValues, StudentActionTrans filter, String orderBy) {
|
||||
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, StudentActionTrans.class);
|
||||
return studentActionTransMapper.getStudentActionTransList(inFilterColumn, inFilterValues, filter, orderBy);
|
||||
}
|
||||
<M> List<StudentActionTrans> getStudentActionTransList(String inFilterField, Set<M> inFilterValues, StudentActionTrans filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
@@ -119,12 +70,7 @@ public class StudentActionTransService extends BaseService<StudentActionTrans, L
|
||||
* @param orderBy 排序对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public List<StudentActionTrans> getStudentActionTransListWithRelation(StudentActionTrans filter, String orderBy) {
|
||||
List<StudentActionTrans> resultList = studentActionTransMapper.getStudentActionTransList(null, null, filter, orderBy);
|
||||
Map<String, List<MyWhereCriteria>> criteriaMap = buildAggregationAdditionalWhereCriteria();
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), criteriaMap);
|
||||
return resultList;
|
||||
}
|
||||
List<StudentActionTrans> getStudentActionTransListWithRelation(StudentActionTrans filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
||||
@@ -137,13 +83,8 @@ public class StudentActionTransService extends BaseService<StudentActionTrans, L
|
||||
* @param orderBy 排序对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
public <M> List<StudentActionTrans> getStudentActionTransListWithRelation(
|
||||
String inFilterField, Set<M> inFilterValues, StudentActionTrans filter, String orderBy) {
|
||||
List<StudentActionTrans> resultList =
|
||||
studentActionTransMapper.getStudentActionTransList(inFilterField, inFilterValues, filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly(), null);
|
||||
return resultList;
|
||||
}
|
||||
<M> List<StudentActionTrans> getStudentActionTransListWithRelation(
|
||||
String inFilterField, Set<M> inFilterValues, StudentActionTrans filter, String orderBy);
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的远程字典数据和多对一主表数据是否都是合法数据。
|
||||
@@ -152,22 +93,5 @@ public class StudentActionTransService extends BaseService<StudentActionTrans, L
|
||||
* @param originalStudentActionTrans 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false,同时返回具体的错误信息。
|
||||
*/
|
||||
public CallResult verifyRemoteRelatedData(StudentActionTrans studentActionTrans, StudentActionTrans originalStudentActionTrans) {
|
||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
||||
if (this.needToVerify(studentActionTrans, originalStudentActionTrans, StudentActionTrans::getSchoolId)) {
|
||||
ResponseResult<Boolean> responseResult =
|
||||
schoolInfoClient.existId(studentActionTrans.getSchoolId());
|
||||
if (this.hasErrorOfVerifyRemoteRelatedData(responseResult)) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "学生校区"));
|
||||
}
|
||||
}
|
||||
if (this.needToVerify(studentActionTrans, originalStudentActionTrans, StudentActionTrans::getGradeId)) {
|
||||
ResponseResult<Boolean> responseResult =
|
||||
gradeClient.existId(studentActionTrans.getGradeId());
|
||||
if (this.hasErrorOfVerifyRemoteRelatedData(responseResult)) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "所属年级"));
|
||||
}
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
CallResult verifyRemoteRelatedData(StudentActionTrans studentActionTrans, StudentActionTrans originalStudentActionTrans);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.orange.demo.statsservice.service.impl;
|
||||
|
||||
import com.orange.demo.statsservice.service.*;
|
||||
import com.orange.demo.statsservice.dao.*;
|
||||
import com.orange.demo.statsservice.model.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
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-08-08
|
||||
*/
|
||||
@Service("courseTransStatsService")
|
||||
public class CourseTransStatsServiceImpl extends BaseService<CourseTransStats, Long> implements CourseTransStatsService {
|
||||
|
||||
@Autowired
|
||||
private CourseTransStatsMapper courseTransStatsMapper;
|
||||
|
||||
/**
|
||||
* 返回当前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(null, null, filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
||||
* 由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getCourseTransStatsListWithRelation)方法。
|
||||
*
|
||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public <M> List<CourseTransStats> getCourseTransStatsList(
|
||||
String inFilterField, Set<M> inFilterValues, CourseTransStats filter, String orderBy) {
|
||||
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, CourseTransStats.class);
|
||||
return courseTransStatsMapper.getCourseTransStatsList(inFilterColumn, inFilterValues, filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getCourseTransStatsList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<CourseTransStats> getCourseTransStatsListWithRelation(CourseTransStats filter, String orderBy) {
|
||||
List<CourseTransStats> resultList = courseTransStatsMapper.getCourseTransStatsList(null, null, filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
||||
* 同时还包含主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 如果仅仅需要获取主表数据,请移步(getCourseTransStatsList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public <M> List<CourseTransStats> getCourseTransStatsListWithRelation(
|
||||
String inFilterField, Set<M> inFilterValues, CourseTransStats filter, String orderBy) {
|
||||
List<CourseTransStats> resultList =
|
||||
courseTransStatsMapper.getCourseTransStatsList(inFilterField, inFilterValues, filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
|
||||
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,123 @@
|
||||
package com.orange.demo.statsservice.service.impl;
|
||||
|
||||
import com.orange.demo.statsservice.service.*;
|
||||
import com.orange.demo.statsservice.dao.*;
|
||||
import com.orange.demo.statsservice.model.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
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-08-08
|
||||
*/
|
||||
@Service("studentActionStatsService")
|
||||
public class StudentActionStatsServiceImpl extends BaseService<StudentActionStats, Long> implements StudentActionStatsService {
|
||||
|
||||
@Autowired
|
||||
private StudentActionStatsMapper studentActionStatsMapper;
|
||||
|
||||
/**
|
||||
* 返回当前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(null, null, filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
||||
* 由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getStudentActionStatsListWithRelation)方法。
|
||||
*
|
||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public <M> List<StudentActionStats> getStudentActionStatsList(
|
||||
String inFilterField, Set<M> inFilterValues, StudentActionStats filter, String orderBy) {
|
||||
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, StudentActionStats.class);
|
||||
return studentActionStatsMapper.getStudentActionStatsList(inFilterColumn, inFilterValues, filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentActionStatsList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<StudentActionStats> getStudentActionStatsListWithRelation(StudentActionStats filter, String orderBy) {
|
||||
List<StudentActionStats> resultList = studentActionStatsMapper.getStudentActionStatsList(null, null, filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
||||
* 同时还包含主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentActionStatsList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public <M> List<StudentActionStats> getStudentActionStatsListWithRelation(
|
||||
String inFilterField, Set<M> inFilterValues, StudentActionStats filter, String orderBy) {
|
||||
List<StudentActionStats> resultList =
|
||||
studentActionStatsMapper.getStudentActionStatsList(inFilterField, inFilterValues, filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
|
||||
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,182 @@
|
||||
package com.orange.demo.statsservice.service.impl;
|
||||
|
||||
import com.orange.demo.statsservice.service.*;
|
||||
import com.orange.demo.statsservice.dao.*;
|
||||
import com.orange.demo.statsservice.model.*;
|
||||
import com.orange.demo.courseclassinterface.client.*;
|
||||
import com.orange.demo.common.core.util.*;
|
||||
import com.orange.demo.common.core.object.MyRelationParam;
|
||||
import com.orange.demo.common.core.object.ResponseResult;
|
||||
import com.orange.demo.common.core.object.CallResult;
|
||||
import com.orange.demo.common.core.base.dao.BaseDaoMapper;
|
||||
import com.orange.demo.common.core.base.service.BaseService;
|
||||
import com.orange.demo.common.sequence.wrapper.IdGeneratorWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 学生行为流水数据操作服务类。
|
||||
*
|
||||
* @author Jerry
|
||||
* @date 2020-08-08
|
||||
*/
|
||||
@Service("studentActionTransService")
|
||||
public class StudentActionTransServiceImpl extends BaseService<StudentActionTrans, Long> implements StudentActionTransService {
|
||||
|
||||
@Autowired
|
||||
private StudentActionTransMapper studentActionTransMapper;
|
||||
@Autowired
|
||||
private SchoolInfoClient schoolInfoClient;
|
||||
@Autowired
|
||||
private GradeClient gradeClient;
|
||||
@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(null, null, filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
||||
* 由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
||||
* 如果需要同时获取关联数据,请移步(getStudentActionTransListWithRelation)方法。
|
||||
*
|
||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
||||
* @param filter 过滤对象。
|
||||
* @param orderBy 排序参数。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public <M> List<StudentActionTrans> getStudentActionTransList(
|
||||
String inFilterField, Set<M> inFilterValues, StudentActionTrans filter, String orderBy) {
|
||||
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, StudentActionTrans.class);
|
||||
return studentActionTransMapper.getStudentActionTransList(inFilterColumn, inFilterValues, filter, orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentActionTransList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public List<StudentActionTrans> getStudentActionTransListWithRelation(StudentActionTrans filter, String orderBy) {
|
||||
List<StudentActionTrans> resultList = studentActionTransMapper.getStudentActionTransList(null, null, filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
||||
* 同时还包含主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
||||
* 如果仅仅需要获取主表数据,请移步(getStudentActionTransList),以便获取更好的查询性能。
|
||||
*
|
||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
||||
* @param filter 主表过滤对象。
|
||||
* @param orderBy 排序对象。
|
||||
* @return 查询结果集。
|
||||
*/
|
||||
@Override
|
||||
public <M> List<StudentActionTrans> getStudentActionTransListWithRelation(
|
||||
String inFilterField, Set<M> inFilterValues, StudentActionTrans filter, String orderBy) {
|
||||
List<StudentActionTrans> resultList =
|
||||
studentActionTransMapper.getStudentActionTransList(inFilterField, inFilterValues, filter, orderBy);
|
||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据最新对象和原有对象的数据对比,判断关联的远程字典数据和多对一主表数据是否都是合法数据。
|
||||
*
|
||||
* @param studentActionTrans 最新数据对象。
|
||||
* @param originalStudentActionTrans 原有数据对象。
|
||||
* @return 数据全部正确返回true,否则false,同时返回具体的错误信息。
|
||||
*/
|
||||
@Override
|
||||
public CallResult verifyRemoteRelatedData(StudentActionTrans studentActionTrans, StudentActionTrans originalStudentActionTrans) {
|
||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
||||
if (this.needToVerify(studentActionTrans, originalStudentActionTrans, StudentActionTrans::getSchoolId)) {
|
||||
ResponseResult<Boolean> responseResult =
|
||||
schoolInfoClient.existId(studentActionTrans.getSchoolId());
|
||||
if (this.hasErrorOfVerifyRemoteRelatedData(responseResult)) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "学生校区"));
|
||||
}
|
||||
}
|
||||
if (this.needToVerify(studentActionTrans, originalStudentActionTrans, StudentActionTrans::getGradeId)) {
|
||||
ResponseResult<Boolean> responseResult =
|
||||
gradeClient.existId(studentActionTrans.getGradeId());
|
||||
if (this.hasErrorOfVerifyRemoteRelatedData(responseResult)) {
|
||||
return CallResult.error(String.format(errorMessageFormat, "所属年级"));
|
||||
}
|
||||
}
|
||||
return CallResult.ok();
|
||||
}
|
||||
}
|
||||
@@ -83,12 +83,12 @@
|
||||
<orderEntry type="library" name="Maven: tk.mybatis:mapper-spring:1.1.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: tk.mybatis:mapper-extra:1.1.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: tk.mybatis:mapper-spring-boot-autoconfigure:2.1.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.2.13" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.2.13" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.1.11" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:2.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.2.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:3.2" level="project" />
|
||||
<orderEntry type="module" module-name="common-swagger" />
|
||||
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-micro-spring-boot-starter:2.0.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring-boot-autoconfigure:2.0.5" level="project" />
|
||||
|
||||
Reference in New Issue
Block a user