Compare commits
No commits in common. "master" and "develop" have entirely different histories.
@ -1,7 +0,0 @@
|
|||||||
FROM openjdk:8
|
|
||||||
|
|
||||||
# 指定当前操作目录
|
|
||||||
WORKDIR /_data/workspace/ASE/
|
|
||||||
|
|
||||||
#容器启动后执行的操作
|
|
||||||
CMD java -jar ASE-docker.jar
|
|
75
pom.xml
75
pom.xml
@ -126,10 +126,10 @@
|
|||||||
<version>3.14</version>
|
<version>3.14</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>1.2.61</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -141,45 +141,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mariadb.jdbc</groupId>
|
<groupId>org.mariadb.jdbc</groupId>
|
||||||
<artifactId>mariadb-java-client</artifactId>
|
<artifactId>mariadb-java-client</artifactId>
|
||||||
</dependency>
|
<version>2.5.4</version>
|
||||||
|
|
||||||
<!-- 内存数据库 -->
|
|
||||||
<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>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
@ -195,45 +157,14 @@
|
|||||||
<addResources>true</addResources>
|
<addResources>true</addResources>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</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>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
||||||
<repositories>
|
<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>
|
<repository>
|
||||||
<id>AlibabaMaven</id>
|
<id>AlibabaMaven</id>
|
||||||
<name>Maven Aliyun Mirror</name>
|
<name>Maven Aliyun Mirror</name>
|
||||||
<url>https://maven.aliyun.com/repository/central</url>
|
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
|
||||||
<releases>
|
<releases>
|
||||||
<enabled>true</enabled>
|
<enabled>true</enabled>
|
||||||
</releases>
|
</releases>
|
||||||
|
@ -1,128 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
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() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,11 +7,11 @@ import org.springframework.stereotype.Component;
|
|||||||
// SHA1算法不可逆加密 主要用于JSON签名
|
// SHA1算法不可逆加密 主要用于JSON签名
|
||||||
@Component
|
@Component
|
||||||
public class SHA1Encoder {
|
public class SHA1Encoder {
|
||||||
public String encode(CharSequence charSequence){
|
String encode(CharSequence charSequence){
|
||||||
return DigestUtils.sha1Hex(charSequence.toString());
|
return DigestUtils.sha1Hex(charSequence.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean match (CharSequence charSequence, String s){
|
boolean match(CharSequence charSequence, String s){
|
||||||
return s.equals(encode(charSequence));
|
return s.equals(encode(charSequence));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,4 @@ public class TimestampExpiredChecker {
|
|||||||
return timestampDate.before(maxDate);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.codesdream.ase.component.datamanager;
|
package com.codesdream.ase.component.datamanager;
|
||||||
|
|
||||||
import com.codesdream.ase.exception.notfound.DataFileNotFoundException;
|
import com.codesdream.ase.exception.DataFileNotFoundException;
|
||||||
import com.codesdream.ase.exception.innerservererror.DataIOException;
|
import com.codesdream.ase.exception.DataIOException;
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
@ -2,10 +2,6 @@ package com.codesdream.ase.component.datamanager;
|
|||||||
|
|
||||||
|
|
||||||
import com.codesdream.ase.exception.*;
|
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.openxml4j.exceptions.InvalidFormatException;
|
||||||
import org.apache.poi.ss.usermodel.*;
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
|
||||||
@ -51,7 +47,7 @@ public class DataExcelReader implements DataReader {
|
|||||||
Row titleRow = sheet.getRow(0);
|
Row titleRow = sheet.getRow(0);
|
||||||
colNumber = titleRow.getLastCellNum();
|
colNumber = titleRow.getLastCellNum();
|
||||||
// 表头项目个数不可为0
|
// 表头项目个数不可为0
|
||||||
if(colNumber == 0) throw new DataIllegalTableFormatException();
|
if(colNumber == 0) throw new DataIllegalTableFormatException();
|
||||||
Collection<String> title = new ArrayList<>();
|
Collection<String> title = new ArrayList<>();
|
||||||
for(int cellIdx = 0; cellIdx < colNumber; cellIdx++){
|
for(int cellIdx = 0; cellIdx < colNumber; cellIdx++){
|
||||||
title.add(readCell(titleRow.getCell(cellIdx)));
|
title.add(readCell(titleRow.getCell(cellIdx)));
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package com.codesdream.ase.component.datamanager;
|
package com.codesdream.ase.component.datamanager;
|
||||||
|
|
||||||
import com.codesdream.ase.exception.innerservererror.DataIllegalTableFormatException;
|
import com.codesdream.ase.exception.DataIllegalTableFormatException;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.swing.text.html.Option;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
// 描述一张数据表
|
// 描述一张数据表
|
||||||
|
@ -3,12 +3,6 @@ package com.codesdream.ase.component.datamanager;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.codesdream.ase.component.json.respond.JSONBaseRespondObject;
|
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 org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@ -75,15 +69,6 @@ public class JSONParameter {
|
|||||||
return json.map(jsonObject -> getJavaObject(jsonObject, type));
|
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,80 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,12 +0,0 @@
|
|||||||
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";
|
|
||||||
}
|
|
@ -1,92 +0,0 @@
|
|||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
package com.codesdream.ase.component.json.form;
|
|
||||||
|
|
||||||
public class RegisterForm {
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
package com.codesdream.ase.component.json.model;
|
|
||||||
|
|
||||||
public class JsonableUidGetter {
|
|
||||||
private String checkType;
|
|
||||||
private String username;
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package com.codesdream.ase.component.json.request;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class UserLeaveAuth {
|
|
||||||
/*
|
|
||||||
备注
|
|
||||||
*/
|
|
||||||
private int id;
|
|
||||||
private String Comment;
|
|
||||||
/*
|
|
||||||
审核结果
|
|
||||||
*/
|
|
||||||
private String newStat;
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
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;//结束时间
|
|
||||||
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
package com.codesdream.ase.component.json.request;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class UserSGettudentLeaveListRequest {
|
|
||||||
private int studentId;
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
@ -12,6 +12,5 @@ public class UserLoginCheckerJSONRespond {
|
|||||||
String respondInformation = null;
|
String respondInformation = null;
|
||||||
String token = null;
|
String token = null;
|
||||||
String uid = null;
|
String uid = null;
|
||||||
String pvc = null;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.codesdream.ase.component.auth;
|
package com.codesdream.ase.component.permission;
|
||||||
|
|
||||||
import com.codesdream.ase.component.api.QuickJSONRespond;
|
import com.codesdream.ase.component.datamanager.JSONParameter;
|
||||||
|
import com.codesdream.ase.component.datamanager.QuickJSONRespond;
|
||||||
|
import com.codesdream.ase.component.json.respond.UserLoginCheckerJSONRespond;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.security.access.AccessDeniedException;
|
import org.springframework.security.access.AccessDeniedException;
|
||||||
import org.springframework.security.web.access.AccessDeniedHandler;
|
import org.springframework.security.web.access.AccessDeniedHandler;
|
@ -1,12 +1,16 @@
|
|||||||
package com.codesdream.ase.component.auth;
|
package com.codesdream.ase.component.permission;
|
||||||
|
|
||||||
import com.codesdream.ase.component.api.QuickJSONRespond;
|
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 lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
@ -1,13 +1,16 @@
|
|||||||
package com.codesdream.ase.component.auth;
|
package com.codesdream.ase.component.permission;
|
||||||
|
|
||||||
import com.codesdream.ase.component.api.QuickJSONRespond;
|
import com.codesdream.ase.component.datamanager.JSONParameter;
|
||||||
|
import com.codesdream.ase.component.datamanager.QuickJSONRespond;
|
||||||
import com.codesdream.ase.component.json.respond.ErrorInfoJSONRespond;
|
import com.codesdream.ase.component.json.respond.ErrorInfoJSONRespond;
|
||||||
|
import com.codesdream.ase.component.json.respond.UserLoginCheckerJSONRespond;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
|
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
@ -1,6 +1,8 @@
|
|||||||
package com.codesdream.ase.component.auth;
|
package com.codesdream.ase.component.permission;
|
||||||
|
|
||||||
import com.codesdream.ase.component.api.QuickJSONRespond;
|
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.json.respond.UserLoginCheckerJSONRespond;
|
import com.codesdream.ase.component.json.respond.UserLoginCheckerJSONRespond;
|
||||||
import com.codesdream.ase.model.permission.User;
|
import com.codesdream.ase.model.permission.User;
|
||||||
|
|
||||||
@ -17,6 +19,7 @@ import javax.annotation.Resource;
|
|||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -38,7 +41,6 @@ public class ASEAuthenticationSuccessHandler extends SavedRequestAwareAuthentica
|
|||||||
UserLoginCheckerJSONRespond respond = new UserLoginCheckerJSONRespond();
|
UserLoginCheckerJSONRespond respond = new UserLoginCheckerJSONRespond();
|
||||||
respond.setUserExist(authentication.isAuthenticated());
|
respond.setUserExist(authentication.isAuthenticated());
|
||||||
respond.setLoginStatus(authentication.isAuthenticated());
|
respond.setLoginStatus(authentication.isAuthenticated());
|
||||||
respond.setPvc(authService.preValidationCodeGetter());
|
|
||||||
|
|
||||||
// 获得 JSONTokenAuthenticationToken
|
// 获得 JSONTokenAuthenticationToken
|
||||||
JSONTokenAuthenticationToken authenticationToken = (JSONTokenAuthenticationToken) authentication;
|
JSONTokenAuthenticationToken authenticationToken = (JSONTokenAuthenticationToken) authentication;
|
@ -1,5 +1,10 @@
|
|||||||
package com.codesdream.ase.component.auth;
|
package com.codesdream.ase.component.permission;
|
||||||
|
|
||||||
|
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.model.auth.JSONToken;
|
||||||
import com.codesdream.ase.service.AuthService;
|
import com.codesdream.ase.service.AuthService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -25,9 +30,15 @@ import java.util.Optional;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class ASEJSONTokenAuthenticationFilter extends OncePerRequestFilter {
|
public class ASEJSONTokenAuthenticationFilter extends OncePerRequestFilter {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private JSONParameter jsonParameter;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private JSONRandomCodeGenerator randomCodeGenerator;
|
private JSONRandomCodeGenerator randomCodeGenerator;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AJAXRequestChecker ajaxRequestChecker;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AuthService authService;
|
private AuthService authService;
|
||||||
|
|
||||||
@ -48,13 +59,7 @@ public class ASEJSONTokenAuthenticationFilter extends OncePerRequestFilter {
|
|||||||
// 时间戳
|
// 时间戳
|
||||||
String timestamp = request.getHeader("timestamp");
|
String timestamp = request.getHeader("timestamp");
|
||||||
|
|
||||||
// 服务端API测试豁免签名
|
if (signed != null && username != null && timestamp != null) {
|
||||||
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));
|
Date date = new Date(Long.parseLong(timestamp));
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.codesdream.ase.component.auth;
|
package com.codesdream.ase.component.permission;
|
||||||
|
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
@ -1,5 +1,7 @@
|
|||||||
package com.codesdream.ase.component.auth;
|
package com.codesdream.ase.component.permission;
|
||||||
|
|
||||||
|
import com.codesdream.ase.component.auth.JSONTokenAuthenticationToken;
|
||||||
|
import com.codesdream.ase.component.auth.JSONTokenUsernamePasswordAuthenticationToken;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.security.authentication.*;
|
import org.springframework.security.authentication.*;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
@ -32,11 +34,11 @@ public class ASESecurityAuthenticationProvider implements AuthenticationProvider
|
|||||||
JSONTokenUsernamePasswordAuthenticationToken authenticationToken =
|
JSONTokenUsernamePasswordAuthenticationToken authenticationToken =
|
||||||
(JSONTokenUsernamePasswordAuthenticationToken) authentication;
|
(JSONTokenUsernamePasswordAuthenticationToken) authentication;
|
||||||
|
|
||||||
// 获得JSON中的学号
|
// 获得登录表单中的学号
|
||||||
String username = usernameEncoder.encode((CharSequence) authenticationToken.getPrincipal());
|
String username = usernameEncoder.encode((CharSequence) authenticationToken.getPrincipal());
|
||||||
// 获得JSON中的加密密码
|
// 获得表单中的密码
|
||||||
String encrypted_password = (String) authenticationToken.getCredentials();
|
String password = passwordEncoder.encode((CharSequence) authenticationToken.getCredentials());
|
||||||
// 获得客户端代码
|
// 获得
|
||||||
String clientCode = authenticationToken.getClientCode();
|
String clientCode = authenticationToken.getClientCode();
|
||||||
// 判断用户是否存在
|
// 判断用户是否存在
|
||||||
UserDetails userInfo = userDetailsService.loadUserByUsername(username);
|
UserDetails userInfo = userDetailsService.loadUserByUsername(username);
|
||||||
@ -45,23 +47,20 @@ public class ASESecurityAuthenticationProvider implements AuthenticationProvider
|
|||||||
throw new UsernameNotFoundException("User Not Exist");
|
throw new UsernameNotFoundException("User Not Exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
String sha256_password = userInfo.getPassword();
|
|
||||||
|
|
||||||
// 判断密码是否正确
|
// 判断密码是否正确
|
||||||
if(!passwordEncoder.encode(String.format(
|
if (!userInfo.getPassword().equals(password)) {
|
||||||
"PASS_ENCODE [%s][%s]", sha256_password, clientCode)).equals(encrypted_password)){
|
throw new BadCredentialsException("Password IS Uncorrected");
|
||||||
throw new BadCredentialsException("Password IS INCORRECT");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断账号是否停用/删除
|
// 判断账号是否停用/删除
|
||||||
if (!userInfo.isEnabled()) {
|
if (!userInfo.isEnabled()) {
|
||||||
throw new DisabledException("User IS Disabled");
|
throw new DisabledException("User IS Disabled");
|
||||||
}
|
}
|
||||||
else if(!userInfo.isAccountNonLocked()) {
|
else if(!userInfo.isAccountNonLocked()){
|
||||||
throw new LockedException("User IS Locked");
|
throw new LockedException("User IS Locked");
|
||||||
}
|
}
|
||||||
else if(!userInfo.isAccountNonExpired()) {
|
else if(!userInfo.isAccountNonExpired()){
|
||||||
throw new AccountExpiredException("User IS Expired");
|
throw new AccountExpiredException("User IS Expired");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成权限列表
|
// 生成权限列表
|
@ -1,4 +1,4 @@
|
|||||||
package com.codesdream.ase.component.auth;
|
package com.codesdream.ase.component.permission;
|
||||||
|
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
@ -1,4 +1,4 @@
|
|||||||
package com.codesdream.ase.component.auth;
|
package com.codesdream.ase.component.permission;
|
||||||
|
|
||||||
import com.codesdream.ase.component.auth.AJAXRequestChecker;
|
import com.codesdream.ase.component.auth.AJAXRequestChecker;
|
||||||
import com.codesdream.ase.component.auth.JSONTokenUsernamePasswordAuthenticationToken;
|
import com.codesdream.ase.component.auth.JSONTokenUsernamePasswordAuthenticationToken;
|
||||||
@ -8,17 +8,19 @@ import com.codesdream.ase.component.json.request.UserLoginChecker;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.security.authentication.AuthenticationServiceException;
|
import org.springframework.security.authentication.AuthenticationServiceException;
|
||||||
import org.springframework.security.authentication.BadCredentialsException;
|
import org.springframework.security.authentication.BadCredentialsException;
|
||||||
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||||
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
|
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
// 普通登录验证过滤器
|
// 登录验证过滤器
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ASEUsernamePasswordAuthenticationFilter extends UsernamePasswordAuthenticationFilter {
|
public class ASEUsernamePasswordAuthenticationFilter extends UsernamePasswordAuthenticationFilter {
|
||||||
|
|
||||||
@ -63,7 +65,6 @@ public class ASEUsernamePasswordAuthenticationFilter extends UsernamePasswordAut
|
|||||||
|
|
||||||
// 获得相应的用户名密码
|
// 获得相应的用户名密码
|
||||||
String username = checker.getUsername();
|
String username = checker.getUsername();
|
||||||
// 得到加密密码
|
|
||||||
String password = checker.getPassword();
|
String password = checker.getPassword();
|
||||||
String clientCode = checker.getClientCode();
|
String clientCode = checker.getClientCode();
|
||||||
|
|
@ -5,14 +5,15 @@ import org.springframework.security.core.GrantedAuthority;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class UserAuthoritiesGenerator {
|
public class UserAuthoritiesGenerator {
|
||||||
|
@Resource
|
||||||
|
UserRolesListGenerator userRolesListGenerator;
|
||||||
|
|
||||||
public Collection<? extends GrantedAuthority> grantedAuthorities(User user){
|
public Collection<? extends GrantedAuthority> grantedAuthorities(User user){
|
||||||
return new ArrayList<>();
|
return userRolesListGenerator.generateRoles(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
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)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
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)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,19 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -30,7 +30,6 @@ public class ActivityFormConfigure {
|
|||||||
add("attendance");
|
add("attendance");
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
|
||||||
public HashSet<String> getStdActivityForm() {
|
public HashSet<String> getStdActivityForm() {
|
||||||
return stdActivityForm;
|
return stdActivityForm;
|
||||||
}
|
}
|
||||||
|
@ -39,5 +39,4 @@ public class AppConfigure {
|
|||||||
public String getOrganization() {
|
public String getOrganization() {
|
||||||
return "全员育人WEB端开发组";
|
return "全员育人WEB端开发组";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package com.codesdream.ase.configure;
|
package com.codesdream.ase.configure;
|
||||||
|
|
||||||
import com.codesdream.ase.component.auth.*;
|
import com.codesdream.ase.component.permission.*;
|
||||||
import com.codesdream.ase.service.ASEUserDetailsService;
|
import com.codesdream.ase.service.ASEUserDetailsService;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
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.authentication.builders.AuthenticationManagerBuilder;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.builders.WebSecurity;
|
import org.springframework.security.config.annotation.web.builders.WebSecurity;
|
||||||
@ -12,10 +13,12 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
|
|||||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||||
import org.springframework.security.core.session.SessionRegistry;
|
import org.springframework.security.core.session.SessionRegistry;
|
||||||
import org.springframework.security.core.session.SessionRegistryImpl;
|
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.UsernamePasswordAuthenticationFilter;
|
||||||
|
import org.springframework.security.web.authentication.session.CompositeSessionAuthenticationStrategy;
|
||||||
import org.springframework.security.web.authentication.session.ConcurrentSessionControlAuthenticationStrategy;
|
import org.springframework.security.web.authentication.session.ConcurrentSessionControlAuthenticationStrategy;
|
||||||
import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy;
|
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 org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -49,9 +52,6 @@ public class CustomWebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
@Resource
|
@Resource
|
||||||
ASEAccessDeniedHandler accessDeniedHandler;
|
ASEAccessDeniedHandler accessDeniedHandler;
|
||||||
|
|
||||||
@Resource
|
|
||||||
ASESecurityInterceptor securityInterceptor;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure(HttpSecurity http) throws Exception {
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
@ -68,8 +68,7 @@ public class CustomWebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
|
|
||||||
// 替换掉原有的UsernamePasswordAuthenticationFilter
|
// 替换掉原有的UsernamePasswordAuthenticationFilter
|
||||||
http.addFilterAt(aseUsernamePasswordAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class)
|
http.addFilterAt(aseUsernamePasswordAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class)
|
||||||
.addFilterBefore(asejsonTokenAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class)
|
.addFilterBefore(asejsonTokenAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
|
||||||
.addFilterAt(securityInterceptor, FilterSecurityInterceptor.class);
|
|
||||||
|
|
||||||
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
|
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
|
||||||
|
|
||||||
@ -92,13 +91,7 @@ public class CustomWebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
"/forget/**",
|
"/forget/**",
|
||||||
"/not_found/**",
|
"/not_found/**",
|
||||||
"/error/**",
|
"/error/**",
|
||||||
"/login/**",
|
"/login/**");
|
||||||
"/swagger-ui.html",
|
|
||||||
"/webjars/**",
|
|
||||||
"/swagger-resources/**",
|
|
||||||
"/v2/api-docs",
|
|
||||||
"/configuration/ui",
|
|
||||||
"/configuration/security");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//注册自定义的UsernamePasswordAuthenticationFilter
|
//注册自定义的UsernamePasswordAuthenticationFilter
|
||||||
|
@ -1,77 +1,31 @@
|
|||||||
package com.codesdream.ase.controller;
|
package com.codesdream.ase.controller;
|
||||||
|
|
||||||
import com.codesdream.ase.component.api.QuickJSONRespond;
|
import com.codesdream.ase.component.error.ErrorResponse;
|
||||||
import com.codesdream.ase.component.json.respond.ErrorInfoJSONRespond;
|
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.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
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.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
import org.springframework.web.context.request.WebRequest;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestControllerAdvice
|
@RestControllerAdvice
|
||||||
public class ASEControllerAdvice {
|
public class ASEControllerAdvice {
|
||||||
|
@ExceptionHandler(value = {RuntimeException.class})
|
||||||
@Resource
|
public final Object handleRuntimeException(RuntimeException e, WebRequest webRequest){
|
||||||
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 errorInfoJSONRespond = new ErrorInfoJSONRespond();
|
||||||
errorInfoJSONRespond.setException(ex.getClass().getName());
|
|
||||||
errorInfoJSONRespond.setExceptionMessage(ex.getMessage());
|
|
||||||
errorInfoJSONRespond.setDate(new Date());
|
errorInfoJSONRespond.setDate(new Date());
|
||||||
|
errorInfoJSONRespond.setExceptionMessage(e.getMessage());
|
||||||
|
errorInfoJSONRespond.setException(e.getClass().getName());
|
||||||
return errorInfoJSONRespond;
|
return errorInfoJSONRespond;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,24 @@
|
|||||||
package com.codesdream.ase.controller;
|
package com.codesdream.ase.controller;
|
||||||
|
|
||||||
import com.codesdream.ase.component.api.QuickJSONRespond;
|
import com.codesdream.ase.component.datamanager.QuickJSONRespond;
|
||||||
|
import com.codesdream.ase.component.error.ErrorResponse;
|
||||||
import com.codesdream.ase.component.json.respond.ErrorInfoJSONRespond;
|
import com.codesdream.ase.component.json.respond.ErrorInfoJSONRespond;
|
||||||
import org.springframework.boot.web.servlet.error.ErrorController;
|
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.context.request.WebRequest;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class ASEErrorController implements ErrorController {
|
public class ASEErrorController implements ErrorController {
|
||||||
@ -72,7 +80,7 @@ public class ASEErrorController implements ErrorController {
|
|||||||
|
|
||||||
return quickJSONRespond.getJSONStandardRespond(
|
return quickJSONRespond.getJSONStandardRespond(
|
||||||
statusCode,
|
statusCode,
|
||||||
"Internal Server Error",
|
"Error Controller Handle",
|
||||||
null,
|
null,
|
||||||
errorInfoJSONRespond);
|
errorInfoJSONRespond);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
|||||||
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 {
|
|
||||||
}
|
|
@ -0,0 +1,35 @@
|
|||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
@ -2,17 +2,16 @@ package com.codesdream.ase.controller;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.codesdream.ase.component.datamanager.JSONParameter;
|
import com.codesdream.ase.component.datamanager.JSONParameter;
|
||||||
import com.codesdream.ase.component.api.QuickJSONRespond;
|
import com.codesdream.ase.component.datamanager.QuickJSONRespond;
|
||||||
import com.codesdream.ase.component.json.respond.JSONStandardFailedRespond;
|
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.request.UserLoginChecker;
|
||||||
import com.codesdream.ase.component.json.respond.UserLoginCheckerJSONRespond;
|
import com.codesdream.ase.component.json.respond.UserLoginCheckerJSONRespond;
|
||||||
import com.codesdream.ase.service.IAuthService;
|
|
||||||
import com.codesdream.ase.service.IUserService;
|
import com.codesdream.ase.service.IUserService;
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
@ -27,7 +26,6 @@ import java.util.Optional;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Controller
|
@Controller
|
||||||
@Api(tags = "用户登录有关接口")
|
|
||||||
public class LoginController {
|
public class LoginController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@ -40,15 +38,20 @@ public class LoginController {
|
|||||||
private IUserService userService;
|
private IUserService userService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private IAuthService authService;
|
private ASEUsernameEncoder usernameEncoder;
|
||||||
|
|
||||||
@PostMapping(value = "/login/check_exists")
|
@RequestMapping(value = "/login")
|
||||||
|
String printLogin(Model model) {
|
||||||
|
return "login";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/login/check_exists", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
String checkExists(HttpServletRequest request){
|
String checkExists(HttpServletRequest request){
|
||||||
|
|
||||||
// 检查是否为JSON
|
// 检查是否为JSON
|
||||||
Optional<JSONObject> json = jsonParameter.getJSONByRequest(request);
|
Optional<JSONObject> json = jsonParameter.getJSONByRequest(request);
|
||||||
if(!json.isPresent()) return quickJSONRespond.getRespond400("Invalid JSON Form");
|
if(!json.isPresent()) return jsonParameter.getJSONString(new JSONStandardFailedRespond());
|
||||||
|
|
||||||
|
|
||||||
UserLoginChecker loginChecker = json.get().toJavaObject(UserLoginChecker.class);
|
UserLoginChecker loginChecker = json.get().toJavaObject(UserLoginChecker.class);
|
||||||
@ -74,22 +77,12 @@ public class LoginController {
|
|||||||
@RequestMapping(value = "/login/check_uid", method = RequestMethod.POST)
|
@RequestMapping(value = "/login/check_uid", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
String checkUsernameByStudentID(HttpServletRequest request){
|
String checkUsernameByStudentID(HttpServletRequest request){
|
||||||
|
|
||||||
String preValidationCode = request.getHeader("pvc");
|
|
||||||
|
|
||||||
// 检查随机预验证码
|
|
||||||
if(preValidationCode == null || !authService.preValidationCodeChecker(preValidationCode))
|
|
||||||
return quickJSONRespond.getRespond403("Invalid PreValidationCode");
|
|
||||||
|
|
||||||
// 检查是否为JSON
|
// 检查是否为JSON
|
||||||
Optional<JSONObject> json = jsonParameter.getJSONByRequest(request);
|
Optional<JSONObject> json = jsonParameter.getJSONByRequest(request);
|
||||||
if(!json.isPresent()) return jsonParameter.getJSONString(new JSONStandardFailedRespond());
|
if(!json.isPresent()) return jsonParameter.getJSONString(new JSONStandardFailedRespond());
|
||||||
|
|
||||||
UserLoginChecker loginChecker = json.get().toJavaObject(UserLoginChecker.class);
|
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")) {
|
if(loginChecker.getCheckType().equals("UIDGeneratorChecker")) {
|
||||||
UserLoginCheckerJSONRespond respond = new UserLoginCheckerJSONRespond();
|
UserLoginCheckerJSONRespond respond = new UserLoginCheckerJSONRespond();
|
||||||
respond.setUid(userService.getUsernameByStudentId(loginChecker.getUsername()));
|
respond.setUid(userService.getUsernameByStudentId(loginChecker.getUsername()));
|
||||||
@ -99,6 +92,8 @@ public class LoginController {
|
|||||||
// 返回失败对象
|
// 返回失败对象
|
||||||
return quickJSONRespond.getRespond400("CheckType Mismatch");
|
return quickJSONRespond.getRespond400("CheckType Mismatch");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
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,);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
package com.codesdream.ase.controller;
|
package com.codesdream.ase.controller;
|
||||||
|
|
||||||
import com.codesdream.ase.component.datamanager.JSONParameter;
|
import com.codesdream.ase.component.datamanager.JSONParameter;
|
||||||
import com.codesdream.ase.component.api.QuickJSONRespond;
|
import com.codesdream.ase.component.datamanager.QuickJSONRespond;
|
||||||
import com.codesdream.ase.component.json.request.UserRegisterChecker;
|
import com.codesdream.ase.component.json.request.UserRegisterChecker;
|
||||||
import com.codesdream.ase.model.information.BaseStudentInfo;
|
import com.codesdream.ase.model.information.BaseStudentInfo;
|
||||||
import com.codesdream.ase.model.permission.User;
|
import com.codesdream.ase.model.permission.User;
|
||||||
@ -18,7 +18,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("register")
|
|
||||||
public class RegisterController {
|
public class RegisterController {
|
||||||
@Resource
|
@Resource
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@ -32,22 +31,13 @@ public class RegisterController {
|
|||||||
@Resource
|
@Resource
|
||||||
private QuickJSONRespond quickJSONRespond;
|
private QuickJSONRespond quickJSONRespond;
|
||||||
|
|
||||||
@RequestMapping(value = "")
|
@RequestMapping(value = "/register")
|
||||||
String registerView(Model model){
|
String registerView(Model model){
|
||||||
return "register";
|
return "register";
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value="baseinfo")
|
|
||||||
@ResponseBody
|
|
||||||
String addBaseInfo(){
|
|
||||||
BaseStudentInfo bsi = baseInformationService.constructStudentInfo("2018303209", "14011809", "Jack",
|
|
||||||
"男","软件学院","软件工程","汉族","群众","未知");
|
|
||||||
baseInformationService.save(bsi);
|
|
||||||
|
|
||||||
return "OK";
|
|
||||||
}
|
|
||||||
// 处理注册表单
|
// 处理注册表单
|
||||||
@PostMapping(value = "user")
|
@PostMapping(value = "/register/do_register")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
String doRegister(HttpServletRequest request){
|
String doRegister(HttpServletRequest request){
|
||||||
|
|
||||||
@ -88,7 +78,7 @@ public class RegisterController {
|
|||||||
BaseStudentInfo studentInfo = baseInformationService.findStudentInfoByStudentId(student_id);
|
BaseStudentInfo studentInfo = baseInformationService.findStudentInfoByStudentId(student_id);
|
||||||
|
|
||||||
// 根据基本信息生成对应用户
|
// 根据基本信息生成对应用户
|
||||||
User user = userService.createUserByStudentInfo(studentInfo);
|
User user = userService.getUserByStudentInfo(studentInfo);
|
||||||
|
|
||||||
// 填充密保问题
|
// 填充密保问题
|
||||||
user.getUserAuth().setUserQuestion(user_question);
|
user.getUserAuth().setUserQuestion(user_question);
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
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 {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
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())));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +1,16 @@
|
|||||||
package com.codesdream.ase.exception.badrequest;
|
package com.codesdream.ase.exception;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class BaseInformationAlreadyExistException extends AlreadyExistException {
|
public class BaseInformationAlreadyExistException extends RuntimeException {
|
||||||
private String className;
|
private String className;
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
public BaseInformationAlreadyExistException(Class<?> aClass, String value){
|
public BaseInformationAlreadyExistException(Class<?> aClass, String value){
|
||||||
super(String.format("%s: %s", aClass.getName(), value));
|
super();
|
||||||
this.className = aClass.getName();
|
this.className = aClass.getName();
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
@ -1,11 +1,11 @@
|
|||||||
package com.codesdream.ase.exception.badrequest;
|
package com.codesdream.ase.exception;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class BaseInformationIllegalException extends IllegalException {
|
public class BaseInformationIllegalException extends RuntimeException {
|
||||||
String type;
|
String type;
|
||||||
String value;
|
String value;
|
||||||
|
|
@ -1,16 +1,16 @@
|
|||||||
package com.codesdream.ase.exception.notfound;
|
package com.codesdream.ase.exception;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class BaseInformationNotFoundException extends NotFoundException {
|
public class BaseInformationNotExistException extends RuntimeException {
|
||||||
private String className;
|
private String className;
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
public BaseInformationNotFoundException(Class<?> baseInformationClass, String value){
|
public BaseInformationNotExistException(Class<?> baseInformationClass, String value){
|
||||||
super(String.format("%s: %s", baseInformationClass.getName(), value));
|
super();
|
||||||
this.className = baseInformationClass.getName();
|
this.className = baseInformationClass.getName();
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.codesdream.ase.exception;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class DataIOException extends RuntimeException {
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.codesdream.ase.exception;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class DataIllegalTableFormatException extends RuntimeException {
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.codesdream.ase.exception.innerservererror;
|
package com.codesdream.ase.exception;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@ -7,9 +7,9 @@ import javax.persistence.criteria.CriteriaBuilder;
|
|||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class InvalidFormFormatException extends FormatException {
|
public class InvalidFormFormatException extends Throwable {
|
||||||
|
|
||||||
private String message = "Invalid form format";
|
private String message = "";
|
||||||
|
|
||||||
public InvalidFormFormatException(){
|
public InvalidFormFormatException(){
|
||||||
super();
|
super();
|
@ -0,0 +1,14 @@
|
|||||||
|
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;}
|
||||||
|
}
|
@ -1,18 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +1,11 @@
|
|||||||
package com.codesdream.ase.exception.badrequest;
|
package com.codesdream.ase.exception;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class UserInformationIllegalException extends IllegalException {
|
public class UserInformationIllegalException extends RuntimeException {
|
||||||
|
|
||||||
String username;
|
String username;
|
||||||
|
|
@ -1,20 +1,17 @@
|
|||||||
package com.codesdream.ase.exception.notfound;
|
package com.codesdream.ase.exception;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class UserNotFoundException extends NotFoundException {
|
public class UserNotFoundException extends RuntimeException {
|
||||||
Integer id;
|
Integer id;
|
||||||
String username;
|
String username;
|
||||||
|
|
||||||
public UserNotFoundException(Integer id, String username){
|
public UserNotFoundException(Integer id, String username){
|
||||||
super();
|
super();
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserNotFoundException(String msg){
|
|
||||||
super(msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,16 +1,16 @@
|
|||||||
package com.codesdream.ase.exception.badrequest;
|
package com.codesdream.ase.exception;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class UsernameAlreadyExistException extends AlreadyExistException {
|
public class UsernameAlreadyExistException extends RuntimeException {
|
||||||
|
|
||||||
String username;
|
String username;
|
||||||
|
|
||||||
public UsernameAlreadyExistException(String username){
|
public UsernameAlreadyExistException(String username){
|
||||||
super(username);
|
super();
|
||||||
this.username = username;
|
this.username = username;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,14 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
package com.codesdream.ase.exception.badrequest;
|
|
||||||
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class IllegalException extends RuntimeException {
|
|
||||||
public IllegalException(String msg){
|
|
||||||
super(msg);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
package com.codesdream.ase.exception.conflict;
|
|
||||||
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 存在与之相关联的对象
|
|
||||||
*/
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class RelatedObjectsExistException extends RuntimeException {
|
|
||||||
public RelatedObjectsExistException(String msg){
|
|
||||||
super(msg);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package com.codesdream.ase.exception.innerservererror;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
|
||||||
public class DataIOException extends RuntimeIOException {
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package com.codesdream.ase.exception.innerservererror;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
|
||||||
public class DataIllegalTableFormatException extends FormatException {
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
package com.codesdream.ase.exception.innerservererror;
|
|
||||||
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class FormatException extends RuntimeException {
|
|
||||||
public FormatException(String msg){
|
|
||||||
super(msg);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
package com.codesdream.ase.exception.innerservererror;
|
|
||||||
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class RuntimeIOException extends RuntimeException {
|
|
||||||
public RuntimeIOException(String msg){
|
|
||||||
super(msg);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
package com.codesdream.ase.exception.notfound;
|
|
||||||
|
|
||||||
|
|
||||||
public class NotFoundException extends RuntimeException {
|
|
||||||
public NotFoundException(String msg){
|
|
||||||
super(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotFoundException(){
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package com.codesdream.ase.exception.notfound;
|
|
||||||
|
|
||||||
|
|
||||||
public class TagNotFoundException extends NotFoundException {
|
|
||||||
String tagName;
|
|
||||||
|
|
||||||
public TagNotFoundException(String tagName){
|
|
||||||
super(tagName);
|
|
||||||
this.tagName = tagName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +1,199 @@
|
|||||||
package com.codesdream.ase.model.activity;
|
package com.codesdream.ase.model.activity;
|
||||||
|
|
||||||
import com.codesdream.ase.model.file.File;
|
import com.codesdream.ase.model.permission.User;
|
||||||
import com.codesdream.ase.model.mark.Tag;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.springframework.security.core.parameters.P;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table
|
|
||||||
@Data
|
@Data
|
||||||
|
@Entity
|
||||||
|
@Table(name = "activity")
|
||||||
public class Activity {
|
public class Activity {
|
||||||
@Id
|
@Id
|
||||||
int id;
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private int id;
|
||||||
|
|
||||||
String title;
|
//活动标题
|
||||||
|
@Column(name = "title", nullable = false)
|
||||||
|
private String title;
|
||||||
|
|
||||||
int creatorId;
|
//创建人
|
||||||
|
@ManyToOne(cascade = CascadeType.MERGE)
|
||||||
|
@JoinColumn(nullable = false)
|
||||||
|
private User creator;
|
||||||
|
|
||||||
@ElementCollection
|
//活动类型
|
||||||
List<Integer> managerIds = new ArrayList<>();
|
@Column(nullable = false)
|
||||||
|
private String type;
|
||||||
|
|
||||||
@ElementCollection
|
//活动描述
|
||||||
List<Integer> participantIds = new ArrayList<>();
|
@Column
|
||||||
|
private String description;
|
||||||
|
|
||||||
@ElementCollection
|
//活动周期,格式:阿拉伯数字数字+单位,0表示无周期
|
||||||
List<Integer> absentees = new ArrayList<>();
|
@Column
|
||||||
|
private String cycle;
|
||||||
|
|
||||||
// 活动出勤情况,对应人员是否出勤
|
//自愿参与人列表
|
||||||
@ElementCollection
|
@ManyToMany(cascade = CascadeType.DETACH)
|
||||||
Map<Integer, Boolean> attendance = new HashMap<>();
|
@JoinTable(name = "act_volunteer")
|
||||||
|
private Set<User> volunteers;
|
||||||
|
|
||||||
@OneToMany(cascade = CascadeType.MERGE)
|
//参与人列表
|
||||||
List<File> appendixes = new ArrayList<>();
|
@ManyToMany(cascade = CascadeType.DETACH)
|
||||||
|
@JoinTable(name = "act_participate",
|
||||||
|
joinColumns = {
|
||||||
|
@JoinColumn(name = "act_id")
|
||||||
|
},
|
||||||
|
inverseJoinColumns = {
|
||||||
|
@JoinColumn(name = "participate_id")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
private Set<User> participateGroup;
|
||||||
|
|
||||||
|
//实际参与人列表
|
||||||
|
@ManyToMany(cascade = CascadeType.DETACH)
|
||||||
|
@JoinTable(name = "act_participated",
|
||||||
|
joinColumns = {
|
||||||
|
@JoinColumn(name = "act_id" )
|
||||||
|
},
|
||||||
|
inverseJoinColumns = {
|
||||||
|
@JoinColumn(name = "participated_id")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
private Set<User> participatedGroup;
|
||||||
|
|
||||||
Date registrationDDL;
|
//可报名人员列表
|
||||||
|
@ManyToMany(cascade = CascadeType.DETACH)
|
||||||
Date creationTime = new Date();
|
@JoinTable(name = "act_sign",
|
||||||
|
joinColumns = {
|
||||||
Date realBeginDate;
|
@JoinColumn(name = "act_id")
|
||||||
|
},
|
||||||
Date realEndDate;
|
inverseJoinColumns = {
|
||||||
|
@JoinColumn(name = "sign_id")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
private Set<User> signGroup;
|
||||||
|
|
||||||
|
//已报名人员列表
|
||||||
@ManyToMany(cascade = CascadeType.MERGE)
|
@ManyToMany(cascade = CascadeType.MERGE)
|
||||||
List<Tag> tags = new ArrayList<>();
|
@JoinTable(name = "act_signed",
|
||||||
|
joinColumns = {
|
||||||
|
@JoinColumn(name = "act_id")
|
||||||
|
},
|
||||||
|
inverseJoinColumns = {
|
||||||
|
@JoinColumn(name = "signed_id")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
private Set<User> signedGroup;
|
||||||
|
|
||||||
@OneToOne(cascade = CascadeType.MERGE)
|
//可见人员列表
|
||||||
Report report;
|
@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;
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
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;
|
||||||
|
}
|
32
src/main/java/com/codesdream/ase/model/activity/Period.java
Normal file
32
src/main/java/com/codesdream/ase/model/activity/Period.java
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
}
|
@ -1,36 +1,174 @@
|
|||||||
package com.codesdream.ase.model.activity;
|
package com.codesdream.ase.model.activity;
|
||||||
|
|
||||||
import com.codesdream.ase.model.file.Image;
|
|
||||||
import com.codesdream.ase.model.permission.User;
|
import com.codesdream.ase.model.permission.User;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table
|
|
||||||
@Data
|
@Data
|
||||||
|
@Entity
|
||||||
|
@Table(name = "report")
|
||||||
public class Report {
|
public class Report {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
int id;
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private int id;
|
||||||
|
|
||||||
int activityId;
|
//活动标题
|
||||||
|
@Column(nullable = false, unique = true)
|
||||||
|
private String title;
|
||||||
|
|
||||||
String title;
|
//创建人
|
||||||
|
@OneToOne(cascade = CascadeType.MERGE)
|
||||||
|
private User creator;
|
||||||
|
|
||||||
@ManyToOne(cascade = CascadeType.MERGE)
|
//活动类型
|
||||||
User creator;
|
@Column(nullable = false)
|
||||||
|
private String type;
|
||||||
|
|
||||||
@ManyToOne(cascade = CascadeType.MERGE)
|
//活动描述
|
||||||
User manager;
|
@Column(nullable = true)
|
||||||
|
private String description;
|
||||||
|
|
||||||
Date realBeginDate;
|
//活动周期,格式:阿拉伯数字数字+单位,0表示无周期
|
||||||
|
@Column(nullable = true)
|
||||||
|
private String cycle;
|
||||||
|
|
||||||
Date realEndDate;
|
//自愿参与人列表
|
||||||
|
@ManyToMany(cascade = CascadeType.MERGE)
|
||||||
|
@JoinTable(name = "act_volunteer")
|
||||||
|
private Set<User> volunteers;
|
||||||
|
|
||||||
String context;
|
//参与人列表
|
||||||
|
@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;
|
||||||
|
|
||||||
@ManyToMany
|
|
||||||
List<Image> images;
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
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;
|
||||||
|
}
|
@ -1,20 +0,0 @@
|
|||||||
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();
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
|||||||
package com.codesdream.ase.model.chart;
|
|
||||||
import java.util.*;
|
|
||||||
import java.lang.String;
|
|
||||||
|
|
||||||
public class FanChart extends Chart{
|
|
||||||
|
|
||||||
public String[] x;
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package com.codesdream.ase.model.chart;
|
|
||||||
import java.lang.String;
|
|
||||||
|
|
||||||
|
|
||||||
public class Form {
|
|
||||||
public String title;
|
|
||||||
public String[][] body;
|
|
||||||
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
@ -12,7 +12,7 @@ import javax.persistence.*;
|
|||||||
@Table(name = "base_major")
|
@Table(name = "base_major")
|
||||||
public class BaseMajor {
|
public class BaseMajor {
|
||||||
@Id
|
@Id
|
||||||
private String id;
|
private int id;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
}
|
}
|
||||||
|
36
src/main/java/com/codesdream/ase/model/leaves/Leave.java
Normal file
36
src/main/java/com/codesdream/ase/model/leaves/Leave.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
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
Loading…
Reference in New Issue
Block a user