mirror of
https://gitee.com/orangeform/orange-admin.git
synced 2026-01-17 10:36:31 +08:00
删除文件 orange-demo-multi
This commit is contained in:
@@ -1,26 +0,0 @@
|
|||||||
target/
|
|
||||||
!.mvn/wrapper/maven-wrapper.jar
|
|
||||||
/.mvn/*
|
|
||||||
|
|
||||||
### STS ###
|
|
||||||
.apt_generated
|
|
||||||
.classpath
|
|
||||||
.factorypath
|
|
||||||
.project
|
|
||||||
.settings
|
|
||||||
.springBeans
|
|
||||||
.sts4-cache
|
|
||||||
|
|
||||||
### IntelliJ IDEA ###
|
|
||||||
.idea
|
|
||||||
*.iws
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
|
|
||||||
### NetBeans ###
|
|
||||||
/nbproject/private/
|
|
||||||
/build/
|
|
||||||
/nbbuild/
|
|
||||||
/dist/
|
|
||||||
/nbdist/
|
|
||||||
/.nb-gradle/
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
### 必知要点
|
|
||||||
---
|
|
||||||
在该文档中,我们将主要介绍开发和调试阶段,系统所依赖的服务组件的启动与控制台访问方式。
|
|
||||||
|
|
||||||
1. 我们目前提供的启动方式包括,docker-compose和本地命令行两种方式。推荐操作更为简便的docker-compose方式。
|
|
||||||
2. 对于基础服务组件,如注册中心(nacos/consul)、配置中心(nacos/consul)、Redis、Zookeeper和Kafka,均可通过docker-compose的方式启动。
|
|
||||||
与此同时,我们也为这些服务组件提供了本地启动文档,具体详见开发文档中[环境准备章节](http://www.orangeforms.com/development-doc/environment/)。
|
|
||||||
3. 出于某些原因,apollo配置中心和skywalking,我们目前尚未提供docker-compose方式,因此只能通过本地命令行的方式启动。
|
|
||||||
具体详见开发文档中[环境准备章节](http://www.orangeforms.com/development-doc/environment/)。
|
|
||||||
4. ELK、Prometheus、Grafana和PinPoint,由于不会影响正常的开发和调试,我们目前仅提供了docker-compose的启动方式。
|
|
||||||
|
|
||||||
最后,我们真诚的希望能够得到您的反馈,并持续改进我们的产品、文档、服务和操作流程。
|
|
||||||
### 服务接口文档
|
|
||||||
---
|
|
||||||
- Knife4j
|
|
||||||
- 服务启动后,Knife4j的文档入口地址 [http://localhost:8082/doc.html#/plus](http://localhost:8082/doc.html#/plus)
|
|
||||||
- Postman
|
|
||||||
- 无需启动服务,即可将当前工程的接口导出成Postman格式。在工程的common/common-tools/模块下,找到ExportApiApp文件,并执行main函数。
|
|
||||||
|
|
||||||
### 系统依赖服务组件
|
|
||||||
---
|
|
||||||
当前工程所有微服务启动前,需将下列服务组件依次启动,可选组件可根据实际需要决定是否启动。
|
|
||||||
> 如果采用本地启动方式,启动顺序如下。docker-compose方式,脚本文件中已经编排好启动顺序。
|
|
||||||
- Redis
|
|
||||||
- 版本:4
|
|
||||||
- 端口: 6379
|
|
||||||
- 推荐客户端工具 [AnotherRedisDesktopManager](https://github.com/qishibo/AnotherRedisDesktopManager)
|
|
||||||
- Zookeeper
|
|
||||||
- 版本:3.5.5
|
|
||||||
- 端口:2181
|
|
||||||
- 推荐客户端工具 [zkui](https://github.com/DeemOpen/zkui)
|
|
||||||
- Kafka
|
|
||||||
- 版本:2.12-2.4.0
|
|
||||||
- 端口:9092
|
|
||||||
- 推荐客户端工具 [Kafka Tool](http://www.kafkatool.com/download.html)
|
|
||||||
- Nacos
|
|
||||||
- 版本:1.3.1
|
|
||||||
- 控制台URL:localhost:8848/nacos
|
|
||||||
- 用户名密码:nacos/nacos
|
|
||||||
- Sentinel-Dashboard (可选)
|
|
||||||
- 版本:1.7.2
|
|
||||||
- 控制台URL: localhost:8858
|
|
||||||
- 用户名密码:sentinel/sentinel
|
|
||||||
- 注意:该服务缺省端口为8080,容易冲突,所以改为8858。我们在所有的配置中均使用了8858,而非8080。
|
|
||||||
- ELK (可选,docker-compose-elk)
|
|
||||||
- 版本:7.5.x
|
|
||||||
- Kibana控制台URL:localhost:5601
|
|
||||||
- SkyWalking (可选,仅当尝试使用SkyWalking进行链路跟踪时使用)
|
|
||||||
- 版本:8.1.x
|
|
||||||
- 控制台URL:localhost:8095
|
|
||||||
- 注意:该服务缺省端口为8080,容易冲突,所以改为8095。具体修改方式参考开发文档[环境准备章节](http://www.orangeforms.com/development-doc/environment/#skywalking)
|
|
||||||
- admin-monitor服务模块 (可选)
|
|
||||||
- 控制台URL:localhost:8769
|
|
||||||
- XXL-Job (可选,仅当启动Job服务时使用)
|
|
||||||
- 重要声明:xxl_job 官网仅提供对mysql的支持,如果您在橙单中选择了postgresql,xxl-job-admin仍需依赖mysql。
|
|
||||||
- 版本:2.2.0
|
|
||||||
- 控制台URL:localhost:8081/xxl-job-admin/
|
|
||||||
- 注意:该服务缺省端口为8080,容易冲突,所以改为了8081。我们在所有的配置中均使用了8081,而非8080。
|
|
||||||
- 用户名密码:admin/123456
|
|
||||||
- 启动upms服务 (保证登录和用户权限服务可用)
|
|
||||||
- 启动其他业务应用微服务<br>
|
|
||||||
推荐在gateway服务之前启动,以便gateway服务启动后可以即刻发现服务。由于gateway是从注册中心定时拉取微服务信息,所以在gateway之后启动的微服务,通常会延迟一小段时间之后才会被发现。
|
|
||||||
- 启动gateway网关服务<br>
|
|
||||||
在所有微服务之后启动,启动后即可发现所有微服务。仅有被gateway发现的微服务,该服务的请求才可以被正常转发。
|
|
||||||
|
|
||||||
### 服务组件启动
|
|
||||||
---
|
|
||||||
> 下述文件位于工程目录的zz-resource/docker-files子目录内。
|
|
||||||
- docker-compose.yml (必须)
|
|
||||||
- 包含系统所需的必备组件,如注册中心、配置中心、Sentinel-Dashboard、Redis、Kafka和Zookeeper。
|
|
||||||
- 第一次启动方式为 docker-compose up -d
|
|
||||||
- 停止方式推荐为 docker-compose stop
|
|
||||||
- 再次启动方式推荐为 docker-compose start
|
|
||||||
- 强行停止方式为 docker-compose down
|
|
||||||
- 强行停止后再次启动,可能导致kafka和zookeeper出现数据错误,执行./clear-data.sh可清空部分临时数据。
|
|
||||||
- 清空后再次执行docker-compose up -d 即可。
|
|
||||||
- docker-compose start和docker-compose stop不会出现该类数据问题。
|
|
||||||
- 查看启动日志命令 docker-compose logs
|
|
||||||
- docker-compose-full.yml (可选)
|
|
||||||
- 包含全部服务的启动项,基础服务 + elk + gp。
|
|
||||||
- 启动方式为 docker-compose -f docker-compose-full.yml up -d
|
|
||||||
- 停止方式和数据错误处理方式,请参考上面docker-compose.yml的说明。
|
|
||||||
- Skywalking服务启动 (可选)
|
|
||||||
- 启动方式,目前仅支持命令行方式,具体参考开发文档中[环境准备章节](http://www.orangeforms.com/development-doc/environment/#skywalking)
|
|
||||||
|
|
||||||
### 本地命令行启动方式
|
|
||||||
---
|
|
||||||
1. Nacos、Consul、Sentinel、Apollo、XXL-Job、Redis、Kafka、Zookeeper、Skywalking的本地启动方式,请参考开发文档中[环境准备章节](http://www.orangeforms.com/development-doc/environment/)。
|
|
||||||
2. ELK、Grafana、Prometheus、Pinpoint目前仅提供docker-compose方式。
|
|
||||||
3. 再次强调,通过本地命令行启动所有系统服务组件时,启动顺序一定要和上面"系统依赖服务组件"部分列出的服务顺序保持一致,因为服务组件之间是有依赖的。
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>application-consumer</artifactId>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>operation-log-consumer</artifactId>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>common-log</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<includes>
|
|
||||||
<include>**/*.*</include>
|
|
||||||
</includes>
|
|
||||||
<filtering>false</filtering>
|
|
||||||
</resource>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/java</directory>
|
|
||||||
<includes>
|
|
||||||
<include>**/*.xml</include>
|
|
||||||
</includes>
|
|
||||||
<filtering>false</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.orangeforms.operationlogconsumer;
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 操作日志消费者服务启动类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@ComponentScan("com.orangeforms")
|
|
||||||
@EnableDiscoveryClient
|
|
||||||
@SpringBootApplication
|
|
||||||
public class OperationLogConsumerApplication {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(OperationLogConsumerApplication.class, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.orangeforms.operationlogconsumer.config;
|
|
||||||
|
|
||||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据源配置Bean对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
@EnableTransactionManagement
|
|
||||||
@MapperScan(value = {"com.orangeforms.*.dao", "com.orangeforms.common.*.dao"})
|
|
||||||
public class DataSourceConfig {
|
|
||||||
|
|
||||||
@Bean(initMethod = "init", destroyMethod = "close")
|
|
||||||
@Primary
|
|
||||||
@ConfigurationProperties(prefix = "spring.datasource.druid")
|
|
||||||
public DataSource druidDataSource() {
|
|
||||||
return DruidDataSourceBuilder.create().build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
package com.orangeforms.operationlogconsumer.consumer;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.orangeforms.common.log.model.SysOperationLog;
|
|
||||||
import com.orangeforms.common.log.service.SysOperationLogService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.dao.DuplicateKeyException;
|
|
||||||
import org.springframework.kafka.annotation.KafkaListener;
|
|
||||||
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
|
|
||||||
import org.springframework.kafka.config.KafkaListenerContainerFactory;
|
|
||||||
import org.springframework.kafka.core.ConsumerFactory;
|
|
||||||
import org.springframework.kafka.listener.ContainerProperties;
|
|
||||||
import org.springframework.kafka.support.Acknowledgment;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 各个微服务操作日志的消费者对象。该消费者会集中处理操作日志。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class OperationLogConsumer {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SysOperationLogService sysOperationLogService;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public KafkaListenerContainerFactory<?> batchFactory(ConsumerFactory<Integer, String> consumerFactory) {
|
|
||||||
ConcurrentKafkaListenerContainerFactory<Integer, String> factory =
|
|
||||||
new ConcurrentKafkaListenerContainerFactory<>();
|
|
||||||
factory.setConsumerFactory(consumerFactory);
|
|
||||||
factory.setConcurrency(10);
|
|
||||||
factory.getContainerProperties().setPollTimeout(1500);
|
|
||||||
//设置为批量消费,每个批次数量在Kafka配置参数中设置
|
|
||||||
factory.setBatchListener(true);
|
|
||||||
factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL_IMMEDIATE);
|
|
||||||
return factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@KafkaListener(
|
|
||||||
topics = {"${common-log.operation-log.kafkaTopic}"},
|
|
||||||
containerFactory = "batchFactory",
|
|
||||||
groupId = "operation-log")
|
|
||||||
public void listen(List<ConsumerRecord<?, ?>> recordList, Acknowledgment ack) {
|
|
||||||
if (CollectionUtils.isNotEmpty(recordList)) {
|
|
||||||
List<SysOperationLog> operationLogList = new LinkedList<>();
|
|
||||||
for (ConsumerRecord<?, ?> record : recordList) {
|
|
||||||
Optional<?> message = Optional.ofNullable(record.value());
|
|
||||||
if (message.isPresent()) {
|
|
||||||
SysOperationLog operationLog =
|
|
||||||
JSON.parseObject(message.get().toString(), SysOperationLog.class);
|
|
||||||
operationLogList.add(operationLog);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isNotEmpty(operationLogList)) {
|
|
||||||
try {
|
|
||||||
sysOperationLogService.batchSave(operationLogList);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Failed to batchSave SysOperationLog and try again one by one", e);
|
|
||||||
this.safeSave(operationLogList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ack.acknowledge();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void safeSave(List<SysOperationLog> operationLogList) {
|
|
||||||
for (SysOperationLog operationLog : operationLogList) {
|
|
||||||
try {
|
|
||||||
// 如果批量插入失败,为了确保最大限度的将操作日志数据插入到目的表。
|
|
||||||
// 这里我们将逐条插入,对于重复插入直接忽略错误,对于其他异常,需要用户修改后自行处理。
|
|
||||||
sysOperationLogService.saveNew(operationLog);
|
|
||||||
} catch (DuplicateKeyException e1) {
|
|
||||||
// 出现重复的场景,很大可能是因为之前插入数据库成功了,但是提交kafka offset失败了。
|
|
||||||
// 因此就会出现重复消费的情况,我们通过logId主键进行了去重。
|
|
||||||
log.warn("Duplicated Key for logId [{}]", operationLog.getLogId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
spring:
|
|
||||||
application:
|
|
||||||
name: operation-log-consumer
|
|
||||||
profiles:
|
|
||||||
active: dev
|
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
discovery:
|
|
||||||
server-addr: localhost:8848
|
|
||||||
config:
|
|
||||||
server-addr: localhost:8848
|
|
||||||
file-extension: yaml
|
|
||||||
# 共享配置文件,排序越高后,优先级越高。
|
|
||||||
shared-configs:
|
|
||||||
- data-id: application-dev.yaml
|
|
||||||
group: DEFAULT_GROUP
|
|
||||||
refresh: true
|
|
||||||
main:
|
|
||||||
allow-bean-definition-overriding: true
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!-- 本项目全部使用log4j2性能上有很大提升 -->
|
|
||||||
|
|
||||||
<!--monitorInterval="60" 自动检测配置文件更改时间 单位为秒 最小值为5 -->
|
|
||||||
<!--Configuration后面的status,这个用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,你会看到log4j2内部各种详细输出。 -->
|
|
||||||
<configuration monitorInterval="20" status="OFF">
|
|
||||||
<!--日志变量 -->
|
|
||||||
<properties>
|
|
||||||
<!-- 日志主目录 ,需要保存到文件时请自己配置-->
|
|
||||||
<property name="LOG_HOME">./zzlogs/operation-log-consumer</property>
|
|
||||||
<!-- 日志备份目录 -->
|
|
||||||
<property name="BACKUP_HOME">./zzlogs/operation-log-consumer/backup</property>
|
|
||||||
<!-- 日志输出级别 -->
|
|
||||||
<property name="OUTPUT_LOG_LEVEL">info</property>
|
|
||||||
<!-- 日志输出格式 -->
|
|
||||||
<property name="LOG_PATTERN">
|
|
||||||
<!-- 输出格式%d{HH:mm:ss}时间24小时制 -->
|
|
||||||
<!-- %-5p日志级别 5位左对齐 [%t]线程名 [%c]类名 -->
|
|
||||||
<!--%l:输出日志事件的发生位置,相当于%c.%M(%F:%L)的组合,包括类全名、方法、文件名以及在代码中的行数。例如:test.TestLog4j.main(TestLog4j.java:10)。 -->
|
|
||||||
<!-- 另一种输出风格<PatternLayout pattern="级别%-5p [%d{YYYY-MM-dd HH:mm:ss}] [%t] 位置[%l] - 信息:%msg%n" /> -->
|
|
||||||
<!-- [%-5p][%d{yy-MM-dd HH:mm:ss}][%t]==>%m==>%c==>%L%n -->
|
|
||||||
[%-5p] [%d{YYYY-MM-dd HH:mm:ss}] [%t] ==> %msg%n
|
|
||||||
</property>
|
|
||||||
<property name="LOG_PATTERN_EX">
|
|
||||||
<!-- 下面注释中 %traceid 为SkyWalking 中的traceid -->
|
|
||||||
[%-5p] [%d{YYYY-MM-dd HH:mm:ss}] [%t] ==> [%traceId] %msg%n
|
|
||||||
</property>
|
|
||||||
<!-- 日志保留天数 -->
|
|
||||||
<property name="EVERY_FILE_COUNT">31</property>
|
|
||||||
<!-- 日志切割的最小单位 -->
|
|
||||||
<property name="EVERY_FILE_SIZE">20M</property>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<appenders>
|
|
||||||
<!--Kafka输出 -->
|
|
||||||
<Kafka name="kafka_log" topic="zz-log-topic" syncSend="false" ignoreExceptions="false">
|
|
||||||
<PatternLayout pattern="${LOG_PATTERN_EX}"/>
|
|
||||||
<Property name="bootstrap.servers">localhost:9092</Property>
|
|
||||||
<Property name="max.block.ms">10000</Property>
|
|
||||||
</Kafka>
|
|
||||||
<!--控制台输出 -->
|
|
||||||
<console name="console" target="SYSTEM_OUT">
|
|
||||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
|
||||||
</console>
|
|
||||||
<!--每次大小超过size,则这size大小的日志会自动进行压缩,作为存档 -->
|
|
||||||
<rollingFile name="file_log" fileName="${LOG_HOME}/operation-log-consumer.log"
|
|
||||||
filePattern="${LOG_HOME}/operation-log-consumer-%d{yyyy-MM-dd}-%i.log.gz">
|
|
||||||
<PatternLayout charset="UTF-8" pattern="${LOG_PATTERN_EX}"/>
|
|
||||||
<!-- 日志切割的最小单位 -->
|
|
||||||
<SizeBasedTriggeringPolicy size="${EVERY_FILE_SIZE}"/>
|
|
||||||
<!-- 默认的日志文件数量 -->
|
|
||||||
<DefaultRolloverStrategy max="${EVERY_FILE_COUNT}"/>
|
|
||||||
</rollingFile>
|
|
||||||
</appenders>
|
|
||||||
|
|
||||||
<!-- 然后定义logger,只有定义了logger并引入的appender,appender才会生效 -->
|
|
||||||
<!-- 这里我们把输出到控制台appender的日志级别设置为DEBUG,便于调试。但是输出文件我们缺省为INFO,两者均可随时修改。-->
|
|
||||||
<Loggers>
|
|
||||||
<Root level="${OUTPUT_LOG_LEVEL}">
|
|
||||||
<AppenderRef ref="console"/>
|
|
||||||
</Root>
|
|
||||||
<AsyncLogger name="com.orangeforms" additivity="false" level="info">
|
|
||||||
<AppenderRef ref="console"/>
|
|
||||||
<AppenderRef ref="kafka_log"/>
|
|
||||||
<AppenderRef ref="file_log"/>
|
|
||||||
</AsyncLogger>
|
|
||||||
<!-- 这里将dao的日志级别设置为DEBUG,是为了SQL语句的输出 -->
|
|
||||||
<AsyncLogger name="com.orangeforms.operationlogconsumer.dao" additivity="false" level="debug">
|
|
||||||
<AppenderRef ref="console"/>
|
|
||||||
<AppenderRef ref="kafka_log"/>
|
|
||||||
<AppenderRef ref="file_log"/>
|
|
||||||
</AsyncLogger>
|
|
||||||
<AsyncLogger name="com.orangeforms.common.log.dao" additivity="false" level="debug">
|
|
||||||
<AppenderRef ref="console"/>
|
|
||||||
<AppenderRef ref="kafka_log"/>
|
|
||||||
<AppenderRef ref="file_log"/>
|
|
||||||
</AsyncLogger>
|
|
||||||
</Loggers>
|
|
||||||
</configuration>
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>OrangeMultiDemo</artifactId>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>application-consumer</artifactId>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
<modules>
|
|
||||||
<module>operation-log-consumer</module>
|
|
||||||
</modules>
|
|
||||||
<dependencies>
|
|
||||||
<!--nacos 服务发现客户端-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>application</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>application-common</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<name>application-common</name>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
</project>
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package com.orangeforms.application.common.constant;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备类型常量字典对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public final class DeviceType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* iOS。
|
|
||||||
*/
|
|
||||||
public static final int IOS = 0;
|
|
||||||
/**
|
|
||||||
* Android。
|
|
||||||
*/
|
|
||||||
public static final int ANDROID = 1;
|
|
||||||
/**
|
|
||||||
* PC。
|
|
||||||
*/
|
|
||||||
public static final int PC = 2;
|
|
||||||
|
|
||||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(3);
|
|
||||||
static {
|
|
||||||
DICT_MAP.put(IOS, "iOS");
|
|
||||||
DICT_MAP.put(ANDROID, "Android");
|
|
||||||
DICT_MAP.put(PC, "PC");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数是否为当前常量字典的合法值。
|
|
||||||
*
|
|
||||||
* @param value 待验证的参数值。
|
|
||||||
* @return 合法返回true,否则false。
|
|
||||||
*/
|
|
||||||
public static boolean isValid(Integer value) {
|
|
||||||
return value != null && DICT_MAP.containsKey(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私有构造函数,明确标识该常量类的作用。
|
|
||||||
*/
|
|
||||||
private DeviceType() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package com.orangeforms.application.common.constant;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 经验等级常量字典对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public final class ExpLevel {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初级学员。
|
|
||||||
*/
|
|
||||||
public static final int LOWER = 0;
|
|
||||||
/**
|
|
||||||
* 中级学员。
|
|
||||||
*/
|
|
||||||
public static final int MIDDLE = 1;
|
|
||||||
/**
|
|
||||||
* 高级学员。
|
|
||||||
*/
|
|
||||||
public static final int HIGH = 2;
|
|
||||||
|
|
||||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(3);
|
|
||||||
static {
|
|
||||||
DICT_MAP.put(LOWER, "初级学员");
|
|
||||||
DICT_MAP.put(MIDDLE, "中级学员");
|
|
||||||
DICT_MAP.put(HIGH, "高级学员");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数是否为当前常量字典的合法值。
|
|
||||||
*
|
|
||||||
* @param value 待验证的参数值。
|
|
||||||
* @return 合法返回true,否则false。
|
|
||||||
*/
|
|
||||||
public static boolean isValid(Integer value) {
|
|
||||||
return value != null && DICT_MAP.containsKey(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私有构造函数,明确标识该常量类的作用。
|
|
||||||
*/
|
|
||||||
private ExpLevel() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package com.orangeforms.application.common.constant;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 性别常量字典对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public final class Gender {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 男。
|
|
||||||
*/
|
|
||||||
public static final int MALE = 1;
|
|
||||||
/**
|
|
||||||
* 女。
|
|
||||||
*/
|
|
||||||
public static final int FEMALE = 0;
|
|
||||||
|
|
||||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(2);
|
|
||||||
static {
|
|
||||||
DICT_MAP.put(MALE, "男");
|
|
||||||
DICT_MAP.put(FEMALE, "女");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数是否为当前常量字典的合法值。
|
|
||||||
*
|
|
||||||
* @param value 待验证的参数值。
|
|
||||||
* @return 合法返回true,否则false。
|
|
||||||
*/
|
|
||||||
public static boolean isValid(Integer value) {
|
|
||||||
return value != null && DICT_MAP.containsKey(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私有构造函数,明确标识该常量类的作用。
|
|
||||||
*/
|
|
||||||
private Gender() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
package com.orangeforms.application.common.constant;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生行为常量字典对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public final class StudentActionType {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 充值。
|
|
||||||
*/
|
|
||||||
public static final int RECHARGE = 0;
|
|
||||||
/**
|
|
||||||
* 购课。
|
|
||||||
*/
|
|
||||||
public static final int BUY_COURSE = 1;
|
|
||||||
/**
|
|
||||||
* 上课签到。
|
|
||||||
*/
|
|
||||||
public static final int SIGNIN_COURSE = 2;
|
|
||||||
/**
|
|
||||||
* 上课签退。
|
|
||||||
*/
|
|
||||||
public static final int SIGNOUT_COURSE = 3;
|
|
||||||
/**
|
|
||||||
* 看视频课。
|
|
||||||
*/
|
|
||||||
public static final int WATCH_VIDEO = 4;
|
|
||||||
/**
|
|
||||||
* 做作业。
|
|
||||||
*/
|
|
||||||
public static final int DO_PAPER = 5;
|
|
||||||
/**
|
|
||||||
* 刷题。
|
|
||||||
*/
|
|
||||||
public static final int REFRESH_EXERCISE = 6;
|
|
||||||
/**
|
|
||||||
* 献花。
|
|
||||||
*/
|
|
||||||
public static final int PRESENT_FLOWER = 7;
|
|
||||||
/**
|
|
||||||
* 购买视频课。
|
|
||||||
*/
|
|
||||||
public static final int BUY_VIDEO_COURSE = 8;
|
|
||||||
/**
|
|
||||||
* 购买鲜花。
|
|
||||||
*/
|
|
||||||
public static final int BUY_FLOWER = 9;
|
|
||||||
/**
|
|
||||||
* 购买作业。
|
|
||||||
*/
|
|
||||||
public static final int BUY_PAPER = 10;
|
|
||||||
|
|
||||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(11);
|
|
||||||
static {
|
|
||||||
DICT_MAP.put(RECHARGE, "充值");
|
|
||||||
DICT_MAP.put(BUY_COURSE, "购课");
|
|
||||||
DICT_MAP.put(SIGNIN_COURSE, "上课签到");
|
|
||||||
DICT_MAP.put(SIGNOUT_COURSE, "上课签退");
|
|
||||||
DICT_MAP.put(WATCH_VIDEO, "看视频课");
|
|
||||||
DICT_MAP.put(DO_PAPER, "做作业");
|
|
||||||
DICT_MAP.put(REFRESH_EXERCISE, "刷题");
|
|
||||||
DICT_MAP.put(PRESENT_FLOWER, "献花");
|
|
||||||
DICT_MAP.put(BUY_VIDEO_COURSE, "购买视频课");
|
|
||||||
DICT_MAP.put(BUY_FLOWER, "购买鲜花");
|
|
||||||
DICT_MAP.put(BUY_PAPER, "购买作业");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数是否为当前常量字典的合法值。
|
|
||||||
*
|
|
||||||
* @param value 待验证的参数值。
|
|
||||||
* @return 合法返回true,否则false。
|
|
||||||
*/
|
|
||||||
public static boolean isValid(Integer value) {
|
|
||||||
return value != null && DICT_MAP.containsKey(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私有构造函数,明确标识该常量类的作用。
|
|
||||||
*/
|
|
||||||
private StudentActionType() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package com.orangeforms.application.common.constant;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生状态常量字典对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public final class StudentStatus {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 正常。
|
|
||||||
*/
|
|
||||||
public static final int NORMAL = 0;
|
|
||||||
/**
|
|
||||||
* 锁定。
|
|
||||||
*/
|
|
||||||
public static final int LOCKED = 1;
|
|
||||||
/**
|
|
||||||
* 注销。
|
|
||||||
*/
|
|
||||||
public static final int DELETED = 2;
|
|
||||||
|
|
||||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(3);
|
|
||||||
static {
|
|
||||||
DICT_MAP.put(NORMAL, "正常");
|
|
||||||
DICT_MAP.put(LOCKED, "锁定");
|
|
||||||
DICT_MAP.put(DELETED, "注销");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数是否为当前常量字典的合法值。
|
|
||||||
*
|
|
||||||
* @param value 待验证的参数值。
|
|
||||||
* @return 合法返回true,否则false。
|
|
||||||
*/
|
|
||||||
public static boolean isValid(Integer value) {
|
|
||||||
return value != null && DICT_MAP.containsKey(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私有构造函数,明确标识该常量类的作用。
|
|
||||||
*/
|
|
||||||
private StudentStatus() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package com.orangeforms.application.common.constant;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学科常量字典对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public final class Subject {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 语文。
|
|
||||||
*/
|
|
||||||
public static final int CHINESE = 0;
|
|
||||||
/**
|
|
||||||
* 数学。
|
|
||||||
*/
|
|
||||||
public static final int MATCH = 1;
|
|
||||||
/**
|
|
||||||
* 英语。
|
|
||||||
*/
|
|
||||||
public static final int ENGLISH = 2;
|
|
||||||
|
|
||||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(3);
|
|
||||||
static {
|
|
||||||
DICT_MAP.put(CHINESE, "语文");
|
|
||||||
DICT_MAP.put(MATCH, "数学");
|
|
||||||
DICT_MAP.put(ENGLISH, "英语");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数是否为当前常量字典的合法值。
|
|
||||||
*
|
|
||||||
* @param value 待验证的参数值。
|
|
||||||
* @return 合法返回true,否则false。
|
|
||||||
*/
|
|
||||||
public static boolean isValid(Integer value) {
|
|
||||||
return value != null && DICT_MAP.containsKey(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私有构造函数,明确标识该常量类的作用。
|
|
||||||
*/
|
|
||||||
private Subject() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>course-class</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>course-class-api</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<name>course-class-api</name>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- 通用业务依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>application-common</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- 通用组件依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>common-core</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>common-datafilter</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- knife4j 接口文档框架 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>common-swagger</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.client;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.client.BaseFallbackFactory;
|
|
||||||
import com.orangeforms.common.core.base.client.BaseClient;
|
|
||||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.courseclassapi.dto.AreaCodeDto;
|
|
||||||
import com.orangeforms.courseclassapi.vo.AreaCodeVo;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行政区划远程访问接口类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@FeignClient(name = "course-class", fallbackFactory = AreaCodeClient.AreaCodeClientFallbackFactory.class)
|
|
||||||
public interface AreaCodeClient extends BaseClient<AreaCodeDto, AreaCodeVo, Long> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键Id集合,返回给定的数据集合。
|
|
||||||
*
|
|
||||||
* @param areaCodeIds 待获取的主键Id列表。
|
|
||||||
* @param withDict 是否包含字典关联。
|
|
||||||
* @return 获取的对象列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/areaCode/listByIds")
|
|
||||||
ResponseResult<List<AreaCodeVo>> listByIds(
|
|
||||||
@RequestParam("areaCodeIds") Set<Long> areaCodeIds,
|
|
||||||
@RequestParam("withDict") Boolean withDict);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键Id返回给定的数据。
|
|
||||||
*
|
|
||||||
* @param areaId 待获取的主键Id。
|
|
||||||
* @param withDict 是否获取表实体关联的字典数据。
|
|
||||||
* @return 获取的对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@GetMapping("/areaCode/getById")
|
|
||||||
ResponseResult<AreaCodeVo> getById(
|
|
||||||
@RequestParam("areaId") Long areaId,
|
|
||||||
@RequestParam("withDict") Boolean withDict);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数列表中指定的主键Id,是否全部存在。
|
|
||||||
*
|
|
||||||
* @param areaIds 主键Id。
|
|
||||||
* @return 应答结果对象,包含true全部存在,否则false。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@GetMapping("/areaCode/existIds")
|
|
||||||
ResponseResult<Boolean> existIds(@RequestParam("areaIds") Set<Long> areaIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 给定主键Id是否存在。
|
|
||||||
*
|
|
||||||
* @param areaId 参数主键Id。
|
|
||||||
* @return 应答结果对象,包含true,否则false。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@GetMapping("/areaCode/existId")
|
|
||||||
ResponseResult<Boolean> existId(@RequestParam("areaId") Long areaId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的数据列表。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含实体对象集合。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/areaCode/listBy")
|
|
||||||
ResponseResult<MyPageData<AreaCodeVo>> listBy(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的单条数据对象。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含实体对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/areaCode/getBy")
|
|
||||||
ResponseResult<AreaCodeVo> getBy(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 以id、name的形式返回所有字典数据的列表。
|
|
||||||
*
|
|
||||||
* @return 字典数据列表,返回形式为 List<Map<String, Object>>,map中包含两条记录,分别是id和name。
|
|
||||||
*/
|
|
||||||
@PostMapping("/areaCode/listDict")
|
|
||||||
ResponseResult<List<Map<String, Object>>> listDict();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 以id、name的形式返回所有字典数据的列表。
|
|
||||||
*
|
|
||||||
* @param parentId 主键的ParentId,用于对主键数据进行过滤。
|
|
||||||
* @return 字典数据列表,返回形式为 List<Map<String, Object>>,map中包含两条记录,分别是id和name。
|
|
||||||
*/
|
|
||||||
@GetMapping("/areaCode/listDictByParentId")
|
|
||||||
ResponseResult<List<Map<String, Object>>> listDictByParentId(@RequestParam("parentId") Long parentId);
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
class AreaCodeClientFallbackFactory
|
|
||||||
extends BaseFallbackFactory<AreaCodeDto, AreaCodeVo, Long, AreaCodeClient> implements AreaCodeClient {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listDict() {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.RPC_DATA_ACCESS_FAILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listDictByParentId(Long parentId) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.RPC_DATA_ACCESS_FAILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AreaCodeClient create(Throwable throwable) {
|
|
||||||
log.error("Exception For Feign Remote Call.", throwable);
|
|
||||||
return new AreaCodeClientFallbackFactory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,208 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.client;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.client.BaseFallbackFactory;
|
|
||||||
import com.orangeforms.common.core.config.FeignConfig;
|
|
||||||
import com.orangeforms.common.core.base.client.BaseClient;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.courseclassapi.dto.CourseDto;
|
|
||||||
import com.orangeforms.courseclassapi.vo.CourseVo;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程数据服务远程数据操作访问接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@FeignClient(
|
|
||||||
name = "course-class",
|
|
||||||
configuration = FeignConfig.class,
|
|
||||||
fallbackFactory = CourseClient.CourseClientFallbackFactory.class)
|
|
||||||
public interface CourseClient extends BaseClient<CourseDto, CourseVo, Long> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基于主键的(In-list)条件获取远程数据接口。
|
|
||||||
*
|
|
||||||
* @param courseIds 主键Id集合。
|
|
||||||
* @param withDict 是否包含字典关联。
|
|
||||||
* @return 应答结果对象,包含主对象的数据集合。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/course/listByIds")
|
|
||||||
ResponseResult<List<CourseVo>> listByIds(
|
|
||||||
@RequestParam("courseIds") Set<Long> courseIds,
|
|
||||||
@RequestParam("withDict") Boolean withDict);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基于主键Id,获取远程对象。
|
|
||||||
*
|
|
||||||
* @param courseId 主键Id。
|
|
||||||
* @param withDict 是否包含字典关联。
|
|
||||||
* @return 应答结果对象,包含主对象数据。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/course/getById")
|
|
||||||
ResponseResult<CourseVo> getById(
|
|
||||||
@RequestParam("courseId") Long courseId,
|
|
||||||
@RequestParam("withDict") Boolean withDict);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数列表中指定的主键Id,是否都存在。
|
|
||||||
*
|
|
||||||
* @param courseIds 主键Id集合。
|
|
||||||
* @return 应答结果对象,包含true全部存在,否则false。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/course/existIds")
|
|
||||||
ResponseResult<Boolean> existIds(@RequestParam("courseIds") Set<Long> courseIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断主键Id是否存在。
|
|
||||||
*
|
|
||||||
* @param courseId 参数主键Id。
|
|
||||||
* @return 应答结果对象,包含true表示存在,否则false。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/course/existId")
|
|
||||||
ResponseResult<Boolean> existId(@RequestParam("courseId") Long courseId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存或更新数据。
|
|
||||||
*
|
|
||||||
* @param data 主键Id为null时表示新增数据,否则更新数据。
|
|
||||||
* @return 应答结果对象,主键Id。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/course/saveNewOrUpdate")
|
|
||||||
ResponseResult<CourseVo> saveNewOrUpdate(@RequestBody CourseDto data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量新增或保存数据列表。
|
|
||||||
*
|
|
||||||
* @param dataList 数据列表。主键Id为null时表示新增数据,否则更新数据。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/course/saveNewOrUpdateBatch")
|
|
||||||
ResponseResult<Void> saveNewOrUpdateBatch(@RequestBody List<CourseDto> dataList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据最新对象和原有对象列表的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
|
||||||
*
|
|
||||||
* @param data 数据对象。
|
|
||||||
* 主键有值是视为更新操作的数据比对,因此仅当关联Id变化时才会验证。
|
|
||||||
* 主键为空视为新增操作的数据比对,所有关联Id都会被验证。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/course/verifyRelatedData")
|
|
||||||
ResponseResult<Void> verifyRelatedData(@RequestBody CourseDto data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据最新对象列表和原有对象列表的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
|
||||||
*
|
|
||||||
* @param dataList 数据对象列表。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/course/verifyRelatedDataList")
|
|
||||||
ResponseResult<Void> verifyRelatedDataList(@RequestBody List<CourseDto> dataList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除主键Id关联的对象。
|
|
||||||
*
|
|
||||||
* @param courseId 主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/course/deleteById")
|
|
||||||
ResponseResult<Integer> deleteById(@RequestParam("courseId") Long courseId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除符合过滤条件的数据。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @return 应答结果对象,包含删除数量。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/course/deleteBy")
|
|
||||||
ResponseResult<Integer> deleteBy(@RequestBody CourseDto filter);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的数据列表。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含实体对象集合。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/course/listBy")
|
|
||||||
ResponseResult<MyPageData<CourseVo>> listBy(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的单条数据对象。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含实体对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/course/getBy")
|
|
||||||
ResponseResult<CourseVo> getBy(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的数据列表。
|
|
||||||
* 和listBy接口相比,以Map列表的方式返回的主要目的是,降低服务之间的耦合度。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含主对象集合。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/course/listMapBy")
|
|
||||||
ResponseResult<MyPageData<Map<String, Object>>> listMapBy(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的数据数量。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含结果数量。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/course/countBy")
|
|
||||||
ResponseResult<Integer> countBy(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程对象中符合查询条件的分组聚合计算Map列表。
|
|
||||||
*
|
|
||||||
* @param aggregationParam 聚合参数。
|
|
||||||
* @return 应该结果对象,包含聚合计算后的分组Map列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/course/aggregateBy")
|
|
||||||
ResponseResult<List<Map<String, Object>>> aggregateBy(@RequestBody MyAggregationParam aggregationParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据过滤字段和过滤集合,返回不存在的数据。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return filterSet中,在从表中不存在的数据集合。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/course/notExist")
|
|
||||||
ResponseResult<List<?>> notExist(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
@Component("CourseClassCourseClientFallbackFactory")
|
|
||||||
@Slf4j
|
|
||||||
class CourseClientFallbackFactory
|
|
||||||
extends BaseFallbackFactory<CourseDto, CourseVo, Long, CourseClient> implements CourseClient {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CourseClient create(Throwable throwable) {
|
|
||||||
log.error("Exception For Feign Remote Call.", throwable);
|
|
||||||
return new CourseClientFallbackFactory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,125 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.client;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.client.BaseFallbackFactory;
|
|
||||||
import com.orangeforms.common.core.config.FeignConfig;
|
|
||||||
import com.orangeforms.common.core.base.client.BaseClient;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.courseclassapi.dto.GradeDto;
|
|
||||||
import com.orangeforms.courseclassapi.vo.GradeVo;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 服务远程数据操作访问接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@FeignClient(
|
|
||||||
name = "course-class",
|
|
||||||
configuration = FeignConfig.class,
|
|
||||||
fallbackFactory = GradeClient.GradeClientFallbackFactory.class)
|
|
||||||
public interface GradeClient extends BaseClient<GradeDto, GradeVo, Integer> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基于主键的(in list)条件获取远程数据接口。
|
|
||||||
*
|
|
||||||
* @param gradeIds 主键Id集合。
|
|
||||||
* @param withDict 是否包含字典关联。
|
|
||||||
* @return 应答结果对象,包含主对象的数据集合。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/grade/listByIds")
|
|
||||||
ResponseResult<List<GradeVo>> listByIds(
|
|
||||||
@RequestParam("gradeIds") Set<Integer> gradeIds,
|
|
||||||
@RequestParam("withDict") Boolean withDict);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基于主键Id,获取远程对象。
|
|
||||||
*
|
|
||||||
* @param gradeId 主键Id。
|
|
||||||
* @param withDict 是否包含字典关联。
|
|
||||||
* @return 应答结果对象,包含主对象数据。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/grade/getById")
|
|
||||||
ResponseResult<GradeVo> getById(
|
|
||||||
@RequestParam("gradeId") Integer gradeId,
|
|
||||||
@RequestParam("withDict") Boolean withDict);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数列表中指定的主键Id,是否全部存在。
|
|
||||||
*
|
|
||||||
* @param gradeIds 主键Id集合。
|
|
||||||
* @return 应答结果对象,包含true全部存在,否则false。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/grade/existIds")
|
|
||||||
ResponseResult<Boolean> existIds(Set<Integer> gradeIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 给定主键Id是否存在。
|
|
||||||
*
|
|
||||||
* @param gradeId 参数主键Id。
|
|
||||||
* @return 应答结果对象,包含true表示存在,否则false。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/grade/existId")
|
|
||||||
ResponseResult<Boolean> existId(@RequestParam("gradeId") Integer gradeId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除主键Id关联的对象。
|
|
||||||
*
|
|
||||||
* @param gradeId 主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/grade/deleteById")
|
|
||||||
ResponseResult<Integer> deleteById(@RequestParam("gradeId") Integer gradeId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除符合过滤条件的数据。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @return 应答结果对象,包含删除数量。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/grade/deleteBy")
|
|
||||||
ResponseResult<Integer> deleteBy(@RequestBody GradeDto filter);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的数据列表。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含实体对象集合。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/grade/listBy")
|
|
||||||
ResponseResult<MyPageData<GradeVo>> listBy(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的单条数据对象。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含实体对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/grade/getBy")
|
|
||||||
ResponseResult<GradeVo> getBy(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
@Component("CourseClassGradeClientFallbackFactory")
|
|
||||||
@Slf4j
|
|
||||||
class GradeClientFallbackFactory
|
|
||||||
extends BaseFallbackFactory<GradeDto, GradeVo, Integer, GradeClient> implements GradeClient {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GradeClient create(Throwable throwable) {
|
|
||||||
log.error("Exception For Feign Remote Call.", throwable);
|
|
||||||
return new GradeClientFallbackFactory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,208 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.client;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.client.BaseFallbackFactory;
|
|
||||||
import com.orangeforms.common.core.config.FeignConfig;
|
|
||||||
import com.orangeforms.common.core.base.client.BaseClient;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.courseclassapi.dto.StudentClassDto;
|
|
||||||
import com.orangeforms.courseclassapi.vo.StudentClassVo;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级数据服务远程数据操作访问接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@FeignClient(
|
|
||||||
name = "course-class",
|
|
||||||
configuration = FeignConfig.class,
|
|
||||||
fallbackFactory = StudentClassClient.StudentClassClientFallbackFactory.class)
|
|
||||||
public interface StudentClassClient extends BaseClient<StudentClassDto, StudentClassVo, Long> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基于主键的(In-list)条件获取远程数据接口。
|
|
||||||
*
|
|
||||||
* @param classIds 主键Id集合。
|
|
||||||
* @param withDict 是否包含字典关联。
|
|
||||||
* @return 应答结果对象,包含主对象的数据集合。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/studentClass/listByIds")
|
|
||||||
ResponseResult<List<StudentClassVo>> listByIds(
|
|
||||||
@RequestParam("classIds") Set<Long> classIds,
|
|
||||||
@RequestParam("withDict") Boolean withDict);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基于主键Id,获取远程对象。
|
|
||||||
*
|
|
||||||
* @param classId 主键Id。
|
|
||||||
* @param withDict 是否包含字典关联。
|
|
||||||
* @return 应答结果对象,包含主对象数据。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/studentClass/getById")
|
|
||||||
ResponseResult<StudentClassVo> getById(
|
|
||||||
@RequestParam("classId") Long classId,
|
|
||||||
@RequestParam("withDict") Boolean withDict);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数列表中指定的主键Id,是否都存在。
|
|
||||||
*
|
|
||||||
* @param classIds 主键Id集合。
|
|
||||||
* @return 应答结果对象,包含true全部存在,否则false。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/studentClass/existIds")
|
|
||||||
ResponseResult<Boolean> existIds(@RequestParam("classIds") Set<Long> classIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断主键Id是否存在。
|
|
||||||
*
|
|
||||||
* @param classId 参数主键Id。
|
|
||||||
* @return 应答结果对象,包含true表示存在,否则false。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/studentClass/existId")
|
|
||||||
ResponseResult<Boolean> existId(@RequestParam("classId") Long classId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存或更新数据。
|
|
||||||
*
|
|
||||||
* @param data 主键Id为null时表示新增数据,否则更新数据。
|
|
||||||
* @return 应答结果对象,主键Id。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/studentClass/saveNewOrUpdate")
|
|
||||||
ResponseResult<StudentClassVo> saveNewOrUpdate(@RequestBody StudentClassDto data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量新增或保存数据列表。
|
|
||||||
*
|
|
||||||
* @param dataList 数据列表。主键Id为null时表示新增数据,否则更新数据。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/studentClass/saveNewOrUpdateBatch")
|
|
||||||
ResponseResult<Void> saveNewOrUpdateBatch(@RequestBody List<StudentClassDto> dataList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据最新对象和原有对象列表的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
|
||||||
*
|
|
||||||
* @param data 数据对象。
|
|
||||||
* 主键有值是视为更新操作的数据比对,因此仅当关联Id变化时才会验证。
|
|
||||||
* 主键为空视为新增操作的数据比对,所有关联Id都会被验证。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/studentClass/verifyRelatedData")
|
|
||||||
ResponseResult<Void> verifyRelatedData(@RequestBody StudentClassDto data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据最新对象列表和原有对象列表的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
|
||||||
*
|
|
||||||
* @param dataList 数据对象列表。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/studentClass/verifyRelatedDataList")
|
|
||||||
ResponseResult<Void> verifyRelatedDataList(@RequestBody List<StudentClassDto> dataList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除主键Id关联的对象。
|
|
||||||
*
|
|
||||||
* @param classId 主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/studentClass/deleteById")
|
|
||||||
ResponseResult<Integer> deleteById(@RequestParam("classId") Long classId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除符合过滤条件的数据。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @return 应答结果对象,包含删除数量。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/studentClass/deleteBy")
|
|
||||||
ResponseResult<Integer> deleteBy(@RequestBody StudentClassDto filter);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的数据列表。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含实体对象集合。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/studentClass/listBy")
|
|
||||||
ResponseResult<MyPageData<StudentClassVo>> listBy(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的单条数据对象。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含实体对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/studentClass/getBy")
|
|
||||||
ResponseResult<StudentClassVo> getBy(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的数据列表。
|
|
||||||
* 和listBy接口相比,以Map列表的方式返回的主要目的是,降低服务之间的耦合度。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含主对象集合。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/studentClass/listMapBy")
|
|
||||||
ResponseResult<MyPageData<Map<String, Object>>> listMapBy(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的数据数量。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含结果数量。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/studentClass/countBy")
|
|
||||||
ResponseResult<Integer> countBy(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程对象中符合查询条件的分组聚合计算Map列表。
|
|
||||||
*
|
|
||||||
* @param aggregationParam 聚合参数。
|
|
||||||
* @return 应该结果对象,包含聚合计算后的分组Map列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/studentClass/aggregateBy")
|
|
||||||
ResponseResult<List<Map<String, Object>>> aggregateBy(@RequestBody MyAggregationParam aggregationParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据过滤字段和过滤集合,返回不存在的数据。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return filterSet中,在从表中不存在的数据集合。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/studentClass/notExist")
|
|
||||||
ResponseResult<List<?>> notExist(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
@Component("CourseClassStudentClassClientFallbackFactory")
|
|
||||||
@Slf4j
|
|
||||||
class StudentClassClientFallbackFactory
|
|
||||||
extends BaseFallbackFactory<StudentClassDto, StudentClassVo, Long, StudentClassClient> implements StudentClassClient {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public StudentClassClient create(Throwable throwable) {
|
|
||||||
log.error("Exception For Feign Remote Call.", throwable);
|
|
||||||
return new StudentClassClientFallbackFactory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,208 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.client;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.client.BaseFallbackFactory;
|
|
||||||
import com.orangeforms.common.core.config.FeignConfig;
|
|
||||||
import com.orangeforms.common.core.base.client.BaseClient;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.courseclassapi.dto.StudentDto;
|
|
||||||
import com.orangeforms.courseclassapi.vo.StudentVo;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生数据服务远程数据操作访问接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@FeignClient(
|
|
||||||
name = "course-class",
|
|
||||||
configuration = FeignConfig.class,
|
|
||||||
fallbackFactory = StudentClient.StudentClientFallbackFactory.class)
|
|
||||||
public interface StudentClient extends BaseClient<StudentDto, StudentVo, Long> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基于主键的(In-list)条件获取远程数据接口。
|
|
||||||
*
|
|
||||||
* @param studentIds 主键Id集合。
|
|
||||||
* @param withDict 是否包含字典关联。
|
|
||||||
* @return 应答结果对象,包含主对象的数据集合。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/student/listByIds")
|
|
||||||
ResponseResult<List<StudentVo>> listByIds(
|
|
||||||
@RequestParam("studentIds") Set<Long> studentIds,
|
|
||||||
@RequestParam("withDict") Boolean withDict);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基于主键Id,获取远程对象。
|
|
||||||
*
|
|
||||||
* @param studentId 主键Id。
|
|
||||||
* @param withDict 是否包含字典关联。
|
|
||||||
* @return 应答结果对象,包含主对象数据。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/student/getById")
|
|
||||||
ResponseResult<StudentVo> getById(
|
|
||||||
@RequestParam("studentId") Long studentId,
|
|
||||||
@RequestParam("withDict") Boolean withDict);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数列表中指定的主键Id,是否都存在。
|
|
||||||
*
|
|
||||||
* @param studentIds 主键Id集合。
|
|
||||||
* @return 应答结果对象,包含true全部存在,否则false。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/student/existIds")
|
|
||||||
ResponseResult<Boolean> existIds(@RequestParam("studentIds") Set<Long> studentIds);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断主键Id是否存在。
|
|
||||||
*
|
|
||||||
* @param studentId 参数主键Id。
|
|
||||||
* @return 应答结果对象,包含true表示存在,否则false。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/student/existId")
|
|
||||||
ResponseResult<Boolean> existId(@RequestParam("studentId") Long studentId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存或更新数据。
|
|
||||||
*
|
|
||||||
* @param data 主键Id为null时表示新增数据,否则更新数据。
|
|
||||||
* @return 应答结果对象,主键Id。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/student/saveNewOrUpdate")
|
|
||||||
ResponseResult<StudentVo> saveNewOrUpdate(@RequestBody StudentDto data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量新增或保存数据列表。
|
|
||||||
*
|
|
||||||
* @param dataList 数据列表。主键Id为null时表示新增数据,否则更新数据。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/student/saveNewOrUpdateBatch")
|
|
||||||
ResponseResult<Void> saveNewOrUpdateBatch(@RequestBody List<StudentDto> dataList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据最新对象和原有对象列表的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
|
||||||
*
|
|
||||||
* @param data 数据对象。
|
|
||||||
* 主键有值是视为更新操作的数据比对,因此仅当关联Id变化时才会验证。
|
|
||||||
* 主键为空视为新增操作的数据比对,所有关联Id都会被验证。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/student/verifyRelatedData")
|
|
||||||
ResponseResult<Void> verifyRelatedData(@RequestBody StudentDto data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据最新对象列表和原有对象列表的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
|
||||||
*
|
|
||||||
* @param dataList 数据对象列表。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/student/verifyRelatedDataList")
|
|
||||||
ResponseResult<Void> verifyRelatedDataList(@RequestBody List<StudentDto> dataList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除主键Id关联的对象。
|
|
||||||
*
|
|
||||||
* @param studentId 主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/student/deleteById")
|
|
||||||
ResponseResult<Integer> deleteById(@RequestParam("studentId") Long studentId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除符合过滤条件的数据。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @return 应答结果对象,包含删除数量。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/student/deleteBy")
|
|
||||||
ResponseResult<Integer> deleteBy(@RequestBody StudentDto filter);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的数据列表。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含实体对象集合。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/student/listBy")
|
|
||||||
ResponseResult<MyPageData<StudentVo>> listBy(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的单条数据对象。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含实体对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/student/getBy")
|
|
||||||
ResponseResult<StudentVo> getBy(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的数据列表。
|
|
||||||
* 和listBy接口相比,以Map列表的方式返回的主要目的是,降低服务之间的耦合度。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含主对象集合。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/student/listMapBy")
|
|
||||||
ResponseResult<MyPageData<Map<String, Object>>> listMapBy(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的数据数量。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含结果数量。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/student/countBy")
|
|
||||||
ResponseResult<Integer> countBy(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程对象中符合查询条件的分组聚合计算Map列表。
|
|
||||||
*
|
|
||||||
* @param aggregationParam 聚合参数。
|
|
||||||
* @return 应该结果对象,包含聚合计算后的分组Map列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/student/aggregateBy")
|
|
||||||
ResponseResult<List<Map<String, Object>>> aggregateBy(@RequestBody MyAggregationParam aggregationParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据过滤字段和过滤集合,返回不存在的数据。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return filterSet中,在从表中不存在的数据集合。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@PostMapping("/student/notExist")
|
|
||||||
ResponseResult<List<?>> notExist(@RequestBody MyQueryParam queryParam);
|
|
||||||
|
|
||||||
@Component("CourseClassStudentClientFallbackFactory")
|
|
||||||
@Slf4j
|
|
||||||
class StudentClientFallbackFactory
|
|
||||||
extends BaseFallbackFactory<StudentDto, StudentVo, Long, StudentClient> implements StudentClient {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public StudentClient create(Throwable throwable) {
|
|
||||||
log.error("Exception For Feign Remote Call.", throwable);
|
|
||||||
return new StudentClientFallbackFactory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.constant;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级级别常量字典对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public final class ClassLevel {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初级班。
|
|
||||||
*/
|
|
||||||
public static final int NORMAL = 0;
|
|
||||||
/**
|
|
||||||
* 中级班。
|
|
||||||
*/
|
|
||||||
public static final int MIDDLE = 1;
|
|
||||||
/**
|
|
||||||
* 高级班。
|
|
||||||
*/
|
|
||||||
public static final int HIGH = 2;
|
|
||||||
|
|
||||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(3);
|
|
||||||
static {
|
|
||||||
DICT_MAP.put(NORMAL, "初级班");
|
|
||||||
DICT_MAP.put(MIDDLE, "中级班");
|
|
||||||
DICT_MAP.put(HIGH, "高级班");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数是否为当前常量字典的合法值。
|
|
||||||
*
|
|
||||||
* @param value 待验证的参数值。
|
|
||||||
* @return 合法返回true,否则false。
|
|
||||||
*/
|
|
||||||
public static boolean isValid(Integer value) {
|
|
||||||
return value != null && DICT_MAP.containsKey(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私有构造函数,明确标识该常量类的作用。
|
|
||||||
*/
|
|
||||||
private ClassLevel() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.constant;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级状态常量字典对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public final class ClassStatus {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 正常。
|
|
||||||
*/
|
|
||||||
public static final int NORAML = 1;
|
|
||||||
/**
|
|
||||||
* 解散。
|
|
||||||
*/
|
|
||||||
public static final int DELETED = -1;
|
|
||||||
|
|
||||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(2);
|
|
||||||
static {
|
|
||||||
DICT_MAP.put(NORAML, "正常");
|
|
||||||
DICT_MAP.put(DELETED, "解散");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数是否为当前常量字典的合法值。
|
|
||||||
*
|
|
||||||
* @param value 待验证的参数值。
|
|
||||||
* @return 合法返回true,否则false。
|
|
||||||
*/
|
|
||||||
public static boolean isValid(Integer value) {
|
|
||||||
return value != null && DICT_MAP.containsKey(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私有构造函数,明确标识该常量类的作用。
|
|
||||||
*/
|
|
||||||
private ClassStatus() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.constant;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程难度常量字典对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public final class CourseDifficult {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 容易。
|
|
||||||
*/
|
|
||||||
public static final int NORMAL = 0;
|
|
||||||
/**
|
|
||||||
* 普通。
|
|
||||||
*/
|
|
||||||
public static final int MIDDLE = 1;
|
|
||||||
/**
|
|
||||||
* 困难。
|
|
||||||
*/
|
|
||||||
public static final int HIGH = 2;
|
|
||||||
|
|
||||||
private static final Map<Object, String> DICT_MAP = new HashMap<>(3);
|
|
||||||
static {
|
|
||||||
DICT_MAP.put(NORMAL, "容易");
|
|
||||||
DICT_MAP.put(MIDDLE, "普通");
|
|
||||||
DICT_MAP.put(HIGH, "困难");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数是否为当前常量字典的合法值。
|
|
||||||
*
|
|
||||||
* @param value 待验证的参数值。
|
|
||||||
* @return 合法返回true,否则false。
|
|
||||||
*/
|
|
||||||
public static boolean isValid(Integer value) {
|
|
||||||
return value != null && DICT_MAP.containsKey(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私有构造函数,明确标识该常量类的作用。
|
|
||||||
*/
|
|
||||||
private CourseDifficult() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.dto;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行政区划Dto。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@ApiModel("行政区划实体对象")
|
|
||||||
@Data
|
|
||||||
public class AreaCodeDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行政区划主键Id
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "行政区划主键Id", required = true)
|
|
||||||
private Long areaId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行政区划名称
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "行政区划名称")
|
|
||||||
private String areaName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行政区划级别 (1: 省级别 2: 市级别 3: 区级别)
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "行政区划级别")
|
|
||||||
private Integer areaLevel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 父级行政区划Id
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "父级行政区划Id")
|
|
||||||
private Long parentId;
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.dto;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ClassCourseDto对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@ApiModel("ClassCourseDto对象")
|
|
||||||
@Data
|
|
||||||
public class ClassCourseDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "班级Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,班级Id不能为空!", groups = {UpdateGroup.class})
|
|
||||||
private Long classId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "课程Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,课程Id不能为空!", groups = {UpdateGroup.class})
|
|
||||||
private Long courseId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程顺序(数值越小越靠前)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "课程顺序(数值越小越靠前)", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,课程顺序(数值越小越靠前)不能为空!", groups = {UpdateGroup.class})
|
|
||||||
private Integer courseOrder;
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.dto;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ClassStudentDto对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@ApiModel("ClassStudentDto对象")
|
|
||||||
@Data
|
|
||||||
public class ClassStudentDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "班级Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,班级Id不能为空!", groups = {UpdateGroup.class})
|
|
||||||
private Long classId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "学生Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,学生Id不能为空!", groups = {UpdateGroup.class})
|
|
||||||
private Long studentId;
|
|
||||||
}
|
|
||||||
@@ -1,144 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.dto;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
import com.orangeforms.common.core.validator.ConstDictRef;
|
|
||||||
import com.orangeforms.courseclassapi.constant.CourseDifficult;
|
|
||||||
import com.orangeforms.application.common.constant.Subject;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CourseDto对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@ApiModel("CourseDto对象")
|
|
||||||
@Data
|
|
||||||
public class CourseDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "主键Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
|
||||||
private Long courseId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程名称。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "课程名称", required = true)
|
|
||||||
@NotBlank(message = "数据验证失败,课程名称不能为空!")
|
|
||||||
private String courseName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程价格。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "课程价格", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,课程价格不能为空!")
|
|
||||||
private BigDecimal price;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程描述。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "课程描述")
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程难度(0: 容易 1: 普通 2: 很难)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "课程难度(0: 容易 1: 普通 2: 很难)", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,课程难度不能为空!")
|
|
||||||
@ConstDictRef(constDictClass = CourseDifficult.class, message = "数据验证失败,课程难度为无效值!")
|
|
||||||
private Integer difficulty;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 年级Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "年级Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,所属年级不能为空!")
|
|
||||||
private Integer gradeId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学科Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "学科Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,所属学科不能为空!")
|
|
||||||
@ConstDictRef(constDictClass = Subject.class, message = "数据验证失败,所属学科为无效值!")
|
|
||||||
private Integer subjectId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课时数量。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "课时数量", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,课时数量不能为空!")
|
|
||||||
private Integer classHour;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 多张课程图片地址。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "多张课程图片地址", required = true)
|
|
||||||
@NotBlank(message = "数据验证失败,课程图片不能为空!")
|
|
||||||
private String pictureUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建用户Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "创建用户Id")
|
|
||||||
private Long createUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最后修改时间。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "最后修改时间")
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* price 范围过滤起始值(>=)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "price 范围过滤起始值(>=)")
|
|
||||||
private BigDecimal priceStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* price 范围过滤结束值(<=)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "price 范围过滤结束值(<=)")
|
|
||||||
private BigDecimal priceEnd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* classHour 范围过滤起始值(>=)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "classHour 范围过滤起始值(>=)")
|
|
||||||
private Integer classHourStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* classHour 范围过滤结束值(<=)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "classHour 范围过滤结束值(<=)")
|
|
||||||
private Integer classHourEnd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* updateTime 范围过滤起始值(>=)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "updateTime 范围过滤起始值(>=)")
|
|
||||||
private String updateTimeStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* updateTime 范围过滤结束值(<=)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "updateTime 范围过滤结束值(<=)")
|
|
||||||
private String updateTimeEnd;
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.dto;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GradeDto对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@ApiModel("GradeDto对象")
|
|
||||||
@Data
|
|
||||||
public class GradeDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "主键Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,主键Id不能为空!", groups = {UpdateGroup.class})
|
|
||||||
private Integer gradeId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 年级名称。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "年级名称", required = true)
|
|
||||||
@NotBlank(message = "数据验证失败,年级名称不能为空!")
|
|
||||||
private String gradeName;
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.dto;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
import com.orangeforms.common.core.validator.ConstDictRef;
|
|
||||||
import com.orangeforms.courseclassapi.constant.ClassLevel;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* StudentClassDto对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@ApiModel("StudentClassDto对象")
|
|
||||||
@Data
|
|
||||||
public class StudentClassDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "班级Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,班级Id不能为空!", groups = {UpdateGroup.class})
|
|
||||||
private Long classId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级名称。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "班级名称", required = true)
|
|
||||||
@NotBlank(message = "数据验证失败,班级名称不能为空!")
|
|
||||||
private String className;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学校Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "学校Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,所属校区不能为空!")
|
|
||||||
private Long schoolId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生班长Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "学生班长Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,班长不能为空!")
|
|
||||||
private Long leaderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 已完成课时数量。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "已完成课时数量", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,已完成课时不能为空!")
|
|
||||||
private Integer finishClassHour;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,班级级别不能为空!")
|
|
||||||
@ConstDictRef(constDictClass = ClassLevel.class, message = "数据验证失败,班级级别为无效值!")
|
|
||||||
private Integer classLevel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建用户。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "创建用户")
|
|
||||||
private Long createUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级创建时间。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "班级创建时间")
|
|
||||||
private Date createTime;
|
|
||||||
}
|
|
||||||
@@ -1,164 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.dto;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
import com.orangeforms.common.core.validator.ConstDictRef;
|
|
||||||
import com.orangeforms.application.common.constant.Gender;
|
|
||||||
import com.orangeforms.application.common.constant.ExpLevel;
|
|
||||||
import com.orangeforms.application.common.constant.StudentStatus;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.*;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* StudentDto对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@ApiModel("StudentDto对象")
|
|
||||||
@Data
|
|
||||||
public class StudentDto {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "学生Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,学生Id不能为空!", groups = {UpdateGroup.class})
|
|
||||||
private Long studentId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录手机。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "登录手机", required = true)
|
|
||||||
@NotBlank(message = "数据验证失败,手机号码不能为空!")
|
|
||||||
private String loginMobile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生姓名。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "学生姓名", required = true)
|
|
||||||
@NotBlank(message = "数据验证失败,姓名不能为空!")
|
|
||||||
private String studentName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 所在省份Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "所在省份Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,所在省份不能为空!")
|
|
||||||
private Long provinceId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 所在城市Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "所在城市Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,所在城市不能为空!")
|
|
||||||
private Long cityId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 区县Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "区县Id", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,所在区县不能为空!")
|
|
||||||
private Long districtId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生性别 (0: 女生 1: 男生)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "学生性别 (0: 女生 1: 男生)", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,性别不能为空!")
|
|
||||||
@ConstDictRef(constDictClass = Gender.class, message = "数据验证失败,性别为无效值!")
|
|
||||||
private Integer gender;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生日。
|
|
||||||
*/
|
|
||||||
@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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注册时间。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "注册时间", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,注册时间不能为空!")
|
|
||||||
private Date registerTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生状态 (0: 正常 1: 锁定 2: 注销)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "学生状态 (0: 正常 1: 锁定 2: 注销)", required = true)
|
|
||||||
@NotNull(message = "数据验证失败,状态 不能为空!", groups = {UpdateGroup.class})
|
|
||||||
@ConstDictRef(constDictClass = StudentStatus.class, message = "数据验证失败,状态 为无效值!")
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* birthday 范围过滤起始值(>=)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "birthday 范围过滤起始值(>=)")
|
|
||||||
private String birthdayStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* birthday 范围过滤结束值(<=)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "birthday 范围过滤结束值(<=)")
|
|
||||||
private String birthdayEnd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* registerTime 范围过滤起始值(>=)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "registerTime 范围过滤起始值(>=)")
|
|
||||||
private String registerTimeStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* registerTime 范围过滤结束值(<=)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "registerTime 范围过滤结束值(<=)")
|
|
||||||
private String registerTimeEnd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* true LIKE搜索字符串。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "LIKE模糊搜索字符串")
|
|
||||||
private String searchString;
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.vo;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行政区划VO。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@ApiModel("行政区划实体对象VO")
|
|
||||||
@Data
|
|
||||||
public class AreaCodeVo {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行政区划主键Id
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "行政区划主键Id", required = true)
|
|
||||||
private Long areaId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行政区划名称
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "行政区划名称")
|
|
||||||
private String areaName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行政区划级别 (1: 省级别 2: 市级别 3: 区级别)
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "行政区划级别")
|
|
||||||
private Integer areaLevel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 父级行政区划Id
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "父级行政区划Id")
|
|
||||||
private Long parentId;
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.vo;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ClassCourseVO视图对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@ApiModel("ClassCourseVO视图对象")
|
|
||||||
@Data
|
|
||||||
public class ClassCourseVo {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "班级Id")
|
|
||||||
private Long classId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "课程Id")
|
|
||||||
private Long courseId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程顺序(数值越小越靠前)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "课程顺序(数值越小越靠前)")
|
|
||||||
private Integer courseOrder;
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.vo;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ClassStudentVO视图对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@ApiModel("ClassStudentVO视图对象")
|
|
||||||
@Data
|
|
||||||
public class ClassStudentVo {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "班级Id")
|
|
||||||
private Long classId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "学生Id")
|
|
||||||
private Long studentId;
|
|
||||||
}
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.vo;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CourseVO视图对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@ApiModel("CourseVO视图对象")
|
|
||||||
@Data
|
|
||||||
public class CourseVo {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "主键Id")
|
|
||||||
private Long courseId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程名称。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "课程名称")
|
|
||||||
private String courseName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程价格。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "课程价格")
|
|
||||||
private BigDecimal price;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程描述。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "课程描述")
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程难度(0: 容易 1: 普通 2: 很难)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "课程难度(0: 容易 1: 普通 2: 很难)")
|
|
||||||
private Integer difficulty;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 年级Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "年级Id")
|
|
||||||
private Integer gradeId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学科Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "学科Id")
|
|
||||||
private Integer subjectId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课时数量。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "课时数量")
|
|
||||||
private Integer classHour;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 多张课程图片地址。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "多张课程图片地址")
|
|
||||||
private String pictureUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建用户Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "创建用户Id")
|
|
||||||
private Long createUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最后修改时间。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "最后修改时间")
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* courseId 的多对多关联表数据对象,数据对应类型为ClassCourseVo。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "courseId 的多对多关联表数据对象,数据对应类型为ClassCourseVo")
|
|
||||||
private Map<String, Object> classCourse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gradeId 字典关联数据。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "gradeId 字典关联数据")
|
|
||||||
private Map<String, Object> gradeIdDictMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* difficulty 常量字典关联数据。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "difficulty 常量字典关联数据")
|
|
||||||
private Map<String, Object> difficultyDictMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* subjectId 常量字典关联数据。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "subjectId 常量字典关联数据")
|
|
||||||
private Map<String, Object> subjectIdDictMap;
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.vo;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GradeVO视图对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@ApiModel("GradeVO视图对象")
|
|
||||||
@Data
|
|
||||||
public class GradeVo {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "主键Id")
|
|
||||||
private Integer gradeId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 年级名称。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "年级名称")
|
|
||||||
private String gradeName;
|
|
||||||
}
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.vo;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* StudentClassVO视图对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@ApiModel("StudentClassVO视图对象")
|
|
||||||
@Data
|
|
||||||
public class StudentClassVo {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "班级Id")
|
|
||||||
private Long classId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级名称。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "班级名称")
|
|
||||||
private String className;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学校Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "学校Id")
|
|
||||||
private Long schoolId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生班长Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "学生班长Id")
|
|
||||||
private Long leaderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 已完成课时数量。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "已完成课时数量")
|
|
||||||
private Integer finishClassHour;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)")
|
|
||||||
private Integer classLevel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建用户。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "创建用户")
|
|
||||||
private Long createUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级创建时间。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "班级创建时间")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* schoolId 字典关联数据。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "schoolId 字典关联数据")
|
|
||||||
private Map<String, Object> schoolIdDictMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* leaderId 字典关联数据。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "leaderId 字典关联数据")
|
|
||||||
private Map<String, Object> leaderIdDictMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* classLevel 常量字典关联数据。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "classLevel 常量字典关联数据")
|
|
||||||
private Map<String, Object> classLevelDictMap;
|
|
||||||
}
|
|
||||||
@@ -1,157 +0,0 @@
|
|||||||
package com.orangeforms.courseclassapi.vo;
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* StudentVO视图对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@ApiModel("StudentVO视图对象")
|
|
||||||
@Data
|
|
||||||
public class StudentVo {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "学生Id")
|
|
||||||
private Long studentId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录手机。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "登录手机")
|
|
||||||
private String loginMobile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生姓名。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "学生姓名")
|
|
||||||
private String studentName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 所在省份Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "所在省份Id")
|
|
||||||
private Long provinceId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 所在城市Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "所在城市Id")
|
|
||||||
private Long cityId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 区县Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "区县Id")
|
|
||||||
private Long districtId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生性别 (0: 女生 1: 男生)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "学生性别 (0: 女生 1: 男生)")
|
|
||||||
private Integer gender;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生日。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "生日")
|
|
||||||
private Date birthday;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 经验等级 (0: 初级 1: 中级 2: 高级 3: 资深)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "经验等级 (0: 初级 1: 中级 2: 高级 3: 资深)")
|
|
||||||
private Integer experienceLevel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 总共充值学币数量。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "总共充值学币数量")
|
|
||||||
private Integer totalCoin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 可用学币数量。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "可用学币数量")
|
|
||||||
private Integer leftCoin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 年级Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "年级Id")
|
|
||||||
private Integer gradeId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校区Id。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "校区Id")
|
|
||||||
private Long schoolId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注册时间。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "注册时间")
|
|
||||||
private Date registerTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生状态 (0: 正常 1: 锁定 2: 注销)。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "学生状态 (0: 正常 1: 锁定 2: 注销)")
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* schoolId 字典关联数据。
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "schoolId 字典关联数据")
|
|
||||||
private Map<String, Object> schoolIdDictMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>course-class</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>course-class-service</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<name>course-class-service</name>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- 业务组件依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>course-class-api</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>upms-api</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>common-log</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>common-redis</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>common-sequence</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<includes>
|
|
||||||
<include>**/*.*</include>
|
|
||||||
</includes>
|
|
||||||
<filtering>false</filtering>
|
|
||||||
</resource>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/java</directory>
|
|
||||||
<includes>
|
|
||||||
<include>**/*.xml</include>
|
|
||||||
</includes>
|
|
||||||
<filtering>false</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice;
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
|
||||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* course-class服务启动类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@ComponentScan("com.orangeforms")
|
|
||||||
@EnableFeignClients(basePackages = "com.orangeforms")
|
|
||||||
@SpringBootApplication
|
|
||||||
public class CourseClassApplication {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(CourseClassApplication.class, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.config;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 应用程序自定义的程序属性配置文件。
|
|
||||||
* 在yml格式的配置文件中,配置application开头应用配置信息,如:
|
|
||||||
*
|
|
||||||
* application:
|
|
||||||
* uploadFileBaseDir: /user/xxx/fileRoot/
|
|
||||||
* defaultSomething: defaultValue
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@RefreshScope
|
|
||||||
@Configuration
|
|
||||||
@ConfigurationProperties(prefix = "application")
|
|
||||||
public class ApplicationConfig {
|
|
||||||
/**
|
|
||||||
* 上传文件的基础目录
|
|
||||||
*/
|
|
||||||
private String uploadFileBaseDir;
|
|
||||||
/**
|
|
||||||
* 每个微服务的url目录上下文,如(/admin/upms),通常和网关的路由目录一致。
|
|
||||||
*/
|
|
||||||
private String serviceContextPath;
|
|
||||||
/**
|
|
||||||
* 是否忽略远程调用中出现的任何错误,包括逻辑异常和系统异常。
|
|
||||||
* 通常在调试和测试阶段设置为false,以便及时发现问题。
|
|
||||||
*/
|
|
||||||
private Boolean ignoreRpcError;
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.config;
|
|
||||||
|
|
||||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据源配置Bean对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
@EnableTransactionManagement
|
|
||||||
@MapperScan(value = {"com.orangeforms.*.dao", "com.orangeforms.common.*.dao"})
|
|
||||||
public class DataSourceConfig {
|
|
||||||
|
|
||||||
@Bean(initMethod = "init", destroyMethod = "close")
|
|
||||||
@Primary
|
|
||||||
@ConfigurationProperties(prefix = "spring.datasource.druid")
|
|
||||||
public DataSource druidDataSource() {
|
|
||||||
return DruidDataSourceBuilder.create().build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,160 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.controller;
|
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import cn.jimmyshi.beanquery.BeanQuery;
|
|
||||||
import com.orangeforms.common.core.base.controller.BaseController;
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseDictService;
|
|
||||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
|
||||||
import com.orangeforms.common.core.util.MyModelUtil;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.courseclassapi.vo.AreaCodeVo;
|
|
||||||
import com.orangeforms.courseclassservice.model.AreaCode;
|
|
||||||
import com.orangeforms.courseclassservice.service.AreaCodeService;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行政区划数据访问接口类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Api(tags = "行政区划数据访问接口")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/areaCode")
|
|
||||||
public class AreaCodeController extends BaseController<AreaCode, AreaCodeVo, Long> {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AreaCodeService areaCodeService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IBaseDictService<AreaCode, Long> service() {
|
|
||||||
return areaCodeService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 按照字典的形式返回行政区划列表。
|
|
||||||
*
|
|
||||||
* @return 字典形式的行政区划列表。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listDict")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listDict() {
|
|
||||||
List<AreaCode> resultList = areaCodeService.getAllListFromCache();
|
|
||||||
return ResponseResult.success(BeanQuery.select(
|
|
||||||
"parentId as parentId", "areaId as id", "areaName as name").executeFrom(resultList));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据上级行政区划Id获取其下级行政区划列表。
|
|
||||||
*
|
|
||||||
* @param parentId 上级行政区划Id。
|
|
||||||
* @return 按照字典的形式返回下级行政区划列表。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listDictByParentId")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listDictByParentId(@RequestParam(required = false) Long parentId) {
|
|
||||||
Collection<AreaCode> resultList = areaCodeService.getListByParentId(parentId);
|
|
||||||
if (CollectionUtils.isEmpty(resultList)) {
|
|
||||||
return ResponseResult.success(new LinkedList<>());
|
|
||||||
}
|
|
||||||
return ResponseResult.success(BeanQuery.select(
|
|
||||||
"parentId as parentId", "areaId as id", "areaName as name").executeFrom(resultList));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据字典Id集合,获取查询后的字典数据。
|
|
||||||
*
|
|
||||||
* @param dictIds 字典Id集合。
|
|
||||||
* @return 字典形式的行政区划列表。
|
|
||||||
*/
|
|
||||||
@PostMapping("/listDictByIds")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listDictByIds(
|
|
||||||
@MyRequestBody(elementType = Long.class) List<Long> dictIds) {
|
|
||||||
List<AreaCode> resultList = areaCodeService.getInList(new HashSet<>(dictIds));
|
|
||||||
return ResponseResult.success(BeanQuery.select(
|
|
||||||
"parentId as parentId", "areaId as id", "areaName as name").executeFrom(resultList));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看单条记录的详情信息,如果当前主对象包含字典和一对一关联,也都同时返回。
|
|
||||||
*
|
|
||||||
* @param areaId 行政区划Id。
|
|
||||||
* @return 应答结果的Data对象中,将包含行政区划对象。
|
|
||||||
*/
|
|
||||||
@GetMapping("/view")
|
|
||||||
public ResponseResult<AreaCodeVo> view(@RequestParam Long areaId) {
|
|
||||||
AreaCode areaCode = areaCodeService.getById(areaId);
|
|
||||||
return ResponseResult.success(MyModelUtil.copyTo(areaCode, AreaCodeVo.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取存在于主键Id列表的数据集合,该方法主要用于微服务间远程数据调用。
|
|
||||||
*
|
|
||||||
* @param areaCodeIds 主键Id列表。
|
|
||||||
* @param withDict 该字段只是为了保证和其他对象接口一致,在这里没有实际用处。
|
|
||||||
* @return 符合主键(in list)的数据集合。
|
|
||||||
*/
|
|
||||||
@PostMapping("/listByIds")
|
|
||||||
public ResponseResult<List<AreaCodeVo>> listByIds(
|
|
||||||
@RequestParam Set<Long> areaCodeIds, @RequestParam Boolean withDict) {
|
|
||||||
return super.baseListByIds(areaCodeIds, withDict, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基于主键Id,获取远程对象,该方法主要用于微服务间远程数据调用。
|
|
||||||
*
|
|
||||||
* @param areaId 主键Id。
|
|
||||||
* @param withDict 该字段只是为了保证和其他对象接口一致,在这里没有实际用处。
|
|
||||||
* @return 应答结果对象,包含主对象数据。
|
|
||||||
*/
|
|
||||||
@GetMapping("/getById")
|
|
||||||
public ResponseResult<AreaCodeVo> getById(@RequestParam Long areaId, @RequestParam Boolean withDict) {
|
|
||||||
return super.baseGetById(areaId, withDict, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数列表中指定的主键Id集合,是否全部存在。仅限于微服务间远程接口调用。
|
|
||||||
*
|
|
||||||
* @param areaCodeIds 主键Id集合。
|
|
||||||
* @return 应答结果对象,包含true全部存在,否则false。
|
|
||||||
*/
|
|
||||||
@GetMapping("/existIds")
|
|
||||||
public ResponseResult<Boolean> existIds(@RequestParam Set<Long> areaCodeIds) {
|
|
||||||
return super.baseExistIds(areaCodeIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断指定主键Id的对象是否存在,该方法主要用于微服务间远程数据调用。
|
|
||||||
*
|
|
||||||
* @param areaId 主键Id。
|
|
||||||
* @return 存在返回true,否则false。
|
|
||||||
*/
|
|
||||||
@GetMapping("/existId")
|
|
||||||
public ResponseResult<Boolean> existId(@RequestParam Long areaId) {
|
|
||||||
return super.baseExistId(areaId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 复杂的查询调用,包括(in list)过滤,对象条件过滤,分组和排序等。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含符合查询过滤条件的对象结果集。
|
|
||||||
*/
|
|
||||||
@PostMapping("/listBy")
|
|
||||||
public ResponseResult<MyPageData<AreaCodeVo>> listBy(@RequestBody MyQueryParam queryParam) {
|
|
||||||
return super.baseListBy(queryParam, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 复杂的查询调用,仅返回单体记录。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含符合查询过滤条件的对象结果集。
|
|
||||||
*/
|
|
||||||
@PostMapping("/getBy")
|
|
||||||
public ResponseResult<AreaCodeVo> getBy(@RequestBody MyQueryParam queryParam) {
|
|
||||||
return super.baseGetBy(queryParam, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,532 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.controller;
|
|
||||||
|
|
||||||
import cn.jimmyshi.beanquery.BeanQuery;
|
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
|
||||||
import com.github.pagehelper.page.PageMethod;
|
|
||||||
import com.orangeforms.courseclassservice.model.*;
|
|
||||||
import com.orangeforms.courseclassservice.service.*;
|
|
||||||
import com.orangeforms.courseclassapi.dto.*;
|
|
||||||
import com.orangeforms.courseclassapi.vo.*;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.common.core.util.*;
|
|
||||||
import com.orangeforms.common.core.constant.*;
|
|
||||||
import com.orangeforms.common.core.base.controller.BaseController;
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseService;
|
|
||||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
|
||||||
import com.orangeforms.common.core.upload.BaseUpDownloader;
|
|
||||||
import com.orangeforms.common.core.upload.UpDownloaderFactory;
|
|
||||||
import com.orangeforms.common.core.upload.UploadResponseInfo;
|
|
||||||
import com.orangeforms.common.core.upload.UploadStoreInfo;
|
|
||||||
import com.orangeforms.common.log.annotation.OperationLog;
|
|
||||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
|
||||||
import com.orangeforms.common.redis.cache.SessionCacheHelper;
|
|
||||||
import com.orangeforms.courseclassservice.config.ApplicationConfig;
|
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程数据操作控制器类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Api(tags = "课程数据管理接口")
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/course")
|
|
||||||
public class CourseController extends BaseController<Course, CourseVo, Long> {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CourseService courseService;
|
|
||||||
@Autowired
|
|
||||||
private ApplicationConfig appConfig;
|
|
||||||
@Autowired
|
|
||||||
private SessionCacheHelper cacheHelper;
|
|
||||||
@Autowired
|
|
||||||
private UpDownloaderFactory upDownloaderFactory;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IBaseService<Course, Long> service() {
|
|
||||||
return courseService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增课程数据数据。
|
|
||||||
*
|
|
||||||
* @param courseDto 新增对象。
|
|
||||||
* @return 应答结果对象,包含新增对象主键Id。
|
|
||||||
*/
|
|
||||||
@ApiOperationSupport(ignoreParameters = {
|
|
||||||
"courseDto.courseId",
|
|
||||||
"courseDto.priceStart",
|
|
||||||
"courseDto.priceEnd",
|
|
||||||
"courseDto.classHourStart",
|
|
||||||
"courseDto.classHourEnd",
|
|
||||||
"courseDto.updateTimeStart",
|
|
||||||
"courseDto.updateTimeEnd"})
|
|
||||||
@OperationLog(type = SysOperationLogType.ADD)
|
|
||||||
@PostMapping("/add")
|
|
||||||
public ResponseResult<Long> add(@MyRequestBody CourseDto courseDto) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(courseDto, false);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
Course course = MyModelUtil.copyTo(courseDto, Course.class);
|
|
||||||
// 验证关联Id的数据合法性
|
|
||||||
CallResult callResult = courseService.verifyAllRelatedData(course, null);
|
|
||||||
if (!callResult.isSuccess()) {
|
|
||||||
return ResponseResult.errorFrom(callResult);
|
|
||||||
}
|
|
||||||
course = courseService.saveNew(course);
|
|
||||||
return ResponseResult.success(course.getCourseId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新课程数据数据。
|
|
||||||
*
|
|
||||||
* @param courseDto 更新对象。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@ApiOperationSupport(ignoreParameters = {
|
|
||||||
"CourseDto.priceStart",
|
|
||||||
"CourseDto.priceEnd",
|
|
||||||
"CourseDto.classHourStart",
|
|
||||||
"CourseDto.classHourEnd",
|
|
||||||
"CourseDto.updateTimeStart",
|
|
||||||
"CourseDto.updateTimeEnd"})
|
|
||||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
|
||||||
@PostMapping("/update")
|
|
||||||
public ResponseResult<Void> update(@MyRequestBody CourseDto courseDto) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(courseDto, true);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
Course course = MyModelUtil.copyTo(courseDto, Course.class);
|
|
||||||
Course originalCourse = courseService.getById(course.getCourseId());
|
|
||||||
if (originalCourse == null) {
|
|
||||||
// NOTE: 修改下面方括号中的话述
|
|
||||||
errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
// 验证关联Id的数据合法性
|
|
||||||
CallResult callResult = courseService.verifyAllRelatedData(course, originalCourse);
|
|
||||||
if (!callResult.isSuccess()) {
|
|
||||||
return ResponseResult.errorFrom(callResult);
|
|
||||||
}
|
|
||||||
if (!courseService.update(course, originalCourse)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除课程数据数据。
|
|
||||||
*
|
|
||||||
* @param courseId 删除对象主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DELETE)
|
|
||||||
@PostMapping("/delete")
|
|
||||||
public ResponseResult<Void> delete(@MyRequestBody Long courseId) {
|
|
||||||
String errorMessage;
|
|
||||||
if (MyCommonUtil.existBlankArgument(courseId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
return this.doDelete(courseId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列出符合过滤条件的课程数据列表。
|
|
||||||
*
|
|
||||||
* @param courseDtoFilter 过滤对象。
|
|
||||||
* @param orderParam 排序参数。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 应答结果对象,包含查询结果集。
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
public ResponseResult<MyPageData<CourseVo>> list(
|
|
||||||
@MyRequestBody CourseDto courseDtoFilter,
|
|
||||||
@MyRequestBody MyOrderParam orderParam,
|
|
||||||
@MyRequestBody MyPageParam pageParam) {
|
|
||||||
if (pageParam != null) {
|
|
||||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
||||||
}
|
|
||||||
Course courseFilter = MyModelUtil.copyTo(courseDtoFilter, Course.class);
|
|
||||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Course.class);
|
|
||||||
List<Course> courseList = courseService.getCourseListWithRelation(courseFilter, orderBy);
|
|
||||||
return ResponseResult.success(MyPageUtil.makeResponseData(courseList, Course.INSTANCE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看指定课程数据对象详情。
|
|
||||||
*
|
|
||||||
* @param courseId 指定对象主键Id。
|
|
||||||
* @return 应答结果对象,包含对象详情。
|
|
||||||
*/
|
|
||||||
@GetMapping("/view")
|
|
||||||
public ResponseResult<CourseVo> view(@RequestParam Long courseId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(courseId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
Course course = courseService.getByIdWithRelation(courseId, MyRelationParam.full());
|
|
||||||
if (course == null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
CourseVo courseVo = Course.INSTANCE.fromModel(course);
|
|
||||||
return ResponseResult.success(courseVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 附件文件下载。
|
|
||||||
* 这里将图片和其他类型的附件文件放到不同的父目录下,主要为了便于今后图片文件的迁移。
|
|
||||||
*
|
|
||||||
* @param courseId 附件所在记录的主键Id。
|
|
||||||
* @param fieldName 附件所属的字段名。
|
|
||||||
* @param filename 文件名。如果没有提供该参数,就从当前记录的指定字段中读取。
|
|
||||||
* @param asImage 下载文件是否为图片。
|
|
||||||
* @param response Http 应答对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DOWNLOAD, saveResponse = false)
|
|
||||||
@GetMapping("/download")
|
|
||||||
public void download(
|
|
||||||
@RequestParam(required = false) Long courseId,
|
|
||||||
@RequestParam String fieldName,
|
|
||||||
@RequestParam String filename,
|
|
||||||
@RequestParam Boolean asImage,
|
|
||||||
HttpServletResponse response) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(fieldName, filename, asImage)) {
|
|
||||||
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 使用try来捕获异常,是为了保证一旦出现异常可以返回500的错误状态,便于调试。
|
|
||||||
// 否则有可能给前端返回的是200的错误码。
|
|
||||||
try {
|
|
||||||
// 如果请求参数中没有包含主键Id,就判断该文件是否为当前session上传的。
|
|
||||||
if (courseId == null) {
|
|
||||||
if (!cacheHelper.existSessionUploadFile(filename)) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Course course = courseService.getById(courseId);
|
|
||||||
if (course == null) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_NOT_FOUND);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String fieldJsonData = (String) ReflectUtil.getFieldValue(course, fieldName);
|
|
||||||
if (fieldJsonData == null) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!BaseUpDownloader.containFile(fieldJsonData, filename)) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UploadStoreInfo storeInfo = MyModelUtil.getUploadStoreInfo(Course.class, fieldName);
|
|
||||||
if (!storeInfo.isSupportUpload()) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_NOT_IMPLEMENTED,
|
|
||||||
ResponseResult.error(ErrorCodeEnum.INVALID_UPLOAD_FIELD));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BaseUpDownloader upDownloader = upDownloaderFactory.get(storeInfo.getStoreType());
|
|
||||||
upDownloader.doDownload(appConfig.getUploadFileBaseDir(),
|
|
||||||
Course.class.getSimpleName(), fieldName, filename, asImage, response);
|
|
||||||
} catch (Exception e) {
|
|
||||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件上传操作。
|
|
||||||
*
|
|
||||||
* @param fieldName 上传文件名。
|
|
||||||
* @param asImage 是否作为图片上传。如果是图片,今后下载的时候无需权限验证。否则就是附件上传,下载时需要权限验证。
|
|
||||||
* @param uploadFile 上传文件对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.UPLOAD, saveResponse = false)
|
|
||||||
@PostMapping("/upload")
|
|
||||||
public void upload(
|
|
||||||
@RequestParam String fieldName,
|
|
||||||
@RequestParam Boolean asImage,
|
|
||||||
@RequestParam("uploadFile") MultipartFile uploadFile) throws Exception {
|
|
||||||
UploadStoreInfo storeInfo = MyModelUtil.getUploadStoreInfo(Course.class, fieldName);
|
|
||||||
// 这里就会判断参数中指定的字段,是否支持上传操作。
|
|
||||||
if (!storeInfo.isSupportUpload()) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN,
|
|
||||||
ResponseResult.error(ErrorCodeEnum.INVALID_UPLOAD_FIELD));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 根据字段注解中的存储类型,通过工厂方法获取匹配的上传下载实现类,从而解耦。
|
|
||||||
BaseUpDownloader upDownloader = upDownloaderFactory.get(storeInfo.getStoreType());
|
|
||||||
UploadResponseInfo responseInfo = upDownloader.doUpload(appConfig.getServiceContextPath(),
|
|
||||||
appConfig.getUploadFileBaseDir(), Course.class.getSimpleName(), fieldName, asImage, uploadFile);
|
|
||||||
if (responseInfo.getUploadFailed()) {
|
|
||||||
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN,
|
|
||||||
ResponseResult.error(ErrorCodeEnum.UPLOAD_FAILED, responseInfo.getErrorMessage()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cacheHelper.putSessionUploadFile(responseInfo.getFilename());
|
|
||||||
ResponseResult.output(ResponseResult.success(responseInfo));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 以字典形式返回全部课程数据数据集合。字典的键值为[courseId, courseName]。
|
|
||||||
* 白名单接口,登录用户均可访问。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @return 应答结果对象,包含字典形式的数据集合。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listDict")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listDict(Course filter) {
|
|
||||||
List<Course> resultList = courseService.getListByFilter(filter);
|
|
||||||
return ResponseResult.success(
|
|
||||||
BeanQuery.select("courseId as id", "courseName as name").executeFrom(resultList));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据字典Id集合,获取查询后的字典数据。
|
|
||||||
*
|
|
||||||
* @param dictIds 字典Id集合。
|
|
||||||
* @return 应答结果对象,包含字典形式的数据集合。
|
|
||||||
*/
|
|
||||||
@PostMapping("/listDictByIds")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listDictByIds(
|
|
||||||
@MyRequestBody(elementType = Long.class) List<Long> dictIds) {
|
|
||||||
List<Course> resultList = courseService.getInList(new HashSet<>(dictIds));
|
|
||||||
return ResponseResult.success(
|
|
||||||
BeanQuery.select("courseId as id", "courseName as name").executeFrom(resultList));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键Id集合,获取数据对象集合。仅限于微服务间远程接口调用。
|
|
||||||
*
|
|
||||||
* @param courseIds 主键Id集合。
|
|
||||||
* @param withDict 是否包含字典关联。
|
|
||||||
* @return 应答结果对象,包含主对象集合。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "listByIds")
|
|
||||||
@PostMapping("/listByIds")
|
|
||||||
public ResponseResult<List<CourseVo>> listByIds(
|
|
||||||
@RequestParam Set<Long> courseIds, @RequestParam Boolean withDict) {
|
|
||||||
return super.baseListByIds(courseIds, withDict, Course.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键Id,获取数据对象。仅限于微服务间远程接口调用。
|
|
||||||
*
|
|
||||||
* @param courseId 主键Id。
|
|
||||||
* @param withDict 是否包含字典关联。
|
|
||||||
* @return 应答结果对象,包含主对象数据。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "getById")
|
|
||||||
@PostMapping("/getById")
|
|
||||||
public ResponseResult<CourseVo> getById(
|
|
||||||
@RequestParam Long courseId, @RequestParam Boolean withDict) {
|
|
||||||
return super.baseGetById(courseId, withDict, Course.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数列表中指定的主键Id集合,是否全部存在。仅限于微服务间远程接口调用。
|
|
||||||
*
|
|
||||||
* @param courseIds 主键Id集合。
|
|
||||||
* @return 应答结果对象,包含true全部存在,否则false。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "existIds")
|
|
||||||
@PostMapping("/existIds")
|
|
||||||
public ResponseResult<Boolean> existIds(@RequestParam Set<Long> courseIds) {
|
|
||||||
return super.baseExistIds(courseIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数列表中指定的主键Id是否存在。仅限于微服务间远程接口调用。
|
|
||||||
*
|
|
||||||
* @param courseId 主键Id。
|
|
||||||
* @return 应答结果对象,包含true表示存在,否则false。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "existId")
|
|
||||||
@PostMapping("/existId")
|
|
||||||
public ResponseResult<Boolean> existId(@RequestParam Long courseId) {
|
|
||||||
return super.baseExistId(courseId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存或更新数据。
|
|
||||||
*
|
|
||||||
* @param data 主键Id为null时表示新增数据,否则更新数据。
|
|
||||||
* @return 应答结果对象,主键Id。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "saveNewOrUpdate")
|
|
||||||
@PostMapping("/saveNewOrUpdate")
|
|
||||||
public ResponseResult<CourseVo> saveNewOrUpdate(@RequestBody CourseDto data) {
|
|
||||||
Course course = MyModelUtil.copyTo(data, Course.class);
|
|
||||||
service().saveNewOrUpdate(course, courseService::saveNew, courseService::update);
|
|
||||||
return ResponseResult.success(Course.INSTANCE.fromModel(course));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量新增或保存数据列表。
|
|
||||||
*
|
|
||||||
* @param dataList 数据列表。主键Id为null时表示新增数据,否则更新数据。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "saveNewOrUpdateBatch")
|
|
||||||
@PostMapping("/saveNewOrUpdateBatch")
|
|
||||||
public ResponseResult<Void> saveNewOrUpdateBatch(@RequestBody List<CourseDto> dataList) {
|
|
||||||
List<Course> courseList = MyModelUtil.copyCollectionTo(dataList, Course.class);
|
|
||||||
service().saveNewOrUpdateBatch(courseList, courseService::saveNewBatch, courseService::update);
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据最新对象列表和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
|
||||||
*
|
|
||||||
* @param data 数据对象。
|
|
||||||
* 主键有值是视为更新操作的数据比对,因此仅当关联Id变化时才会验证。
|
|
||||||
* 主键为空视为新增操作的数据比对,所有关联Id都会被验证。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "verifyRelatedData")
|
|
||||||
@PostMapping("/verifyRelatedData")
|
|
||||||
public ResponseResult<Void> verifyRelatedData(@RequestBody CourseDto data) {
|
|
||||||
Course course = MyModelUtil.copyTo(data, Course.class);
|
|
||||||
return super.baseVerifyRelatedData(course, Course::getCourseId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据最新对象列表和原有对象列表的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
|
||||||
*
|
|
||||||
* @param dataList 数据对象列表。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "verifyRelatedDataList")
|
|
||||||
@PostMapping("/verifyRelatedDataList")
|
|
||||||
public ResponseResult<Void> verifyRelatedDataList(@RequestBody List<CourseDto> dataList) {
|
|
||||||
List<Course> courseList = MyModelUtil.copyCollectionTo(dataList, Course.class);
|
|
||||||
return super.baseVerifyRelatedDataList(courseList, Course::getCourseId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键Id删除数据。
|
|
||||||
*
|
|
||||||
* @param courseId 主键Id。
|
|
||||||
* @return 删除数量。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "deleteById")
|
|
||||||
@PostMapping("/deleteById")
|
|
||||||
public ResponseResult<Integer> deleteById(@RequestParam Long courseId) throws Exception {
|
|
||||||
Course filter = new Course();
|
|
||||||
filter.setCourseId(courseId);
|
|
||||||
return super.baseDeleteBy(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除符合过滤条件的数据。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @return 删除数量。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "deleteBy")
|
|
||||||
@PostMapping("/deleteBy")
|
|
||||||
public ResponseResult<Integer> deleteBy(@RequestBody CourseDto filter) throws Exception {
|
|
||||||
return super.baseDeleteBy(MyModelUtil.copyTo(filter, Course.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 复杂的查询调用,包括(in list)过滤,对象条件过滤,分页和排序等。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 分页数据集合对象。如MyQueryParam参数的分页属性为空,则不会执行分页操作,只是基于MyPageData对象返回数据结果。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "listBy")
|
|
||||||
@PostMapping("/listBy")
|
|
||||||
public ResponseResult<MyPageData<CourseVo>> listBy(@RequestBody MyQueryParam queryParam) {
|
|
||||||
return super.baseListBy(queryParam, Course.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 复杂的查询调用,包括(in list)过滤,对象条件过滤,分页和排序等。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 分页数据集合对象。如MyQueryParam参数的分页属性为空,则不会执行分页操作,只是基于MyPageData对象返回数据结果。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "listMapBy")
|
|
||||||
@PostMapping("/listMapBy")
|
|
||||||
public ResponseResult<MyPageData<Map<String, Object>>> listMapBy(@RequestBody MyQueryParam queryParam) {
|
|
||||||
return super.baseListMapBy(queryParam, Course.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 复杂的查询调用,仅返回单体记录。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含符合查询过滤条件的对象结果集。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "getBy")
|
|
||||||
@PostMapping("/getBy")
|
|
||||||
public ResponseResult<CourseVo> getBy(@RequestBody MyQueryParam queryParam) {
|
|
||||||
return super.baseGetBy(queryParam, Course.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的数据数量。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含结果数量。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "countBy")
|
|
||||||
@PostMapping("/countBy")
|
|
||||||
public ResponseResult<Integer> countBy(@RequestBody MyQueryParam queryParam) {
|
|
||||||
return super.baseCountBy(queryParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程对象中符合查询条件的分组聚合计算Map列表。
|
|
||||||
*
|
|
||||||
* @param aggregationParam 聚合参数。
|
|
||||||
* @return 应该结果对象,包含聚合计算后的分组Map列表。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "aggregateBy")
|
|
||||||
@PostMapping("/aggregateBy")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> aggregateBy(@RequestBody MyAggregationParam aggregationParam) {
|
|
||||||
return super.baseAggregateBy(aggregationParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据过滤字段和过滤集合,返回不存在的数据。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 不存在的数据集合。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "notExist")
|
|
||||||
@PostMapping("/notExist")
|
|
||||||
public ResponseResult<List<?>> notExist(@RequestBody MyQueryParam queryParam) {
|
|
||||||
List<?> notExistIdSet = service().notExist(
|
|
||||||
queryParam.getInFilterField(), queryParam.getInFilterValues(), true);
|
|
||||||
return ResponseResult.success(notExistIdSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResponseResult<Void> doDelete(Long courseId) {
|
|
||||||
String errorMessage;
|
|
||||||
// 验证关联Id的数据合法性
|
|
||||||
Course originalCourse = courseService.getById(courseId);
|
|
||||||
if (originalCourse == null) {
|
|
||||||
// NOTE: 修改下面方括号中的话述
|
|
||||||
errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
if (!courseService.remove(courseId)) {
|
|
||||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,290 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.controller;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import cn.jimmyshi.beanquery.BeanQuery;
|
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import com.orangeforms.common.core.base.controller.BaseController;
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseDictService;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
|
||||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
|
||||||
import com.orangeforms.common.core.util.MyModelUtil;
|
|
||||||
import com.orangeforms.common.core.util.MyCommonUtil;
|
|
||||||
import com.orangeforms.common.core.validator.UpdateGroup;
|
|
||||||
import com.orangeforms.common.log.annotation.OperationLog;
|
|
||||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
|
||||||
import com.orangeforms.courseclassapi.dto.GradeDto;
|
|
||||||
import com.orangeforms.courseclassapi.vo.GradeVo;
|
|
||||||
import com.orangeforms.courseclassservice.model.Grade;
|
|
||||||
import com.orangeforms.courseclassservice.service.GradeService;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.validation.groups.Default;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 年级操作控制器类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Api(tags = "年级管理接口")
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/grade")
|
|
||||||
public class GradeController extends BaseController<Grade, GradeVo, Integer> {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private GradeService gradeService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IBaseDictService<Grade, Integer> service() {
|
|
||||||
return gradeService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增年级数据。
|
|
||||||
*
|
|
||||||
* @param gradeDto 新增对象。
|
|
||||||
* @return 应答结果对象,包含新增对象主键Id。
|
|
||||||
*/
|
|
||||||
@ApiOperationSupport(ignoreParameters = {"gradeDto.gradeId"})
|
|
||||||
@OperationLog(type = SysOperationLogType.ADD)
|
|
||||||
@PostMapping("/add")
|
|
||||||
public ResponseResult<Integer> add(@MyRequestBody GradeDto gradeDto) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(gradeDto);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
Grade grade = MyModelUtil.copyTo(gradeDto, Grade.class);
|
|
||||||
grade = gradeService.saveNew(grade);
|
|
||||||
return ResponseResult.success(grade.getGradeId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新年级数据。
|
|
||||||
*
|
|
||||||
* @param gradeDto 更新对象。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
|
||||||
@PostMapping("/update")
|
|
||||||
public ResponseResult<Void> update(@MyRequestBody GradeDto gradeDto) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(gradeDto, Default.class, UpdateGroup.class);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
Grade grade = MyModelUtil.copyTo(gradeDto, Grade.class);
|
|
||||||
Grade originalGrade = gradeService.getById(grade.getGradeId());
|
|
||||||
if (originalGrade == null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
if (!gradeService.update(grade, originalGrade)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除年级数据。
|
|
||||||
*
|
|
||||||
* @param gradeId 删除对象主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DELETE)
|
|
||||||
@PostMapping("/delete")
|
|
||||||
public ResponseResult<Void> delete(@MyRequestBody Integer gradeId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(gradeId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
if (!gradeService.remove(gradeId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看指定年级对象详情。
|
|
||||||
*
|
|
||||||
* @param gradeId 指定对象主键Id。
|
|
||||||
* @return 应答结果对象,包含对象详情。
|
|
||||||
*/
|
|
||||||
@GetMapping("/view")
|
|
||||||
public ResponseResult<GradeVo> view(@RequestParam Integer gradeId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(gradeId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
Grade grade = gradeService.getById(gradeId);
|
|
||||||
if (grade == null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
GradeVo gradeVo = MyModelUtil.copyTo(grade, GradeVo.class);
|
|
||||||
return ResponseResult.success(gradeVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 白名单接口,登录用户均可访问。以字典形式返回全部年级数据集合。
|
|
||||||
* 所有数据全部取自于缓存,对于数据库中存在,但是缓存中不存在的数据,不会返回。
|
|
||||||
*
|
|
||||||
* @return 应答结果对象,包含字典形式的数据集合。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listDict")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listDict() {
|
|
||||||
List<Grade> resultList = gradeService.getAllListFromCache();
|
|
||||||
if (CollectionUtils.isEmpty(resultList)) {
|
|
||||||
gradeService.reloadCachedData(true);
|
|
||||||
resultList = gradeService.getAllList();
|
|
||||||
}
|
|
||||||
return ResponseResult.success(BeanQuery.select(
|
|
||||||
"gradeId as id", "gradeName as name").executeFrom(resultList));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 白名单接口,登录用户均可访问。以字典形式返回全部年级数据集合。
|
|
||||||
* fullResultList中的字典列表全部取自于数据库,而cachedResultList全部取自于缓存,前端负责比对。
|
|
||||||
*
|
|
||||||
* @return 应答结果对象,包含字典形式的数据集合。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listAll")
|
|
||||||
public ResponseResult<JSONObject> listAll() {
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
|
||||||
jsonObject.put("fullResultList", BeanQuery.select(
|
|
||||||
"gradeId as id", "gradeName as name").executeFrom(gradeService.getAllList()));
|
|
||||||
jsonObject.put("cachedResultList", BeanQuery.select(
|
|
||||||
"gradeId as id", "gradeName as name").executeFrom(gradeService.getAllListFromCache()));
|
|
||||||
return ResponseResult.success(jsonObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据字典Id集合,获取查询后的字典数据。
|
|
||||||
*
|
|
||||||
* @param dictIds 字典Id集合。
|
|
||||||
* @return 应答结果对象,包含字典形式的数据集合。
|
|
||||||
*/
|
|
||||||
@PostMapping("/listDictByIds")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listDictByIds(
|
|
||||||
@MyRequestBody(elementType = Integer.class) List<Integer> dictIds) {
|
|
||||||
List<Grade> resultList = gradeService.getInList(new HashSet<>(dictIds));
|
|
||||||
return ResponseResult.success(BeanQuery.select(
|
|
||||||
"gradeId as id", "gradeName as name").executeFrom(resultList));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键Id集合,获取数据对象集合。仅限于微服务间远程接口调用。
|
|
||||||
*
|
|
||||||
* @param gradeIds 主键Id集合。
|
|
||||||
* @param withDict 是否包含字典关联。
|
|
||||||
* @return 应答结果对象,包含主对象集合。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "listByIds")
|
|
||||||
@PostMapping("/listByIds")
|
|
||||||
public ResponseResult<List<GradeVo>> listByIds(
|
|
||||||
@RequestParam Set<Integer> gradeIds, @RequestParam Boolean withDict) {
|
|
||||||
return super.baseListByIds(gradeIds, withDict, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键Id,获取数据对象。仅限于微服务间远程接口调用。
|
|
||||||
*
|
|
||||||
* @param gradeId 主键Id。
|
|
||||||
* @param withDict 是否包含字典关联。
|
|
||||||
* @return 应答结果对象,包含主对象数据。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "getById")
|
|
||||||
@PostMapping("/getById")
|
|
||||||
public ResponseResult<GradeVo> getById(
|
|
||||||
@RequestParam Integer gradeId, @RequestParam Boolean withDict) {
|
|
||||||
return super.baseGetById(gradeId, withDict, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数列表中指定的主键Id集合,是否全部存在。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param gradeIds 主键Id集合。
|
|
||||||
* @return 应答结果对象,包含true全部存在,否则false。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "existIds")
|
|
||||||
@PostMapping("/existIds")
|
|
||||||
public ResponseResult<Boolean> existIds(@RequestParam Set<Integer> gradeIds) {
|
|
||||||
return super.baseExistIds(gradeIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数列表中指定的主键Id集合,是否全部存在。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param gradeId 主键Id。
|
|
||||||
* @return 应答结果对象,包含true全部存在,否则false。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "existId")
|
|
||||||
@PostMapping("/existId")
|
|
||||||
public ResponseResult<Boolean> existId(@RequestParam Integer gradeId) {
|
|
||||||
return super.baseExistId(gradeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键Id删除数据。
|
|
||||||
*
|
|
||||||
* @param gradeId 主键Id。
|
|
||||||
* @return 删除数量。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "deleteById")
|
|
||||||
@PostMapping("/deleteById")
|
|
||||||
public ResponseResult<Integer> deleteById(@RequestParam Integer gradeId) throws Exception {
|
|
||||||
Grade filter = new Grade();
|
|
||||||
filter.setGradeId(gradeId);
|
|
||||||
return super.baseDeleteBy(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除符合过滤条件的数据。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @return 删除数量。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "deleteBy")
|
|
||||||
@PostMapping("/deleteBy")
|
|
||||||
public ResponseResult<Integer> deleteBy(@RequestBody GradeDto filter) throws Exception {
|
|
||||||
return super.baseDeleteBy(MyModelUtil.copyTo(filter, Grade.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 复杂的查询调用,包括(in list)过滤,对象条件过滤,分组和排序等。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含符合查询过滤条件的对象结果集。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "listBy")
|
|
||||||
@PostMapping("/listBy")
|
|
||||||
public ResponseResult<MyPageData<GradeVo>> listBy(@RequestBody MyQueryParam queryParam) {
|
|
||||||
return super.baseListBy(queryParam, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 复杂的查询调用,仅返回单体记录。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含符合查询过滤条件的对象结果集。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "getBy")
|
|
||||||
@PostMapping("/getBy")
|
|
||||||
public ResponseResult<GradeVo> getBy(@RequestBody MyQueryParam queryParam) {
|
|
||||||
return super.baseGetBy(queryParam, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将当前字典表的数据重新加载到缓存中。
|
|
||||||
* 由于缓存的数据更新,在add/update/delete等接口均有同步处理。因此该接口仅当同步过程中出现问题时,
|
|
||||||
* 可手工调用,或者每天晚上定时同步一次。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.RELOAD_CACHE)
|
|
||||||
@GetMapping("/reloadCachedData")
|
|
||||||
public ResponseResult<Boolean> reloadCachedData() {
|
|
||||||
gradeService.reloadCachedData(true);
|
|
||||||
return ResponseResult.success(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,643 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.controller;
|
|
||||||
|
|
||||||
import com.github.pagehelper.page.PageMethod;
|
|
||||||
import com.orangeforms.courseclassservice.model.*;
|
|
||||||
import com.orangeforms.courseclassservice.service.*;
|
|
||||||
import com.orangeforms.courseclassapi.dto.*;
|
|
||||||
import com.orangeforms.courseclassapi.vo.*;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.common.core.util.*;
|
|
||||||
import com.orangeforms.common.core.constant.*;
|
|
||||||
import com.orangeforms.common.core.base.controller.BaseController;
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseService;
|
|
||||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
|
||||||
import com.orangeforms.common.log.annotation.OperationLog;
|
|
||||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级数据操作控制器类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Api(tags = "班级数据管理接口")
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/studentClass")
|
|
||||||
public class StudentClassController extends BaseController<StudentClass, StudentClassVo, Long> {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private StudentClassService studentClassService;
|
|
||||||
@Autowired
|
|
||||||
private CourseService courseService;
|
|
||||||
@Autowired
|
|
||||||
private StudentService studentService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IBaseService<StudentClass, Long> service() {
|
|
||||||
return studentClassService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增班级数据数据。
|
|
||||||
*
|
|
||||||
* @param studentClassDto 新增对象。
|
|
||||||
* @return 应答结果对象,包含新增对象主键Id。
|
|
||||||
*/
|
|
||||||
@ApiOperationSupport(ignoreParameters = {"studentClassDto.classId"})
|
|
||||||
@OperationLog(type = SysOperationLogType.ADD)
|
|
||||||
@PostMapping("/add")
|
|
||||||
public ResponseResult<Long> add(@MyRequestBody StudentClassDto studentClassDto) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(studentClassDto, false);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
StudentClass studentClass = MyModelUtil.copyTo(studentClassDto, StudentClass.class);
|
|
||||||
// 验证关联Id的数据合法性
|
|
||||||
CallResult callResult = studentClassService.verifyAllRelatedData(studentClass, null);
|
|
||||||
if (!callResult.isSuccess()) {
|
|
||||||
return ResponseResult.errorFrom(callResult);
|
|
||||||
}
|
|
||||||
studentClass = studentClassService.saveNew(studentClass);
|
|
||||||
return ResponseResult.success(studentClass.getClassId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新班级数据数据。
|
|
||||||
*
|
|
||||||
* @param studentClassDto 更新对象。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
|
||||||
@PostMapping("/update")
|
|
||||||
public ResponseResult<Void> update(@MyRequestBody StudentClassDto studentClassDto) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(studentClassDto, true);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
StudentClass studentClass = MyModelUtil.copyTo(studentClassDto, StudentClass.class);
|
|
||||||
StudentClass originalStudentClass = studentClassService.getById(studentClass.getClassId());
|
|
||||||
if (originalStudentClass == null) {
|
|
||||||
// NOTE: 修改下面方括号中的话述
|
|
||||||
errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
// 验证关联Id的数据合法性
|
|
||||||
CallResult callResult = studentClassService.verifyAllRelatedData(studentClass, originalStudentClass);
|
|
||||||
if (!callResult.isSuccess()) {
|
|
||||||
return ResponseResult.errorFrom(callResult);
|
|
||||||
}
|
|
||||||
if (!studentClassService.update(studentClass, originalStudentClass)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除班级数据数据。
|
|
||||||
*
|
|
||||||
* @param classId 删除对象主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DELETE)
|
|
||||||
@PostMapping("/delete")
|
|
||||||
public ResponseResult<Void> delete(@MyRequestBody Long classId) {
|
|
||||||
String errorMessage;
|
|
||||||
if (MyCommonUtil.existBlankArgument(classId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
return this.doDelete(classId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列出符合过滤条件的班级数据列表。
|
|
||||||
*
|
|
||||||
* @param studentClassDtoFilter 过滤对象。
|
|
||||||
* @param orderParam 排序参数。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 应答结果对象,包含查询结果集。
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
public ResponseResult<MyPageData<StudentClassVo>> list(
|
|
||||||
@MyRequestBody StudentClassDto studentClassDtoFilter,
|
|
||||||
@MyRequestBody MyOrderParam orderParam,
|
|
||||||
@MyRequestBody MyPageParam pageParam) {
|
|
||||||
if (pageParam != null) {
|
|
||||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
||||||
}
|
|
||||||
StudentClass studentClassFilter = MyModelUtil.copyTo(studentClassDtoFilter, StudentClass.class);
|
|
||||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, StudentClass.class);
|
|
||||||
List<StudentClass> studentClassList =
|
|
||||||
studentClassService.getStudentClassListWithRelation(studentClassFilter, orderBy);
|
|
||||||
return ResponseResult.success(MyPageUtil.makeResponseData(studentClassList, StudentClass.INSTANCE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看指定班级数据对象详情。
|
|
||||||
*
|
|
||||||
* @param classId 指定对象主键Id。
|
|
||||||
* @return 应答结果对象,包含对象详情。
|
|
||||||
*/
|
|
||||||
@GetMapping("/view")
|
|
||||||
public ResponseResult<StudentClassVo> view(@RequestParam Long classId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(classId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
StudentClass studentClass = studentClassService.getByIdWithRelation(classId, MyRelationParam.full());
|
|
||||||
if (studentClass == null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
StudentClassVo studentClassVo = StudentClass.INSTANCE.fromModel(studentClass);
|
|
||||||
return ResponseResult.success(studentClassVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列出不与指定班级数据存在多对多关系的 [课程数据] 列表数据。
|
|
||||||
* 通常用于查看添加新 [课程数据] 对象的候选列表。
|
|
||||||
*
|
|
||||||
* @param classId 主表主键Id。
|
|
||||||
* @param courseDtoFilter [课程数据] 过滤对象。
|
|
||||||
* @param orderParam 排序参数。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 应答结果对象,返回符合条件的数据列表。
|
|
||||||
*/
|
|
||||||
@PostMapping("/listNotInClassCourse")
|
|
||||||
public ResponseResult<MyPageData<CourseVo>> listNotInClassCourse(
|
|
||||||
@MyRequestBody Long classId,
|
|
||||||
@MyRequestBody CourseDto courseDtoFilter,
|
|
||||||
@MyRequestBody MyOrderParam orderParam,
|
|
||||||
@MyRequestBody MyPageParam pageParam) {
|
|
||||||
if (MyCommonUtil.isNotBlankOrNull(classId) && !studentClassService.existId(classId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
|
||||||
}
|
|
||||||
if (pageParam != null) {
|
|
||||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
||||||
}
|
|
||||||
Course filter = MyModelUtil.copyTo(courseDtoFilter, Course.class);
|
|
||||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Course.class);
|
|
||||||
List<Course> courseList =
|
|
||||||
courseService.getNotInCourseListByClassId(classId, filter, orderBy);
|
|
||||||
return ResponseResult.success(MyPageUtil.makeResponseData(courseList, Course.INSTANCE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列出与指定班级数据存在多对多关系的 [课程数据] 列表数据。
|
|
||||||
*
|
|
||||||
* @param classId 主表主键Id。
|
|
||||||
* @param courseDtoFilter [课程数据] 过滤对象。
|
|
||||||
* @param orderParam 排序参数。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 应答结果对象,返回符合条件的数据列表。
|
|
||||||
*/
|
|
||||||
@PostMapping("/listClassCourse")
|
|
||||||
public ResponseResult<MyPageData<CourseVo>> listClassCourse(
|
|
||||||
@MyRequestBody(required = true) Long classId,
|
|
||||||
@MyRequestBody CourseDto courseDtoFilter,
|
|
||||||
@MyRequestBody MyOrderParam orderParam,
|
|
||||||
@MyRequestBody MyPageParam pageParam) {
|
|
||||||
if (!studentClassService.existId(classId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
|
||||||
}
|
|
||||||
if (pageParam != null) {
|
|
||||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
||||||
}
|
|
||||||
Course filter = MyModelUtil.copyTo(courseDtoFilter, Course.class);
|
|
||||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Course.class);
|
|
||||||
List<Course> courseList =
|
|
||||||
courseService.getCourseListByClassId(classId, filter, orderBy);
|
|
||||||
return ResponseResult.success(MyPageUtil.makeResponseData(courseList, Course.INSTANCE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量添加班级数据和 [课程数据] 对象的多对多关联关系数据。
|
|
||||||
*
|
|
||||||
* @param classId 主表主键Id。
|
|
||||||
* @param classCourseDtoList 关联对象列表。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.ADD_M2M)
|
|
||||||
@PostMapping("/addClassCourse")
|
|
||||||
public ResponseResult<Void> addClassCourse(
|
|
||||||
@MyRequestBody Long classId,
|
|
||||||
@MyRequestBody(elementType = ClassCourseDto.class) List<ClassCourseDto> classCourseDtoList) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(classId, classCourseDtoList)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(classCourseDtoList);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
Set<Long> courseIdSet =
|
|
||||||
classCourseDtoList.stream().map(ClassCourseDto::getCourseId).collect(Collectors.toSet());
|
|
||||||
if (!studentClassService.existId(classId)
|
|
||||||
|| !courseService.existUniqueKeyList("courseId", courseIdSet)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
|
||||||
}
|
|
||||||
List<ClassCourse> classCourseList =
|
|
||||||
MyModelUtil.copyCollectionTo(classCourseDtoList, ClassCourse.class);
|
|
||||||
studentClassService.addClassCourseList(classCourseList, classId);
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新指定班级数据和指定 [课程数据] 的多对多关联数据。
|
|
||||||
*
|
|
||||||
* @param classCourseDto 对多对中间表对象。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
|
||||||
@PostMapping("/updateClassCourse")
|
|
||||||
public ResponseResult<Void> updateClassCourse(
|
|
||||||
@MyRequestBody ClassCourseDto classCourseDto) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(classCourseDto);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
ClassCourse classCourse = MyModelUtil.copyTo(classCourseDto, ClassCourse.class);
|
|
||||||
if (!studentClassService.updateClassCourse(classCourse)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示班级数据和指定 [课程数据] 的多对多关联详情数据。
|
|
||||||
*
|
|
||||||
* @param classId 主表主键Id。
|
|
||||||
* @param courseId 从表主键Id。
|
|
||||||
* @return 应答结果对象,包括中间表详情。
|
|
||||||
*/
|
|
||||||
@GetMapping("/viewClassCourse")
|
|
||||||
public ResponseResult<ClassCourseVo> viewClassCourse(
|
|
||||||
@RequestParam Long classId, @RequestParam Long courseId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(classId, courseId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
ClassCourse classCourse = studentClassService.getClassCourse(classId, courseId);
|
|
||||||
if (classCourse == null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
ClassCourseVo classCourseVo = MyModelUtil.copyTo(classCourse, ClassCourseVo.class);
|
|
||||||
return ResponseResult.success(classCourseVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 移除指定班级数据和指定 [课程数据] 的多对多关联关系。
|
|
||||||
*
|
|
||||||
* @param classId 主表主键Id。
|
|
||||||
* @param courseId 关联表主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DELETE_M2M)
|
|
||||||
@PostMapping("/deleteClassCourse")
|
|
||||||
public ResponseResult<Void> deleteClassCourse(
|
|
||||||
@MyRequestBody Long classId, @MyRequestBody Long courseId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(classId, courseId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
if (!studentClassService.removeClassCourse(classId, courseId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列出不与指定班级数据存在多对多关系的 [学生数据] 列表数据。
|
|
||||||
* 通常用于查看添加新 [学生数据] 对象的候选列表。
|
|
||||||
*
|
|
||||||
* @param classId 主表主键Id。
|
|
||||||
* @param studentDtoFilter [学生数据] 过滤对象。
|
|
||||||
* @param orderParam 排序参数。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 应答结果对象,返回符合条件的数据列表。
|
|
||||||
*/
|
|
||||||
@PostMapping("/listNotInClassStudent")
|
|
||||||
public ResponseResult<MyPageData<StudentVo>> listNotInClassStudent(
|
|
||||||
@MyRequestBody Long classId,
|
|
||||||
@MyRequestBody StudentDto studentDtoFilter,
|
|
||||||
@MyRequestBody MyOrderParam orderParam,
|
|
||||||
@MyRequestBody MyPageParam pageParam) {
|
|
||||||
if (MyCommonUtil.isNotBlankOrNull(classId) && !studentClassService.existId(classId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
|
||||||
}
|
|
||||||
if (pageParam != null) {
|
|
||||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
||||||
}
|
|
||||||
Student filter = MyModelUtil.copyTo(studentDtoFilter, Student.class);
|
|
||||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Student.class);
|
|
||||||
List<Student> studentList =
|
|
||||||
studentService.getNotInStudentListByClassId(classId, filter, orderBy);
|
|
||||||
return ResponseResult.success(MyPageUtil.makeResponseData(studentList, Student.INSTANCE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列出与指定班级数据存在多对多关系的 [学生数据] 列表数据。
|
|
||||||
*
|
|
||||||
* @param classId 主表主键Id。
|
|
||||||
* @param studentDtoFilter [学生数据] 过滤对象。
|
|
||||||
* @param orderParam 排序参数。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 应答结果对象,返回符合条件的数据列表。
|
|
||||||
*/
|
|
||||||
@PostMapping("/listClassStudent")
|
|
||||||
public ResponseResult<MyPageData<StudentVo>> listClassStudent(
|
|
||||||
@MyRequestBody(required = true) Long classId,
|
|
||||||
@MyRequestBody StudentDto studentDtoFilter,
|
|
||||||
@MyRequestBody MyOrderParam orderParam,
|
|
||||||
@MyRequestBody MyPageParam pageParam) {
|
|
||||||
if (!studentClassService.existId(classId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
|
||||||
}
|
|
||||||
if (pageParam != null) {
|
|
||||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
||||||
}
|
|
||||||
Student filter = MyModelUtil.copyTo(studentDtoFilter, Student.class);
|
|
||||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Student.class);
|
|
||||||
List<Student> studentList =
|
|
||||||
studentService.getStudentListByClassId(classId, filter, orderBy);
|
|
||||||
return ResponseResult.success(MyPageUtil.makeResponseData(studentList, Student.INSTANCE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量添加班级数据和 [学生数据] 对象的多对多关联关系数据。
|
|
||||||
*
|
|
||||||
* @param classId 主表主键Id。
|
|
||||||
* @param classStudentDtoList 关联对象列表。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.ADD_M2M)
|
|
||||||
@PostMapping("/addClassStudent")
|
|
||||||
public ResponseResult<Void> addClassStudent(
|
|
||||||
@MyRequestBody Long classId,
|
|
||||||
@MyRequestBody(elementType = ClassStudentDto.class) List<ClassStudentDto> classStudentDtoList) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(classId, classStudentDtoList)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(classStudentDtoList);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
Set<Long> studentIdSet =
|
|
||||||
classStudentDtoList.stream().map(ClassStudentDto::getStudentId).collect(Collectors.toSet());
|
|
||||||
if (!studentClassService.existId(classId)
|
|
||||||
|| !studentService.existUniqueKeyList("studentId", studentIdSet)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.INVALID_RELATED_RECORD_ID);
|
|
||||||
}
|
|
||||||
List<ClassStudent> classStudentList =
|
|
||||||
MyModelUtil.copyCollectionTo(classStudentDtoList, ClassStudent.class);
|
|
||||||
studentClassService.addClassStudentList(classStudentList, classId);
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 移除指定班级数据和指定 [学生数据] 的多对多关联关系。
|
|
||||||
*
|
|
||||||
* @param classId 主表主键Id。
|
|
||||||
* @param studentId 关联表主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DELETE_M2M)
|
|
||||||
@PostMapping("/deleteClassStudent")
|
|
||||||
public ResponseResult<Void> deleteClassStudent(
|
|
||||||
@MyRequestBody Long classId, @MyRequestBody Long studentId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(classId, studentId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
if (!studentClassService.removeClassStudent(classId, studentId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键Id集合,获取数据对象集合。仅限于微服务间远程接口调用。
|
|
||||||
*
|
|
||||||
* @param classIds 主键Id集合。
|
|
||||||
* @param withDict 是否包含字典关联。
|
|
||||||
* @return 应答结果对象,包含主对象集合。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "listByIds")
|
|
||||||
@PostMapping("/listByIds")
|
|
||||||
public ResponseResult<List<StudentClassVo>> listByIds(
|
|
||||||
@RequestParam Set<Long> classIds, @RequestParam Boolean withDict) {
|
|
||||||
return super.baseListByIds(classIds, withDict, StudentClass.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键Id,获取数据对象。仅限于微服务间远程接口调用。
|
|
||||||
*
|
|
||||||
* @param classId 主键Id。
|
|
||||||
* @param withDict 是否包含字典关联。
|
|
||||||
* @return 应答结果对象,包含主对象数据。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "getById")
|
|
||||||
@PostMapping("/getById")
|
|
||||||
public ResponseResult<StudentClassVo> getById(
|
|
||||||
@RequestParam Long classId, @RequestParam Boolean withDict) {
|
|
||||||
return super.baseGetById(classId, withDict, StudentClass.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数列表中指定的主键Id集合,是否全部存在。仅限于微服务间远程接口调用。
|
|
||||||
*
|
|
||||||
* @param classIds 主键Id集合。
|
|
||||||
* @return 应答结果对象,包含true全部存在,否则false。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "existIds")
|
|
||||||
@PostMapping("/existIds")
|
|
||||||
public ResponseResult<Boolean> existIds(@RequestParam Set<Long> classIds) {
|
|
||||||
return super.baseExistIds(classIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数列表中指定的主键Id是否存在。仅限于微服务间远程接口调用。
|
|
||||||
*
|
|
||||||
* @param classId 主键Id。
|
|
||||||
* @return 应答结果对象,包含true表示存在,否则false。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "existId")
|
|
||||||
@PostMapping("/existId")
|
|
||||||
public ResponseResult<Boolean> existId(@RequestParam Long classId) {
|
|
||||||
return super.baseExistId(classId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存或更新数据。
|
|
||||||
*
|
|
||||||
* @param data 主键Id为null时表示新增数据,否则更新数据。
|
|
||||||
* @return 应答结果对象,主键Id。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "saveNewOrUpdate")
|
|
||||||
@PostMapping("/saveNewOrUpdate")
|
|
||||||
public ResponseResult<StudentClassVo> saveNewOrUpdate(@RequestBody StudentClassDto data) {
|
|
||||||
StudentClass studentClass = MyModelUtil.copyTo(data, StudentClass.class);
|
|
||||||
service().saveNewOrUpdate(studentClass, studentClassService::saveNew, studentClassService::update);
|
|
||||||
return ResponseResult.success(StudentClass.INSTANCE.fromModel(studentClass));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量新增或保存数据列表。
|
|
||||||
*
|
|
||||||
* @param dataList 数据列表。主键Id为null时表示新增数据,否则更新数据。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "saveNewOrUpdateBatch")
|
|
||||||
@PostMapping("/saveNewOrUpdateBatch")
|
|
||||||
public ResponseResult<Void> saveNewOrUpdateBatch(@RequestBody List<StudentClassDto> dataList) {
|
|
||||||
List<StudentClass> studentClassList = MyModelUtil.copyCollectionTo(dataList, StudentClass.class);
|
|
||||||
service().saveNewOrUpdateBatch(studentClassList, studentClassService::saveNewBatch, studentClassService::update);
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据最新对象列表和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
|
||||||
*
|
|
||||||
* @param data 数据对象。
|
|
||||||
* 主键有值是视为更新操作的数据比对,因此仅当关联Id变化时才会验证。
|
|
||||||
* 主键为空视为新增操作的数据比对,所有关联Id都会被验证。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "verifyRelatedData")
|
|
||||||
@PostMapping("/verifyRelatedData")
|
|
||||||
public ResponseResult<Void> verifyRelatedData(@RequestBody StudentClassDto data) {
|
|
||||||
StudentClass studentClass = MyModelUtil.copyTo(data, StudentClass.class);
|
|
||||||
return super.baseVerifyRelatedData(studentClass, StudentClass::getClassId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据最新对象列表和原有对象列表的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
|
||||||
*
|
|
||||||
* @param dataList 数据对象列表。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "verifyRelatedDataList")
|
|
||||||
@PostMapping("/verifyRelatedDataList")
|
|
||||||
public ResponseResult<Void> verifyRelatedDataList(@RequestBody List<StudentClassDto> dataList) {
|
|
||||||
List<StudentClass> studentClassList = MyModelUtil.copyCollectionTo(dataList, StudentClass.class);
|
|
||||||
return super.baseVerifyRelatedDataList(studentClassList, StudentClass::getClassId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键Id删除数据。
|
|
||||||
*
|
|
||||||
* @param classId 主键Id。
|
|
||||||
* @return 删除数量。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "deleteById")
|
|
||||||
@PostMapping("/deleteById")
|
|
||||||
public ResponseResult<Integer> deleteById(@RequestParam Long classId) throws Exception {
|
|
||||||
StudentClass filter = new StudentClass();
|
|
||||||
filter.setClassId(classId);
|
|
||||||
return super.baseDeleteBy(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除符合过滤条件的数据。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @return 删除数量。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "deleteBy")
|
|
||||||
@PostMapping("/deleteBy")
|
|
||||||
public ResponseResult<Integer> deleteBy(@RequestBody StudentClassDto filter) throws Exception {
|
|
||||||
return super.baseDeleteBy(MyModelUtil.copyTo(filter, StudentClass.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 复杂的查询调用,包括(in list)过滤,对象条件过滤,分页和排序等。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 分页数据集合对象。如MyQueryParam参数的分页属性为空,则不会执行分页操作,只是基于MyPageData对象返回数据结果。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "listBy")
|
|
||||||
@PostMapping("/listBy")
|
|
||||||
public ResponseResult<MyPageData<StudentClassVo>> listBy(@RequestBody MyQueryParam queryParam) {
|
|
||||||
return super.baseListBy(queryParam, StudentClass.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 复杂的查询调用,包括(in list)过滤,对象条件过滤,分页和排序等。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 分页数据集合对象。如MyQueryParam参数的分页属性为空,则不会执行分页操作,只是基于MyPageData对象返回数据结果。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "listMapBy")
|
|
||||||
@PostMapping("/listMapBy")
|
|
||||||
public ResponseResult<MyPageData<Map<String, Object>>> listMapBy(@RequestBody MyQueryParam queryParam) {
|
|
||||||
return super.baseListMapBy(queryParam, StudentClass.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 复杂的查询调用,仅返回单体记录。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含符合查询过滤条件的对象结果集。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "getBy")
|
|
||||||
@PostMapping("/getBy")
|
|
||||||
public ResponseResult<StudentClassVo> getBy(@RequestBody MyQueryParam queryParam) {
|
|
||||||
return super.baseGetBy(queryParam, StudentClass.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的数据数量。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含结果数量。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "countBy")
|
|
||||||
@PostMapping("/countBy")
|
|
||||||
public ResponseResult<Integer> countBy(@RequestBody MyQueryParam queryParam) {
|
|
||||||
return super.baseCountBy(queryParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程对象中符合查询条件的分组聚合计算Map列表。
|
|
||||||
*
|
|
||||||
* @param aggregationParam 聚合参数。
|
|
||||||
* @return 应该结果对象,包含聚合计算后的分组Map列表。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "aggregateBy")
|
|
||||||
@PostMapping("/aggregateBy")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> aggregateBy(@RequestBody MyAggregationParam aggregationParam) {
|
|
||||||
return super.baseAggregateBy(aggregationParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据过滤字段和过滤集合,返回不存在的数据。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 不存在的数据集合。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "notExist")
|
|
||||||
@PostMapping("/notExist")
|
|
||||||
public ResponseResult<List<?>> notExist(@RequestBody MyQueryParam queryParam) {
|
|
||||||
List<?> notExistIdSet = service().notExist(
|
|
||||||
queryParam.getInFilterField(), queryParam.getInFilterValues(), true);
|
|
||||||
return ResponseResult.success(notExistIdSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResponseResult<Void> doDelete(Long classId) {
|
|
||||||
String errorMessage;
|
|
||||||
// 验证关联Id的数据合法性
|
|
||||||
StudentClass originalStudentClass = studentClassService.getById(classId);
|
|
||||||
if (originalStudentClass == null) {
|
|
||||||
// NOTE: 修改下面方括号中的话述
|
|
||||||
errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
if (!studentClassService.remove(classId)) {
|
|
||||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,420 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.controller;
|
|
||||||
|
|
||||||
import cn.jimmyshi.beanquery.BeanQuery;
|
|
||||||
import com.github.pagehelper.page.PageMethod;
|
|
||||||
import com.orangeforms.courseclassservice.model.*;
|
|
||||||
import com.orangeforms.courseclassservice.service.*;
|
|
||||||
import com.orangeforms.courseclassapi.dto.*;
|
|
||||||
import com.orangeforms.courseclassapi.vo.*;
|
|
||||||
import com.orangeforms.common.core.object.*;
|
|
||||||
import com.orangeforms.common.core.util.*;
|
|
||||||
import com.orangeforms.common.core.constant.*;
|
|
||||||
import com.orangeforms.common.core.base.controller.BaseController;
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseService;
|
|
||||||
import com.orangeforms.common.core.annotation.MyRequestBody;
|
|
||||||
import com.orangeforms.common.log.annotation.OperationLog;
|
|
||||||
import com.orangeforms.common.log.model.constant.SysOperationLogType;
|
|
||||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生数据操作控制器类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Api(tags = "学生数据管理接口")
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/student")
|
|
||||||
public class StudentController extends BaseController<Student, StudentVo, Long> {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private StudentService studentService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IBaseService<Student, Long> service() {
|
|
||||||
return studentService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增学生数据数据。
|
|
||||||
*
|
|
||||||
* @param studentDto 新增对象。
|
|
||||||
* @return 应答结果对象,包含新增对象主键Id。
|
|
||||||
*/
|
|
||||||
@ApiOperationSupport(ignoreParameters = {
|
|
||||||
"studentDto.studentId",
|
|
||||||
"studentDto.searchString",
|
|
||||||
"studentDto.birthdayStart",
|
|
||||||
"studentDto.birthdayEnd",
|
|
||||||
"studentDto.registerTimeStart",
|
|
||||||
"studentDto.registerTimeEnd"})
|
|
||||||
@OperationLog(type = SysOperationLogType.ADD)
|
|
||||||
@PostMapping("/add")
|
|
||||||
public ResponseResult<Long> add(@MyRequestBody StudentDto studentDto) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(studentDto, false);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
Student student = MyModelUtil.copyTo(studentDto, Student.class);
|
|
||||||
// 验证关联Id的数据合法性
|
|
||||||
CallResult callResult = studentService.verifyAllRelatedData(student, null);
|
|
||||||
if (!callResult.isSuccess()) {
|
|
||||||
return ResponseResult.errorFrom(callResult);
|
|
||||||
}
|
|
||||||
student = studentService.saveNew(student);
|
|
||||||
return ResponseResult.success(student.getStudentId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新学生数据数据。
|
|
||||||
*
|
|
||||||
* @param studentDto 更新对象。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@ApiOperationSupport(ignoreParameters = {
|
|
||||||
"StudentDto.searchString",
|
|
||||||
"StudentDto.birthdayStart",
|
|
||||||
"StudentDto.birthdayEnd",
|
|
||||||
"StudentDto.registerTimeStart",
|
|
||||||
"StudentDto.registerTimeEnd"})
|
|
||||||
@OperationLog(type = SysOperationLogType.UPDATE)
|
|
||||||
@PostMapping("/update")
|
|
||||||
public ResponseResult<Void> update(@MyRequestBody StudentDto studentDto) {
|
|
||||||
String errorMessage = MyCommonUtil.getModelValidationError(studentDto, true);
|
|
||||||
if (errorMessage != null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
|
|
||||||
}
|
|
||||||
Student student = MyModelUtil.copyTo(studentDto, Student.class);
|
|
||||||
Student originalStudent = studentService.getById(student.getStudentId());
|
|
||||||
if (originalStudent == null) {
|
|
||||||
// NOTE: 修改下面方括号中的话述
|
|
||||||
errorMessage = "数据验证失败,当前 [数据] 并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
// 验证关联Id的数据合法性
|
|
||||||
CallResult callResult = studentService.verifyAllRelatedData(student, originalStudent);
|
|
||||||
if (!callResult.isSuccess()) {
|
|
||||||
return ResponseResult.errorFrom(callResult);
|
|
||||||
}
|
|
||||||
if (!studentService.update(student, originalStudent)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除学生数据数据。
|
|
||||||
*
|
|
||||||
* @param studentId 删除对象主键Id。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@OperationLog(type = SysOperationLogType.DELETE)
|
|
||||||
@PostMapping("/delete")
|
|
||||||
public ResponseResult<Void> delete(@MyRequestBody Long studentId) {
|
|
||||||
String errorMessage;
|
|
||||||
if (MyCommonUtil.existBlankArgument(studentId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
return this.doDelete(studentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 列出符合过滤条件的学生数据列表。
|
|
||||||
*
|
|
||||||
* @param studentDtoFilter 过滤对象。
|
|
||||||
* @param orderParam 排序参数。
|
|
||||||
* @param pageParam 分页参数。
|
|
||||||
* @return 应答结果对象,包含查询结果集。
|
|
||||||
*/
|
|
||||||
@PostMapping("/list")
|
|
||||||
public ResponseResult<MyPageData<StudentVo>> list(
|
|
||||||
@MyRequestBody StudentDto studentDtoFilter,
|
|
||||||
@MyRequestBody MyOrderParam orderParam,
|
|
||||||
@MyRequestBody MyPageParam pageParam) {
|
|
||||||
if (pageParam != null) {
|
|
||||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
|
|
||||||
}
|
|
||||||
Student studentFilter = MyModelUtil.copyTo(studentDtoFilter, Student.class);
|
|
||||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, Student.class);
|
|
||||||
List<Student> studentList = studentService.getStudentListWithRelation(studentFilter, orderBy);
|
|
||||||
return ResponseResult.success(MyPageUtil.makeResponseData(studentList, Student.INSTANCE));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看指定学生数据对象详情。
|
|
||||||
*
|
|
||||||
* @param studentId 指定对象主键Id。
|
|
||||||
* @return 应答结果对象,包含对象详情。
|
|
||||||
*/
|
|
||||||
@GetMapping("/view")
|
|
||||||
public ResponseResult<StudentVo> view(@RequestParam Long studentId) {
|
|
||||||
if (MyCommonUtil.existBlankArgument(studentId)) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST);
|
|
||||||
}
|
|
||||||
Student student = studentService.getByIdWithRelation(studentId, MyRelationParam.full());
|
|
||||||
if (student == null) {
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
|
|
||||||
}
|
|
||||||
StudentVo studentVo = Student.INSTANCE.fromModel(student);
|
|
||||||
return ResponseResult.success(studentVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 以字典形式返回全部学生数据数据集合。字典的键值为[studentId, studentName]。
|
|
||||||
* 白名单接口,登录用户均可访问。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @return 应答结果对象,包含字典形式的数据集合。
|
|
||||||
*/
|
|
||||||
@GetMapping("/listDict")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listDict(Student filter) {
|
|
||||||
List<Student> resultList = studentService.getListByFilter(filter);
|
|
||||||
return ResponseResult.success(
|
|
||||||
BeanQuery.select("studentId as id", "studentName as name").executeFrom(resultList));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据字典Id集合,获取查询后的字典数据。
|
|
||||||
*
|
|
||||||
* @param dictIds 字典Id集合。
|
|
||||||
* @return 应答结果对象,包含字典形式的数据集合。
|
|
||||||
*/
|
|
||||||
@PostMapping("/listDictByIds")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> listDictByIds(
|
|
||||||
@MyRequestBody(elementType = Long.class) List<Long> dictIds) {
|
|
||||||
List<Student> resultList = studentService.getInList(new HashSet<>(dictIds));
|
|
||||||
return ResponseResult.success(
|
|
||||||
BeanQuery.select("studentId as id", "studentName as name").executeFrom(resultList));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键Id集合,获取数据对象集合。仅限于微服务间远程接口调用。
|
|
||||||
*
|
|
||||||
* @param studentIds 主键Id集合。
|
|
||||||
* @param withDict 是否包含字典关联。
|
|
||||||
* @return 应答结果对象,包含主对象集合。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "listByIds")
|
|
||||||
@PostMapping("/listByIds")
|
|
||||||
public ResponseResult<List<StudentVo>> listByIds(
|
|
||||||
@RequestParam Set<Long> studentIds, @RequestParam Boolean withDict) {
|
|
||||||
return super.baseListByIds(studentIds, withDict, Student.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键Id,获取数据对象。仅限于微服务间远程接口调用。
|
|
||||||
*
|
|
||||||
* @param studentId 主键Id。
|
|
||||||
* @param withDict 是否包含字典关联。
|
|
||||||
* @return 应答结果对象,包含主对象数据。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "getById")
|
|
||||||
@PostMapping("/getById")
|
|
||||||
public ResponseResult<StudentVo> getById(
|
|
||||||
@RequestParam Long studentId, @RequestParam Boolean withDict) {
|
|
||||||
return super.baseGetById(studentId, withDict, Student.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数列表中指定的主键Id集合,是否全部存在。仅限于微服务间远程接口调用。
|
|
||||||
*
|
|
||||||
* @param studentIds 主键Id集合。
|
|
||||||
* @return 应答结果对象,包含true全部存在,否则false。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "existIds")
|
|
||||||
@PostMapping("/existIds")
|
|
||||||
public ResponseResult<Boolean> existIds(@RequestParam Set<Long> studentIds) {
|
|
||||||
return super.baseExistIds(studentIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断参数列表中指定的主键Id是否存在。仅限于微服务间远程接口调用。
|
|
||||||
*
|
|
||||||
* @param studentId 主键Id。
|
|
||||||
* @return 应答结果对象,包含true表示存在,否则false。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "existId")
|
|
||||||
@PostMapping("/existId")
|
|
||||||
public ResponseResult<Boolean> existId(@RequestParam Long studentId) {
|
|
||||||
return super.baseExistId(studentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存或更新数据。
|
|
||||||
*
|
|
||||||
* @param data 主键Id为null时表示新增数据,否则更新数据。
|
|
||||||
* @return 应答结果对象,主键Id。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "saveNewOrUpdate")
|
|
||||||
@PostMapping("/saveNewOrUpdate")
|
|
||||||
public ResponseResult<StudentVo> saveNewOrUpdate(@RequestBody StudentDto data) {
|
|
||||||
Student student = MyModelUtil.copyTo(data, Student.class);
|
|
||||||
service().saveNewOrUpdate(student, studentService::saveNew, studentService::update);
|
|
||||||
return ResponseResult.success(Student.INSTANCE.fromModel(student));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量新增或保存数据列表。
|
|
||||||
*
|
|
||||||
* @param dataList 数据列表。主键Id为null时表示新增数据,否则更新数据。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "saveNewOrUpdateBatch")
|
|
||||||
@PostMapping("/saveNewOrUpdateBatch")
|
|
||||||
public ResponseResult<Void> saveNewOrUpdateBatch(@RequestBody List<StudentDto> dataList) {
|
|
||||||
List<Student> studentList = MyModelUtil.copyCollectionTo(dataList, Student.class);
|
|
||||||
service().saveNewOrUpdateBatch(studentList, studentService::saveNewBatch, studentService::update);
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据最新对象列表和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
|
||||||
*
|
|
||||||
* @param data 数据对象。
|
|
||||||
* 主键有值是视为更新操作的数据比对,因此仅当关联Id变化时才会验证。
|
|
||||||
* 主键为空视为新增操作的数据比对,所有关联Id都会被验证。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "verifyRelatedData")
|
|
||||||
@PostMapping("/verifyRelatedData")
|
|
||||||
public ResponseResult<Void> verifyRelatedData(@RequestBody StudentDto data) {
|
|
||||||
Student student = MyModelUtil.copyTo(data, Student.class);
|
|
||||||
return super.baseVerifyRelatedData(student, Student::getStudentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据最新对象列表和原有对象列表的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
|
||||||
*
|
|
||||||
* @param dataList 数据对象列表。
|
|
||||||
* @return 应答结果对象。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "verifyRelatedDataList")
|
|
||||||
@PostMapping("/verifyRelatedDataList")
|
|
||||||
public ResponseResult<Void> verifyRelatedDataList(@RequestBody List<StudentDto> dataList) {
|
|
||||||
List<Student> studentList = MyModelUtil.copyCollectionTo(dataList, Student.class);
|
|
||||||
return super.baseVerifyRelatedDataList(studentList, Student::getStudentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键Id删除数据。
|
|
||||||
*
|
|
||||||
* @param studentId 主键Id。
|
|
||||||
* @return 删除数量。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "deleteById")
|
|
||||||
@PostMapping("/deleteById")
|
|
||||||
public ResponseResult<Integer> deleteById(@RequestParam Long studentId) throws Exception {
|
|
||||||
Student filter = new Student();
|
|
||||||
filter.setStudentId(studentId);
|
|
||||||
return super.baseDeleteBy(filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除符合过滤条件的数据。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @return 删除数量。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "deleteBy")
|
|
||||||
@PostMapping("/deleteBy")
|
|
||||||
public ResponseResult<Integer> deleteBy(@RequestBody StudentDto filter) throws Exception {
|
|
||||||
return super.baseDeleteBy(MyModelUtil.copyTo(filter, Student.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 复杂的查询调用,包括(in list)过滤,对象条件过滤,分页和排序等。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 分页数据集合对象。如MyQueryParam参数的分页属性为空,则不会执行分页操作,只是基于MyPageData对象返回数据结果。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "listBy")
|
|
||||||
@PostMapping("/listBy")
|
|
||||||
public ResponseResult<MyPageData<StudentVo>> listBy(@RequestBody MyQueryParam queryParam) {
|
|
||||||
return super.baseListBy(queryParam, Student.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 复杂的查询调用,包括(in list)过滤,对象条件过滤,分页和排序等。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 分页数据集合对象。如MyQueryParam参数的分页属性为空,则不会执行分页操作,只是基于MyPageData对象返回数据结果。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "listMapBy")
|
|
||||||
@PostMapping("/listMapBy")
|
|
||||||
public ResponseResult<MyPageData<Map<String, Object>>> listMapBy(@RequestBody MyQueryParam queryParam) {
|
|
||||||
return super.baseListMapBy(queryParam, Student.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 复杂的查询调用,仅返回单体记录。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含符合查询过滤条件的对象结果集。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "getBy")
|
|
||||||
@PostMapping("/getBy")
|
|
||||||
public ResponseResult<StudentVo> getBy(@RequestBody MyQueryParam queryParam) {
|
|
||||||
return super.baseGetBy(queryParam, Student.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程主对象中符合查询条件的数据数量。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 应答结果对象,包含结果数量。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "countBy")
|
|
||||||
@PostMapping("/countBy")
|
|
||||||
public ResponseResult<Integer> countBy(@RequestBody MyQueryParam queryParam) {
|
|
||||||
return super.baseCountBy(queryParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程对象中符合查询条件的分组聚合计算Map列表。
|
|
||||||
*
|
|
||||||
* @param aggregationParam 聚合参数。
|
|
||||||
* @return 应该结果对象,包含聚合计算后的分组Map列表。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "aggregateBy")
|
|
||||||
@PostMapping("/aggregateBy")
|
|
||||||
public ResponseResult<List<Map<String, Object>>> aggregateBy(@RequestBody MyAggregationParam aggregationParam) {
|
|
||||||
return super.baseAggregateBy(aggregationParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据过滤字段和过滤集合,返回不存在的数据。主要用于微服务间远程过程调用。
|
|
||||||
*
|
|
||||||
* @param queryParam 查询参数。
|
|
||||||
* @return 不存在的数据集合。
|
|
||||||
*/
|
|
||||||
@ApiOperation(hidden = true, value = "notExist")
|
|
||||||
@PostMapping("/notExist")
|
|
||||||
public ResponseResult<List<?>> notExist(@RequestBody MyQueryParam queryParam) {
|
|
||||||
List<?> notExistIdSet = service().notExist(
|
|
||||||
queryParam.getInFilterField(), queryParam.getInFilterValues(), true);
|
|
||||||
return ResponseResult.success(notExistIdSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResponseResult<Void> doDelete(Long studentId) {
|
|
||||||
String errorMessage;
|
|
||||||
// 验证关联Id的数据合法性
|
|
||||||
Student originalStudent = studentService.getById(studentId);
|
|
||||||
if (originalStudent == null) {
|
|
||||||
// NOTE: 修改下面方括号中的话述
|
|
||||||
errorMessage = "数据验证失败,当前 [对象] 并不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
if (!studentService.remove(studentId)) {
|
|
||||||
errorMessage = "数据操作失败,删除的对象不存在,请刷新后重试!";
|
|
||||||
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage);
|
|
||||||
}
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.courseclassservice.model.AreaCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行政区划数据操作访问接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public interface AreaCodeMapper extends BaseDaoMapper<AreaCode> {
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.courseclassservice.model.ClassCourse;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据操作访问接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public interface ClassCourseMapper extends BaseDaoMapper<ClassCourse> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入对象列表。
|
|
||||||
*
|
|
||||||
* @param classCourseList 新增对象列表。
|
|
||||||
*/
|
|
||||||
void insertList(List<ClassCourse> classCourseList);
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.courseclassservice.model.ClassStudent;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据操作访问接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public interface ClassStudentMapper extends BaseDaoMapper<ClassStudent> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入对象列表。
|
|
||||||
*
|
|
||||||
* @param classStudentList 新增对象列表。
|
|
||||||
*/
|
|
||||||
void insertList(List<ClassStudent> classStudentList);
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.courseclassservice.model.Course;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程数据数据操作访问接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public interface CourseMapper extends BaseDaoMapper<Course> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入对象列表。
|
|
||||||
*
|
|
||||||
* @param courseList 新增对象列表。
|
|
||||||
*/
|
|
||||||
void insertList(List<Course> courseList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取过滤后的对象列表。
|
|
||||||
*
|
|
||||||
* @param inFilterColumn 参与(In-list)过滤的数据表列。
|
|
||||||
* @param inFilterValues 参与(In-list)过滤的数据表列值集合。
|
|
||||||
* @param courseFilter 过滤对象。
|
|
||||||
* @param orderBy 排序字符串,order by从句的参数。
|
|
||||||
* @return 对象列表。
|
|
||||||
*/
|
|
||||||
<M> List<Course> getCourseList(
|
|
||||||
@Param("inFilterColumn") String inFilterColumn,
|
|
||||||
@Param("inFilterValues") Set<M> inFilterValues,
|
|
||||||
@Param("courseFilter") Course courseFilter,
|
|
||||||
@Param("orderBy") String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取对象列表,过滤条件中包含like和between条件,以及指定属性的(in list)过滤条件。
|
|
||||||
*
|
|
||||||
* @param inFilterColumn 参与(In-list)过滤的数据表列。
|
|
||||||
* @param inFilterValues 参与(In-list)过滤的数据表列值集合。
|
|
||||||
* @param courseFilter 过滤对象。
|
|
||||||
* @return 对象列表。
|
|
||||||
*/
|
|
||||||
<M> Integer getCourseCount(
|
|
||||||
@Param("inFilterColumn") String inFilterColumn,
|
|
||||||
@Param("inFilterValues") Set<M> inFilterValues,
|
|
||||||
@Param("courseFilter") Course courseFilter);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据关联主表Id,获取关联从表数据列表。
|
|
||||||
*
|
|
||||||
* @param classId 关联主表Id。
|
|
||||||
* @param courseFilter 从表过滤对象。
|
|
||||||
* @param orderBy 排序字符串,order by从句的参数。
|
|
||||||
* @return 从表数据列表。
|
|
||||||
*/
|
|
||||||
List<Course> getCourseListByClassId(
|
|
||||||
@Param("classId") Long classId,
|
|
||||||
@Param("courseFilter") Course courseFilter,
|
|
||||||
@Param("orderBy") String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据关联主表Id,获取关联从表中没有和主表建立关联关系的数据列表。
|
|
||||||
*
|
|
||||||
* @param classId 关联主表Id。
|
|
||||||
* @param courseFilter 过滤对象。
|
|
||||||
* @param orderBy 排序字符串,order by从句的参数。
|
|
||||||
* @return 与主表没有建立关联的从表数据列表。
|
|
||||||
*/
|
|
||||||
List<Course> getNotInCourseListByClassId(
|
|
||||||
@Param("classId") Long classId,
|
|
||||||
@Param("courseFilter") Course courseFilter,
|
|
||||||
@Param("orderBy") String orderBy);
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.courseclassservice.model.Grade;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 年级数据操作访问接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public interface GradeMapper extends BaseDaoMapper<Grade> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入对象列表。
|
|
||||||
*
|
|
||||||
* @param gradeList 新增对象列表。
|
|
||||||
*/
|
|
||||||
void insertList(List<Grade> gradeList);
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.courseclassservice.model.MaterialEdition;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据操作访问接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public interface MaterialEditionMapper extends BaseDaoMapper<MaterialEdition> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入对象列表。
|
|
||||||
*
|
|
||||||
* @param materialEditionList 新增对象列表。
|
|
||||||
*/
|
|
||||||
void insertList(List<MaterialEdition> materialEditionList);
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.annotation.EnableDataPerm;
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.courseclassservice.model.StudentClass;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级数据数据操作访问接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@EnableDataPerm
|
|
||||||
public interface StudentClassMapper extends BaseDaoMapper<StudentClass> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入对象列表。
|
|
||||||
*
|
|
||||||
* @param studentClassList 新增对象列表。
|
|
||||||
*/
|
|
||||||
void insertList(List<StudentClass> studentClassList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取过滤后的对象列表。
|
|
||||||
*
|
|
||||||
* @param inFilterColumn 参与(In-list)过滤的数据表列。
|
|
||||||
* @param inFilterValues 参与(In-list)过滤的数据表列值集合。
|
|
||||||
* @param studentClassFilter 过滤对象。
|
|
||||||
* @param orderBy 排序字符串,order by从句的参数。
|
|
||||||
* @return 对象列表。
|
|
||||||
*/
|
|
||||||
<M> List<StudentClass> getStudentClassList(
|
|
||||||
@Param("inFilterColumn") String inFilterColumn,
|
|
||||||
@Param("inFilterValues") Set<M> inFilterValues,
|
|
||||||
@Param("studentClassFilter") StudentClass studentClassFilter,
|
|
||||||
@Param("orderBy") String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取对象列表,过滤条件中包含like和between条件,以及指定属性的(in list)过滤条件。
|
|
||||||
*
|
|
||||||
* @param inFilterColumn 参与(In-list)过滤的数据表列。
|
|
||||||
* @param inFilterValues 参与(In-list)过滤的数据表列值集合。
|
|
||||||
* @param studentClassFilter 过滤对象。
|
|
||||||
* @return 对象列表。
|
|
||||||
*/
|
|
||||||
<M> Integer getStudentClassCount(
|
|
||||||
@Param("inFilterColumn") String inFilterColumn,
|
|
||||||
@Param("inFilterValues") Set<M> inFilterValues,
|
|
||||||
@Param("studentClassFilter") StudentClass studentClassFilter);
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.dao;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.annotation.EnableDataPerm;
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.courseclassservice.model.Student;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生数据数据操作访问接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@EnableDataPerm
|
|
||||||
public interface StudentMapper extends BaseDaoMapper<Student> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入对象列表。
|
|
||||||
*
|
|
||||||
* @param studentList 新增对象列表。
|
|
||||||
*/
|
|
||||||
void insertList(List<Student> studentList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取过滤后的对象列表。
|
|
||||||
*
|
|
||||||
* @param inFilterColumn 参与(In-list)过滤的数据表列。
|
|
||||||
* @param inFilterValues 参与(In-list)过滤的数据表列值集合。
|
|
||||||
* @param studentFilter 过滤对象。
|
|
||||||
* @param orderBy 排序字符串,order by从句的参数。
|
|
||||||
* @return 对象列表。
|
|
||||||
*/
|
|
||||||
<M> List<Student> getStudentList(
|
|
||||||
@Param("inFilterColumn") String inFilterColumn,
|
|
||||||
@Param("inFilterValues") Set<M> inFilterValues,
|
|
||||||
@Param("studentFilter") Student studentFilter,
|
|
||||||
@Param("orderBy") String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取对象列表,过滤条件中包含like和between条件,以及指定属性的(in list)过滤条件。
|
|
||||||
*
|
|
||||||
* @param inFilterColumn 参与(In-list)过滤的数据表列。
|
|
||||||
* @param inFilterValues 参与(In-list)过滤的数据表列值集合。
|
|
||||||
* @param studentFilter 过滤对象。
|
|
||||||
* @return 对象列表。
|
|
||||||
*/
|
|
||||||
<M> Integer getStudentCount(
|
|
||||||
@Param("inFilterColumn") String inFilterColumn,
|
|
||||||
@Param("inFilterValues") Set<M> inFilterValues,
|
|
||||||
@Param("studentFilter") Student studentFilter);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据关联主表Id,获取关联从表数据列表。
|
|
||||||
*
|
|
||||||
* @param classId 关联主表Id。
|
|
||||||
* @param studentFilter 从表过滤对象。
|
|
||||||
* @param orderBy 排序字符串,order by从句的参数。
|
|
||||||
* @return 从表数据列表。
|
|
||||||
*/
|
|
||||||
List<Student> getStudentListByClassId(
|
|
||||||
@Param("classId") Long classId,
|
|
||||||
@Param("studentFilter") Student studentFilter,
|
|
||||||
@Param("orderBy") String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据关联主表Id,获取关联从表中没有和主表建立关联关系的数据列表。
|
|
||||||
*
|
|
||||||
* @param classId 关联主表Id。
|
|
||||||
* @param studentFilter 过滤对象。
|
|
||||||
* @param orderBy 排序字符串,order by从句的参数。
|
|
||||||
* @return 与主表没有建立关联的从表数据列表。
|
|
||||||
*/
|
|
||||||
List<Student> getNotInStudentListByClassId(
|
|
||||||
@Param("classId") Long classId,
|
|
||||||
@Param("studentFilter") Student studentFilter,
|
|
||||||
@Param("orderBy") String orderBy);
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.courseclassservice.dao.AreaCodeMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.courseclassservice.model.AreaCode">
|
|
||||||
<id column="area_id" jdbcType="BIGINT" property="areaId"/>
|
|
||||||
<result column="area_name" jdbcType="VARCHAR" property="areaName"/>
|
|
||||||
<result column="area_level" jdbcType="INTEGER" property="areaLevel"/>
|
|
||||||
<result column="parent_id" jdbcType="BIGINT" property="parentId"/>
|
|
||||||
</resultMap>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.courseclassservice.dao.ClassCourseMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.courseclassservice.model.ClassCourse">
|
|
||||||
<id column="class_id" jdbcType="BIGINT" property="classId"/>
|
|
||||||
<id column="course_id" jdbcType="BIGINT" property="courseId"/>
|
|
||||||
<result column="course_order" jdbcType="TINYINT" property="courseOrder"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<insert id="insertList">
|
|
||||||
INSERT INTO zz_class_course
|
|
||||||
(class_id,
|
|
||||||
course_id,
|
|
||||||
course_order)
|
|
||||||
VALUES
|
|
||||||
<foreach collection="list" index="index" item="item" separator="," >
|
|
||||||
(#{item.classId},
|
|
||||||
#{item.courseId},
|
|
||||||
#{item.courseOrder})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.courseclassservice.dao.ClassStudentMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.courseclassservice.model.ClassStudent">
|
|
||||||
<id column="class_id" jdbcType="BIGINT" property="classId"/>
|
|
||||||
<id column="student_id" jdbcType="BIGINT" property="studentId"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<insert id="insertList">
|
|
||||||
INSERT INTO zz_class_student
|
|
||||||
(class_id,
|
|
||||||
student_id)
|
|
||||||
VALUES
|
|
||||||
<foreach collection="list" index="index" item="item" separator="," >
|
|
||||||
(#{item.classId},
|
|
||||||
#{item.studentId})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,158 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.courseclassservice.dao.CourseMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.courseclassservice.model.Course">
|
|
||||||
<id column="course_id" jdbcType="BIGINT" property="courseId"/>
|
|
||||||
<result column="course_name" jdbcType="VARCHAR" property="courseName"/>
|
|
||||||
<result column="price" jdbcType="DECIMAL" property="price"/>
|
|
||||||
<result column="description" jdbcType="VARCHAR" property="description"/>
|
|
||||||
<result column="difficulty" jdbcType="INTEGER" property="difficulty"/>
|
|
||||||
<result column="grade_id" jdbcType="TINYINT" property="gradeId"/>
|
|
||||||
<result column="subject_id" jdbcType="TINYINT" property="subjectId"/>
|
|
||||||
<result column="class_hour" jdbcType="INTEGER" property="classHour"/>
|
|
||||||
<result column="picture_url" jdbcType="VARCHAR" property="pictureUrl"/>
|
|
||||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
|
||||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
|
||||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<resultMap id="BaseResultMapWithClassCourse" type="com.orangeforms.courseclassservice.model.Course" extends="BaseResultMap">
|
|
||||||
<association property="classCourse" column="course_id" foreignColumn="course_id"
|
|
||||||
notNullColumn="course_id" resultMap="com.orangeforms.courseclassservice.dao.ClassCourseMapper.BaseResultMap" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<insert id="insertList">
|
|
||||||
INSERT INTO zz_course
|
|
||||||
(course_id,
|
|
||||||
course_name,
|
|
||||||
price,
|
|
||||||
description,
|
|
||||||
difficulty,
|
|
||||||
grade_id,
|
|
||||||
subject_id,
|
|
||||||
class_hour,
|
|
||||||
picture_url,
|
|
||||||
create_user_id,
|
|
||||||
create_time,
|
|
||||||
update_time)
|
|
||||||
VALUES
|
|
||||||
<foreach collection="list" index="index" item="item" separator="," >
|
|
||||||
(#{item.courseId},
|
|
||||||
#{item.courseName},
|
|
||||||
#{item.price},
|
|
||||||
#{item.description},
|
|
||||||
#{item.difficulty},
|
|
||||||
#{item.gradeId},
|
|
||||||
#{item.subjectId},
|
|
||||||
#{item.classHour},
|
|
||||||
#{item.pictureUrl},
|
|
||||||
#{item.createUserId},
|
|
||||||
#{item.createTime},
|
|
||||||
#{item.updateTime})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
|
||||||
<sql id="filterRef">
|
|
||||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
|
||||||
<include refid="com.orangeforms.courseclassservice.dao.CourseMapper.inputFilterRef"/>
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
|
||||||
<sql id="inputFilterRef">
|
|
||||||
<if test="courseFilter != null">
|
|
||||||
<if test="courseFilter.courseName != null and courseFilter.courseName != ''">
|
|
||||||
<bind name = "safeCourseCourseName" value = "'%' + courseFilter.courseName + '%'" />
|
|
||||||
AND zz_course.course_name LIKE #{safeCourseCourseName}
|
|
||||||
</if>
|
|
||||||
<if test="courseFilter.priceStart != null">
|
|
||||||
AND zz_course.price >= #{courseFilter.priceStart}
|
|
||||||
</if>
|
|
||||||
<if test="courseFilter.priceEnd != null">
|
|
||||||
AND zz_course.price <= #{courseFilter.priceEnd}
|
|
||||||
</if>
|
|
||||||
<if test="courseFilter.difficulty != null">
|
|
||||||
AND zz_course.difficulty = #{courseFilter.difficulty}
|
|
||||||
</if>
|
|
||||||
<if test="courseFilter.gradeId != null">
|
|
||||||
AND zz_course.grade_id = #{courseFilter.gradeId}
|
|
||||||
</if>
|
|
||||||
<if test="courseFilter.subjectId != null">
|
|
||||||
AND zz_course.subject_id = #{courseFilter.subjectId}
|
|
||||||
</if>
|
|
||||||
<if test="courseFilter.classHourStart != null">
|
|
||||||
AND zz_course.class_hour >= #{courseFilter.classHourStart}
|
|
||||||
</if>
|
|
||||||
<if test="courseFilter.classHourEnd != null">
|
|
||||||
AND zz_course.class_hour <= #{courseFilter.classHourEnd}
|
|
||||||
</if>
|
|
||||||
<if test="courseFilter.updateTimeStart != null and courseFilter.updateTimeStart != ''">
|
|
||||||
AND zz_course.update_time >= #{courseFilter.updateTimeStart}
|
|
||||||
</if>
|
|
||||||
<if test="courseFilter.updateTimeEnd != null and courseFilter.updateTimeEnd != ''">
|
|
||||||
AND zz_course.update_time <= #{courseFilter.updateTimeEnd}
|
|
||||||
</if>
|
|
||||||
</if>
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="getCourseList" resultMap="BaseResultMap" parameterType="com.orangeforms.courseclassservice.model.Course">
|
|
||||||
SELECT * FROM zz_course
|
|
||||||
<where>
|
|
||||||
<if test="inFilterColumn != null and inFilterColumn != '' and inFilterValues != null and inFilterValues.size > 0">
|
|
||||||
AND ${inFilterColumn} IN
|
|
||||||
<foreach collection="inFilterValues" item="item" open="(" separator="," close=")">
|
|
||||||
'${item}'
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
<if test="orderBy != null and orderBy != ''">
|
|
||||||
ORDER BY ${orderBy}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getCourseCount" resultType="java.lang.Integer" parameterType="com.orangeforms.courseclassservice.model.Course">
|
|
||||||
SELECT COUNT(1) FROM zz_course
|
|
||||||
<where>
|
|
||||||
<if test="inFilterColumn != null and inFilterColumn != '' and inFilterValues != null and inFilterValues.size > 0">
|
|
||||||
AND ${inFilterColumn} IN
|
|
||||||
<foreach collection="inFilterValues" item="item" open="(" separator="," close=")">
|
|
||||||
'${item}'
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getCourseListByClassId" resultMap="BaseResultMapWithClassCourse">
|
|
||||||
SELECT
|
|
||||||
zz_course.*,
|
|
||||||
zz_class_course.*
|
|
||||||
FROM
|
|
||||||
zz_course,
|
|
||||||
zz_class_course
|
|
||||||
<where>
|
|
||||||
AND zz_class_course.class_id = #{classId}
|
|
||||||
AND zz_class_course.course_id = zz_course.course_id
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
<if test="orderBy != null and orderBy != ''">
|
|
||||||
ORDER BY ${orderBy}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getNotInCourseListByClassId" resultMap="BaseResultMap">
|
|
||||||
SELECT
|
|
||||||
zz_course.*
|
|
||||||
FROM
|
|
||||||
zz_course
|
|
||||||
<where>
|
|
||||||
AND NOT EXISTS (SELECT * FROM zz_class_course
|
|
||||||
WHERE zz_class_course.class_id = #{classId} AND zz_class_course.course_id = zz_course.course_id)
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
<if test="orderBy != null and orderBy != ''">
|
|
||||||
ORDER BY ${orderBy}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.courseclassservice.dao.GradeMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.courseclassservice.model.Grade">
|
|
||||||
<id column="grade_id" jdbcType="INTEGER" property="gradeId"/>
|
|
||||||
<result column="grade_name" jdbcType="VARCHAR" property="gradeName"/>
|
|
||||||
<result column="status" jdbcType="INTEGER" property="status"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<insert id="insertList">
|
|
||||||
INSERT INTO zz_grade
|
|
||||||
(grade_id,
|
|
||||||
grade_name,
|
|
||||||
status)
|
|
||||||
VALUES
|
|
||||||
<foreach collection="list" index="index" item="item" separator="," >
|
|
||||||
(#{item.gradeId},
|
|
||||||
#{item.gradeName},
|
|
||||||
#{item.status})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.courseclassservice.dao.MaterialEditionMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.courseclassservice.model.MaterialEdition">
|
|
||||||
<id column="edition_id" jdbcType="INTEGER" property="editionId"/>
|
|
||||||
<result column="edition_name" jdbcType="VARCHAR" property="editionName"/>
|
|
||||||
<result column="status" jdbcType="INTEGER" property="status"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<insert id="insertList">
|
|
||||||
INSERT INTO zz_material_edition
|
|
||||||
(edition_id,
|
|
||||||
edition_name,
|
|
||||||
status)
|
|
||||||
VALUES
|
|
||||||
<foreach collection="list" index="index" item="item" separator="," >
|
|
||||||
(#{item.editionId},
|
|
||||||
#{item.editionName},
|
|
||||||
#{item.status})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.courseclassservice.dao.StudentClassMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.courseclassservice.model.StudentClass">
|
|
||||||
<id column="class_id" jdbcType="BIGINT" property="classId"/>
|
|
||||||
<result column="class_name" jdbcType="VARCHAR" property="className"/>
|
|
||||||
<result column="school_id" jdbcType="BIGINT" property="schoolId"/>
|
|
||||||
<result column="leader_id" jdbcType="BIGINT" property="leaderId"/>
|
|
||||||
<result column="finish_class_hour" jdbcType="INTEGER" property="finishClassHour"/>
|
|
||||||
<result column="class_level" jdbcType="TINYINT" property="classLevel"/>
|
|
||||||
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
|
|
||||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
|
||||||
<result column="status" jdbcType="TINYINT" property="status"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<insert id="insertList">
|
|
||||||
INSERT INTO zz_class
|
|
||||||
(class_id,
|
|
||||||
class_name,
|
|
||||||
school_id,
|
|
||||||
leader_id,
|
|
||||||
finish_class_hour,
|
|
||||||
class_level,
|
|
||||||
create_user_id,
|
|
||||||
create_time,
|
|
||||||
status)
|
|
||||||
VALUES
|
|
||||||
<foreach collection="list" index="index" item="item" separator="," >
|
|
||||||
(#{item.classId},
|
|
||||||
#{item.className},
|
|
||||||
#{item.schoolId},
|
|
||||||
#{item.leaderId},
|
|
||||||
#{item.finishClassHour},
|
|
||||||
#{item.classLevel},
|
|
||||||
#{item.createUserId},
|
|
||||||
#{item.createTime},
|
|
||||||
#{item.status})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
|
||||||
<sql id="filterRef">
|
|
||||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
|
||||||
<include refid="com.orangeforms.courseclassservice.dao.StudentClassMapper.inputFilterRef"/>
|
|
||||||
AND zz_class.status = ${@com.orangeforms.common.core.constant.GlobalDeletedFlag@NORMAL}
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
|
||||||
<sql id="inputFilterRef">
|
|
||||||
<if test="studentClassFilter != null">
|
|
||||||
<if test="studentClassFilter.className != null and studentClassFilter.className != ''">
|
|
||||||
AND zz_class.class_name = #{studentClassFilter.className}
|
|
||||||
</if>
|
|
||||||
<if test="studentClassFilter.schoolId != null">
|
|
||||||
AND zz_class.school_id = #{studentClassFilter.schoolId}
|
|
||||||
</if>
|
|
||||||
<if test="studentClassFilter.classLevel != null">
|
|
||||||
AND zz_class.class_level = #{studentClassFilter.classLevel}
|
|
||||||
</if>
|
|
||||||
</if>
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="getStudentClassList" resultMap="BaseResultMap" parameterType="com.orangeforms.courseclassservice.model.StudentClass">
|
|
||||||
SELECT * FROM zz_class
|
|
||||||
<where>
|
|
||||||
<if test="inFilterColumn != null and inFilterColumn != '' and inFilterValues != null and inFilterValues.size > 0">
|
|
||||||
AND ${inFilterColumn} IN
|
|
||||||
<foreach collection="inFilterValues" item="item" open="(" separator="," close=")">
|
|
||||||
'${item}'
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
<if test="orderBy != null and orderBy != ''">
|
|
||||||
ORDER BY ${orderBy}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getStudentClassCount" resultType="java.lang.Integer" parameterType="com.orangeforms.courseclassservice.model.StudentClass">
|
|
||||||
SELECT COUNT(1) FROM zz_class
|
|
||||||
<where>
|
|
||||||
<if test="inFilterColumn != null and inFilterColumn != '' and inFilterValues != null and inFilterValues.size > 0">
|
|
||||||
AND ${inFilterColumn} IN
|
|
||||||
<foreach collection="inFilterValues" item="item" open="(" separator="," close=")">
|
|
||||||
'${item}'
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,164 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.orangeforms.courseclassservice.dao.StudentMapper">
|
|
||||||
<resultMap id="BaseResultMap" type="com.orangeforms.courseclassservice.model.Student">
|
|
||||||
<id column="student_id" jdbcType="BIGINT" property="studentId"/>
|
|
||||||
<result column="login_mobile" jdbcType="VARCHAR" property="loginMobile"/>
|
|
||||||
<result column="student_name" jdbcType="VARCHAR" property="studentName"/>
|
|
||||||
<result column="province_id" jdbcType="BIGINT" property="provinceId"/>
|
|
||||||
<result column="city_id" jdbcType="BIGINT" property="cityId"/>
|
|
||||||
<result column="district_id" jdbcType="BIGINT" property="districtId"/>
|
|
||||||
<result column="gender" jdbcType="INTEGER" property="gender"/>
|
|
||||||
<result column="birthday" jdbcType="DATE" property="birthday"/>
|
|
||||||
<result column="experience_level" jdbcType="TINYINT" property="experienceLevel"/>
|
|
||||||
<result column="total_coin" jdbcType="INTEGER" property="totalCoin"/>
|
|
||||||
<result column="left_coin" jdbcType="INTEGER" property="leftCoin"/>
|
|
||||||
<result column="grade_id" jdbcType="INTEGER" property="gradeId"/>
|
|
||||||
<result column="school_id" jdbcType="BIGINT" property="schoolId"/>
|
|
||||||
<result column="register_time" jdbcType="TIMESTAMP" property="registerTime"/>
|
|
||||||
<result column="status" jdbcType="TINYINT" property="status"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<insert id="insertList">
|
|
||||||
INSERT INTO zz_student
|
|
||||||
(student_id,
|
|
||||||
login_mobile,
|
|
||||||
student_name,
|
|
||||||
province_id,
|
|
||||||
city_id,
|
|
||||||
district_id,
|
|
||||||
gender,
|
|
||||||
birthday,
|
|
||||||
experience_level,
|
|
||||||
total_coin,
|
|
||||||
left_coin,
|
|
||||||
grade_id,
|
|
||||||
school_id,
|
|
||||||
register_time,
|
|
||||||
status)
|
|
||||||
VALUES
|
|
||||||
<foreach collection="list" index="index" item="item" separator="," >
|
|
||||||
(#{item.studentId},
|
|
||||||
#{item.loginMobile},
|
|
||||||
#{item.studentName},
|
|
||||||
#{item.provinceId},
|
|
||||||
#{item.cityId},
|
|
||||||
#{item.districtId},
|
|
||||||
#{item.gender},
|
|
||||||
#{item.birthday},
|
|
||||||
#{item.experienceLevel},
|
|
||||||
#{item.totalCoin},
|
|
||||||
#{item.leftCoin},
|
|
||||||
#{item.gradeId},
|
|
||||||
#{item.schoolId},
|
|
||||||
#{item.registerTime},
|
|
||||||
#{item.status})
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<!-- 如果有逻辑删除字段过滤,请写到这里 -->
|
|
||||||
<sql id="filterRef">
|
|
||||||
<!-- 这里必须加上全包名,否则当filterRef被其他Mapper.xml包含引用的时候,就会调用Mapper.xml中的该SQL片段 -->
|
|
||||||
<include refid="com.orangeforms.courseclassservice.dao.StudentMapper.inputFilterRef"/>
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<!-- 这里仅包含调用接口输入的主表过滤条件 -->
|
|
||||||
<sql id="inputFilterRef">
|
|
||||||
<if test="studentFilter != null">
|
|
||||||
<if test="studentFilter.provinceId != null">
|
|
||||||
AND zz_student.province_id = #{studentFilter.provinceId}
|
|
||||||
</if>
|
|
||||||
<if test="studentFilter.cityId != null">
|
|
||||||
AND zz_student.city_id = #{studentFilter.cityId}
|
|
||||||
</if>
|
|
||||||
<if test="studentFilter.districtId != null">
|
|
||||||
AND zz_student.district_id = #{studentFilter.districtId}
|
|
||||||
</if>
|
|
||||||
<if test="studentFilter.birthdayStart != null and studentFilter.birthdayStart != ''">
|
|
||||||
AND zz_student.birthday >= #{studentFilter.birthdayStart}
|
|
||||||
</if>
|
|
||||||
<if test="studentFilter.birthdayEnd != null and studentFilter.birthdayEnd != ''">
|
|
||||||
AND zz_student.birthday <= #{studentFilter.birthdayEnd}
|
|
||||||
</if>
|
|
||||||
<if test="studentFilter.gradeId != null">
|
|
||||||
AND zz_student.grade_id = #{studentFilter.gradeId}
|
|
||||||
</if>
|
|
||||||
<if test="studentFilter.schoolId != null">
|
|
||||||
AND zz_student.school_id = #{studentFilter.schoolId}
|
|
||||||
</if>
|
|
||||||
<if test="studentFilter.registerTimeStart != null and studentFilter.registerTimeStart != ''">
|
|
||||||
AND zz_student.register_time >= #{studentFilter.registerTimeStart}
|
|
||||||
</if>
|
|
||||||
<if test="studentFilter.registerTimeEnd != null and studentFilter.registerTimeEnd != ''">
|
|
||||||
AND zz_student.register_time <= #{studentFilter.registerTimeEnd}
|
|
||||||
</if>
|
|
||||||
<if test="studentFilter.status != null">
|
|
||||||
AND zz_student.status = #{studentFilter.status}
|
|
||||||
</if>
|
|
||||||
<if test="studentFilter.searchString != null and studentFilter.searchString != ''">
|
|
||||||
<bind name = "safeStudentSearchString" value = "'%' + studentFilter.searchString + '%'" />
|
|
||||||
AND CONCAT(IFNULL(zz_student.login_mobile,''), IFNULL(zz_student.student_name,'')) LIKE #{safeStudentSearchString}
|
|
||||||
</if>
|
|
||||||
</if>
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="getStudentList" resultMap="BaseResultMap" parameterType="com.orangeforms.courseclassservice.model.Student">
|
|
||||||
SELECT * FROM zz_student
|
|
||||||
<where>
|
|
||||||
<if test="inFilterColumn != null and inFilterColumn != '' and inFilterValues != null and inFilterValues.size > 0">
|
|
||||||
AND ${inFilterColumn} IN
|
|
||||||
<foreach collection="inFilterValues" item="item" open="(" separator="," close=")">
|
|
||||||
'${item}'
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
<if test="orderBy != null and orderBy != ''">
|
|
||||||
ORDER BY ${orderBy}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getStudentCount" resultType="java.lang.Integer" parameterType="com.orangeforms.courseclassservice.model.Student">
|
|
||||||
SELECT COUNT(1) FROM zz_student
|
|
||||||
<where>
|
|
||||||
<if test="inFilterColumn != null and inFilterColumn != '' and inFilterValues != null and inFilterValues.size > 0">
|
|
||||||
AND ${inFilterColumn} IN
|
|
||||||
<foreach collection="inFilterValues" item="item" open="(" separator="," close=")">
|
|
||||||
'${item}'
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getStudentListByClassId" resultMap="BaseResultMap">
|
|
||||||
SELECT
|
|
||||||
zz_student.*
|
|
||||||
FROM
|
|
||||||
zz_student,
|
|
||||||
zz_class_student
|
|
||||||
<where>
|
|
||||||
AND zz_class_student.class_id = #{classId}
|
|
||||||
AND zz_class_student.student_id = zz_student.student_id
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
<if test="orderBy != null and orderBy != ''">
|
|
||||||
ORDER BY ${orderBy}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="getNotInStudentListByClassId" resultMap="BaseResultMap">
|
|
||||||
SELECT
|
|
||||||
zz_student.*
|
|
||||||
FROM
|
|
||||||
zz_student
|
|
||||||
<where>
|
|
||||||
AND NOT EXISTS (SELECT * FROM zz_class_student
|
|
||||||
WHERE zz_class_student.class_id = #{classId} AND zz_class_student.student_id = zz_student.student_id)
|
|
||||||
<include refid="filterRef"/>
|
|
||||||
</where>
|
|
||||||
<if test="orderBy != null and orderBy != ''">
|
|
||||||
ORDER BY ${orderBy}
|
|
||||||
</if>
|
|
||||||
</select>
|
|
||||||
</mapper>
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行政区划实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_area_code")
|
|
||||||
public class AreaCode {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行政区划主键Id
|
|
||||||
*/
|
|
||||||
@TableId(value = "area_id")
|
|
||||||
private Long areaId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行政区划名称
|
|
||||||
*/
|
|
||||||
@TableField(value = "area_name")
|
|
||||||
private String areaName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行政区划级别 (1: 省级别 2: 市级别 3: 区级别)
|
|
||||||
*/
|
|
||||||
@TableField(value = "area_level")
|
|
||||||
private Integer areaLevel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 父级行政区划Id
|
|
||||||
*/
|
|
||||||
@TableField(value = "parent_id")
|
|
||||||
private Long parentId;
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ClassCourse实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_class_course")
|
|
||||||
public class ClassCourse {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "class_id")
|
|
||||||
private Long classId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "course_id")
|
|
||||||
private Long courseId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程顺序(数值越小越靠前)。
|
|
||||||
*/
|
|
||||||
@TableField(value = "course_order")
|
|
||||||
private Integer courseOrder;
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ClassStudent实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_class_student")
|
|
||||||
public class ClassStudent {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "class_id")
|
|
||||||
private Long classId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "student_id")
|
|
||||||
private Long studentId;
|
|
||||||
}
|
|
||||||
@@ -1,183 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import com.orangeforms.courseclassapi.vo.CourseVo;
|
|
||||||
import com.orangeforms.courseclassapi.constant.CourseDifficult;
|
|
||||||
import com.orangeforms.application.common.constant.Subject;
|
|
||||||
import com.orangeforms.common.core.upload.UploadStoreTypeEnum;
|
|
||||||
import com.orangeforms.common.core.annotation.*;
|
|
||||||
import com.orangeforms.common.core.base.mapper.BaseModelMapper;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.mapstruct.*;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Course实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_course")
|
|
||||||
public class Course {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键Id。
|
|
||||||
*/
|
|
||||||
@TableId(value = "course_id")
|
|
||||||
private Long courseId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程名称。
|
|
||||||
*/
|
|
||||||
@TableField(value = "course_name")
|
|
||||||
private String courseName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程价格。
|
|
||||||
*/
|
|
||||||
private BigDecimal price;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程描述。
|
|
||||||
*/
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程难度(0: 容易 1: 普通 2: 很难)。
|
|
||||||
*/
|
|
||||||
private Integer difficulty;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 年级Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "grade_id")
|
|
||||||
private Integer gradeId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学科Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "subject_id")
|
|
||||||
private Integer subjectId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课时数量。
|
|
||||||
*/
|
|
||||||
@TableField(value = "class_hour")
|
|
||||||
private Integer classHour;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 多张课程图片地址。
|
|
||||||
*/
|
|
||||||
@UploadFlagColumn(storeType = UploadStoreTypeEnum.LOCAL_SYSTEM)
|
|
||||||
@TableField(value = "picture_url")
|
|
||||||
private String pictureUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建用户Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_user_id")
|
|
||||||
private Long createUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_time")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最后修改时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_time")
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* price 范围过滤起始值(>=)。
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private BigDecimal priceStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* price 范围过滤结束值(<=)。
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private BigDecimal priceEnd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* classHour 范围过滤起始值(>=)。
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Integer classHourStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* classHour 范围过滤结束值(<=)。
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Integer classHourEnd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* updateTime 范围过滤起始值(>=)。
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String updateTimeStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* updateTime 范围过滤结束值(<=)。
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String updateTimeEnd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* courseId 的多对多关联表数据对象。
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private ClassCourse classCourse;
|
|
||||||
|
|
||||||
@RelationDict(
|
|
||||||
masterIdField = "gradeId",
|
|
||||||
slaveServiceName = "gradeService",
|
|
||||||
slaveModelClass = Grade.class,
|
|
||||||
slaveIdField = "gradeId",
|
|
||||||
slaveNameField = "gradeName")
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> gradeIdDictMap;
|
|
||||||
|
|
||||||
@RelationConstDict(
|
|
||||||
masterIdField = "difficulty",
|
|
||||||
constantDictClass = CourseDifficult.class)
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> difficultyDictMap;
|
|
||||||
|
|
||||||
@RelationConstDict(
|
|
||||||
masterIdField = "subjectId",
|
|
||||||
constantDictClass = Subject.class)
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> subjectIdDictMap;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface CourseModelMapper extends BaseModelMapper<CourseVo, Course> {
|
|
||||||
/**
|
|
||||||
* 转换Vo对象到实体对象。
|
|
||||||
*
|
|
||||||
* @param courseVo 域对象。
|
|
||||||
* @return 实体对象。
|
|
||||||
*/
|
|
||||||
@Mapping(target = "classCourse", expression = "java(mapToBean(courseVo.getClassCourse(), com.orangeforms.courseclassservice.model.ClassCourse.class))")
|
|
||||||
@Override
|
|
||||||
Course toModel(CourseVo courseVo);
|
|
||||||
/**
|
|
||||||
* 转换实体对象到VO对象。
|
|
||||||
*
|
|
||||||
* @param course 实体对象。
|
|
||||||
* @return 域对象。
|
|
||||||
*/
|
|
||||||
@Mapping(target = "classCourse", expression = "java(beanToMap(course.getClassCourse(), false))")
|
|
||||||
@Override
|
|
||||||
CourseVo fromModel(Course course);
|
|
||||||
}
|
|
||||||
public static final CourseModelMapper INSTANCE = Mappers.getMapper(CourseModelMapper.class);
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Grade实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_grade")
|
|
||||||
public class Grade {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键Id。
|
|
||||||
*/
|
|
||||||
@TableId(value = "grade_id", type = IdType.AUTO)
|
|
||||||
private Integer gradeId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 年级名称。
|
|
||||||
*/
|
|
||||||
@TableField(value = "grade_name")
|
|
||||||
private String gradeName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
|
|
||||||
*/
|
|
||||||
@TableLogic
|
|
||||||
private Integer status;
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MaterialEdition实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_material_edition")
|
|
||||||
public class MaterialEdition {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键Id。
|
|
||||||
*/
|
|
||||||
@TableId(value = "edition_id", type = IdType.AUTO)
|
|
||||||
private Integer editionId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 教材版本名称。
|
|
||||||
*/
|
|
||||||
@TableField(value = "edition_name")
|
|
||||||
private String editionName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否正在使用(0:不是,1:是)。
|
|
||||||
*/
|
|
||||||
private Integer status;
|
|
||||||
}
|
|
||||||
@@ -1,235 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import com.orangeforms.courseclassapi.vo.StudentVo;
|
|
||||||
import com.orangeforms.upmsapi.client.SysDeptClient;
|
|
||||||
import com.orangeforms.upmsapi.vo.SysDeptVo;
|
|
||||||
import com.orangeforms.application.common.constant.Gender;
|
|
||||||
import com.orangeforms.application.common.constant.ExpLevel;
|
|
||||||
import com.orangeforms.application.common.constant.StudentStatus;
|
|
||||||
import com.orangeforms.common.core.annotation.*;
|
|
||||||
import com.orangeforms.common.core.base.mapper.BaseModelMapper;
|
|
||||||
import com.orangeforms.common.core.util.MyCommonUtil;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.mapstruct.*;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Student实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_student")
|
|
||||||
public class Student {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生Id。
|
|
||||||
*/
|
|
||||||
@TableId(value = "student_id")
|
|
||||||
private Long studentId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录手机。
|
|
||||||
*/
|
|
||||||
@TableField(value = "login_mobile")
|
|
||||||
private String loginMobile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生姓名。
|
|
||||||
*/
|
|
||||||
@TableField(value = "student_name")
|
|
||||||
private String studentName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 所在省份Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "province_id")
|
|
||||||
private Long provinceId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 所在城市Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "city_id")
|
|
||||||
private Long cityId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 区县Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "district_id")
|
|
||||||
private Long districtId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生性别 (0: 女生 1: 男生)。
|
|
||||||
*/
|
|
||||||
private Integer gender;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生日。
|
|
||||||
*/
|
|
||||||
private Date birthday;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 经验等级 (0: 初级 1: 中级 2: 高级 3: 资深)。
|
|
||||||
*/
|
|
||||||
@TableField(value = "experience_level")
|
|
||||||
private Integer experienceLevel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 总共充值学币数量。
|
|
||||||
*/
|
|
||||||
@TableField(value = "total_coin")
|
|
||||||
private Integer totalCoin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 可用学币数量。
|
|
||||||
*/
|
|
||||||
@TableField(value = "left_coin")
|
|
||||||
private Integer leftCoin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 年级Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "grade_id")
|
|
||||||
private Integer gradeId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校区Id。
|
|
||||||
*/
|
|
||||||
@DeptFilterColumn
|
|
||||||
@TableField(value = "school_id")
|
|
||||||
private Long schoolId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注册时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "register_time")
|
|
||||||
private Date registerTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生状态 (0: 正常 1: 锁定 2: 注销)。
|
|
||||||
*/
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* birthday 范围过滤起始值(>=)。
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String birthdayStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* birthday 范围过滤结束值(<=)。
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String birthdayEnd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* registerTime 范围过滤起始值(>=)。
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String registerTimeStart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* registerTime 范围过滤结束值(<=)。
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String registerTimeEnd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* true LIKE搜索字符串。
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private String searchString;
|
|
||||||
|
|
||||||
public void setSearchString(String searchString) {
|
|
||||||
this.searchString = MyCommonUtil.replaceSqlWildcard(searchString);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RelationDict(
|
|
||||||
masterIdField = "schoolId",
|
|
||||||
slaveClientClass = SysDeptClient.class,
|
|
||||||
slaveModelClass = SysDeptVo.class,
|
|
||||||
slaveIdField = "deptId",
|
|
||||||
slaveNameField = "deptName")
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> schoolIdDictMap;
|
|
||||||
|
|
||||||
@RelationDict(
|
|
||||||
masterIdField = "provinceId",
|
|
||||||
slaveServiceName = "areaCodeService",
|
|
||||||
slaveModelClass = AreaCode.class,
|
|
||||||
slaveIdField = "areaId",
|
|
||||||
slaveNameField = "areaName")
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> provinceIdDictMap;
|
|
||||||
|
|
||||||
@RelationDict(
|
|
||||||
masterIdField = "cityId",
|
|
||||||
slaveServiceName = "areaCodeService",
|
|
||||||
slaveModelClass = AreaCode.class,
|
|
||||||
slaveIdField = "areaId",
|
|
||||||
slaveNameField = "areaName")
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> cityIdDictMap;
|
|
||||||
|
|
||||||
@RelationDict(
|
|
||||||
masterIdField = "districtId",
|
|
||||||
slaveServiceName = "areaCodeService",
|
|
||||||
slaveModelClass = AreaCode.class,
|
|
||||||
slaveIdField = "areaId",
|
|
||||||
slaveNameField = "areaName")
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> districtIdDictMap;
|
|
||||||
|
|
||||||
@RelationDict(
|
|
||||||
masterIdField = "gradeId",
|
|
||||||
slaveServiceName = "gradeService",
|
|
||||||
slaveModelClass = Grade.class,
|
|
||||||
slaveIdField = "gradeId",
|
|
||||||
slaveNameField = "gradeName")
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> gradeIdDictMap;
|
|
||||||
|
|
||||||
@RelationConstDict(
|
|
||||||
masterIdField = "gender",
|
|
||||||
constantDictClass = Gender.class)
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> genderDictMap;
|
|
||||||
|
|
||||||
@RelationConstDict(
|
|
||||||
masterIdField = "experienceLevel",
|
|
||||||
constantDictClass = ExpLevel.class)
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> experienceLevelDictMap;
|
|
||||||
|
|
||||||
@RelationConstDict(
|
|
||||||
masterIdField = "status",
|
|
||||||
constantDictClass = StudentStatus.class)
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> statusDictMap;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface StudentModelMapper extends BaseModelMapper<StudentVo, Student> {
|
|
||||||
/**
|
|
||||||
* 转换Vo对象到实体对象。
|
|
||||||
*
|
|
||||||
* @param studentVo 域对象。
|
|
||||||
* @return 实体对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
Student toModel(StudentVo studentVo);
|
|
||||||
/**
|
|
||||||
* 转换实体对象到VO对象。
|
|
||||||
*
|
|
||||||
* @param student 实体对象。
|
|
||||||
* @return 域对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
StudentVo fromModel(Student student);
|
|
||||||
}
|
|
||||||
public static final StudentModelMapper INSTANCE = Mappers.getMapper(StudentModelMapper.class);
|
|
||||||
}
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.model;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import com.orangeforms.courseclassapi.vo.StudentClassVo;
|
|
||||||
import com.orangeforms.upmsapi.client.SysDeptClient;
|
|
||||||
import com.orangeforms.upmsapi.vo.SysDeptVo;
|
|
||||||
import com.orangeforms.courseclassapi.constant.ClassLevel;
|
|
||||||
import com.orangeforms.common.core.annotation.*;
|
|
||||||
import com.orangeforms.common.core.base.mapper.BaseModelMapper;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.mapstruct.*;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* StudentClass实体对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "zz_class")
|
|
||||||
public class StudentClass {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级Id。
|
|
||||||
*/
|
|
||||||
@TableId(value = "class_id")
|
|
||||||
private Long classId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级名称。
|
|
||||||
*/
|
|
||||||
@TableField(value = "class_name")
|
|
||||||
private String className;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学校Id。
|
|
||||||
*/
|
|
||||||
@DeptFilterColumn
|
|
||||||
@TableField(value = "school_id")
|
|
||||||
private Long schoolId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生班长Id。
|
|
||||||
*/
|
|
||||||
@TableField(value = "leader_id")
|
|
||||||
private Long leaderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 已完成课时数量。
|
|
||||||
*/
|
|
||||||
@TableField(value = "finish_class_hour")
|
|
||||||
private Integer finishClassHour;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级级别(0: 初级班 1: 培优班 2: 冲刺提分班 3: 竞赛班)。
|
|
||||||
*/
|
|
||||||
@TableField(value = "class_level")
|
|
||||||
private Integer classLevel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建用户。
|
|
||||||
*/
|
|
||||||
@UserFilterColumn
|
|
||||||
@TableField(value = "create_user_id")
|
|
||||||
private Long createUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级创建时间。
|
|
||||||
*/
|
|
||||||
@TableField(value = "create_time")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。
|
|
||||||
*/
|
|
||||||
@TableLogic
|
|
||||||
private Integer status;
|
|
||||||
|
|
||||||
@RelationDict(
|
|
||||||
masterIdField = "schoolId",
|
|
||||||
slaveClientClass = SysDeptClient.class,
|
|
||||||
slaveModelClass = SysDeptVo.class,
|
|
||||||
slaveIdField = "deptId",
|
|
||||||
slaveNameField = "deptName")
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> schoolIdDictMap;
|
|
||||||
|
|
||||||
@RelationDict(
|
|
||||||
masterIdField = "leaderId",
|
|
||||||
slaveServiceName = "studentService",
|
|
||||||
slaveModelClass = Student.class,
|
|
||||||
slaveIdField = "studentId",
|
|
||||||
slaveNameField = "studentName")
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> leaderIdDictMap;
|
|
||||||
|
|
||||||
@RelationConstDict(
|
|
||||||
masterIdField = "classLevel",
|
|
||||||
constantDictClass = ClassLevel.class)
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> classLevelDictMap;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface StudentClassModelMapper extends BaseModelMapper<StudentClassVo, StudentClass> {
|
|
||||||
/**
|
|
||||||
* 转换Vo对象到实体对象。
|
|
||||||
*
|
|
||||||
* @param studentClassVo 域对象。
|
|
||||||
* @return 实体对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
StudentClass toModel(StudentClassVo studentClassVo);
|
|
||||||
/**
|
|
||||||
* 转换实体对象到VO对象。
|
|
||||||
*
|
|
||||||
* @param studentClass 实体对象。
|
|
||||||
* @return 域对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
StudentClassVo fromModel(StudentClass studentClass);
|
|
||||||
}
|
|
||||||
public static final StudentClassModelMapper INSTANCE = Mappers.getMapper(StudentClassModelMapper.class);
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.service;
|
|
||||||
|
|
||||||
import com.orangeforms.courseclassservice.model.AreaCode;
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseDictService;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行政区划的Service接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public interface AreaCodeService extends IBaseDictService<AreaCode, Long> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据上级行政区划Id,获取其下级行政区划列表。
|
|
||||||
*
|
|
||||||
* @param parentId 上级行政区划Id。
|
|
||||||
* @return 下级行政区划列表。
|
|
||||||
*/
|
|
||||||
Collection<AreaCode> getListByParentId(Long parentId);
|
|
||||||
}
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.service;
|
|
||||||
|
|
||||||
import com.orangeforms.courseclassservice.model.*;
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseService;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 课程数据数据操作服务接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public interface CourseService extends IBaseService<Course, Long> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增对象。
|
|
||||||
*
|
|
||||||
* @param course 新增对象。
|
|
||||||
* @return 返回新增对象。
|
|
||||||
*/
|
|
||||||
Course saveNew(Course course);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 利用数据库的insertList语法,批量插入对象列表。
|
|
||||||
*
|
|
||||||
* @param courseList 新增对象列表。
|
|
||||||
*/
|
|
||||||
void saveNewBatch(List<Course> courseList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新数据对象。
|
|
||||||
*
|
|
||||||
* @param course 更新的对象。
|
|
||||||
* @param originalCourse 原有数据对象。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean update(Course course, Course originalCourse);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定数据。
|
|
||||||
*
|
|
||||||
* @param courseId 主键Id。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean remove(Long courseId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
|
||||||
* 如果需要同时获取关联数据,请移步(getCourseListWithRelation)方法。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
List<Course> getCourseList(Course filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
|
||||||
* 由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
|
||||||
* 如果需要同时获取关联数据,请移步(getCourseListWithRelation)方法。
|
|
||||||
*
|
|
||||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
|
||||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
<M> List<Course> getCourseList(String inFilterField, Set<M> inFilterValues, Course filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
|
||||||
* 如果仅仅需要获取主表数据,请移步(getCourseList),以便获取更好的查询性能。
|
|
||||||
*
|
|
||||||
* @param filter 主表过滤对象。
|
|
||||||
* @param orderBy 排序对象。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
List<Course> getCourseListWithRelation(Course filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
|
||||||
* 同时还包含主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
|
||||||
* 如果仅仅需要获取主表数据,请移步(getCourseList),以便获取更好的查询性能。
|
|
||||||
*
|
|
||||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
|
||||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
|
||||||
* @param filter 主表过滤对象。
|
|
||||||
* @param orderBy 排序对象。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
<M> List<Course> getCourseListWithRelation(
|
|
||||||
String inFilterField, Set<M> inFilterValues, Course filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。
|
|
||||||
*
|
|
||||||
* @param classId 主表的关联键Id。
|
|
||||||
* @param filter 从表的过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
List<Course> getNotInCourseListByClassId(Long classId, Course filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。
|
|
||||||
*
|
|
||||||
* @param classId 主表的关联键Id。
|
|
||||||
* @param filter 从表的过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
List<Course> getCourseListByClassId(Long classId, Course filter, String orderBy);
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.service;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseDictService;
|
|
||||||
import com.orangeforms.courseclassservice.model.Grade;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 年级字典数据操作服务接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public interface GradeService extends IBaseDictService<Grade, Integer> {
|
|
||||||
}
|
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.service;
|
|
||||||
|
|
||||||
import com.orangeforms.courseclassservice.model.*;
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseService;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 班级数据数据操作服务接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public interface StudentClassService extends IBaseService<StudentClass, Long> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增对象。
|
|
||||||
*
|
|
||||||
* @param studentClass 新增对象。
|
|
||||||
* @return 返回新增对象。
|
|
||||||
*/
|
|
||||||
StudentClass saveNew(StudentClass studentClass);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 利用数据库的insertList语法,批量插入对象列表。
|
|
||||||
*
|
|
||||||
* @param studentClassList 新增对象列表。
|
|
||||||
*/
|
|
||||||
void saveNewBatch(List<StudentClass> studentClassList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新数据对象。
|
|
||||||
*
|
|
||||||
* @param studentClass 更新的对象。
|
|
||||||
* @param originalStudentClass 原有数据对象。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean update(StudentClass studentClass, StudentClass originalStudentClass);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定数据。
|
|
||||||
*
|
|
||||||
* @param classId 主键Id。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean remove(Long classId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
|
||||||
* 如果需要同时获取关联数据,请移步(getStudentClassListWithRelation)方法。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
List<StudentClass> getStudentClassList(StudentClass filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
|
||||||
* 由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
|
||||||
* 如果需要同时获取关联数据,请移步(getStudentClassListWithRelation)方法。
|
|
||||||
*
|
|
||||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
|
||||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
<M> List<StudentClass> getStudentClassList(String inFilterField, Set<M> inFilterValues, StudentClass filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
|
||||||
* 如果仅仅需要获取主表数据,请移步(getStudentClassList),以便获取更好的查询性能。
|
|
||||||
*
|
|
||||||
* @param filter 主表过滤对象。
|
|
||||||
* @param orderBy 排序对象。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
List<StudentClass> getStudentClassListWithRelation(StudentClass filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
|
||||||
* 同时还包含主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
|
||||||
* 如果仅仅需要获取主表数据,请移步(getStudentClassList),以便获取更好的查询性能。
|
|
||||||
*
|
|
||||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
|
||||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
|
||||||
* @param filter 主表过滤对象。
|
|
||||||
* @param orderBy 排序对象。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
<M> List<StudentClass> getStudentClassListWithRelation(
|
|
||||||
String inFilterField, Set<M> inFilterValues, StudentClass filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量添加多对多关联关系。
|
|
||||||
*
|
|
||||||
* @param classCourseList 多对多关联表对象集合。
|
|
||||||
* @param classId 主表Id。
|
|
||||||
*/
|
|
||||||
void addClassCourseList(List<ClassCourse> classCourseList, Long classId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新中间表数据。
|
|
||||||
*
|
|
||||||
* @param classCourse 中间表对象。
|
|
||||||
* @return 更新成功与否。
|
|
||||||
*/
|
|
||||||
boolean updateClassCourse(ClassCourse classCourse);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取中间表数据。
|
|
||||||
*
|
|
||||||
* @param classId 主表Id。
|
|
||||||
* @param courseId 从表Id。
|
|
||||||
* @return 中间表对象。
|
|
||||||
*/
|
|
||||||
ClassCourse getClassCourse(Long classId, Long courseId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 移除单条多对多关系。
|
|
||||||
*
|
|
||||||
* @param classId 主表Id。
|
|
||||||
* @param courseId 从表Id。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean removeClassCourse(Long classId, Long courseId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量添加多对多关联关系。
|
|
||||||
*
|
|
||||||
* @param classStudentList 多对多关联表对象集合。
|
|
||||||
* @param classId 主表Id。
|
|
||||||
*/
|
|
||||||
void addClassStudentList(List<ClassStudent> classStudentList, Long classId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 移除单条多对多关系。
|
|
||||||
*
|
|
||||||
* @param classId 主表Id。
|
|
||||||
* @param studentId 从表Id。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean removeClassStudent(Long classId, Long studentId);
|
|
||||||
}
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.service;
|
|
||||||
|
|
||||||
import com.orangeforms.courseclassservice.model.*;
|
|
||||||
import com.orangeforms.common.core.base.service.IBaseService;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生数据数据操作服务接口。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public interface StudentService extends IBaseService<Student, Long> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增对象。
|
|
||||||
*
|
|
||||||
* @param student 新增对象。
|
|
||||||
* @return 返回新增对象。
|
|
||||||
*/
|
|
||||||
Student saveNew(Student student);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 利用数据库的insertList语法,批量插入对象列表。
|
|
||||||
*
|
|
||||||
* @param studentList 新增对象列表。
|
|
||||||
*/
|
|
||||||
void saveNewBatch(List<Student> studentList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新数据对象。
|
|
||||||
*
|
|
||||||
* @param student 更新的对象。
|
|
||||||
* @param originalStudent 原有数据对象。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean update(Student student, Student originalStudent);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定数据。
|
|
||||||
*
|
|
||||||
* @param studentId 主键Id。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
boolean remove(Long studentId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
|
||||||
* 如果需要同时获取关联数据,请移步(getStudentListWithRelation)方法。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
List<Student> getStudentList(Student filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
|
||||||
* 由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
|
||||||
* 如果需要同时获取关联数据,请移步(getStudentListWithRelation)方法。
|
|
||||||
*
|
|
||||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
|
||||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
<M> List<Student> getStudentList(String inFilterField, Set<M> inFilterValues, Student filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
|
||||||
* 如果仅仅需要获取主表数据,请移步(getStudentList),以便获取更好的查询性能。
|
|
||||||
*
|
|
||||||
* @param filter 主表过滤对象。
|
|
||||||
* @param orderBy 排序对象。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
List<Student> getStudentListWithRelation(Student filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
|
||||||
* 同时还包含主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
|
||||||
* 如果仅仅需要获取主表数据,请移步(getStudentList),以便获取更好的查询性能。
|
|
||||||
*
|
|
||||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
|
||||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
|
||||||
* @param filter 主表过滤对象。
|
|
||||||
* @param orderBy 排序对象。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
<M> List<Student> getStudentListWithRelation(
|
|
||||||
String inFilterField, Set<M> inFilterValues, Student filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。
|
|
||||||
*
|
|
||||||
* @param classId 主表的关联键Id。
|
|
||||||
* @param filter 从表的过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
List<Student> getNotInStudentListByClassId(Long classId, Student filter, String orderBy);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。
|
|
||||||
*
|
|
||||||
* @param classId 主表的关联键Id。
|
|
||||||
* @param filter 从表的过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
List<Student> getStudentListByClassId(Long classId, Student filter, String orderBy);
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.service.impl;
|
|
||||||
|
|
||||||
import com.orangeforms.courseclassservice.service.AreaCodeService;
|
|
||||||
import com.orangeforms.courseclassservice.dao.AreaCodeMapper;
|
|
||||||
import com.orangeforms.courseclassservice.model.AreaCode;
|
|
||||||
import com.orangeforms.common.core.cache.MapTreeDictionaryCache;
|
|
||||||
import com.orangeforms.common.core.base.service.BaseDictService;
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 行政区划的Service类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Service("areaCodeService")
|
|
||||||
public class AreaCodeServiceImpl extends BaseDictService<AreaCode, Long> implements AreaCodeService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AreaCodeMapper areaCodeMapper;
|
|
||||||
|
|
||||||
public AreaCodeServiceImpl() {
|
|
||||||
super();
|
|
||||||
this.dictionaryCache = MapTreeDictionaryCache.create(AreaCode::getAreaId, AreaCode::getParentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
public void init() {
|
|
||||||
this.reloadCachedData(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BaseDaoMapper<AreaCode> mapper() {
|
|
||||||
return areaCodeMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据上级行政区划Id,获取其下级行政区划列表。
|
|
||||||
*
|
|
||||||
* @param parentId 上级行政区划Id。
|
|
||||||
* @return 下级行政区划列表。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Collection<AreaCode> getListByParentId(Long parentId) {
|
|
||||||
return ((MapTreeDictionaryCache<Long, AreaCode>) dictionaryCache).getListByParentId(parentId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,253 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.service.impl;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.*;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
||||||
import com.orangeforms.courseclassservice.service.*;
|
|
||||||
import com.orangeforms.courseclassservice.dao.*;
|
|
||||||
import com.orangeforms.courseclassservice.model.*;
|
|
||||||
import com.orangeforms.common.core.util.*;
|
|
||||||
import com.orangeforms.common.core.object.MyRelationParam;
|
|
||||||
import com.orangeforms.common.core.object.CallResult;
|
|
||||||
import com.orangeforms.common.core.object.TokenData;
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.common.core.base.service.BaseService;
|
|
||||||
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import com.github.pagehelper.Page;
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service("courseService")
|
|
||||||
public class CourseServiceImpl extends BaseService<Course, Long> implements CourseService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CourseMapper courseMapper;
|
|
||||||
@Autowired
|
|
||||||
private ClassCourseMapper classCourseMapper;
|
|
||||||
@Autowired
|
|
||||||
private GradeService gradeService;
|
|
||||||
@Autowired
|
|
||||||
private IdGeneratorWrapper idGenerator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回当前Service的主表Mapper对象。
|
|
||||||
*
|
|
||||||
* @return 主表Mapper对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected BaseDaoMapper<Course> mapper() {
|
|
||||||
return courseMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增对象。
|
|
||||||
*
|
|
||||||
* @param course 新增对象。
|
|
||||||
* @return 返回新增对象。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public Course saveNew(Course course) {
|
|
||||||
courseMapper.insert(this.buildDefaultValue(course));
|
|
||||||
return course;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 利用数据库的insertList语法,批量插入对象列表。
|
|
||||||
*
|
|
||||||
* @param courseList 新增对象列表。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public void saveNewBatch(List<Course> courseList) {
|
|
||||||
if (CollUtil.isNotEmpty(courseList)) {
|
|
||||||
courseList.forEach(this::buildDefaultValue);
|
|
||||||
courseMapper.insertList(courseList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新数据对象。
|
|
||||||
*
|
|
||||||
* @param course 更新的对象。
|
|
||||||
* @param originalCourse 原有数据对象。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean update(Course course, Course originalCourse) {
|
|
||||||
course.setCreateUserId(originalCourse.getCreateUserId());
|
|
||||||
course.setCreateTime(originalCourse.getCreateTime());
|
|
||||||
course.setUpdateTime(new Date());
|
|
||||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
|
||||||
UpdateWrapper<Course> uw = this.createUpdateQueryForNullValue(course, course.getCourseId());
|
|
||||||
return courseMapper.update(course, uw) == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定数据。
|
|
||||||
*
|
|
||||||
* @param courseId 主键Id。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean remove(Long courseId) {
|
|
||||||
if (courseMapper.deleteById(courseId) == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// 开始删除与本地多对多父表的关联
|
|
||||||
ClassCourse classCourse = new ClassCourse();
|
|
||||||
classCourse.setCourseId(courseId);
|
|
||||||
classCourseMapper.delete(new QueryWrapper<>(classCourse));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
|
||||||
* 如果需要同时获取关联数据,请移步(getCourseListWithRelation)方法。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Course> getCourseList(Course filter, String orderBy) {
|
|
||||||
return courseMapper.getCourseList(null, null, filter, orderBy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
|
||||||
* 由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
|
||||||
* 如果需要同时获取关联数据,请移步(getCourseListWithRelation)方法。
|
|
||||||
*
|
|
||||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
|
||||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public <M> List<Course> getCourseList(
|
|
||||||
String inFilterField, Set<M> inFilterValues, Course filter, String orderBy) {
|
|
||||||
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, Course.class);
|
|
||||||
return courseMapper.getCourseList(inFilterColumn, inFilterValues, filter, orderBy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
|
||||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
|
||||||
* 如果仅仅需要获取主表数据,请移步(getCourseList),以便获取更好的查询性能。
|
|
||||||
*
|
|
||||||
* @param filter 主表过滤对象。
|
|
||||||
* @param orderBy 排序对象。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Course> getCourseListWithRelation(Course filter, String orderBy) {
|
|
||||||
List<Course> resultList = courseMapper.getCourseList(null, null, filter, orderBy);
|
|
||||||
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
|
|
||||||
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
|
|
||||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
|
||||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
|
||||||
return resultList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
|
||||||
* 同时还包含主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
|
||||||
* 如果仅仅需要获取主表数据,请移步(getCourseList),以便获取更好的查询性能。
|
|
||||||
*
|
|
||||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
|
||||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
|
||||||
* @param filter 主表过滤对象。
|
|
||||||
* @param orderBy 排序对象。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public <M> List<Course> getCourseListWithRelation(
|
|
||||||
String inFilterField, Set<M> inFilterValues, Course filter, String orderBy) {
|
|
||||||
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, Course.class);
|
|
||||||
List<Course> resultList =
|
|
||||||
courseMapper.getCourseList(inFilterColumn, inFilterValues, filter, orderBy);
|
|
||||||
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
|
|
||||||
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
|
|
||||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
|
||||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly(), batchSize);
|
|
||||||
return resultList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。
|
|
||||||
*
|
|
||||||
* @param classId 主表的关联键Id。
|
|
||||||
* @param filter 从表的过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Course> getNotInCourseListByClassId(Long classId, Course filter, String orderBy) {
|
|
||||||
List<Course> resultList;
|
|
||||||
if (classId != null) {
|
|
||||||
resultList = courseMapper.getNotInCourseListByClassId(classId, filter, orderBy);
|
|
||||||
} else {
|
|
||||||
resultList = getCourseList(filter, orderBy);
|
|
||||||
}
|
|
||||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
|
|
||||||
return resultList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。
|
|
||||||
*
|
|
||||||
* @param classId 主表的关联键Id。
|
|
||||||
* @param filter 从表的过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Course> getCourseListByClassId(Long classId, Course filter, String orderBy) {
|
|
||||||
List<Course> resultList =
|
|
||||||
courseMapper.getCourseListByClassId(classId, filter, orderBy);
|
|
||||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
|
|
||||||
return resultList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
|
||||||
*
|
|
||||||
* @param course 最新数据对象。
|
|
||||||
* @param originalCourse 原有数据对象。
|
|
||||||
* @return 数据全部正确返回true,否则false,同时返回具体的错误信息。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public CallResult verifyRelatedData(Course course, Course originalCourse) {
|
|
||||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
|
||||||
if (this.needToVerify(course, originalCourse, Course::getGradeId)
|
|
||||||
&& !gradeService.existId(course.getGradeId())) {
|
|
||||||
return CallResult.error(String.format(errorMessageFormat, "所属年级"));
|
|
||||||
}
|
|
||||||
return CallResult.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Course buildDefaultValue(Course course) {
|
|
||||||
course.setCourseId(idGenerator.nextLongId());
|
|
||||||
TokenData tokenData = TokenData.takeFromRequest();
|
|
||||||
course.setCreateUserId(tokenData.getUserId());
|
|
||||||
Date now = new Date();
|
|
||||||
course.setCreateTime(now);
|
|
||||||
course.setUpdateTime(now);
|
|
||||||
return course;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.service.impl;
|
|
||||||
|
|
||||||
import com.orangeforms.common.redis.cache.RedisDictionaryCache;
|
|
||||||
import com.orangeforms.common.core.base.service.BaseDictService;
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.courseclassservice.service.GradeService;
|
|
||||||
import com.orangeforms.courseclassservice.dao.GradeMapper;
|
|
||||||
import com.orangeforms.courseclassservice.model.Grade;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.redisson.api.RedissonClient;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 年级字典数据操作服务类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service("gradeService")
|
|
||||||
public class GradeServiceImpl extends BaseDictService<Grade, Integer> implements GradeService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private GradeMapper gradeMapper;
|
|
||||||
@Autowired
|
|
||||||
private RedissonClient redissonClient;
|
|
||||||
|
|
||||||
public GradeServiceImpl() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
public void init() {
|
|
||||||
this.dictionaryCache = RedisDictionaryCache.create(
|
|
||||||
redissonClient, "Grade", Grade.class, Grade::getGradeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回当前Service的主表Mapper对象。
|
|
||||||
*
|
|
||||||
* @return 主表Mapper对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected BaseDaoMapper<Grade> mapper() {
|
|
||||||
return gradeMapper;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,341 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.service.impl;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.*;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
||||||
import com.orangeforms.courseclassservice.service.*;
|
|
||||||
import com.orangeforms.courseclassservice.dao.*;
|
|
||||||
import com.orangeforms.courseclassservice.model.*;
|
|
||||||
import com.orangeforms.upmsapi.client.SysDeptClient;
|
|
||||||
import com.orangeforms.common.core.util.*;
|
|
||||||
import com.orangeforms.common.core.object.MyRelationParam;
|
|
||||||
import com.orangeforms.common.core.object.ResponseResult;
|
|
||||||
import com.orangeforms.common.core.object.CallResult;
|
|
||||||
import com.orangeforms.common.core.object.TokenData;
|
|
||||||
import com.orangeforms.common.core.constant.GlobalDeletedFlag;
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.common.core.base.service.BaseService;
|
|
||||||
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import com.github.pagehelper.Page;
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service("studentClassService")
|
|
||||||
public class StudentClassServiceImpl extends BaseService<StudentClass, Long> implements StudentClassService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private StudentClassMapper studentClassMapper;
|
|
||||||
@Autowired
|
|
||||||
private ClassCourseMapper classCourseMapper;
|
|
||||||
@Autowired
|
|
||||||
private ClassStudentMapper classStudentMapper;
|
|
||||||
@Autowired
|
|
||||||
private StudentService studentService;
|
|
||||||
@Autowired
|
|
||||||
private SysDeptClient sysDeptClient;
|
|
||||||
@Autowired
|
|
||||||
private IdGeneratorWrapper idGenerator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回当前Service的主表Mapper对象。
|
|
||||||
*
|
|
||||||
* @return 主表Mapper对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected BaseDaoMapper<StudentClass> mapper() {
|
|
||||||
return studentClassMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增对象。
|
|
||||||
*
|
|
||||||
* @param studentClass 新增对象。
|
|
||||||
* @return 返回新增对象。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public StudentClass saveNew(StudentClass studentClass) {
|
|
||||||
studentClassMapper.insert(this.buildDefaultValue(studentClass));
|
|
||||||
return studentClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 利用数据库的insertList语法,批量插入对象列表。
|
|
||||||
*
|
|
||||||
* @param studentClassList 新增对象列表。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public void saveNewBatch(List<StudentClass> studentClassList) {
|
|
||||||
if (CollUtil.isNotEmpty(studentClassList)) {
|
|
||||||
studentClassList.forEach(this::buildDefaultValue);
|
|
||||||
studentClassMapper.insertList(studentClassList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新数据对象。
|
|
||||||
*
|
|
||||||
* @param studentClass 更新的对象。
|
|
||||||
* @param originalStudentClass 原有数据对象。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean update(StudentClass studentClass, StudentClass originalStudentClass) {
|
|
||||||
studentClass.setCreateUserId(originalStudentClass.getCreateUserId());
|
|
||||||
studentClass.setCreateTime(originalStudentClass.getCreateTime());
|
|
||||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
|
||||||
UpdateWrapper<StudentClass> uw = this.createUpdateQueryForNullValue(studentClass, studentClass.getClassId());
|
|
||||||
return studentClassMapper.update(studentClass, uw) == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定数据。
|
|
||||||
*
|
|
||||||
* @param classId 主键Id。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean remove(Long classId) {
|
|
||||||
if (studentClassMapper.deleteById(classId) == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// 开始删除多对多中间表的关联
|
|
||||||
ClassCourse classCourse = new ClassCourse();
|
|
||||||
classCourse.setClassId(classId);
|
|
||||||
classCourseMapper.delete(new QueryWrapper<>(classCourse));
|
|
||||||
ClassStudent classStudent = new ClassStudent();
|
|
||||||
classStudent.setClassId(classId);
|
|
||||||
classStudentMapper.delete(new QueryWrapper<>(classStudent));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
|
||||||
* 如果需要同时获取关联数据,请移步(getStudentClassListWithRelation)方法。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<StudentClass> getStudentClassList(StudentClass filter, String orderBy) {
|
|
||||||
return studentClassMapper.getStudentClassList(null, null, filter, orderBy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
|
||||||
* 由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
|
||||||
* 如果需要同时获取关联数据,请移步(getStudentClassListWithRelation)方法。
|
|
||||||
*
|
|
||||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
|
||||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public <M> List<StudentClass> getStudentClassList(
|
|
||||||
String inFilterField, Set<M> inFilterValues, StudentClass filter, String orderBy) {
|
|
||||||
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, StudentClass.class);
|
|
||||||
return studentClassMapper.getStudentClassList(inFilterColumn, inFilterValues, filter, orderBy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
|
||||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
|
||||||
* 如果仅仅需要获取主表数据,请移步(getStudentClassList),以便获取更好的查询性能。
|
|
||||||
*
|
|
||||||
* @param filter 主表过滤对象。
|
|
||||||
* @param orderBy 排序对象。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<StudentClass> getStudentClassListWithRelation(StudentClass filter, String orderBy) {
|
|
||||||
List<StudentClass> resultList = studentClassMapper.getStudentClassList(null, null, filter, orderBy);
|
|
||||||
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
|
|
||||||
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
|
|
||||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
|
||||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
|
||||||
return resultList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
|
||||||
* 同时还包含主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
|
||||||
* 如果仅仅需要获取主表数据,请移步(getStudentClassList),以便获取更好的查询性能。
|
|
||||||
*
|
|
||||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
|
||||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
|
||||||
* @param filter 主表过滤对象。
|
|
||||||
* @param orderBy 排序对象。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public <M> List<StudentClass> getStudentClassListWithRelation(
|
|
||||||
String inFilterField, Set<M> inFilterValues, StudentClass filter, String orderBy) {
|
|
||||||
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, StudentClass.class);
|
|
||||||
List<StudentClass> resultList =
|
|
||||||
studentClassMapper.getStudentClassList(inFilterColumn, inFilterValues, filter, orderBy);
|
|
||||||
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
|
|
||||||
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
|
|
||||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
|
||||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly(), batchSize);
|
|
||||||
return resultList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量添加多对多关联关系。
|
|
||||||
*
|
|
||||||
* @param classCourseList 多对多关联表对象集合。
|
|
||||||
* @param classId 主表Id。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public void addClassCourseList(List<ClassCourse> classCourseList, Long classId) {
|
|
||||||
for (ClassCourse classCourse : classCourseList) {
|
|
||||||
classCourse.setClassId(classId);
|
|
||||||
MyModelUtil.setDefaultValue(classCourse, "courseOrder", 0);
|
|
||||||
classCourseMapper.insert(classCourse);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新中间表数据。
|
|
||||||
*
|
|
||||||
* @param classCourse 中间表对象。
|
|
||||||
* @return 更新成功与否。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean updateClassCourse(ClassCourse classCourse) {
|
|
||||||
ClassCourse filter = new ClassCourse();
|
|
||||||
filter.setClassId(classCourse.getClassId());
|
|
||||||
filter.setCourseId(classCourse.getCourseId());
|
|
||||||
UpdateWrapper<ClassCourse> uw =
|
|
||||||
BaseService.createUpdateQueryForNullValue(classCourse, ClassCourse.class);
|
|
||||||
uw.setEntity(filter);
|
|
||||||
return classCourseMapper.update(classCourse, uw) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取中间表数据。
|
|
||||||
*
|
|
||||||
* @param classId 主表Id。
|
|
||||||
* @param courseId 从表Id。
|
|
||||||
* @return 中间表对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ClassCourse getClassCourse(Long classId, Long courseId) {
|
|
||||||
ClassCourse filter = new ClassCourse();
|
|
||||||
filter.setClassId(classId);
|
|
||||||
filter.setCourseId(courseId);
|
|
||||||
return classCourseMapper.selectOne(new QueryWrapper<>(filter));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 移除单条多对多关系。
|
|
||||||
*
|
|
||||||
* @param classId 主表Id。
|
|
||||||
* @param courseId 从表Id。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean removeClassCourse(Long classId, Long courseId) {
|
|
||||||
ClassCourse filter = new ClassCourse();
|
|
||||||
filter.setClassId(classId);
|
|
||||||
filter.setCourseId(courseId);
|
|
||||||
return classCourseMapper.delete(new QueryWrapper<>(filter)) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量添加多对多关联关系。
|
|
||||||
*
|
|
||||||
* @param classStudentList 多对多关联表对象集合。
|
|
||||||
* @param classId 主表Id。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public void addClassStudentList(List<ClassStudent> classStudentList, Long classId) {
|
|
||||||
for (ClassStudent classStudent : classStudentList) {
|
|
||||||
classStudent.setClassId(classId);
|
|
||||||
classStudentMapper.insert(classStudent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 移除单条多对多关系。
|
|
||||||
*
|
|
||||||
* @param classId 主表Id。
|
|
||||||
* @param studentId 从表Id。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean removeClassStudent(Long classId, Long studentId) {
|
|
||||||
ClassStudent filter = new ClassStudent();
|
|
||||||
filter.setClassId(classId);
|
|
||||||
filter.setStudentId(studentId);
|
|
||||||
return classStudentMapper.delete(new QueryWrapper<>(filter)) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
|
||||||
*
|
|
||||||
* @param studentClass 最新数据对象。
|
|
||||||
* @param originalStudentClass 原有数据对象。
|
|
||||||
* @return 数据全部正确返回true,否则false,同时返回具体的错误信息。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public CallResult verifyRelatedData(StudentClass studentClass, StudentClass originalStudentClass) {
|
|
||||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
|
||||||
if (this.needToVerify(studentClass, originalStudentClass, StudentClass::getLeaderId)
|
|
||||||
&& !studentService.existId(studentClass.getLeaderId())) {
|
|
||||||
return CallResult.error(String.format(errorMessageFormat, "班长"));
|
|
||||||
}
|
|
||||||
return CallResult.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据最新对象和原有对象的数据对比,判断关联的远程字典数据和多对一主表数据是否都是合法数据。
|
|
||||||
*
|
|
||||||
* @param studentClass 最新数据对象。
|
|
||||||
* @param originalStudentClass 原有数据对象。
|
|
||||||
* @return 数据全部正确返回true,否则false,同时返回具体的错误信息。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public CallResult verifyRemoteRelatedData(StudentClass studentClass, StudentClass originalStudentClass) {
|
|
||||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
|
||||||
if (this.needToVerify(studentClass, originalStudentClass, StudentClass::getSchoolId)) {
|
|
||||||
ResponseResult<Boolean> responseResult =
|
|
||||||
sysDeptClient.existId(studentClass.getSchoolId());
|
|
||||||
if (this.hasErrorOfVerifyRemoteRelatedData(responseResult)) {
|
|
||||||
return CallResult.error(String.format(errorMessageFormat, "所属校区"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CallResult.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
private StudentClass buildDefaultValue(StudentClass studentClass) {
|
|
||||||
studentClass.setClassId(idGenerator.nextLongId());
|
|
||||||
TokenData tokenData = TokenData.takeFromRequest();
|
|
||||||
studentClass.setCreateUserId(tokenData.getUserId());
|
|
||||||
studentClass.setCreateTime(new Date());
|
|
||||||
studentClass.setStatus(GlobalDeletedFlag.NORMAL);
|
|
||||||
return studentClass;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,286 +0,0 @@
|
|||||||
package com.orangeforms.courseclassservice.service.impl;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.*;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
||||||
import com.orangeforms.application.common.constant.StudentStatus;
|
|
||||||
import com.orangeforms.courseclassservice.service.*;
|
|
||||||
import com.orangeforms.courseclassservice.dao.*;
|
|
||||||
import com.orangeforms.courseclassservice.model.*;
|
|
||||||
import com.orangeforms.upmsapi.client.SysDeptClient;
|
|
||||||
import com.orangeforms.common.core.util.*;
|
|
||||||
import com.orangeforms.common.core.object.MyRelationParam;
|
|
||||||
import com.orangeforms.common.core.object.ResponseResult;
|
|
||||||
import com.orangeforms.common.core.object.CallResult;
|
|
||||||
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
|
|
||||||
import com.orangeforms.common.core.base.service.BaseService;
|
|
||||||
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import com.github.pagehelper.Page;
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Service("studentService")
|
|
||||||
public class StudentServiceImpl extends BaseService<Student, Long> implements StudentService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private StudentMapper studentMapper;
|
|
||||||
@Autowired
|
|
||||||
private ClassStudentMapper classStudentMapper;
|
|
||||||
@Autowired
|
|
||||||
private AreaCodeService areaCodeService;
|
|
||||||
@Autowired
|
|
||||||
private GradeService gradeService;
|
|
||||||
@Autowired
|
|
||||||
private SysDeptClient sysDeptClient;
|
|
||||||
@Autowired
|
|
||||||
private IdGeneratorWrapper idGenerator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回当前Service的主表Mapper对象。
|
|
||||||
*
|
|
||||||
* @return 主表Mapper对象。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected BaseDaoMapper<Student> mapper() {
|
|
||||||
return studentMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存新增对象。
|
|
||||||
*
|
|
||||||
* @param student 新增对象。
|
|
||||||
* @return 返回新增对象。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public Student saveNew(Student student) {
|
|
||||||
studentMapper.insert(this.buildDefaultValue(student));
|
|
||||||
return student;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 利用数据库的insertList语法,批量插入对象列表。
|
|
||||||
*
|
|
||||||
* @param studentList 新增对象列表。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public void saveNewBatch(List<Student> studentList) {
|
|
||||||
if (CollUtil.isNotEmpty(studentList)) {
|
|
||||||
studentList.forEach(this::buildDefaultValue);
|
|
||||||
studentMapper.insertList(studentList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新数据对象。
|
|
||||||
*
|
|
||||||
* @param student 更新的对象。
|
|
||||||
* @param originalStudent 原有数据对象。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean update(Student student, Student originalStudent) {
|
|
||||||
// 这里重点提示,在执行主表数据更新之前,如果有哪些字段不支持修改操作,请用原有数据对象字段替换当前数据字段。
|
|
||||||
UpdateWrapper<Student> uw = this.createUpdateQueryForNullValue(student, student.getStudentId());
|
|
||||||
return studentMapper.update(student, uw) == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除指定数据。
|
|
||||||
*
|
|
||||||
* @param studentId 主键Id。
|
|
||||||
* @return 成功返回true,否则false。
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Override
|
|
||||||
public boolean remove(Long studentId) {
|
|
||||||
if (studentMapper.deleteById(studentId) == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// 开始删除与本地多对多父表的关联
|
|
||||||
ClassStudent classStudent = new ClassStudent();
|
|
||||||
classStudent.setStudentId(studentId);
|
|
||||||
classStudentMapper.delete(new QueryWrapper<>(classStudent));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
|
||||||
* 如果需要同时获取关联数据,请移步(getStudentListWithRelation)方法。
|
|
||||||
*
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Student> getStudentList(Student filter, String orderBy) {
|
|
||||||
return studentMapper.getStudentList(null, null, filter, orderBy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
|
||||||
* 由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
|
|
||||||
* 如果需要同时获取关联数据,请移步(getStudentListWithRelation)方法。
|
|
||||||
*
|
|
||||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
|
||||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
|
||||||
* @param filter 过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public <M> List<Student> getStudentList(
|
|
||||||
String inFilterField, Set<M> inFilterValues, Student filter, String orderBy) {
|
|
||||||
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, Student.class);
|
|
||||||
return studentMapper.getStudentList(inFilterColumn, inFilterValues, filter, orderBy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
|
||||||
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
|
|
||||||
* 如果仅仅需要获取主表数据,请移步(getStudentList),以便获取更好的查询性能。
|
|
||||||
*
|
|
||||||
* @param filter 主表过滤对象。
|
|
||||||
* @param orderBy 排序对象。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Student> getStudentListWithRelation(Student filter, String orderBy) {
|
|
||||||
List<Student> resultList = studentMapper.getStudentList(null, null, filter, orderBy);
|
|
||||||
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
|
|
||||||
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
|
|
||||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
|
||||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize);
|
|
||||||
return resultList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取主表的查询结果,查询条件中包括主表过滤对象和指定字段的(in list)过滤。
|
|
||||||
* 同时还包含主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
|
|
||||||
* 如果仅仅需要获取主表数据,请移步(getStudentList),以便获取更好的查询性能。
|
|
||||||
*
|
|
||||||
* @param inFilterField (In-list)指定的字段(Java成员字段,而非数据列名)。
|
|
||||||
* @param inFilterValues inFilterField指定字段的(In-list)数据列表。
|
|
||||||
* @param filter 主表过滤对象。
|
|
||||||
* @param orderBy 排序对象。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public <M> List<Student> getStudentListWithRelation(
|
|
||||||
String inFilterField, Set<M> inFilterValues, Student filter, String orderBy) {
|
|
||||||
String inFilterColumn = MyModelUtil.mapToColumnName(inFilterField, Student.class);
|
|
||||||
List<Student> resultList =
|
|
||||||
studentMapper.getStudentList(inFilterColumn, inFilterValues, filter, orderBy);
|
|
||||||
// 在缺省生成的代码中,如果查询结果resultList不是Page对象,说明没有分页,那么就很可能是数据导出接口调用了当前方法。
|
|
||||||
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
|
|
||||||
int batchSize = resultList instanceof Page ? 0 : 1000;
|
|
||||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly(), batchSize);
|
|
||||||
return resultList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在多对多关系中,当前Service的数据表为从表,返回不与指定主表主键Id存在对多对关系的列表。
|
|
||||||
*
|
|
||||||
* @param classId 主表的关联键Id。
|
|
||||||
* @param filter 从表的过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Student> getNotInStudentListByClassId(Long classId, Student filter, String orderBy) {
|
|
||||||
List<Student> resultList;
|
|
||||||
if (classId != null) {
|
|
||||||
resultList = studentMapper.getNotInStudentListByClassId(classId, filter, orderBy);
|
|
||||||
} else {
|
|
||||||
resultList = getStudentList(filter, orderBy);
|
|
||||||
}
|
|
||||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
|
|
||||||
return resultList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在多对多关系中,当前Service的数据表为从表,返回与指定主表主键Id存在对多对关系的列表。
|
|
||||||
*
|
|
||||||
* @param classId 主表的关联键Id。
|
|
||||||
* @param filter 从表的过滤对象。
|
|
||||||
* @param orderBy 排序参数。
|
|
||||||
* @return 查询结果集。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Student> getStudentListByClassId(Long classId, Student filter, String orderBy) {
|
|
||||||
List<Student> resultList =
|
|
||||||
studentMapper.getStudentListByClassId(classId, filter, orderBy);
|
|
||||||
this.buildRelationForDataList(resultList, MyRelationParam.dictOnly());
|
|
||||||
return resultList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据最新对象和原有对象的数据对比,判断关联的字典数据和多对一主表数据是否都是合法数据。
|
|
||||||
*
|
|
||||||
* @param student 最新数据对象。
|
|
||||||
* @param originalStudent 原有数据对象。
|
|
||||||
* @return 数据全部正确返回true,否则false,同时返回具体的错误信息。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public CallResult verifyRelatedData(Student student, Student originalStudent) {
|
|
||||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
|
||||||
if (this.needToVerify(student, originalStudent, Student::getProvinceId)
|
|
||||||
&& !areaCodeService.existId(student.getProvinceId())) {
|
|
||||||
return CallResult.error(String.format(errorMessageFormat, "所在省份"));
|
|
||||||
}
|
|
||||||
if (this.needToVerify(student, originalStudent, Student::getCityId)
|
|
||||||
&& !areaCodeService.existId(student.getCityId())) {
|
|
||||||
return CallResult.error(String.format(errorMessageFormat, "所在城市"));
|
|
||||||
}
|
|
||||||
if (this.needToVerify(student, originalStudent, Student::getDistrictId)
|
|
||||||
&& !areaCodeService.existId(student.getDistrictId())) {
|
|
||||||
return CallResult.error(String.format(errorMessageFormat, "所在区县"));
|
|
||||||
}
|
|
||||||
if (this.needToVerify(student, originalStudent, Student::getGradeId)
|
|
||||||
&& !gradeService.existId(student.getGradeId())) {
|
|
||||||
return CallResult.error(String.format(errorMessageFormat, "年级"));
|
|
||||||
}
|
|
||||||
return CallResult.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据最新对象和原有对象的数据对比,判断关联的远程字典数据和多对一主表数据是否都是合法数据。
|
|
||||||
*
|
|
||||||
* @param student 最新数据对象。
|
|
||||||
* @param originalStudent 原有数据对象。
|
|
||||||
* @return 数据全部正确返回true,否则false,同时返回具体的错误信息。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public CallResult verifyRemoteRelatedData(Student student, Student originalStudent) {
|
|
||||||
String errorMessageFormat = "数据验证失败,关联的%s并不存在,请刷新后重试!";
|
|
||||||
if (this.needToVerify(student, originalStudent, Student::getSchoolId)) {
|
|
||||||
ResponseResult<Boolean> responseResult =
|
|
||||||
sysDeptClient.existId(student.getSchoolId());
|
|
||||||
if (this.hasErrorOfVerifyRemoteRelatedData(responseResult)) {
|
|
||||||
return CallResult.error(String.format(errorMessageFormat, "所属校区"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CallResult.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Student buildDefaultValue(Student student) {
|
|
||||||
student.setStudentId(idGenerator.nextLongId());
|
|
||||||
MyModelUtil.setDefaultValue(student, "totalCoin", 0);
|
|
||||||
MyModelUtil.setDefaultValue(student, "leftCoin", 0);
|
|
||||||
MyModelUtil.setDefaultValue(student, "status", StudentStatus.NORMAL);
|
|
||||||
return student;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
spring:
|
|
||||||
application:
|
|
||||||
name: course-class
|
|
||||||
profiles:
|
|
||||||
active: dev
|
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
discovery:
|
|
||||||
server-addr: localhost:8848
|
|
||||||
config:
|
|
||||||
server-addr: localhost:8848
|
|
||||||
file-extension: yaml
|
|
||||||
# 共享配置文件,排序越高后,优先级越高。
|
|
||||||
shared-configs:
|
|
||||||
- data-id: application-dev.yaml
|
|
||||||
group: DEFAULT_GROUP
|
|
||||||
refresh: true
|
|
||||||
sentinel:
|
|
||||||
eager: true
|
|
||||||
datasource:
|
|
||||||
ds1:
|
|
||||||
nacos:
|
|
||||||
server-addr: localhost:8848
|
|
||||||
data-id: ${spring.application.name}-dev-sentinel
|
|
||||||
group-id: DEFAULT_GROUP
|
|
||||||
data-type: json
|
|
||||||
# 如果是降级服务,需要改为degrade
|
|
||||||
rule-type: flow
|
|
||||||
main:
|
|
||||||
allow-bean-definition-overriding: true
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!-- 本项目全部使用log4j2性能上有很大提升 -->
|
|
||||||
|
|
||||||
<!--monitorInterval="60" 自动检测配置文件更改时间 单位为秒 最小值为5 -->
|
|
||||||
<!--Configuration后面的status,这个用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,你会看到log4j2内部各种详细输出。 -->
|
|
||||||
<configuration monitorInterval="20" status="OFF">
|
|
||||||
<!--日志变量 -->
|
|
||||||
<properties>
|
|
||||||
<!-- 日志主目录 ,需要保存到文件时请自己配置-->
|
|
||||||
<property name="LOG_HOME">./zzlogs/course-class</property>
|
|
||||||
<!-- 日志备份目录 -->
|
|
||||||
<property name="BACKUP_HOME">./zzlogs/course-class/backup</property>
|
|
||||||
<!-- 日志输出级别 -->
|
|
||||||
<property name="OUTPUT_LOG_LEVEL">info</property>
|
|
||||||
<!-- 日志输出格式 -->
|
|
||||||
<property name="LOG_PATTERN">
|
|
||||||
<!-- 输出格式%d{HH:mm:ss}时间24小时制 -->
|
|
||||||
<!-- %-5p日志级别 5位左对齐 [%t]线程名 [%c]类名 -->
|
|
||||||
<!--%l:输出日志事件的发生位置,相当于%c.%M(%F:%L)的组合,包括类全名、方法、文件名以及在代码中的行数。例如:test.TestLog4j.main(TestLog4j.java:10)。 -->
|
|
||||||
<!-- 另一种输出风格<PatternLayout pattern="级别%-5p [%d{YYYY-MM-dd HH:mm:ss}] [%t] 位置[%l] - 信息:%msg%n" /> -->
|
|
||||||
<!-- [%-5p][%d{yy-MM-dd HH:mm:ss}][%t]==>%m==>%c==>%L%n -->
|
|
||||||
[%-5p] [%d{YYYY-MM-dd HH:mm:ss}] [%t] ==> %msg%n
|
|
||||||
</property>
|
|
||||||
<property name="LOG_PATTERN_EX">
|
|
||||||
<!-- 下面注释中 %traceid 为SkyWalking 中的traceid -->
|
|
||||||
[%-5p] [%d{YYYY-MM-dd HH:mm:ss}] T:[%X{traceId}] S:[%X{sessionId}] U:[%X{userId}] [%t] ==> [%traceId] %msg%n
|
|
||||||
</property>
|
|
||||||
<!-- 日志保留天数 -->
|
|
||||||
<property name="EVERY_FILE_COUNT">31</property>
|
|
||||||
<!-- 日志切割的最小单位 -->
|
|
||||||
<property name="EVERY_FILE_SIZE">20M</property>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<appenders>
|
|
||||||
<!--Kafka输出 -->
|
|
||||||
<Kafka name="kafka_log" topic="zz-log-topic" syncSend="false" ignoreExceptions="false">
|
|
||||||
<PatternLayout pattern="${LOG_PATTERN_EX}"/>
|
|
||||||
<Property name="bootstrap.servers">localhost:9092</Property>
|
|
||||||
<Property name="max.block.ms">10000</Property>
|
|
||||||
</Kafka>
|
|
||||||
<!--控制台输出 -->
|
|
||||||
<console name="console" target="SYSTEM_OUT">
|
|
||||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
|
||||||
</console>
|
|
||||||
<!--每次大小超过size,则这size大小的日志会自动进行压缩,作为存档 -->
|
|
||||||
<rollingFile name="file_log" fileName="${LOG_HOME}/course-class.log"
|
|
||||||
filePattern="${LOG_HOME}/course-class-%d{yyyy-MM-dd}-%i.log.gz">
|
|
||||||
<PatternLayout charset="UTF-8" pattern="${LOG_PATTERN_EX}"/>
|
|
||||||
<!-- 日志切割的最小单位 -->
|
|
||||||
<SizeBasedTriggeringPolicy size="${EVERY_FILE_SIZE}"/>
|
|
||||||
<!-- 默认的日志文件数量 -->
|
|
||||||
<DefaultRolloverStrategy max="${EVERY_FILE_COUNT}"/>
|
|
||||||
</rollingFile>
|
|
||||||
</appenders>
|
|
||||||
|
|
||||||
<!-- 然后定义logger,只有定义了logger并引入的appender,appender才会生效 -->
|
|
||||||
<!-- 这里我们把输出到控制台appender的日志级别设置为DEBUG,便于调试。但是输出文件我们缺省为INFO,两者均可随时修改。-->
|
|
||||||
<Loggers>
|
|
||||||
<Root level="${OUTPUT_LOG_LEVEL}">
|
|
||||||
<AppenderRef ref="console"/>
|
|
||||||
</Root>
|
|
||||||
<Logger name="springfox.documentation" additivity="false" level="error">
|
|
||||||
<AppenderRef ref="console"/>
|
|
||||||
</Logger>
|
|
||||||
<!-- AsyncLogger 是基于Disruptor的全量异步队列,性能极高,队列默认大小4096。-->
|
|
||||||
<!-- 队列默认值可通过JVM参数设置,参考博客:https://www.jianshu.com/p/82469047acbf -->
|
|
||||||
<AsyncLogger name="com.orangeforms" additivity="false" level="info">
|
|
||||||
<AppenderRef ref="console"/>
|
|
||||||
<AppenderRef ref="kafka_log"/>
|
|
||||||
<AppenderRef ref="file_log"/>
|
|
||||||
</AsyncLogger>
|
|
||||||
<!-- 这里将dao的日志级别设置为DEBUG,是为了SQL语句的输出 -->
|
|
||||||
<AsyncLogger name="com.orangeforms.courseclassservice.dao" additivity="false" level="debug">
|
|
||||||
<AppenderRef ref="console"/>
|
|
||||||
<AppenderRef ref="kafka_log"/>
|
|
||||||
<AppenderRef ref="file_log"/>
|
|
||||||
</AsyncLogger>
|
|
||||||
</Loggers>
|
|
||||||
</configuration>
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>application</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>course-class</artifactId>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
|
|
||||||
<modules>
|
|
||||||
<module>course-class-api</module>
|
|
||||||
<module>course-class-service</module>
|
|
||||||
</modules>
|
|
||||||
</project>
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>application</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>gateway</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<name>gateway</name>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- swagger和knife4j相关集成-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
|
||||||
<artifactId>knife4j-spring-ui</artifactId>
|
|
||||||
<version>${knife4j.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
|
||||||
<artifactId>springfox-swagger2</artifactId>
|
|
||||||
<version>${springfox.version}</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>io.swagger</groupId>
|
|
||||||
<artifactId>swagger-models</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.swagger</groupId>
|
|
||||||
<artifactId>swagger-models</artifactId>
|
|
||||||
<version>${zz-swagger.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
|
||||||
<artifactId>springfox-bean-validators</artifactId>
|
|
||||||
<version>${springfox.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- 网关服务 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.csp</groupId>
|
|
||||||
<artifactId>sentinel-spring-cloud-gateway-adapter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>common-redis</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- 通用组件依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<artifactId>common-core</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
|
||||||
<groupId>mysql</groupId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>druid-spring-boot-starter</artifactId>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package com.orangeforms.gateway;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.util.ApplicationContextHolder;
|
|
||||||
import com.orangeforms.gateway.filter.AuthenticationPostFilter;
|
|
||||||
import com.orangeforms.gateway.filter.AuthenticationPreFilter;
|
|
||||||
import com.orangeforms.gateway.filter.RequestLogFilter;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|
||||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 网关服务启动类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@EnableDiscoveryClient
|
|
||||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
|
||||||
public class GatewayApplication {
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/fallback")
|
|
||||||
static class FallbackController {
|
|
||||||
@GetMapping("")
|
|
||||||
public String fallback() {
|
|
||||||
return "GATEWAY FALLBACK!!!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public AuthenticationPreFilter authenticationPreFilter() {
|
|
||||||
return new AuthenticationPreFilter();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public AuthenticationPostFilter authenticationPostFilter() {
|
|
||||||
return new AuthenticationPostFilter();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public RequestLogFilter requestLogPreFilter() {
|
|
||||||
return new RequestLogFilter();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
ApplicationContextHolder applicationContextHolder() {
|
|
||||||
return new ApplicationContextHolder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(GatewayApplication.class, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package com.orangeforms.gateway.config;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 网关业务配置类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@RefreshScope
|
|
||||||
@Configuration
|
|
||||||
@ConfigurationProperties(prefix = "application")
|
|
||||||
public class ApplicationConfig {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* token加密用的密钥,该值的长度最少10个字符(过短会报错)。
|
|
||||||
*/
|
|
||||||
private String tokenSigningKey;
|
|
||||||
/**
|
|
||||||
* 客户端或者浏览器在提交http请求时,携带token的header name,如 Authorization
|
|
||||||
*/
|
|
||||||
private String tokenHeaderKey;
|
|
||||||
/**
|
|
||||||
* 令牌Token在被刷新之后,服务器Http应答的header name,客户端或浏览器需要保存并替换原有的token,用于下次发送时携带
|
|
||||||
*/
|
|
||||||
private String refreshedTokenHeaderKey;
|
|
||||||
/**
|
|
||||||
* 令牌的过期时间,单位毫秒
|
|
||||||
*/
|
|
||||||
private Long expiration;
|
|
||||||
/**
|
|
||||||
* 授信ip列表,没有填写表示全部信任。多个ip之间逗号分隔,如: http://10.10.10.1:8080,http://10.10.10.2:8080
|
|
||||||
*/
|
|
||||||
private String credentialIpList;
|
|
||||||
/**
|
|
||||||
* Session会话和用户权限在Redis中的过期时间(秒)。
|
|
||||||
* 缺省值是 one day
|
|
||||||
*/
|
|
||||||
private int sessionExpiredSeconds = 86400;
|
|
||||||
/**
|
|
||||||
* 基于完全等于(equals)判定规则的白名单地址集合,过滤效率高于whitelistUrlPattern。
|
|
||||||
*/
|
|
||||||
private Set<String> whitelistUrl;
|
|
||||||
/**
|
|
||||||
* 基于Ant Pattern模式判定规则的白名单地址集合。如:/aa/**。
|
|
||||||
*/
|
|
||||||
private Set<String> whitelistUrlPattern;
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package com.orangeforms.gateway.config;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.cors.CorsConfiguration;
|
|
||||||
import org.springframework.web.cors.reactive.CorsWebFilter;
|
|
||||||
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
|
|
||||||
import org.springframework.web.util.pattern.PathPatternParser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 跨域信任配置类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class CorsConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public CorsWebFilter corsFilter(ApplicationConfig appConfig) {
|
|
||||||
UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource(new PathPatternParser());
|
|
||||||
CorsConfiguration config = new CorsConfiguration();
|
|
||||||
if (StringUtils.isNotBlank(appConfig.getCredentialIpList())) {
|
|
||||||
if ("*".equals(appConfig.getCredentialIpList())) {
|
|
||||||
config.addAllowedOriginPattern("*");
|
|
||||||
} else {
|
|
||||||
String[] credentialIpList = StringUtils.split(appConfig.getCredentialIpList(), ",");
|
|
||||||
if (credentialIpList.length > 0) {
|
|
||||||
for (String ip : credentialIpList) {
|
|
||||||
config.addAllowedOrigin(ip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
config.addAllowedHeader("*");
|
|
||||||
config.addAllowedMethod("*");
|
|
||||||
config.addExposedHeader(appConfig.getRefreshedTokenHeaderKey());
|
|
||||||
config.setAllowCredentials(true);
|
|
||||||
configSource.registerCorsConfiguration("/**", config);
|
|
||||||
}
|
|
||||||
return new CorsWebFilter(configSource);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.orangeforms.gateway.config;
|
|
||||||
|
|
||||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import javax.servlet.Filter;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Web通用过滤器配置类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class FilterConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public FilterRegistrationBean<Filter> characterEncodingFilterRegistration() {
|
|
||||||
FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>(
|
|
||||||
new org.springframework.web.filter.CharacterEncodingFilter());
|
|
||||||
filterRegistrationBean.addUrlPatterns("/*");
|
|
||||||
filterRegistrationBean.addInitParameter("encoding", StandardCharsets.UTF_8.name());
|
|
||||||
// forceEncoding强制response也被编码,另外即使request中已经设置encoding,forceEncoding也会重新设置
|
|
||||||
filterRegistrationBean.addInitParameter("forceEncoding", "true");
|
|
||||||
filterRegistrationBean.setAsyncSupported(true);
|
|
||||||
return filterRegistrationBean;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package com.orangeforms.gateway.config;
|
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.adapter.gateway.sc.SentinelGatewayFilter;
|
|
||||||
import com.alibaba.csp.sentinel.adapter.gateway.sc.exception.SentinelGatewayBlockExceptionHandler;
|
|
||||||
import org.springframework.beans.factory.ObjectProvider;
|
|
||||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.core.Ordered;
|
|
||||||
import org.springframework.core.annotation.Order;
|
|
||||||
import org.springframework.http.codec.ServerCodecConfigurer;
|
|
||||||
import org.springframework.web.reactive.result.view.ViewResolver;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Spring Cloud Gateway的Sentinel流控配置类。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class SentinelConfig {
|
|
||||||
|
|
||||||
private final List<ViewResolver> viewResolvers;
|
|
||||||
private final ServerCodecConfigurer serverCodecConfigurer;
|
|
||||||
|
|
||||||
public SentinelConfig(
|
|
||||||
ObjectProvider<List<ViewResolver>> viewResolversProvider,
|
|
||||||
ServerCodecConfigurer serverCodecConfigurer) {
|
|
||||||
this.viewResolvers = viewResolversProvider.getIfAvailable(Collections::emptyList);
|
|
||||||
this.serverCodecConfigurer = serverCodecConfigurer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
|
||||||
public SentinelGatewayBlockExceptionHandler sentinelGatewayBlockExceptionHandler() {
|
|
||||||
// Register the block exception handler for Spring Cloud Gateway.
|
|
||||||
return new SentinelGatewayBlockExceptionHandler(viewResolvers, serverCodecConfigurer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
|
||||||
public GlobalFilter sentinelGatewayFilter() {
|
|
||||||
return new SentinelGatewayFilter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
package com.orangeforms.gateway.config;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.cloud.gateway.config.GatewayProperties;
|
|
||||||
import org.springframework.cloud.gateway.route.RouteLocator;
|
|
||||||
import org.springframework.cloud.gateway.support.NameUtils;
|
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import springfox.documentation.swagger.web.SwaggerResource;
|
|
||||||
import springfox.documentation.swagger.web.SwaggerResourcesProvider;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/***
|
|
||||||
* 返回Swagger UI需要读取的资源数据,这里是微服务的路由数据。
|
|
||||||
*
|
|
||||||
* @author Knife4j Team。
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Component
|
|
||||||
@Primary
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class SwaggerResourceConfig implements SwaggerResourcesProvider {
|
|
||||||
|
|
||||||
private final RouteLocator routeLocator;
|
|
||||||
private final GatewayProperties gatewayProperties;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<SwaggerResource> get() {
|
|
||||||
List<SwaggerResource> resources = new ArrayList<>();
|
|
||||||
List<String> routes = new ArrayList<>();
|
|
||||||
routeLocator.getRoutes().subscribe(route -> {
|
|
||||||
if (!"upms-captcha".equals(route.getId())) {
|
|
||||||
routes.add(route.getId());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId()))
|
|
||||||
.forEach(route -> route.getPredicates().stream()
|
|
||||||
.filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName()))
|
|
||||||
.forEach(predicateDefinition -> resources.add(swaggerResource(route.getId(),
|
|
||||||
predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0")
|
|
||||||
.replace("**", "v2/api-docs")))));
|
|
||||||
return resources;
|
|
||||||
}
|
|
||||||
|
|
||||||
private SwaggerResource swaggerResource(String name, String location) {
|
|
||||||
SwaggerResource swaggerResource = new SwaggerResource();
|
|
||||||
swaggerResource.setName(name);
|
|
||||||
swaggerResource.setLocation(location);
|
|
||||||
swaggerResource.setSwaggerVersion("2.0");
|
|
||||||
return swaggerResource;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
package com.orangeforms.gateway.constant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 网关业务相关的常量对象。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
public final class GatewayConstant {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求进入网关的开始时间。
|
|
||||||
*/
|
|
||||||
public static final String START_TIME_ATTRIBUTE = "startTime";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录URL。
|
|
||||||
*/
|
|
||||||
public static final String ADMIN_LOGIN_URL = "/admin/upms/login/doLogin";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登出URL。
|
|
||||||
*/
|
|
||||||
public static final String ADMIN_LOGOUT_URL = "/admin/upms/login/doLogout";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* sessionId的键名称。
|
|
||||||
*/
|
|
||||||
public static final String SESSION_ID_KEY_NAME = "sessionId";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私有构造函数,明确标识该常量类的作用。
|
|
||||||
*/
|
|
||||||
private GatewayConstant() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,231 +0,0 @@
|
|||||||
package com.orangeforms.gateway.filter;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
||||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
|
||||||
import com.orangeforms.common.core.object.ResponseResult;
|
|
||||||
import com.orangeforms.common.core.object.TokenData;
|
|
||||||
import com.orangeforms.common.core.util.JwtUtil;
|
|
||||||
import com.orangeforms.common.core.util.MyCommonUtil;
|
|
||||||
import com.orangeforms.common.core.util.RedisKeyUtil;
|
|
||||||
import com.orangeforms.gateway.config.ApplicationConfig;
|
|
||||||
import com.orangeforms.gateway.constant.GatewayConstant;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.reactivestreams.Publisher;
|
|
||||||
import org.redisson.api.RBucket;
|
|
||||||
import org.redisson.api.RSet;
|
|
||||||
import org.redisson.api.RedissonClient;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
|
||||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
|
||||||
import org.springframework.core.Ordered;
|
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
|
||||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
|
||||||
import org.springframework.core.io.buffer.DataBufferUtils;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
|
||||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
|
||||||
import org.springframework.http.server.reactive.ServerHttpResponseDecorator;
|
|
||||||
import org.springframework.lang.NonNull;
|
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
|
||||||
import reactor.core.publisher.Flux;
|
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 全局后处理过滤器。主要用于将用户的会话信息存到缓存服务器,以及在登出时清除缓存中的会话数据。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
public class AuthenticationPostFilter implements GlobalFilter, Ordered {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ApplicationConfig appConfig;
|
|
||||||
@Autowired
|
|
||||||
private RedissonClient redissonClient;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
|
||||||
ServerHttpRequest originalRequest = exchange.getRequest();
|
|
||||||
ServerHttpResponse originalResponse = exchange.getResponse();
|
|
||||||
String refreshedToken =
|
|
||||||
(String) exchange.getAttributes().get(appConfig.getRefreshedTokenHeaderKey());
|
|
||||||
if (refreshedToken != null) {
|
|
||||||
originalResponse.getHeaders().add(appConfig.getRefreshedTokenHeaderKey(), refreshedToken);
|
|
||||||
}
|
|
||||||
if (!originalRequest.getURI().getPath().equals(GatewayConstant.ADMIN_LOGIN_URL)
|
|
||||||
&& !originalRequest.getURI().getPath().equals(GatewayConstant.ADMIN_LOGOUT_URL)) {
|
|
||||||
return chain.filter(exchange);
|
|
||||||
}
|
|
||||||
DataBufferFactory bufferFactory = originalResponse.bufferFactory();
|
|
||||||
ServerHttpResponseDecorator decoratedResponse = new ServerHttpResponseDecorator(originalResponse) {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public Mono<Void> writeWith(@NonNull Publisher<? extends DataBuffer> bodyData) {
|
|
||||||
StringBuilder sb = new StringBuilder(128);
|
|
||||||
sb.append("url: ")
|
|
||||||
.append(originalRequest.getURI().getPath())
|
|
||||||
.append(" -- status: ")
|
|
||||||
.append(getStatusCode());
|
|
||||||
if (getStatusCode() != HttpStatus.OK) {
|
|
||||||
log.error(sb.toString());
|
|
||||||
return super.writeWith(bodyData);
|
|
||||||
}
|
|
||||||
if (!(bodyData instanceof Flux)) {
|
|
||||||
return super.writeWith(bodyData);
|
|
||||||
}
|
|
||||||
Flux<? extends DataBuffer> fluxBody = (Flux<? extends DataBuffer>) bodyData;
|
|
||||||
return super.writeWith(fluxBody.buffer().map(dataBuffers -> {
|
|
||||||
// 读取完整的服务应答消息体。
|
|
||||||
String responseBody = readResponseBody(dataBuffers);
|
|
||||||
originalResponse.getHeaders().setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
// 先判断body中是否包含数据。
|
|
||||||
if (StringUtils.isBlank(responseBody)) {
|
|
||||||
sb.append(" -- Internal Error, no RESPONSE DATA returns !!");
|
|
||||||
log.error(sb.toString());
|
|
||||||
String errorMessage = "后台服务没有任何数据返回!";
|
|
||||||
responseBody = JSON.toJSONString(
|
|
||||||
ResponseResult.error(ErrorCodeEnum.SERVER_INTERNAL_ERROR, errorMessage));
|
|
||||||
byte[] uppedContent = new String(responseBody.getBytes(), StandardCharsets.UTF_8).getBytes();
|
|
||||||
originalResponse.getHeaders().setContentLength(uppedContent.length);
|
|
||||||
return bufferFactory.wrap(uppedContent);
|
|
||||||
}
|
|
||||||
// 处理登录和登出请求。
|
|
||||||
String result;
|
|
||||||
try {
|
|
||||||
result = doProcess(exchange, responseBody);
|
|
||||||
} catch (Exception e) {
|
|
||||||
setStatusCode(HttpStatus.BAD_REQUEST);
|
|
||||||
String errorMsg = "Server Internal Error";
|
|
||||||
sb.append(errorMsg);
|
|
||||||
log.error(sb.toString(), e);
|
|
||||||
result = JSON.toJSONString(
|
|
||||||
ResponseResult.error(ErrorCodeEnum.SERVER_INTERNAL_ERROR, errorMsg));
|
|
||||||
}
|
|
||||||
byte[] uppedContent = new String(result.getBytes(), StandardCharsets.UTF_8).getBytes();
|
|
||||||
originalResponse.getHeaders().setContentLength(uppedContent.length);
|
|
||||||
return bufferFactory.wrap(uppedContent);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return chain.filter(exchange.mutate().response(decoratedResponse).build());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回过滤器在在调用链上的优先级。
|
|
||||||
*
|
|
||||||
* @return 数值越低,优先级越高。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int getOrder() {
|
|
||||||
// -1 is response write filter, must be called before that
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String readResponseBody(List<? extends DataBuffer> dataBuffers) {
|
|
||||||
int dataCount = 0;
|
|
||||||
for (DataBuffer dataBuffer : dataBuffers) {
|
|
||||||
dataCount += dataBuffer.readableByteCount();
|
|
||||||
}
|
|
||||||
byte[] allBytes = new byte[dataCount];
|
|
||||||
int offset = 0;
|
|
||||||
for (DataBuffer dataBuffer : dataBuffers) {
|
|
||||||
int length = dataBuffer.readableByteCount();
|
|
||||||
dataBuffer.read(allBytes, offset, length);
|
|
||||||
DataBufferUtils.release(dataBuffer);
|
|
||||||
offset += length;
|
|
||||||
}
|
|
||||||
return new String(allBytes, StandardCharsets.UTF_8);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private String doProcess(ServerWebExchange exchange, String responseBody) {
|
|
||||||
// 这个解析出来的就是upms登录或登出接口返回的ResponseResult对象。
|
|
||||||
ServerHttpRequest originalRequest = exchange.getRequest();
|
|
||||||
if (originalRequest.getURI().getPath().equals(GatewayConstant.ADMIN_LOGIN_URL)) {
|
|
||||||
// 处理登录服务的消息体,同时重构该消息体,并最终返回前端。
|
|
||||||
ResponseResult<JSONObject> result = processLoginResponse(responseBody);
|
|
||||||
return JSON.toJSONString(result);
|
|
||||||
}
|
|
||||||
if (originalRequest.getURI().getPath().equals(GatewayConstant.ADMIN_LOGOUT_URL)) {
|
|
||||||
ResponseResult<Void> result = JSON.parseObject(responseBody, ResponseResult.class);
|
|
||||||
if (result.isSuccess()) {
|
|
||||||
String sessionId = (String) exchange.getAttributes().get(GatewayConstant.SESSION_ID_KEY_NAME);
|
|
||||||
redissonClient.getBucket(RedisKeyUtil.makeSessionIdKey(sessionId)).deleteAsync();
|
|
||||||
redissonClient.getSet(RedisKeyUtil.makeSessionPermIdKey(sessionId)).deleteAsync();
|
|
||||||
}
|
|
||||||
return responseBody;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private ResponseResult<JSONObject> processLoginResponse(String responseBody) {
|
|
||||||
ResponseResult<JSONObject> responseResult = JSON.parseObject(responseBody, ResponseResult.class);
|
|
||||||
if (!responseResult.isSuccess()) {
|
|
||||||
return responseResult;
|
|
||||||
}
|
|
||||||
JSONObject loginData = responseResult.getData();
|
|
||||||
// 1. 先验证登陆服务器返回的应答数据是否正确
|
|
||||||
JSONObject tokenData = loginData.getJSONObject(TokenData.REQUEST_ATTRIBUTE_NAME);
|
|
||||||
ErrorCodeEnum errorCode = ErrorCodeEnum.SERVER_INTERNAL_ERROR;
|
|
||||||
if (tokenData == null) {
|
|
||||||
return ResponseResult.error(errorCode, "内部错误,用户登录令牌对象没有正确返回!");
|
|
||||||
}
|
|
||||||
Long userId = tokenData.getLong("userId");
|
|
||||||
if (MyCommonUtil.isBlankOrNull(userId)) {
|
|
||||||
return ResponseResult.error(errorCode, "内部错误,用户Id没有正确返回!");
|
|
||||||
}
|
|
||||||
Boolean isAdmin = tokenData.getBoolean("isAdmin");
|
|
||||||
if (isAdmin == null) {
|
|
||||||
return ResponseResult.error(errorCode, "内部错误,是否为管理员标记没有正确返回!");
|
|
||||||
}
|
|
||||||
String showName = tokenData.getString("showName");
|
|
||||||
if (StringUtils.isBlank(showName)) {
|
|
||||||
return ResponseResult.error(errorCode, "内部错误,用户显示名没有正确返回!");
|
|
||||||
}
|
|
||||||
String loginName = tokenData.getString("loginName");
|
|
||||||
if (StringUtils.isBlank(loginName)) {
|
|
||||||
return ResponseResult.error(errorCode, "内部错误,用户登录名没有正确返回!");
|
|
||||||
}
|
|
||||||
String sessionId = tokenData.getString("sessionId");
|
|
||||||
if (StringUtils.isBlank(sessionId)) {
|
|
||||||
return ResponseResult.error(errorCode, "内部错误,SESSION_ID没有正确返回!");
|
|
||||||
}
|
|
||||||
// 2. 生成sessionId并存放到token中
|
|
||||||
Map<String, Object> claims = new HashMap<>(1);
|
|
||||||
claims.put(GatewayConstant.SESSION_ID_KEY_NAME, sessionId);
|
|
||||||
String token = JwtUtil.generateToken(claims, appConfig.getExpiration(), appConfig.getTokenSigningKey());
|
|
||||||
// 3. 更新缓存
|
|
||||||
String sessionIdKey = RedisKeyUtil.makeSessionIdKey(sessionId);
|
|
||||||
String sessionData = JSON.toJSONString(tokenData, SerializerFeature.WriteNonStringValueAsString);
|
|
||||||
RBucket<String> bucket = redissonClient.getBucket(sessionIdKey);
|
|
||||||
bucket.set(sessionData);
|
|
||||||
bucket.expire(appConfig.getSessionExpiredSeconds(), TimeUnit.SECONDS);
|
|
||||||
// 3.2 sessionId -> permList 是set结构的缓存
|
|
||||||
JSONArray permSet = loginData.getJSONArray("permSet");
|
|
||||||
if (permSet != null) {
|
|
||||||
String sessionPermKey = RedisKeyUtil.makeSessionPermIdKey(sessionId);
|
|
||||||
RSet<String> redisPermSet = redissonClient.getSet(sessionPermKey);
|
|
||||||
redisPermSet.addAll(permSet.stream().map(Object::toString).collect(Collectors.toSet()));
|
|
||||||
redisPermSet.expire(appConfig.getSessionExpiredSeconds(), TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
// 4. 构造返回给用户的应答,将加密后的令牌返回给前端。
|
|
||||||
loginData.put(TokenData.REQUEST_ATTRIBUTE_NAME, token);
|
|
||||||
// 5. 这里需要移除权限资源集合的数据,验证在后端进行,无需返回给前端。
|
|
||||||
loginData.remove("permSet");
|
|
||||||
return ResponseResult.success(loginData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
package com.orangeforms.gateway.filter;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.orangeforms.common.core.constant.ErrorCodeEnum;
|
|
||||||
import com.orangeforms.common.core.object.ResponseResult;
|
|
||||||
import com.orangeforms.common.core.object.TokenData;
|
|
||||||
import com.orangeforms.common.core.util.JwtUtil;
|
|
||||||
import com.orangeforms.common.core.util.RedisKeyUtil;
|
|
||||||
import com.orangeforms.common.core.util.IpUtil;
|
|
||||||
import com.orangeforms.gateway.config.ApplicationConfig;
|
|
||||||
import com.orangeforms.gateway.constant.GatewayConstant;
|
|
||||||
import io.jsonwebtoken.Claims;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.redisson.api.RBucket;
|
|
||||||
import org.redisson.api.RedissonClient;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
|
||||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
|
||||||
import org.springframework.core.Ordered;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
|
||||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
|
||||||
import org.springframework.util.AntPathMatcher;
|
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
|
||||||
import reactor.core.publisher.Flux;
|
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 全局前处理过滤器。主要用于用户操作权限验证。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
public class AuthenticationPreFilter implements GlobalFilter, Ordered {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ApplicationConfig appConfig;
|
|
||||||
@Autowired
|
|
||||||
private RedissonClient redissonClient;
|
|
||||||
/**
|
|
||||||
* Ant Pattern模式的白名单地址匹配器。
|
|
||||||
*/
|
|
||||||
private final AntPathMatcher antMatcher = new AntPathMatcher();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
|
||||||
ServerHttpRequest request = exchange.getRequest();
|
|
||||||
ServerHttpResponse response = exchange.getResponse();
|
|
||||||
String url = request.getURI().getPath();
|
|
||||||
String token = this.getTokenFromRequest(request);
|
|
||||||
boolean noLoginUrl = false;
|
|
||||||
// 判断是否为白名单请求,以及一些内置不需要验证的请求。(登录请求也包含其中)。
|
|
||||||
// 如果当前请求中包含token令牌不为空的时候,也会继续验证Token的合法性,这样就能保证
|
|
||||||
// Token中的用户信息被业务接口正常访问到了。而如果当token为空的时候,白名单的接口可以
|
|
||||||
// 被网关直接转发,无需登录验证。当然被转发的接口,也无法获取到用户的token身份数据了。
|
|
||||||
if (this.shouldNotFilter(url)) {
|
|
||||||
noLoginUrl = true;
|
|
||||||
if (StringUtils.isBlank(token)) {
|
|
||||||
return chain.filter(exchange);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Claims c = JwtUtil.parseToken(token, appConfig.getTokenSigningKey());
|
|
||||||
if (JwtUtil.isNullOrExpired(c)) {
|
|
||||||
log.warn("EXPIRED request [{}] from REMOTE-IP [{}].", url, IpUtil.getRemoteIpAddress(request));
|
|
||||||
response.setStatusCode(HttpStatus.UNAUTHORIZED);
|
|
||||||
response.getHeaders().setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
byte[] responseBody = JSON.toJSONString(ResponseResult.error(ErrorCodeEnum.UNAUTHORIZED_LOGIN,
|
|
||||||
"用户登录已过期或尚未登录,请重新登录!")).getBytes(StandardCharsets.UTF_8);
|
|
||||||
return response.writeWith(Flux.just(response.bufferFactory().wrap(responseBody)));
|
|
||||||
}
|
|
||||||
// 这里判断是否需要定时刷新token
|
|
||||||
if (JwtUtil.needToRefresh(c)) {
|
|
||||||
exchange.getAttributes().put(appConfig.getRefreshedTokenHeaderKey(),
|
|
||||||
JwtUtil.generateToken(c, appConfig.getExpiration(), appConfig.getTokenSigningKey()));
|
|
||||||
}
|
|
||||||
// 先基于sessionId获取userInfo
|
|
||||||
String sessionId = (String) c.get(GatewayConstant.SESSION_ID_KEY_NAME);
|
|
||||||
String sessionIdKey = RedisKeyUtil.makeSessionIdKey(sessionId);
|
|
||||||
RBucket<String> sessionData = redissonClient.getBucket(sessionIdKey);
|
|
||||||
JSONObject tokenData = null;
|
|
||||||
if (sessionData.isExists()) {
|
|
||||||
tokenData = JSON.parseObject(sessionData.get());
|
|
||||||
}
|
|
||||||
if (tokenData == null) {
|
|
||||||
log.warn("UNAUTHORIZED request [{}] from REMOTE-IP [{}] because no sessionId exists in redis.",
|
|
||||||
url, IpUtil.getRemoteIpAddress(request));
|
|
||||||
response.setStatusCode(HttpStatus.UNAUTHORIZED);
|
|
||||||
response.getHeaders().setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
byte[] responseBody = JSON.toJSONString(ResponseResult.error(ErrorCodeEnum.UNAUTHORIZED_LOGIN,
|
|
||||||
"用户会话已失效,请重新登录!")).getBytes(StandardCharsets.UTF_8);
|
|
||||||
return response.writeWith(Flux.just(response.bufferFactory().wrap(responseBody)));
|
|
||||||
}
|
|
||||||
String userId = tokenData.getString("userId");
|
|
||||||
if (StringUtils.isBlank(userId)) {
|
|
||||||
log.warn("UNAUTHORIZED request [{}] from REMOTE-IP [{}] because userId is empty in redis.",
|
|
||||||
url, IpUtil.getRemoteIpAddress(request));
|
|
||||||
response.setStatusCode(HttpStatus.UNAUTHORIZED);
|
|
||||||
response.getHeaders().setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
byte[] responseBody = JSON.toJSONString(ResponseResult.error(ErrorCodeEnum.UNAUTHORIZED_LOGIN,
|
|
||||||
"用户登录验证信息已过期,请重新登录!")).getBytes(StandardCharsets.UTF_8);
|
|
||||||
return response.writeWith(Flux.just(response.bufferFactory().wrap(responseBody)));
|
|
||||||
}
|
|
||||||
String showName = tokenData.getString("showName");
|
|
||||||
// 因为http header中不支持中文传输,所以需要编码。
|
|
||||||
try {
|
|
||||||
showName = URLEncoder.encode(showName, StandardCharsets.UTF_8.name());
|
|
||||||
tokenData.put("showName", showName);
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
log.error("Failed to call AuthenticationPreFilter.filter.", e);
|
|
||||||
}
|
|
||||||
boolean isAdmin = tokenData.getBoolean("isAdmin");
|
|
||||||
if (!noLoginUrl && Boolean.FALSE.equals(isAdmin) && !this.hasPermission(redissonClient, sessionId, url)) {
|
|
||||||
log.warn("FORBIDDEN request [{}] from REMOTE-IP [{}] for USER [{} -- {}] no perm!",
|
|
||||||
url, IpUtil.getRemoteIpAddress(request), userId, showName);
|
|
||||||
response.setStatusCode(HttpStatus.FORBIDDEN);
|
|
||||||
response.getHeaders().setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
byte[] responseBody = JSON.toJSONString(ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION,
|
|
||||||
"用户对该URL没有访问权限,请核对!")).getBytes(StandardCharsets.UTF_8);
|
|
||||||
return response.writeWith(Flux.just(response.bufferFactory().wrap(responseBody)));
|
|
||||||
}
|
|
||||||
// 将session中关联的用户信息,添加到当前的Request中。转发后,业务服务可以根据需要自定读取。
|
|
||||||
tokenData.put("sessionId", sessionId);
|
|
||||||
exchange.getAttributes().put(GatewayConstant.SESSION_ID_KEY_NAME, sessionId);
|
|
||||||
ServerHttpRequest mutableReq = exchange.getRequest().mutate().header(
|
|
||||||
TokenData.REQUEST_ATTRIBUTE_NAME, tokenData.toJSONString()).build();
|
|
||||||
ServerWebExchange mutableExchange = exchange.mutate().request(mutableReq).build();
|
|
||||||
return chain.filter(mutableExchange);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回过滤器在在调用链上的优先级。
|
|
||||||
*
|
|
||||||
* @return 数值越低,优先级越高。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int getOrder() {
|
|
||||||
return HIGHEST_PRECEDENCE + 10000;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getTokenFromRequest(ServerHttpRequest request) {
|
|
||||||
String token = request.getHeaders().getFirst(appConfig.getTokenHeaderKey());
|
|
||||||
if (StringUtils.isBlank(token)) {
|
|
||||||
token = request.getQueryParams().getFirst(appConfig.getTokenHeaderKey());
|
|
||||||
}
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasPermission(RedissonClient redissonClient, String sessionId, String url) {
|
|
||||||
// 对于退出登录操作,不需要进行权限验证,仅仅确认是已经登录的合法用户即可。
|
|
||||||
if (url.equals(GatewayConstant.ADMIN_LOGOUT_URL)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String permKey = RedisKeyUtil.makeSessionPermIdKey(sessionId);
|
|
||||||
return redissonClient.getSet(permKey).contains(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断当前请求的url是否为配置中的白名单地址。以及一些内置的不需要登录即可访问的url。
|
|
||||||
* @param url 请求的url。
|
|
||||||
* @return 是返回true,否则false。
|
|
||||||
*/
|
|
||||||
private boolean shouldNotFilter(String url) {
|
|
||||||
// 这里过滤和swagger相关的url
|
|
||||||
if (url.endsWith("/v2/api-docs") || url.endsWith("/v2/api-docs-ext")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (url.equals(GatewayConstant.ADMIN_LOGIN_URL) || url.startsWith("/captcha")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// 先过滤直接匹配的白名单url。
|
|
||||||
if (CollectionUtils.isNotEmpty(appConfig.getWhitelistUrl())) {
|
|
||||||
if (appConfig.getWhitelistUrl().contains(url)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 过滤ant pattern模式的白名单url。
|
|
||||||
if (CollectionUtils.isNotEmpty(appConfig.getWhitelistUrlPattern())) {
|
|
||||||
for (String urlPattern : appConfig.getWhitelistUrlPattern()) {
|
|
||||||
if (antMatcher.match(urlPattern, url)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
package com.orangeforms.gateway.filter;
|
|
||||||
|
|
||||||
import com.orangeforms.common.core.constant.ApplicationConstant;
|
|
||||||
import com.orangeforms.common.core.util.MyCommonUtil;
|
|
||||||
import com.orangeforms.gateway.constant.GatewayConstant;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.slf4j.MDC;
|
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
|
||||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
|
||||||
import org.springframework.core.Ordered;
|
|
||||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
|
||||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 链路日志前置过虑器。
|
|
||||||
* 为整个链路生成唯一的traceId,并存储在Request Head中。
|
|
||||||
*
|
|
||||||
* @author Jerry
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
public class RequestLogFilter implements GlobalFilter, Ordered {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
|
||||||
final String traceId = MyCommonUtil.generateUuid();
|
|
||||||
MDC.put(ApplicationConstant.HTTP_HEADER_TRACE_ID, traceId);
|
|
||||||
log.info("开始请求,app={gateway}, url={}", exchange.getRequest().getURI().getPath());
|
|
||||||
// 分别记录traceId和执行开始时间。
|
|
||||||
exchange.getAttributes().put(GatewayConstant.START_TIME_ATTRIBUTE, System.currentTimeMillis());
|
|
||||||
ServerHttpRequest mutableReq = exchange.getRequest().mutate().header(
|
|
||||||
ApplicationConstant.HTTP_HEADER_TRACE_ID, traceId).build();
|
|
||||||
ServerWebExchange mutableExchange = exchange.mutate().request(mutableReq).build();
|
|
||||||
ServerHttpResponse response = mutableExchange.getResponse();
|
|
||||||
response.beforeCommit(() -> {
|
|
||||||
response.getHeaders().set(ApplicationConstant.HTTP_HEADER_TRACE_ID, traceId);
|
|
||||||
return Mono.empty();
|
|
||||||
});
|
|
||||||
return chain.filter(mutableExchange).then(Mono.fromRunnable(() -> {
|
|
||||||
Long startTime = exchange.getAttribute(GatewayConstant.START_TIME_ATTRIBUTE);
|
|
||||||
MDC.put(ApplicationConstant.HTTP_HEADER_TRACE_ID, traceId);
|
|
||||||
long elapse = 0;
|
|
||||||
if (startTime != null) {
|
|
||||||
elapse = System.currentTimeMillis() - startTime;
|
|
||||||
}
|
|
||||||
log.info("请求完成, app={gateway}, url={},elapse={}", exchange.getRequest().getURI().getPath(), elapse);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回过滤器在在调用链上的优先级。
|
|
||||||
*
|
|
||||||
* @return 数值越低,优先级越高。
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int getOrder() {
|
|
||||||
return HIGHEST_PRECEDENCE + 9900;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package com.orangeforms.gateway.handler;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
import springfox.documentation.swagger.web.*;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Swagger的资源请求处理器。
|
|
||||||
*
|
|
||||||
* @author Knife4j Team。
|
|
||||||
* @date 2020-08-08
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
public class SwaggerHandler {
|
|
||||||
|
|
||||||
@Autowired(required = false)
|
|
||||||
private SecurityConfiguration securityConfiguration;
|
|
||||||
|
|
||||||
@Autowired(required = false)
|
|
||||||
private UiConfiguration uiConfiguration;
|
|
||||||
|
|
||||||
private final SwaggerResourcesProvider swaggerResources;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public SwaggerHandler(SwaggerResourcesProvider swaggerResources) {
|
|
||||||
this.swaggerResources = swaggerResources;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/swagger-resources/configuration/security")
|
|
||||||
public Mono<ResponseEntity<SecurityConfiguration>> securityConfiguration() {
|
|
||||||
return Mono.just(new ResponseEntity<>(
|
|
||||||
Optional.ofNullable(securityConfiguration)
|
|
||||||
.orElse(SecurityConfigurationBuilder.builder().build()), HttpStatus.OK));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/swagger-resources/configuration/ui")
|
|
||||||
public Mono<ResponseEntity<UiConfiguration>> uiConfiguration() {
|
|
||||||
return Mono.just(new ResponseEntity<>(
|
|
||||||
Optional.ofNullable(uiConfiguration)
|
|
||||||
.orElse(UiConfigurationBuilder.builder().build()), HttpStatus.OK));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/swagger-resources")
|
|
||||||
public Mono<ResponseEntity> swaggerResources() {
|
|
||||||
return Mono.just((new ResponseEntity<>(swaggerResources.get(), HttpStatus.OK)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
spring:
|
|
||||||
application:
|
|
||||||
name: gateway
|
|
||||||
profiles:
|
|
||||||
active: dev
|
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
discovery:
|
|
||||||
server-addr: localhost:8848
|
|
||||||
config:
|
|
||||||
server-addr: localhost:8848
|
|
||||||
file-extension: yaml
|
|
||||||
# 共享配置文件,排序越高后,优先级越高。
|
|
||||||
shared-configs:
|
|
||||||
- data-id: application-dev.yaml
|
|
||||||
group: DEFAULT_GROUP
|
|
||||||
refresh: true
|
|
||||||
main:
|
|
||||||
allow-bean-definition-overriding: true
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!-- 本项目全部使用log4j2性能上有很大提升 -->
|
|
||||||
|
|
||||||
<!--monitorInterval="60" 自动检测配置文件更改时间 单位为秒 最小值为5 -->
|
|
||||||
<!--Configuration后面的status,这个用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,你会看到log4j2内部各种详细输出。 -->
|
|
||||||
<configuration monitorInterval="20" status="OFF">
|
|
||||||
<!--日志变量 -->
|
|
||||||
<properties>
|
|
||||||
<!-- 日志主目录 ,需要保存到文件时请自己配置-->
|
|
||||||
<property name="LOG_HOME">./zzlogs/gateway</property>
|
|
||||||
<!-- 日志备份目录 -->
|
|
||||||
<property name="BACKUP_HOME">./zzlogs/gateway/backup</property>
|
|
||||||
<!-- 日志输出级别 -->
|
|
||||||
<property name="OUTPUT_LOG_LEVEL">info</property>
|
|
||||||
<!-- 日志输出格式 -->
|
|
||||||
<property name="LOG_PATTERN">
|
|
||||||
<!-- 输出格式%d{HH:mm:ss}时间24小时制 -->
|
|
||||||
<!-- %-5p日志级别 5位左对齐 [%t]线程名 [%c]类名 -->
|
|
||||||
<!--%l:输出日志事件的发生位置,相当于%c.%M(%F:%L)的组合,包括类全名、方法、文件名以及在代码中的行数。例如:test.TestLog4j.main(TestLog4j.java:10)。 -->
|
|
||||||
<!-- 另一种输出风格<PatternLayout pattern="级别%-5p [%d{YYYY-MM-dd HH:mm:ss}] [%t] 位置[%l] - 信息:%msg%n" /> -->
|
|
||||||
<!-- [%-5p][%d{yy-MM-dd HH:mm:ss}][%t]==>%m==>%c==>%L%n -->
|
|
||||||
[%-5p] [%d{YYYY-MM-dd HH:mm:ss}] [%t] ==> %msg%n
|
|
||||||
</property>
|
|
||||||
<property name="LOG_PATTERN_EX">
|
|
||||||
<!-- 下面注释中 %traceid 为SkyWalking 中的traceid -->
|
|
||||||
[%-5p] [%d{YYYY-MM-dd HH:mm:ss}] T:[%X{traceId}] [%t] ==> [%traceId] %msg%n
|
|
||||||
</property>
|
|
||||||
<!-- 日志保留天数 -->
|
|
||||||
<property name="EVERY_FILE_COUNT">31</property>
|
|
||||||
<!-- 日志切割的最小单位 -->
|
|
||||||
<property name="EVERY_FILE_SIZE">20M</property>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<appenders>
|
|
||||||
<!--Kafka输出 -->
|
|
||||||
<Kafka name="kafka_log" topic="zz-log-topic" syncSend="false" ignoreExceptions="false">
|
|
||||||
<PatternLayout pattern="${LOG_PATTERN_EX}"/>
|
|
||||||
<Property name="bootstrap.servers">localhost:9092</Property>
|
|
||||||
<Property name="max.block.ms">10000</Property>
|
|
||||||
</Kafka>
|
|
||||||
<!--控制台输出 -->
|
|
||||||
<console name="console" target="SYSTEM_OUT">
|
|
||||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
|
||||||
</console>
|
|
||||||
<!--每次大小超过size,则这size大小的日志会自动进行压缩,作为存档 -->
|
|
||||||
<rollingFile name="file_log" fileName="${LOG_HOME}/gateway.log"
|
|
||||||
filePattern="${LOG_HOME}/gateway-%d{yyyy-MM-dd}-%i.log.gz">
|
|
||||||
<PatternLayout charset="UTF-8" pattern="${LOG_PATTERN_EX}"/>
|
|
||||||
<!-- 日志切割的最小单位 -->
|
|
||||||
<SizeBasedTriggeringPolicy size="${EVERY_FILE_SIZE}"/>
|
|
||||||
<!-- 默认的日志文件数量 -->
|
|
||||||
<DefaultRolloverStrategy max="${EVERY_FILE_COUNT}"/>
|
|
||||||
</rollingFile>
|
|
||||||
</appenders>
|
|
||||||
|
|
||||||
<!-- 然后定义logger,只有定义了logger并引入的appender,appender才会生效 -->
|
|
||||||
<!-- 这里我们把输出到控制台appender的日志级别设置为DEBUG,便于调试。但是输出文件我们缺省为INFO,两者均可随时修改。-->
|
|
||||||
<Loggers>
|
|
||||||
<Root level="${OUTPUT_LOG_LEVEL}">
|
|
||||||
<AppenderRef ref="console"/>
|
|
||||||
</Root>
|
|
||||||
<Logger name="springfox.documentation" additivity="false" level="error">
|
|
||||||
<AppenderRef ref="console"/>
|
|
||||||
</Logger>
|
|
||||||
<!-- AsyncLogger 是基于Disruptor的全量异步队列,性能极高,队列默认大小4096。-->
|
|
||||||
<!-- 队列默认值可通过JVM参数设置,参考博客:https://www.jianshu.com/p/82469047acbf -->
|
|
||||||
<AsyncLogger name="com.orangeforms" additivity="false" level="info">
|
|
||||||
<AppenderRef ref="console"/>
|
|
||||||
<AppenderRef ref="kafka_log"/>
|
|
||||||
<AppenderRef ref="file_log"/>
|
|
||||||
</AsyncLogger>
|
|
||||||
</Loggers>
|
|
||||||
</configuration>
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>OrangeMultiDemo</artifactId>
|
|
||||||
<groupId>com.orangeforms</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>application</artifactId>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
|
|
||||||
<modules>
|
|
||||||
<module>application-common</module>
|
|
||||||
<module>gateway</module>
|
|
||||||
<module>course-class</module>
|
|
||||||
<module>stats</module>
|
|
||||||
<module>upms</module>
|
|
||||||
</modules>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!--nacos 服务发现客户端-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- 限流、熔断组件 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- sentinel 规则配置持久化nacos -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.csp</groupId>
|
|
||||||
<artifactId>sentinel-datasource-nacos</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user