tan 10 months ago
parent 7165957ba4
commit fd9dea67f5

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="StudentManagerSystemApi" />
</profile>
</annotationProcessing>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="StudentManagerSystemApi" options="-parameters" />
</option>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
</component>
</project>

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="ContinueStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
</profile>
</component>

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="aliyun" />
<option name="name" value="aliyun" />
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="17" project-jdk-type="JavaSDK" />
</project>

@ -0,0 +1,169 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- Spring Boot 启动父依赖 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.cow.horse</groupId>
<artifactId>StudentManagerSystemApi</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>StudentManagerSystemApi</name>
<description>Demo project for Spring Boot</description>
<properties>
<mybatis-spring-boot>1.2.0</mybatis-spring-boot>
<mysql-connector>5.1.39</mysql-connector>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- 阿里fastjson包JSON转换-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.62</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- Spring Boot Web 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- MySQL 连接驱动依赖 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>RELEASE</version>
</dependency>
<!-- 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.1</version>
</dependency>
<!-- Spring Boot Mybatis 依赖 -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!--token-->
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.4.0</version>
</dependency>
</dependencies>
<build>
<defaultGoal>compile</defaultGoal>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
<resource>
<directory>src/main/webapp</directory>
<targetPath>META-INF/resources</targetPath>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>aliyun</id>
<name>aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>aliyun</id>
<name>aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>

@ -0,0 +1,14 @@
package com.cow.horse; // 声明该类所属的包用于组织项目代码结构此包名为com.cow.horse
import org.mybatis.spring.annotation.MapperScan; // 导入MyBatis框架中用于扫描Mapper接口的注解类
import org.springframework.boot.SpringApplication; // 导入Spring Boot框架中用于启动应用的核心类
import org.springframework.boot.autoconfigure.SpringBootApplication; // 导入Spring Boot的自动配置注解用于开启自动配置、组件扫描等功能
import org.springframework.transaction.annotation.EnableTransactionManagement; // 导入用于启用事务管理的注解
@SpringBootApplication// 使用@SpringBootApplication注解这是一个组合注解相当于@Configuration、@EnableAutoConfiguration、@ComponentScan的组合用于标识这是一个Spring Boot应用的主配置类
@EnableTransactionManagement// 使用@EnableTransactionManagement注解开启Spring的事务管理功能使项目中的事务相关操作能够正常工作
@MapperScan("com.cow.horse.dao")// 使用@MapperScan注解指定扫描MyBatis的Mapper接口的包路径为com.cow.horse.dao以便Spring能自动扫描到这些Mapper接口并进行相关配置
public class StudentMisApplication {// 定义Spring Boot应用的主类是整个应用程序的入口
public static void main(String[] args) { // 主方法是Java程序的入口点Spring Boot应用启动时会从这里开始执行
SpringApplication.run(StudentMisApplication.class, args); // 调用SpringApplication类的run方法来启动Spring Boot应用传入当前主类和命令行参数
}
}

@ -0,0 +1,42 @@
package com.cow.horse.config; // 声明该类所在的包用于组织配置相关的代码这里是com.cow.horse.config包
import com.mchange.v2.c3p0.ComboPooledDataSource; // 导入c3p0连接池的核心类ComboPooledDataSource用于创建和管理数据库连接池
import org.mybatis.spring.annotation.MapperScan; // 导入MyBatis的MapperScan注解用于扫描MyBatis的Mapper接口
import org.springframework.beans.factory.annotation.Value; // 导入Spring的Value注解用于从配置文件中获取属性值
import org.springframework.context.annotation.Bean; // 导入Spring的Bean注解用于将方法返回的对象注册为Spring容器中的Bean
import org.springframework.context.annotation.Configuration; // 导入Spring的Configuration注解标识该类是一个配置类
import java.beans.PropertyVetoException; // 导入处理属性否决异常的类,在设置数据源属性可能会抛出该异常
/**
* Description
* Author: cow.horse
* Date: 2020/2/26 23:39
**/
@Configuration // 标记该类为配置类Spring会在启动时扫描并处理该类中的配置信息
@MapperScan("com.zjh.student_mis.dao") // 配置MyBatis扫描指定包下com.zjh.student_mis.dao的Mapper接口以便自动生成Mapper代理对象
public class DataSourceConfiguration {
@Value("${jdbc.driver}") // 从配置文件中获取名为jdbc.driver的属性值并注入到jdbcDriver变量中
private String jdbcDriver;
@Value("${jdbc.url}") // 从配置文件中获取名为jdbc.url的属性值并注入到jdbcUrl变量中
private String jdbcUrl;
@Value("${jdbc.username}") // 从配置文件中获取名为jdbc.username的属性值并注入到jdbcUsername变量中
private String jdbcUsername;
@Value("${jdbc.password}") // 从配置文件中获取名为jdbc.password的属性值并注入到jdbcPassword变量中
private String jdbcPassword;
@Bean(name = "dataSource") // 将该方法返回的对象注册为Spring容器中的Bean名称为dataSource
public ComboPooledDataSource createDataSource() throws PropertyVetoException {
ComboPooledDataSource dataSource = new ComboPooledDataSource(); // 创建一个ComboPooledDataSource对象用于管理数据库连接
dataSource.setDriverClass(jdbcDriver); // 设置数据库驱动类使用从配置文件中获取的jdbcDriver值
dataSource.setJdbcUrl(jdbcUrl); // 设置数据库连接URL使用从配置文件中获取的jdbcUrl值
dataSource.setUser(jdbcUsername); // 设置数据库连接的用户名使用从配置文件中获取的jdbcUsername值
dataSource.setPassword(jdbcPassword); // 设置数据库连接的密码使用从配置文件中获取的jdbcPassword值
dataSource.setAutoCommitOnClose(false); // 设置在关闭连接时不自动提交事务
return dataSource; // 返回配置好的数据源对象
}
}

@ -0,0 +1,49 @@
package com.cow.horse.config; // 声明该类所属的包用于组织与配置相关的代码这里是com.cow.horse.config包
import org.mybatis.spring.SqlSessionFactoryBean; // 导入用于创建MyBatis的SqlSessionFactory的工厂Bean类在Spring整合MyBatis时使用
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring的自动装配注解用于自动注入依赖对象
import org.springframework.beans.factory.annotation.Qualifier; // 导入Spring的限定符注解当有多个同类型Bean时用于指定具体要注入的Bean
import org.springframework.beans.factory.annotation.Value; // 导入Spring的Value注解用于从配置文件中获取属性值并注入到对应的变量中
import org.springframework.context.annotation.Bean; // 导入Spring的Bean注解用于将方法返回的对象注册为Spring容器中的Bean
import org.springframework.context.annotation.Configuration; // 导入Spring的Configuration注解标识该类是一个配置类Spring会扫描并处理该类中的配置信息
import org.springframework.core.io.ClassPathResource; // 导入用于表示类路径下资源的类,可用于加载配置文件等资源
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; // 导入用于解析资源路径模式的类,可根据指定模式查找资源
import javax.sql.DataSource; // 导入Java的数据源接口代表数据库连接的数据源
import java.io.IOException; // 导入用于处理I/O异常的类在加载资源等操作时可能会抛出此类异常
/**
* Description
* Author: cow.horse
* Date: 2020/2/27 11:31
**/
@Configuration // 标记该类为配置类Spring容器会处理该类中定义的Bean和配置信息
public class SessionFactoryConfiguration {
// 从配置文件中获取名为mybatis_config_file的属性值并注入到mybatisConfigFilePath变量中代表MyBatis的配置文件路径
@Value("${mybatis_config_file}")
private String mybatisConfigFilePath;
// 从配置文件中获取名为mapper_path的属性值并注入到mapperPath变量中代表MyBatis的Mapper文件所在路径
@Value("${mapper_path}")
private String mapperPath;
// 从配置文件中获取名为entity_package的属性值并注入到entityPackage变量中代表实体类所在的包路径
@Value("${entity_package}")
private String entityPackage;
// 自动装配DataSource类型的Bean并通过Qualifier注解指定要装配名为"dataSource"的Bean
@Autowired
@Qualifier("dataSource")
private DataSource dataSource;
// 将该方法返回的对象注册为Spring容器中的Bean名称为"sqlSessionFactory"
@Bean(name = "sqlSessionFactory")
public SqlSessionFactoryBean createSqlSessionFactoryBean() throws IOException {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); // 创建SqlSessionFactoryBean实例用于构建SqlSessionFactory
sqlSessionFactoryBean.setConfigLocation(new ClassPathResource(mybatisConfigFilePath)); // 设置MyBatis的配置文件位置从类路径加载配置文件
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); // 创建路径匹配资源模式解析器实例
String packageSearchPath = PathMatchingResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + mapperPath; // 构建Mapper文件的搜索路径字符串
sqlSessionFactoryBean.setMapperLocations(resolver.getResources(packageSearchPath)); // 设置Mapper文件的位置通过解析器获取Mapper文件资源
sqlSessionFactoryBean.setDataSource(dataSource); // 设置数据源注入之前自动装配的DataSource对象
sqlSessionFactoryBean.setTypeAliasesPackage(entityPackage); // 设置类型别名包让MyBatis自动扫描该包下的类并注册别名
return sqlSessionFactoryBean; // 返回配置好的SqlSessionFactoryBean对象
}
}

@ -0,0 +1,56 @@
package com.cow.horse.config; // 声明该类属于com.cow.horse.config包用于组织项目的配置类
import com.cow.horse.utils.AuthenticationInterceptor; // 导入自定义的身份验证拦截器类,用于拦截请求进行身份验证
import org.springframework.context.annotation.Bean; // 用于将方法返回的对象注册为Spring容器中的Bean
import org.springframework.context.annotation.Configuration; // 表明这是一个Spring配置类会被Spring容器扫描并处理
import org.springframework.web.servlet.HandlerInterceptor; // Spring中用于拦截请求的拦截器接口
import org.springframework.web.servlet.config.annotation.*; // 包含了Web MVC配置相关的类和注解
/**
* Description vue+spring boot
* Author: cow.horse
* Date: 2022/2/26 22:48
**/
@Configuration // 标记该类为配置类Spring会自动加载该类中的配置信息
public class WebConfig extends WebMvcConfigurationSupport { // 继承WebMvcConfigurationSupport类用于自定义Spring Web MVC的配置
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { // 重写此方法,用于配置静态资源的映射
// 在windows环境下的图片存放资源路径user.dir表示当前工作目录
String winPath = System.getProperty("user.dir") + "\\src\\main\\resources\\static\\files\\";
// 在Linux环境下的图片存放资源路径
String linuxPath = "/usr/local/my_project/files/";
String os = System.getProperty("os.name"); // 获取当前操作系统的名称
if (os.toLowerCase().startsWith("win")) { // 判断当前操作系统是否为Windows
// 第一个参数设置访问路径前缀,第二个参数设置资源的实际存储路径,"file:"表示文件系统资源
registry.addResourceHandler("/files/**").addResourceLocations("file:" + winPath);
} else { // 若为Linux系统
registry.addResourceHandler("/files/**").addResourceLocations("file:" + linuxPath);
}
super.addResourceHandlers(registry); // 调用父类的方法,保证父类的资源映射配置也生效
}
@Override
public void addCorsMappings(CorsRegistry registry) { // 重写此方法用于配置跨域资源共享CORS
registry.addMapping("/**") // 对所有请求路径都应用跨域配置
.allowedOriginPatterns("*") // 允许所有来源的请求进行跨域访问
.allowCredentials(true) // 允许跨域请求携带凭证如cookie
.allowedMethods("GET", "POST", "DELETE", "PUT", "PATCH", "OPTIONS") // 允许的请求方法
.maxAge(3600 * 24); // 预检请求的有效期,单位为秒
}
// 重写此方法,用于注册自定义的拦截器
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 添加自定义的拦截器实例,并设置拦截路径
registry.addInterceptor(appInterceptor())
.addPathPatterns("/api/sms/**") // 拦截所有以/api/sms/开头的请求
.excludePathPatterns("/login"); // 排除对/login路径的拦截
super.addInterceptors(registry); // 调用父类的方法,确保父类的拦截器配置也生效
}
@Bean // 将方法返回的对象注册为Spring容器中的Bean
public HandlerInterceptor appInterceptor() { // 定义一个方法,返回自定义的拦截器实例
return new AuthenticationInterceptor(); // 创建并返回身份验证拦截器实例
}
}

@ -0,0 +1,52 @@
package com.cow.horse.controller.Course; // 声明该类所在的包,一般用于组织代码结构
import com.cow.horse.dto.Course; // 导入自定义的数据传输对象Course类用于在不同层之间传输课程相关的数据
import com.cow.horse.service.Course.CourseService; // 导入课程服务类CourseService该类提供了课程相关的业务逻辑处理方法
import com.cow.horse.utils.PagingResult; // 导入分页结果类PagingResult用于封装分页查询的结果
import org.apache.ibatis.session.RowBounds; // 导入MyBatis的RowBounds类用于分页查询时指定偏移量和每页记录数
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring框架的Autowired注解用于实现依赖注入
import org.springframework.web.bind.annotation.*; // 导入Spring框架的相关注解用于处理HTTP请求
import java.util.List; // 导入Java集合框架中的List接口用于存储一组对象
import java.util.Map; // 导入Java中的Map接口用于存储键值对
import java.util.stream.Collectors; // 导入Java 8引入的Stream API中的Collectors类用于将流中的元素收集到集合中
import java.util.stream.Stream; // 导入Java 8引入的Stream API中的Stream类用于对集合元素进行流式操作
/**
* Description
* Author: cow.horse
* Date: 2020/3/11 14:40
**/
@RestController // 表明这是一个RESTful风格的控制器Spring会自动将控制器方法的返回值转换为JSON等格式响应给客户端
@RequestMapping("/api/sms/course") // 该控制器处理的请求URL前缀为 /api/sms/course
public class CourseController {
@Autowired // 使用Spring的依赖注入功能将CourseService的实例注入到当前控制器中
private CourseService courseService;
@PostMapping // 处理HTTP POST请求用于添加课程
public void addCourse(@RequestBody Course course) { // @RequestBody注解表示从请求体中获取课程对象
courseService.addCourse(course); // 调用CourseService的addCourse方法将课程对象传递过去进行添加操作
}
@DeleteMapping("/{ids}") // 处理HTTP DELETE请求用于删除课程{ids}是URL路径变量
public void delete(@PathVariable("ids") String[] ids) { // @PathVariable注解表示从URL路径中获取课程ID数组
List<Long> idsList = Stream.of(ids).map(Long::parseLong).collect(Collectors.toList()); // 将字符串数组ids转换为流然后对每个元素使用Long::parseLong方法将其转换为Long类型最后将结果收集到一个List中
courseService.delete(idsList); // 调用CourseService的delete方法传入课程ID列表进行删除操作
}
@PutMapping // 处理HTTP PUT请求用于更新课程信息
public void update(@RequestBody Course course) { // @RequestBody注解表示从请求体中获取课程对象
courseService.update(course); // 调用CourseService的update方法将课程对象传递过去进行更新操作
}
@GetMapping("/getCourseList") // 处理HTTP GET请求用于获取课程列表
private PagingResult<Course> getCourseList(@RequestParam Map<String, Object> condition, // @RequestParam注解表示从请求参数中获取查询条件以Map形式存储
@RequestParam(required = false, name = "$limit", defaultValue = "10") Integer limit, // 每页显示的记录数默认为10
@RequestParam(required = false, name = "$offset", defaultValue = "0") Integer offset) { // 偏移量即从第几条记录开始查询默认为0
RowBounds rowBounds = new RowBounds(offset, limit); // 创建RowBounds对象用于分页查询指定偏移量和每页记录数
return courseService.getCourseList(rowBounds, condition); // 调用CourseService的getCourseList方法传入分页信息和查询条件获取课程列表
}
@GetMapping("/getCourseByMap") // 处理HTTP GET请求用于根据条件获取课程列表
private List<Course> getCourseByMap(@RequestParam Map<String, Object> condition) { // @RequestParam注解表示从请求参数中获取查询条件以Map形式存储
return courseService.getCourseByMap(condition); // 调用CourseService的getCourseByMap方法传入查询条件获取课程列表
}
}

@ -0,0 +1,27 @@
package com.cow.horse.controller.Profession; // 声明该类所属的包,用于组织项目的代码结构,这里表明该类属于专业相关的控制器包
import com.cow.horse.domain.Profession; // 导入专业领域对象类,该类通常用于封装专业的相关属性,如专业名称、编号等
import com.cow.horse.service.Profession.ProfessionService; // 导入专业服务类,该类包含了处理专业相关业务逻辑的方法
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring框架的自动装配注解用于实现依赖注入方便在控制器中使用服务类
import org.springframework.web.bind.annotation.GetMapping; // 导入Spring框架的GetMapping注解用于处理HTTP的GET请求
import org.springframework.web.bind.annotation.RequestMapping; // 导入Spring框架的RequestMapping注解用于映射请求的URL路径
import org.springframework.web.bind.annotation.RestController; // 导入Spring框架的RestController注解表明该类是一个RESTful风格的控制器会自动将返回值转换为JSON格式
import java.util.List; // 导入Java的List接口用于存储专业对象的集合
/**
* Description
* Author: cow.horse
* Date: 2020/3/31 17:28
**/
@RestController // 使用RestController注解将该类标记为RESTful风格的控制器
@RequestMapping("/api/sms/profession") // 使用RequestMapping注解指定该控制器处理的请求URL前缀为 /api/sms/profession
public class ProfessionController {
@Autowired // 使用Autowired注解将ProfessionService的实例自动注入到该控制器中方便调用其业务方法
private ProfessionService professionService;
@GetMapping("/getProfessionList") // 处理HTTP的GET请求请求路径为 /api/sms/profession/getProfessionList
private List<Profession> getProfessionList () { // 该方法用于获取所有专业的列表
return professionService.getProfessionList(); // 调用ProfessionService的getProfessionList方法获取专业列表并返回
}
}

@ -0,0 +1,55 @@
package com.cow.horse.controller.Score; // 声明该类所在的包,表明这是成绩查询相关的控制器类所在的包
import com.alibaba.fastjson.JSONArray; // 导入阿里巴巴的FastJSON库中的JSONArray类用于处理JSON数组数据
import com.alibaba.fastjson.JSONObject; // 导入阿里巴巴的FastJSON库中的JSONObject类用于处理JSON对象数据
import com.cow.horse.dto.Course; // 导入自定义的数据传输对象Course类用于在不同层之间传输课程相关的数据
import com.cow.horse.dto.Score; // 导入自定义的数据传输对象Score类用于在不同层之间传输成绩相关的数据
import com.cow.horse.service.Score.ScoreService; // 导入成绩服务类ScoreService该类提供了成绩相关的业务逻辑处理方法
import com.cow.horse.utils.PagingResult; // 导入分页结果类PagingResult用于封装分页查询的结果
import org.apache.ibatis.session.RowBounds; // 导入MyBatis的RowBounds类用于分页查询时指定偏移量和每页记录数
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring框架的Autowired注解用于实现依赖注入
import org.springframework.web.bind.annotation.*; // 导入Spring框架的相关注解用于处理HTTP请求
import java.util.List; // 导入Java集合框架中的List接口用于存储一组对象
import java.util.Map; // 导入Java中的Map接口用于存储键值对
/**
* Description
* Author: cow.horse
* Date: 2020/3/13 15:25
**/
@RestController // 表明这是一个RESTful风格的控制器Spring会自动将控制器方法的返回值转换为JSON等格式响应给客户端
@RequestMapping("/api/sms/score") // 该控制器处理的请求URL前缀为 /api/sms/score
public class ScoreController {
@Autowired // 使用Spring的依赖注入功能将ScoreService的实例注入到当前控制器中
private ScoreService scoreService;
@GetMapping("/getCourseList") // 处理HTTP GET请求用于获取课程列表支持分页查询
public PagingResult<Course> getCourseList(@RequestParam Map<String, Object> condition, // 请求参数中的查询条件以Map形式存储
@RequestParam(required = false, name = "$limit", defaultValue = "10") Integer limit, // 每页显示的记录数默认为10
@RequestParam(required = false, name = "$offset", defaultValue = "0") Integer offset) { // 偏移量即从第几条记录开始查询默认为0
RowBounds rowBounds = new RowBounds(offset, limit); // 创建RowBounds对象用于分页查询指定偏移量和每页记录数
return scoreService.getCourseList(rowBounds, condition); // 调用ScoreService的getCourseList方法传入分页信息和查询条件获取课程列表
}
@PostMapping // 处理HTTP POST请求用于添加成绩记录
private void addEntry(@RequestBody JSONArray UserScore) { // 从请求体中获取的JSON数组包含多个成绩记录
List<Score> list = JSONObject.parseArray(UserScore.toJSONString(), Score.class); // 将JSON数组转换为Score对象的列表
scoreService.addEntry(list); // 调用ScoreService的addEntry方法传入成绩记录列表进行添加操作
}
@GetMapping("/export") // 处理HTTP GET请求用于获取可导出的课程列表
public List<Course> getExportList(@RequestParam Map<String, Object> condition) { // 请求参数中的查询条件以Map形式存储
return scoreService.getExportList(condition); // 调用ScoreService的getExportList方法传入查询条件获取可导出的课程列表
}
@GetMapping("/getUserNum") // 处理HTTP GET请求用于获取用户数量相关信息
public List<Map<String, Object>> getUserNum(@RequestParam Map<String, Object> condition) { // 请求参数中的查询条件以Map形式存储
return scoreService.getUserNum(condition); // 调用ScoreService的getUserNum方法传入查询条件获取用户数量相关信息
}
@GetMapping("/getUserTotal") // 处理HTTP GET请求用于获取用户总计信息
public Map<String, Object> getUserTotal(@RequestParam Map<String, Object> condition) { // 请求参数中的查询条件以Map形式存储
return scoreService.getUserTotal(condition); // 调用ScoreService的getUserTotal方法传入查询条件获取用户总计信息
}
}

@ -0,0 +1,63 @@
package com.cow.horse.controller.TeacherCourse; // 声明该类所在的包,表明这是教师课程相关的控制器类所在的包
import com.alibaba.fastjson.JSONArray; // 导入阿里巴巴FastJSON库中的JSONArray类用于处理JSON数组数据
import com.alibaba.fastjson.JSONObject; // 导入阿里巴巴FastJSON库中的JSONObject类用于处理JSON对象数据
import com.cow.horse.domain.TeacherCourse; // 导入教师课程领域对象类,用于封装教师课程的相关属性
import com.cow.horse.dto.Course; // 导入课程数据传输对象类,用于在不同层之间传输课程相关的数据
import com.cow.horse.service.TeacherCourse.TeacherCourseService; // 导入教师课程服务类,该类提供了教师课程相关的业务逻辑处理方法
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring框架的Autowired注解用于实现依赖注入
import org.springframework.web.bind.annotation.*; // 导入Spring框架的相关注解用于处理HTTP请求
import java.util.Arrays; // 导入Java的Arrays类用于处理数组相关操作
import java.util.List; // 导入Java集合框架中的List接口用于存储一组对象
import java.util.Map; // 导入Java中的Map接口用于存储键值对
/**
* Description
* Author: cow.horse
* Date: 2020/3/29 15:03
**/
@RestController // 表明这是一个RESTful风格的控制器Spring会自动将控制器方法的返回值转换为JSON等格式响应给客户端
@RequestMapping("/api/sms/teacher/course") // 该控制器处理的请求URL前缀为 /api/sms/teacher/course
public class TeacherCourseController {
@Autowired // 使用Spring的依赖注入功能将TeacherCourseService的实例注入到当前控制器中
private TeacherCourseService teacherCourseService;
@PostMapping // 处理HTTP POST请求用于添加教师课程信息
public void add(@RequestBody JSONArray teacherCourseInfo) { // 从请求体中获取的JSON数组包含多个教师课程信息
List<TeacherCourse> list = JSONObject.parseArray(teacherCourseInfo.toJSONString(), TeacherCourse.class); // 将JSON数组转换为TeacherCourse对象的列表
teacherCourseService.add(list); // 调用TeacherCourseService的add方法传入教师课程信息列表进行添加操作
}
@DeleteMapping("/{ids}") // 处理HTTP DELETE请求用于删除教师课程信息
public void delete(@PathVariable("ids") Integer[] ids) { // 从URL路径中获取的课程ID数组
List<Integer> idsList = Arrays.asList(ids); // 将数组转换为List集合
teacherCourseService.delete(idsList); // 调用TeacherCourseService的delete方法传入课程ID列表进行删除操作
}
@PutMapping // 处理HTTP PUT请求用于更新教师课程信息
public void update(@RequestBody TeacherCourse teacherCourse) { // 从请求体中获取的教师课程对象
teacherCourseService.update(teacherCourse); // 调用TeacherCourseService的update方法传入教师课程对象进行更新操作
}
@GetMapping("/getCourseListById/{id}") // 处理HTTP GET请求根据ID获取教师课程列表
public List<TeacherCourse> getCourseListById(@PathVariable("id") String id) { // 从URL路径中获取的ID
List<TeacherCourse> teacherCourses = teacherCourseService.getCourseListById(id); // 调用TeacherCourseService的getCourseListById方法传入ID获取教师课程列表
return teacherCourses;
}
@GetMapping("/getProfessionInfoByTeacher/{teacherId}") // 处理HTTP GET请求根据教师ID获取专业信息
public List<Map<String, Object>> getProfessionInfo(@PathVariable("teacherId") String teacherId) { // 从URL路径中获取的教师ID
return teacherCourseService.getProfessionInfo(teacherId); // 调用TeacherCourseService的getProfessionInfo方法传入教师ID获取专业信息
}
@GetMapping("/getProfessionInfoByAdmin") // 处理HTTP GET请求以管理员身份获取专业信息
public List<Map<String, Object>> getProfessionInfoByAdmin() {
return teacherCourseService.getProfessionInfoByAdmin(); // 调用TeacherCourseService的getProfessionInfoByAdmin方法获取管理员视角的专业信息
}
@GetMapping("/getCourseInfo") // 处理HTTP GET请求根据条件获取课程信息
public Course getCourseInfo(@RequestParam Map<String, Object> condition) { // 请求参数中的查询条件以Map形式存储
return teacherCourseService.getCourseInfo(condition); // 调用TeacherCourseService的getCourseInfo方法传入查询条件获取课程信息
}
}

@ -0,0 +1,48 @@
package com.cow.horse.controller.Timetable; // 声明该类所属的包,此包用于存放课程表相关的控制器类
import com.alibaba.fastjson.JSONArray; // 导入阿里巴巴FastJSON库中的JSONArray类用于处理JSON数组类型的数据
import com.alibaba.fastjson.JSONObject; // 导入阿里巴巴FastJSON库中的JSONObject类用于处理JSON对象类型的数据
import com.cow.horse.domain.CourseInfo; // 导入课程信息领域对象类,用于封装课程的详细信息
import com.cow.horse.domain.WeekCourse; // 导入周课程领域对象类,用于封装一周内课程的相关信息
import com.cow.horse.service.Timetable.TimetableService; // 导入课程表服务类,该类包含了课程表相关的业务逻辑处理方法
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring框架的自动装配注解用于实现依赖注入方便在控制器中使用服务类
import org.springframework.web.bind.annotation.*; // 导入Spring框架的一系列注解用于处理HTTP请求和映射URL
import java.util.List; // 导入Java集合框架中的List接口用于存储一组对象
import java.util.Map; // 导入Java中的Map接口用于存储键值对
/**
* Description
* Author: cow.horse
* Date: 2020/4/7 14:02
**/
@RestController // 使用RestController注解将该类标记为RESTful风格的控制器会自动将返回值转换为JSON格式
@RequestMapping("/api/sms/timetable") // 使用RequestMapping注解指定该控制器处理的请求URL前缀为 /api/sms/timetable
public class TimetableController {
@Autowired // 使用Autowired注解将TimetableService的实例自动注入到该控制器中方便调用其业务方法
private TimetableService timetableService;
@PostMapping // 新增、更新课程表
public void add(@RequestBody JSONArray WeekCourseList) { // 课程表信息以JSON数组形式从请求体中获取
List<WeekCourse> list = JSONObject.parseArray(WeekCourseList.toJSONString(), WeekCourse.class); // 将JSON数组转换为WeekCourse对象的列表
timetableService.add(list); // 调用TimetableService的add方法传入周课程列表进行新增或更新操作
}
@GetMapping("/getTimetable") // 获取课程表信息
public List<WeekCourse> getStudentList(@RequestParam Map<String, Object> condition) { // 请求参数中的查询条件以Map形式存储
return timetableService.getTimetable(condition); // 调用TimetableService的getTimetable方法传入查询条件获取课程表信息
}
@GetMapping("/getTimetableByStudent") // 根据学生相关条件获取课程表信息
public List<WeekCourse> getTimetableByStudent(@RequestParam Map<String, Object> condition) { // 请求参数中的查询条件以Map形式存储
return timetableService.getTimetableByStudent(condition); // 调用TimetableService的getTimetableByStudent方法传入查询条件获取学生视角的课程表信息
}
@GetMapping("/getTimetableByTeacher") // 根据教师相关条件获取课程表信息
public List<WeekCourse> getTimetableByTeacher(@RequestParam Map<String, Object> condition) { // 请求参数中的查询条件以Map形式存储
return timetableService.getTimetableByTeacher(condition); // 调用TimetableService的getTimetableByTeacher方法传入查询条件获取教师视角的课程表信息
}
@PostMapping("/updateCourseInfo") // 更新课程信息
public void updateCourseInfo(@RequestBody CourseInfo courseInfo) { // 课程信息对象,从请求体中获取
timetableService.updateCourseInfo(courseInfo); // 调用TimetableService的updateCourseInfo方法传入课程信息对象进行更新操作
}
}

@ -0,0 +1,64 @@
package com.cow.horse.controller.Upload; // 声明该类所在的包,表明这是上传功能相关的控制器类所在的包
import com.cow.horse.domain.Upload; // 导入自定义的上传领域对象类,用于封装上传相关的信息
import com.cow.horse.service.Upload.UploadService; // 导入上传服务类,该类提供了上传相关的业务逻辑处理方法
import com.cow.horse.utils.ResourceUtil; // 导入自定义的资源工具类,可能用于获取一些资源路径等信息
import com.cow.horse.utils.UserLoginToken; // 导入自定义的用户登录令牌注解类,可能用于权限控制
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring框架的Autowired注解用于实现依赖注入
import org.springframework.web.bind.annotation.*; // 导入Spring框架的相关注解用于处理HTTP请求
import org.springframework.web.multipart.MultipartFile; // 导入Spring框架用于处理文件上传的MultipartFile类
import javax.servlet.http.HttpServletRequest; // 导入用于处理Servlet请求相关的HttpServletRequest类
import java.io.IOException; // 导入处理I/O异常的IOException类
import java.nio.file.Files; // 导入用于处理文件和目录路径的Files类
import java.nio.file.Path; // 导入用于表示文件路径的Path类
import java.nio.file.Paths; // 导入用于创建文件路径的Paths类
import java.util.Map; // 导入用于存储键值对的Map接口
import java.util.UUID; // 导入用于生成唯一标识符的UUID类
import static java.lang.Integer.parseInt; // 导入静态方法parseInt用于将字符串转换为整数
/**
* Description
* Author: cow.horse
* Date: 2020/4/29 13:53
**/
@RestController // 表明这是一个RESTful风格的控制器Spring会自动将控制器方法的返回值转换为JSON等格式响应给客户端
@RequestMapping("/api/sms/upload") // 该控制器处理的请求URL前缀为 /api/sms/upload
public class UploadController {
@Autowired // 使用Spring的依赖注入功能将UploadService的实例注入到当前控制器中
private UploadService uploadService;
@PostMapping("/headImg") // 处理HTTP POST请求用于上传头像图片
@ResponseBody
public String upload(MultipartFile file, HttpServletRequest request) throws IOException { // file为从请求中获取的要上传的文件MultipartFile类型request用于获取请求中的其他参数等信息
if (!file.isEmpty()) { // 检查文件是否为空
try {
byte[] bytes = file.getBytes(); // 将文件内容读取为字节数组
String staticDir = ResourceUtil.getPath(); // 储存位置通过ResourceUtil工具类获取路径
String ImgName = file.getOriginalFilename(); // 图片的原始文件名
String uid = UUID.randomUUID().toString(); // 生成一个唯一的标识符UUID
assert ImgName != null; // 断言文件名不为空(如果为空则会抛出异常)
String str = ImgName.substring(ImgName.lastIndexOf(".")); // 获取文件的后缀名
String newName = uid + str; // 重定义文件名,由唯一标识符和后缀名组成
Path path = Paths.get(staticDir + newName); // 图片存储的完整路径
Files.write(path, bytes); // 将字节数组写入到指定路径的文件中
String imgUrl = "/files/" + newName; // 图片的URL路径相对于项目的路径
String userId = request.getParameter("id"); // 从请求参数中获取用户ID
int level = parseInt(request.getParameter("level")); // 从请求参数中获取用户级别,并将其转换为整数
Upload upload = new Upload(); // 创建Upload对象
upload.setUserId(userId); // 设置Upload对象的用户ID属性
upload.setLevel(level); // 设置Upload对象的用户级别属性
upload.setUrl(imgUrl); // 设置Upload对象的图片URL属性
uploadService.upload(upload); // 调用UploadService的upload方法将上传信息保存到系统中
return imgUrl; // 返回图片的URL路径这里注释说去除"sms",但代码中未体现去除操作)
} catch (IOException e) {
e.printStackTrace(); // 打印异常堆栈信息(用于调试)
}
}
return ""; // 如果文件为空或上传过程中出现异常,返回空字符串
}
@GetMapping("/getHeadImg") // 处理HTTP GET请求用于获取头像图片信息
@UserLoginToken // 该方法上标注了UserLoginToken注解可能表示需要用户登录才能访问
public String getAdminList(@RequestParam Map<String, Object> condition, HttpServletRequest httpServletRequest) { // condition为请求参数中的查询条件以Map形式存储httpServletRequest用于获取请求相关信息
return uploadService.getHeader(condition); // 调用UploadService的getHeader方法传入查询条件获取头像图片信息
}
}

@ -0,0 +1,49 @@
package com.cow.horse.controller.User; // 声明该类所在的包,表明这是与用户(管理员相关)控制器的包路径
import com.cow.horse.dto.User; // 导入自定义的用户数据传输对象DTO用于在不同层之间传输用户相关数据
import com.cow.horse.service.User.AdminService; // 导入管理员服务类,该类包含了管理员相关业务逻辑的处理方法
import com.cow.horse.utils.PagingResult; // 导入自定义的分页结果类,用于封装分页查询的结果
import org.apache.ibatis.session.RowBounds; // 导入MyBatis的RowBounds类用于在查询时指定偏移量和每页记录数实现分页功能
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring框架的Autowired注解用于实现依赖注入
import org.springframework.web.bind.annotation.*; // 导入Spring框架的相关注解用于处理HTTP请求和映射URL
import java.util.Arrays; // 导入Java的Arrays类用于处理数组相关操作
import java.util.List; // 导入Java集合框架中的List接口用于存储一组对象
import java.util.Map; // 导入Java中的Map接口用于存储键值对
import java.util.*; // 导入Java的util包虽然这里没有明确使用到包中的具体类但可能为了后续扩展
/**
* Description
* Author: cow.horse
* Date: 2020/3/28 11:05
**/
@RestController // 表明这是一个RESTful风格的控制器Spring会自动将控制器方法的返回值转换为JSON等格式响应给客户端
@RequestMapping("/api/sms/user/admin") // 该控制器处理的请求URL前缀为 /api/sms/user/admin
public class AdminController {
@Autowired // 使用Spring的依赖注入功能将AdminService的实例注入到当前控制器中
private AdminService adminService;
@PostMapping // 处理HTTP POST请求用于添加管理员用户
public void addAdmin(@RequestBody User user) { // user为从请求体中获取的用户对象包含要添加的管理员信息
adminService.add(user); // 调用AdminService的add方法将用户对象传递过去进行添加操作
}
@DeleteMapping("/{ids}") // 处理HTTP DELETE请求用于删除管理员用户
public void delete(@PathVariable("ids") Integer[] ids) { // ids为从URL路径中获取的用户ID数组
List<Integer> idsList = Arrays.asList(ids); // 将数组转换为List集合方便后续处理
adminService.delete(idsList); // 调用AdminService的delete方法传入用户ID列表进行删除操作
}
@PutMapping // 处理HTTP PUT请求用于更新管理员用户信息
public void update(@RequestBody User user) { // user为从请求体中获取的用户对象包含要更新的管理员信息
adminService.update(user); // 调用AdminService的update方法将用户对象传递过去进行更新操作
}
@GetMapping("/getAdminList") // 处理HTTP GET请求用于获取管理员用户列表支持分页查询
public PagingResult<User> getAdminList(@RequestParam Map<String, Object> condition, // condition为请求参数中的查询条件以Map形式存储
@RequestParam(required = false, name = "$limit", defaultValue = "10") Integer limit, // limit为每页显示的记录数默认为10
@RequestParam(required = false, name = "$offset", defaultValue = "0") Integer offset) { // offset为偏移量即从第几条记录开始查询默认为0
RowBounds rowBounds = new RowBounds(offset, limit); // 创建RowBounds对象用于分页查询指定偏移量和每页记录数
return adminService.getAdminList(rowBounds, condition); // 调用AdminService的getAdminList方法传入分页信息和查询条件获取管理员用户列表的分页结果
}
}

@ -0,0 +1,48 @@
package com.cow.horse.controller.User; // 声明该类所属的包,用于组织项目的代码结构,表明这是与学生账号相关的控制器类所在的包
import com.cow.horse.dto.User; // 导入自定义的用户数据传输对象DTO用于在不同层之间传输用户相关的数据这里可用于传输学生用户信息
import com.cow.horse.service.User.StudentService; // 导入学生服务类,该类包含了处理学生账号相关业务逻辑的方法
import com.cow.horse.utils.PagingResult; // 导入自定义的分页结果类,用于封装分页查询的结果,方便在获取学生列表时进行分页展示
import org.apache.ibatis.session.RowBounds; // 导入MyBatis框架的RowBounds类用于在数据库查询时指定偏移量和每页记录数实现分页功能
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring框架的自动装配注解用于实现依赖注入将StudentService的实例注入到当前控制器中
import org.springframework.web.bind.annotation.*; // 导入Spring框架的相关注解用于处理HTTP请求和映射URL路径
import java.util.Arrays; // 导入Java的Arrays类用于处理数组相关的操作如将数组转换为列表
import java.util.List; // 导入Java集合框架中的List接口用于存储一组对象如存储学生ID列表
import java.util.Map; // 导入Java中的Map接口用于存储键值对这里可用于存储查询条件等参数
/**
* Description
* Author: cow.horse
* Date: 2020/3/7 11:50
**/
@RestController // 使用RestController注解将该类标记为RESTful风格的控制器会自动将方法的返回值转换为JSON格式响应给客户端
@RequestMapping("/api/sms/user/student") // 使用RequestMapping注解指定该控制器处理的请求URL前缀为 /api/sms/user/student
public class StudentController {
@Autowired // 使用Autowired注解将StudentService的实例自动注入到该控制器中以便调用其业务方法
private StudentService studentService;
@PostMapping // 处理HTTP POST请求用于添加学生账号
public void addStudent(@RequestBody User user) { // user 从请求体中获取的用户对象,包含要添加的学生账号信息
studentService.addStudent(user); // 调用StudentService的addStudent方法将用户对象传递过去进行添加操作
}
@DeleteMapping("/{ids}") // 处理HTTP DELETE请求用于删除学生账号
public void delete(@PathVariable("ids") String[] ids) { // ids 从URL路径中获取的学生账号ID数组
List<String> idsList = Arrays.asList(ids); // 将字符串数组转换为List集合方便后续在服务层进行处理
studentService.delete(idsList); // 调用StudentService的delete方法传入学生账号ID列表进行删除操作
}
@PutMapping // 处理HTTP PUT请求用于更新学生账号信息
public void update(@RequestBody User user) { // user 从请求体中获取的用户对象,包含要更新的学生账号信息
studentService.update(user); // 调用StudentService的update方法将用户对象传递过去进行更新操作
}
@GetMapping("/getStudentList") // 处理HTTP GET请求用于获取学生账号列表支持分页查询
public PagingResult<User> getStudentList(@RequestParam Map<String, Object> condition, // condition 请求参数中的查询条件以Map形式存储
@RequestParam(required = false, name = "$limit", defaultValue = "10") Integer limit, // limit 每页显示的记录数默认为10
@RequestParam(required = false, name = "$offset", defaultValue = "0") Integer offset) { // offset 偏移量即从第几条记录开始查询默认为0
RowBounds rowBounds = new RowBounds(offset, limit); // 创建RowBounds对象用于分页查询指定偏移量和每页记录数
return studentService.getStudentList(rowBounds, condition); // 调用StudentService的getStudentList方法传入分页信息和查询条件获取学生账号列表的分页结果
}
}

@ -0,0 +1,48 @@
package com.cow.horse.controller.User; // 声明该类所在的包,表明这是与用户模块下教师账号相关的控制器类
import com.cow.horse.dto.User; // 导入自定义的用户数据传输对象类,用于在不同层之间传递用户信息
import com.cow.horse.service.User.TeacherService; // 导入教师服务类,该类封装了与教师账号相关的业务逻辑
import com.cow.horse.utils.PagingResult; // 导入自定义的分页结果类,用于封装分页查询的结果
import org.apache.ibatis.session.RowBounds; // 导入MyBatis的RowBounds类用于在数据库查询时进行分页控制
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring框架的自动装配注解用于实现依赖注入
import org.springframework.web.bind.annotation.*; // 导入Spring框架用于处理HTTP请求的各种注解
import java.util.Arrays; // 导入Java的Arrays类用于处理数组相关操作
import java.util.List; // 导入Java集合框架中的List接口用于存储一组对象
import java.util.Map; // 导入Java中的Map接口用于存储键值对可作为查询条件
/**
* Description
* Author: cow.horse
* Date: 2020/3/7 11:51
**/
@RestController // 使用RestController注解将该类标记为RESTful风格的控制器Spring会自动将返回值转换为JSON格式
@RequestMapping("/api/sms/user/teacher") // 该控制器处理的请求URL前缀为 /api/sms/user/teacher
public class TeacherController {
@Autowired // 使用自动装配注解将TeacherService的实例注入到当前控制器中
private TeacherService teacherService;
@PostMapping // 处理HTTP POST请求用于添加教师账号
public void addTeacher(@RequestBody User user) { // user 从请求体中获取的用户对象,包含要添加的教师信息
teacherService.addTeacher(user); // 调用教师服务类的添加教师方法,传入用户对象
}
@DeleteMapping("/{ids}") // 处理HTTP DELETE请求用于删除教师账号
public void delete(@PathVariable("ids") Integer[] ids) { // ids 从URL路径中获取的教师账号ID数组
List<Integer> idsList = Arrays.asList(ids); // 将数组转换为List集合方便后续处理
teacherService.delete(idsList); // 调用教师服务类的删除方法传入教师账号ID列表
}
@PutMapping // 处理HTTP PUT请求用于更新教师账号信息
public void update(@RequestBody User user) { // user 从请求体中获取的用户对象,包含要更新的教师信息
teacherService.update(user); // 调用教师服务类的更新方法,传入用户对象
}
@GetMapping("/getTeacherList") // 处理HTTP GET请求用于获取教师账号列表支持分页查询
public PagingResult<User> getTeacherList(@RequestParam Map<String, Object> condition, // condition 请求参数中的查询条件以Map形式存储
@RequestParam(required = false, name = "$limit", defaultValue = "10") Integer limit, // limit 每页显示的记录数默认为10
@RequestParam(required = false, name = "$offset", defaultValue = "0") Integer offset) { // offset 偏移量即从第几条记录开始查询默认为0
RowBounds rowBounds = new RowBounds(offset, limit); // 创建RowBounds对象指定分页的偏移量和每页记录数
return teacherService.getTeacherList(rowBounds, condition); // 调用教师服务类的获取教师列表方法,传入分页信息和查询条件
}
}

@ -0,0 +1,59 @@
package com.cow.horse.controller.User; // 声明该类所在的包,表明这是与用户相关的控制器类所在的包
import com.cow.horse.dto.User; // 导入自定义的用户数据传输对象DTO用于在不同层之间传输用户相关数据
import com.cow.horse.service.User.UserService; // 导入用户服务类,该类包含了处理用户相关业务逻辑的方法
import com.cow.horse.utils.PassToken; // 导入自定义的注解类PassToken可能用于标记某些接口不需要token验证
import com.cow.horse.utils.UserLoginToken; // 导入自定义的注解类UserLoginToken可能用于标记需要用户登录验证的接口
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring框架的Autowired注解用于实现依赖注入
import org.springframework.web.bind.annotation.*; // 导入Spring框架的相关注解用于处理HTTP请求和映射URL
import java.util.Map; // 导入Java的集合框架中的Map接口用于存储键值对
import java.util.HashMap; // 导入Java的集合框架中的HashMap类用于创建键值对集合
import java.util.List; // 导入Java的集合框架中的List接口用于存储一组对象
import java.util.*; // 导入Java的util包这里可能是为了使用包中的其他工具类虽然目前没有明确使用到
/**
* Description
* Author: cow.horse
* Date2019/10/21 21:00
**/
@RestController // 表明这是一个RESTful风格的控制器Spring会自动将控制器方法的返回值转换为JSON等格式响应给客户端
@UserLoginToken // 使用UserLoginToken注解标记该控制器下的方法默认需要用户登录验证除了标记了PassToken的方法
@RequestMapping("/api/sms/user") // 该控制器处理的请求URL前缀为 /api/sms/user
public class UserController {
@Autowired // 使用Spring的依赖注入功能将UserService的实例注入到当前控制器中
private UserService userService;
@GetMapping("/login") // 处理HTTP GET请求用于用户登录获取用户信息并生成token和refreshToken
@PassToken // 该方法上标注了PassToken注解说明该接口不需要token验证
public User getStudentInfo(@RequestParam Map<String, Object> condition) { // condition 请求参数中的查询条件以Map形式存储包含用户名、密码和用户级别等信息
Map<String, Object> map = new HashMap<>(); // 创建一个新的HashMap对象用于整理用户登录信息
map.put("username", condition.get("username").toString()); // 将用户名从请求参数中取出并放入map中
map.put("password", condition.get("password").toString()); // 将密码从请求参数中取出并放入map中
map.put("level", condition.get("level")); // 将用户级别从请求参数中取出并放入map中
User user = userService.getStudentInfo(map); // 调用UserService的getStudentInfo方法传入整理后的用户信息获取用户对象
if (user == null) { // 如果用户对象为空直接返回null
return null;
}
String token = userService.getToken(user, 24 * 60 * 60 * 1000); // 调用UserService的getToken方法传入用户对象和有效期这里是一天的毫秒数生成token
String refreshToken = userService.getToken(user, 24 * 60 * 60 * 1000); // 调用UserService的getToken方法传入用户对象和有效期这里是一天的毫秒数生成refreshToken
user.setToken(token); // 将生成的token设置到用户对象中
user.setRefreshToken(refreshToken); // 将生成的refreshToken设置到用户对象中
return user; // 返回包含用户信息以及token和refreshToken的用户对象
}
@GetMapping("/edit/password") // 处理HTTP GET请求用于修改用户密码
public boolean update(@RequestParam Map<String, Object> condition) { // condition 请求参数中的查询条件以Map形式存储包含用户名、旧密码、新密码和用户级别等信息
Map<String, Object> map = new HashMap<>(); // 创建一个新的HashMap对象用于整理密码修改信息
map.put("username", condition.get("username").toString()); // 将用户名从请求参数中取出并放入map中
map.put("password", condition.get("password").toString()); // 将旧密码从请求参数中取出并放入map中
map.put("passwordAgain", condition.get("passwordAgain").toString()); // 将新密码再次输入的从请求参数中取出并放入map中
map.put("level", condition.get("level").toString()); // 将用户级别从请求参数中取出并放入map中
return userService.update(map); // 调用UserService的update方法传入整理后的密码修改信息返回修改结果
}
@GetMapping("/getTree") // 处理HTTP GET请求用于获取某种树形结构的数据
public List<Object> getTree() {
return userService.getTree(); // 调用UserService的getTree方法获取树形结构数据
}
}

@ -0,0 +1,79 @@
package com.cow.horse.dao.Course;
import com.github.pagehelper.PageRowBounds;
import com.cow.horse.dto.Course;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* Description mapper
* Author: cow.horse
* Date: 2020/3/11 15:02
**/
@Mapper
public interface CourseMapper {
/**
* description:
* @param course
* @return void
* @author cow.horse
* @Date 2020/3/4 23:05
*/
void addCourse(Course course);
/**
* description:
*
* @param ids
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void delete(@Param("ids") List<Long> ids);
/**
* description:
*
* @param course
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void update(Course course);
/**
* description:
* param: rowBounds
* param: condition
* return: List<Course>
* Author: cow.horse
* @Date: 2022/3/11 15:03
*/
List<Course> getCourseList(PageRowBounds rowBounds, @Param("condition") Map<String, Object> condition);
/**
* description: id
* return: Integer
* Author: cow.horse
* @Date: 2022/3/11 15:03
*/
String checkCodeCount(@Param("condition") Map<String, Object> condition);
/**
* description:
* @param: condition
* return: List<Course>
* Author: cow.horse
* @Date: 2022/3/31 22:29
*/
List<Course> getCourseByMap(@Param("condition") Map<String, Object> condition);
/**
* description: id
* @param: String
* return: Course
* Author: cow.horse
* @Date: 2022/3/31 22:29
*/
Course getCourseById(@Param("courseId") String courseId);
}

@ -0,0 +1,48 @@
package com.cow.horse.dao.CourseInfo;
import com.cow.horse.domain.CourseInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
/**
* Description
* Author: cow.horse
* Date: 2020/5/3 14:57
**/
@Mapper
public interface CourseInfoMapper {
/**
* description:
* @param: courseInfo
* return: void
* Author: cow.horse
* @Date: 2022/5/3 14:57
*/
void addCourseInfo(CourseInfo courseInfo);
/**
* description:
* @param: courseInfo
* return: void
* Author: cow.horse
* @Date: 2022/5/3 14:57
*/
void updateCourseInfo(CourseInfo courseInfo);
/**
* description:
* @param: String
* return: void
* Author: cow.horse
* @Date: 2022/5/3 16:23
*/
void deleteInfo(@Param("id") String id);
/**
* description:
* @param: Map<String, Object> condition
* return: CourseInfo
* Author: cow.horse
* @Date: 2022/5/3 17:06
*/
CourseInfo getInfo(@Param("condition") Map<String, Object> condition);
}

@ -0,0 +1,55 @@
package com.cow.horse.dao.Profession;
import com.cow.horse.domain.Profession;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Description Mapper
* Author: cow.horse
* Date: 2020/3/31 17:34
**/
@Mapper
public interface ProfessionMapper {
/**
* description:
* return: List<Profession>
* Author: cow.horse
* @Date: 2022/3/31 17:34
*/
List<Profession> getProfessionList();
/**
* description:
* @param: String
* return: Integer
* Author: cow.horse
* @Date: 2022/3/31 17:35
*/
Integer checkProfessionCount(@Param("name") String name);
/**
* description:
* @param: Profession
* return: void
* Author: cow.horse
* @Date: 2022/3/31 17:36
*/
void addProfession(Profession profession);
/**
* description:
* @param: Integer
* return: void
* Author: cow.horse
* @Date: 2022/3/31 17:37
*/
void deleteProfession(@Param("id") Integer id);
/**
* description:
* @param: String
* return: Profession
* Author: cow.horse
* @Date: 2022/3/31 17:52
*/
Profession getProfessionIdByName(@Param("name") String name);
}

@ -0,0 +1,107 @@
package com.cow.horse.dao.Score;
import com.github.pagehelper.PageRowBounds;
import com.cow.horse.dto.Course;
import com.cow.horse.dto.Score;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* Description Mapper
* Author: cow.horse
* Date: 2020/3/14 16:25
**/
@Mapper
public interface ScoreMapper {
/**
* description:
* param: rowBounds
* param: condition
* return: List<Course>
* Author: cow.horse
* @Date: 2022/3/11 15:03
*/
List<Course> getCourseByMap(PageRowBounds rowBounds, @Param("condition") Map<String, Object> condition);
/**
* description:
* @param: condition
* return: List<Course>
* Author: cow.horse
* @Date: 2022/4/1 11:27
*/
List<Course> getCourseByAdmin(PageRowBounds rowBounds, @Param("condition") Map<String, Object> condition);
/**
* description: id
* @param: condition
* return: List<Course>
* Author: cow.horse
* @Date: 2022/4/1 17:37
*/
List<Course> getCourseByStudent(PageRowBounds rowBounds, @Param("condition") Map<String, Object> condition);
/**
* description: id
* @param: condition
* return: Course
* Author: cow.horse
* @Date: 2022/4/1 11:36
*/
Course getScoreById(@Param("condition") Map<String, Object> condition);
/**
* description:
* @param: Score
* return: void
* Author: cow.horse
* @Date: 2022/3/19 16:23
*/
void addEntry(Score score);
/**
* description:
* @param: Score
* return: void
* Author: cow.horse
* @Date: 2022/3/20 11:52
*/
void updateEntry(Score score);
/**
* description:
* return: Integer
* Author: cow.horse
* @Date: 2022/3/11 15:03
*/
Integer checkCount(@Param("condition") Map<String, Object> condition);
/**
* description:
* @param: condition
* return: List<Course>
* Author: cow.horse
* @Date: 2022/3/21 16:27
*/
List<Course> getExportList(@Param("condition") Map<String, Object> condition);
/**
* description:
* @param: condition
* return: List<Course>
* Author: cow.horse
* @Date: 2022/3/21 16:27
*/
List<Course> getExportListByAdmin(@Param("condition") Map<String, Object> condition);
/**
* description:
* @param: condition
* return: List<Course>
* Author: cow.horse
* @Date: 2022/4/1 17:38
*/
List<Course> getExportListByStudent(@Param("condition") Map<String, Object> condition);
/**
* description: id
* @param: condition
* return: List<Course>
* Author: cow.horse
* @Date: 2022/4/12 23:03
*/
List<Course> getStudentTotal(@Param("condition") Map<String, Object> condition);
}

@ -0,0 +1,79 @@
package com.cow.horse.dao.TeacherCourse;
import com.cow.horse.domain.TeacherCourse;
import com.cow.horse.dto.Course;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* Description Mapper
* Author: cow.horse
* Date: 2020/3/29 15:13
**/
@Mapper
public interface TeacherCourseMapper {
/**
* description:
* @param teacherCourse
* @return void
* @author cow.horse
* @date 2020/3/4 23:05
*/
void add(TeacherCourse teacherCourse);
/**
* description:
*
* @param ids
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void delete(@Param("ids") List<Integer> ids);
/**
* description:
*
* @param teacherCourse
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void update(TeacherCourse teacherCourse);
/**
* description: id
* @param: String
* return: List<TeacherCourse>
* Author: cow.horse
* @Date: 2022/3/29 14:33
*/
List<TeacherCourse> getCourseListById(@Param("id") String id);
/**
* description: id
* @param:
* return:
* Author: cow.horse
* @Date: 2022/4/4 20:54
*/
List<TeacherCourse> getGradeInfoByMap(@Param("condition") Map<String, Object> condition);
/**
* description: id
* @param: condition
* return: String
* Author: cow.horse
* @Date: 2022/4/7 16:17
*/
String getTeacherId(@Param("condition") Map<String, Object> condition);
/**
* description:
* @param: condition
* return: TeacherCourse
* Author: cow.horse
* @Date: 2022/4/9 17:31
*/
Course getCourseInfo(@Param("condition") Map<String, Object> condition);
}

@ -0,0 +1,51 @@
package com.cow.horse.dao.Timetable;
import com.cow.horse.dto.Timetable;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* Description Mapper
* Author: cow.horse
* Date: 2020/4/7 14:18
**/
@Mapper
public interface TimetableMapper {
/**
* description:
* @param timetable
* @return void
* @author cow.horse
* @date 2020/3/4 23:05
*/
void add(Timetable timetable);
/**
* description: timetable
* @param condition
* @author cow.horse
* @return List<Timetable>
* @date 2020/3/4 23:05
*/
List<Timetable> getTimetable(@Param("condition") Map<String, Object> condition);
/**
* description:
* @param: Map<String, Object> condition
* return: Integer
* Author: cow.horse
* @Date: 2022/4/7 17:24
*/
Integer checkCount(@Param("condition") Map<String, Object> condition);
/**
* description: timetable
* @param: Map<String, Object> condition
* return:void
* Author: cow.horse
* @Date: 2022/4/7 17:34
*/
void deleteTimeTable(@Param("condition") Map<String, Object> condition);
}

@ -0,0 +1,49 @@
package com.cow.horse.dao.Upload;
import com.cow.horse.domain.Upload;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
/**
* Description
* Author: cow.horse
* Date: 2020/4/29 12:47
**/
@Mapper
public interface UploadMapper {
/**
* description:
*
* @param: condition
* return: void
* Author: cow.horse
* @Date: 2022/4/29 11:41
*/
void add(Upload upload);
/**
* description:
* @param: condition
* return: String
* Author: cow.horse
* @Date: 2022/4/29 14:03
*/
String getHead(@Param("condition") Map<String, Object> condition);
/**
* description: id
* @param: condition
* return: Integer
* Author: cow.horse
* @Date: 2022/4/29 14:19
*/
Integer checkCount(@Param("condition") Map<String, Object> condition);
/**
* description:
* @param: upload
* return: void
* Author: cow.horse
* @Date: 2022/4/29 14:21
*/
void update(Upload upload);
}

@ -0,0 +1,70 @@
package com.cow.horse.dao.User;
import com.github.pagehelper.PageRowBounds;
import com.cow.horse.dto.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* Description Mapper
* Author: cow.horse
* Date: 2020/3/28 11:08
**/
@Mapper
public interface AdminMapper {
/**
* description:
* @param user
* @return void
* @author cow.horse
* @date 2020/3/4 23:05
*/
void add(User user);
/**
* description:
*
* @param ids
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void delete(@Param("ids") List<Integer> ids);
/**
* description:
*
* @param user
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void update(User user);
/**
* description:
* @param rowBounds
* @author cow.horse
* @return java.util.List<com.zjh.sms.dto.User>
* @date 2020/3/4 23:05
*/
List<User> getAdminList(PageRowBounds rowBounds, @Param("condition") Map<String, Object> condition);
/**
* description: id
* @param: String
* return: User
* Author: cow.horse
* @Date: 2022/3/30 23:43
*/
User getUserById(@Param("id") String id);
/**
* description:
* return: Integer
* Author: cow.horse
* @Date: 2022/3/11 15:03
*/
Integer checkCodeCount();
}

@ -0,0 +1,94 @@
package com.cow.horse.dao.User;
import com.github.pagehelper.PageRowBounds;
import com.cow.horse.dto.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* Description mapper
* Author: cow.horse
* Date: 2020/3/7 15:11
**/
@Mapper
public interface StudentMapper {
/**
* description:
* @param user
* @return void
* @author cow.horse
* @date 2020/3/4 23:05
*/
void addStudent(User user);
/**
* description:
*
* @param ids
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void delete(@Param("ids") List<String> ids);
/**
* description:
*
* @param user
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void update(User user);
/**
* description:
* @param rowBounds
* @author cow.horse
* @return java.util.List<com.zjh.sms.dto.User>
* @date 2020/3/4 23:05
*/
List<User> getStudentList(PageRowBounds rowBounds, @Param("condition") Map<String, Object> condition);
/**
* description:
* @param:
* return:
* Author: cow.horse
* @Date: 2022/3/27 22:14
*/
List<User> getStudentTree();
/**
* description:
* @param: String
* return: List<String>
* Author: cow.horse
* @Date: 2022/3/28 11:46
*/
List<String> getGradeByProfession(@Param("code") String code);
/**
* description:
* return: Integer
* Author: cow.horse
* @Date: 2022/3/11 15:03
*/
Integer checkCodeCount(@Param("condition") Map<String, Object> condition);
/**
* description: id
* @param:
* return:
* Author: cow.horse
* @Date: 2022/3/30 23:43
*/
User getUserById(@Param("id") String id);
/**
* description: id
* @param:
* return:
* Author: cow.horse
* @Date: 2022/4/7 21:13
*/
User getStudentById(@Param("id") String id);
}

@ -0,0 +1,71 @@
package com.cow.horse.dao.User;
import com.github.pagehelper.PageRowBounds;
import com.cow.horse.dto.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* Description mapper
* Author: cow.horse
* Date: 2020/3/7 15:11
**/
@Mapper
public interface TeacherMapper {
/**
* description:
* @param user
* @return void
* @author cow.horse
* @date 2020/3/4 23:05
*/
void addTeacher(User user);
/**
* description:
*
* @param ids
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void delete(@Param("ids") List<Integer> ids);
/**
* description:
*
* @param user
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void update(User user);
/**
* description:
* @param rowBounds
* @author cow.horse
* @return java.util.List<com.zjh.sms.dto.User>
* @date 2020/3/4 23:05
*/
List<User> getTeacherList(PageRowBounds rowBounds, @Param("condition") Map<String, Object> condition);
/**
* description:
* @param:
* return:
* Author: cow.horse
* @Date: 2022/3/30 23:43
*/
User getUserById(@Param("id") String id);
/**
* description:
* return: Integer
* Author: cow.horse
* @Date: 2022/3/11 15:03
*/
Integer checkCodeCount();
}

@ -0,0 +1,56 @@
package com.cow.horse.dao.User;
import com.cow.horse.dto.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
/**
* Description mapper
* Author: cow.horse
* Date2019/10/21 21:08
**/
@Mapper
public interface UserMapper {
/**
* description:
* @params: condition
* @return: com.zjh.sms.dto.User
* @Author: cow.horse
* @Date: 2021/10/21 21:05
*/
User getStudentInfo(@Param("condition") Map<String, Object> condition);
/**
* description:
* @params: condition
* @return: com.zjh.sms.dto.User
* @Author: cow.horse
* @Date: 2021/10/21 21:05
*/
User getTeacherInfo(@Param("condition") Map<String, Object> condition);
/**
* description:
* @params: condition
* @return: com.zjh.sms.dto.User
* @Author: cow.horse
* @Date: 2021/10/21 21:05
*/
User getAdminInfo(@Param("condition") Map<String, Object> condition);
/**
* description:
* @params: condition
* @return: void
* @Author: cow.horse
* @Date: 2022/3/4 23:05
*/
void update(@Param("condition") Map<String, Object> condition);
/**
* description:
* @params: condition
* @return: Integer
* @Author: cow.horse
* @Date: 2022/3/4 23:05
*/
Integer checkPasswordCount(@Param("condition") Map<String, Object> condition);
}

@ -0,0 +1,41 @@
package com.cow.horse.dao.WeekCourse;
import com.cow.horse.domain.WeekCourse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* Description Mapper
* Author: cow.horse
* Date: 2020/4/7 16:46
**/
@Mapper
public interface WeekCourseMapper {
/**
* description: week
* @param weekCourse
* @return void
* @author cow.horse
* @date 2020/3/4 23:05
*/
void add(WeekCourse weekCourse);
/**
* description: week
* @param: WeekCourse
* return: void
* Author: cow.horse
* @Date: 2022/4/7 17:46
*/
void update(WeekCourse weekCourse);
/**
* description:
* @param: condition
* return: List<WeekCourse>
* Author: cow.horse
* @Date: 2022/4/7 17:16
*/
List<WeekCourse> getWeekCourse(@Param("condition") Map<String, Object> condition);
}

@ -0,0 +1,105 @@
package com.cow.horse.domain; // 声明该类所在的包,用于组织代码结构,这里属于领域模型相关的包
/**
* Description
* Author: cow.horse
* Date: 2020/5/3 14:48
**/
public class CourseInfo { // 定义一个名为 CourseInfo 的公共类,用于表示课程的具体安排信息
/**
* id
*/
private Integer id; // 声明一个私有成员变量 id类型为 Integer用于唯一标识课程安排记录
/**
* id
*/
private String courseId; // 声明一个私有成员变量 courseId类型为 String用于存储课程的唯一标识符
/**
* start
*/
private Integer start; // 声明一个私有成员变量 start类型为 Integer用于表示课程安排的起始周数
/**
* end
*/
private Integer end; // 声明一个私有成员变量 end类型为 Integer用于表示课程安排的结束周数
/**
*
*/
private String room; // 声明一个私有成员变量 room类型为 String用于存储课程安排的教室信息
/**
*
*/
private String profession; // 声明一个私有成员变量 profession类型为 String用于存储该课程所针对的专业信息
public CourseInfo() { // 定义一个无参构造函数,用于创建 CourseInfo 对象
}
public CourseInfo(Integer id, String courseId, Integer start, Integer end, String room, String profession) { // 定义一个有参构造函数,用于创建 CourseInfo 对象并初始化其成员变量
this.id = id; // 将传入的 id 参数赋值给类的 id 成员变量
this.courseId = courseId; // 将传入的 courseId 参数赋值给类的 courseId 成员变量
this.start = start; // 将传入的 start 参数赋值给类的 start 成员变量
this.end = end; // 将传入的 end 参数赋值给类的 end 成员变量
this.room = room; // 将传入的 room 参数赋值给类的 room 成员变量
this.profession = profession; // 将传入的 profession 参数赋值给类的 profession 成员变量
}
public Integer getId() { // 定义一个公共的获取方法,用于获取课程安排记录的 id
return id; // 返回类的 id 成员变量的值
}
public void setId(Integer id) { // 定义一个公共的设置方法,用于设置课程安排记录的 id
this.id = id; // 将传入的 id 参数赋值给类的 id 成员变量
}
public String getCourseId() { // 定义一个公共的获取方法,用于获取课程的唯一标识符
return courseId; // 返回类的 courseId 成员变量的值
}
public void setCourseId(String courseId) { // 定义一个公共的设置方法,用于设置课程的唯一标识符
this.courseId = courseId; // 将传入的 courseId 参数赋值给类的 courseId 成员变量
}
public Integer getStart() { // 定义一个公共的获取方法,用于获取课程安排的起始周数
return start; // 返回类的 start 成员变量的值
}
public void setStart(Integer start) { // 定义一个公共的设置方法,用于设置课程安排的起始周数
this.start = start; // 将传入的 start 参数赋值给类的 start 成员变量
}
public Integer getEnd() { // 定义一个公共的获取方法,用于获取课程安排的结束周数
return end; // 返回类的 end 成员变量的值
}
public void setEnd(Integer end) { // 定义一个公共的设置方法,用于设置课程安排的结束周数
this.end = end; // 将传入的 end 参数赋值给类的 end 成员变量
}
public String getRoom() { // 定义一个公共的获取方法,用于获取课程安排的教室信息
return room; // 返回类的 room 成员变量的值
}
public void setRoom(String room) { // 定义一个公共的设置方法,用于设置课程安排的教室信息
this.room = room; // 将传入的 room 参数赋值给类的 room 成员变量
}
public String getProfession() { // 定义一个公共的获取方法,用于获取该课程所针对的专业信息
return profession; // 返回类的 profession 成员变量的值
}
public void setProfession(String profession) { // 定义一个公共的设置方法,用于设置该课程所针对的专业信息
this.profession = profession; // 将传入的 profession 参数赋值给类的 profession 成员变量
}
@Override
public String toString() { // 重写 Object 类的 toString 方法,用于返回 CourseInfo 对象的字符串表示形式
return "CourseInfo{" + // 返回一个包含课程安排信息的字符串
"id=" + id +
", courseId='" + courseId + '\'' +
", start=" + start +
", end=" + end +
", room='" + room + '\'' +
", profession='" + profession + '\'' +
'}';
}
}

@ -0,0 +1,40 @@
package com.cow.horse.domain; // 声明该类所在的包,用于组织代码结构,表明该类属于领域模型相关的包
/**
* Description
* Author: cow.horse
* Date: 2020/3/31 17:25
**/
public class Profession { // 定义一个名为 Profession 的公共类,作为专业的实体类,用于封装专业相关信息
/**
* id
*/
private Integer id; // 声明一个私有成员变量 id类型为 Integer用于唯一标识一个专业
/**
*
*/
private String name; // 声明一个私有成员变量 name类型为 String用于存储专业的名称
public Profession() { // 定义一个无参构造函数,用于创建 Profession 对象,可在不传入参数的情况下初始化对象
}
public Profession(Integer id, String name) { // 定义一个有参构造函数,用于创建 Profession 对象并同时初始化其成员变量
this.id = id; // 将传入的 id 参数赋值给类的 id 成员变量
this.name = name; // 将传入的 name 参数赋值给类的 name 成员变量
}
public Integer getId() { // 定义一个公共的获取方法,用于获取专业的 id
return id; // 返回类的 id 成员变量的值
}
public void setId(Integer id) { // 定义一个公共的设置方法,用于设置专业的 id
this.id = id; // 将传入的 id 参数赋值给类的 id 成员变量
}
public String getName() { // 定义一个公共的获取方法,用于获取专业的名称
return name; // 返回类的 name 成员变量的值
}
public void setName(String name) { // 定义一个公共的设置方法,用于设置专业的名称
this.name = name; // 将传入的 name 参数赋值给类的 name 成员变量
}
}

@ -0,0 +1,141 @@
package com.cow.horse.domain; // 声明该类所在的包,表明该类属于领域模型相关的包,用于组织代码结构
/**
* Description
* Author: cow.horse
* Date: 2020/3/29 15:04
**/
public class TeacherCourse { // 定义一个名为 TeacherCourse 的公共类,作为教师课程任命表的实体类,用于封装相关信息
/**
* id
*/
private Integer id; // 声明一个私有成员变量 id类型为 Integer用于唯一标识一条教师课程任命记录
/**
* id
*/
private String teacherId; // 声明一个私有成员变量 teacherId类型为 String用于存储教师的唯一标识符
/**
*
*/
private String username; // 声明一个私有成员变量 username类型为 String用于存储教师的用户名
/**
*
*/
private String name; // 声明一个私有成员变量 name类型为 String用于存储课程的名称
/**
*
*/
private String profession; // 声明一个私有成员变量 profession类型为 String用于存储该课程对应的专业信息
/**
*
*/
private String grade; // 声明一个私有成员变量 grade类型为 String用于存储该课程对应的班级信息
/**
*
*/
private Integer term; // 声明一个私有成员变量 term类型为 Integer用于存储该课程对应的学期信息
/**
* id
*/
private String courseId; // 声明一个私有成员变量 courseId类型为 String用于存储课程的唯一标识符
private CourseInfo courseInfo; // 声明一个私有成员变量 courseInfo类型为 CourseInfo 类,用于存储课程的具体安排信息
public TeacherCourse(String name, String grade) { // 定义一个包含课程名和班级的构造函数,用于创建 TeacherCourse 对象
this.name = name; // 将传入的课程名赋值给类的 name 成员变量
this.grade = grade; // 将传入的班级赋值给类的 grade 成员变量
}
public TeacherCourse(Integer id, String teacherId, String username, String name, String profession, String grade, Integer term, String courseId) { // 定义一个包含多个参数的构造函数,用于创建 TeacherCourse 对象并初始化其成员变量
this.id = id; // 将传入的 id 参数赋值给类的 id 成员变量
this.teacherId = teacherId; // 将传入的教师 id 参数赋值给类的 teacherId 成员变量
this.username = username; // 将传入的教师用户名参数赋值给类的 username 成员变量
this.name = name; // 将传入的课程名参数赋值给类的 name 成员变量
this.profession = profession; // 将传入的专业参数赋值给类的 profession 成员变量
this.grade = grade; // 将传入的班级参数赋值给类的 grade 成员变量
this.term = term; // 将传入的学期参数赋值给类的 term 成员变量
this.courseId = courseId; // 将传入的课程 id 参数赋值给类的 courseId 成员变量
}
public TeacherCourse(Integer id, String teacherId, String username, String name, String profession, String grade, Integer term, String courseId, CourseInfo courseInfo) { // 定义一个包含所有属性的构造函数,用于创建 TeacherCourse 对象并初始化其成员变量
this.id = id; // 将传入的 id 参数赋值给类的 id 成员变量
this.teacherId = teacherId; // 将传入的教师 id 参数赋值给类的 teacherId 成员变量
this.username = username; // 将传入的教师用户名参数赋值给类的 username 成员变量
this.name = name; // 将传入的课程名参数赋值给类的 name 成员变量
this.profession = profession; // 将传入的专业参数赋值给类的 profession 成员变量
this.grade = grade; // 将传入的班级参数赋值给类的 grade 成员变量
this.term = term; // 将传入的学期参数赋值给类的 term 成员变量
this.courseId = courseId; // 将传入的课程 id 参数赋值给类的 courseId 成员变量
this.courseInfo = courseInfo; // 将传入的课程具体安排信息对象赋值给类的 courseInfo 成员变量
}
public CourseInfo getCourseInfo() { // 定义一个公共的获取方法,用于获取课程的具体安排信息
return courseInfo; // 返回类的 courseInfo 成员变量的值
}
public void setCourseInfo(CourseInfo courseInfo) { // 定义一个公共的设置方法,用于设置课程的具体安排信息
this.courseInfo = courseInfo; // 将传入的课程具体安排信息对象赋值给类的 courseInfo 成员变量
}
public Integer getId() { // 定义一个公共的获取方法,用于获取教师课程任命记录的 id
return id; // 返回类的 id 成员变量的值
}
public void setId(Integer id) { // 定义一个公共的设置方法,用于设置教师课程任命记录的 id
this.id = id; // 将传入的 id 参数赋值给类的 id 成员变量
}
public String getTeacherId() { // 定义一个公共的获取方法,用于获取教师的 id
return teacherId; // 返回类的 teacherId 成员变量的值
}
public void setTeacherId(String teacherId) { // 定义一个公共的设置方法,用于设置教师的 id
this.teacherId = teacherId; // 将传入的教师 id 参数赋值给类的 teacherId 成员变量
}
public String getUsername() { // 定义一个公共的获取方法,用于获取教师的用户名
return username; // 返回类的 username 成员变量的值
}
public void setUsername(String username) { // 定义一个公共的设置方法,用于设置教师的用户名
this.username = username; // 将传入的教师用户名参数赋值给类的 username 成员变量
}
public String getName() { // 定义一个公共的获取方法,用于获取课程的名称
return name; // 返回类的 name 成员变量的值
}
public void setName(String name) { // 定义一个公共的设置方法,用于设置课程的名称
this.name = name; // 将传入的课程名参数赋值给类的 name 成员变量
}
public String getProfession() { // 定义一个公共的获取方法,用于获取该课程对应的专业信息
return profession; // 返回类的 profession 成员变量的值
}
public void setProfession(String profession) { // 定义一个公共的设置方法,用于设置该课程对应的专业信息
this.profession = profession; // 将传入的专业参数赋值给类的 profession 成员变量
}
public String getGrade() { // 定义一个公共的获取方法,用于获取该课程对应的班级信息
return grade; // 返回类的 grade 成员变量的值
}
public void setGrade(String grade) { // 定义一个公共的设置方法,用于设置该课程对应的班级信息
this.grade = grade; // 将传入的班级参数赋值给类的 grade 成员变量
}
public Integer getTerm() { // 定义一个公共的获取方法,用于获取该课程对应的学期信息
return term; // 返回类的 term 成员变量的值
}
public void setTerm(Integer term) { // 定义一个公共的设置方法,用于设置该课程对应的学期信息
this.term = term; // 将传入的学期参数赋值给类的 term 成员变量
}
public String getCourseId() { // 定义一个公共的获取方法,用于获取课程的 id
return courseId; // 返回类的 courseId 成员变量的值
}
public void setCourseId(String courseId) { // 定义一个公共的设置方法,用于设置课程的 id
this.courseId = courseId; // 将传入的课程 id 参数赋值给类的 courseId 成员变量
}
}

@ -0,0 +1,76 @@
package com.cow.horse.domain; // 声明该类所属的包,用于代码的组织和管理,表明这是一个领域模型类
/**
* Description
* Author: cow.horse
* Date: 2020/4/29 12:50
**/
public class Upload { // 定义一个公共类 Upload作为上传相关信息的实体类
/**
* id
*/
private Integer id; // 声明一个私有成员变量 id类型为 Integer用于唯一标识一条上传记录
/**
* id
*/
private String userId; // 声明一个私有成员变量 userId类型为 String用于存储上传用户的唯一标识符
/**
*
*/
private Integer level; // 声明一个私有成员变量 level类型为 Integer用于存储上传用户的等级信息
/**
*
*/
private String url; // 声明一个私有成员变量 url类型为 String用于存储上传文件的存储地址
public Upload() { // 定义一个无参构造函数,方便创建 Upload 对象时不传入任何初始值
}
public Upload(Integer id, String userId, Integer level, String url) { // 定义一个有参构造函数,用于创建 Upload 对象并初始化其成员变量
this.id = id; // 将传入的 id 参数赋值给类的 id 成员变量
this.userId = userId; // 将传入的用户 id 参数赋值给类的 userId 成员变量
this.level = level; // 将传入的用户等级参数赋值给类的 level 成员变量
this.url = url; // 将传入的存储地址参数赋值给类的 url 成员变量
}
public Integer getId() { // 定义一个公共的获取方法,用于获取上传记录的 id
return id; // 返回类的 id 成员变量的值
}
public void setId(Integer id) { // 定义一个公共的设置方法,用于设置上传记录的 id
this.id = id; // 将传入的 id 参数赋值给类的 id 成员变量
}
public String getUserId() { // 定义一个公共的获取方法,用于获取上传用户的 id
return userId; // 返回类的 userId 成员变量的值
}
public void setUserId(String userId) { // 定义一个公共的设置方法,用于设置上传用户的 id
this.userId = userId; // 将传入的用户 id 参数赋值给类的 userId 成员变量
}
public Integer getLevel() { // 定义一个公共的获取方法,用于获取上传用户的等级
return level; // 返回类的 level 成员变量的值
}
public void setLevel(Integer level) { // 定义一个公共的设置方法,用于设置上传用户的等级
this.level = level; // 将传入的用户等级参数赋值给类的 level 成员变量
}
public String getUrl() { // 定义一个公共的获取方法,用于获取上传文件的存储地址
return url; // 返回类的 url 成员变量的值
}
public void setUrl(String url) { // 定义一个公共的设置方法,用于设置上传文件的存储地址
this.url = url; // 将传入的存储地址参数赋值给类的 url 成员变量
}
@Override
public String toString() { // 重写 Object 类的 toString 方法,用于返回 Upload 对象的字符串表示形式
return "Upload{" + // 返回一个包含上传记录信息的字符串
"id=" + id +
", userId='" + userId + '\'' +
", level=" + level +
", url='" + url + '\'' +
'}';
}
}

@ -0,0 +1,230 @@
package com.cow.horse.domain; // 声明该类所在的包,用于组织代码结构,这里是领域模型相关的包
/**
* Description
* Author: cow.horse
* Date: 2020/4/7 14:50
**/
public class WeekCourse { // 定义一个名为 WeekCourse 的公共类,用于表示课程表的具体排布信息
/**
* id
*/
private Integer id; // 声明一个私有成员变量 id类型为 Integer用于唯一标识课程表排布记录
/**
*
*/
private String monday; // 声明一个私有成员变量 monday类型为 String用于存储周一的课程安排信息
/**
*
*/
private String tuesday; // 声明一个私有成员变量 tuesday类型为 String用于存储周二的课程安排信息
/**
*
*/
private String wednesday; // 声明一个私有成员变量 wednesday类型为 String用于存储周三的课程安排信息
/**
*
*/
private String thursday; // 声明一个私有成员变量 thursday类型为 String用于存储周四的课程安排信息
/**
*
*/
private String friday; // 声明一个私有成员变量 friday类型为 String用于存储周五的课程安排信息
/**
*
*/
private String saturday; // 声明一个私有成员变量 saturday类型为 String用于存储周六的课程安排信息
/**
*
*/
private String sunday; // 声明一个私有成员变量 sunday类型为 String用于存储周日的课程安排信息
/**
*
*/
private String profession; // 声明一个私有成员变量 profession类型为 String用于存储课程表对应的专业信息
/**
*
*/
private String grade; // 声明一个私有成员变量 grade类型为 String用于存储课程表对应的班级信息
/**
*
*/
private Integer year; // 声明一个私有成员变量 year类型为 Integer用于存储课程表对应的学年信息
/**
*
*/
private Integer term; // 声明一个私有成员变量 term类型为 Integer用于存储课程表对应的学期信息
/**
*
*/
private Integer week; // 声明一个私有成员变量 week类型为 Integer用于存储课程表对应的周数信息
public WeekCourse() { // 定义一个无参构造函数,用于创建 WeekCourse 对象
}
public WeekCourse(Integer id, String monday, String tuesday, String wednesday, String thursday, String friday, String saturday, String sunday, String profession, String grade, Integer year, Integer term, Integer week) { // 定义一个包含所有成员变量的构造函数
this.id = id; // 将传入的 id 参数赋值给类的 id 成员变量
this.monday = monday; // 将传入的周一课程安排参数赋值给类的 monday 成员变量
this.tuesday = tuesday; // 将传入的周二课程安排参数赋值给类的 tuesday 成员变量
this.wednesday = wednesday; // 将传入的周三课程安排参数赋值给类的 wednesday 成员变量
this.thursday = thursday; // 将传入的周四课程安排参数赋值给类的 thursday 成员变量
this.friday = friday; // 将传入的周五课程安排参数赋值给类的 friday 成员变量
this.saturday = saturday; // 将传入的周六课程安排参数赋值给类的 saturday 成员变量
this.sunday = sunday; // 将传入的周日课程安排参数赋值给类的 sunday 成员变量
this.profession = profession; // 将传入的专业参数赋值给类的 profession 成员变量
this.grade = grade; // 将传入的班级参数赋值给类的 grade 成员变量
this.year = year; // 将传入的学年参数赋值给类的 year 成员变量
this.term = term; // 将传入的学期参数赋值给类的 term 成员变量
this.week = week; // 将传入的周数参数赋值给类的 week 成员变量
}
public WeekCourse(Integer id, String monday, String tuesday, String wednesday, String thursday, String friday, String saturday, String sunday, String profession, String grade, Integer year, Integer term) { // 定义一个不包含周数的构造函数
this.id = id; // 将传入的 id 参数赋值给类的 id 成员变量
this.monday = monday; // 将传入的周一课程安排参数赋值给类的 monday 成员变量
this.tuesday = tuesday; // 将传入的周二课程安排参数赋值给类的 tuesday 成员变量
this.wednesday = wednesday; // 将传入的周三课程安排参数赋值给类的 wednesday 成员变量
this.thursday = thursday; // 将传入的周四课程安排参数赋值给类的 thursday 成员变量
this.friday = friday; // 将传入的周五课程安排参数赋值给类的 friday 成员变量
this.saturday = saturday; // 将传入的周六课程安排参数赋值给类的 saturday 成员变量
this.sunday = sunday; // 将传入的周日课程安排参数赋值给类的 sunday 成员变量
this.profession = profession; // 将传入的专业参数赋值给类的 profession 成员变量
this.grade = grade; // 将传入的班级参数赋值给类的 grade 成员变量
this.year = year; // 将传入的学年参数赋值给类的 year 成员变量
this.term = term; // 将传入的学期参数赋值给类的 term 成员变量
}
public Integer getWeek() { // 定义一个公共的获取方法,用于获取课程表对应的周数
return week; // 返回类的 week 成员变量的值
}
public void setWeek(Integer week) { // 定义一个公共的设置方法,用于设置课程表对应的周数
this.week = week; // 将传入的周数参数赋值给类的 week 成员变量
}
public Integer getId() { // 定义一个公共的获取方法,用于获取课程表排布记录的 id
return id; // 返回类的 id 成员变量的值
}
public void setId(Integer id) { // 定义一个公共的设置方法,用于设置课程表排布记录的 id
this.id = id; // 将传入的 id 参数赋值给类的 id 成员变量
}
public String getMonday() { // 定义一个公共的获取方法,用于获取周一的课程安排信息
return monday; // 返回类的 monday 成员变量的值
}
public void setMonday(String monday) { // 定义一个公共的设置方法,用于设置周一的课程安排信息
this.monday = monday; // 将传入的周一课程安排参数赋值给类的 monday 成员变量
}
public String getTuesday() { // 定义一个公共的获取方法,用于获取周二的课程安排信息
return tuesday; // 返回类的 tuesday 成员变量的值
}
public void setTuesday(String tuesday) { // 定义一个公共的设置方法,用于设置周二的课程安排信息
this.tuesday = tuesday; // 将传入的周二课程安排参数赋值给类的 tuesday 成员变量
}
public String getWednesday() { // 定义一个公共的获取方法,用于获取周三的课程安排信息
return wednesday; // 返回类的 wednesday 成员变量的值
}
public void setWednesday(String wednesday) { // 定义一个公共的设置方法,用于设置周三的课程安排信息
this.wednesday = wednesday; // 将传入的周三课程安排参数赋值给类的 wednesday 成员变量
}
public String getThursday() { // 定义一个公共的获取方法,用于获取周四的课程安排信息
return thursday; // 返回类的 thursday 成员变量的值
}
public void setThursday(String thursday) { // 定义一个公共的设置方法,用于设置周四的课程安排信息
this.thursday = thursday; // 将传入的周四课程安排参数赋值给类的 thursday 成员变量
}
public String getFriday() { // 定义一个公共的获取方法,用于获取周五的课程安排信息
return friday; // 返回类的 friday 成员变量的值
}
public void setFriday(String friday) { // 定义一个公共的设置方法,用于设置周五的课程安排信息
this.friday = friday; // 将传入的周五课程安排参数赋值给类的 friday 成员变量
}
public String getSaturday() { // 定义一个公共的获取方法,用于获取周六的课程安排信息
return saturday; // 返回类的 saturday 成员变量的值
}
public void setSaturday(String saturday) { // 定义一个公共的设置方法,用于设置周六的课程安排信息
this.saturday = saturday; // 将传入的周六课程安排参数赋值给类的 saturday 成员变量
}
public String getSunday() { // 定义一个公共的获取方法,用于获取周日的课程安排信息
return sunday; // 返回类的 sunday 成员变量的值
}
public void setSunday(String sunday) { // 定义一个公共的设置方法,用于设置周日的课程安排信息
this.sunday = sunday; // 将传入的周日课程安排参数赋值给类的 sunday 成员变量
}
public String getProfession() { // 定义一个公共的获取方法,用于获取课程表对应的专业信息
return profession; // 返回类的 profession 成员变量的值
}
public void setProfession(String profession) { // 定义一个公共的设置方法,用于设置课程表对应的专业信息
this.profession = profession; // 将传入的专业参数赋值给类的 profession 成员变量
}
public String getGrade() { // 定义一个公共的获取方法,用于获取课程表对应的班级信息
return grade; // 返回类的 grade 成员变量的值
}
public void setGrade(String grade) { // 定义一个公共的设置方法,用于设置课程表对应的班级信息
this.grade = grade; // 将传入的班级参数赋值给类的 grade 成员变量
}
public Integer getYear() { // 定义一个公共的获取方法,用于获取课程表对应的学年信息
return year; // 返回类的 year 成员变量的值
}
public void setYear(Integer year) { // 定义一个公共的设置方法,用于设置课程表对应的学年信息
this.year = year; // 将传入的学年参数赋值给类的 year 成员变量
}
public Integer getTerm() { // 定义一个公共的获取方法,用于获取课程表对应的学期信息
return term; // 返回类的 term 成员变量的值
}
public void setTerm(Integer term) { // 定义一个公共的设置方法,用于设置课程表对应的学期信息
this.term = term; // 将传入的学期参数赋值给类的 term 成员变量
}
@Override
public String toString() { // 重写 Object 类的 toString 方法,用于返回 WeekCourse 对象的字符串表示形式
return "WeekCourse{" + // 返回一个包含课程表排布信息的字符串
"id=" + id +
", monday='" + monday + '\'' +
", tuesday='" + tuesday + '\'' +
", wednesday='" + wednesday + '\'' +
", thursday='" + thursday + '\'' +
", friday='" + friday + '\'' +
", saturday='" + saturday + '\'' +
", sunday='" + sunday + '\'' +
", profession='" + profession + '\'' +
", grade='" + grade + '\'' +
", year=" + year +
", term=" + term +
'}';
}
}

@ -0,0 +1,129 @@
// 声明该类所在的包用于组织代码结构这里是数据传输对象DTO相关的包
package com.cow.horse.dto;
// 导入Java的Date类用于表示日期和时间
import java.util.Date;
/**
* Description
* Author: cow.horse
* Date: 2020/3/11 14:50
**/
// 定义课程信息的数据传输对象类,用于在不同层之间传输课程相关的数据
public class Course {
private String id; // 用于唯一标识课程的字符串类型的ID
private String name; // 存储课程名称的字符串
private Double credits; // 表示课程学分的双精度浮点数
private Integer score; // 课程的满分成绩,为整数类型
private Integer number; // 课程的总课时数,为整数类型
private Integer year; // 表示课程相关年份的整数(可能是笔误,推测为“届时”想表达的年份)
private Integer term; // 课程所属的学期,为整数类型
private Integer type; // 用整数表示课程的类型1代表必修2代表选修
private String profession; // 存储课程所属专业的字符串
private String grade; // 课程对应的班级名称,为字符串类型
private String realName; // 可能是与课程相关的人员姓名(如授课教师或学生姓名等,需结合具体业务场景),为字符串类型
private String no; // 学生的学号,为字符串类型(如果与学生相关)
private String studentId; // 学生的账号标识,为字符串类型
private String pointByUser; // 存储查询到的学生绩点信息的字符串
private String scoreByUser; // 存储查询到的学生课程分数的字符串
private String creditsByUser; // 存储查询到的学生获得的学分信息的字符串
private Integer start; // 课程开始的周数,为整数类型
private Integer end; // 课程结束的周数,为整数类型
private String room; // 课程授课的教室名称或编号,为字符串类型
private Date createTime; // 课程记录的创建时间使用Date类型表示
public Course() {} // 无参构造函数用于创建Course对象时不传入任何初始值
// 全参构造函数用于一次性初始化Course对象的所有属性
public Course(String id, String name, Double credits, Integer score, Integer number, Integer year, Integer term, Integer type, String profession, String grade, String realName, String no, String studentId, String pointByUser, String scoreByUser, String creditsByUser, Integer start, Integer end, String room, Date createTime) {
this.id = id; // 初始化课程ID
this.name = name; // 初始化课程名称
this.credits = credits; // 初始化课程学分
this.score = score; // 初始化课程满分成绩
this.number = number; // 初始化课程总课时数
this.year = year; // 初始化课程相关年份
this.term = term; // 初始化课程所属学期
this.type = type; // 初始化课程类型
this.profession = profession; // 初始化课程所属专业
this.grade = grade; // 初始化课程对应的班级
this.realName = realName; // 初始化相关人员姓名
this.no = no; // 初始化学号
this.studentId = studentId; // 初始化学生账号
this.pointByUser = pointByUser; // 初始化查询到的学生绩点信息
this.scoreByUser = scoreByUser; // 初始化查询到的学生课程分数
this.creditsByUser = creditsByUser; // 初始化查询到的学生获得的学分信息
this.start = start; // 初始化课程开始周数
this.end = end; // 初始化课程结束周数
this.room = room; // 初始化课程授课教室
this.createTime = createTime; // 初始化课程记录创建时间
}
public String getId() { return id; } // id属性的获取方法
public void setId(String id) { this.id = id; } // id属性的设置方法
public String getName() { return name; } // name属性的获取方法
public void setName(String name) { this.name = name; } // name属性的设置方法
public Double getCredits() { return credits; } // credits属性的获取方法
public void setCredits(Double credits) { this.credits = credits; } // credits属性的设置方法
public Integer getScore() { return score; } // score属性的获取方法
public void setScore(Integer score) { this.score = score; } // score属性的设置方法
public Integer getNumber() { return number; } // number属性的获取方法
public void setNumber(Integer number) { this.number = number; } // number属性的设置方法
public Integer getYear() { return year; } // year属性的获取方法
public void setYear(Integer year) { this.year = year; } // year属性的设置方法
public Integer getTerm() { return term; } // term属性的获取方法
public void setTerm(Integer term) { this.term = term; } // term属性的设置方法
public Integer getType() { return type; } // type属性的获取方法
public void setType(Integer type) { this.type = type; } // type属性的设置方法
public String getProfession() { return profession; } // profession属性的获取方法
public void setProfession(String profession) { this.profession = profession; } // profession属性的设置方法
public String getGrade() { return grade; } // grade属性的获取方法
public void setGrade(String grade) { this.grade = grade; } // grade属性的设置方法
public String getRealName() { return realName; } // realName属性的获取方法
public void setRealName(String realName) { this.realName = realName; } // realName属性的设置方法
public String getNo() { return no; } // no属性的获取方法
public void setNo(String no) { this.no = no; } // no属性的设置方法
public String getStudentId() { return studentId; } // studentId属性的获取方法
public void setStudentId(String studentId) { this.studentId = studentId; } // studentId属性的设置方法
public String getPointByUser() { return pointByUser; } // pointByUser属性的获取方法
public void setPointByUser(String pointByUser) { this.pointByUser = pointByUser; } // pointByUser属性的设置方法
public String getScoreByUser() { return scoreByUser; } // scoreByUser属性的获取方法
public void setScoreByUser(String scoreByUser) { this.scoreByUser = scoreByUser; } // scoreByUser属性的设置方法
public String getCreditsByUser() { return creditsByUser; } // creditsByUser属性的获取方法
public void setCreditsByUser(String creditsByUser) { this.creditsByUser = creditsByUser; } // creditsByUser属性的设置方法
public Integer getStart() { return start; } // start属性的获取方法
public void setStart(Integer start) { this.start = start; } // start属性的设置方法
public Integer getEnd() { return end; } // end属性的获取方法
public void setEnd(Integer end) { this.end = end; } // end属性的设置方法
public String getRoom() { return room; } // room属性的获取方法
public void setRoom(String room) { this.room = room; } // room属性的设置方法
public Date getCreateTime() { return createTime; } // createTime属性的获取方法
public void setCreateTime(Date createTime) { this.createTime = createTime; } // createTime属性的设置方法
@Override// 重写toString方法用于将Course对象以字符串形式表示方便调试和输出
public String toString() {// 构建一个字符串,包含了该课程对象的各个属性值,以特定格式拼接在一起
// 这种格式便于查看和理解对象的具体状态,常用于调试和日志记录等场景
return "Course{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", credits=" + credits +
", score=" + score +
", number=" + number +
", year=" + year +
", term=" + term +
", type=" + type +
", profession='" + profession + '\'' +
", grade='" + grade + '\'' +
", realName='" + realName + '\'' +
", no='" + no + '\'' +
", studentId='" + studentId + '\'' +
", pointByUser='" + pointByUser + '\'' +
", scoreByUser='" + scoreByUser + '\'' +
", creditsByUser='" + creditsByUser + '\'' +
", start=" + start +
", end=" + end +
", room='" + room + '\'' +
", createTime=" + createTime +
'}';
}
}

@ -0,0 +1,87 @@
package com.cow.horse.dto; // 声明该类所属的包,用于组织项目结构,此包通常存放数据传输对象
/**
* Description
* Author: cow.horse
* Date: 2020/3/19 10:55
**/
public class Score { // 定义一个名为Score的类用于表示分数信息的数据传输对象
private Long id; // 用于唯一标识分数记录的ID使用Long类型可存储较大范围的整数
private String username; // 存储与分数相关的用户名,以字符串形式表示
private String name; // 存储课程的名称,以字符串形式表示
private String scoreByUser; // 存储用户在该课程中获得的分数,以字符串形式表示
private String pointByUser; // 存储用户在该课程中获得的绩点,以字符串形式表示
private String creditsByUser; // 存储用户在该课程中获得的学分,以字符串形式表示
private Integer score; // 存储课程的总分使用Integer类型
private String credits; // 存储课程的学分,以字符串形式表示
private Integer term; // 存储分数所属的学期使用Integer类型
private Integer year; // 存储分数所属的年份使用Integer类型
private String no; // 存储学生的学号,以字符串形式表示
private String studentId; // 存储学生的账号ID以字符串形式表示
private String courseId; // 存储课程的ID以字符串形式表示
public Score() {} // 无参构造函数用于创建Score对象时不进行属性初始化
public Long getId() { return id; } // 获取分数记录ID的方法
public void setId(Long id) { this.id = id; } // 设置分数记录ID的方法
public Score(Long id, String username, String name, String scoreByUser, String pointByUser, String creditsByUser, Integer score, String credits, Integer term, Integer year, String no, String studentId, String courseId) { // 全参构造函数用于创建Score对象时同时初始化所有属性
this.id = id; // 初始化分数记录ID
this.username = username; // 初始化用户名
this.name = name; // 初始化课程名称
this.scoreByUser = scoreByUser; // 初始化用户获得的分数
this.pointByUser = pointByUser; // 初始化用户获得的绩点
this.creditsByUser = creditsByUser; // 初始化用户获得的学分
this.score = score; // 初始化课程总分
this.credits = credits; // 初始化课程学分
this.term = term; // 初始化学期
this.year = year; // 初始化年份
this.no = no; // 初始化学号
this.studentId = studentId; // 初始化学生账号ID
this.courseId = courseId; // 初始化课程ID
}
public String getUsername() { return username; } // 获取用户名的方法
public void setUsername(String username) { this.username = username; } // 设置用户名的方法
public String getName() { return name; } // 获取课程名称的方法
public void setName(String name) { this.name = name; } // 设置课程名称的方法
public String getScoreByUser() { return scoreByUser; } // 获取用户获得分数的方法
public void setScoreByUser(String scoreByUser) { this.scoreByUser = scoreByUser; } // 设置用户获得分数的方法
public String getPointByUser() { return pointByUser; } // 获取用户获得绩点的方法
public void setPointByUser(String pointByUser) { this.pointByUser = pointByUser; } // 设置用户获得绩点的方法
public String getCreditsByUser() { return creditsByUser; } // 获取用户获得学分的方法
public void setCreditsByUser(String creditsByUser) { this.creditsByUser = creditsByUser; } // 设置用户获得学分的方法
public Integer getScore() { return score; } // 获取课程总分的方法
public void setScore(Integer score) { this.score = score; } // 设置课程总分的方法
public String getCredits() { return credits; } // 获取课程学分的方法
public void setCredits(String credits) { this.credits = credits; } // 设置课程学分的方法
public Integer getTerm() { return term; } // 获取学期的方法
public void setTerm(Integer term) { this.term = term; } // 设置学期的方法
public Integer getYear() { return year; } // 获取年份的方法
public void setYear(Integer year) { this.year = year; } // 设置年份的方法
public String getNo() { return no; } // 获取学号的方法
public void setNo(String no) { this.no = no; } // 设置学号的方法
public String getStudentId() { return studentId; } // 获取学生账号ID的方法
public void setStudentId(String studentId) { this.studentId = studentId; } // 设置学生账号ID的方法
public String getCourseId() { return courseId; } // 获取课程ID的方法
public void setCourseId(String courseId) { this.courseId = courseId; } // 设置课程ID的方法
@Override
public String toString() { // 重写toString方法用于将对象以字符串形式输出方便调试和日志记录
return "Score{" +
"id=" + id +
", username='" + username + '\'' +
", name='" + name + '\'' +
", scoreByUser='" + scoreByUser + '\'' +
", pointByUser='" + pointByUser + '\'' +
", creditsByUser='" + creditsByUser + '\'' +
", score=" + score +
", credits='" + credits + '\'' +
", term=" + term +
", year=" + year +
", no='" + no + '\'' +
", studentId='" + studentId + '\'' +
", courseId='" + courseId + '\'' +
'}';
}
}

@ -0,0 +1,87 @@
package com.cow.horse.dto; // 声明该类所在的包,一般用于存放数据传输对象
/**
* Description
* Author: cow.horse
* Date: 2020/4/7 13:57
**/
public class Timetable { // 定义课程表实体类,用于表示课程表相关信息
/**
* id
*/
private Integer id; // 课程表记录的唯一标识符
/**
* week id
*/
private Integer weekId; // 与周相关的ID可能用于标识某一周
/**
*
*/
private String profession; // 课程表对应的专业名称
/**
*
*/
private String grade; // 课程表对应的班级名称
/**
*
*/
private Integer year; // 课程表对应的学年
/**
*
*/
private Integer term; // 课程表对应的学期
/**
*
*/
private Integer weekNum; // 课程表对应的周数
public Timetable() {} // 无参构造函数用于创建一个空的Timetable对象
// 全参构造函数用于创建包含所有属性值的Timetable对象
public Timetable(Integer id, Integer weekId, String profession, String grade, Integer year, Integer term, Integer weekNum) {
this.id = id; // 初始化课程表记录ID
this.weekId = weekId; // 初始化周ID
this.profession = profession; // 初始化专业名称
this.grade = grade; // 初始化班级名称
this.year = year; // 初始化学年
this.term = term; // 初始化学期
this.weekNum = weekNum; // 初始化周数
}
// 部分参数构造函数用于创建不包含周数信息的Timetable对象
public Timetable(Integer id, Integer weekId, String profession, String grade, Integer year, Integer term) {
this.id = id; // 初始化课程表记录ID
this.weekId = weekId; // 初始化周ID
this.profession = profession; // 初始化专业名称
this.grade = grade; // 初始化班级名称
this.year = year; // 初始化学年
this.term = term; // 初始化学期
}
public Integer getWeekNum() { return weekNum; } // 获取周数的方法
public void setWeekNum(Integer weekNum) { this.weekNum = weekNum; } // 设置周数的方法
public Integer getId() { return id; } // 获取课程表记录ID的方法
public void setId(Integer id) { this.id = id; } // 设置课程表记录ID的方法
public Integer getWeekId() { return weekId; } // 获取周ID的方法
public void setWeekId(Integer weekId) { this.weekId = weekId; } // 设置周ID的方法
public String getProfession() { return profession; } // 获取专业名称的方法
public void setProfession(String profession) { this.profession = profession; } // 设置专业名称的方法
public String getGrade() { return grade; } // 获取班级名称的方法
public void setGrade(String grade) { this.grade = grade; } // 设置班级名称的方法
public Integer getYear() { return year; } // 获取学年的方法
public void setYear(Integer year) { this.year = year; } // 设置学年的方法
public Integer getTerm() { return term; } // 获取学期的方法
public void setTerm(Integer term) { this.term = term; } // 设置学期的方法
@Override
public String toString() { // 重写toString方法用于将对象信息以字符串形式输出
return "Timetable{" +
"id=" + id +
", weekId=" + weekId +
", profession='" + profession + '\'' +
", grade='" + grade + '\'' +
", year=" + year +
", term=" + term +
'}';
}
}

@ -0,0 +1,57 @@
package com.cow.horse.dto; // 声明该类所在的包通常用于存放数据传输对象DTO
import java.util.Arrays; // 导入Arrays类用于处理数组相关操作如将数组转换为字符串表示
/**
* Description
* Author: cow.horse
* Date: 2020/3/27 22:07
**/
public class Tree { // 定义一个名为Tree的树形实体类
private String name; // 树形结构的名称,用于标识该树形结构的用途或类型
private String [] school; // 存储学校名称的字符串数组,可能表示树形结构中学校相关的节点信息
private String [] profession; // 存储专业名称的字符串数组,可能表示树形结构中专业相关的节点信息
public Tree() { // 无参构造函数用于创建一个Tree对象不初始化任何属性
}
// 全参构造函数用于创建Tree对象时同时初始化所有属性
public Tree(String name, String[] school, String[] profession) {
this.name = name; // 初始化树形结构的名称
this.school = school; // 初始化学校名称数组
this.profession = profession; // 初始化专业名称数组
}
public String getName() { // 获取树形结构名称的方法
return name;
}
public void setName(String name) { // 设置树形结构名称的方法
this.name = name;
}
public String[] getSchool() { // 获取学校名称数组的方法
return school;
}
public void setSchool(String[] school) { // 设置学校名称数组的方法
this.school = school;
}
public String[] getProfession() { // 获取专业名称数组的方法
return profession;
}
public void setProfession(String[] profession) { // 设置专业名称数组的方法
this.profession = profession;
}
@Override
public String toString() { // 重写toString方法用于将Tree对象以字符串形式表示方便调试和日志记录
return "Tree{" +
"name='" + name + '\'' +
", school=" + Arrays.toString(school) + // 使用Arrays.toString方法将学校名称数组转换为字符串
", profession=" + Arrays.toString(profession) + // 使用Arrays.toString方法将专业名称数组转换为字符串
'}';
}
}

@ -0,0 +1,110 @@
package com.cow.horse.dto; // 声明该类所在的包用于组织项目中的数据传输对象DTO
import lombok.AllArgsConstructor; // 导入Lombok的AllArgsConstructor注解用于自动生成全参构造函数
import lombok.Data; // 导入Lombok的Data注解自动生成getter、setter、toString、equals和hashCode方法
import lombok.NoArgsConstructor; // 导入Lombok的NoArgsConstructor注解用于自动生成无参构造函数
import java.util.Date; // 导入Java的Date类用于处理日期和时间
/**
* Description
* Author: cow.horse
* Date2019/10/21 20:58
**/
public class User { // 定义一个名为User的类用于表示用户登录信息及相关属性
private String id; // 用户的唯一标识符,以字符串形式存储
private String username; // 用户登录使用的名称,以字符串形式存储
private String password; // 用户登录使用的密码,以字符串形式存储
private String passwordAgain; // 用于确认密码输入是否一致,以字符串形式存储
private String realName; // 用户的真实姓名,以字符串形式存储
private Integer level; // 用户的等级,以整数形式存储,可用于区分不同权限的用户
private String school; // 用户所属的学校名称,以字符串形式存储
private String admissionTime; // 用户的入学时间,以字符串形式存储
private String email; // 用户的电子邮箱地址,以字符串形式存储
private String profession; // 用户的专业名称,以字符串形式存储
private String phone; // 用户的联系电话,以字符串形式存储
private Integer sex; // 用户的性别以整数形式存储如0表示男1表示女
private String grade; // 用户所在的班级名称,以字符串形式存储
private Date createTime; // 用户账号的创建时间使用Date类型存储
private String token; // 用户登录后生成的令牌,用于身份验证,以字符串形式存储
private String refreshToken; // 用户用于刷新token的令牌以字符串形式存储
private Integer state; // 可能表示用户的某种状态,如默哀模式等,以整数形式存储
public User() {} // 无参构造函数用于创建一个空的User对象
public User(String id, String username, String password, String passwordAgain, String realName, Integer level, String school, String admissionTime, String email, String profession, String phone, Integer sex, String grade, Date createTime, String token, String refreshToken, Integer state) { // 全参构造函数用于创建User对象并初始化所有属性
this.id = id; // 初始化用户唯一标识符
this.username = username; // 初始化用户名
this.password = password; // 初始化用户密码
this.passwordAgain = passwordAgain; // 初始化确认密码
this.realName = realName; // 初始化用户真实姓名
this.level = level; // 初始化用户等级
this.school = school; // 初始化用户所属学校名称
this.admissionTime = admissionTime; // 初始化用户入学时间
this.email = email; // 初始化用户电子邮箱地址
this.profession = profession; // 初始化用户专业名称
this.phone = phone; // 初始化用户联系电话
this.sex = sex; // 初始化用户性别
this.grade = grade; // 初始化用户所在班级名称
this.createTime = createTime; // 初始化用户账号创建时间
this.token = token; // 初始化用户登录令牌
this.refreshToken = refreshToken; // 初始化用户刷新令牌
this.state = state; // 初始化用户状态
}
public String getId() { return id; } // 获取用户唯一标识符的方法
public void setId(String id) { this.id = id; } // 设置用户唯一标识符的方法
public String getUsername() { return username; } // 获取用户名的方法
public void setUsername(String username) { this.username = username; } // 设置用户名的方法
public String getPassword() { return password; } // 获取用户密码的方法
public void setPassword(String password) { this.password = password; } // 设置用户密码的方法
public String getPasswordAgain() { return passwordAgain; } // 获取确认密码的方法
public void setPasswordAgain(String passwordAgain) { this.passwordAgain = passwordAgain; } // 设置确认密码的方法
public String getRealName() { return realName; } // 获取用户真实姓名的方法
public void setRealName(String realName) { this.realName = realName; } // 设置用户真实姓名的方法
public Integer getLevel() { return level; } // 获取用户等级的方法
public void setLevel(Integer level) { this.level = level; } // 设置用户等级的方法
public String getSchool() { return school; } // 获取用户所属学校名称的方法
public void setSchool(String school) { this.school = school; } // 设置用户所属学校名称的方法
public String getAdmissionTime() { return admissionTime; } // 获取用户入学时间的方法
public void setAdmissionTime(String admissionTime) { this.admissionTime = admissionTime; } // 设置用户入学时间的方法
public String getEmail() { return email; } // 获取用户电子邮箱地址的方法
public void setEmail(String email) { this.email = email; } // 设置用户电子邮箱地址的方法
public String getProfession() { return profession; } // 获取用户专业名称的方法
public void setProfession(String profession) { this.profession = profession; } // 设置用户专业名称的方法
public String getPhone() { return phone; } // 获取用户联系电话的方法
public void setPhone(String phone) { this.phone = phone; } // 设置用户联系电话的方法
public Integer getSex() { return sex; } // 获取用户性别的方法
public void setSex(Integer sex) { this.sex = sex; } // 设置用户性别的方法
public String getGrade() { return grade; } // 获取用户所在班级名称的方法
public void setGrade(String grade) { this.grade = grade; } // 设置用户所在班级名称的方法
public Date getCreateTime() { return createTime; } // 获取用户账号创建时间的方法
public void setCreateTime(Date createTime) { this.createTime = createTime; } // 设置用户账号创建时间的方法
public String getToken() { return token; } // 获取用户登录令牌的方法
public void setToken(String token) { this.token = token; } // 设置用户登录令牌的方法
public String getRefreshToken() { return refreshToken; } // 获取用户刷新令牌的方法
public void setRefreshToken(String refreshToken) { this.refreshToken = refreshToken; } // 设置用户刷新令牌的方法
public Integer getState() { return state; } // 获取用户状态的方法
public void setState(Integer state) { this.state = state; } // 设置用户状态的方法
@Override
public String toString() { // 重写toString方法将User对象转换为字符串表示方便调试和日志记录
return "User{" +
"id='" + id + '\'' +
", username='" + username + '\'' +
", password='" + password + '\'' +
", passwordAgain='" + passwordAgain + '\'' +
", realName='" + realName + '\'' +
", level=" + level +
", school='" + school + '\'' +
", admissionTime='" + admissionTime + '\'' +
", email='" + email + '\'' +
", profession='" + profession + '\'' +
", phone='" + phone + '\'' +
", sex=" + sex +
", grade='" + grade + '\'' +
", createTime=" + createTime +
", token='" + token + '\'' +
", refreshToken='" + refreshToken + '\'' +
", state=" + state +
'}';
}
}

@ -0,0 +1,61 @@
package com.cow.horse.service.Course;
import com.cow.horse.dto.Course;
import com.cow.horse.utils.PagingResult;
import org.apache.ibatis.session.RowBounds;
import java.util.List;
import java.util.Map;
/**
* Description service
* Author: cow.horse
* Date: 2020/3/11 14:49
**/
public interface CourseService {
/**
* description:
* @param course
* return void
* @author cow.horse
* @Date 2020/3/4 23:05
*/
void addCourse(Course course);
/**
* description:
*
* @param ids
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void delete(List<Long> ids);
/**
* description:
*
* @param course
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void update(Course course);
/**
* description:
* @param: rowBounds
* @param: condition
* return: com.jw.zjh.sms.utils.PagingResult
* Author: cow.horse
* @Date: 2022/3/11 14:49
*/
PagingResult<Course> getCourseList(RowBounds rowBounds, Map<String, Object> condition);
/**
* description:
* @param: Map<String, Object> condition
* return: List<Course>
* Author: cow.horse
* @Date: 2022/3/31 22:28
*/
List<Course> getCourseByMap(Map<String, Object> condition);
}

@ -0,0 +1,99 @@
package com.cow.horse.service.Course.impl;
import com.cow.horse.dao.Course.CourseMapper;
import com.cow.horse.dao.CourseInfo.CourseInfoMapper;
import com.cow.horse.dao.Profession.ProfessionMapper;
import com.cow.horse.domain.CourseInfo;
import com.cow.horse.domain.Profession;
import com.cow.horse.dto.Course;
import com.cow.horse.service.Course.CourseService;
import com.cow.horse.utils.PagingResult;
import com.github.pagehelper.PageRowBounds;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Description
* Author: cow.horse
* Date: 2020/3/11 14:49
**/
@Service
public class CourseServiceImpl implements CourseService {
@Resource
private CourseMapper courseMapper;
@Resource
private CourseInfoMapper courseInfoMapper;
@Resource
private ProfessionMapper professionMapper;
@Override
public void addCourse(Course course) {
Profession profession = professionMapper.getProfessionIdByName(course.getProfession());
String id = "";
String str = course.getYear().toString() + "0" + profession.getId() + course.getTerm();
Map<String, Object> condition = new HashMap<>();
condition.put("profession", course.getProfession());
condition.put("year", course.getYear());
String value = courseMapper.checkCodeCount(condition);
String strValue = "";
if (value != null) {
int num = Integer.parseInt(value.substring(value.length() - 3)) + 1;
if (num < 10) {
strValue = "00" + Integer.toString(num);
} else if (num < 100) {
strValue = "0" + Integer.toString(num);
} else {
strValue = Integer.toString(num);
}
} else {
strValue = "001";
}
id = str + strValue;
course.setId(id);
courseMapper.addCourse(course);
courseInfoMapper.deleteInfo(id);
// 新增课程的周数等
CourseInfo courseInfo = new CourseInfo();
courseInfo.setStart(1);
courseInfo.setEnd(25);
courseInfo.setCourseId(id);
courseInfo.setProfession(course.getProfession());
courseInfoMapper.addCourseInfo(courseInfo);
}
@Override
public void delete(List<Long> ids) {
courseMapper.delete(ids);
for (Long id : ids) {
courseInfoMapper.deleteInfo(Long.toString(id));
}
}
@Override
public void update(Course course) {
courseMapper.update(course);
CourseInfo courseInfo = new CourseInfo();
courseInfo.setProfession(course.getProfession());
courseInfo.setCourseId(course.getId());
courseInfoMapper.updateCourseInfo(courseInfo);
}
@Override
public PagingResult<Course> getCourseList(RowBounds rowBounds, Map<String, Object> condition) {
PageRowBounds pageRowBounds = new PageRowBounds(rowBounds.getOffset(), rowBounds.getLimit());
List<Course> CourseList = courseMapper.getCourseList(pageRowBounds, condition);
return new PagingResult<>(CourseList, pageRowBounds.getTotal());
}
@Override
public List<Course> getCourseByMap(Map<String, Object> condition) {
return courseMapper.getCourseByMap(condition);
}
}

@ -0,0 +1,20 @@
package com.cow.horse.service.Profession;
import com.cow.horse.domain.Profession;
import java.util.List;
/**
* Description Service
* Author: cow.horse
* Date: 2020/3/31 17:31
**/
public interface ProfessionService {
/**
* description:
* return:
* Author: cow.horse
* @Date: 2022/3/31 17:31
*/
List<Profession> getProfessionList();
}

@ -0,0 +1,25 @@
package com.cow.horse.service.Profession.impl;
import com.cow.horse.dao.Profession.ProfessionMapper;
import com.cow.horse.domain.Profession;
import com.cow.horse.service.Profession.ProfessionService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* Description
* Author: cow.horse
* Date: 2020/3/31 17:33
**/
@Service
public class ProfessionServiceImpl implements ProfessionService {
@Resource
private ProfessionMapper professionMapper;
@Override
public List<Profession> getProfessionList() {
return professionMapper.getProfessionList();
}
}

@ -0,0 +1,58 @@
package com.cow.horse.service.Score;
import com.cow.horse.dto.Course;
import com.cow.horse.dto.Score;
import com.cow.horse.utils.PagingResult;
import org.apache.ibatis.session.RowBounds;
import java.util.List;
import java.util.Map;
/**
* Description Service
* Author: cow.horse
* Date: 2020/3/13 15:47
**/
public interface ScoreService {
/**
* description:
* @param rowBounds
* @param condition
* @author cow.horse
* @return com.jw.zjh.sms.utils.PagingResult
* @date 2020/3/4 23:05
*/
PagingResult<Course> getCourseList(RowBounds rowBounds, Map<String, Object> condition);
/**
* description:
* @param: List<Score>
* return: void
* Author: cow.horse
* @Date: 2022/3/19 16:23
*/
void addEntry(List<Score> list);
/**
* description: Excel
* @param: Map<String, Object> condition
* return: List<Course>
* Author: cow.horse
* @Date: 2022/3/21 16:26
*/
List<Course> getExportList(Map<String, Object> condition);
/**
* description:
* @param: Map<String, Object> condition
* return: List<Map<String, Object>>
* Author: cow.horse
* @Date: 2022/4/3 22:53
*/
List<Map<String, Object>> getUserNum(Map<String, Object> condition);
/**
* description: id
* @param: Map<String, Object> condition
* return: Map<String, Object>
* Author: cow.horse
* @Date: 2022/4/3 22:53
*/
Map<String, Object> getUserTotal(Map<String, Object> condition);
}

@ -0,0 +1,232 @@
package com.cow.horse.service.Score.impl;
import com.cow.horse.dao.Score.ScoreMapper;
import com.cow.horse.dto.Course;
import com.cow.horse.dto.Score;
import com.cow.horse.service.Score.ScoreService;
import com.cow.horse.utils.PagingResult;
import com.github.pagehelper.PageRowBounds;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
/**
* Description
* Author: cow.horse
* Date: 2020/3/13 15:49
**/
@Service
public class ScoreServiceImpl implements ScoreService {
@Autowired
private ScoreMapper scoreMapper;
@Override
public PagingResult<Course> getCourseList(RowBounds rowBounds, Map<String, Object> condition) {
PageRowBounds pageRowBounds = new PageRowBounds(rowBounds.getOffset(), rowBounds.getLimit());
List<Course> courseList = new ArrayList<>();
switch (condition.get("level").toString()) {
case "0":
courseList = scoreMapper.getCourseByAdmin(pageRowBounds, condition);
for (Course course : courseList) {
adminCourseMethod(course);
}
break;
case "1":
courseList = scoreMapper.getCourseByMap(pageRowBounds, condition);
break;
case "2":
courseList = scoreMapper.getCourseByStudent(pageRowBounds, condition);
}
return new PagingResult<>(courseList, pageRowBounds.getTotal());
}
private void adminCourseMethod(Course course) {
Map<String, Object> map = new HashMap<>();
map.put("id", course.getNo());
map.put("courseName", course.getName());
Course courseById = scoreMapper.getScoreById(map);
if (courseById != null) {
course.setCreditsByUser(courseById.getCreditsByUser());
course.setPointByUser(courseById.getPointByUser());
course.setScoreByUser(courseById.getScoreByUser());
}
}
@Override
public void addEntry(List<Score> list) {
for (Score score : list) {
// string转double
double scoreByUser = Double.parseDouble(score.getScoreByUser());
BigDecimal bg = new BigDecimal((scoreByUser/10-5));
// 取两位有效数字
double f1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
String point = scoreByUser > 59 ? String.valueOf(f1):"0";
String credits = scoreByUser >= score.getScore()*0.6 ? score.getCredits() : "0.00";
score.setPointByUser(point);
score.setCreditsByUser(credits);
score.setCourseId(Long.toString(score.getId()));
Map<String, Object> condition = new HashMap<>();
condition.put("StudentId", score.getNo());
condition.put("CourseName", score.getName());
Integer num = scoreMapper.checkCount(condition);
if (num == 0) {
scoreMapper.addEntry(score);
} else {
scoreMapper.updateEntry(score);
}
}
}
@Override
public List<Course> getExportList(Map<String, Object> condition) {
List<Course> courseList = new ArrayList<>();
switch (condition.get("level").toString()) {
case "0":
courseList = scoreMapper.getExportListByAdmin(condition);
for (Course course : courseList) {
adminCourseMethod(course);
}
break;
case "1":
courseList = scoreMapper.getExportList(condition);
break;
case "2":
courseList = scoreMapper.getExportListByStudent(condition);
}
return courseList;
}
@Override
public List<Map<String, Object>> getUserNum(Map<String, Object> condition) {
List<Map<String, Object>> list = new ArrayList<>();
List<Course> courseList = new ArrayList<>();
switch (condition.get("level").toString()) {
case "0":
courseList = scoreMapper.getExportListByAdmin(condition);
for (Course course : courseList) {
adminCourseMethod(course);
}
list = dealScore(courseList);
break;
case "1":
courseList = scoreMapper.getExportList(condition);
list = dealScore(courseList);
break;
case "2":
courseList = scoreMapper.getExportListByStudent(condition);
list = dealScore(courseList);
}
return list;
}
@Override
public Map<String, Object> getUserTotal(Map<String, Object> condition) {
String level = condition.get("level").toString();
if (level.equals("2")) {
List<Course> list = scoreMapper.getStudentTotal(condition);
double credits = 0.00;
double point = 0.00;
for (Course course : list) {
double a = Double.parseDouble(course.getCreditsByUser());
credits += a;
double b = Double.parseDouble(course.getPointByUser());
point += b;
}
Map<String, Object> map = new HashMap<>();
map.put("credits", credits);
map.put("point", point);
return map;
} else if (level.equals("1")) {
List<Course> courseList = scoreMapper.getExportList(condition);
return getLimit(courseList);
} else {
List<Course> courseList = scoreMapper.getExportListByAdmin(condition);
for (Course course : courseList) {
adminCourseMethod(course);
}
return getLimit(courseList);
}
}
private Map<String, Object> getLimit(List<Course> courseList) {
List<Double> list = new ArrayList<>();
double max = 0.00;
double min = 0.00;
double average = 0.00;
double count = 0.00;
for (Course course : courseList) {
if (course.getScoreByUser() != null) {
list.add(Double.parseDouble(course.getScoreByUser()));
}
}
if (list.size() > 0) {
Collections.sort(list);
min = list.get(0);
max = list.get(list.size() - 1);
}
for (Double score : list) {
count += score;
}
average = list.size()==0 ? 0.00 : count / list.size();
Map<String, Object> map = new HashMap<>();
map.put("max", max);
map.put("min", min);
map.put("average", average);
return map;
}
private List<Map<String, Object>> dealScore(List<Course> courseList) {
if (courseList.size() > 0) {
Map<String, Object> unknownCondition = new HashMap<>();
Map<String, Object> failCondition = new HashMap<>();
Map<String, Object> passCondition = new HashMap<>();
Map<String, Object> goodCondition = new HashMap<>();
int fail = 0;
int pass = 0;
int good = 0;
int unknown = 0;
for (Course course : courseList) {
double scoreFull = course.getScore() / 100;
if (course.getScoreByUser() == null) {
unknown++;
} else {
double score = Double.parseDouble(course.getScoreByUser()) * scoreFull;
if (score < 60) {
fail++;
} else if (score < 85) {
pass++;
} else {
good++;
}
}
}
int passLine = (int) (courseList.get(0).getScore() * 0.6);
int goodLine = (int) (courseList.get(0).getScore() * 0.85);
int FullLine = courseList.get(0).getScore();
String unknownLabel = "未录入";
String failLabel = "不及格(" + "0-" + (passLine - 1) + ")";
String passLabel = "及格(" + passLine + "-" + (goodLine - 1) + ")";
String goodLabel = "优秀(" + goodLine + "-" + FullLine + ")";
if (unknown != 0) {
unknownCondition.put("label", unknownLabel);
unknownCondition.put("value", unknown);
}
failCondition.put("label", failLabel);
failCondition.put("value", fail);
passCondition.put("label", passLabel);
passCondition.put("value", pass);
goodCondition.put("label", goodLabel);
goodCondition.put("value", good);
List<Map<String, Object>> list = new ArrayList<>();
list.add(goodCondition);
list.add(passCondition);
list.add(failCondition);
list.add(unknownCondition);
return list;
} else {
return new ArrayList<>();
}
}
}

@ -0,0 +1,74 @@
package com.cow.horse.service.TeacherCourse;
import com.cow.horse.domain.TeacherCourse;
import com.cow.horse.dto.Course;
import java.util.List;
import java.util.Map;
/**
* Description Service
* Author: cow.horse
* Date: 2020/3/29 15:09
**/
public interface TeacherCourseService {
/**
* description:
* @param list
* @return void
* @author cow.horse
* @date 2020/3/4 23:05
*/
void add(List<TeacherCourse> list);
/**
* description:
*
* @param ids
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void delete(List<Integer> ids);
/**
* description:
* @param teacherCourse
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void update(TeacherCourse teacherCourse);
/**
* description: id
* @param: String
* return: List<TeacherCourse>
* Author: cow.horse
* @Date: 2022/3/29 14:31
*/
List<TeacherCourse> getCourseListById(String id);
/**
* description: id
* @param: String
* return: List<Map<String, Object>>
* Author: cow.horse
* @Date: 2022/4/4 20:54
*/
List<Map<String, Object>> getProfessionInfo(String teacherId);
/**
* description:
* return: List<Map<String, Object>>
* Author: cow.horse
* @Date: 2022/4/5 0:16
*/
List<Map<String, Object>> getProfessionInfoByAdmin();
/**
* description:
* @param: Map<String, Object> condition
* return: TeacherCourse
* Author: cow.horse
* @Date: 2022/4/9 17:29
*/
Course getCourseInfo(Map<String, Object> condition);
}

@ -0,0 +1,126 @@
package com.cow.horse.service.TeacherCourse.impl;
import com.cow.horse.dao.Course.CourseMapper;
import com.cow.horse.dao.Profession.ProfessionMapper;
import com.cow.horse.dao.TeacherCourse.TeacherCourseMapper;
import com.cow.horse.dao.User.StudentMapper;
import com.cow.horse.domain.Profession;
import com.cow.horse.domain.TeacherCourse;
import com.cow.horse.dto.Course;
import com.cow.horse.service.TeacherCourse.TeacherCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* Description
* Author: cow.horse
* Date: 2020/3/29 15:09
**/
@Service
public class TeacherCourseServiceImpl implements TeacherCourseService {
@Autowired
private TeacherCourseMapper teacherCourseMapper;
@Autowired
private ProfessionMapper professionMapper;
@Autowired
private StudentMapper studentMapper;
@Autowired
private CourseMapper courseMapper;
@Override
public void add(List<TeacherCourse> list) {
List<Integer> ids = new ArrayList<>();
for (TeacherCourse teacherCourse : list) {
if (teacherCourse.getId() != -1) {
ids.add(teacherCourse.getId());
}
}
if (ids.size() > 0) {
teacherCourseMapper.delete(ids);
}
for (TeacherCourse teacherCourse : list) {
Course course = courseMapper.getCourseById(teacherCourse.getCourseId());
teacherCourse.setName(course.getName());
teacherCourseMapper.add(teacherCourse);
}
}
@Override
public void delete(List<Integer> ids) {
teacherCourseMapper.delete(ids);
}
@Override
public void update(TeacherCourse teacherCourse) {
teacherCourseMapper.update(teacherCourse);
}
@Override
public List<TeacherCourse> getCourseListById(String id) {
List<TeacherCourse> teacherCourseList = teacherCourseMapper.getCourseListById(id);
return teacherCourseList;
}
@Override
public List<Map<String, Object>> getProfessionInfo(String teacherId) {
List<TeacherCourse> list = teacherCourseMapper.getCourseListById(teacherId);
List<Map<String, Object>> arr = new ArrayList<>();
Set<String> professionSet = new HashSet<>();
for (TeacherCourse teacherCourse : list) {
professionSet.add(teacherCourse.getProfession());
}
for (String s : professionSet) {
Map<String, Object> condition = new HashMap<>();
condition.put("teacherId", teacherId);
condition.put("profession", s);
List<TeacherCourse> listObj = teacherCourseMapper.getGradeInfoByMap(condition);
Set<String> gradeSet = new HashSet<>();
Set<String> courseSet = new HashSet<>();
for (TeacherCourse teacherCourse : listObj) {
gradeSet.add(teacherCourse.getGrade());
courseSet.add(teacherCourse.getName());
}
condition.put("grade", gradeSet);
condition.put("course", courseSet);
arr.add(condition);
}
return arr;
}
@Override
public List<Map<String, Object>> getProfessionInfoByAdmin() {
List<Map<String, Object>> arr = new ArrayList<>();
List<Profession> professionList = professionMapper.getProfessionList();
for (Profession profession : professionList) {
Map<String, Object> condition = new HashMap<>();
condition.put("profession", profession.getName());
List<String> gradeList = studentMapper.getGradeByProfession(profession.getName());
List<Course> courseList = courseMapper.getCourseByMap(condition);
List<String> courseNameList = new ArrayList<>();
for (Course course : courseList) {
courseNameList.add(course.getName());
}
// 转成int然后再排序
List<Integer> list = new ArrayList<>();
for (String str : new HashSet<>(gradeList)) {
int number = Integer.parseInt(str);
list.add(number);
}
Collections.sort(list);
condition.put("grade", list);
condition.put("course", new HashSet<>(courseNameList));
arr.add(condition);
}
return arr;
}
@Override
public Course getCourseInfo(Map<String, Object> condition) {
return teacherCourseMapper.getCourseInfo(condition);
}
}

@ -0,0 +1,56 @@
package com.cow.horse.service.Timetable;
import com.cow.horse.domain.CourseInfo;
import com.cow.horse.domain.WeekCourse;
import java.util.List;
import java.util.Map;
/**
* Description Service
* Author: cow.horse
* Date: 2020/4/7 14:03
**/
public interface TimetableService {
/**
* description:
* @param list
* @return void
* @author cow.horse
* @date 2020/3/4 23:05
*/
void add(List<WeekCourse> list);
/**
* description:
* @param condition
* @author cow.horse
* @return List<WeekCourse>
* @date 2020/3/4 23:05
*/
List<WeekCourse> getTimetable(Map<String, Object> condition);
/**
* description:
* @param: condition
* return: List<WeekCourse>
* Author: cow.horse
* @Date: 2022/4/7 21:10
*/
List<WeekCourse> getTimetableByStudent(Map<String, Object> condition);
/**
* description:
* @param: condition
* return: List<WeekCourse>
* Author: cow.horse
* @Date: 2022/4/7 21:31
*/
List<WeekCourse> getTimetableByTeacher(Map<String, Object> condition);
/**
* description:
* @param: CourseInfo
* return: void
* Author: cow.horse
* @Date: 2022/5/3 14:50
*/
void updateCourseInfo(CourseInfo courseInfo);
}

@ -0,0 +1,281 @@
package com.cow.horse.service.Timetable.impl;
import com.cow.horse.dao.CourseInfo.CourseInfoMapper;
import com.cow.horse.dao.TeacherCourse.TeacherCourseMapper;
import com.cow.horse.dao.Timetable.TimetableMapper;
import com.cow.horse.dao.User.StudentMapper;
import com.cow.horse.dao.WeekCourse.WeekCourseMapper;
import com.cow.horse.domain.CourseInfo;
import com.cow.horse.domain.TeacherCourse;
import com.cow.horse.domain.WeekCourse;
import com.cow.horse.dto.Timetable;
import com.cow.horse.dto.User;
import com.cow.horse.service.Timetable.TimetableService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
/**
* Description
* Author: cow.horse
* Date: 2020/4/7 14:17
**/
@Service
public class TimetableServiceImpl implements TimetableService {
@Resource
private TimetableMapper timetableMapper;
@Resource
private StudentMapper studentMapper;
@Resource
private WeekCourseMapper weekCourseMapper;
@Resource
private TeacherCourseMapper teacherCourseMapper;
@Resource
private CourseInfoMapper courseInfoMapper;
@Override
@Transactional
public void add(List<WeekCourse> list) {
Map<String, Object> condition = new HashMap<>();
condition.put("profession", list.get(0).getProfession());
condition.put("grade", list.get(0).getGrade());
condition.put("year", list.get(0).getYear());
condition.put("term", list.get(0).getTerm());
condition.put("week", list.get(0).getWeek());
// 获取原本课程表信息
List<Timetable> timeTableList = timetableMapper.getTimetable(condition);
Set<Integer> ids = new HashSet<>();
Set<Integer> weekIds = new HashSet<>();
for (Timetable timetable : timeTableList) {
ids.add(timetable.getId());
weekIds.add(timetable.getWeekId());
}
if (ids.size() > 0) {
// 修改
for (int i = 0; i < list.size(); i++) {
List<Integer> weekList = new ArrayList<>(weekIds);
// 排序
Collections.sort(weekList);
WeekCourse weekCourse = list.get(i);
weekCourse.setId(weekList.get(i));
dealWeek(list.get(i));
weekCourseMapper.update(list.get(i));
}
} else {
// 新增课程表
// 删除旧课程表
timetableMapper.deleteTimeTable(condition);
// 新增
for (WeekCourse weekCourse : list) {
dealWeek(weekCourse);
weekCourseMapper.add(weekCourse);
Timetable timetable = new Timetable();
timetable.setWeekId(weekCourse.getId());
timetable.setProfession(weekCourse.getProfession());
timetable.setGrade(weekCourse.getGrade());
timetable.setYear(weekCourse.getYear());
timetable.setTerm(weekCourse.getTerm());
timetable.setWeekNum(weekCourse.getWeek());
timetableMapper.add(timetable);
}
}
}
private void dealWeek(WeekCourse weekCourse) {
if (weekCourse.getMonday() == null || weekCourse.getMonday().equals("")) {
weekCourse.setMonday("一");
}
if (weekCourse.getTuesday() == null || weekCourse.getTuesday().equals("")) {
weekCourse.setTuesday("一");
}
if (weekCourse.getWednesday() == null || weekCourse.getWednesday().equals("")) {
weekCourse.setWednesday("一");
}
if (weekCourse.getThursday() == null || weekCourse.getThursday().equals("")) {
weekCourse.setThursday("一");
}
if (weekCourse.getFriday() == null || weekCourse.getFriday().equals("")) {
weekCourse.setFriday("一");
}
if (weekCourse.getSaturday() == null || weekCourse.getSaturday().equals("")) {
weekCourse.setSaturday("一");
}
if (weekCourse.getSunday() == null || weekCourse.getSunday().equals("")) {
weekCourse.setSunday("一");
}
}
@Override
public List<WeekCourse> getTimetable(Map<String, Object> condition) {
int num = timetableMapper.checkCount(condition);
List<WeekCourse> list = new ArrayList<>();
if (num == 0) {
for (int i = 1; i < 11; i++) {
WeekCourse week = new WeekCourse();
list.add(week);
}
} else {
list = weekCourseMapper.getWeekCourse(condition);
dealMethod(list, condition);
}
return list;
}
// 根据当前周过滤课程表中不属于当前周的课程
private void dealMethod (List<WeekCourse> list, Map<String, Object> condition) {
for (WeekCourse weekCourse : list) {
Map<String, Object> map = new HashMap<>();
map.put("profession", condition.get("profession").toString());
map.put("week", condition.get("week").toString());
map.put("name", weekCourse.getMonday().toString());
weekCourse.setMonday(dealCourseInfo(map));
map.put("name", weekCourse.getTuesday().toString());
weekCourse.setTuesday(dealCourseInfo(map));
map.put("name", weekCourse.getWednesday().toString());
weekCourse.setWednesday(dealCourseInfo(map));
map.put("name", weekCourse.getThursday().toString());
weekCourse.setThursday(dealCourseInfo(map));
map.put("name", weekCourse.getFriday().toString());
weekCourse.setFriday(dealCourseInfo(map));
map.put("name", weekCourse.getSaturday().toString());
weekCourse.setSaturday(dealCourseInfo(map));
map.put("name", weekCourse.getSunday().toString());
weekCourse.setSunday(dealCourseInfo(map));
}
}
private String dealCourseInfo (Map<String, Object> map) {
CourseInfo courseInfo = courseInfoMapper.getInfo(map);
if (courseInfo != null) {
int start = courseInfo.getStart();
int end = courseInfo.getEnd();
int content = Integer.parseInt(map.get("week").toString());
if (content < start || content > end) {
return "一";
}
}
return map.get("name").toString();
}
@Override
public List<WeekCourse> getTimetableByStudent(Map<String, Object> condition) {
User user = studentMapper.getStudentById(condition.get("studentName").toString());
Map<String, Object> oldMap = new HashMap<>();
oldMap.put("profession", user.getProfession());
oldMap.put("grade", user.getGrade());
oldMap.put("year", condition.get("year"));
oldMap.put("term", condition.get("term"));
oldMap.put("week", condition.get("week"));
List<WeekCourse> list = weekCourseMapper.getWeekCourse(oldMap);
dealMethod(list, oldMap);
return list;
}
@Override
public List<WeekCourse> getTimetableByTeacher(Map<String, Object> condition) {
// Deprecated Function
int num = timetableMapper.checkCount(condition);
List<WeekCourse> weekCourseList = new ArrayList<>();
if (num == 0) {
// 空课程表
for (int i = 1; i < 11; i++) {
WeekCourse week = new WeekCourse();
weekCourseList.add(week);
}
} else {
weekCourseList = weekCourseMapper.getWeekCourse(condition);
dealMethod(weekCourseList, condition);
}
// 获取教师负责的专业、班级、课程
List<TeacherCourse> teacherCourseList = teacherCourseMapper.getCourseListById(condition.get("teacherId").toString());
List<WeekCourse> newList = new ArrayList<>();
// 将新课程的每一项设为"一"
for (int i = 1; i < 11; i++) {
WeekCourse week = new WeekCourse();
dealWeek(week);
newList.add(week);
}
if(num == 0) {
return newList;
}
for (TeacherCourse teacherCourse : teacherCourseList) {
for (int i = 0; i < weekCourseList.size(); i++) {
WeekCourse weekCourse = dealWeekCourse(newList.get(i), weekCourseList.get(i), teacherCourse.getName());
newList.set(i, weekCourse);
}
}
return newList;
// 获取教师负责的专业、班级、课程
// List<TeacherCourse> list = teacherCourseMapper.getCourseListById(condition.get("teacherId").toString());
// List<WeekCourse> newList = new ArrayList<>();
// // 将新课程的每一项设为"一"
// for (int i = 1; i < 11; i++) {
// WeekCourse week = new WeekCourse();
// dealWeek(week);
// newList.add(week);
// }
// for (TeacherCourse teacherCourse : list) {
// Map<String, Object> map = new HashMap<>();
// map.put("profession", teacherCourse.getProfession());
// // 计算年份
// Calendar calendar = Calendar.getInstance();
// int month = calendar.get(Calendar.MONTH) + 1;
// int year = calendar.get(Calendar.YEAR);
// if(month > 9) {
// year += 1;
// }
// map.put("year", year);
// map.put("grade", teacherCourse.getGrade());
// map.put("term", teacherCourse.getTerm());
// map.put("week", condition.get("week"));
// // 根据专业班级获取课程表
// List<WeekCourse> weekCourseList = weekCourseMapper.getWeekCourse(map);
// dealMethod(weekCourseList, map);
// for (int i = 0; i < weekCourseList.size(); i++) {
// WeekCourse weekCourse = dealWeekCourse(newList.get(i), weekCourseList.get(i), teacherCourse.getName());
// newList.set(i, weekCourse);
// }
// }
// return newList;
}
@Override
public void updateCourseInfo(CourseInfo courseInfo) {
courseInfoMapper.updateCourseInfo(courseInfo);
}
private WeekCourse dealWeekCourse(WeekCourse newWeek, WeekCourse oldWeek, String name) {
// 当课程表的课程等于教师负责的课程时存入新的课程表newWeek
if (oldWeek.getMonday().equals(name)) {
newWeek.setMonday(oldWeek.getMonday());
}
if (oldWeek.getTuesday().equals(name)) {
newWeek.setTuesday(oldWeek.getTuesday());
}
if (oldWeek.getWednesday().equals(name)) {
newWeek.setWednesday(oldWeek.getWednesday());
}
if (oldWeek.getThursday().equals(name)) {
newWeek.setThursday(oldWeek.getThursday());
}
if (oldWeek.getFriday().equals(name)) {
newWeek.setFriday(oldWeek.getFriday());
}
if (oldWeek.getSaturday().equals(name)) {
newWeek.setSaturday(oldWeek.getSaturday());
}
if (oldWeek.getSunday().equals(name)) {
newWeek.setSunday(oldWeek.getSunday());
}
return newWeek;
}
}

@ -0,0 +1,29 @@
package com.cow.horse.service.Upload;
import com.cow.horse.domain.Upload;
import java.util.Map;
/**
* Description service
* Author: cow.horse
* Date: 2020/4/29 13:54
**/
public interface UploadService {
/**
* description:
* @param: upload
* return: void
* Author: cow.horse
* @Date: 2022/4/29 11:40
*/
void upload(Upload upload);
/**
* description:
* @param: condition
* return: String
* Author: cow.horse
* @Date: 2022/4/29 14:02
*/
String getHeader(Map<String, Object> condition);
}

@ -0,0 +1,53 @@
package com.cow.horse.service.Upload.impl;
import com.alibaba.druid.support.logging.Log;
import com.alibaba.druid.support.logging.LogFactory;
import com.cow.horse.dao.Upload.UploadMapper;
import com.cow.horse.domain.Upload;
import com.cow.horse.service.Upload.UploadService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
/**
* Description
* Author: cow.horse
* Date: 2020/4/29 13:55
**/
@Service
public class UploadServiceImpl implements UploadService {
private final Log logger = LogFactory.getLog(UploadServiceImpl.class);
@Resource
private UploadMapper uploadMapper;
@Override
public void upload(Upload upload) {
Map<String, Object> condition = new HashMap<>();
condition.put("userId", upload.getUserId());
condition.put("level", upload.getLevel());
String oldUrl = uploadMapper.getHead(condition);
if (oldUrl == null) {
uploadMapper.add(upload);
} else {
File file = new File(oldUrl);
//文件是否存在
if (file.exists()) {
if (file.delete()) {
logger.info("删除文件成功");
}
}
uploadMapper.update(upload);
}
}
@Override
public String getHeader(Map<String, Object> condition) {
String imgUrl = uploadMapper.getHead(condition);
return imgUrl == null ? "" : imgUrl.substring(imgUrl.indexOf("/"));
}
}

@ -0,0 +1,54 @@
package com.cow.horse.service.User;
import com.cow.horse.dto.User;
import com.cow.horse.utils.PagingResult;
import org.apache.ibatis.session.RowBounds;
import java.util.List;
import java.util.Map;
/**
* Description Service
* Author: cow.horse
* Date: 2020/3/28 11:05
**/
public interface AdminService {
/**
* description:
* @param user
* @return void
* @author cow.horse
* @date 2020/3/4 23:05
*/
void add(User user);
/**
* description:
*
* @param ids
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void delete(List<Integer> ids);
/**
* description:
*
* @param user
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void update(User user);
/**
* description:
* @param rowBounds
* @param condition
* @author cow.horse
* @return com.jw.zjh.sms.utils.PagingResult
* @date 2020/3/4 23:05
*/
PagingResult<User> getAdminList(RowBounds rowBounds, Map<String, Object> condition);
}

@ -0,0 +1,54 @@
package com.cow.horse.service.User;
import com.cow.horse.dto.User;
import com.cow.horse.utils.PagingResult;
import org.apache.ibatis.session.RowBounds;
import java.util.List;
import java.util.Map;
/**
* Description
* Author: cow.horse
* Date: 2020/3/7 15:04
**/
public interface StudentService {
/**
* description:
* @param user
* @return void
* @author cow.horse
* @date 2020/3/4 23:05
*/
void addStudent(User user);
/**
* description:
*
* @param ids
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void delete(List<String> ids);
/**
* description:
*
* @param user
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void update(User user);
/**
* description:
* @param rowBounds
* @param condition
* @author cow.horse
* @return com.jw.zjh.sms.utils.PagingResult
* @date 2020/3/4 23:05
*/
PagingResult<User> getStudentList(RowBounds rowBounds, Map<String, Object> condition);
}

@ -0,0 +1,54 @@
package com.cow.horse.service.User;
import com.cow.horse.dto.User;
import com.cow.horse.utils.PagingResult;
import org.apache.ibatis.session.RowBounds;
import java.util.List;
import java.util.Map;
/**
* Description
* Author: cow.horse
* Date: 2020/3/7 15:05
**/
public interface TeacherService {
/**
* description:
* @param user
* @return void
* @author cow.horse
* @date 2020/3/4 23:05
*/
void addTeacher(User user);
/**
* description:
*
* @param ids
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void delete(List<Integer> ids);
/**
* description:
*
* @param user
* @return void
* @author cow.horse
* @date 2019/8/29 14:55
*/
void update(User user);
/**
* description:
* @param rowBounds
* @param condition
* @author cow.horse
* @return com.jw.zjh.sms.utils.PagingResult
* @date 2020/3/4 23:05
*/
PagingResult<User> getTeacherList(RowBounds rowBounds, Map<String, Object> condition);
}

@ -0,0 +1,53 @@
package com.cow.horse.service.User;
import com.cow.horse.dto.User;
import java.util.List;
import java.util.Map;
/**
* Description
* Author: cow.horse
* Date2019/10/21 21:01
**/
public interface UserService {
/**
* description:
* @params: condition
* @return: com.zjh.student_mis.dto.User
* @Author: cow.horse
* @Date: 2021/10/21 21:05
*/
User getStudentInfo(Map<String, Object> condition);
/**
* description:
* @param condition
* @return void
* @author cow.horse
* @Date: 2022/3/4 23:05
*/
boolean update(Map<String, Object> condition);
/**
* description:
* return: List<Object>
* Author: cow.horse
* @Date: 2022/3/27 22:13
*/
List<Object> getTree();
/**
* description: token
* @param: User
* return: String
* Author: cow.horse
* @Date: 2022/3/30 23:21
*/
String getToken(User user, long time);
/**
* description: id
* @param: condition
* return: User
* Author: cow.horse
* @Date: 2022/3/30 23:42
*/
User findUser(Map<String, Object> condition);
}

@ -0,0 +1,52 @@
package com.cow.horse.service.User.impl;
import com.cow.horse.dao.User.AdminMapper;
import com.cow.horse.dto.User;
import com.cow.horse.service.User.AdminService;
import com.cow.horse.utils.PagingResult;
import com.github.pagehelper.PageRowBounds;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* Description
* Author: cow.horse
* Date: 2020/3/28 11:06
**/
@Service
public class AdminServiceImpl implements AdminService {
@Resource
private AdminMapper adminMapper;
@Override
public void add(User user) {
int num = adminMapper.checkCodeCount();
String username = "980502" + Integer.toString(num);
user.setUsername(username);
user.setPassword("password");
adminMapper.add(user);
}
@Override
public void
delete(List<Integer> ids) {
adminMapper.delete(ids);
}
@Override
public void update(User user) {
adminMapper.update(user);
}
@Override
public PagingResult<User> getAdminList(RowBounds rowBounds, Map<String, Object> condition) {
PageRowBounds pageRowBounds = new PageRowBounds(rowBounds.getOffset(), rowBounds.getLimit());
List<User> StudentInfoList = adminMapper.getAdminList(pageRowBounds, condition);
return new PagingResult<>(StudentInfoList, pageRowBounds.getTotal());
}
}

@ -0,0 +1,87 @@
package com.cow.horse.service.User.impl;
import com.cow.horse.dao.Profession.ProfessionMapper;
import com.cow.horse.dao.User.StudentMapper;
import com.cow.horse.domain.Profession;
import com.cow.horse.dto.User;
import com.cow.horse.service.User.StudentService;
import com.cow.horse.utils.PagingResult;
import com.github.pagehelper.PageRowBounds;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
/**
* Description
* Author: cow.horse
* Date: 2020/3/7 15:09
**/
@Service
public class StudentServiceImpl implements StudentService {
@Resource
private StudentMapper studentMapper;
@Autowired
private ProfessionMapper professionMapper;
@Override
@Transactional
public void addStudent(User user) {
int professionId = 0;
int count = professionMapper.checkProfessionCount(user.getProfession());
if (count > 0) {
Profession profession = professionMapper.getProfessionIdByName(user.getProfession());
professionId = profession.getId();
} else {
Profession profession = new Profession();
profession.setName(user.getProfession());
professionMapper.addProfession(profession);
professionId = profession.getId();
}
String professionStr = "";
if (professionId < 10) {
professionStr = "0" + Integer.toString(professionId);
} else {
professionStr = Integer.toString(professionId);
}
Map<String, Object> condition = new HashMap<>();
condition.put("profession", user.getProfession());
condition.put("grade", user.getGrade());
int num = studentMapper.checkCodeCount(condition) + 1;
String str = "";
if (num < 10) {
str = "0" + Integer.toString(num);
} else if (num < 100) {
str = Integer.toString(num);
}
String no = "3" + user.getAdmissionTime().substring(user.getAdmissionTime().length()-2)
+ "89" + professionStr + user.getGrade().substring(user.getGrade().length()-1) + str;
user.setId(no);
user.setUsername(no);
user.setPassword("123456");
studentMapper.addStudent(user);
}
@Override
public void
delete(List<String> ids) {
studentMapper.delete(ids);
}
@Override
public void update(User user) {
studentMapper.update(user);
}
@Override
public PagingResult<User> getStudentList(RowBounds rowBounds, Map<String, Object> condition) {
PageRowBounds pageRowBounds = new PageRowBounds(rowBounds.getOffset(), rowBounds.getLimit());
List<User> StudentInfoList = studentMapper.getStudentList(pageRowBounds, condition);
return new PagingResult<>(StudentInfoList, pageRowBounds.getTotal());
}
}

@ -0,0 +1,60 @@
package com.cow.horse.service.User.impl;
import com.cow.horse.dao.User.TeacherMapper;
import com.cow.horse.dto.User;
import com.cow.horse.service.User.TeacherService;
import com.cow.horse.utils.PagingResult;
import com.github.pagehelper.PageRowBounds;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* Description
* Author: cow.horse
* Date: 2020/3/7 15:10
**/
@Service
public class TeacherServiceImpl implements TeacherService {
@Resource
private TeacherMapper teacherMapper;
@Override
public void addTeacher(User user) {
int num = teacherMapper.checkCodeCount();
String str = "";
if (num < 10) {
str = "00" + Integer.toString(num);
} else if (num < 100) {
str = "0" + Integer.toString(num);
} else {
str = Integer.toString(num);
}
String no = "389"+str+user.getSex().toString();
user.setUsername(no);
user.setId(no);
user.setPassword("159357");
teacherMapper.addTeacher(user);
}
@Override
public void delete(List<Integer> ids) {
teacherMapper.delete(ids);
}
@Override
public void update(User user) {
teacherMapper.update(user);
}
@Override
public PagingResult<User> getTeacherList(RowBounds rowBounds, Map<String, Object> condition) {
PageRowBounds pageRowBounds = new PageRowBounds(rowBounds.getOffset(), rowBounds.getLimit());
List<User> TeacherInfoList = teacherMapper.getTeacherList(pageRowBounds, condition);
return new PagingResult<>(TeacherInfoList, pageRowBounds.getTotal());
}
}

@ -0,0 +1,143 @@
package com.cow.horse.service.User.impl;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTCreator;
import com.auth0.jwt.algorithms.Algorithm;
import com.cow.horse.dao.User.AdminMapper;
import com.cow.horse.dao.User.StudentMapper;
import com.cow.horse.dao.User.TeacherMapper;
import com.cow.horse.dao.User.UserMapper;
import com.cow.horse.dto.User;
import com.cow.horse.service.User.UserService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
/**
* Description
* Author: cow.horse
* Date2019/10/21 21:09
**/
@Service
public class UserServiceImpl implements UserService {
@Resource
private UserMapper userMapper;
@Resource
private StudentMapper studentMapper;
@Resource
private TeacherMapper teacherMapper;
@Resource
private AdminMapper adminMapper;
@Override
public User getStudentInfo(Map<String, Object> condition) {
String keyValue = condition.get("level").toString();
if (keyValue.equals("0")) {
return userMapper.getAdminInfo(condition);
} else if (keyValue.equals("1")) {
return userMapper.getTeacherInfo(condition);
} else {
return userMapper.getStudentInfo(condition);
}
}
@Override
public boolean update(Map<String, Object> condition) {
switch (condition.get("level").toString()) {
case "0":
condition.put("table", "admin");
break;
case "1":
condition.put("table", "teacher");
break;
case "2":
condition.put("table", "student");
break;
}
Integer num = userMapper.checkPasswordCount(condition);
if (num != 0) {
userMapper.update(condition);
}
return num != 0;
}
@Override
public List<Object> getTree() {
// 获取专业
List<User> studentList = studentMapper.getStudentTree();
Set<User> studentSet = new HashSet<>(studentList);
List<Map<String, Object>> professionList = new ArrayList<>();
// 转化为前端树形结构所需的数据格式
Set<String> proSet = studentList.stream().map(User::getProfession).collect(Collectors.toSet());
for (String profession : proSet) {
Map<String, Object> stuProfessionTreeObj = new HashMap<>();
stuProfessionTreeObj.put("label", profession);
List<String> gradeList = studentMapper.getGradeByProfession(profession);
gradeList = new HashSet<>(gradeList).stream().sorted(Comparator.comparing(Integer::new)).collect(Collectors.toList());
// 转成int然后再排序
List<Map<String, Object>> gradeTreeList = new ArrayList<>();
for (String grade : gradeList) {
Map<String, Object> gradeTreeMap = new HashMap<>();
gradeTreeMap.put("label", grade);
gradeTreeList.add(gradeTreeMap);
}
stuProfessionTreeObj.put("children", gradeTreeList);
professionList.add(stuProfessionTreeObj);
}
ArrayList<Object> treeList = new ArrayList<>();
Map<String, Object> studentObj = new HashMap<>();
Map<String, Object> teacherObj = new HashMap<>();
Map<String, Object> adminObj = new HashMap<>();
studentObj.put("label", "学生");
studentObj.put("children", professionList);
teacherObj.put("label", "教师");
adminObj.put("label", "管理员");
treeList.add(studentObj);
treeList.add(teacherObj);
treeList.add(adminObj);
return treeList;
}
@Override
public String getToken(User user, long time) {
if (user == null) {
return "";
}
Date start = new Date();
long currentTime = System.currentTimeMillis() + time;//一小时有效时间
Date end = new Date(currentTime);
String token = "";
JWTCreator.Builder builder = JWT.create().withAudience(user.getLevel().toString() + user.getId());
token = builder.withIssuedAt(start).withExpiresAt(end)
// 储存id和level
.sign(Algorithm.HMAC256(user.getPassword())); // 储存password用于解密
return token;
}
@Override
public User findUser(Map<String, Object> condition) {
String id = condition.get("id").toString();
String level = condition.get("level").toString();
User user = new User();
switch (level) {
case "0":
user = adminMapper.getUserById(id);
break;
case "1":
user = teacherMapper.getUserById(id);
break;
case "2":
user = studentMapper.getUserById(id);
break;
}
return user;
}
}

@ -0,0 +1,130 @@
package com.cow.horse.utils; // 声明该类所在的包,用于组织代码结构,这里是工具类相关的包
import com.alibaba.druid.support.logging.Log; // 导入阿里巴巴Druid库的日志支持类用于获取日志记录器
import com.alibaba.druid.support.logging.LogFactory; // 导入获取日志记录器的工厂类
import com.auth0.jwt.JWT; // 导入Auth0的JWT类用于处理JSON Web Token
import com.auth0.jwt.JWTVerifier; // 导入Auth0的JWT验证器类用于验证Token
import com.auth0.jwt.algorithms.Algorithm; // 导入Auth0的JWT算法类用于指定加密算法
import com.auth0.jwt.exceptions.JWTDecodeException; // 导入JWT解码异常类用于捕获解码Token时的异常
import com.auth0.jwt.exceptions.JWTVerificationException; // 导入JWT验证异常类用于捕获验证Token时的异常
import com.cow.horse.dto.User; // 导入自定义的用户数据传输对象类,用于在不同层之间传输用户相关数据
import com.cow.horse.service.Upload.impl.UploadServiceImpl; // 导入上传服务实现类,这里用于获取日志记录相关的类(获取日志记录器时用到)
import com.cow.horse.service.User.UserService; // 导入用户服务类,用于处理用户相关业务逻辑
import lombok.extern.slf4j.Slf4j; // 导入Lombok的Slf4j注解用于简化日志记录代码
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring框架的依赖注入注解用于实现依赖注入
import org.springframework.web.method.HandlerMethod; // 导入Spring框架的处理方法类用于处理控制器方法相关操作
import org.springframework.web.servlet.HandlerInterceptor; // 导入Spring框架的拦截器接口用于实现自定义拦截器
import org.springframework.web.servlet.ModelAndView; // 导入Spring框架的模型和视图类用于处理视图和模型数据
import javax.servlet.http.HttpServletRequest; // 导入用于处理HTTP请求的类
import javax.servlet.http.HttpServletResponse; // 导入用于处理HTTP响应的类
import java.lang.reflect.Method; // 导入用于反射操作的类,用于获取方法信息
import java.util.*; // 导入Java的util包提供常用工具类和集合类
/**
* Description tokentoken
* Author: cow.horse
* Date: 2020/3/30 23:25
**/
@Slf4j // 使用Slf4j注解自动生成日志记录器对象log
public class AuthenticationInterceptor implements HandlerInterceptor {
private final Log logger = LogFactory.getLog(UploadServiceImpl.class); // 获取日志记录器指定记录UploadServiceImpl类相关的日志
@Autowired // 使用Spring的依赖注入将UserService的实例注入到当前拦截器类中
UserService userService;
@Override // 重写HandlerInterceptor接口的preHandle方法在请求处理之前调用
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object object) throws Exception {
if (httpServletRequest.getMethod().toUpperCase().equals("OPTIONS")) { // 判断请求方法是否为OPTIONSHTTP的一种请求方法常用于预检
return true; // 如果是OPTIONS方法直接返回true允许请求通过因为OPTIONS请求一般用于检查服务器的能力
}
String token = httpServletRequest.getHeader("Authorization"); // 从HTTP请求头中获取名为"Authorization"的字段值即Token通常用于身份验证
String refreshToken = httpServletRequest.getHeader("freshToken"); // 从HTTP请求头中获取名为"freshToken"的字段值即刷新Token用于在Token过期时获取新的Token
Enumeration<String> headerNames = httpServletRequest.getHeaderNames(); // 获取HTTP请求头中所有字段名称的枚举对象
while (headerNames.hasMoreElements()) { // 遍历所有请求头字段名称
String name = headerNames.nextElement(); // 获取下一个请求头字段名称
String value = httpServletRequest.getHeader(name); // 根据字段名称获取对应的字段值
System.out.println(name + "----" + value); // 打印请求头字段名称和对应的值,可能用于调试查看请求头信息
}
if (!(object instanceof HandlerMethod)) { // 判断被调用的目标对象是否不是HandlerMethod类型即不是一个控制器方法
return true; // 如果不是直接返回true允许请求通过因为不是方法的请求可能不需要进行权限验证等操作
}
HandlerMethod handlerMethod = (HandlerMethod) object; // 将目标对象转换为HandlerMethod类型以便获取方法相关信息
Method method = handlerMethod.getMethod(); // 获取HandlerMethod中的具体方法对象
if (method.isAnnotationPresent(PassToken.class)) { // 检查方法上是否存在PassToken注解自定义注解可能用于标记不需要Token验证的方法
PassToken passToken = method.getAnnotation(PassToken.class); // 获取PassToken注解的实例
if (passToken.required()) { // 判断PassToken注解的required属性是否为true
return true; // 如果为true直接返回true允许请求通过即跳过Token验证
}
}
if (token == null) { // 判断获取到的Token是否为null
throw new RuntimeException("登录信息过期"); // 如果为null抛出运行时异常提示登录信息过期因为没有有效的Token
}
String userValue = null;
try {
userValue = JWT.decode(token).getAudience().get(0); // 解码Token并获取其中的受众信息中的第一个元素假设包含用户相关信息
} catch (JWTDecodeException j) { // 捕获JWT解码异常
throw new RuntimeException("401"); // 如果解码异常抛出运行时异常返回401状态码相关的错误提示
}
Map<String, Object> map = new HashMap<>(); // 创建一个HashMap对象用于存储从Token中解析出的用户相关信息
map.put("level", (userValue).substring(0, 1)); // 从userValue中截取第一个字符作为用户级别存入map中
map.put("id", (userValue).substring(1)); // 从userValue中截取除第一个字符外的其他字符作为用户ID存入map中
User user = userService.findUser(map); // 调用UserService的findUser方法根据map中的用户信息查找用户对象
if (user == null) { // 判断查找到的用户对象是否为null
throw new RuntimeException("用户不存在,请重新登录"); // 如果为null抛出运行时异常提示用户不存在需要重新登录
}
Date oldTime = JWT.decode(token).getExpiresAt(); // 解码Token获取其过期时间
Date refreshTime = JWT.decode(refreshToken).getExpiresAt(); // 解码刷新Token获取其过期时间
long oldDiff = oldTime.getTime() - new Date().getTime(); // 计算Token的过期时间与当前时间的差值以毫秒为单位
long refreshDiff = refreshTime.getTime() - new Date().getTime(); // 计算刷新Token的过期时间与当前时间的差值以毫秒为单位
if (oldDiff <= 0) { // 判断Token是否已过期剩余有效时间小于等于0
if (refreshDiff <= 0) { // 判断刷新Token是否也已过期剩余有效时间小于等于0
logger.error("=== token 已过期, 请重新登录 ==="); // 记录错误日志提示Token已过期需要重新登录
httpServletResponse.sendError(401); // 设置HTTP响应状态码为401未授权表示用户需要重新认证
return false; // 返回false拦截请求不允许继续处理
}
}
String newToken = userService.getToken(user, 60 * 60 * 1000); // 调用UserService的getToken方法生成新的Token有效期为1小时60 * 60 * 1000毫秒
String newRefToken = userService.getToken(user, 24 * 60 * 60 * 1000); // 调用UserService的getToken方法生成新的刷新Token有效期为24小时24 * 60 * 60 * 1000毫秒
httpServletResponse.setHeader("Authorization", newToken); // 在HTTP响应头中设置新的Token
httpServletResponse.setHeader("freshToken", newRefToken); // 在HTTP响应头中设置新的刷新Token
if (token == null) { // 判断Token是否为null这部分代码逻辑和上面有重复可能是需要进一步整理优化
throw new RuntimeException("=== 无token请重新登录 ==="); // 如果为null抛出运行时异常提示没有Token需要重新登录
}
JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(user.getPassword())).build(); // 创建JWT验证器使用HMAC256算法和用户密码进行验证
try {
jwtVerifier.verify(token); // 使用JWT验证器验证Token的有效性
} catch (JWTVerificationException e) { // 捕获JWT验证异常
logger.error("=== token验证失败 ==="); // 记录错误日志提示Token验证失败
httpServletResponse.sendError(401); // 设置HTTP响应状态码为401未授权
return false; // 返回false拦截请求不允许继续处理
}
return true; // 返回true允许请求继续处理即通过Token验证
}
@Override // 重写HandlerInterceptor接口的postHandle方法在请求处理之后视图渲染之前调用
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
// 该方法目前为空,可根据需求添加在请求处理之后、视图渲染之前的处理逻辑,例如修改模型数据或视图相关的操作
}
@Override // 重写HandlerInterceptor接口的afterCompletion方法在整个请求处理完成后调用包括视图渲染完成后
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
// 该方法目前为空,可根据需求添加在请求处理完成后的处理逻辑,例如记录日志、清理资源等操作
}
}

@ -0,0 +1,35 @@
package com.cow.horse.utils; // 声明包名,将该类归类到 com.cow.horse.utils 包下,方便代码管理和组织
import com.fasterxml.jackson.annotation.JsonInclude; // 导入 Jackson 库的 JsonInclude 注解,用于控制对象序列化时对属性的包含策略
import java.util.Collections; // 导入 Java 集合框架中的 Collections 工具类,它提供了一系列对集合进行操作的静态方法
import java.util.Iterator; // 导入 Java 集合框架中的 Iterator 接口,用于实现对集合元素的迭代遍历
import java.util.List; // 导入 Java 集合框架中的 List 接口,用于表示有序的、可重复的对象集合
/**
* @author cow.horse
* @date 2019/4/23 16:41
* @description:
*/
@JsonInclude(JsonInclude.Include.NON_NULL) // 该注解指定在将对象序列化为 JSON 时,只包含非空的属性,忽略值为 null 的属性
public class PagingResult<T> implements Iterable<T> { // 定义一个泛型类 PagingResult它实现了 Iterable 接口,意味着该类的对象可以使用 for-each 循环遍历
private static final long serialVersionUID = 1L; // 定义一个静态常量 serialVersionUID用于在序列化和反序列化过程中确保版本的兼容性
private long totalCount; // 定义一个私有成员变量 totalCount用于存储分页数据的总记录数
private List<T> items = Collections.emptyList(); // 定义一个私有成员变量 items它是一个泛型 List初始化为空列表用于存储当前页的数据项
public PagingResult(List<T> items, long totalCount) { // 定义类的构造函数,接收一个泛型 List 和一个 long 类型的参数,用于初始化对象
this.totalCount = totalCount; // 将传入的总记录数赋值给类的 totalCount 成员变量
this.items = items; // 将传入的当前页数据项列表赋值给类的 items 成员变量
}
public long getTotalCount() { // 定义一个公共的获取方法,用于获取分页数据的总记录数
return totalCount; // 返回类的 totalCount 成员变量的值
}
public List<T> getItems() { // 定义一个公共的获取方法,用于获取当前页的数据项列表
return items; // 返回类的 items 成员变量的值
}
@Override // 重写 Iterable 接口中的 iterator 方法
public Iterator<T> iterator() { // 该方法返回一个用于遍历 items 列表的迭代器
return this.items.iterator(); // 调用 items 列表的 iterator 方法,返回一个迭代器实例
}
}

@ -0,0 +1,16 @@
package com.cow.horse.utils; // 声明该注解类所在的包,方便对代码进行组织和管理
import java.lang.annotation.ElementType; // 导入用于指定注解可以应用的目标类型的类
import java.lang.annotation.Retention; // 导入用于指定注解的保留策略的类
import java.lang.annotation.RetentionPolicy; // 导入定义注解保留策略的枚举类
import java.lang.annotation.Target; // 导入用于指定注解应用目标的注解类
/**
* Description PassToken
* Author: cow.horse
* Date: 2020/3/30 23:31
**/
@Target({ElementType.METHOD, ElementType.TYPE}) // 此注解指定了 PassToken 注解可以应用的目标类型METHOD 表示可用于方法TYPE 表示可用于类、接口等类型
@Retention(RetentionPolicy.RUNTIME) // 此注解指定了 PassToken 注解的保留策略为运行时,即在运行时可以通过反射机制获取该注解信息
public @interface PassToken { // 定义一个名为 PassToken 的注解
boolean required() default true; // 定义一个名为 required 的注解属性,类型为布尔型,默认值为 true该属性可用于指定是否需要跳过验证
}

@ -0,0 +1,28 @@
package com.cow.horse.utils; // 声明该类所在的包,用于组织代码结构,这里属于工具类相关的包
import java.io.File; // 导入Java的File类用于操作文件和目录
public class ResourceUtil { // 定义一个名为ResourceUtil的公共类通常用于提供资源相关的工具方法
public static String getPath() { // 定义一个公共的静态方法getPath用于获取资源路径
String staticDir; // 声明一个字符串变量staticDir用于存储资源目录的路径
String os = System.getProperty("os.name"); // 获取当前操作系统的名称
if (os.toLowerCase().startsWith("win")) { // 判断当前操作系统是否为Windows系统
staticDir = System.getProperty("user.dir") + "\\src\\main\\resources\\static\\files\\"; // 如果是Windows系统将项目根目录与指定的相对路径拼接成资源目录路径
// 如果结果目录不存在,则创建目录
File resDirFile = new File(staticDir); // 创建一个File对象代表资源目录
if (!resDirFile.exists()) { // 检查该目录是否存在
boolean flag = resDirFile.mkdirs(); // 如果目录不存在,则尝试创建该目录及其所有父目录
if (!flag) throw new RuntimeException("创建结果目录失败"); // 如果创建目录失败,抛出运行时异常
}
} else {
//linux系统
staticDir = "/usr/local/my_project/files/"; // 如果是Linux系统直接指定资源目录路径
// 如果结果目录不存在,则创建目录
File resDirFile = new File(staticDir); // 创建一个File对象代表资源目录
if (!resDirFile.exists()) { // 检查该目录是否存在
boolean flag = resDirFile.mkdirs(); // 如果目录不存在,则尝试创建该目录及其所有父目录
if (!flag) throw new RuntimeException("创建结果目录失败"); // 如果创建目录失败,抛出运行时异常
}
}
return staticDir; // 返回最终确定的资源目录路径
}
}

@ -0,0 +1,16 @@
package com.cow.horse.utils; // 声明该注解类所在的包,便于代码组织与管理
import java.lang.annotation.ElementType; // 导入用于指定注解可应用目标类型的类
import java.lang.annotation.Retention; // 导入用于指定注解保留策略的类
import java.lang.annotation.RetentionPolicy; // 导入定义注解保留策略的枚举类
import java.lang.annotation.Target; // 导入用于指定注解应用目标的注解类
/**
* Description UserLoginToken
* Author: cow.horse
* Date: 2020/3/30 23:32
**/
@Target({ElementType.METHOD, ElementType.TYPE}) // 此注解指定了 UserLoginToken 注解可应用的目标类型METHOD 表示可用于方法TYPE 表示可用于类、接口等类型
@Retention(RetentionPolicy.RUNTIME) // 此注解指定了 UserLoginToken 注解的保留策略为运行时,即运行时可通过反射机制获取该注解信息
public @interface UserLoginToken { // 定义一个名为 UserLoginToken 的注解
boolean required() default true; // 定义一个名为 required 的注解属性,类型为布尔型,默认值为 true该属性用于指定是否需要用户登录才能进行操作
}

@ -0,0 +1,11 @@
server.port=9121
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/student_manager_system?characterEncoding=utf8&allowPublicKeyRetrieval=true&useSSL=false
jdbc.username=root
jdbc.password=root123
mybatis_config_file=mybatis-config.xml
mapper_path=/mapper/*/**.xml
entity_package=com.cow.horse.dto

@ -0,0 +1,168 @@
<?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.cow.horse.dao.Course.CourseMapper">
<!-- 定义一个结果映射,将数据库查询结果映射到 com.cow.horse.dto.Course 类型的对象 -->
<!-- id="BaseUserMap" 是结果映射的唯一标识 -->
<!-- type="com.cow.horse.dto.Course" 指定了映射的目标对象类型 -->
<resultMap id="BaseUserMap" type="com.cow.horse.dto.Course">
<result column="id" property="id" jdbcType="VARCHAR" /> <!-- 将数据库列 id 映射到对象的 id 属性,指定 JDBC 类型为 VARCHAR -->
<result column="name" property="name" jdbcType="VARCHAR" /> <!-- 将数据库列 name 映射到对象的 name 属性,指定 JDBC 类型为 VARCHAR -->
<result column="credits" property="credits" jdbcType="DECIMAL" /> <!-- 将数据库列 credits 映射到对象的 credits 属性,指定 JDBC 类型为 DECIMAL -->
<result column="number" property="number" jdbcType="INTEGER" /> <!-- 将数据库列 number 映射到对象的 number 属性,指定 JDBC 类型为 INTEGER -->
<result column="score" property="score" jdbcType="INTEGER" /> <!-- 将数据库列 score 映射到对象的 score 属性,指定 JDBC 类型为 INTEGER -->
<result column="year" property="year" jdbcType="INTEGER" /> <!-- 将数据库列 year 映射到对象的 year 属性,指定 JDBC 类型为 INTEGER -->
<result column="term" property="term" jdbcType="INTEGER" /> <!-- 将数据库列 term 映射到对象的 term 属性,指定 JDBC 类型为 INTEGER -->
<result column="type" property="type" jdbcType="INTEGER" /> <!-- 将数据库列 type 映射到对象的 type 属性,指定 JDBC 类型为 INTEGER -->
<result column="profession" property="profession" jdbcType="VARCHAR" /> <!-- 将数据库列 profession 映射到对象的 profession 属性,指定 JDBC 类型为 VARCHAR -->
<result column="start" property="start" jdbcType="INTEGER" /> <!-- 将数据库列 start 映射到对象的 start 属性,指定 JDBC 类型为 INTEGER -->
<result column="end" property="end" jdbcType="INTEGER" /> <!-- 将数据库列 end 映射到对象的 end 属性,指定 JDBC 类型为 INTEGER -->
<result column="room" property="room" jdbcType="VARCHAR" /> <!-- 将数据库列 room 映射到对象的 room 属性,指定 JDBC 类型为 VARCHAR -->
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" /> <!-- 将数据库列 create_time 映射到对象的 createTime 属性,指定 JDBC 类型为 TIMESTAMP -->
</resultMap>
<!-- 插入数据的 SQL 语句id="addCourse" 是该操作的唯一标识 -->
<!-- parameterType="com.cow.horse.dto.Course" 指定传入参数的类型为 com.cow.horse.dto.Course -->
<insert id="addCourse" parameterType="com.cow.horse.dto.Course">
INSERT INTO course
<!-- trim 标签用于去除多余的逗号等字符prefix="(" 表示添加前缀 "("suffix=")" 表示添加后缀 ")"suffixOverrides="," 表示去除后缀多余的逗号 -->
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">id,</if> <!-- 如果对象的 id 属性不为空且不为空字符串,则插入 id 列 -->
<if test="name != null and name != ''">`name`,</if> <!-- 如果对象的 name 属性不为空且不为空字符串,则插入 name 列 -->
<if test="number != null and number != ''">`number`,</if> <!-- 如果对象的 number 属性不为空且不为空字符串,则插入 number 列 -->
<if test="credits != null and credits != ''">`credits`,</if> <!-- 如果对象的 credits 属性不为空且不为空字符串,则插入 credits 列 -->
<if test="score != null and score != ''">`score`,</if> <!-- 如果对象的 score 属性不为空且不为空字符串,则插入 score 列 -->
<if test="year != null and year != ''">`year`,</if> <!-- 如果对象的 year 属性不为空且不为空字符串,则插入 year 列 -->
<if test="type != null and type != ''">`type`,</if> <!-- 如果对象的 type 属性不为空且不为空字符串,则插入 type 列 -->
<if test="term != null and term != ''">term,</if> <!-- 如果对象的 term 属性不为空且不为空字符串,则插入 term 列 -->
<if test="profession != null and profession != ''">profession,</if> <!-- 如果对象的 profession 属性不为空且不为空字符串,则插入 profession 列 -->
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">#{id},</if> <!-- 如果对象的 id 属性不为空且不为空字符串,则插入对应的 id 值 -->
<if test="name != null and name != ''">#{name},</if> <!-- 如果对象的 name 属性不为空且不为空字符串,则插入对应的 name 值 -->
<if test="number != null and number != ''">#{number},</if> <!-- 如果对象的 number 属性不为空且不为空字符串,则插入对应的 number 值 -->
<if test="credits != null and credits != ''">#{credits},</if> <!-- 如果对象的 credits 属性不为空且不为空字符串,则插入对应的 credits 值 -->
<if test="score != null and score != ''">#{score},</if> <!-- 如果对象的 score 属性不为空且不为空字符串,则插入对应的 score 值 -->
<if test="year != null and year != ''">#{year},</if> <!-- 如果对象的 year 属性不为空且不为空字符串,则插入对应的 year 值 -->
<if test="type != null and type != ''">#{type},</if> <!-- 如果对象的 type 属性不为空且不为空字符串,则插入对应的 type 值 -->
<if test="term != null and term != ''">#{term},</if> <!-- 如果对象的 term 属性不为空且不为空字符串,则插入对应的 term 值 -->
<if test="profession != null and profession != ''">#{profession},</if> <!-- 如果对象的 profession 属性不为空且不为空字符串,则插入对应的 profession 值 -->
</trim>
</insert>
<!-- 删除数据的 SQL 语句id="delete" 是该操作的唯一标识 -->
<!-- parameterType="map" 指定传入参数的类型为 Map -->
<delete id="delete" parameterType="map">
DELETE FROM
course
<!-- where 标签用于动态生成 WHERE 子句 -->
<where>
id IN
<!-- foreach 标签用于遍历集合collection="ids" 指定集合名称item="id" 指定集合中元素的变量名open="(" 表示开始括号separator="," 表示元素之间的分隔符close=")" 表示结束括号 -->
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</where>
</delete>
<!-- 更新数据的 SQL 语句id="update" 是该操作的唯一标识 -->
<!-- parameterType="com.cow.horse.dto.User" 指定传入参数的类型为 com.cow.horse.dto.User -->
<update id="update" parameterType="com.cow.horse.dto.User">
UPDATE course
<!-- trim 标签用于去除多余的逗号等字符prefix="set" 表示添加前缀 "set"suffixOverrides="," 表示去除后缀多余的逗号 -->
<trim prefix="set" suffixOverrides=",">
<if test="name != null and name != ''">
`name` = #{name}, <!-- 如果对象的 name 属性不为空且不为空字符串,则更新 name 列 -->
</if>
<if test="number != null and number != ''">
`number` = #{number}, <!-- 如果对象的 number 属性不为空且不为空字符串,则更新 number 列 -->
</if>
<if test="credits != null and credits != ''">
credits = #{credits}, <!-- 如果对象的 credits 属性不为空且不为空字符串,则更新 credits 列 -->
</if>
<if test="score != null and score != ''">
score = #{score}, <!-- 如果对象的 score 属性不为空且不为空字符串,则更新 score 列 -->
</if>
<if test="year != null and year != ''">
`year`= #{year}, <!-- 如果对象的 year 属性不为空且不为空字符串,则更新 year 列 -->
</if>
<if test="type != null and type != ''">
`type` = #{type}, <!-- 如果对象的 type 属性不为空且不为空字符串,则更新 type 列 -->
</if>
<if test="term != null and term != ''">
term = #{term}, <!-- 如果对象的 term 属性不为空且不为空字符串,则更新 term 列 -->
</if>
<if test="profession != null and profession != ''">
profession = #{profession}, <!-- 如果对象的 profession 属性不为空且不为空字符串,则更新 profession 列 -->
</if>
</trim>
<where>
<if test="id != null and id != ''">
id = #{id} <!-- 如果对象的 id 属性不为空且不为空字符串,则作为更新的条件 -->
</if>
</where>
</update>
<!-- 查询数据的 SQL 语句id="getCourseList" 是该操作的唯一标识 -->
<!-- resultMap="BaseUserMap" 指定使用之前定义的结果映射parameterType="map" 指定传入参数的类型为 Map -->
<select id="getCourseList" resultMap="BaseUserMap" parameterType="map">
SELECT
*
FROM course
<where>
<if test="condition.code != null and condition.code != ''">
name LIKE CONCAT('%',#{condition.code},'%') OR profession LIKE CONCAT('%',#{condition.code},'%') <!-- 如果传入参数中 condition.code 不为空且不为空字符串,则根据 name 或 profession 进行模糊查询 -->
</if>
</where>
ORDER BY create_time desc <!-- 按照 create_time 字段降序排列结果 -->
</select>
<!-- 查询数据的 SQL 语句id="checkCodeCount" 是该操作的唯一标识 -->
<!-- resultType="string" 指定查询结果的类型为字符串 -->
<select id="checkCodeCount" resultType="string">
select MAX(id) from course
<where>
<if test="condition.profession != null and condition.profession != ''">
profession = #{condition.profession} <!-- 如果传入参数中 condition.profession 不为空且不为空字符串,则作为查询条件 -->
</if>
<if test="condition.year != null and condition.year != ''">
AND year = #{condition.year} <!-- 如果传入参数中 condition.year 不为空且不为空字符串,则作为查询条件 -->
</if>
</where>
</select>
<!-- 查询数据的 SQL 语句id="getCourseByMap" 是该操作的唯一标识 -->
<!-- resultMap="BaseUserMap" 指定使用之前定义的结果映射parameterType="map" 指定传入参数的类型为 Map -->
<select id="getCourseByMap" resultMap="BaseUserMap" parameterType="map">
SELECT
a.*,
c.real_name,
d.start,
d.end,
d.room
FROM course a
left join teacher_course b
on a.id = b.course_id
left join teacher c
on b.teacher_id = c.id
left join course_info d
on a.id = d.course_id
<where>
<if test="condition.profession != null and condition.profession != ''">
a.profession = #{condition.profession} <!-- 如果传入参数中 condition.profession 不为空且不为空字符串,则作为查询条件 -->
</if>
<if test="condition.term != null and condition.term != ''">
AND a.term = #{condition.term} <!-- 如果传入参数中 condition.term 不为空且不为空字符串,则作为查询条件 -->
</if>
<if test="condition.courseName != null and condition.courseName != ''">
AND a.name = #{condition.courseName} <!-- 如果传入参数中 condition.courseName 不为空且不为空字符串,则作为查询条件 -->
</if>
</where>
</select>
<!-- 查询数据的 SQL 语句id="getCourseById" 是该操作的唯一标识 -->
<!-- resultMap="BaseUserMap" 指定使用之前定义的结果映射parameterType="string" 指定传入参数的类型为字符串 -->
<select id="getCourseById" resultMap="BaseUserMap" parameterType="string">
SELECT
*
FROM course
<where>
id = #{courseId} <!-- 根据传入的 courseId 参数查询对应的课程记录 -->
</where>
</select>
</mapper>

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?> <!-- 声明 XML 文件的版本为 1.0,编码为 UTF-8 -->
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!-- 引入 MyBatis 的 DTD 定义,用于验证 Mapper XML 文件的结构 -->
<mapper namespace="com.cow.horse.dao.CourseInfo.CourseInfoMapper" > <!-- 定义 Mapper 标签namespace 指定了该 Mapper 的命名空间,与对应的接口关联 -->
<resultMap id="BaseUserMap" type="com.cow.horse.domain.CourseInfo" > <!-- 定义结果映射id 为结果映射的标识type 为映射的目标对象类型 -->
<result column="id" property="id" jdbcType="INTEGER" /> <!-- 将数据库列 id 映射到对象的 id 属性,指定 JDBC 类型为 INTEGER -->
<result column="course_id" property="courseId" jdbcType="VARCHAR" /> <!-- 将数据库列 course_id 映射到对象的 courseId 属性,指定 JDBC 类型为 VARCHAR -->
<result column="start" property="start" jdbcType="INTEGER" /> <!-- 将数据库列 start 映射到对象的 start 属性,指定 JDBC 类型为 INTEGER -->
<result column="end" property="end" jdbcType="INTEGER" /> <!-- 将数据库列 end 映射到对象的 end 属性,指定 JDBC 类型为 INTEGER -->
<result column="room" property="room" jdbcType="INTEGER" /> <!-- 将数据库列 room 映射到对象的 room 属性,指定 JDBC 类型为 INTEGER -->
<result column="profession" property="profession" jdbcType="VARCHAR" /> <!-- 将数据库列 profession 映射到对象的 profession 属性,指定 JDBC 类型为 VARCHAR -->
</resultMap>
<insert id="addCourseInfo" parameterType="com.cow.horse.domain.CourseInfo"> <!-- 定义插入操作id 为操作标识parameterType 为传入参数类型 -->
INSERT INTO course_info <!-- SQL 插入语句,指定插入的表为 course_info -->
<trim prefix="(" suffix=")" suffixOverrides=","> <!-- trim 标签用于处理 SQL 片段,添加前缀、后缀并去除多余逗号 -->
<if test="courseId != null and courseId != ''">course_id,</if> <!-- 如果传入对象的 courseId 属性不为空且非空字符串,添加 course_id 列到 SQL 中 -->
<if test="start != null and start != ''">`start`,</if> <!-- 如果传入对象的 start 属性不为空且非空字符串,添加 start 列到 SQL 中 -->
<if test="end != null and end != ''">`end`,</if> <!-- 如果传入对象的 end 属性不为空且非空字符串,添加 end 列到 SQL 中 -->
<if test="room != null and room != ''">room,</if> <!-- 如果传入对象的 room 属性不为空且非空字符串,添加 room 列到 SQL 中 -->
<if test="profession != null and profession != ''">profession,</if> <!-- 如果传入对象的 profession 属性不为空且非空字符串,添加 profession 列到 SQL 中 -->
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <!-- 处理插入值部分的 SQL 片段,添加前缀、后缀并去除多余逗号 -->
<if test="courseId != null and courseId != ''">#{courseId},</if> <!-- 如果传入对象的 courseId 属性不为空且非空字符串,添加对应的 courseId 值到 SQL 中 -->
<if test="start != null and start != ''">#{start},</if> <!-- 如果传入对象的 start 属性不为空且非空字符串,添加对应的 start 值到 SQL 中 -->
<if test="end != null and end != ''">#{end},</if> <!-- 如果传入对象的 end 属性不为空且非空字符串,添加对应的 end 值到 SQL 中 -->
<if test="room != null and room != ''">#{room},</if> <!-- 如果传入对象的 room 属性不为空且非空字符串,添加对应的 room 值到 SQL 中 -->
<if test="profession != null and profession != ''">#{profession},</if> <!-- 如果传入对象的 profession 属性不为空且非空字符串,添加对应的 profession 值到 SQL 中 -->
</trim>
</insert>
<update id="updateCourseInfo" parameterType="com.cow.horse.domain.CourseInfo"> <!-- 定义更新操作id 为操作标识parameterType 为传入参数类型 -->
UPDATE course_info <!-- SQL 更新语句,指定更新的表为 course_info -->
<trim prefix="set" suffixOverrides=","> <!-- trim 标签处理更新部分的 SQL 片段,添加 set 前缀并去除多余逗号 -->
<if test="start != null and start != ''"> <!-- 如果传入对象的 start 属性不为空且非空字符串 -->
`start` = #{start}, <!-- 更新 start 列的值为传入对象的 start 属性值 -->
</if>
<if test="end != null and end != ''"> <!-- 如果传入对象的 end 属性不为空且非空字符串 -->
`end` = #{end}, <!-- 更新 end 列的值为传入对象的 end 属性值 -->
</if>
<if test="room != null and room != ''"> <!-- 如果传入对象的 room 属性不为空且非空字符串 -->
room = #{room}, <!-- 更新 room 列的值为传入对象的 room 属性值 -->
</if>
<if test="profession != null and profession != ''"> <!-- 如果传入对象的 profession 属性不为空且非空字符串 -->
profession = #{profession}, <!-- 更新 profession 列的值为传入对象的 profession 属性值 -->
</if>
</trim>
<where> <!-- where 标签用于添加 SQL 的条件部分 -->
<if test="courseId != null and courseId != ''"> <!-- 如果传入对象的 courseId 属性不为空且非空字符串 -->
course_id = #{courseId} <!-- 添加条件course_id 等于传入对象的 courseId 属性值 -->
</if>
</where>
</update>
<delete id="deleteInfo" parameterType="string"> <!-- 定义删除操作id 为操作标识parameterType 为传入参数类型 -->
DELETE FROM <!-- SQL 删除语句,指定从 course_info 表删除数据 -->
course_info
<where> <!-- where 标签添加删除的条件 -->
course_id = #{id} <!-- 条件course_id 等于传入的字符串参数 id -->
</where>
</delete>
<select id="getInfo" resultType="com.cow.horse.domain.CourseInfo" parameterType="map"> <!-- 定义查询操作id 为操作标识resultType 为结果类型parameterType 为传入参数类型 -->
select <!-- SQL 查询语句的开始 -->
a.*
from <!-- 指定查询的表及别名 -->
course_info a
left join course b <!-- 左连接 course 表,别名为 b -->
on a.course_id = b.id <!-- 连接条件course_info 表的 course_id 列等于 course 表的 id 列 -->
<where> <!-- where 标签添加查询条件 -->
<if test="condition.profession != null and condition.profession != ''"> <!-- 如果传入 Map 参数中 condition.profession 不为空且非空字符串 -->
a.profession = #{condition.profession} <!-- 添加条件course_info 表的 profession 列等于传入的 condition.profession 值 -->
</if>
<if test="condition.name != null and condition.name != ''"> <!-- 如果传入 Map 参数中 condition.name 不为空且非空字符串 -->
AND b.name = #{condition.name} <!-- 添加条件course 表的 name 列等于传入的 condition.name 值 -->
</if>
</where>
</select>
</mapper>

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?> <!-- 声明 XML 文件的版本为 1.0,编码方式为 UTF-8 -->
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!-- 引入 MyBatis 的 DTD 定义,用于验证 Mapper XML 文件的结构 -->
<mapper namespace="com.cow.horse.dao.Profession.ProfessionMapper"> <!-- 定义 Mapper 标签namespace 指定了该 Mapper 的命名空间,用于与对应的 Mapper 接口关联 -->
<resultMap id="BaseUserMap" type="com.cow.horse.domain.Profession"> <!-- 定义一个结果映射id 为结果映射的唯一标识type 指定了映射的目标对象类型为 com.cow.horse.domain.Profession -->
<result column="id" property="id" jdbcType="INTEGER" /> <!-- 将数据库列 "id" 映射到 Profession 对象的 "id" 属性,指定 JDBC 类型为 INTEGER -->
<result column="name" property="name" jdbcType="VARCHAR" /> <!-- 将数据库列 "name" 映射到 Profession 对象的 "name" 属性,指定 JDBC 类型为 VARCHAR -->
</resultMap>
<insert id="addProfession" parameterType="com.cow.horse.domain.Profession"> <!-- 定义插入操作id 为操作的唯一标识parameterType 指定传入参数的类型为 com.cow.horse.domain.Profession -->
<selectKey keyProperty="id" resultType="java.lang.Integer" order="AFTER"> <!-- 定义一个获取插入后自增 ID 的操作keyProperty 指定属性名resultType 指定结果类型order指定操作顺序为插入后 -->
select LAST_INSERT_ID() as id <!-- 使用数据库函数获取最后插入的 ID并将其别名为 id -->
</selectKey>
INSERT INTO profession <!-- SQL 插入语句,指定插入到 profession 表 -->
<trim prefix="(" suffix=")" suffixOverrides=","> <!-- trim 标签用于处理 SQL 片段,添加前缀、后缀并去除多余的逗号 -->
<if test="name != null and name != ''">`name`,</if> <!-- 如果传入的 Profession 对象的 name 属性不为空且不为空字符串,则在 SQL 中添加 "name" 列 -->
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <!-- 处理插入值部分的 SQL 片段,添加前缀、后缀并去除多余的逗号 -->
<if test="name != null and name != ''">#{name},</if> <!-- 如果传入的 Profession 对象的 name 属性不为空且不为空字符串,则插入对应的 name 值 -->
</trim>
</insert>
<delete id="deleteProfession" parameterType="int"> <!-- 定义删除操作id 为操作的唯一标识parameterType 指定传入参数的类型为 int -->
DELETE FROM <!-- SQL 删除语句的开始,指定从 profession 表删除数据 -->
profession
<where> <!-- where 标签用于添加 SQL 语句的条件部分 -->
id = #{id} <!-- 条件为:表中 "id" 列的值等于传入的参数 "id" -->
</where>
</delete>
<select id="checkProfessionCount" resultType="int" parameterType="string"> <!-- 定义查询操作id 为操作的唯一标识resultType 指定查询结果的类型为 intparameterType 指定传入参数的类型为 string -->
select count(0) from profession <!-- SQL 查询语句,统计 profession 表中满足条件的记录数量 -->
<where> <!-- where 标签添加查询条件 -->
name = #{name} <!-- 条件为:表中 "name" 列的值等于传入的参数 "name" -->
</where>
</select>
<select id="getProfessionList" resultMap="BaseUserMap" parameterType="map"> <!-- 定义查询操作id 为操作的唯一标识resultMap 指定使用的结果映射为 BaseUserMapparameterType 指定传入参数的类型为 map -->
SELECT
* <!-- 查询 profession 表的所有列 -->
from profession
</select>
<select id="getProfessionIdByName" resultMap="BaseUserMap" parameterType="string"> <!-- 定义查询操作id 为操作的唯一标识resultMap 指定使用的结果映射为 BaseUserMapparameterType 指定传入参数的类型为 string -->
SELECT
id <!-- 只查询 profession 表的 "id" 列 -->
from profession
where name = #{name} <!-- 查询条件为:表中 "name" 列的值等于传入的参数 "name" -->
</select>
</mapper>

@ -0,0 +1,337 @@
<?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.cow.horse.dao.Score.ScoreMapper" >
<!-- 定义结果映射,将数据库查询结果映射到 com.cow.horse.dto.Course 对象 -->
<resultMap id="BaseUserMap" type="com.cow.horse.dto.Course">
<result column="id" property="id" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="credits" property="credits" jdbcType="DECIMAL"/>
<result column="number" property="number" jdbcType="INTEGER"/>
<result column="score" property="score" jdbcType="INTEGER"/>
<result column="year" property="year" jdbcType="INTEGER"/>
<result column="term" property="term" jdbcType="INTEGER"/>
<result column="grade" property="grade" jdbcType="VARCHAR"/>
<result column="profession" property="profession" jdbcType="VARCHAR"/>
<result column="type" property="type" jdbcType="INTEGER"/>
<result column="profession" property="profession" jdbcType="VARCHAR"/>
<result column="real_name" property="realName" jdbcType="VARCHAR"/>
<result column="no" property="no" jdbcType="VARCHAR"/>
<result column="student_id" property="studentId" jdbcType="VARCHAR"/>
<result column="pointByUser" property="pointByUser" jdbcType="VARCHAR"/>
<result column="creditsByUser" property="creditsByUser" jdbcType="VARCHAR"/>
<result column="scoreByUser" property="scoreByUser" jdbcType="VARCHAR"/>
</resultMap>
<!-- 根据条件查询课程信息,关联多个表,返回结果映射为 BaseUserMap参数为 map 类型 -->
<select id="getCourseByMap" resultMap="BaseUserMap" parameterType="map">
SELECT
b.*,
c.real_name,
c.id as no,
c.grade,
c.username as student_name,
d.point as pointByUser,
d.credits as creditsByUser,
d.score as scoreByUser
FROM teacher_course a
LEFT JOIN course b
ON a.course_id = b.id
LEFT JOIN student c
ON a.profession = c.profession and a.grade = c.grade
LEFT JOIN student_course d
ON c.id = d.student_id and a.course_id = d.course_id
<where>
<if test="condition.profession != null and condition.profession != ''">
a.profession = #{condition.profession}
</if>
<if test="condition.grade != null and condition.grade != ''">
AND a.grade = #{condition.grade}
</if>
<if test="condition.username != null and condition.username != ''">
AND a.teacher_id = #{condition.username}
</if>
<if test="condition.courseName != null and condition.courseName != ''">
AND a.name = #{condition.courseName}
</if>
<if test="condition.studentName != null and condition.studentName != ''">
AND d.student_id = #{condition.studentName}
</if>
</where>
ORDER BY c.id
</select>
<!-- 管理员获取导出列表,关联学生表和课程表,返回结果映射为 BaseUserMap参数为 map 类型 -->
<select id="getExportListByAdmin" resultMap="BaseUserMap" parameterType="map">
select
a.id as no,
a.real_name,
a.admission_time as year,
a.grade,
a.profession,
b.name,
b.credits,
b.score,
b.number,
b.term,
b.type
FROM
student a
Left join course b
on a.profession = b.profession
<where>
<if test="condition.profession != null and condition.profession != ''">
a.profession = #{condition.profession}
</if>
<if test="condition.grade != null and condition.grade != ''">
AND a.grade = #{condition.grade}
</if>
<if test="condition.courseName != null and condition.courseName != ''">
AND b.name = #{condition.courseName}
</if>
</where>
order by a.id
</select>
<!-- 管理员获取课程信息,关联学生表和课程表,返回结果映射为 BaseUserMap参数为 map 类型 -->
<select id="getCourseByAdmin" resultMap="BaseUserMap" parameterType="map">
select
a.id as no,
a.real_name,
a.admission_time as year,
a.grade,
a.profession,
b.id,
b.name,
b.credits,
b.score,
b.number,
b.term,
b.type
FROM
student a
Left join course b
on a.profession = b.profession
<where>
<if test="condition.profession != null and condition.profession != ''">
a.profession = #{condition.profession}
</if>
<if test="condition.grade != null and condition.grade != ''">
AND a.grade = #{condition.grade}
</if>
<if test="condition.courseName != null and condition.courseName != ''">
AND b.name = #{condition.courseName}
</if>
</where>
order by a.id
</select>
<!-- 学生获取导出列表,关联学生课程表、学生表和课程表,返回结果映射为 BaseUserMap参数为 map 类型 -->
<select id="getExportListByStudent" resultMap="BaseUserMap" parameterType="map">
SELECT
a.student_id AS NO,
a.point as pointByUser,
a.credits as creditsByUser,
a.score as scoreByUser,
b.real_name,
b.admission_time as year,
b.grade,
b.profession,
c.name,
c.credits,
c.score,
c.number,
c.term,
c.type
FROM
student_course a
LEFT JOIN student b ON a.student_id = b.id
LEFT JOIN course c on a.course_id = c.id
<where>
<if test="condition.studentName != null and condition.studentName != ''">
AND a.student_id = #{condition.studentName}
</if>
<if test="condition.year != null and condition.year != ''">
AND a.year = #{condition.year}
</if>
<if test="condition.term != null and condition.term != ''">
AND a.term = #{condition.term}
</if>
</where>
order by a.id
</select>
<!-- 学生获取课程信息,关联学生课程表、学生表和课程表,返回结果映射为 BaseUserMap参数为 map 类型 -->
<select id="getCourseByStudent" resultMap="BaseUserMap" parameterType="map">
SELECT
a.student_id AS NO,
a.point as pointByUser,
a.credits as creditsByUser,
a.score as scoreByUser,
b.real_name,
b.admission_time as year,
b.grade,
b.profession,
c.name,
c.credits,
c.score,
c.number,
c.term,
c.type
FROM
student_course a
LEFT JOIN student b ON a.student_id = b.id
LEFT JOIN course c on a.course_id = c.id
<where>
<if test="condition.studentName != null and condition.studentName != ''">
AND a.student_id = #{condition.studentName}
</if>
<if test="condition.year != null and condition.year != ''">
AND a.year = #{condition.year}
</if>
<if test="condition.term != null and condition.term != ''">
AND a.term = #{condition.term}
</if>
</where>
order by a.id
</select>
<!-- 根据条件获取成绩信息,返回结果映射为 BaseUserMap参数为 map 类型 -->
<select id="getScoreById" resultMap="BaseUserMap" parameterType="map">
select
point as pointByUser,
credits as creditsByUser,
score as scoreByUser
FROM
student_course
<where>
<if test="condition.id != null and condition.id != ''">
student_id = #{condition.id}
</if>
<if test="condition.courseName != null and condition.courseName != ''">
AND name = #{condition.courseName}
</if>
</where>
</select>
<!-- 插入学生课程记录,参数为 com.cow.horse.dto.Score 类型 -->
<insert id="addEntry" parameterType="com.cow.horse.dto.Score">
INSERT INTO student_course
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="no != null and no != ''">student_id,</if>
<if test="name != null and name != ''">`name`,</if>
<if test="creditsByUser != null and creditsByUser != ''">`credits`,</if>
<if test="pointByUser != null and pointByUser != ''">`point`,</if>
<if test="scoreByUser != null and scoreByUser != ''">`score`,</if>
<if test="year != null and year != ''">`year`,</if>
<if test="term != null and term != ''">term,</if>
<if test="courseId != null and courseId != ''">course_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="no != null and no != ''">#{no},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="creditsByUser != null and creditsByUser != ''">#{creditsByUser},</if>
<if test="pointByUser != null and pointByUser != ''">#{pointByUser},</if>
<if test="scoreByUser != null and scoreByUser != ''">#{scoreByUser},</if>
<if test="year != null and year != ''">#{year},</if>
<if test="term != null and term != ''">#{term},</if>
<if test="courseId != null and courseId != ''">#{courseId},</if>
</trim>
</insert>
<!-- 更新学生课程记录,参数为 com.cow.horse.dto.Score 类型 -->
<update id="updateEntry" parameterType="com.cow.horse.dto.Score">
UPDATE student_course
<trim prefix="set" suffixOverrides=",">
<if test="name != null and name != ''">
`name` = #{name},
</if>
<if test="creditsByUser != null and creditsByUser != ''">
credits = #{creditsByUser},
</if>
<if test="pointByUser != null and pointByUser != ''">
point = #{pointByUser},
</if>
<if test="scoreByUser != null and scoreByUser != ''">
score = #{scoreByUser},
</if>
<if test="year != null and year != ''">
`year`= #{year},
</if>
<if test="term != null and term != ''">
term = #{term},
</if>
</trim>
<where>
<if test="no != null and no != ''">
student_id = #{no}
</if>
<if test="name != null and name != ''">
AND `name` = #{name}
</if>
</where>
</update>
<!-- 统计学生课程记录数量,返回结果类型为 int参数为 map 类型 -->
<select id="checkCount" resultType="int" parameterType="map">
select count(0) from student_course
<where>
student_id = #{condition.StudentId}
AND `name` = #{condition.CourseName}
</where>
</select>
<!-- 获取导出列表,关联多个表,返回结果映射为 BaseUserMap参数为 map 类型 -->
<select id="getExportList" resultMap="BaseUserMap" parameterType="map">
SELECT
b.*,
c.real_name,
c.id as no,
c.grade,
c.username as student_name,
d.point as pointByUser,
d.credits as creditsByUser,
d.score as scoreByUser
FROM teacher_course a
LEFT JOIN course b
ON a.course_id = b.id
LEFT JOIN student c
ON a.profession = c.profession and a.grade = c.grade
LEFT JOIN student_course d
ON c.id = d.student_id and a.course_id = d.course_id
<where>
<if test="condition.profession != null and condition.profession != ''">
a.profession = #{condition.profession}
</if>
<if test="condition.grade != null and condition.grade != ''">
AND a.grade = #{condition.grade}
</if>
<if test="condition.username != null and condition.username != ''">
AND a.teacher_id = #{condition.username}
</if>
<if test="condition.courseName != null and condition.courseName != ''">
AND a.name = #{condition.courseName}
</if>
<if test="condition.studentName != null and condition.studentName != ''">
AND d.student_id = #{condition.studentName}
</if>
</where>
ORDER BY c.id
</select>
<!-- 获取学生的总学分和总绩点,返回结果映射为 BaseUserMap参数为 map 类型 -->
<select id="getStudentTotal" resultMap="BaseUserMap" parameterType="map">
SELECT
credits as creditsByUser,
point as pointByUser
FROM student_course
<where>
<if test="condition.studentName != null and condition.studentName != ''">
AND student_id = #{condition.studentName}
</if>
</where>
</select>
</mapper>

@ -0,0 +1,181 @@
<?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.cow.horse.dao.TeacherCourse.TeacherCourseMapper" >
<!-- 定义 BaseUserMap 结果映射,将数据库表字段映射到 com.cow.horse.domain.TeacherCourse 类的属性 -->
<resultMap id="BaseUserMap" type="com.cow.horse.domain.TeacherCourse">
<!-- 将数据库中的 id 字段映射到 Java 对象的 id 属性,指定 JDBC 类型为 INTEGER -->
<result column="id" property="id" jdbcType="INTEGER"/>
<result column="teacher_id" property="teacherId" jdbcType="VARCHAR"/>
<result column="username" property="username" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="profession" property="profession" jdbcType="VARCHAR"/>
<result column="grade" property="grade" jdbcType="VARCHAR"/>
<result column="term" property="term" jdbcType="INTEGER"/>
<result column="course_id" property="courseId" jdbcType="VARCHAR"/>
</resultMap>
<!-- 定义 CourseMap 结果映射,将数据库表字段映射到 com.cow.horse.dto.Course 类的属性 -->
<resultMap id="CourseMap" type="com.cow.horse.dto.Course">
<result column="id" property="id" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="credits" property="credits" jdbcType="DECIMAL"/>
<result column="number" property="number" jdbcType="INTEGER"/>
<result column="score" property="score" jdbcType="INTEGER"/>
<result column="year" property="year" jdbcType="INTEGER"/>
<result column="term" property="term" jdbcType="INTEGER"/>
<result column="type" property="type" jdbcType="INTEGER"/>
<result column="profession" property="profession" jdbcType="VARCHAR"/>
<result column="start" property="start" jdbcType="INTEGER"/>
<result column="end" property="end" jdbcType="INTEGER"/>
<result column="room" property="room" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<!-- 插入操作,向 teacher_course 表插入数据,参数类型为 com.cow.horse.domain.TeacherCourse -->
<insert id="add" parameterType="com.cow.horse.domain.TeacherCourse">
INSERT INTO teacher_course
<!-- 使用 trim 标签处理插入字段列表,去除多余的逗号 -->
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 条件判断,如果 teacherId 不为空且不为空字符串,则插入该字段 -->
<if test="teacherId != null and teacherId != ''">teacher_id,</if>
<if test="username != null and username != ''">username,</if>
<if test="name != null and name != ''">name,</if>
<if test="profession != null and profession != ''">profession,</if>
<if test="grade != null and grade != ''">grade,</if>
<if test="term != null and term != ''">term,</if>
<if test="courseId != null and courseId != ''">course_id,</if>
</trim>
<!-- 使用 trim 标签处理插入值列表,去除多余的逗号 -->
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="teacherId != null and teacherId != ''">#{teacherId},</if>
<if test="username != null and username != ''">#{username},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="profession != null and profession != ''">#{profession},</if>
<if test="grade != null and grade != ''">#{grade},</if>
<if test="term != null and term != ''">#{term},</if>
<if test="courseId != null and courseId != ''">#{courseId},</if>
</trim>
</insert>
<!-- 删除操作,根据传入的 id 列表删除 teacher_course 表中的记录,参数类型为 map -->
<delete id="delete" parameterType="map">
DELETE FROM
teacher_course
<where>
id IN
<!-- 使用 foreach 标签遍历 id 列表,拼接成 SQL 语句 -->
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</where>
</delete>
<!-- 更新操作,更新 teacher_course 表中的记录,参数类型为 com.cow.horse.domain.TeacherCourse -->
<update id="update" parameterType="com.cow.horse.domain.TeacherCourse">
UPDATE teacher_course
<!-- 使用 trim 标签处理更新字段列表,去除多余的逗号 -->
<trim prefix="set" suffixOverrides=",">
<if test="username != null and username != ''">
username = #{username},
</if>
<if test="teacherId != null and teacherId != ''">
teacher_id = #{teacherId},
</if>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="profession != null and profession != ''">
profession = #{profession},
</if>
<if test="grade != null and grade != ''">
grade = #{grade},
</if>
<if test="term != null and term != ''">
term = #{term},
</if>
</trim>
<where>
<if test="id != null and id != ''">
id = #{id}
</if>
</where>
</update>
<!-- 查询操作,根据教师 id 获取课程列表,参数类型为 string结果映射为 BaseUserMap -->
<select id="getCourseListById" parameterType="string" resultMap="BaseUserMap">
SELECT
*
FROM teacher_course
<where>
teacher_id = #{id}
</where>
</select>
<!-- 查询操作,根据条件获取年级信息,参数类型为 string结果映射为 BaseUserMap -->
<select id="getGradeInfoByMap" parameterType="string" resultMap="BaseUserMap">
SELECT
name,
grade
FROM teacher_course
<where>
<!-- 条件判断,如果 profession 不为空且不为空字符串,则添加该条件 -->
<if test="condition.profession != null and condition.profession != ''">
AND profession = #{condition.profession}
</if>
<if test="condition.teacherId != null and condition.teacherId != ''">
AND teacher_id = #{condition.teacherId}
</if>
</where>
</select>
<!-- 查询操作,根据条件获取教师 id参数类型为 map结果类型为 string -->
<select id="getTeacherId" parameterType="map" resultType="string">
SELECT
teacher_id
FROM teacher_course
<where>
<if test="condition.profession != null and condition.profession != ''">
AND profession = #{condition.profession}
</if>
<if test="condition.grade != null and condition.grade != ''">
AND grade = #{condition.grade}
</if>
<if test="condition.course != null and condition.course != ''">
AND name = #{condition.course}
</if>
</where>
</select>
<!-- 查询操作,根据条件获取课程信息,关联多个表,参数类型为 map结果映射为 CourseMap -->
<select id="getCourseInfo" parameterType="map" resultMap="CourseMap">
SELECT
a.*,
b.number,
b.credits,
b.type,
c.real_name,
d.start,
d.end,
d.room
FROM teacher_course a
left join course b
on a.course_id = b.id
left join teacher c
on a.teacher_id = c.id
left join course_info d
on b.id = d.course_id
<where>
<if test="condition.profession != null and condition.profession != ''">
AND a.profession = #{condition.profession}
</if>
<if test="condition.grade != null and condition.grade != ''">
AND a.grade = #{condition.grade}
</if>
<if test="condition.courseName != null and condition.courseName != ''">
AND a.name = #{condition.courseName}
</if>
<if test="condition.teacherId != null and condition.teacherId != ''">
AND a.teacher_id = #{condition.teacherId}
</if>
</where>
</select>
</mapper>

@ -0,0 +1,108 @@
<?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.cow.horse.dao.Timetable.TimetableMapper" >
<!-- 定义结果映射,将数据库表的字段映射到 com.cow.horse.dto.Timetable 类的属性 -->
<resultMap id="BaseUserMap" type="com.cow.horse.dto.Timetable">
<!-- 将数据库中的 id 字段映射到 Java 对象的 id 属性,指定 JDBC 类型为 INTEGER -->
<result column="id" property="id" jdbcType="INTEGER"/>
<result column="week_id" property="weekId" jdbcType="INTEGER"/>
<result column="profession" property="profession" jdbcType="VARCHAR"/>
<result column="grade" property="grade" jdbcType="VARCHAR"/>
<result column="year" property="year" jdbcType="INTEGER"/>
<result column="term" property="term" jdbcType="INTEGER"/>
</resultMap>
<!-- 插入操作,向 timetable 表插入数据,参数类型为 com.cow.horse.dto.Timetable -->
<insert id="add" parameterType="com.cow.horse.dto.Timetable">
INSERT INTO timetable
<!-- 使用 trim 标签处理插入字段列表,去除多余的逗号 -->
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 条件判断,如果 weekId 不为空且不为空字符串,则插入该字段 -->
<if test="weekId != null and weekId != ''">week_id,</if>
<if test="profession != null and profession != ''">profession,</if>
<if test="grade != null and grade != ''">grade,</if>
<if test="year != null and year != ''">year,</if>
<if test="term != null and term != ''">term,</if>
<if test="weekNum != null and weekNum != ''">week_num,</if>
</trim>
<!-- 使用 trim 标签处理插入值列表,去除多余的逗号 -->
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="weekId != null and weekId != ''">#{weekId},</if>
<if test="profession != null and profession != ''">#{profession},</if>
<if test="grade != null and grade != ''">#{grade},</if>
<if test="year != null and year != ''">#{year},</if>
<if test="term != null and term != ''">#{term},</if>
<if test="weekNum != null and weekNum != ''">#{weekNum},</if>
</trim>
</insert>
<!-- 查询操作,根据条件从 timetable 表中查询数据,参数类型为 map结果映射为 BaseUserMap -->
<select id="getTimetable" resultMap="BaseUserMap" parameterType="map">
SELECT
*
FROM timetable
<where>
<!-- 条件判断,如果 profession 不为空且不为空字符串,则添加该查询条件 -->
<if test="condition.profession != null and condition.profession != ''">
profession = #{condition.profession}
</if>
<if test="condition.grade != null and condition.grade != ''">
AND grade = #{condition.grade}
</if>
<if test="condition.year != null and condition.year != ''">
AND year = #{condition.year}
</if>
<if test="condition.term != null and condition.term != ''">
AND term = #{condition.term}
</if>
<if test="condition.week != null and condition.week != ''">
AND week_num = #{condition.week}
</if>
</where>
</select>
<!-- 删除操作,根据条件从 timetable 表中删除数据,参数类型为 map -->
<delete id="deleteTimeTable" parameterType="map">
DELETE FROM
timetable
<where>
<if test="condition.profession != null and condition.profession != ''">
profession = #{condition.profession}
</if>
<if test="condition.grade != null and condition.grade != ''">
AND grade = #{condition.grade}
</if>
<if test="condition.year != null and condition.year != ''">
AND year = #{condition.year}
</if>
<if test="condition.term != null and condition.term != ''">
AND term = #{condition.term}
</if>
<if test="condition.week != null and condition.week != ''">
AND week_num = #{condition.week}
</if>
</where>
</delete>
<!-- 查询操作,根据条件统计 timetable 表中的记录数量,参数类型为 map结果类型为 int -->
<select id="checkCount" resultType="int" parameterType="map">
select count(0) from timetable
<where>
<if test="condition.profession != null and condition.profession != ''">
profession = #{condition.profession}
</if>
<if test="condition.grade != null and condition.grade != ''">
AND grade = #{condition.grade}
</if>
<if test="condition.year != null and condition.year != ''">
AND year = #{condition.year}
</if>
<if test="condition.term != null and condition.term != ''">
AND term = #{condition.term}
</if>
<if test="condition.week != null and condition.week != ''">
AND week_num = #{condition.week}
</if>
</where>
</select>
</mapper>

@ -0,0 +1,72 @@
<?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.cow.horse.dao.Upload.UploadMapper" >
<!-- 定义结果映射,将数据库表 upload 的字段映射到 com.cow.horse.domain.Upload 类的属性 -->
<resultMap id="BaseUserMap" type="com.cow.horse.domain.Upload">
<!-- 将数据库中的 id 字段映射到 Java 对象的 id 属性,指定 JDBC 类型为 INTEGER -->
<result column="id" property="id" jdbcType="INTEGER"/>
<result column="user_id" property="userId" jdbcType="VARCHAR"/>
<result column="url" property="url" jdbcType="VARCHAR"/>
<result column="level" property="level" jdbcType="INTEGER"/>
</resultMap>
<!-- 插入操作,向 upload 表插入数据,不过参数类型这里可能有误,应为 com.cow.horse.domain.Upload -->
<insert id="add" parameterType="com.cow.horse.dto.Timetable">
INSERT INTO upload
<!-- 使用 trim 标签处理插入字段列表,去除多余的逗号 -->
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 条件判断,如果 userId 不为空且不为空字符串,则插入该字段 -->
<if test="userId != null and userId != ''">user_id,</if>
<if test="url != null and url != ''">url,</if>
<if test="level != null and level != ''">level,</if>
</trim>
<!-- 使用 trim 标签处理插入值列表,去除多余的逗号 -->
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null and userId != ''">#{userId},</if>
<if test="url != null and url != ''">#{url},</if>
<if test="level != null and level != ''">#{level},</if>
</trim>
</insert>
<!-- 查询操作,根据条件从 upload 表中查询 url 字段,参数类型为 map结果类型为 string -->
<select id="getHead" resultType="string" parameterType="map">
SELECT
url
FROM upload
<where>
<!-- 根据传入的 userId 和 level 作为查询条件 -->
user_id = #{condition.userId}
AND level = #{condition.level}
</where>
</select>
<!-- 查询操作,根据条件统计 upload 表中的记录数量,参数类型为 map结果类型为 int -->
<select id="checkCount" resultType="int" parameterType="map">
select count(0) from upload
<where>
<!-- 根据传入的 userId 和 level 作为查询条件 -->
user_id = #{condition.userId}
AND level = #{condition.level}
</where>
</select>
<!-- 更新操作,根据条件更新 upload 表中的 url 字段,参数类型为 com.cow.horse.domain.Upload -->
<update id="update" parameterType="com.cow.horse.domain.Upload">
UPDATE upload
<!-- 使用 trim 标签处理更新字段列表,去除多余的逗号 -->
<trim prefix="set" suffixOverrides=",">
<!-- 条件判断,如果 url 不为空且不为空字符串,则更新该字段 -->
<if test="url != null and url != ''">
url = #{url},
</if>
</trim>
<where>
<!-- 根据传入的 userId 和 level 作为更新条件 -->
<if test="userId != null and userId != ''">
user_id = #{userId}
</if>
<if test="level != null and level != ''">
AND level = #{level}
</if>
</where>
</update>
</mapper>

@ -0,0 +1,136 @@
<?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.cow.horse.dao.User.AdminMapper" >
<!-- 定义结果映射,将数据库表字段映射到 com.cow.horse.dto.User 类的属性 -->
<resultMap id="BaseUserMap" type="com.cow.horse.dto.User">
<!-- 将数据库中的 id 字段映射到 Java 对象的 id 属性,指定 JDBC 类型为 VARCHAR -->
<result column="id" property="id" jdbcType="VARCHAR"/>
<result column="username" property="username" jdbcType="VARCHAR"/>
<result column="password" property="password" jdbcType="VARCHAR"/>
<result column="real_name" property="realName" jdbcType="VARCHAR"/>
<result column="level" property="level" jdbcType="INTEGER"/>
<result column="school" property="school" jdbcType="VARCHAR"/>
<result column="admission_time" property="admissionTime" jdbcType="VARCHAR"/>
<result column="email" property="email" jdbcType="VARCHAR"/>
<result column="profession" property="profession" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="sex" property="sex" jdbcType="INTEGER"/>
<result column="grade" property="grade" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<!-- 插入操作,向 admin 表插入数据,参数类型为 com.cow.horse.dto.User -->
<insert id="add" parameterType="com.cow.horse.dto.User">
INSERT INTO `admin`
<!-- 使用 trim 标签处理插入字段列表,去除多余的逗号 -->
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 条件判断,如果 username 不为空且不为空字符串,则插入该字段 -->
<if test="username != null and username != ''">username,</if>
<if test="password != null and password != ''">password,</if>
<if test="realName != null and realName != ''">real_name,</if>
<if test="school != null and school != ''">school,</if>
<if test="email != null and email != ''">email,</if>
<if test="profession != null and profession != ''">profession,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="sex != null and sex != ''">sex,</if>
</trim>
<!-- 使用 trim 标签处理插入值列表,去除多余的逗号 -->
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="username != null and username != ''">#{username},</if>
<if test="password != null and password != ''">#{password},</if>
<if test="realName != null and realName != ''">#{realName},</if>
<if test="school != null and school != ''">#{school},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="profession != null and profession != ''">#{profession},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="sex != null and sex != ''">#{sex},</if>
</trim>
</insert>
<!-- 删除操作,根据传入的 id 列表删除 admin 表中的记录,参数类型为 map -->
<delete id="delete" parameterType="map">
DELETE FROM
admin
<where>
id IN
<!-- 使用 foreach 标签遍历 id 列表,拼接成 SQL 语句 -->
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</where>
</delete>
<!-- 更新操作,更新 admin 表中的记录,参数类型为 com.cow.horse.dto.User -->
<update id="update" parameterType="com.cow.horse.dto.User">
UPDATE `admin`
<!-- 使用 trim 标签处理更新字段列表,去除多余的逗号 -->
<trim prefix="set" suffixOverrides=",">
<if test="username != null and username != ''">
username = #{username},
</if>
<if test="password != null and password != ''">
password = #{password},
</if>
<if test="realName != null and realName != ''">
real_name = #{realName},
</if>
<if test="school != null and school != ''">
school = #{school},
</if>
<if test="admissionTime != null and admissionTime != ''">
admission_time = #{admissionTime},
</if>
<if test="email != null and email != ''">
email = #{email},
</if>
<if test="profession != null and profession != ''">
profession = #{profession},
</if>
<if test="phone != null and phone != ''">
phone = #{phone},
</if>
<if test="sex != null">
sex = #{sex},
</if>
<if test="grade != null and grade != ''">
grade = #{grade},
</if>
</trim>
<where>
<if test="id != null and id != ''">
id = #{id}
</if>
</where>
</update>
<!-- 查询操作,根据条件获取管理员列表,参数类型为 map结果映射为 BaseUserMap -->
<select id="getAdminList" resultMap="BaseUserMap" parameterType="map">
SELECT
*
FROM `admin`
<where>
<!-- 条件判断,如果 code 不为空且不为空字符串,则添加模糊查询条件 -->
<if test="condition.code != null and condition.code != ''">
id LIKE CONCAT('%',#{condition.code},'%') OR real_name LIKE CONCAT('%',#{condition.code},'%')
</if>
</where>
<!-- 按创建时间降序排序 -->
ORDER BY create_time DESC
</select>
<!-- 查询操作,根据 id 获取用户信息,参数类型为 string结果映射为 BaseUserMap -->
<select id="getUserById" resultMap="BaseUserMap" parameterType="string">
SELECT
*
FROM `admin`
<where>
id = #{id}
</where>
</select>
<!-- 查询操作,统计 admin 表中的记录数量,结果类型为 int -->
<select id="checkCodeCount" resultType="int">
select
count(0)
from
`admin`
</select>
</mapper>

@ -0,0 +1,190 @@
<?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.cow.horse.dao.User.StudentMapper" >
<!-- 定义结果映射,将数据库表 student 的字段映射到 com.cow.horse.dto.User 类的属性 -->
<resultMap id="BaseUserMap" type="com.cow.horse.dto.User">
<!-- 将数据库中的 id 字段映射到 Java 对象的 id 属性,指定 JDBC 类型为 VARCHAR -->
<result column="id" property="id" jdbcType="VARCHAR"/>
<result column="username" property="username" jdbcType="VARCHAR"/>
<result column="password" property="password" jdbcType="VARCHAR"/>
<result column="real_name" property="realName" jdbcType="VARCHAR"/>
<result column="level" property="level" jdbcType="INTEGER"/>
<result column="school" property="school" jdbcType="VARCHAR"/>
<result column="admission_time" property="admissionTime" jdbcType="VARCHAR"/>
<result column="email" property="email" jdbcType="VARCHAR"/>
<result column="profession" property="profession" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="sex" property="sex" jdbcType="INTEGER"/>
<result column="grade" property="grade" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<!-- 插入操作,向 student 表插入学生信息,参数类型为 com.cow.horse.dto.User -->
<insert id="addStudent" parameterType="com.cow.horse.dto.User">
INSERT INTO student
<!-- 使用 trim 标签处理插入字段列表,去除多余的逗号 -->
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 条件判断,如果 id 不为空且不为空字符串,则插入该字段 -->
<if test="id != null and id != ''">id,</if>
<if test="username != null and username != ''">username,</if>
<if test="password != null and password != ''">password,</if>
<if test="realName != null and realName != ''">real_name,</if>
<if test="school != null and school != ''">school,</if>
<if test="admissionTime != null and admissionTime != ''">admission_time,</if>
<if test="email != null and email != ''">email,</if>
<if test="profession != null and profession != ''">profession,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="sex != null and sex != ''">sex,</if>
<if test="grade != null and grade != ''">grade,</if>
</trim>
<!-- 使用 trim 标签处理插入值列表,去除多余的逗号 -->
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">#{id},</if>
<if test="username != null and username != ''">#{username},</if>
<if test="password != null and password != ''">#{password},</if>
<if test="realName != null and realName != ''">#{realName},</if>
<if test="school != null and school != ''">#{school},</if>
<if test="admissionTime != null and admissionTime != ''">#{admissionTime},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="profession != null and profession != ''">#{profession},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="sex != null and sex != ''">#{sex},</if>
<if test="grade != null and grade != ''">#{grade},</if>
</trim>
</insert>
<!-- 删除操作,根据传入的 id 列表删除 student 表中的记录,参数类型为 map -->
<delete id="delete" parameterType="map">
DELETE FROM
student
<where>
id IN
<!-- 使用 foreach 标签遍历 id 列表,拼接成 SQL 语句 -->
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</where>
</delete>
<!-- 更新操作,更新 student 表中的学生信息,参数类型为 com.cow.horse.dto.User -->
<update id="update" parameterType="com.cow.horse.dto.User">
UPDATE student
<!-- 使用 trim 标签处理更新字段列表,去除多余的逗号 -->
<trim prefix="set" suffixOverrides=",">
<if test="id != null and id != ''">
id = #{id},
</if>
<if test="username != null and username != ''">
username = #{username},
</if>
<if test="password != null and password != ''">
password = #{password},
</if>
<if test="realName != null and realName != ''">
real_name = #{realName},
</if>
<if test="school != null and school != ''">
school = #{school},
</if>
<if test="admissionTime != null and admissionTime != ''">
admission_time = #{admissionTime},
</if>
<if test="email != null and email != ''">
email = #{email},
</if>
<if test="profession != null and profession != ''">
profession = #{profession},
</if>
<if test="phone != null and phone != ''">
phone = #{phone},
</if>
<if test="sex != null">
sex = #{sex},
</if>
<if test="grade != null and grade != ''">
grade = #{grade},
</if>
</trim>
<where>
<if test="id != null and id != ''">
id = #{id}
</if>
</where>
</update>
<!-- 查询操作,根据条件获取学生列表,参数类型为 map结果映射为 BaseUserMap -->
<select id="getStudentList" resultMap="BaseUserMap" parameterType="map">
SELECT
*
FROM student
<where>
<!-- 条件判断,如果 code 不为空且不为空字符串,则添加模糊查询条件 -->
<if test="condition.code != null and condition.code != ''">
id LIKE CONCAT('%',#{condition.code},'%') OR real_name LIKE CONCAT('%',#{condition.code},'%') OR profession LIKE CONCAT('%',#{condition.code},'%')
</if>
<!-- 条件判断,如果 profession 不为空且不为空字符串,则添加精确查询条件 -->
<if test="condition.profession != null and condition.profession != ''">
AND profession = #{condition.profession}
</if>
<!-- 条件判断,如果 grade 不为空且不为空字符串,则添加精确查询条件 -->
<if test="condition.grade != null and condition.grade != ''">
AND grade = #{condition.grade}
</if>
</where>
<!-- 按 id 降序排序 -->
ORDER BY id DESC
</select>
<!-- 查询操作,获取学生专业信息,结果类型为 com.cow.horse.dto.User -->
<select id="getStudentTree" resultType="com.cow.horse.dto.User">
SELECT
profession
FROM student
</select>
<!-- 查询操作,根据专业代码获取对应的年级信息,参数类型为 string结果类型为 string -->
<select id="getGradeByProfession" resultType="string" parameterType="string">
SELECT
grade
FROM student
<where>
<!-- 条件判断,如果 code 不为空且不为空字符串,则添加精确查询条件 -->
<if test="code != null and code != ''">
AND profession = #{code}
</if>
</where>
</select>
<!-- 查询操作,统计符合条件的学生记录数量,结果类型为 int -->
<select id="checkCodeCount" resultType="int">
select
count(0)
from
student
<where>
<!-- 条件判断,如果 profession 不为空且不为空字符串,则添加精确查询条件 -->
<if test="condition.profession != null and condition.profession != ''">
AND profession = #{condition.profession}
</if>
<!-- 条件判断,如果 grade 不为空且不为空字符串,则添加精确查询条件 -->
<if test="condition.grade != null and condition.grade != ''">
AND grade = #{condition.grade}
</if>
</where>
</select>
<!-- 查询操作,根据 id 获取学生信息,参数类型为 string结果映射为 BaseUserMap -->
<select id="getUserById" resultMap="BaseUserMap" parameterType="string">
SELECT
*
FROM student
<where>
id = #{id}
</where>
</select>
<!-- 查询操作,根据 id 获取学生信息,参数类型为 string结果映射为 BaseUserMap -->
<select id="getStudentById" resultMap="BaseUserMap" parameterType="string">
SELECT
*
FROM student
<where>
id = #{id}
</where>
</select>
</mapper>

@ -0,0 +1,146 @@
<?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.cow.horse.dao.User.TeacherMapper" >
<!-- 定义结果映射,将数据库表字段映射到 com.cow.horse.dto.User 类的属性 -->
<resultMap id="BaseUserMap" type="com.cow.horse.dto.User">
<!-- 将数据库中的 id 字段映射到 Java 对象的 id 属性,指定 JDBC 类型为 VARCHAR -->
<result column="id" property="id" jdbcType="VARCHAR"/>
<result column="username" property="username" jdbcType="VARCHAR"/>
<result column="password" property="password" jdbcType="VARCHAR"/>
<result column="real_name" property="realName" jdbcType="VARCHAR"/>
<result column="level" property="level" jdbcType="INTEGER"/>
<result column="school" property="school" jdbcType="VARCHAR"/>
<result column="admission_time" property="admissionTime" jdbcType="VARCHAR"/>
<result column="email" property="email" jdbcType="VARCHAR"/>
<result column="profession" property="profession" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="sex" property="sex" jdbcType="INTEGER"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<!-- 插入操作,向 teacher 表插入教师信息,参数类型为 com.cow.horse.dto.User -->
<insert id="addTeacher" parameterType="com.cow.horse.dto.User">
INSERT INTO teacher
<!-- 使用 trim 标签处理插入字段列表,去除多余的逗号 -->
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 条件判断,如果 id 不为空且不为空字符串,则插入该字段 -->
<if test="id != null and id != ''">id,</if>
<if test="username != null and username != ''">username,</if>
<if test="password != null and password != ''">password,</if>
<if test="realName != null and realName != ''">real_name,</if>
<if test="school != null and school != ''">school,</if>
<if test="email != null and email != ''">email,</if>
<if test="profession != null and profession != ''">profession,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="sex != null and sex != ''">sex,</if>
</trim>
<!-- 使用 trim 标签处理插入值列表,去除多余的逗号 -->
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">#{id},</if>
<if test="username != null and username != ''">#{username},</if>
<if test="password != null and password != ''">#{password},</if>
<if test="realName != null and realName != ''">#{realName},</if>
<if test="school != null and school != ''">#{school},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="profession != null and profession != ''">#{profession},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="sex != null and sex != ''">#{sex},</if>
</trim>
</insert>
<!-- 删除操作,根据传入的 id 列表删除 teacher 表中的记录,参数类型为 map -->
<delete id="delete" parameterType="map">
DELETE FROM
teacher
<where>
id IN
<!-- 使用 foreach 标签遍历 id 列表,拼接成 SQL 语句 -->
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</where>
</delete>
<!-- 更新操作,更新 teacher 表中的教师信息,参数类型为 com.cow.horse.dto.User -->
<update id="update" parameterType="com.cow.horse.dto.User">
UPDATE teacher
<!-- 使用 trim 标签处理更新字段列表,去除多余的逗号 -->
<trim prefix="set" suffixOverrides=",">
<if test="username != null and username != ''">
username = #{username},
</if>
<if test="password != null and password != ''">
password = #{password},
</if>
<if test="realName != null and realName != ''">
real_name = #{realName},
</if>
<if test="school != null and school != ''">
school = #{school},
</if>
<if test="email != null and email != ''">
email = #{email},
</if>
<if test="profession != null and profession != ''">
profession = #{profession},
</if>
<if test="phone != null and phone != ''">
phone = #{phone},
</if>
<if test="sex != null and sex != ''">
sex = #{sex},
</if>
</trim>
<where>
<if test="id != null and id != ''">
id = #{id}
</if>
</where>
</update>
<!-- 查询操作,根据条件获取教师列表,参数类型为 int结果映射为 BaseUserMap -->
<select id="getTeacherList" resultMap="BaseUserMap" parameterType="int">
SELECT
distinct a.id,
a.username, a.password, a.real_name,
a.level, a.school, a.email, a.phone,
a.sex, a.create_time
FROM
teacher a
LEFT JOIN
teacher_course b
ON a.username = b.username
<where>
<!-- 条件判断,如果 code 不为空且不为空字符串,则添加模糊查询条件 -->
<if test="condition.code != null and condition.code != ''">
a.username LIKE CONCAT('%',#{condition.code},'%') OR a.real_name LIKE CONCAT('%',#{condition.code},'%')
</if>
<!-- 条件判断,如果 profession 不为空且不为空字符串,则添加精确查询条件 -->
<if test="condition.profession != null and condition.profession != ''">
AND b.profession = #{condition.profession}
</if>
<!-- 条件判断,如果 grade 不为空且不为空字符串,则添加精确查询条件 -->
<if test="condition.grade != null and condition.grade != ''">
AND b.grade = #{condition.grade}
</if>
</where>
<!-- 按 a.id 降序排序 -->
ORDER BY a.id DESC
</select>
<!-- 查询操作,根据 id 获取用户信息,参数类型为 string结果映射为 BaseUserMap -->
<select id="getUserById" resultMap="BaseUserMap" parameterType="string">
SELECT
*
FROM teacher
<where>
id = #{id}
</where>
</select>
<!-- 查询操作,统计 teacher 表中的记录数量,结果类型为 int -->
<select id="checkCodeCount" resultType="int">
select
count(0)
from
teacher
</select>
</mapper>

@ -0,0 +1,82 @@
<?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.cow.horse.dao.User.UserMapper" >
<!-- 定义结果映射,将数据库表的字段映射到 com.cow.horse.dto.User 类的属性 -->
<resultMap id="BaseUserMap" type="com.cow.horse.dto.User">
<!-- 将数据库中的 id 字段映射到 Java 对象的 id 属性,指定 JDBC 类型为 VARCHAR -->
<result column="id" property="id" jdbcType="VARCHAR"/>
<result column="username" property="username" jdbcType="VARCHAR"/>
<result column="password" property="password" jdbcType="VARCHAR"/>
<result column="real_name" property="realName" jdbcType="VARCHAR"/>
<result column="level" property="level" jdbcType="INTEGER"/>
<result column="school" property="school" jdbcType="VARCHAR"/>
<result column="admission_time" property="admissionTime" jdbcType="VARCHAR"/>
<result column="email" property="email" jdbcType="VARCHAR"/>
<result column="profession" property="profession" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="sex" property="sex" jdbcType="INTEGER"/>
<result column="state" property="state" jdbcType="INTEGER"/>
</resultMap>
<!-- 查询操作,根据用户名和密码从 student 表中获取学生信息,参数类型为 map结果映射为 BaseUserMap -->
<select id="getStudentInfo" resultMap="BaseUserMap" parameterType="map">
SELECT
*
FROM student
<where>
<!-- 根据传入的用户名和密码作为查询条件 -->
username = #{condition.username}
AND password = #{condition.password}
</where>
</select>
<!-- 查询操作,根据用户名和密码从 teacher 表中获取教师信息,参数类型为 map结果映射为 BaseUserMap -->
<select id="getTeacherInfo" resultMap="BaseUserMap" parameterType="map">
SELECT
*
FROM teacher
<where>
<!-- 根据传入的用户名和密码作为查询条件 -->
username = #{condition.username}
AND password = #{condition.password}
</where>
</select>
<!-- 查询操作,根据用户名和密码从 admin 表中获取管理员信息,参数类型为 map结果映射为 BaseUserMap -->
<select id="getAdminInfo" resultMap="BaseUserMap" parameterType="map">
SELECT
*
FROM `admin`
<where>
<!-- 根据传入的用户名和密码作为查询条件 -->
username = #{condition.username}
AND password = #{condition.password}
</where>
</select>
<!-- 更新操作,根据条件更新指定表中的密码,参数类型为 map -->
<update id="update" parameterType="map">
UPDATE ${condition.table}
<!-- 使用 trim 标签处理更新字段列表,去除多余的逗号 -->
<trim prefix="set" suffixOverrides=",">
<!-- 条件判断,如果 passwordAgain 不为空且不为空字符串,则更新密码字段 -->
<if test="condition.passwordAgain != null and condition.passwordAgain != ''">
password = #{condition.passwordAgain},
</if>
</trim>
<where>
<!-- 根据传入的原密码作为更新条件 -->
<if test="condition.password != null and condition.password != ''">
password = #{condition.password}
</if>
<!-- 根据传入的用户名作为更新条件 -->
<if test="condition.username != null and condition.username != ''">
AND username = #{condition.username}
</if>
</where>
</update>
<!-- 查询操作,根据用户名和密码统计指定表中的记录数量,结果类型为 int参数类型为 map -->
<select id="checkPasswordCount" resultType="int" parameterType="map">
select count(0) from ${condition.table} where password = #{condition.password} AND username = #{condition.username}
</select>
</mapper>

@ -0,0 +1,117 @@
<?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.cow.horse.dao.WeekCourse.WeekCourseMapper" >
<!-- 定义结果映射,将数据库表字段映射到 com.cow.horse.domain.WeekCourse 类的属性 -->
<resultMap id="BaseUserMap" type="com.cow.horse.domain.WeekCourse">
<!-- 将数据库中的 id 字段映射到 Java 对象的 id 属性,指定 JDBC 类型为 INTEGER -->
<result column="id" property="id" jdbcType="INTEGER"/>
<result column="monday" property="monday" jdbcType="VARCHAR"/>
<result column="tuesday" property="tuesday" jdbcType="VARCHAR"/>
<result column="wednesday" property="wednesday" jdbcType="VARCHAR"/>
<result column="thursday" property="thursday" jdbcType="VARCHAR"/>
<result column="friday" property="friday" jdbcType="VARCHAR"/>
<result column="saturday" property="saturday" jdbcType="VARCHAR"/>
<result column="sunday" property="sunday" jdbcType="VARCHAR"/>
</resultMap>
<!-- 插入操作,向 week 表插入数据,参数类型为 com.cow.horse.dto.Timetable可能存在类型不匹配问题推测应为 com.cow.horse.domain.WeekCourse -->
<insert id="add" parameterType="com.cow.horse.dto.Timetable">
<!-- 插入后获取自增的主键值,并将其设置到对象的 id 属性中 -->
<selectKey keyProperty="id" resultType="java.lang.Integer" order="AFTER">
select LAST_INSERT_ID() as id
</selectKey>
INSERT INTO week
<!-- 使用 trim 标签处理插入字段列表,去除多余的逗号 -->
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 条件判断,如果 monday 不为空且不为空字符串,则插入该字段 -->
<if test="monday != null and monday != ''">monday,</if>
<if test="tuesday != null and tuesday != ''">tuesday,</if>
<if test="wednesday != null and wednesday != ''">wednesday,</if>
<if test="thursday != null and thursday != ''">thursday,</if>
<if test="friday != null and friday != ''">friday,</if>
<if test="saturday != null and saturday != ''">saturday,</if>
<if test="sunday != null and sunday != ''">sunday,</if>
</trim>
<!-- 使用 trim 标签处理插入值列表,去除多余的逗号 -->
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="monday != null and monday != ''">#{monday},</if>
<if test="tuesday != null and tuesday != ''">#{tuesday},</if>
<if test="wednesday != null and wednesday != ''">#{wednesday},</if>
<if test="thursday != null and thursday != ''">#{thursday},</if>
<if test="friday != null and friday != ''">#{friday},</if>
<if test="saturday != null and saturday != ''">#{saturday},</if>
<if test="sunday != null and sunday != ''">#{sunday},</if>
</trim>
</insert>
<!-- 更新操作,更新 week 表中的数据,参数类型为 com.cow.horse.domain.WeekCourse -->
<update id="update" parameterType="com.cow.horse.domain.WeekCourse">
UPDATE week
<!-- 使用 trim 标签处理更新字段列表,去除多余的逗号 -->
<trim prefix="set" suffixOverrides=",">
<!-- 条件判断,如果 monday 不为空且不为空字符串,则更新该字段 -->
<if test="monday != null and monday != ''">
monday = #{monday},
</if>
<if test="tuesday != null and tuesday != ''">
tuesday = #{tuesday},
</if>
<if test="wednesday != null and wednesday != ''">
wednesday = #{wednesday},
</if>
<if test="thursday != null and thursday != ''">
thursday = #{thursday},
</if>
<if test="friday != null and friday != ''">
friday = #{friday},
</if>
<if test="saturday != null and saturday != ''">
saturday = #{saturday},
</if>
<if test="sunday != null and sunday != ''">
sunday = #{sunday},
</if>
</trim>
<where>
<!-- 条件判断,如果 id 不为空且不为空字符串,则作为更新的条件 -->
<if test="id != null and id != ''">
id = #{id}
</if>
</where>
</update>
<!-- 查询操作,根据条件从 week 表和 timetable 表关联查询数据,参数类型为 map结果映射为 BaseUserMap -->
<select id="getWeekCourse" parameterType="map" resultMap="BaseUserMap">
select
a.*
from
week a
left join timetable b
on a.id = b.week_id
<where>
<!-- 条件判断,如果 profession 不为空且不为空字符串,则添加该查询条件 -->
<if test="condition.profession != null and condition.profession != ''">
AND b.profession = #{condition.profession}
</if>
<!-- 条件判断,如果 grade 不为空且不为空字符串,则添加该查询条件 -->
<if test="condition.grade != null and condition.grade != ''">
AND b.grade = #{condition.grade}
</if>
<!-- 条件判断,如果 year 不为空且不为空字符串,则添加该查询条件 -->
<if test="condition.year != null and condition.year != ''">
AND year = #{condition.year}
</if>
<!-- 条件判断,如果 term 不为空且不为空字符串,则添加该查询条件 -->
<if test="condition.term != null and condition.term != ''">
AND term = #{condition.term}
</if>
<!-- 条件判断,如果 week 不为空且不为空字符串,则添加该查询条件 -->
<if test="condition.week != null and condition.week != ''">
AND week_num = #{condition.week}
</if>
</where>
</select>
</mapper>

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<!-- 获取数据库自增主键值 -->
<setting name="useGeneratedKeys" value="true"/>
<!-- 使用列标签替换列别名 默认:true -->
<setting name="useColumnLabel" value="true"/>
<!-- 开启驼峰命名转换 -->
<setting name="mapUnderscoreToCamelCase" value="true"/>
<!-- sql打印 -->
<setting name="logImpl" value="STDOUT_LOGGING"/>
</settings>
</configuration>

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

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

Loading…
Cancel
Save