Compare commits

..

106 Commits

Author SHA1 Message Date
周牧之
fe9791ef9d Update pom.xml 2020-09-25 02:26:40 +00:00
周牧之
82a27897bc try to fix pom 2020-09-25 02:03:57 +00:00
周牧之
8fd11c5a94 test pom 2020-09-25 01:53:10 +00:00
周牧之
a0083f35c9 test scp 2020-09-24 12:29:30 +00:00
周牧之
0d08d31c8d test scp 2020-09-24 12:21:20 +00:00
周牧之
cab38b20d4 test scp 2020-09-24 11:40:22 +00:00
周牧之
5e4121bf3c test scp 2020-09-24 04:04:29 +00:00
周牧之
ff9c768951 test scp 2020-09-24 03:54:34 +00:00
周牧之
cffff73506 Update dockerfile 2020-09-24 02:58:16 +00:00
ublue
5e3ba60707 gzq 2020-09-22 15:34:15 +08:00
周牧之
2fdb72b9df test 2020-09-18 12:51:37 +00:00
ublue
fed98c0dad gzq 2020-09-18 17:44:31 +08:00
ublue
82114ebc49 gzq 2020-09-17 18:44:08 +08:00
Saturn&Eric
b870370395 调整 2020-09-17 01:51:27 +08:00
Saturn&Eric
21a4d07583 修正 2020-09-17 00:57:37 +08:00
ublue
89de75abf9 gzq 2020-09-15 23:37:05 +08:00
ublue
8375983b27 gzq 2020-09-12 21:41:22 +08:00
ublue
96dad0ce76 gzq 2020-09-12 21:25:54 +08:00
chuyan
95fdf7d063 对远端代码进行bug修复 2020-09-12 21:14:09 +08:00
chuyan
1e580181a4 Merge remote-tracking branch 'origin/master' 2020-09-12 21:09:56 +08:00
chuyan
61f71403a9 调整了message相关架构 2020-09-12 21:09:28 +08:00
ublue
79264a79a1 gzq 2020-09-12 19:33:02 +08:00
chuyan
882e5afa5d bug修复 2020-09-11 21:00:10 +08:00
chuyan
dc08efbaba 消息推送机制架构搭建完成 2020-09-11 20:44:50 +08:00
chuyan
17aace8fa6 CalculationService构建,有待家长相关的完善 2020-09-11 20:35:05 +08:00
chuyan
29d8aa4079 bug修复 2020-09-11 16:39:54 +08:00
chuyan
31e45ec6ad 增加了几个Repository, StaticsService构建完成 2020-09-11 16:37:27 +08:00
chuyan
ac05b505cc bug修复 2020-09-10 21:29:19 +08:00
chuyan
baf12c0657 ActivityService构建完成,并添加注释 2020-09-10 21:27:00 +08:00
chuyan
f8c9d17dc6 ActivityService进一步完善;
修改部分Model并重置分组
消息处理机制仍待解决
2020-09-10 20:58:43 +08:00
chuyan
49d8892b1d studentService注释添加 2020-09-10 19:29:38 +08:00
chuyan
74559712bc studentService大体构建完成,辅以一些工具类 2020-09-09 17:03:23 +08:00
chuyan
0bf91bd2ed Merge remote-tracking branch 'origin/master' 2020-09-08 21:57:08 +08:00
chuyan
7d2e345876 活动、文件相关repository编写完成 2020-09-08 21:56:54 +08:00
chuyan
5d3b6ec02d student相关repository修改与完善 2020-09-08 21:41:00 +08:00
chuyan
ccb1cb3682 student相关repository初步构建完成 2020-09-08 21:36:22 +08:00
ublue
68ca00297e gzq 2020-09-03 20:52:15 +08:00
chuyan
e6d2941f3c 学生相关实体大致构建完成 2020-09-03 19:17:51 +08:00
chuyan
437cab45dc student实体初步构建 2020-09-03 18:47:11 +08:00
chuyan
b496b0317d fourth deletion 数据库密码更换 2020-09-01 15:35:37 +08:00
chuyan
9403588247 third deletion 2020-09-01 15:17:31 +08:00
Saturneric
4f6af49432 调整 2020-09-01 15:14:33 +08:00
Saturneric
3942d547af Merge branch 'master' of http://git.codesdream.com/root/ASE
 Conflicts:
	src/main/java/com/codesdream/ase/repository/activity/ActivityRepository.java
2020-09-01 15:02:43 +08:00
Saturneric
40375ace72 修复 2020-09-01 15:02:23 +08:00
chuyan
b17a11009f first deletion 2020-09-01 14:57:04 +08:00
ddaa2000
615c5a8f42 将AppendixFileNotFoundException改为了IOException,增加了一些测试 2020-04-12 18:07:45 +08:00
ddaa2000
7e43a10dc3 Merge branch 'master' of 39.100.94.111:root/ASE into hua_1 2020-04-11 19:51:20 +08:00
ddaa2000
56e6a9a7d4 fileSystem added 2020-04-11 18:47:43 +08:00
ddaa2000
575a64b4f6 fileSystem added 2020-04-11 16:57:01 +08:00
Saturneric
dc768cb920 Merge branch 'master' of http://39.100.94.111:8082/root/ASE 2020-04-06 16:42:49 +08:00
chuyan
f7040e0111 bug修复 2020-04-06 15:53:53 +08:00
Saturneric
9a24081050 完善权限管理子系统的各个部分(未完);添加或完善用户、标签、功能性权限容器、范围性权限容器、功能接口;配置Spring Security角色管理; 2020-04-06 02:39:04 +08:00
yourtree
62f52e0709 Merge branch 'master' of http://39.100.94.111:8082/root/ASE 2020-04-05 21:46:51 +08:00
chuyan
b27cf72bc5 ActivityViewerController基本完善
对DAO层以及service的功能进行了进一步完善
修改了一些命名规则
2020-04-05 21:45:31 +08:00
Saturneric
2b5274c47d Merge branch 'master' of http://39.100.94.111:8082/root/ASE 2020-04-04 18:51:35 +08:00
Saturneric
b2903bb130 修改标签接口;添加FPC与SPC接口;完善权限管理子系统服务层; 2020-04-04 18:50:53 +08:00
MusingZone
418017a844 又一次完成成绩管理子系统的第一版数据模型 2020-04-04 15:19:55 +08:00
MusingZone
217c20ea3b 完成成绩管理子系统的第一版数据模型 2020-04-04 15:12:48 +08:00
MusingZone
909c7ae6b4 Merge branch 'master' of http://39.100.94.111:8082/root/ASE into master_zone 2020-04-04 14:11:19 +08:00
Saturneric
5168d6e2d9 修复自动部署的相关问题 2020-04-02 14:51:13 +08:00
Saturneric
0511bfb79c Merge branch 'master' of http://39.100.94.111:8082/root/ASE 2020-04-02 00:49:17 +08:00
Saturneric
c580dae176 测试 2020-04-02 00:42:16 +08:00
chuyan
224b2c4a77 毫无营养的测试 2020-04-02 00:27:39 +08:00
MusingZone
6a813c9bdb Merge branch 'master' of http://39.100.94.111:8082/root/ASE into master_zone 2020-04-02 00:12:22 +08:00
chuyan
751dface4e 修复问题 2020-03-29 18:28:55 +08:00
yourtree
801f3a2c7d Merge branch 'master' of https://gitee.com/saturneric/ASE
 Conflicts:
	src/main/java/com/codesdream/ase/controller/activity/ActivityCreatorController.java
2020-03-29 18:25:56 +08:00
yourtree
b9ddb73f3f 二维码模块基本完善;同时添加了一些文件处理工具FileUtils,存放于component/activity/下;为ActivityCreatorController添加了API调用说明 2020-03-29 18:25:02 +08:00
Saturneric
20a33c3b9a 修复问题 2020-03-29 17:43:32 +08:00
Saturneric
a61cf68ef0 Merge remote-tracking branch 'origin/master' 2020-03-29 17:40:38 +08:00
Saturneric
565e9ea835 添加权限管理子系统相关接口;继续完善错误管理子系统;添加了对于部分数据更新接口的相关支持(JSON Patch); 2020-03-29 17:40:26 +08:00
Vindicator645
0ede1972fd Leaving 2020-03-29 15:51:37 +08:00
MusingZone
356832b149 Merge branch 'master' of https://gitee.com/saturneric/ASE 2020-03-28 14:24:27 +08:00
Vindicator645
311ace2bd0 Merge branch 'master' of https://gitee.com/saturneric/ASE
 Conflicts:
	src/main/java/com/codesdream/ase/controller/LeavesController.java
2020-03-28 14:06:19 +08:00
Vindicator645
1004f13367 Leaving 2020-03-28 14:05:19 +08:00
Saturneric
e09f373fc0 编写标签相关接口;完善用户管理服务层;完善权限管理服务层;完善错误管理子系统; 2020-03-26 01:28:22 +08:00
Saturneric
f4d00f349f 添加Swagger;引入Restful API标准;Exception归类;错误管理子系统完善; 2020-03-25 15:51:06 +08:00
Saturneric
e8d91a4022 由于权限问题,修改服务端运行端口为8081 2020-03-25 02:40:38 +08:00
Saturneric
4b7411f562 修改服务端运行端口,避免与其他应用程序冲突 2020-03-25 02:22:11 +08:00
Saturneric
3181288755 修正活动管理子系统的一些问题 2020-03-25 02:07:09 +08:00
Saturneric
2cf0ff666f Merge remote-tracking branch 'origin/master' 2020-03-25 02:01:49 +08:00
Saturneric
9a8459df6c 增强安全策略;添加预验证;修正服务端编译问题; 2020-03-25 02:01:24 +08:00
chuyan
15cdca1894 (修正)
增加了从JSON到activity的转化器。
进而填补了repository层和service层的缺失。
增加了JSON表单格式校验,推荐把标准表单格式放在configure层下。
二维码初始学习,添加了二维码相关依赖。
2020-03-23 22:46:41 +08:00
yourtree
aef9478a83 Merge remote-tracking branch 'origin/master' 2020-03-22 21:08:07 +08:00
yourtree
720b047144 增加了从JSON到activity的转化器。
进而填补了repository层和service层的缺失。
增加了JSON表单格式校验,推荐把标准表单格式放在configure层下。
二维码初始学习,添加了二维码相关依赖。
2020-03-22 21:06:43 +08:00
Saturneric
ae21439c2e 添加测试豁免;开始添加权限管理子系统相关接口;调整项目架构; 2020-03-22 17:57:43 +08:00
yourtree
fbb2a3afc8 Merge branch 'master' of https://gitee.com/saturneric/ASE 2020-03-22 15:05:48 +08:00
Vindicator645
62ee044d13 Merge branch 'master' of https://gitee.com/saturneric/ASE
 Conflicts:
	src/main/java/com/codesdream/ase/controller/LeavesController.java
2020-03-21 13:59:41 +08:00
Vindicator645
ce1e3979bd jason 2020-03-21 13:57:38 +08:00
Saturneric
a64d65a70e 添加文件传输支持;添加单元测数据库本地化支持; 2020-03-18 18:50:35 +08:00
Saturneric
27ebd6205a 修复错误代码; 2020-03-17 23:50:53 +08:00
yourtree
3f56611fa9 Merge branch 'master' of https://gitee.com/saturneric/ASE 2020-03-17 20:16:32 +08:00
Vindicator645
5bb3cfe375 Merge branch 'master' of https://gitee.com/saturneric/ASE 2020-03-17 19:57:48 +08:00
Vindicator645
47d724163f jason 2020-03-17 19:57:17 +08:00
Saturneric
1b6bebc663 Merge remote-tracking branch 'origin/master' 2020-03-17 19:53:19 +08:00
yourtree
bbc2fc090b Merge branch 'develop' of https://gitee.com/saturneric/ASE 2020-03-17 19:43:06 +08:00
yourtree
efe497ed7c Merge branches 'develop' and 'master' of https://gitee.com/saturneric/ASE 2020-03-17 14:43:56 +08:00
yourtree
4b2d363e85 Merge remote-tracking branch 'origin/master' 2020-03-17 14:43:39 +08:00
MusingZone
34e9455ad9 Merge branch 'develop' of https://gitee.com/saturneric/ASE 2020-03-17 01:00:55 +08:00
yourtree
692d849006 Merge branch 'develop' of https://gitee.com/saturneric/ASE 2020-03-16 14:17:43 +08:00
Vindicator645
4916dea891 Leaving 2020-03-15 20:25:42 +08:00
chuyan
f13b30b4b7 创建活动controller修改以及测试。部分校验器修改。activity系统bug修复 2020-03-15 19:59:41 +08:00
Vindicator645
2277f5c8e4 Leaving 2020-03-15 15:17:47 +08:00
Vindicator645
205b7e2602 Leaving 2020-03-14 17:30:51 +08:00
chuyan
c1a23adaba controller结构微调;活动创建逻辑基本完善;活动查看界面初始编辑;增加校验器;组件结构微调;DAO层微调,增加UserActivityRepository;增加寻找当前登录信息组件,此组件尚未完善。 2020-03-14 17:28:01 +08:00
yourtree
47ef733453 Merge remote-tracking branch 'origin/master' 2020-03-14 13:17:02 +08:00
chuyan
887b44e2ee activity controller 修改 2020-03-14 13:16:24 +08:00
179 changed files with 7867 additions and 2186 deletions

7
dockerfile Normal file
View File

@ -0,0 +1,7 @@
FROM openjdk:8
# 指定当前操作目录
WORKDIR /_data/workspace/ASE/
#容器启动后执行的操作
CMD java -jar ASE-docker.jar

75
pom.xml
View File

@ -126,10 +126,10 @@
<version>3.14</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.61</version>
</dependency>
<dependency>
@ -141,7 +141,45 @@
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.5.4</version>
</dependency>
<!-- 内存数据库 -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<!-- 二维码支持包 -->
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.2.0</version>
</dependency>
<!-- Restful API 文档可视化支持 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.github.java-json-tools</groupId>
<artifactId>json-patch</artifactId>
<version>1.12</version>
</dependency>
@ -157,14 +195,45 @@
<addResources>true</addResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<!--suppress UnresolvedMavenProperty -->
<bootclasspath>${JAVA_HOME}/jre/lib/rt.jar</bootclasspath>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>CentralRepository</id>
<name>Maven Central Repository</name>
<url>https://repo1.maven.org/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>AlibabaMaven</id>
<name>Maven Aliyun Mirror</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
<url>https://maven.aliyun.com/repository/central</url>
<releases>
<enabled>true</enabled>
</releases>

View File

@ -0,0 +1,128 @@
package com.codesdream.ase.component.api;
import com.codesdream.ase.component.datamanager.JSONParameter;
import com.codesdream.ase.component.json.respond.JSONBaseRespondObject;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
public class QuickJSONRespond {
@Resource
private JSONParameter jsonParameter;
// 根据对象构造获得标准的JSON响应字符串返回
public String getJSONStandardRespond(Integer status, String msg, String info, Object dataObject){
JSONBaseRespondObject respondObject = new JSONBaseRespondObject(status, msg);
if(info != null) respondObject.setInfo(info);
else respondObject.setInfo(null);
respondObject.setData(dataObject);
return jsonParameter.getJSONString(respondObject);
}
// 根据对象构造获得标准的JSON响应字符串返回
public String getJSONStandardRespond(HttpStatus status, Object dataObject){
JSONBaseRespondObject respondObject = new JSONBaseRespondObject(status.value(), status.getReasonPhrase());
respondObject.setData(dataObject);
return jsonParameter.getJSONString(respondObject);
}
// 根据对象构造获得标准的JSON响应字符串返回
public String getJSONStandardRespond(HttpStatus status, String info, Object dataObject){
JSONBaseRespondObject respondObject = new JSONBaseRespondObject(status.value(), status.getReasonPhrase());
if(info != null) respondObject.setInfo(info);
else respondObject.setInfo(null);
respondObject.setData(dataObject);
return jsonParameter.getJSONString(respondObject);
}
// 根据对象构造获得标准的JSON响应字符串返回
public String getJSONStandardRespond(HttpStatus status, String info){
JSONBaseRespondObject respondObject = new JSONBaseRespondObject(status.value(), status.getReasonPhrase());
if(info != null) respondObject.setInfo(info);
else respondObject.setInfo(null);
return jsonParameter.getJSONString(respondObject);
}
// 获得标准的JSON响应字符串返回特定状态码的和解释息
public String getJSONStandardRespond(Integer code, String msg, String info){
JSONBaseRespondObject respondObject = new JSONBaseRespondObject(code, msg);
if(info != null) respondObject.setInfo(info);
else respondObject.setInfo(null);
respondObject.setData(null);
return jsonParameter.getJSONString(respondObject);
}
// 获得标准的JSON响应字符串返回(404状态)
public String getRespond404(String info){
return getJSONStandardRespond(HttpStatus.NOT_FOUND, info);
}
// 获得标准的JSON响应字符串返回(404状态)
public String getRespond404(String info, Object object){
return getJSONStandardRespond(HttpStatus.NOT_FOUND, info, object);
}
// 获得标准的JSON响应字符串返回(500状态)
public String getRespond500(String info){
return getJSONStandardRespond(HttpStatus.INTERNAL_SERVER_ERROR, info);
}
// 获得标准的JSON响应字符串返回(200状态)
public String getRespond200(String info){
return getJSONStandardRespond(HttpStatus.OK, info);
}
// 获得标准的JSON响应字符串返回(200状态)
public String getRespond200(String info, Object object){
return getJSONStandardRespond(HttpStatus.OK, info, object);
}
// 获得标准的JSON响应字符串返回(403状态)
public String getRespond403(String info){
return getJSONStandardRespond(HttpStatus.FORBIDDEN, info);
}
// 获得标准的JSON响应字符串返回(406状态)
public String getRespond406(String info){
return getJSONStandardRespond(HttpStatus.NOT_ACCEPTABLE, info);
}
// 获得标准的JSON响应字符串返回(406状态)
public String getRespond406(String info, Object object){
return getJSONStandardRespond(HttpStatus.NOT_ACCEPTABLE, info, object);
}
// 获得标准的JSON响应字符串返回(501态)
public String getRespond501(String info){
return getJSONStandardRespond(501, "Not Implemented", info) ;
}
// 获得标准的JSON响应字符串返回(401状态)
public String getRespond401(String info){
return getJSONStandardRespond(401, "Unauthorized", info);
}
// 获得标准的JSON响应字符串返回(400状态)
public String getRespond400(String info){
return getJSONStandardRespond(400, "Bad Request", info);
}
// 获得标准的JSON响应字符串返回(404状态)
public String getRespond400(String info, Object object){
return getJSONStandardRespond(400, "Bad Request", info, object);
}
// 获得标准的JSON响应字符串返回(400状态)
public String getRespond409(String info){
return getJSONStandardRespond(409, "Conflict", info);
}
}

View File

@ -0,0 +1,42 @@
package com.codesdream.ase.component.auth;
import org.springframework.security.access.AccessDecisionManager;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.authentication.InsufficientAuthenticationException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.Iterator;
@Component
public class ASEAccessDecisionManager implements AccessDecisionManager {
@Override
public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes) throws AccessDeniedException, InsufficientAuthenticationException {
if(null == configAttributes || configAttributes.size() <= 0) {
return;
}
for (ConfigAttribute c : configAttributes) {
String needRole = c.getAttribute();
for (GrantedAuthority ga : authentication.getAuthorities()) {
if (needRole.trim().equals(ga.getAuthority())) {
return;
}
}
}
throw new AccessDeniedException("Access Denied");
}
@Override
public boolean supports(ConfigAttribute attribute) {
return true;
}
@Override
public boolean supports(Class<?> clazz) {
return true;
}
}

View File

@ -1,8 +1,6 @@
package com.codesdream.ase.component.permission;
package com.codesdream.ase.component.auth;
import com.codesdream.ase.component.datamanager.JSONParameter;
import com.codesdream.ase.component.datamanager.QuickJSONRespond;
import com.codesdream.ase.component.json.respond.UserLoginCheckerJSONRespond;
import com.codesdream.ase.component.api.QuickJSONRespond;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;

View File

@ -1,16 +1,12 @@
package com.codesdream.ase.component.permission;
package com.codesdream.ase.component.auth;
import com.codesdream.ase.component.datamanager.JSONParameter;
import com.codesdream.ase.component.datamanager.QuickJSONRespond;
import com.codesdream.ase.component.json.respond.JSONBaseRespondObject;
import com.codesdream.ase.component.json.respond.UserLoginCheckerJSONRespond;
import com.codesdream.ase.component.api.QuickJSONRespond;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

View File

@ -1,16 +1,13 @@
package com.codesdream.ase.component.permission;
package com.codesdream.ase.component.auth;
import com.codesdream.ase.component.datamanager.JSONParameter;
import com.codesdream.ase.component.datamanager.QuickJSONRespond;
import com.codesdream.ase.component.api.QuickJSONRespond;
import com.codesdream.ase.component.json.respond.ErrorInfoJSONRespond;
import com.codesdream.ase.component.json.respond.UserLoginCheckerJSONRespond;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

View File

@ -1,8 +1,6 @@
package com.codesdream.ase.component.permission;
package com.codesdream.ase.component.auth;
import com.codesdream.ase.component.auth.JSONTokenAuthenticationToken;
import com.codesdream.ase.component.datamanager.JSONParameter;
import com.codesdream.ase.component.datamanager.QuickJSONRespond;
import com.codesdream.ase.component.api.QuickJSONRespond;
import com.codesdream.ase.component.json.respond.UserLoginCheckerJSONRespond;
import com.codesdream.ase.model.permission.User;
@ -19,7 +17,6 @@ import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Optional;
@ -41,6 +38,7 @@ public class ASEAuthenticationSuccessHandler extends SavedRequestAwareAuthentica
UserLoginCheckerJSONRespond respond = new UserLoginCheckerJSONRespond();
respond.setUserExist(authentication.isAuthenticated());
respond.setLoginStatus(authentication.isAuthenticated());
respond.setPvc(authService.preValidationCodeGetter());
// 获得 JSONTokenAuthenticationToken
JSONTokenAuthenticationToken authenticationToken = (JSONTokenAuthenticationToken) authentication;

View File

@ -0,0 +1,48 @@
package com.codesdream.ase.component.auth;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.web.FilterInvocation;
import org.springframework.security.web.access.intercept.FilterInvocationSecurityMetadataSource;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.HashMap;
@Component
public class ASEInvocationSecurityMetadataSource implements FilterInvocationSecurityMetadataSource {
private HashMap<String, Collection<ConfigAttribute>> map = null;
private void loadFunctionDefine(){
map = new HashMap<>();
//TODO 给HashMap添加URL
}
@Override
public Collection<ConfigAttribute> getAttributes(Object object) throws IllegalArgumentException {
if(map == null) loadFunctionDefine();
HttpServletRequest request = ((FilterInvocation) object).getHttpRequest();
for (String url : map.keySet()) {
AntPathRequestMatcher matcher = new AntPathRequestMatcher(url);
if (matcher.matches(request)) {
return map.get(url);
}
}
return null;
}
@Override
public Collection<ConfigAttribute> getAllConfigAttributes() {
return null;
}
@Override
public boolean supports(Class<?> clazz) {
return true;
}
}

View File

@ -1,10 +1,5 @@
package com.codesdream.ase.component.permission;
package com.codesdream.ase.component.auth;
import com.codesdream.ase.component.auth.AJAXRequestChecker;
import com.codesdream.ase.component.auth.JSONRandomCodeGenerator;
import com.codesdream.ase.component.auth.JSONSignedGenerator;
import com.codesdream.ase.component.auth.JSONTokenAuthenticationToken;
import com.codesdream.ase.component.datamanager.JSONParameter;
import com.codesdream.ase.model.auth.JSONToken;
import com.codesdream.ase.service.AuthService;
import lombok.extern.slf4j.Slf4j;
@ -30,15 +25,9 @@ import java.util.Optional;
@Slf4j
public class ASEJSONTokenAuthenticationFilter extends OncePerRequestFilter {
@Resource
private JSONParameter jsonParameter;
@Resource
private JSONRandomCodeGenerator randomCodeGenerator;
@Resource
private AJAXRequestChecker ajaxRequestChecker;
@Resource
private AuthService authService;
@ -59,7 +48,13 @@ public class ASEJSONTokenAuthenticationFilter extends OncePerRequestFilter {
// 时间戳
String timestamp = request.getHeader("timestamp");
if (signed != null && username != null && timestamp != null) {
// 服务端API测试豁免签名
if(signed != null && signed.equals("6d4923fca4dcb51f67b85e54a23a8d763d9e02af")){
//执行授权
doAuthentication("u_id_c70233fd7cb1f8a770c440975a0d13ad4013d3631b6f93c0037c7294bbc42140", request);
}
// 正常认证
else if (signed != null && username != null && timestamp != null) {
// 获得具体时间
Date date = new Date(Long.parseLong(timestamp));

View File

@ -1,4 +1,4 @@
package com.codesdream.ase.component.permission;
package com.codesdream.ase.component.auth;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.security.crypto.password.PasswordEncoder;

View File

@ -1,7 +1,5 @@
package com.codesdream.ase.component.permission;
package com.codesdream.ase.component.auth;
import com.codesdream.ase.component.auth.JSONTokenAuthenticationToken;
import com.codesdream.ase.component.auth.JSONTokenUsernamePasswordAuthenticationToken;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.authentication.*;
import org.springframework.security.core.Authentication;
@ -34,11 +32,11 @@ public class ASESecurityAuthenticationProvider implements AuthenticationProvider
JSONTokenUsernamePasswordAuthenticationToken authenticationToken =
(JSONTokenUsernamePasswordAuthenticationToken) authentication;
// 获得登录表单中的学号
// 获得JSON中的学号
String username = usernameEncoder.encode((CharSequence) authenticationToken.getPrincipal());
// 获得表单中的密码
String password = passwordEncoder.encode((CharSequence) authenticationToken.getCredentials());
// 获得
// 获得JSON中的加密密码
String encrypted_password = (String) authenticationToken.getCredentials();
// 获得客户端代码
String clientCode = authenticationToken.getClientCode();
// 判断用户是否存在
UserDetails userInfo = userDetailsService.loadUserByUsername(username);
@ -47,19 +45,22 @@ public class ASESecurityAuthenticationProvider implements AuthenticationProvider
throw new UsernameNotFoundException("User Not Exist");
}
String sha256_password = userInfo.getPassword();
// 判断密码是否正确
if (!userInfo.getPassword().equals(password)) {
throw new BadCredentialsException("Password IS Uncorrected");
if(!passwordEncoder.encode(String.format(
"PASS_ENCODE [%s][%s]", sha256_password, clientCode)).equals(encrypted_password)){
throw new BadCredentialsException("Password IS INCORRECT");
}
// 判断账号是否停用/删除
if (!userInfo.isEnabled()) {
throw new DisabledException("User IS Disabled");
}
else if(!userInfo.isAccountNonLocked()){
else if(!userInfo.isAccountNonLocked()) {
throw new LockedException("User IS Locked");
}
else if(!userInfo.isAccountNonExpired()){
else if(!userInfo.isAccountNonExpired()) {
throw new AccountExpiredException("User IS Expired");
}

View File

@ -0,0 +1,62 @@
package com.codesdream.ase.component.auth;
import javax.annotation.Resource;
import javax.servlet.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.SecurityMetadataSource;
import org.springframework.security.access.intercept.AbstractSecurityInterceptor;
import org.springframework.security.access.intercept.InterceptorStatusToken;
import org.springframework.security.web.FilterInvocation;
import org.springframework.security.web.access.intercept.FilterInvocationSecurityMetadataSource;
import org.springframework.stereotype.Component;
import java.io.IOException;
@Component
public class ASESecurityInterceptor extends AbstractSecurityInterceptor implements Filter {
@Resource
private FilterInvocationSecurityMetadataSource securityMetadataSource;
@Resource
public void setASEAccessDecisionManager(ASEAccessDecisionManager accessDecisionManager) {
super.setAccessDecisionManager(accessDecisionManager);
}
@Override
public Class<?> getSecureObjectClass() {
return FilterInvocation.class;
}
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {
return this.securityMetadataSource;
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
FilterInvocation fi = new FilterInvocation(request, response, chain);
invoke(fi);
}
public void invoke(FilterInvocation fi) throws IOException, ServletException {
InterceptorStatusToken token = super.beforeInvocation(fi);
try {
//执行下一个拦截器
fi.getChain().doFilter(fi.getRequest(), fi.getResponse());
} finally {
super.afterInvocation(token, null);
}
}
@Override
public void destroy() {
}
}

View File

@ -1,4 +1,4 @@
package com.codesdream.ase.component.permission;
package com.codesdream.ase.component.auth;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.stereotype.Component;

View File

@ -1,4 +1,4 @@
package com.codesdream.ase.component.permission;
package com.codesdream.ase.component.auth;
import com.codesdream.ase.component.auth.AJAXRequestChecker;
import com.codesdream.ase.component.auth.JSONTokenUsernamePasswordAuthenticationToken;
@ -8,19 +8,17 @@ import com.codesdream.ase.component.json.request.UserLoginChecker;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Optional;
// 登录验证过滤器
// 普通登录验证过滤器
@Slf4j
public class ASEUsernamePasswordAuthenticationFilter extends UsernamePasswordAuthenticationFilter {
@ -65,6 +63,7 @@ public class ASEUsernamePasswordAuthenticationFilter extends UsernamePasswordAut
// 获得相应的用户名密码
String username = checker.getUsername();
// 得到加密密码
String password = checker.getPassword();
String clientCode = checker.getClientCode();

View File

@ -7,11 +7,11 @@ import org.springframework.stereotype.Component;
// SHA1算法不可逆加密 主要用于JSON签名
@Component
public class SHA1Encoder {
String encode(CharSequence charSequence){
public String encode(CharSequence charSequence){
return DigestUtils.sha1Hex(charSequence.toString());
}
boolean match(CharSequence charSequence, String s){
public boolean match (CharSequence charSequence, String s){
return s.equals(encode(charSequence));
}
}

View File

@ -15,4 +15,10 @@ public class TimestampExpiredChecker {
return timestampDate.before(maxDate);
}
public boolean checkDateBeforeMaxTime(Date date, int seconds){
long currentTime = System.currentTimeMillis();
Date maxDate = new Date(currentTime + seconds * 1000);
return date.before(maxDate);
}
}

View File

@ -1,7 +1,7 @@
package com.codesdream.ase.component.datamanager;
import com.codesdream.ase.exception.DataFileNotFoundException;
import com.codesdream.ase.exception.DataIOException;
import com.codesdream.ase.exception.notfound.DataFileNotFoundException;
import com.codesdream.ase.exception.innerservererror.DataIOException;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

View File

@ -2,6 +2,10 @@ package com.codesdream.ase.component.datamanager;
import com.codesdream.ase.exception.*;
import com.codesdream.ase.exception.innerservererror.DataIOException;
import com.codesdream.ase.exception.innerservererror.DataIllegalTableFormatException;
import com.codesdream.ase.exception.innerservererror.DataInvalidFormatException;
import com.codesdream.ase.exception.notfound.DataFileNotFoundException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;

View File

@ -1,11 +1,9 @@
package com.codesdream.ase.component.datamanager;
import com.codesdream.ase.exception.DataIllegalTableFormatException;
import com.codesdream.ase.exception.innerservererror.DataIllegalTableFormatException;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.persistence.Table;
import javax.swing.text.html.Option;
import java.util.*;
// 描述一张数据表

View File

@ -3,6 +3,12 @@ package com.codesdream.ase.component.datamanager;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.codesdream.ase.component.json.respond.JSONBaseRespondObject;
import com.codesdream.ase.exception.innerservererror.HandlingErrorsException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.fge.jsonpatch.JsonPatch;
import com.github.fge.jsonpatch.JsonPatchException;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
@ -69,6 +75,15 @@ public class JSONParameter {
return json.map(jsonObject -> getJavaObject(jsonObject, type));
}
public <T> T parsePathToObject(JsonPatch patch, T object){
try {
ObjectMapper mapper = new ObjectMapper();
JsonNode patched = patch.apply(mapper.convertValue(object, JsonNode.class));
return (T) mapper.treeToValue(patched, object.getClass());
} catch (JsonPatchException | JsonProcessingException e) {
throw new HandlingErrorsException(e.getMessage());
}
}
}

View File

@ -1,80 +0,0 @@
package com.codesdream.ase.component.datamanager;
import com.codesdream.ase.component.json.respond.EmptyDataObjectRespond;
import com.codesdream.ase.component.json.respond.JSONBaseRespondObject;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
public class QuickJSONRespond {
@Resource
private JSONParameter jsonParameter;
// 根据对象构造获得标准的JSON响应字符串返回
public String getJSONStandardRespond(Integer status, String msg, String info, Object dataObject){
JSONBaseRespondObject respondObject = new JSONBaseRespondObject(status, msg);
if(info != null) respondObject.setInfo(info);
else respondObject.setInfo(null);
respondObject.setData(dataObject);
return jsonParameter.getJSONString(respondObject);
}
// 获得标准的JSON响应字符串返回特定状态码的和解释息
public String getJSONStandardRespond(Integer code, String msg, String info){
JSONBaseRespondObject respondObject = new JSONBaseRespondObject(code, msg);
if(info != null) respondObject.setInfo(info);
else respondObject.setInfo(null);
respondObject.setData(null);
return jsonParameter.getJSONString(respondObject);
}
// 获得标准的JSON响应字符串返回(404状态)
public String getRespond404(String info){
return getJSONStandardRespond(404, "Not Found", info);
}
// 获得标准的JSON响应字符串返回(500状态)
public String getRespond500(String info){
return getJSONStandardRespond(500, "Internal Server Error", info);
}
// 获得标准的JSON响应字符串返回(200状态)
public String getRespond200(String info){
return getJSONStandardRespond(200, "Ok", info);
}
// 获得标准的JSON响应字符串返回(200状态)
public String getRespond200(String info, Object object){
return getJSONStandardRespond(200, "Ok", info, object);
}
// 获得标准的JSON响应字符串返回(403状态)
public String getRespond403(String info){
return getJSONStandardRespond(403, "Forbidden", info);
}
// 获得标准的JSON响应字符串返回(403状态)
public String getRespond406(String info){
return getJSONStandardRespond(406, "Not Acceptable", info);
}
// 获得标准的JSON响应字符串返回(501态)
public String getRespond501(String info){
return getJSONStandardRespond(501, "Not Implemented", info) ;
}
// 获得标准的JSON响应字符串返回(401状态)
public String getRespond401(String info){
return getJSONStandardRespond(401, "Unauthorized", info);
}
// 获得标准的JSON响应字符串返回(400状态)
public String getRespond400(String info){
return getJSONStandardRespond(400, "Bad Request", info);
}
}

View File

@ -0,0 +1,12 @@
package com.codesdream.ase.component.datamanager;
import lombok.Data;
// 储存字符串标识的文件并可以转换为json进行传输
@Data
public class StringFile {
private String strData = null;
private String sha1Checker = null;
private Integer size = null;
private String type = "none";
}

View File

@ -0,0 +1,92 @@
package com.codesdream.ase.component.datamanager;
import com.codesdream.ase.component.auth.SHA1Encoder;
import com.codesdream.ase.exception.StringFileConvertException;
import com.sun.xml.internal.messaging.saaj.util.ByteInputStream;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.*;
import java.util.Base64;
import java.util.Optional;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
// 将文件处理成可发送的字符串文件对象
@Component
public class StringFileGenerator {
@Resource
private SHA1Encoder encoder;
// 用过读入流创建一个字符串文件
public Optional<StringFile> generateStringFile(InputStream stream){
StringFile file = new StringFile();
// 字符串内容计算
file.setStrData(generateFile2String(stream));
if(file.getStrData() == null) return Optional.empty();
// 相关校验值计算
file.setSha1Checker(generateSHA1Checker(file.getStrData()));
file.setSize(file.getStrData().length());
return Optional.of(file);
}
private byte[] readSteamAll(InputStream stream) {
try {
byte[] bytes = new byte[stream.available()];
//检查文件书否完全读取
if (stream.read(bytes) != bytes.length) return null;
else return bytes;
} catch (IOException e){
return null;
}
}
private String generateFile2String(InputStream stream){
ByteArrayOutputStream zipDataStream = new ByteArrayOutputStream();
try {
GZIPOutputStream gzipOutputStream = new GZIPOutputStream(zipDataStream);
byte[] bytes = readSteamAll(stream);
if(bytes == null) return null;
gzipOutputStream.write(bytes);
gzipOutputStream.close();
return Base64.getEncoder().encodeToString(zipDataStream.toByteArray());
} catch (IOException e) {
return null;
}
}
// 生成字符串文件的校验码
private String generateSHA1Checker(String str){
return encoder.encode(str);
}
// 检查文件内容是否正确包括大小与校验码
public boolean checkStringFile(StringFile file){
return file.getStrData().length() == file.getSize()
&& encoder.match(file.getStrData(), file.getSha1Checker());
}
// 从字符串文件中读取真实的文件数据
public InputStream readFileString(StringFile file){
try {
// 字符串转换为二进制数据
byte[] bytes = Base64.getDecoder().decode(file.getStrData());
GZIPInputStream stream = new GZIPInputStream(new ByteArrayInputStream(bytes), bytes.length);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
// 数据解压缩
int readBits = 0;
byte[] rawBytes = new byte[1024];
while ((readBits = stream.read(rawBytes)) != -1) {
outputStream.write(rawBytes, 0, readBits);
}
stream.close();
return new ByteArrayInputStream(outputStream.toByteArray());
} catch (IOException e) {
throw new StringFileConvertException("Read FileString Failed");
}
}
}

View File

@ -0,0 +1,5 @@
package com.codesdream.ase.component.json.form;
public class RegisterForm {
}

View File

@ -0,0 +1,6 @@
package com.codesdream.ase.component.json.model;
public class JsonableUidGetter {
private String checkType;
private String username;
}

View File

@ -0,0 +1,33 @@
package com.codesdream.ase.component.json.model;
import com.codesdream.ase.model.permission.User;
import com.codesdream.ase.model.permission.UserAuth;
import com.codesdream.ase.model.permission.UserDetail;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@ApiModel("用户")
@NoArgsConstructor
public class JsonableUser {
private Integer id;
private String username;
private boolean enabled;
private boolean deleted;
public JsonableUser(User user){
this.id = user.getId();
this.username = user.getUsername();
this.enabled = user.isEnabled();
this.deleted= user.isDeleted();
}
public User parseObject(User user){
user.setEnabled(this.enabled);
user.setDeleted(this.deleted);
return user;
}
}

View File

@ -0,0 +1,16 @@
package com.codesdream.ase.component.json.request;
import lombok.Data;
@Data
public class UserLeaveAuth {
/*
备注
*/
private int id;
private String Comment;
/*
审核结果
*/
private String newStat;
}

View File

@ -0,0 +1,15 @@
package com.codesdream.ase.component.json.request;
import lombok.Data;
import java.util.Date;
@Data
public class UserLeaveRequest {
private String UserId;//用户名
private String Type;//请假类型
private String Reason;//请假原因
private String Addon;//附件
private Date Starttime;//开始时间
private Date EndTime;//结束时间
}

View File

@ -0,0 +1,8 @@
package com.codesdream.ase.component.json.request;
import lombok.Data;
@Data
public class UserSGettudentLeaveListRequest {
private int studentId;
}

View File

@ -0,0 +1,16 @@
package com.codesdream.ase.component.json.respond;
import com.sun.org.apache.xpath.internal.operations.Bool;
import lombok.Data;
import java.util.List;
import java.util.Set;
@Data
public class PermissionJSONRespond {
private Boolean tagExist = null;
private Boolean actionSuccess = null;
private Integer tagId = null;
private String tagName = null;
private Set<Integer> users = null;
}

View File

@ -12,5 +12,6 @@ public class UserLoginCheckerJSONRespond {
String respondInformation = null;
String token = null;
String uid = null;
String pvc = null;
}

View File

@ -5,15 +5,14 @@ import org.springframework.security.core.GrantedAuthority;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
@Component
public class UserAuthoritiesGenerator {
@Resource
UserRolesListGenerator userRolesListGenerator;
public Collection<? extends GrantedAuthority> grantedAuthorities(User user){
return userRolesListGenerator.generateRoles(user);
return new ArrayList<>();
}
}

View File

@ -1,41 +0,0 @@
package com.codesdream.ase.component.permission;
import com.codesdream.ase.model.permission.*;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
/**
* 生成功能性权限容器列表
*/
@Component
public class UserFPCListGenerator {
@Resource
private UserFSRGenerator fsrListGenerator;
public Collection<FunctionalPermissionContainer> generateFPC(
Collection<FunctionalScopeRelation> functionalScopeRelations){
Collection<FunctionalPermissionContainer> functionalPermissionContainers
= new ArrayList<>();
for (FunctionalScopeRelation functionalScopeRelation : functionalScopeRelations){
functionalPermissionContainers.add(functionalScopeRelation.getFunctionalPermissionContainer());
}
return functionalPermissionContainers;
}
public Collection<FunctionalPermissionContainer> generateFPCs(User user){
return generateFPC(
fsrListGenerator.generateFSRs(user)
);
}
public Collection<FunctionalPermissionContainer> generateFPCs(String username){
return generateFPC(
fsrListGenerator.generateFSRs(username)
);
}
}

View File

@ -1,45 +0,0 @@
package com.codesdream.ase.component.permission;
import com.codesdream.ase.model.permission.FunctionalScopeRelation;
import com.codesdream.ase.model.permission.PermissionContainersCollection;
import com.codesdream.ase.model.permission.User;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
/**
* 生成功能性权限容器与范围性权限容器关联对列表
*/
@Component
public class UserFSRGenerator {
@Resource
private UserPCCListGenerator userPCCListGenerator;
public Collection<FunctionalScopeRelation> generateFSRs(
Collection<PermissionContainersCollection> pccs){
Collection<FunctionalScopeRelation> fsrs =
new ArrayList<>();
for(PermissionContainersCollection pcc : pccs){
fsrs.addAll(pcc.getFunctionalScopeRelations());
}
return fsrs;
}
public Collection<FunctionalScopeRelation> generateFSRs(
User user){
return generateFSRs(
userPCCListGenerator.generatePCCs(user));
}
public Collection<FunctionalScopeRelation> generateFSRs(
String username){
return generateFSRs(
userPCCListGenerator.generatePCCs(username));
}
}

View File

@ -1,39 +0,0 @@
package com.codesdream.ase.component.permission;
import com.codesdream.ase.model.permission.PermissionContainersCollection;
import com.codesdream.ase.model.permission.Tag;
import com.codesdream.ase.model.permission.User;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
/**
* 生成权限容器集合列表
*/
@Component
public class UserPCCListGenerator {
@Resource
private UserTagsListGenerator userTagsListGenerator;
public Collection<PermissionContainersCollection> generatePCCs(
Collection<Tag> tags){
Collection<PermissionContainersCollection> pccs =
new ArrayList<>();
for(Tag tag : tags){
pccs.addAll(tag.getPermissionContainersCollections());
}
return pccs;
}
public Collection<PermissionContainersCollection> generatePCCs(
User user) {
return generatePCCs(userTagsListGenerator.generateTags(user));
}
public Collection<PermissionContainersCollection> generatePCCs(
String username){
return generatePCCs(userTagsListGenerator.generateTags(username));
}
}

View File

@ -1,44 +0,0 @@
package com.codesdream.ase.component.permission;
import com.codesdream.ase.model.permission.FunctionalPermissionContainer;
import com.codesdream.ase.model.permission.User;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
/**
* 生成用户访问权限角色列表
*/
@Component
public class UserRolesListGenerator {
@Resource
private UserFPCListGenerator fpcListGenerator;
public Collection<GrantedAuthority> generateRoles(
Collection<FunctionalPermissionContainer> fpcs){
Collection<GrantedAuthority> authorities = new ArrayList<>();
for(FunctionalPermissionContainer fpc :fpcs){
for(String role :fpc.getRoles()){
authorities.add(new SimpleGrantedAuthority(role));
}
}
return authorities;
}
public Collection<GrantedAuthority> generateRoles(String username){
return generateRoles(
fpcListGenerator.generateFPCs(username)
);
}
public Collection<GrantedAuthority> generateRoles(User user){
return generateRoles(
fpcListGenerator.generateFPCs(user)
);
}
}

View File

@ -1,54 +0,0 @@
package com.codesdream.ase.component.permission;
import com.codesdream.ase.model.permission.ScopePermissionContainer;
import com.codesdream.ase.model.permission.Tag;
import com.codesdream.ase.model.permission.User;
import com.codesdream.ase.repository.permission.UserRepository;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
/**
* 生成用户标签列表
*/
@Component
public class UserTagsListGenerator {
@Resource
UserRepository userRepository;
public Collection<Tag> generateTags(ScopePermissionContainer spc){
return new ArrayList<>(spc.getTags());
}
public Collection<Tag> generateTags(User user){
return new ArrayList<Tag>(user.getTags());
}
public Collection<Tag> generateTags(String username){
Optional<User> user = userRepository.findByUsername(username);
// 检查用户是否存在
if(!user.isPresent()) throw new RuntimeException("User Not Found");
return generateTags(user.get());
}
public Collection<String> generateTagsName(User user){
Collection<String> tagsName = new ArrayList<>();
Collection<Tag> tags = generateTags(user);
for(Tag tag : tags){
tagsName.add(tag.getName());
}
return tagsName;
}
public Collection<String> generateTagsName(String username){
Optional<User> user = userRepository.findByUsername(username);
if(!user.isPresent()) throw new RuntimeException("User Not Found");
return generateTagsName(user.get());
}
}

View File

@ -1,22 +0,0 @@
package com.codesdream.ase.component.permission;
import com.codesdream.ase.model.permission.Tag;
import com.codesdream.ase.model.permission.User;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Collection;
/**
* 生成用户列表
*/
@Component
public class UsersListGenerator {
public Collection<User> generateUsers(Collection<Tag> tags){
Collection<User> users = new ArrayList<>();
for(Tag tag : tags){
users.addAll(tag.getUsers());
}
return users;
}
}

View File

@ -0,0 +1,19 @@
package com.codesdream.ase.component.student;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class MemberInfo {
private int memberId;
// -1创建人 0管理员 1普通参与者
private int memberType;
public MemberInfo(int memberId, int memberType){
this.memberId = memberId;
this.memberType = memberType;
}
}

View File

@ -0,0 +1,26 @@
package com.codesdream.ase.component.student;
import lombok.Data;
import java.util.Date;
@Data
public class SubjectScore {
private int studentId;
private String subject;
private float credit;
private float score;
private Date finishedDate;
private boolean isFailed;
public boolean getIsFailed(){
return this.isFailed;
}
}

View File

@ -0,0 +1,57 @@
package com.codesdream.ase.configure;
import com.google.common.collect.Sets;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.core.parameters.P;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Configuration
@EnableSwagger2
public class ASESwaggerConfigure {
@Bean
public Docket createRestApi() {
List<Parameter> pars = new ArrayList<Parameter>();
pars.add(new ParameterBuilder().name("username").description("真实用户名").hidden(true).order(1)
.modelRef(new ModelRef("string")).parameterType("header")
.required(false).defaultValue("u_id_88883b9e023c8824310760d8bb8b6542e5a3f16a0d67253214e01ee7ab0e96a1").build());
pars.add(new ParameterBuilder().name("signed").description("客户端签名").hidden(true).order(2)
.modelRef(new ModelRef("string")).parameterType("header")
.required(false).defaultValue("6d4923fca4dcb51f67b85e54a23a8d763d9e02af").build());
pars.add(new ParameterBuilder().name("timestamp").description("时间戳").hidden(true).order(3)
.modelRef(new ModelRef("string")).parameterType("header")
.required(false).defaultValue(Long.toString(new Date().getTime())).build());
return new Docket(DocumentationType.SWAGGER_2)
.protocols(Sets.newHashSet("http"))
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.codesdream.ase.controller"))
.paths(PathSelectors.any())
.build()
.globalOperationParameters(pars);
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("全员育人管理系统后端接口定义")
.version("0.0.1")
.description("用于对后端接口进行说明")
.build();
}
}

View File

@ -30,6 +30,7 @@ public class ActivityFormConfigure {
add("attendance");
}};
public HashSet<String> getStdActivityForm() {
return stdActivityForm;
}

View File

@ -39,4 +39,5 @@ public class AppConfigure {
public String getOrganization() {
return "全员育人WEB端开发组";
}
}

View File

@ -1,10 +1,9 @@
package com.codesdream.ase.configure;
import com.codesdream.ase.component.permission.*;
import com.codesdream.ase.component.auth.*;
import com.codesdream.ase.service.ASEUserDetailsService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
@ -13,12 +12,10 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.session.SessionRegistry;
import org.springframework.security.core.session.SessionRegistryImpl;
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.authentication.session.CompositeSessionAuthenticationStrategy;
import org.springframework.security.web.authentication.session.ConcurrentSessionControlAuthenticationStrategy;
import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy;
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
import org.springframework.security.web.context.SecurityContextPersistenceFilter;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import javax.annotation.Resource;
@ -52,6 +49,9 @@ public class CustomWebSecurityConfig extends WebSecurityConfigurerAdapter {
@Resource
ASEAccessDeniedHandler accessDeniedHandler;
@Resource
ASESecurityInterceptor securityInterceptor;
@Override
protected void configure(HttpSecurity http) throws Exception {
@ -68,7 +68,8 @@ public class CustomWebSecurityConfig extends WebSecurityConfigurerAdapter {
// 替换掉原有的UsernamePasswordAuthenticationFilter
http.addFilterAt(aseUsernamePasswordAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class)
.addFilterBefore(asejsonTokenAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
.addFilterBefore(asejsonTokenAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class)
.addFilterAt(securityInterceptor, FilterSecurityInterceptor.class);
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
@ -91,7 +92,13 @@ public class CustomWebSecurityConfig extends WebSecurityConfigurerAdapter {
"/forget/**",
"/not_found/**",
"/error/**",
"/login/**");
"/login/**",
"/swagger-ui.html",
"/webjars/**",
"/swagger-resources/**",
"/v2/api-docs",
"/configuration/ui",
"/configuration/security");
}
//注册自定义的UsernamePasswordAuthenticationFilter

View File

@ -1,31 +1,77 @@
package com.codesdream.ase.controller;
import com.codesdream.ase.component.error.ErrorResponse;
import com.codesdream.ase.component.api.QuickJSONRespond;
import com.codesdream.ase.component.json.respond.ErrorInfoJSONRespond;
import com.codesdream.ase.exception.badrequest.AlreadyExistException;
import com.codesdream.ase.exception.badrequest.IllegalException;
import com.codesdream.ase.exception.conflict.RelatedObjectsExistException;
import com.codesdream.ase.exception.innerservererror.FormatException;
import com.codesdream.ase.exception.innerservererror.HandlingErrorsException;
import com.codesdream.ase.exception.innerservererror.RuntimeIOException;
import com.codesdream.ase.exception.notfound.NotFoundException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.core.AuthenticationException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.WebRequest;
import java.util.ArrayList;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@RestControllerAdvice
public class ASEControllerAdvice {
@ExceptionHandler(value = {RuntimeException.class})
public final Object handleRuntimeException(RuntimeException e, WebRequest webRequest){
@Resource
private QuickJSONRespond quickJSONRespond;
@ExceptionHandler(value = {
NullPointerException.class,
AlreadyExistException.class,
IllegalException.class
})
public ResponseEntity<Object> handleBadRequest(Exception ex) {
return getResponse(HttpStatus.BAD_REQUEST, ex);
}
@ExceptionHandler(value = {NotFoundException.class})
public ResponseEntity<Object> handleNotFound(Exception ex) {
return getResponse(HttpStatus.NOT_FOUND, ex);
}
@ExceptionHandler(value = {})
public ResponseEntity<Object> handleNotAcceptable(Exception ex) {
return getResponse(HttpStatus.NOT_ACCEPTABLE, ex);
}
@ExceptionHandler(value = {RelatedObjectsExistException.class})
public ResponseEntity<Object> handleConflict(Exception ex) {
return getResponse(HttpStatus.CONFLICT, ex);
}
@ExceptionHandler(value = {
HandlingErrorsException.class,
FormatException.class,
RuntimeIOException.class})
public ResponseEntity<Object> handleInnerServerError(Exception ex){
return getResponse(HttpStatus.INTERNAL_SERVER_ERROR, ex);
}
private ResponseEntity<Object> getResponse(HttpStatus status, Exception ex){
return ResponseEntity.status(status).body(getJSON(status, ex));
}
private String getJSON(HttpStatus status, Exception ex){
return quickJSONRespond.getJSONStandardRespond(status, getJSONRespondObject(ex));
}
private Object getJSONRespondObject(Exception ex){
ErrorInfoJSONRespond errorInfoJSONRespond = new ErrorInfoJSONRespond();
errorInfoJSONRespond.setException(ex.getClass().getName());
errorInfoJSONRespond.setExceptionMessage(ex.getMessage());
errorInfoJSONRespond.setDate(new Date());
errorInfoJSONRespond.setExceptionMessage(e.getMessage());
errorInfoJSONRespond.setException(e.getClass().getName());
return errorInfoJSONRespond;
}
}

View File

@ -1,24 +1,16 @@
package com.codesdream.ase.controller;
import com.codesdream.ase.component.datamanager.QuickJSONRespond;
import com.codesdream.ase.component.error.ErrorResponse;
import com.codesdream.ase.component.api.QuickJSONRespond;
import com.codesdream.ase.component.json.respond.ErrorInfoJSONRespond;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.WebRequest;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Controller
public class ASEErrorController implements ErrorController {
@ -80,7 +72,7 @@ public class ASEErrorController implements ErrorController {
return quickJSONRespond.getJSONStandardRespond(
statusCode,
"Error Controller Handle",
"Internal Server Error",
null,
errorInfoJSONRespond);
}

View File

@ -1,61 +0,0 @@
package com.codesdream.ase.controller;
import com.alibaba.fastjson.JSONObject;
import com.codesdream.ase.component.ASESpringUtil;
import com.codesdream.ase.component.datamanager.JSONParameter;
import com.codesdream.ase.configure.ActivityFormConfigure;
import com.codesdream.ase.exception.InvalidFormFormatException;
import com.codesdream.ase.exception.LackOfActivityInformation;
import com.codesdream.ase.model.activity.Activity;
import com.codesdream.ase.service.ActivityService;
import com.codesdream.ase.validator.NullValueValidator;
import com.codesdream.ase.validator.WebFormValidator;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.Null;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@Controller
public class ActivityController {
@Resource
ActivityService activityService;
@Resource
JSONParameter jsonParameter;
@RequestMapping(value = "/activity_creator")
String activityCreatorView(Model model){return "activity_creator";}
@PostMapping(value = "/activity_creator")
String activityCreator(Model model, HttpServletRequest request) throws InvalidFormFormatException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
Map<String, String[]> parameterMap = request.getParameterMap();
ASESpringUtil aseSpringUtil = new ASESpringUtil();
ActivityFormConfigure activityFormConfigure = aseSpringUtil.getBean(ActivityFormConfigure.class);
WebFormValidator webFormValidator = aseSpringUtil.getBean(WebFormValidator.class);
if(!webFormValidator.check(activityFormConfigure.getStdActivityForm(), parameterMap)) {
throw new InvalidFormFormatException("Invalid activity form.");
}
// 需要检查JSON是否合法
Optional<JSONObject> jsonObject = jsonParameter.getJSONByRequest(request);
if(!jsonObject.isPresent()) return "error";
Activity activity = jsonObject.get().toJavaObject(Activity.class);
NullValueValidator nullValueValidator = aseSpringUtil.getBean(NullValueValidator.class);
List<String> nullValues = nullValueValidator.checkNullValues(activity);
return "act_created";
}
}

View File

@ -0,0 +1,9 @@
package com.codesdream.ase.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("file")
public class FileController {
}

View File

@ -1,35 +0,0 @@
package com.codesdream.ase.controller;
import com.codesdream.ase.model.permission.User;
import com.codesdream.ase.service.IUserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import java.security.Principal;
import java.util.Optional;
@Controller
public class HomeController {
@Resource
IUserService userService;
@RequestMapping(value = "/home")
public String showHomeView(Model model, Principal principal){
User user = userService.findUserByUsername(principal.getName());
// 为视图模板指定参数
model.addAttribute("username", user.getUsername().substring(0, 18));
model.addAttribute("real_name", user.getUserDetail().getRealName());
model.addAttribute("sex", user.getUserDetail().getSex());
model.addAttribute("student_id", user.getUserAuth().getStudentID());
model.addAttribute("class_id", user.getUserDetail().getClassId());
model.addAttribute("college", user.getUserDetail().getBaseCollege().getName());
model.addAttribute("ethnic", user.getUserDetail().getBaseEthnic().getName());
model.addAttribute("major", user.getUserDetail().getBaseMajor().getName());
model.addAttribute("is_at_school", user.getUserDetail().isAtSchool());
model.addAttribute("ethnic", user.getUserDetail().getBaseEthnic().getName());
model.addAttribute("mail", user.getUserAuth().getMail());
return "home";
}
}

View File

@ -2,16 +2,17 @@ package com.codesdream.ase.controller;
import com.alibaba.fastjson.JSONObject;
import com.codesdream.ase.component.datamanager.JSONParameter;
import com.codesdream.ase.component.datamanager.QuickJSONRespond;
import com.codesdream.ase.component.api.QuickJSONRespond;
import com.codesdream.ase.component.json.respond.JSONStandardFailedRespond;
import com.codesdream.ase.component.json.respond.JSONBaseRespondObject;
import com.codesdream.ase.component.permission.ASEUsernameEncoder;
import com.codesdream.ase.component.json.request.UserLoginChecker;
import com.codesdream.ase.component.json.respond.UserLoginCheckerJSONRespond;
import com.codesdream.ase.service.IAuthService;
import com.codesdream.ase.service.IUserService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@ -26,6 +27,7 @@ import java.util.Optional;
*/
@Slf4j
@Controller
@Api(tags = "用户登录有关接口")
public class LoginController {
@Resource
@ -38,20 +40,15 @@ public class LoginController {
private IUserService userService;
@Resource
private ASEUsernameEncoder usernameEncoder;
private IAuthService authService;
@RequestMapping(value = "/login")
String printLogin(Model model) {
return "login";
}
@RequestMapping(value = "/login/check_exists", method = RequestMethod.POST)
@PostMapping(value = "/login/check_exists")
@ResponseBody
String checkExists(HttpServletRequest request){
// 检查是否为JSON
Optional<JSONObject> json = jsonParameter.getJSONByRequest(request);
if(!json.isPresent()) return jsonParameter.getJSONString(new JSONStandardFailedRespond());
if(!json.isPresent()) return quickJSONRespond.getRespond400("Invalid JSON Form");
UserLoginChecker loginChecker = json.get().toJavaObject(UserLoginChecker.class);
@ -77,12 +74,22 @@ public class LoginController {
@RequestMapping(value = "/login/check_uid", method = RequestMethod.POST)
@ResponseBody
String checkUsernameByStudentID(HttpServletRequest request){
String preValidationCode = request.getHeader("pvc");
// 检查随机预验证码
if(preValidationCode == null || !authService.preValidationCodeChecker(preValidationCode))
return quickJSONRespond.getRespond403("Invalid PreValidationCode");
// 检查是否为JSON
Optional<JSONObject> json = jsonParameter.getJSONByRequest(request);
if(!json.isPresent()) return jsonParameter.getJSONString(new JSONStandardFailedRespond());
UserLoginChecker loginChecker = json.get().toJavaObject(UserLoginChecker.class);
if(loginChecker.getUsername() == null || loginChecker.getCheckType() == null)
return quickJSONRespond.getRespond406("Request Violates The Interface Protocol");
if(loginChecker.getCheckType().equals("UIDGeneratorChecker")) {
UserLoginCheckerJSONRespond respond = new UserLoginCheckerJSONRespond();
respond.setUid(userService.getUsernameByStudentId(loginChecker.getUsername()));
@ -92,8 +99,6 @@ public class LoginController {
// 返回失败对象
return quickJSONRespond.getRespond400("CheckType Mismatch");
}
}

View File

@ -0,0 +1,28 @@
package com.codesdream.ase.controller;
import com.codesdream.ase.model.message.Notification;
import com.codesdream.ase.model.permission.User;
import com.codesdream.ase.service.MessageService;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("message")
public class MessageController {
@Resource
MessageService messageService;
@PostMapping("notification/create")
@ResponseStatus(HttpStatus.CREATED)
public Notification createNotification (@RequestBody String title, @RequestBody String context,
@RequestBody List<Integer> files, Authentication authentication){
User user = (User)authentication.getPrincipal();
return null;//messageService.createNotification(title,context,);
}
}

View File

@ -1,7 +1,7 @@
package com.codesdream.ase.controller;
import com.codesdream.ase.component.datamanager.JSONParameter;
import com.codesdream.ase.component.datamanager.QuickJSONRespond;
import com.codesdream.ase.component.api.QuickJSONRespond;
import com.codesdream.ase.component.json.request.UserRegisterChecker;
import com.codesdream.ase.model.information.BaseStudentInfo;
import com.codesdream.ase.model.permission.User;
@ -18,6 +18,7 @@ import javax.servlet.http.HttpServletRequest;
import java.util.Optional;
@Controller
@RequestMapping("register")
public class RegisterController {
@Resource
private UserService userService;
@ -31,13 +32,22 @@ public class RegisterController {
@Resource
private QuickJSONRespond quickJSONRespond;
@RequestMapping(value = "/register")
@RequestMapping(value = "")
String registerView(Model model){
return "register";
}
@PostMapping(value="baseinfo")
@ResponseBody
String addBaseInfo(){
BaseStudentInfo bsi = baseInformationService.constructStudentInfo("2018303209", "14011809", "Jack",
"","软件学院","软件工程","汉族","群众","未知");
baseInformationService.save(bsi);
return "OK";
}
// 处理注册表单
@PostMapping(value = "/register/do_register")
@PostMapping(value = "user")
@ResponseBody
String doRegister(HttpServletRequest request){
@ -78,7 +88,7 @@ public class RegisterController {
BaseStudentInfo studentInfo = baseInformationService.findStudentInfoByStudentId(student_id);
// 根据基本信息生成对应用户
User user = userService.getUserByStudentInfo(studentInfo);
User user = userService.createUserByStudentInfo(studentInfo);
// 填充密保问题
user.getUserAuth().setUserQuestion(user_question);

View File

@ -0,0 +1,15 @@
package com.codesdream.ase.controller;
import com.codesdream.ase.model.message.Notification;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("student")
public class StudentController {
}

View File

@ -0,0 +1,39 @@
package com.codesdream.ase.controller;
import com.codesdream.ase.model.student.Comment;
import com.codesdream.ase.repository.student.CommentRepository;
import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("test")
public class TestController {
@Resource
private CommentRepository commentRepository;
@GetMapping("")
@ResponseStatus(HttpStatus.OK)
public boolean test() throws InterruptedException {
String userId = "1";
for (int i = 0;i < 10; i++){
Comment comment = new Comment();
comment.setUserId(userId);
comment.setContext(new Integer(i).toString());
commentRepository.save(comment);
Thread.sleep(20);
}
Thread.sleep(1000);
List<Comment> comments = commentRepository.findByUserId(userId,
Sort.by(Sort.Direction.DESC, "date"));
if(!comments.isEmpty()){
System.out.println(comments.toString());
}
return true;
}
}

View File

@ -0,0 +1,64 @@
package com.codesdream.ase.controller;
import com.codesdream.ase.component.datamanager.JSONParameter;
import com.codesdream.ase.component.json.model.JsonableUser;
import com.codesdream.ase.exception.notfound.NotFoundException;
import com.codesdream.ase.model.permission.User;
import com.codesdream.ase.service.UserService;
import com.github.fge.jsonpatch.JsonPatch;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
@RestController
@RequestMapping(value = "pmt")
@Api(tags = "用户管理接口")
public class UserController {
@Resource
private UserService userService;
@Resource
private JSONParameter jsonParameter;
@GetMapping("user")
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "查找用户")
public JsonableUser getUser(@RequestParam(value = "id") Integer id){
Optional<User> user = userService.findUserById(id);
if(!user.isPresent()) throw new NotFoundException(id.toString());
return new JsonableUser(user.get());
}
@GetMapping("users")
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "获得所有用户的信息")
public Set<JsonableUser> listUser(){
Iterable<User> users = userService.findAll();
Set<JsonableUser> jsonableUsers = new HashSet<>();
for(User user : users){
jsonableUsers.add(new JsonableUser(user));
}
return jsonableUsers;
}
@PatchMapping("user")
@ResponseStatus(HttpStatus.CREATED)
@ApiOperation(value = "更新标用户的部分信息")
public JsonableUser patchUser(@RequestParam(value = "id") Integer id, @RequestBody JsonPatch patch){
Optional<User> userOptional = userService.findUserById(id);
if(!userOptional.isPresent()) throw new NotFoundException(id.toString());
JsonableUser jsonableUser = new JsonableUser(userOptional.get());
jsonableUser = jsonParameter.parsePathToObject(patch, jsonableUser);
return new JsonableUser(userService.update(jsonableUser.parseObject(userOptional.get())));
}
}

View File

@ -1,15 +0,0 @@
package com.codesdream.ase.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class DataFileNotFoundException extends RuntimeException {
private String path;
public DataFileNotFoundException(String filePath){
super();
this.path = filePath;
}
}

View File

@ -1,9 +0,0 @@
package com.codesdream.ase.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class DataIOException extends RuntimeException {
}

View File

@ -1,9 +0,0 @@
package com.codesdream.ase.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class DataIllegalTableFormatException extends RuntimeException {
}

View File

@ -1,15 +0,0 @@
package com.codesdream.ase.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class DataInvalidFormatException extends RuntimeException {
String information;
public DataInvalidFormatException(Exception e){
super();
information = e.getMessage();
}
}

View File

@ -1,14 +0,0 @@
package com.codesdream.ase.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class LackOfActivityInformation extends Throwable {
private String message = "";
public LackOfActivityInformation(){super();}
public LackOfActivityInformation(String message){this.message = message;}
}

View File

@ -0,0 +1,18 @@
package com.codesdream.ase.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class LackOfActivityInformationException extends Throwable {
private String message = "";
public LackOfActivityInformationException() {
super();
}
public LackOfActivityInformationException(String message) {
this.message = message;
}
}

View File

@ -0,0 +1,12 @@
package com.codesdream.ase.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class StringFileConvertException extends RuntimeException {
public StringFileConvertException(String msg){
super(msg);
}
}

View File

@ -0,0 +1,14 @@
package com.codesdream.ase.exception.badrequest;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class AlreadyExistException extends RuntimeException {
public AlreadyExistException(String msg){
super(msg);
}
}

View File

@ -1,16 +1,16 @@
package com.codesdream.ase.exception;
package com.codesdream.ase.exception.badrequest;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class BaseInformationAlreadyExistException extends RuntimeException {
public class BaseInformationAlreadyExistException extends AlreadyExistException {
private String className;
private String value;
public BaseInformationAlreadyExistException(Class<?> aClass, String value){
super();
super(String.format("%s: %s", aClass.getName(), value));
this.className = aClass.getName();
this.value = value;
}

View File

@ -1,11 +1,11 @@
package com.codesdream.ase.exception;
package com.codesdream.ase.exception.badrequest;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class BaseInformationIllegalException extends RuntimeException {
public class BaseInformationIllegalException extends IllegalException {
String type;
String value;

View File

@ -0,0 +1,10 @@
package com.codesdream.ase.exception.badrequest;
import lombok.NoArgsConstructor;
@NoArgsConstructor
public class IllegalException extends RuntimeException {
public IllegalException(String msg){
super(msg);
}
}

View File

@ -1,11 +1,11 @@
package com.codesdream.ase.exception;
package com.codesdream.ase.exception.badrequest;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class UserInformationIllegalException extends RuntimeException {
public class UserInformationIllegalException extends IllegalException {
String username;

View File

@ -1,16 +1,16 @@
package com.codesdream.ase.exception;
package com.codesdream.ase.exception.badrequest;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class UsernameAlreadyExistException extends RuntimeException {
public class UsernameAlreadyExistException extends AlreadyExistException {
String username;
public UsernameAlreadyExistException(String username){
super();
super(username);
this.username = username;
}
}

View File

@ -0,0 +1,11 @@
package com.codesdream.ase.exception.conflict;
public class FileNameConflict extends RuntimeException {
public String conflictName;
public FileNameConflict(String msg,String conflictName)
{
super(msg);
this.conflictName = conflictName;
}
}

View File

@ -0,0 +1,13 @@
package com.codesdream.ase.exception.conflict;
import lombok.NoArgsConstructor;
/**
* 存在与之相关联的对象
*/
@NoArgsConstructor
public class RelatedObjectsExistException extends RuntimeException {
public RelatedObjectsExistException(String msg){
super(msg);
}
}

View File

@ -0,0 +1,9 @@
package com.codesdream.ase.exception.innerservererror;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class DataIOException extends RuntimeIOException {
}

View File

@ -0,0 +1,9 @@
package com.codesdream.ase.exception.innerservererror;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class DataIllegalTableFormatException extends FormatException {
}

View File

@ -0,0 +1,23 @@
package com.codesdream.ase.exception.innerservererror;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class DataInvalidFormatException extends FormatException {
String information;
public DataInvalidFormatException(Exception e){
super();
information = e.getMessage();
}
public DataInvalidFormatException(){
super();
}
public DataInvalidFormatException(String s) {
information = s;
}
}

View File

@ -0,0 +1,10 @@
package com.codesdream.ase.exception.innerservererror;
import lombok.NoArgsConstructor;
@NoArgsConstructor
public class FormatException extends RuntimeException {
public FormatException(String msg){
super(msg);
}
}

View File

@ -0,0 +1,15 @@
package com.codesdream.ase.exception.innerservererror;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
// 处理错误对应的异常类
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class HandlingErrorsException extends RuntimeException {
public HandlingErrorsException(String msg){
super(msg);
}
}

View File

@ -0,0 +1,16 @@
package com.codesdream.ase.exception.innerservererror;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class InvalidDataException extends FormatException{
private String message;
public InvalidDataException(String message){
super(message);
this.message = message;
}
}

View File

@ -1,4 +1,4 @@
package com.codesdream.ase.exception;
package com.codesdream.ase.exception.innerservererror;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -7,9 +7,9 @@ import javax.persistence.criteria.CriteriaBuilder;
@EqualsAndHashCode(callSuper = true)
@Data
public class InvalidFormFormatException extends Throwable {
public class InvalidFormFormatException extends FormatException {
private String message = "";
private String message = "Invalid form format";
public InvalidFormFormatException(){
super();

View File

@ -0,0 +1,10 @@
package com.codesdream.ase.exception.innerservererror;
import lombok.NoArgsConstructor;
@NoArgsConstructor
public class RuntimeIOException extends RuntimeException {
public RuntimeIOException(String msg){
super(msg);
}
}

View File

@ -0,0 +1,15 @@
package com.codesdream.ase.exception.notfound;
import java.io.IOException;
public class AppendixFileNotFoundException extends IOException {
public int id;
public int type;
public static final int ID_NOT_FOUND = 1, FILE_NOT_fOUND = 2, STREAM_FAILURE = 3;
public AppendixFileNotFoundException(String msg,int id,int type){
super(msg);
this.id = id;
this.type = type;
}
}

View File

@ -1,16 +1,16 @@
package com.codesdream.ase.exception;
package com.codesdream.ase.exception.notfound;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class BaseInformationNotExistException extends RuntimeException {
public class BaseInformationNotFoundException extends NotFoundException {
private String className;
private String value;
public BaseInformationNotExistException(Class<?> baseInformationClass, String value){
super();
public BaseInformationNotFoundException(Class<?> baseInformationClass, String value){
super(String.format("%s: %s", baseInformationClass.getName(), value));
this.className = baseInformationClass.getName();
this.value = value;
}

View File

@ -0,0 +1,15 @@
package com.codesdream.ase.exception.notfound;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class DataFileNotFoundException extends NotFoundException {
private String path;
public DataFileNotFoundException(String msg){
super(msg);
this.path = msg;
}
}

View File

@ -0,0 +1,12 @@
package com.codesdream.ase.exception.notfound;
public class NotFoundException extends RuntimeException {
public NotFoundException(String msg){
super(msg);
}
public NotFoundException(){
super();
}
}

View File

@ -0,0 +1,11 @@
package com.codesdream.ase.exception.notfound;
public class TagNotFoundException extends NotFoundException {
String tagName;
public TagNotFoundException(String tagName){
super(tagName);
this.tagName = tagName;
}
}

View File

@ -1,17 +1,20 @@
package com.codesdream.ase.exception;
package com.codesdream.ase.exception.notfound;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class UserNotFoundException extends RuntimeException {
public class UserNotFoundException extends NotFoundException {
Integer id;
String username;
public UserNotFoundException(Integer id, String username){
super();
this.id = id;
this.username = username;
}
public UserNotFoundException(String msg){
super(msg);
}
}

View File

@ -1,199 +1,51 @@
package com.codesdream.ase.model.activity;
import com.codesdream.ase.model.permission.User;
import com.codesdream.ase.model.file.File;
import com.codesdream.ase.model.mark.Tag;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.parameters.P;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.*;
@Data
@Entity
@Table(name = "activity")
@Table
@Data
public class Activity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
int id;
//活动标题
@Column(name = "title", nullable = false)
private String title;
String title;
//创建人
@ManyToOne(cascade = CascadeType.MERGE)
@JoinColumn(nullable = false)
private User creator;
int creatorId;
//活动类型
@Column(nullable = false)
private String type;
@ElementCollection
List<Integer> managerIds = new ArrayList<>();
//活动描述
@Column
private String description;
@ElementCollection
List<Integer> participantIds = new ArrayList<>();
//活动周期格式阿拉伯数字数字+单位0表示无周期
@Column
private String cycle;
@ElementCollection
List<Integer> absentees = new ArrayList<>();
//自愿参与人列表
@ManyToMany(cascade = CascadeType.DETACH)
@JoinTable(name = "act_volunteer")
private Set<User> volunteers;
// 活动出勤情况对应人员是否出勤
@ElementCollection
Map<Integer, Boolean> attendance = new HashMap<>();
//参与人列表
@ManyToMany(cascade = CascadeType.DETACH)
@JoinTable(name = "act_participate",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "participate_id")
}
)
private Set<User> participateGroup;
@OneToMany(cascade = CascadeType.MERGE)
List<File> appendixes = new ArrayList<>();
//实际参与人列表
@ManyToMany(cascade = CascadeType.DETACH)
@JoinTable(name = "act_participated",
joinColumns = {
@JoinColumn(name = "act_id" )
},
inverseJoinColumns = {
@JoinColumn(name = "participated_id")
}
)
private Set<User> participatedGroup;
//可报名人员列表
@ManyToMany(cascade = CascadeType.DETACH)
@JoinTable(name = "act_sign",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "sign_id")
}
)
private Set<User> signGroup;
Date registrationDDL;
Date creationTime = new Date();
Date realBeginDate;
Date realEndDate;
//已报名人员列表
@ManyToMany(cascade = CascadeType.MERGE)
@JoinTable(name = "act_signed",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "signed_id")
}
)
private Set<User> signedGroup;
List<Tag> tags = new ArrayList<>();
//可见人员列表
@ManyToMany(cascade = CascadeType.DETACH)
@JoinTable(name = "act_vis",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "vis_id")
}
)
private Set<User> visibleGroup;
//通知人员列表
@ManyToMany(cascade = CascadeType.DETACH)
@JoinTable(name = "act_inform",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "inform_id")
}
)
private Set<User> informGroup;
//已通知人员列表
@ManyToMany(cascade = CascadeType.DETACH)
@JoinTable(name = "act_informed",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "informed_id")
}
)
private Set<User> informedGroup;
//计划开始时间
@OneToOne(cascade = CascadeType.ALL)
private Period planPeriod;
//实际开始时间
@OneToOne(cascade = CascadeType.ALL)
private Period realPeriod;
//提前提醒时间
@Column(name = "remind_time", nullable = true)
private LocalDateTime remindTime;
//附件组(名字)
@ElementCollection(targetClass = String.class)
private List<String> enclosures;
//主要负责人
@OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
@JoinColumn(nullable = false)
private User chiefManager;
//次要负责人
@OneToMany(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
@JoinColumn(name = "act_id")
private Set<User> assistManagers;
//是否开始
@Column//(name = "is_on", nullable = false)
boolean isOn;
//是否结束
@Column//(name = "is_off", nullable = false)
boolean isOff;
//考勤安排
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Attendance attendance;
//活动报告
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Report report;
public Activity(){
initDefault();
}
private void initDefault(){
this.title = "";
this.creator = new User();
this.type = "";
this.description = "";
this.cycle = "";
this.volunteers = new HashSet<>();
this.participateGroup = new HashSet<>();
this.participatedGroup = new HashSet<>();
this.participatedGroup = new HashSet<>();
this.signGroup = new HashSet<>();
this.signedGroup = new HashSet<>();
this.visibleGroup = new HashSet<>();
this.informGroup = new HashSet<>();
this.informedGroup = new HashSet<>();
this.planPeriod = new Period();
this.realPeriod = new Period();
this.enclosures = new ArrayList<>();
this.chiefManager = new User();
this.assistManagers = new HashSet<>();
this.isOn = false;
this.isOff = false;
}
@OneToOne(cascade = CascadeType.MERGE)
Report report;
}

View File

@ -1,33 +0,0 @@
package com.codesdream.ase.model.activity;
import lombok.Data;
import javax.persistence.*;
import java.util.List;
import java.util.Set;
@Data
@Entity
@Table(name = "attendance")
public class Attendance {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
//二维码url
@Column(name = "qr_code")//, nullable = false, unique = true)
private String QRCode;
//是否在线
@Column(name = "is_online")//, nullable = false)
private boolean isOnline;
//打卡时段列表
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private Set<Period> clockInPeriods;
//打卡方式0表示被扫1表示扫
@Column//(nullable = false)
private boolean means;
}

View File

@ -1,32 +0,0 @@
package com.codesdream.ase.model.activity;
import lombok.Data;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Calendar;
import java.util.Date;
import java.util.Objects;
@Entity
@Table(name = "period_container")
@Data
public class Period {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
//开始时间
@Column(name = "start_time")//, nullable = false)
private LocalDateTime startTime = LocalDateTime.of(2020,2,18,16,36);
//结束时间
@Column(name = "end_time")//, nullable = false)
private LocalDateTime endTime = LocalDateTime.of(2020,2,18,16,37);
//启用状态
@Column(name = "enabled")//, nullable = false)
private boolean enabled;
}

View File

@ -1,174 +1,36 @@
package com.codesdream.ase.model.activity;
import com.codesdream.ase.model.file.Image;
import com.codesdream.ase.model.permission.User;
import lombok.Data;
import javax.persistence.*;
import java.awt.*;
import java.util.Date;
import java.util.List;
import java.util.Set;
@Data
@Entity
@Table(name = "report")
@Table
@Data
public class Report {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
int id;
//活动标题
@Column(nullable = false, unique = true)
private String title;
int activityId;
//创建人
@OneToOne(cascade = CascadeType.MERGE)
private User creator;
String title;
//活动类型
@Column(nullable = false)
private String type;
@ManyToOne(cascade = CascadeType.MERGE)
User creator;
//活动描述
@Column(nullable = true)
private String description;
@ManyToOne(cascade = CascadeType.MERGE)
User manager;
//活动周期格式阿拉伯数字数字+单位0表示无周期
@Column(nullable = true)
private String cycle;
Date realBeginDate;
//自愿参与人列表
@ManyToMany(cascade = CascadeType.MERGE)
@JoinTable(name = "act_volunteer")
private Set<User> volunteers;
Date realEndDate;
//参与人列表
@ManyToMany(cascade = CascadeType.MERGE)
@JoinTable(name = "act_participate",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "participate_id")
}
)
private Set<User> participateGroup;
//实际参与人列表
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "act_participated",
joinColumns = {
@JoinColumn(name = "act_id" )
},
inverseJoinColumns = {
@JoinColumn(name = "participated_id")
}
)
private Set<User> participatedGroup;
//可报名人员列表
@ManyToMany(cascade = CascadeType.MERGE)
@JoinTable(name = "act_sign",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "sign_id")
}
)
private Set<User> signGroup;
//已报名人员列表
@ManyToMany(cascade = CascadeType.MERGE)
@JoinTable(name = "act_signed",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "signed_id")
}
)
private Set<User> signedGroup;
//可见人员列表
@ManyToMany(cascade = CascadeType.MERGE)
@JoinTable(name = "act_vis",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "vis_id")
}
)
private Set<User> visibleGroup;
//通知人员列表
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "act_inform",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "inform_id")
}
)
private Set<User> informGroup;
//已通知人员列表
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "act_informed",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "informed_id")
}
)
private Set<User> informedGroup;
//计划开始时间
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "plan_period")
private Period planPeriod;
//实际开始时间
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "real_period")
private Period realPeriod;
//主要负责人
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "chief_manager", nullable = false)
private User chiefManager;
//次要负责人
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "act_id")
private List<User> assistManagers;
//考勤安排
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "attendance")
private Attendance attendance;
//活动笔记
@Column(name = "notes")
private String notes;
//图表
@ElementCollection(targetClass = java.lang.String.class)
@Column(name = "charts")
private List<String> charts;
//附件url
@Column(name = "enclosure")
private String enclosure;
//活动
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "activity")
private Activity activity;
String context;
@ManyToMany
List<Image> images;
}

View File

@ -1,55 +0,0 @@
package com.codesdream.ase.model.activity;
import com.codesdream.ase.model.permission.User;
import javafx.scene.chart.ScatterChart;
import lombok.Data;
import javax.persistence.*;
import java.util.List;
@Data
@Entity
@Table(name = "user_act")
public class UserActivity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
//关联的用户
@OneToOne(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY, mappedBy = "userActivity")
@JoinColumn(nullable = false)
private User user;
//主要负责的活动
@OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY)
private List<Activity> manageActivities;
//次要负责的活动
@ManyToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY)
private List<Activity> assistActivities;
//可见的活动
@OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY)
private List<Activity> visibleActivities;
//创建的活动
@OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY)
private List<Activity> createdActivities;
//可报名的活动
@OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY)
private List<Activity> signUpActivities;
//已经参与的活动
@OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY)
private List<Activity> participatedActivities;
//正在将要参与的活动
@OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY)
private List<Activity> participatingActivities;
//打卡签到活动
@OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY)
private List<Activity> clockIn;
}

View File

@ -0,0 +1,20 @@
package com.codesdream.ase.model.auth;
import lombok.Data;
import javax.persistence.*;
import java.util.Date;
@Data
@Entity
@Table(name = "pre_validation_code")
public class PreValidationCode {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
private String value;
private Date date = new Date();
}

View File

@ -0,0 +1,11 @@
package com.codesdream.ase.model.chart;
import java.lang.String;
import java.util.List;
public class BarChart extends Chart{
public String[] x;
public String xname;
public String yname;
}

View File

@ -0,0 +1,13 @@
package com.codesdream.ase.model.chart;
import java.util.List;
import java.lang.String;
import lombok.Data;
@Data
public class Chart{
public double[] y;
public String title;
}

View File

@ -0,0 +1,8 @@
package com.codesdream.ase.model.chart;
import java.util.*;
import java.lang.String;
public class FanChart extends Chart{
public String[] x;
}

View File

@ -0,0 +1,9 @@
package com.codesdream.ase.model.chart;
import java.lang.String;
public class Form {
public String title;
public String[][] body;
}

View File

@ -0,0 +1,9 @@
package com.codesdream.ase.model.chart;
import java.lang.String;
import java.util.List;
public class LineChart extends Chart{
public double[] x;
public String xname;
public String yname;
}

View File

@ -0,0 +1,22 @@
package com.codesdream.ase.model.file;
import lombok.Data;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
@Entity
@Table
@Data
public class File {
@Id
int id;
String title;
String url;
Date creationTime;
}

View File

@ -0,0 +1,16 @@
package com.codesdream.ase.model.file;
import javax.persistence.*;
@Entity
@Table
public class Image {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
int id;
@Lob
byte[] data;
String description;
}

View File

@ -12,7 +12,7 @@ import javax.persistence.*;
@Table(name = "base_major")
public class BaseMajor {
@Id
private int id;
private String id;
private String name;
}

View File

@ -1,36 +0,0 @@
package com.codesdream.ase.model.leaves;
import com.codesdream.ase.model.permission.User;
import lombok.Data;
import java.util.*;
import javax.persistence.*;
@Data
@Entity
@Table(name = "leaves_archive")
public class Leave {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
//发出人
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private User userFrom;
//审批人容器
@ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
private Set <User> userTo;
//请假类型 病假事假等
@Column(name = "type", nullable = false)
private String type;
//批准状态
@Column(name = "Authentication", nullable = false)
private Boolean Authentication;
//开始时间
@Column(nullable = false)
private Date startTime;
@Column(nullable = false)
private Date endTime;
//申请时间
private Date applyTime;
//认证时间
private Date authTime;
}

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