Compare commits
45 Commits
develop
...
fileSystem
Author | SHA1 | Date | |
---|---|---|---|
|
56e6a9a7d4 | ||
|
575a64b4f6 | ||
|
0511bfb79c | ||
|
c580dae176 | ||
|
224b2c4a77 | ||
|
751dface4e | ||
|
801f3a2c7d | ||
|
b9ddb73f3f | ||
|
20a33c3b9a | ||
|
a61cf68ef0 | ||
|
565e9ea835 | ||
|
0ede1972fd | ||
|
311ace2bd0 | ||
|
1004f13367 | ||
|
e09f373fc0 | ||
|
f4d00f349f | ||
|
e8d91a4022 | ||
|
4b7411f562 | ||
|
3181288755 | ||
|
2cf0ff666f | ||
|
9a8459df6c | ||
|
15cdca1894 | ||
|
aef9478a83 | ||
|
720b047144 | ||
|
ae21439c2e | ||
|
fbb2a3afc8 | ||
|
62ee044d13 | ||
|
ce1e3979bd | ||
|
a64d65a70e | ||
|
27ebd6205a | ||
|
3f56611fa9 | ||
|
5bb3cfe375 | ||
|
47d724163f | ||
|
1b6bebc663 | ||
|
bbc2fc090b | ||
|
efe497ed7c | ||
|
4b2d363e85 | ||
|
692d849006 | ||
|
4916dea891 | ||
|
f13b30b4b7 | ||
|
2277f5c8e4 | ||
|
205b7e2602 | ||
|
c1a23adaba | ||
|
47ef733453 | ||
|
887b44e2ee |
51
pom.xml
51
pom.xml
@ -144,6 +144,45 @@
|
|||||||
<version>2.5.4</version>
|
<version>2.5.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 内存数据库 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.h2database</groupId>
|
||||||
|
<artifactId>h2</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 二维码支持包 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.zxing</groupId>
|
||||||
|
<artifactId>core</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.zxing</groupId>
|
||||||
|
<artifactId>javase</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Restful API 文档可视化支持 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
<version>2.9.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
|
<version>2.9.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.java-json-tools</groupId>
|
||||||
|
<artifactId>json-patch</artifactId>
|
||||||
|
<version>1.12</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@ -157,6 +196,18 @@
|
|||||||
<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>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
@ -0,0 +1,167 @@
|
|||||||
|
package com.codesdream.ase.component.activity;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.codesdream.ase.exception.innerservererror.DataInvalidFormatException;
|
||||||
|
import com.codesdream.ase.model.activity.Activity;
|
||||||
|
import com.codesdream.ase.model.activity.Attendance;
|
||||||
|
import com.codesdream.ase.model.activity.Period;
|
||||||
|
import com.codesdream.ase.model.permission.User;
|
||||||
|
import com.codesdream.ase.service.ActivityService;
|
||||||
|
import com.codesdream.ase.service.AttendanceService;
|
||||||
|
import com.codesdream.ase.service.PeriodService;
|
||||||
|
import com.codesdream.ase.service.UserService;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
//将合法的JSON对象转化为Activity对象
|
||||||
|
@Component
|
||||||
|
public class ActivityConverter {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
UserService userService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
PeriodService periodService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
AttendanceService attendanceService;
|
||||||
|
|
||||||
|
public Activity convertToActivity(Optional<JSONObject> json) {
|
||||||
|
if (!json.isPresent()) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
Activity activity = new Activity();
|
||||||
|
JSONObject jsonObject = json.get();
|
||||||
|
|
||||||
|
int userId = (int) jsonObject.get("creator");
|
||||||
|
Optional<User> creator = userService.findUserById(userId);
|
||||||
|
activity.setCreator(creator.get());
|
||||||
|
|
||||||
|
List<Integer> participateGroupFromJson = (List<Integer>) jsonObject.get("participate-group");
|
||||||
|
Set<User> participateGroup = new HashSet<>();
|
||||||
|
for (int id : participateGroupFromJson) {
|
||||||
|
Optional<User> user = userService.findUserById(id);
|
||||||
|
participateGroup.add(user.get());
|
||||||
|
}
|
||||||
|
activity.setParticipateGroup(participateGroup);
|
||||||
|
|
||||||
|
String title = (String) jsonObject.get("title");
|
||||||
|
activity.setTitle(title);
|
||||||
|
|
||||||
|
int chiefManagerId = (int) jsonObject.get("chief-manager");
|
||||||
|
Optional<User> chiefManager = userService.findUserById(chiefManagerId);
|
||||||
|
activity.setChiefManager(chiefManager.get());
|
||||||
|
|
||||||
|
List<Integer> assistManagersFromJSON = (List<Integer>) jsonObject.get("assist-managers");
|
||||||
|
Set<User> assistManager = new HashSet<>();
|
||||||
|
for (int id : assistManagersFromJSON) {
|
||||||
|
Optional<User> user = userService.findUserById(id);
|
||||||
|
assistManager.add(user.get());
|
||||||
|
}
|
||||||
|
activity.setAssistManagers(assistManager);
|
||||||
|
|
||||||
|
String type = (String) jsonObject.get("type");
|
||||||
|
activity.setType(type);
|
||||||
|
|
||||||
|
String startTimeFromJSON = (String) jsonObject.get("start-time");
|
||||||
|
String endTimeFromJSON = (String) jsonObject.get("end-time");
|
||||||
|
LocalDateTime startTime = LocalDateTime.parse(startTimeFromJSON, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
|
LocalDateTime endTime = LocalDateTime.parse(endTimeFromJSON, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
|
Period period = new Period(startTime, endTime);
|
||||||
|
period.setEnabled(false);
|
||||||
|
period = periodService.save(period);
|
||||||
|
activity.setPlanPeriod(period);
|
||||||
|
|
||||||
|
String cycle = (String) jsonObject.get("cycle");
|
||||||
|
activity.setCycle(cycle);
|
||||||
|
|
||||||
|
String description = (String) jsonObject.get("description");
|
||||||
|
activity.setDescription(description);
|
||||||
|
|
||||||
|
List<Integer> signGroupFromJSON = (List<Integer>) jsonObject.get("sign-group");
|
||||||
|
Set<User> signGroup = new HashSet<>();
|
||||||
|
for (int id : signGroupFromJSON) {
|
||||||
|
Optional<User> user = userService.findUserById(id);
|
||||||
|
signGroup.add(user.get());
|
||||||
|
}
|
||||||
|
activity.setSignGroup(signGroup);
|
||||||
|
|
||||||
|
List<Integer> informGroupFromJSON = (List<Integer>) jsonObject.get("inform-group");
|
||||||
|
if (informGroupFromJSON == null) {
|
||||||
|
participateGroupFromJson.removeAll(signGroupFromJSON);
|
||||||
|
participateGroupFromJson.addAll(signGroupFromJSON);
|
||||||
|
informGroupFromJSON = participateGroupFromJson;
|
||||||
|
}
|
||||||
|
Set<User> informGroup = new HashSet<>();
|
||||||
|
for (int id : informGroupFromJSON) {
|
||||||
|
Optional<User> user = userService.findUserById(id);
|
||||||
|
informGroup.add(user.get());
|
||||||
|
}
|
||||||
|
activity.setInformGroup(informGroup);
|
||||||
|
|
||||||
|
List<Integer> visibleGroupFromJSON = (List<Integer>) jsonObject.get("visible-group");
|
||||||
|
Set<User> visibleGroup = new HashSet<>();
|
||||||
|
for (int id : visibleGroupFromJSON) {
|
||||||
|
Optional<User> user = userService.findUserById(id);
|
||||||
|
visibleGroup.add(user.get());
|
||||||
|
}
|
||||||
|
activity.setVisibleGroup(informGroup);
|
||||||
|
|
||||||
|
String remindTimeFromJSON = (String) jsonObject.get("remind-time");
|
||||||
|
String numStr = remindTimeFromJSON.substring(0, remindTimeFromJSON.length() - 1);
|
||||||
|
int num = Integer.parseInt(numStr);
|
||||||
|
char unit = remindTimeFromJSON.charAt(remindTimeFromJSON.length() - 1);
|
||||||
|
switch (unit) {
|
||||||
|
case 'w': {
|
||||||
|
activity.setRemindTime(activity.getPlanPeriod().getStartTime().minusWeeks(num));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'd': {
|
||||||
|
activity.setRemindTime(activity.getPlanPeriod().getStartTime().minusDays(num));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'm': {
|
||||||
|
activity.setRemindTime(activity.getPlanPeriod().getStartTime().minusMinutes(num));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'h': {
|
||||||
|
activity.setRemindTime(activity.getPlanPeriod().getStartTime().minusHours(num));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 's': {
|
||||||
|
activity.setRemindTime(activity.getPlanPeriod().getStartTime().minusSeconds(num));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Period> periods = new HashSet<>();
|
||||||
|
String[] attendanceTimes = (String[]) jsonObject.get("attendance");
|
||||||
|
boolean attendanceOnLine = (boolean) jsonObject.get("attendance-online");
|
||||||
|
if ((attendanceTimes.length & 1) == 1) {
|
||||||
|
throw new DataInvalidFormatException();
|
||||||
|
}
|
||||||
|
for (int i = 0; i < attendanceTimes.length; i += 2) {
|
||||||
|
LocalDateTime start = LocalDateTime.parse(attendanceTimes[i], DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
|
LocalDateTime end = LocalDateTime.parse(attendanceTimes[i + 1], DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
|
Period period1 = new Period(start, end);
|
||||||
|
periods.add(period1);
|
||||||
|
}
|
||||||
|
Attendance attendance = new Attendance();
|
||||||
|
attendance.setClockInPeriods(periods);
|
||||||
|
attendance.setOnline(attendanceOnLine);
|
||||||
|
/**
|
||||||
|
* 二维码模块未完成
|
||||||
|
*/
|
||||||
|
attendance = attendanceService.save(attendance);
|
||||||
|
activity.setAttendance(attendance);
|
||||||
|
|
||||||
|
activity.setOn(false);
|
||||||
|
activity.setOff(false);
|
||||||
|
|
||||||
|
return activity;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.codesdream.ase.component.activity;
|
||||||
|
|
||||||
|
import com.codesdream.ase.component.ASESpringUtil;
|
||||||
|
import com.codesdream.ase.model.permission.User;
|
||||||
|
import com.codesdream.ase.repository.permission.UserRepository;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.security.Principal;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
//获取当前用户的用户名
|
||||||
|
@Component
|
||||||
|
public class CurrentUserGetter {
|
||||||
|
private Optional<User> user;
|
||||||
|
public Optional<User> getCurrentUser(HttpServletRequest request){
|
||||||
|
|
||||||
|
Principal principal = request.getUserPrincipal();
|
||||||
|
String username = principal.getName();
|
||||||
|
ASESpringUtil aseSpringUtil = new ASESpringUtil();
|
||||||
|
UserRepository userRepository = aseSpringUtil.getBean(UserRepository.class);
|
||||||
|
this.user = userRepository.findByUsername(username);
|
||||||
|
return this.user;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,192 @@
|
|||||||
|
package com.codesdream.ase.component.activity;
|
||||||
|
|
||||||
|
import com.codesdream.ase.exception.conflict.FileNameConflict;
|
||||||
|
import com.codesdream.ase.exception.notfound.AppendixFileNotFoundException;
|
||||||
|
import com.codesdream.ase.model.activity.Activity;
|
||||||
|
import com.codesdream.ase.model.activity.AppendixFile;
|
||||||
|
import com.codesdream.ase.repository.activity.ActivityRepository;
|
||||||
|
import com.codesdream.ase.service.AppendixFileService;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.io.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class FileSystem {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AppendixFileService appendixFileService;
|
||||||
|
|
||||||
|
|
||||||
|
public static final int FAILED = -1;
|
||||||
|
|
||||||
|
//默认文件系统根路径
|
||||||
|
private static final String rootDir = "d:/temp";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于创建文件条目的辅助函数
|
||||||
|
* @param fileName 文件名
|
||||||
|
* @return 文件在数据库中的条目
|
||||||
|
*/
|
||||||
|
private AppendixFile createFileTable(String fileName)
|
||||||
|
{
|
||||||
|
AppendixFile appendixFile = new AppendixFile();
|
||||||
|
appendixFile.setFileName(fileName);
|
||||||
|
appendixFile.setLastEditTime(LocalDateTime.now());
|
||||||
|
String[] temp = fileName.split("\\.",2);
|
||||||
|
for(String s : temp)
|
||||||
|
System.out.println(s);
|
||||||
|
if(temp.length == 1)
|
||||||
|
appendixFile.setType("");
|
||||||
|
else
|
||||||
|
appendixFile.setType(temp[temp.length-1]);
|
||||||
|
return appendixFile;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向磁盘中添加一个文件,并在数据库建立条目
|
||||||
|
* @param data 文件的数据
|
||||||
|
* @param fileName 文件名,包括拓展名
|
||||||
|
* @return 成功时返回文件id,失败时返回FileSystem.FAILED
|
||||||
|
*/
|
||||||
|
public int addFile(byte data[], String fileName) throws Exception
|
||||||
|
{
|
||||||
|
AppendixFile appendixFile = createFileTable(fileName);
|
||||||
|
appendixFile = appendixFileService.save(appendixFile);
|
||||||
|
File file = new File(rootDir,""+appendixFile.getId());
|
||||||
|
FileOutputStream outputStream;
|
||||||
|
if(file.exists())
|
||||||
|
throw new FileNameConflict(
|
||||||
|
"file name conflict,there is a file in the directory, and is not created by this program",
|
||||||
|
file.getName());
|
||||||
|
File parent = file.getParentFile();
|
||||||
|
if(!parent.exists())
|
||||||
|
parent.mkdirs();
|
||||||
|
try{
|
||||||
|
file.createNewFile();
|
||||||
|
outputStream = new FileOutputStream(file);
|
||||||
|
outputStream.write(data);
|
||||||
|
outputStream.close();
|
||||||
|
return appendixFile.getId();
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
appendixFileService.delete(appendixFile);
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new Exception(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id获取一个磁盘中的文件
|
||||||
|
* @param id 文件的id
|
||||||
|
* @return 成功返回文件的InputStream,失败返回null
|
||||||
|
*/
|
||||||
|
public InputStream getFile(int id)throws AppendixFileNotFoundException
|
||||||
|
{
|
||||||
|
Optional<AppendixFile> optionalAppendixFile = appendixFileService.findById(id);
|
||||||
|
if(!optionalAppendixFile.isPresent())
|
||||||
|
throw new AppendixFileNotFoundException(
|
||||||
|
"the required id does not exist in the database",id,
|
||||||
|
AppendixFileNotFoundException.ID_NOT_FOUND);
|
||||||
|
|
||||||
|
AppendixFile appendixFile = appendixFileService.findById(id).get();
|
||||||
|
File file = new File(rootDir,""+appendixFile.getId());
|
||||||
|
|
||||||
|
if(file.exists())
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
InputStream inputStream = new FileInputStream(file);
|
||||||
|
return inputStream;
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new AppendixFileNotFoundException(
|
||||||
|
"the required id exists in the database, but the stream can not be opened",id,
|
||||||
|
AppendixFileNotFoundException.STREAM_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw new AppendixFileNotFoundException(
|
||||||
|
"the required id exists in the database, but the file is missing",id,
|
||||||
|
AppendixFileNotFoundException.FILE_NOT_fOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除一个文件,如果该文件不存在,则不会发生操作
|
||||||
|
* @param id 要删除文件的id
|
||||||
|
*/
|
||||||
|
public void deleteFile(int id)
|
||||||
|
{
|
||||||
|
Optional<AppendixFile> optionalAppendixFile = appendixFileService.findById(id);
|
||||||
|
if(!optionalAppendixFile.isPresent())
|
||||||
|
return;
|
||||||
|
AppendixFile appendixFile = appendixFileService.findById(id).get();
|
||||||
|
File file = new File(rootDir,""+appendixFile.getId());
|
||||||
|
if(file.exists()) {
|
||||||
|
file.delete();
|
||||||
|
appendixFileService.delete(appendixFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id获取一个文件的条目,其中包含文件信息
|
||||||
|
* @param id 要寻找条目的id
|
||||||
|
*/
|
||||||
|
public AppendixFile getFileData(int id)
|
||||||
|
{
|
||||||
|
Optional<AppendixFile> optionalAppendixFile = appendixFileService.findById(id);
|
||||||
|
if(!optionalAppendixFile.isPresent())
|
||||||
|
throw new AppendixFileNotFoundException(
|
||||||
|
"the required id does not exist in the database",id,
|
||||||
|
AppendixFileNotFoundException.ID_NOT_FOUND);
|
||||||
|
|
||||||
|
AppendixFile appendixFile = appendixFileService.findById(id).get();
|
||||||
|
|
||||||
|
return appendixFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 维护数据库,删去所有文件已经缺失的条目(仅用于在文件系统出现故障时的维护)
|
||||||
|
*/
|
||||||
|
public void databaseRefresh()
|
||||||
|
{
|
||||||
|
for (AppendixFile appendixFile:
|
||||||
|
appendixFileService.findAll()) {
|
||||||
|
File file = new File(rootDir,""+appendixFile.getId());
|
||||||
|
if(!file.exists())
|
||||||
|
appendixFileService.delete(appendixFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 维护磁盘,删除指定根目录下所有不在数据库中的文件(仅用于文件系统出现故障时的维护)
|
||||||
|
*/
|
||||||
|
public void diskRefresh()
|
||||||
|
{
|
||||||
|
File dir = new File(rootDir);
|
||||||
|
|
||||||
|
if (dir.exists()) {
|
||||||
|
if (null == dir.listFiles()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(File file : dir.listFiles())
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
try{
|
||||||
|
id = Integer.parseInt(file.getName());
|
||||||
|
if(!appendixFileService.findById(id).isPresent())
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
catch (Exception ex){
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,129 @@
|
|||||||
|
package com.codesdream.ase.component.activity;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.imageio.stream.ImageOutputStream;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class FileUtils {
|
||||||
|
/**
|
||||||
|
* 得到图片字节流 数组大小
|
||||||
|
*/
|
||||||
|
public static byte[] readStream(InputStream inStream) throws Exception {
|
||||||
|
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int len = -1;
|
||||||
|
while ((len = inStream.read(buffer)) != -1) {
|
||||||
|
outStream.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
outStream.close();
|
||||||
|
inStream.close();
|
||||||
|
return outStream.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将文件转换成Byte数组
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static byte[] getBytesByFile(File file) {
|
||||||
|
try {
|
||||||
|
FileInputStream fis = new FileInputStream(file);
|
||||||
|
ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
|
||||||
|
byte[] b = new byte[1000];
|
||||||
|
int n;
|
||||||
|
while ((n = fis.read(b)) != -1) {
|
||||||
|
bos.write(b, 0, n);
|
||||||
|
}
|
||||||
|
fis.close();
|
||||||
|
byte[] data = bos.toByteArray();
|
||||||
|
bos.close();
|
||||||
|
return data;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MultipartFile转File
|
||||||
|
*
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static File transfer(MultipartFile param) {
|
||||||
|
if (!param.isEmpty()) {
|
||||||
|
File file = null;
|
||||||
|
try {
|
||||||
|
InputStream in = param.getInputStream();
|
||||||
|
file = new File(param.getOriginalFilename());
|
||||||
|
OutputStream out = new FileOutputStream(file);
|
||||||
|
int bytesRead = 0;
|
||||||
|
byte[] buffer = new byte[8192];
|
||||||
|
while ((bytesRead = in.read(buffer, 0, 8192)) != -1) {
|
||||||
|
out.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
in.close();
|
||||||
|
out.close();
|
||||||
|
return file;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定文件的输入流
|
||||||
|
*
|
||||||
|
* @param logoPath 文件的路径
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static InputStream getResourceAsStream(String logoPath) {
|
||||||
|
return FileUtils.class.getResourceAsStream(logoPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将InputStream写入到File中
|
||||||
|
*
|
||||||
|
* @param ins
|
||||||
|
* @param file
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public void inputStreamToFile(InputStream ins, File file) throws IOException {
|
||||||
|
OutputStream os = new FileOutputStream(file);
|
||||||
|
int bytesRead = 0;
|
||||||
|
byte[] buffer = new byte[8192];
|
||||||
|
while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
|
||||||
|
os.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
os.close();
|
||||||
|
ins.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将图片转化成输入流
|
||||||
|
*
|
||||||
|
* @param image 图片
|
||||||
|
* @return inputStream 图片转化之后的输入流
|
||||||
|
*/
|
||||||
|
public static InputStream getImageStream(BufferedImage image) {
|
||||||
|
InputStream inputStream = null;
|
||||||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
|
ImageOutputStream imageOutputStream;
|
||||||
|
try {
|
||||||
|
imageOutputStream = ImageIO.createImageOutputStream(byteArrayOutputStream);
|
||||||
|
ImageIO.write(image, "jpg", imageOutputStream);
|
||||||
|
inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return inputStream;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.codesdream.ase.component.activity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
public class NullValueAttributes {
|
||||||
|
private List<String> nullValueAttributes;
|
||||||
|
}
|
@ -0,0 +1,227 @@
|
|||||||
|
package com.codesdream.ase.component.activity;
|
||||||
|
|
||||||
|
import com.google.zxing.BarcodeFormat;
|
||||||
|
import com.google.zxing.EncodeHintType;
|
||||||
|
import com.google.zxing.MultiFormatWriter;
|
||||||
|
import com.google.zxing.common.BitMatrix;
|
||||||
|
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||||
|
import jdk.internal.util.xml.impl.Input;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.imageio.stream.ImageOutputStream;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.geom.RoundRectangle2D;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二维码生成工具类
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class QrCodeUtils {
|
||||||
|
private static final String CHARSET = "utf-8";
|
||||||
|
public static final String FORMAT = "JPG";
|
||||||
|
// 二维码尺寸
|
||||||
|
private static final int QRCODE_SIZE = 300;
|
||||||
|
// LOGO宽度
|
||||||
|
private static final int LOGO_WIDTH = 60;
|
||||||
|
// LOGO高度
|
||||||
|
private static final int LOGO_HEIGHT = 60;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成二维码
|
||||||
|
*
|
||||||
|
* @param content 二维码内容
|
||||||
|
* @param logoPath logo地址
|
||||||
|
* @param needCompress 是否压缩logo
|
||||||
|
* @return 图片
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static BufferedImage createImage(String content, String logoPath, boolean needCompress) throws Exception {
|
||||||
|
Hashtable<EncodeHintType, Object> hints = new Hashtable<>();
|
||||||
|
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
|
||||||
|
hints.put(EncodeHintType.CHARACTER_SET, CHARSET);
|
||||||
|
hints.put(EncodeHintType.MARGIN, 1);
|
||||||
|
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, QRCODE_SIZE, QRCODE_SIZE,
|
||||||
|
hints);
|
||||||
|
int width = bitMatrix.getWidth();
|
||||||
|
int height = bitMatrix.getHeight();
|
||||||
|
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
image.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (logoPath == null || "".equals(logoPath)) {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
// 插入图片
|
||||||
|
QrCodeUtils.insertImage(image, logoPath, needCompress);
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入LOGO
|
||||||
|
*
|
||||||
|
* @param source 二维码图片
|
||||||
|
* @param logoPath LOGO图片地址
|
||||||
|
* @param needCompress 是否压缩
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
private static void insertImage(BufferedImage source, String logoPath, boolean needCompress) throws IOException {
|
||||||
|
InputStream inputStream = null;
|
||||||
|
try {
|
||||||
|
inputStream = FileUtils.getResourceAsStream(logoPath);
|
||||||
|
Image src = ImageIO.read(inputStream);
|
||||||
|
int width = src.getWidth(null);
|
||||||
|
int height = src.getHeight(null);
|
||||||
|
if (needCompress) { // 压缩LOGO
|
||||||
|
if (width > LOGO_WIDTH) {
|
||||||
|
width = LOGO_WIDTH;
|
||||||
|
}
|
||||||
|
if (height > LOGO_HEIGHT) {
|
||||||
|
height = LOGO_HEIGHT;
|
||||||
|
}
|
||||||
|
Image image = src.getScaledInstance(width, height, Image.SCALE_SMOOTH);
|
||||||
|
BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||||
|
Graphics g = tag.getGraphics();
|
||||||
|
g.drawImage(image, 0, 0, null); // 绘制缩小后的图
|
||||||
|
g.dispose();
|
||||||
|
src = image;
|
||||||
|
}
|
||||||
|
// 插入LOGO
|
||||||
|
Graphics2D graph = source.createGraphics();
|
||||||
|
int x = (QRCODE_SIZE - width) / 2;
|
||||||
|
int y = (QRCODE_SIZE - height) / 2;
|
||||||
|
graph.drawImage(src, x, y, width, height, null);
|
||||||
|
Shape shape = new RoundRectangle2D.Float(x, y, width, width, 6, 6);
|
||||||
|
graph.setStroke(new BasicStroke(3f));
|
||||||
|
graph.draw(shape);
|
||||||
|
graph.dispose();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
if (inputStream != null) {
|
||||||
|
inputStream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成二维码(内嵌LOGO)
|
||||||
|
* 二维码文件名随机,文件名可能会有重复
|
||||||
|
*
|
||||||
|
* @param content 内容
|
||||||
|
* @param logoPath LOGO地址
|
||||||
|
* @param destPath 存放目录
|
||||||
|
* @param needCompress 是否压缩LOGO
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static String encode(String content, String logoPath, String destPath, boolean needCompress) throws Exception {
|
||||||
|
BufferedImage image = QrCodeUtils.createImage(content, logoPath, needCompress);
|
||||||
|
mkdirs(destPath);
|
||||||
|
String fileName = new Random().nextInt(99999999) + "." + FORMAT.toLowerCase();
|
||||||
|
ImageIO.write(image, FORMAT, new File(destPath + "/" + fileName));
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成二维码(内嵌LOGO)
|
||||||
|
* 调用者指定二维码文件名
|
||||||
|
*
|
||||||
|
* @param content 内容
|
||||||
|
* @param logoPath LOGO地址
|
||||||
|
* @param destPath 存放目录
|
||||||
|
* @param fileName 二维码文件名
|
||||||
|
* @param needCompress 是否压缩LOGO
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static String encode(String content, String logoPath, String destPath, String fileName, boolean needCompress) throws Exception {
|
||||||
|
BufferedImage image = QrCodeUtils.createImage(content, logoPath, needCompress);
|
||||||
|
mkdirs(destPath);
|
||||||
|
fileName = fileName.substring(0, fileName.indexOf(".") > 0 ? fileName.indexOf(".") : fileName.length())
|
||||||
|
+ "." + FORMAT.toLowerCase();
|
||||||
|
ImageIO.write(image, FORMAT, new File(destPath + "/" + fileName));
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当文件夹不存在时,mkdirs会自动创建多层目录,区别于mkdir.
|
||||||
|
* (mkdir如果父目录不存在则会抛出异常)
|
||||||
|
*
|
||||||
|
* @param destPath 存放目录
|
||||||
|
*/
|
||||||
|
public static void mkdirs(String destPath) {
|
||||||
|
File file = new File(destPath);
|
||||||
|
if (!file.exists() && !file.isDirectory()) {
|
||||||
|
file.mkdirs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成二维码(内嵌LOGO)
|
||||||
|
*
|
||||||
|
* @param content 内容
|
||||||
|
* @param logoPath LOGO地址
|
||||||
|
* @param destPath 存储地址
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static String encode(String content, String logoPath, String destPath) throws Exception {
|
||||||
|
return QrCodeUtils.encode(content, logoPath, destPath, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成二维码
|
||||||
|
*
|
||||||
|
* @param content 内容
|
||||||
|
* @param destPath 存储地址
|
||||||
|
* @param needCompress 是否压缩LOGO
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static String encode(String content, String destPath, boolean needCompress) throws Exception {
|
||||||
|
return QrCodeUtils.encode(content, null, destPath, needCompress);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成二维码
|
||||||
|
*
|
||||||
|
* @param content 内容
|
||||||
|
* @param destPath 存储地址
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static String encode(String content, String destPath) throws Exception {
|
||||||
|
return QrCodeUtils.encode(content, null, destPath, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成二维码(内嵌LOGO)
|
||||||
|
*
|
||||||
|
* @param content 内容
|
||||||
|
* @param logoPath LOGO地址
|
||||||
|
* @param output 输出流
|
||||||
|
* @param needCompress 是否压缩LOGO
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void encode(String content, String logoPath, OutputStream output, boolean needCompress)
|
||||||
|
throws Exception {
|
||||||
|
BufferedImage image = QrCodeUtils.createImage(content, logoPath, needCompress);
|
||||||
|
ImageIO.write(image, FORMAT, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成二维码
|
||||||
|
*
|
||||||
|
* @param content 内容
|
||||||
|
* @param output 输出流
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static void encode(String content, OutputStream output) throws Exception {
|
||||||
|
QrCodeUtils.encode(content, null, output, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,130 @@
|
|||||||
|
package com.codesdream.ase.component.api;
|
||||||
|
|
||||||
|
import com.codesdream.ase.component.datamanager.JSONParameter;
|
||||||
|
import com.codesdream.ase.component.json.respond.EmptyDataObjectRespond;
|
||||||
|
import com.codesdream.ase.component.json.respond.JSONBaseRespondObject;
|
||||||
|
import com.sun.deploy.net.HttpResponse;
|
||||||
|
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,8 +1,6 @@
|
|||||||
package com.codesdream.ase.component.permission;
|
package com.codesdream.ase.component.auth;
|
||||||
|
|
||||||
import com.codesdream.ase.component.datamanager.JSONParameter;
|
import com.codesdream.ase.component.api.QuickJSONRespond;
|
||||||
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,16 +1,12 @@
|
|||||||
package com.codesdream.ase.component.permission;
|
package com.codesdream.ase.component.auth;
|
||||||
|
|
||||||
import com.codesdream.ase.component.datamanager.JSONParameter;
|
import com.codesdream.ase.component.api.QuickJSONRespond;
|
||||||
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,16 +1,13 @@
|
|||||||
package com.codesdream.ase.component.permission;
|
package com.codesdream.ase.component.auth;
|
||||||
|
|
||||||
import com.codesdream.ase.component.datamanager.JSONParameter;
|
import com.codesdream.ase.component.api.QuickJSONRespond;
|
||||||
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,8 +1,6 @@
|
|||||||
package com.codesdream.ase.component.permission;
|
package com.codesdream.ase.component.auth;
|
||||||
|
|
||||||
import com.codesdream.ase.component.auth.JSONTokenAuthenticationToken;
|
import com.codesdream.ase.component.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 com.codesdream.ase.component.json.respond.UserLoginCheckerJSONRespond;
|
||||||
import com.codesdream.ase.model.permission.User;
|
import com.codesdream.ase.model.permission.User;
|
||||||
|
|
||||||
@ -19,7 +17,6 @@ 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;
|
||||||
|
|
||||||
@ -41,6 +38,7 @@ 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,4 +1,4 @@
|
|||||||
package com.codesdream.ase.component.permission;
|
package com.codesdream.ase.component.auth;
|
||||||
|
|
||||||
import com.codesdream.ase.component.auth.AJAXRequestChecker;
|
import com.codesdream.ase.component.auth.AJAXRequestChecker;
|
||||||
import com.codesdream.ase.component.auth.JSONRandomCodeGenerator;
|
import com.codesdream.ase.component.auth.JSONRandomCodeGenerator;
|
||||||
@ -30,15 +30,9 @@ 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;
|
||||||
|
|
||||||
@ -59,7 +53,13 @@ public class ASEJSONTokenAuthenticationFilter extends OncePerRequestFilter {
|
|||||||
// 时间戳
|
// 时间戳
|
||||||
String timestamp = request.getHeader("timestamp");
|
String timestamp = request.getHeader("timestamp");
|
||||||
|
|
||||||
if (signed != null && username != null && timestamp != null) {
|
// 服务端API测试豁免签名
|
||||||
|
if(signed != null && signed.equals("6d4923fca4dcb51f67b85e54a23a8d763d9e02af")){
|
||||||
|
//执行授权
|
||||||
|
doAuthentication("u_id_88883b9e023c8824310760d8bb8b6542e5a3f16a0d67253214e01ee7ab0e96a1", 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.permission;
|
package com.codesdream.ase.component.auth;
|
||||||
|
|
||||||
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,7 +1,5 @@
|
|||||||
package com.codesdream.ase.component.permission;
|
package com.codesdream.ase.component.auth;
|
||||||
|
|
||||||
import com.codesdream.ase.component.auth.JSONTokenAuthenticationToken;
|
|
||||||
import com.codesdream.ase.component.auth.JSONTokenUsernamePasswordAuthenticationToken;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import 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;
|
||||||
@ -34,11 +32,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 password = passwordEncoder.encode((CharSequence) authenticationToken.getCredentials());
|
String encrypted_password = (String) authenticationToken.getCredentials();
|
||||||
// 获得
|
// 获得客户端代码
|
||||||
String clientCode = authenticationToken.getClientCode();
|
String clientCode = authenticationToken.getClientCode();
|
||||||
// 判断用户是否存在
|
// 判断用户是否存在
|
||||||
UserDetails userInfo = userDetailsService.loadUserByUsername(username);
|
UserDetails userInfo = userDetailsService.loadUserByUsername(username);
|
||||||
@ -47,20 +45,23 @@ public class ASESecurityAuthenticationProvider implements AuthenticationProvider
|
|||||||
throw new UsernameNotFoundException("User Not Exist");
|
throw new UsernameNotFoundException("User Not Exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String sha256_password = userInfo.getPassword();
|
||||||
|
|
||||||
// 判断密码是否正确
|
// 判断密码是否正确
|
||||||
if (!userInfo.getPassword().equals(password)) {
|
if(!passwordEncoder.encode(String.format(
|
||||||
throw new BadCredentialsException("Password IS Uncorrected");
|
"PASS_ENCODE [%s][%s]", sha256_password, clientCode)).equals(encrypted_password)){
|
||||||
|
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.permission;
|
package com.codesdream.ase.component.auth;
|
||||||
|
|
||||||
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.permission;
|
package com.codesdream.ase.component.auth;
|
||||||
|
|
||||||
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,19 +8,17 @@ 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 {
|
||||||
|
|
||||||
@ -65,6 +63,7 @@ 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();
|
||||||
|
|
@ -7,11 +7,11 @@ import org.springframework.stereotype.Component;
|
|||||||
// SHA1算法不可逆加密 主要用于JSON签名
|
// SHA1算法不可逆加密 主要用于JSON签名
|
||||||
@Component
|
@Component
|
||||||
public class SHA1Encoder {
|
public class SHA1Encoder {
|
||||||
String encode(CharSequence charSequence){
|
public String encode(CharSequence charSequence){
|
||||||
return DigestUtils.sha1Hex(charSequence.toString());
|
return DigestUtils.sha1Hex(charSequence.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean match(CharSequence charSequence, String s){
|
public boolean match (CharSequence charSequence, String s){
|
||||||
return s.equals(encode(charSequence));
|
return s.equals(encode(charSequence));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,4 +15,10 @@ 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.DataFileNotFoundException;
|
import com.codesdream.ase.exception.notfound.DataFileNotFoundException;
|
||||||
import com.codesdream.ase.exception.DataIOException;
|
import com.codesdream.ase.exception.innerservererror.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,6 +2,10 @@ 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.*;
|
||||||
|
|
||||||
@ -47,7 +51,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,11 +1,9 @@
|
|||||||
package com.codesdream.ase.component.datamanager;
|
package com.codesdream.ase.component.datamanager;
|
||||||
|
|
||||||
import com.codesdream.ase.exception.DataIllegalTableFormatException;
|
import com.codesdream.ase.exception.innerservererror.DataIllegalTableFormatException;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.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.*;
|
||||||
|
|
||||||
// 描述一张数据表
|
// 描述一张数据表
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.codesdream.ase.component.datamanager;
|
||||||
|
|
||||||
|
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.Controller;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class JsonPathParameter {
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,80 +0,0 @@
|
|||||||
package com.codesdream.ase.component.datamanager;
|
|
||||||
|
|
||||||
import com.codesdream.ase.component.json.respond.EmptyDataObjectRespond;
|
|
||||||
import com.codesdream.ase.component.json.respond.JSONBaseRespondObject;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class QuickJSONRespond {
|
|
||||||
@Resource
|
|
||||||
private JSONParameter jsonParameter;
|
|
||||||
|
|
||||||
// 根据对象构造获得标准的JSON响应字符串返回
|
|
||||||
public String getJSONStandardRespond(Integer status, String msg, String info, Object dataObject){
|
|
||||||
JSONBaseRespondObject respondObject = new JSONBaseRespondObject(status, msg);
|
|
||||||
if(info != null) respondObject.setInfo(info);
|
|
||||||
else respondObject.setInfo(null);
|
|
||||||
|
|
||||||
respondObject.setData(dataObject);
|
|
||||||
return jsonParameter.getJSONString(respondObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获得标准的JSON响应字符串返回特定状态码的和解释息
|
|
||||||
public String getJSONStandardRespond(Integer code, String msg, String info){
|
|
||||||
JSONBaseRespondObject respondObject = new JSONBaseRespondObject(code, msg);
|
|
||||||
if(info != null) respondObject.setInfo(info);
|
|
||||||
else respondObject.setInfo(null);
|
|
||||||
respondObject.setData(null);
|
|
||||||
return jsonParameter.getJSONString(respondObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获得标准的JSON响应字符串返回(404状态)
|
|
||||||
public String getRespond404(String info){
|
|
||||||
return getJSONStandardRespond(404, "Not Found", info);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获得标准的JSON响应字符串返回(500状态)
|
|
||||||
public String getRespond500(String info){
|
|
||||||
return getJSONStandardRespond(500, "Internal Server Error", info);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获得标准的JSON响应字符串返回(200状态)
|
|
||||||
public String getRespond200(String info){
|
|
||||||
return getJSONStandardRespond(200, "Ok", info);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获得标准的JSON响应字符串返回(200状态)
|
|
||||||
public String getRespond200(String info, Object object){
|
|
||||||
return getJSONStandardRespond(200, "Ok", info, object);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获得标准的JSON响应字符串返回(403状态)
|
|
||||||
public String getRespond403(String info){
|
|
||||||
return getJSONStandardRespond(403, "Forbidden", info);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获得标准的JSON响应字符串返回(403状态)
|
|
||||||
public String getRespond406(String info){
|
|
||||||
return getJSONStandardRespond(406, "Not Acceptable", info);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获得标准的JSON响应字符串返回(501态)
|
|
||||||
public String getRespond501(String info){
|
|
||||||
return getJSONStandardRespond(501, "Not Implemented", info) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获得标准的JSON响应字符串返回(401状态)
|
|
||||||
public String getRespond401(String info){
|
|
||||||
return getJSONStandardRespond(401, "Unauthorized", info);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获得标准的JSON响应字符串返回(400状态)
|
|
||||||
public String getRespond400(String info){
|
|
||||||
return getJSONStandardRespond(400, "Bad Request", info);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.codesdream.ase.component.datamanager;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
// 储存字符串标识的文件,并可以转换为json进行传输
|
||||||
|
@Data
|
||||||
|
public class StringFile {
|
||||||
|
private String strData = null;
|
||||||
|
private String sha1Checker = null;
|
||||||
|
private Integer size = null;
|
||||||
|
private String type = "none";
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
package com.codesdream.ase.component.datamanager;
|
||||||
|
|
||||||
|
import com.codesdream.ase.component.auth.SHA1Encoder;
|
||||||
|
import com.codesdream.ase.exception.StringFileConvertException;
|
||||||
|
import com.sun.xml.internal.messaging.saaj.util.ByteInputStream;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.Base64;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
|
// 将文件处理成可发送的字符串文件对象
|
||||||
|
@Component
|
||||||
|
public class StringFileGenerator {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SHA1Encoder encoder;
|
||||||
|
|
||||||
|
// 用过读入流创建一个字符串文件
|
||||||
|
public Optional<StringFile> generateStringFile(InputStream stream){
|
||||||
|
StringFile file = new StringFile();
|
||||||
|
// 字符串内容计算
|
||||||
|
file.setStrData(generateFile2String(stream));
|
||||||
|
if(file.getStrData() == null) return Optional.empty();
|
||||||
|
// 相关校验值计算
|
||||||
|
file.setSha1Checker(generateSHA1Checker(file.getStrData()));
|
||||||
|
file.setSize(file.getStrData().length());
|
||||||
|
return Optional.of(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] readSteamAll(InputStream stream) {
|
||||||
|
try {
|
||||||
|
byte[] bytes = new byte[stream.available()];
|
||||||
|
|
||||||
|
//检查文件书否完全读取
|
||||||
|
if (stream.read(bytes) != bytes.length) return null;
|
||||||
|
else return bytes;
|
||||||
|
} catch (IOException e){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String generateFile2String(InputStream stream){
|
||||||
|
ByteArrayOutputStream zipDataStream = new ByteArrayOutputStream();
|
||||||
|
try {
|
||||||
|
GZIPOutputStream gzipOutputStream = new GZIPOutputStream(zipDataStream);
|
||||||
|
byte[] bytes = readSteamAll(stream);
|
||||||
|
if(bytes == null) return null;
|
||||||
|
gzipOutputStream.write(bytes);
|
||||||
|
gzipOutputStream.close();
|
||||||
|
return Base64.getEncoder().encodeToString(zipDataStream.toByteArray());
|
||||||
|
} catch (IOException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成字符串文件的校验码
|
||||||
|
private String generateSHA1Checker(String str){
|
||||||
|
return encoder.encode(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查文件内容是否正确,包括大小与校验码
|
||||||
|
public boolean checkStringFile(StringFile file){
|
||||||
|
return file.getStrData().length() == file.getSize()
|
||||||
|
&& encoder.match(file.getStrData(), file.getSha1Checker());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从字符串文件中读取真实的文件数据
|
||||||
|
public InputStream readFileString(StringFile file){
|
||||||
|
try {
|
||||||
|
// 字符串转换为二进制数据
|
||||||
|
byte[] bytes = Base64.getDecoder().decode(file.getStrData());
|
||||||
|
GZIPInputStream stream = new GZIPInputStream(new ByteArrayInputStream(bytes), bytes.length);
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
// 数据解压缩
|
||||||
|
int readBits = 0;
|
||||||
|
byte[] rawBytes = new byte[1024];
|
||||||
|
while ((readBits = stream.read(rawBytes)) != -1) {
|
||||||
|
outputStream.write(rawBytes, 0, readBits);
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.close();
|
||||||
|
return new ByteArrayInputStream(outputStream.toByteArray());
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new StringFileConvertException("Read FileString Failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,5 +8,5 @@ import java.util.Date;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class JSONBaseObject {
|
public class JSONBaseObject {
|
||||||
Date time = new Date();
|
Date time = new Date();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.codesdream.ase.component.json.model;
|
||||||
|
|
||||||
|
import com.codesdream.ase.model.permission.PermissionContainersCollection;
|
||||||
|
import com.codesdream.ase.model.permission.Tag;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@ApiModel("权限容器集合列表")
|
||||||
|
public class JsonablePCCList {
|
||||||
|
List<Integer> pccIdList;
|
||||||
|
|
||||||
|
public JsonablePCCList(Tag tag){
|
||||||
|
for(PermissionContainersCollection pcc : tag.getPermissionContainersCollections()){
|
||||||
|
pccIdList.add(pcc.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.codesdream.ase.component.json.model;
|
||||||
|
|
||||||
|
import com.codesdream.ase.model.permission.Tag;
|
||||||
|
import com.codesdream.ase.model.permission.User;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import net.bytebuddy.implementation.bind.annotation.DefaultMethod;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@ApiModel("标签")
|
||||||
|
public class JsonableTag {
|
||||||
|
@ApiModelProperty(value = "标签id")
|
||||||
|
private Integer id = null;
|
||||||
|
@ApiModelProperty(value = "标签名", example = "系统管理员")
|
||||||
|
private String name;
|
||||||
|
@ApiModelProperty(value = "标签说明", example = "该系统的管理员")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
|
||||||
|
public JsonableTag(Tag tag){
|
||||||
|
this.id = tag.getId();
|
||||||
|
this.name = tag.getName();
|
||||||
|
this.description = tag.getDescription();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
package com.codesdream.ase.component.json.model;
|
||||||
|
|
||||||
|
public class JsonableUidGetter {
|
||||||
|
private String checkType;
|
||||||
|
private String username;
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.codesdream.ase.component.json.model;
|
||||||
|
|
||||||
|
import com.codesdream.ase.model.permission.User;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("用户")
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class JsonableUser {
|
||||||
|
private Integer id;
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
public JsonableUser(User user){
|
||||||
|
this.id = user.getId();
|
||||||
|
this.username = user.getUsername();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.codesdream.ase.component.json.model;
|
||||||
|
|
||||||
|
import com.codesdream.ase.model.permission.Tag;
|
||||||
|
import com.codesdream.ase.model.permission.User;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@ApiModel("标签所属用户集合")
|
||||||
|
public class JsonableUserList {
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "用户列表")
|
||||||
|
private List<Integer> users;
|
||||||
|
|
||||||
|
|
||||||
|
public JsonableUserList(Tag tag){
|
||||||
|
for(User user : tag.getUsers()){
|
||||||
|
users.add(user.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.codesdream.ase.component.json.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserLeaveAuth {
|
||||||
|
/*
|
||||||
|
备注
|
||||||
|
*/
|
||||||
|
private int id;
|
||||||
|
private String Comment;
|
||||||
|
/*
|
||||||
|
审核结果
|
||||||
|
*/
|
||||||
|
private String newStat;
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.codesdream.ase.component.json.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
@Data
|
||||||
|
public class UserLeaveRequest {
|
||||||
|
private String UserId;//用户名
|
||||||
|
private String Type;//请假类型
|
||||||
|
private String Reason;//请假原因
|
||||||
|
private String Addon;//附件
|
||||||
|
private Date Starttime;//开始时间
|
||||||
|
private Date EndTime;//结束时间
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.codesdream.ase.component.json.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserSGettudentLeaveListRequest {
|
||||||
|
private int studentId;
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.codesdream.ase.component.json.respond;
|
||||||
|
|
||||||
|
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PermissionJSONRespond {
|
||||||
|
private Boolean tagExist = null;
|
||||||
|
private Boolean actionSuccess = null;
|
||||||
|
private Integer tagId = null;
|
||||||
|
private String tagName = null;
|
||||||
|
private Set<Integer> users = null;
|
||||||
|
}
|
@ -12,5 +12,6 @@ public class UserLoginCheckerJSONRespond {
|
|||||||
String respondInformation = null;
|
String respondInformation = null;
|
||||||
String token = null;
|
String token = null;
|
||||||
String uid = null;
|
String uid = null;
|
||||||
|
String pvc = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
package com.codesdream.ase.configure;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.core.parameters.P;
|
||||||
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
|
import springfox.documentation.builders.ParameterBuilder;
|
||||||
|
import springfox.documentation.builders.PathSelectors;
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
import springfox.documentation.schema.ModelRef;
|
||||||
|
import springfox.documentation.service.ApiInfo;
|
||||||
|
import springfox.documentation.service.Parameter;
|
||||||
|
import springfox.documentation.spi.DocumentationType;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableSwagger2
|
||||||
|
public class ASESwaggerConfigure {
|
||||||
|
@Bean
|
||||||
|
public Docket createRestApi() {
|
||||||
|
|
||||||
|
List<Parameter> pars = new ArrayList<Parameter>();
|
||||||
|
|
||||||
|
pars.add(new ParameterBuilder().name("username").description("真实用户名").hidden(true).order(1)
|
||||||
|
.modelRef(new ModelRef("string")).parameterType("header")
|
||||||
|
.required(false).defaultValue("u_id_88883b9e023c8824310760d8bb8b6542e5a3f16a0d67253214e01ee7ab0e96a1").build());
|
||||||
|
pars.add(new ParameterBuilder().name("signed").description("客户端签名").hidden(true).order(2)
|
||||||
|
.modelRef(new ModelRef("string")).parameterType("header")
|
||||||
|
.required(false).defaultValue("6d4923fca4dcb51f67b85e54a23a8d763d9e02af").build());
|
||||||
|
pars.add(new ParameterBuilder().name("timestamp").description("时间戳").hidden(true).order(3)
|
||||||
|
.modelRef(new ModelRef("string")).parameterType("header")
|
||||||
|
.required(false).defaultValue(Long.toString(new Date().getTime())).build());
|
||||||
|
|
||||||
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.protocols(Sets.newHashSet("http"))
|
||||||
|
.apiInfo(apiInfo())
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.basePackage("com.codesdream.ase.controller"))
|
||||||
|
.paths(PathSelectors.any())
|
||||||
|
.build()
|
||||||
|
.globalOperationParameters(pars);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiInfo apiInfo() {
|
||||||
|
return new ApiInfoBuilder()
|
||||||
|
.title("全员育人管理系统后端接口定义")
|
||||||
|
.version("0.0.1")
|
||||||
|
.description("用于对后端接口进行说明")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
@ -30,6 +30,7 @@ public class ActivityFormConfigure {
|
|||||||
add("attendance");
|
add("attendance");
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
|
||||||
public HashSet<String> getStdActivityForm() {
|
public HashSet<String> getStdActivityForm() {
|
||||||
return stdActivityForm;
|
return stdActivityForm;
|
||||||
}
|
}
|
||||||
|
@ -39,4 +39,5 @@ public class AppConfigure {
|
|||||||
public String getOrganization() {
|
public String getOrganization() {
|
||||||
return "全员育人WEB端开发组";
|
return "全员育人WEB端开发组";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package com.codesdream.ase.configure;
|
package com.codesdream.ase.configure;
|
||||||
|
|
||||||
import com.codesdream.ase.component.permission.*;
|
import com.codesdream.ase.component.auth.*;
|
||||||
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;
|
||||||
@ -14,11 +13,8 @@ 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.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;
|
||||||
@ -91,7 +87,13 @@ 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,31 +1,77 @@
|
|||||||
package com.codesdream.ase.controller;
|
package com.codesdream.ase.controller;
|
||||||
|
|
||||||
import com.codesdream.ase.component.error.ErrorResponse;
|
import com.codesdream.ase.component.api.QuickJSONRespond;
|
||||||
import com.codesdream.ase.component.json.respond.ErrorInfoJSONRespond;
|
import com.codesdream.ase.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 java.util.ArrayList;
|
import javax.annotation.Resource;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestControllerAdvice
|
@RestControllerAdvice
|
||||||
public class ASEControllerAdvice {
|
public class ASEControllerAdvice {
|
||||||
@ExceptionHandler(value = {RuntimeException.class})
|
|
||||||
public final Object handleRuntimeException(RuntimeException e, WebRequest webRequest){
|
@Resource
|
||||||
|
private QuickJSONRespond quickJSONRespond;
|
||||||
|
|
||||||
|
@ExceptionHandler(value = {
|
||||||
|
NullPointerException.class,
|
||||||
|
AlreadyExistException.class,
|
||||||
|
IllegalException.class
|
||||||
|
})
|
||||||
|
public ResponseEntity<Object> handleBadRequest(Exception ex) {
|
||||||
|
return getResponse(HttpStatus.BAD_REQUEST, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(value = {NotFoundException.class})
|
||||||
|
public ResponseEntity<Object> handleNotFound(Exception ex) {
|
||||||
|
|
||||||
|
return getResponse(HttpStatus.NOT_FOUND, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(value = {})
|
||||||
|
public ResponseEntity<Object> handleNotAcceptable(Exception ex) {
|
||||||
|
return getResponse(HttpStatus.NOT_ACCEPTABLE, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(value = {RelatedObjectsExistException.class})
|
||||||
|
public ResponseEntity<Object> handleConflict(Exception ex) {
|
||||||
|
return getResponse(HttpStatus.CONFLICT, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(value = {
|
||||||
|
HandlingErrorsException.class,
|
||||||
|
FormatException.class,
|
||||||
|
RuntimeIOException.class})
|
||||||
|
public ResponseEntity<Object> handleInnerServerError(Exception ex){
|
||||||
|
return getResponse(HttpStatus.INTERNAL_SERVER_ERROR, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ResponseEntity<Object> getResponse(HttpStatus status, Exception ex){
|
||||||
|
return ResponseEntity.status(status).body(getJSON(status, ex));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getJSON(HttpStatus status, Exception ex){
|
||||||
|
return quickJSONRespond.getJSONStandardRespond(status, getJSONRespondObject(ex));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getJSONRespondObject(Exception ex){
|
||||||
ErrorInfoJSONRespond errorInfoJSONRespond = new ErrorInfoJSONRespond();
|
ErrorInfoJSONRespond 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,24 +1,16 @@
|
|||||||
package com.codesdream.ase.controller;
|
package com.codesdream.ase.controller;
|
||||||
|
|
||||||
import com.codesdream.ase.component.datamanager.QuickJSONRespond;
|
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 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 {
|
||||||
@ -80,7 +72,7 @@ public class ASEErrorController implements ErrorController {
|
|||||||
|
|
||||||
return quickJSONRespond.getJSONStandardRespond(
|
return quickJSONRespond.getJSONStandardRespond(
|
||||||
statusCode,
|
statusCode,
|
||||||
"Error Controller Handle",
|
"Internal Server Error",
|
||||||
null,
|
null,
|
||||||
errorInfoJSONRespond);
|
errorInfoJSONRespond);
|
||||||
}
|
}
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
package com.codesdream.ase.controller;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.codesdream.ase.component.ASESpringUtil;
|
|
||||||
import com.codesdream.ase.component.datamanager.JSONParameter;
|
|
||||||
import com.codesdream.ase.configure.ActivityFormConfigure;
|
|
||||||
import com.codesdream.ase.exception.InvalidFormFormatException;
|
|
||||||
import com.codesdream.ase.exception.LackOfActivityInformation;
|
|
||||||
import com.codesdream.ase.model.activity.Activity;
|
|
||||||
import com.codesdream.ase.service.ActivityService;
|
|
||||||
import com.codesdream.ase.validator.NullValueValidator;
|
|
||||||
import com.codesdream.ase.validator.WebFormValidator;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.ui.Model;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.validation.constraints.Null;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
public class ActivityController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
ActivityService activityService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
JSONParameter jsonParameter;
|
|
||||||
|
|
||||||
@RequestMapping(value = "/activity_creator")
|
|
||||||
String activityCreatorView(Model model){return "activity_creator";}
|
|
||||||
|
|
||||||
@PostMapping(value = "/activity_creator")
|
|
||||||
String activityCreator(Model model, HttpServletRequest request) throws InvalidFormFormatException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
|
|
||||||
|
|
||||||
Map<String, String[]> parameterMap = request.getParameterMap();
|
|
||||||
ASESpringUtil aseSpringUtil = new ASESpringUtil();
|
|
||||||
ActivityFormConfigure activityFormConfigure = aseSpringUtil.getBean(ActivityFormConfigure.class);
|
|
||||||
WebFormValidator webFormValidator = aseSpringUtil.getBean(WebFormValidator.class);
|
|
||||||
if(!webFormValidator.check(activityFormConfigure.getStdActivityForm(), parameterMap)) {
|
|
||||||
throw new InvalidFormFormatException("Invalid activity form.");
|
|
||||||
}
|
|
||||||
// 需要检查JSON是否合法
|
|
||||||
Optional<JSONObject> jsonObject = jsonParameter.getJSONByRequest(request);
|
|
||||||
if(!jsonObject.isPresent()) return "error";
|
|
||||||
Activity activity = jsonObject.get().toJavaObject(Activity.class);
|
|
||||||
|
|
||||||
NullValueValidator nullValueValidator = aseSpringUtil.getBean(NullValueValidator.class);
|
|
||||||
List<String> nullValues = nullValueValidator.checkNullValues(activity);
|
|
||||||
|
|
||||||
return "act_created";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -17,7 +17,9 @@ public class HomeController {
|
|||||||
|
|
||||||
@RequestMapping(value = "/home")
|
@RequestMapping(value = "/home")
|
||||||
public String showHomeView(Model model, Principal principal){
|
public String showHomeView(Model model, Principal principal){
|
||||||
User user = userService.findUserByUsername(principal.getName());
|
Optional<User> userOptional = userService.findUserByUsername(principal.getName());
|
||||||
|
if(!userOptional.isPresent()) return "error";
|
||||||
|
User user = userOptional.get();
|
||||||
// 为视图模板指定参数
|
// 为视图模板指定参数
|
||||||
model.addAttribute("username", user.getUsername().substring(0, 18));
|
model.addAttribute("username", user.getUsername().substring(0, 18));
|
||||||
model.addAttribute("real_name", user.getUserDetail().getRealName());
|
model.addAttribute("real_name", user.getUserDetail().getRealName());
|
||||||
|
@ -0,0 +1,115 @@
|
|||||||
|
package com.codesdream.ase.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.codesdream.ase.component.api.QuickJSONRespond;
|
||||||
|
import com.codesdream.ase.component.auth.ASEUsernameEncoder;
|
||||||
|
import com.codesdream.ase.component.datamanager.JSONParameter;
|
||||||
|
|
||||||
|
import com.codesdream.ase.component.json.request.UserLeaveAuth;
|
||||||
|
import com.codesdream.ase.component.json.request.UserLeaveRequest;
|
||||||
|
import com.codesdream.ase.component.json.request.UserSGettudentLeaveListRequest;
|
||||||
|
import com.codesdream.ase.component.json.respond.JSONStandardFailedRespond;
|
||||||
|
import com.codesdream.ase.exception.innerservererror.InvalidFormFormatException;
|
||||||
|
import com.codesdream.ase.exception.notfound.NotFoundException;
|
||||||
|
import com.codesdream.ase.model.leaves.Leave;
|
||||||
|
import com.codesdream.ase.service.LeavesService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录界面控制器类
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
public class LeavesController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private JSONParameter jsonParameter;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private QuickJSONRespond quickJSONRespond;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private LeavesService leavesService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ASEUsernameEncoder usernameEncoder;
|
||||||
|
|
||||||
|
/* @RequestMapping(value = "/")
|
||||||
|
String printLeave(Model model) {
|
||||||
|
return "Leave";
|
||||||
|
}*/
|
||||||
|
|
||||||
|
//提交请假申请
|
||||||
|
@RequestMapping(value = "/Leave/check", method = RequestMethod.POST)
|
||||||
|
@ResponseBody
|
||||||
|
String leaveRequest(HttpServletRequest request){
|
||||||
|
|
||||||
|
// 检查是否为JSON
|
||||||
|
Optional<JSONObject> json = jsonParameter.getJSONByRequest(request);
|
||||||
|
if(!json.isPresent()) return jsonParameter.getJSONString(new JSONStandardFailedRespond());
|
||||||
|
UserLeaveRequest userLeaveRequest=json.get().toJavaObject(UserLeaveRequest.class);
|
||||||
|
Leave newleave=new Leave();
|
||||||
|
newleave.setUserFrom(userLeaveRequest.getUserId());
|
||||||
|
newleave.setType(userLeaveRequest.getType());
|
||||||
|
newleave.setReasonToLeave(userLeaveRequest.getReason());
|
||||||
|
//newleave.set
|
||||||
|
newleave.setStartTime(userLeaveRequest.getStarttime());
|
||||||
|
newleave.setEndTime(userLeaveRequest.getEndTime());
|
||||||
|
Calendar calendar =Calendar.getInstance();
|
||||||
|
Date time = calendar.getTime();
|
||||||
|
newleave.setApplyTime(time);
|
||||||
|
|
||||||
|
leavesService.save(newleave);
|
||||||
|
//eturn quickJSONRespond.getRespond200(null, respond);
|
||||||
|
|
||||||
|
return quickJSONRespond.getRespond200("申请已提交");
|
||||||
|
// 检查类型
|
||||||
|
|
||||||
|
}
|
||||||
|
@RequestMapping(value = "/Leave/auth", method = RequestMethod.POST)
|
||||||
|
@ResponseBody
|
||||||
|
String getLeaveAuth(HttpServletRequest request){
|
||||||
|
|
||||||
|
// 检查是否为JSON
|
||||||
|
Optional<JSONObject> json = jsonParameter.getJSONByRequest(request);
|
||||||
|
if(!json.isPresent()) return jsonParameter.getJSONString(new JSONStandardFailedRespond());
|
||||||
|
UserLeaveAuth userLeaveAuth=json.get().toJavaObject(UserLeaveAuth.class);
|
||||||
|
Optional<Leave> leave =leavesService.findLeaveById(userLeaveAuth.getId());
|
||||||
|
if(!leave.isPresent()){
|
||||||
|
return quickJSONRespond.getRespond500("No such entry");
|
||||||
|
}
|
||||||
|
Leave newLeave=leave.get();
|
||||||
|
newLeave.setComment(userLeaveAuth.getComment());
|
||||||
|
newLeave.setAuthentication(userLeaveAuth.getNewStat());
|
||||||
|
return quickJSONRespond.getRespond200("Authentication status updated");
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/Leave/getStuLeaveList", method = RequestMethod.POST)
|
||||||
|
@ResponseBody
|
||||||
|
Leave getStuLeavelist(HttpServletRequest request) throws InvalidFormFormatException {
|
||||||
|
Optional<JSONObject> json = jsonParameter.getJSONByRequest(request);
|
||||||
|
if(!json.isPresent()) throw new InvalidFormFormatException("json request not recognized");
|
||||||
|
UserSGettudentLeaveListRequest userSGettudentLeaveListRequest=json.get().toJavaObject(UserSGettudentLeaveListRequest.class);
|
||||||
|
if(leavesService.findLeaveById(userSGettudentLeaveListRequest.getStudentId()).isPresent()){
|
||||||
|
Leave leave =leavesService.findLeaveById(userSGettudentLeaveListRequest.getStudentId()).get();
|
||||||
|
return leave;
|
||||||
|
}else{
|
||||||
|
throw new NotFoundException("Student Does not exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -2,16 +2,17 @@ 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.datamanager.QuickJSONRespond;
|
import com.codesdream.ase.component.api.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;
|
||||||
@ -26,6 +27,7 @@ import java.util.Optional;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Controller
|
@Controller
|
||||||
|
@Api(tags = "用户登录有关接口")
|
||||||
public class LoginController {
|
public class LoginController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@ -38,20 +40,15 @@ public class LoginController {
|
|||||||
private IUserService userService;
|
private IUserService userService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ASEUsernameEncoder usernameEncoder;
|
private IAuthService authService;
|
||||||
|
|
||||||
@RequestMapping(value = "/login")
|
@PostMapping(value = "/login/check_exists")
|
||||||
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 jsonParameter.getJSONString(new JSONStandardFailedRespond());
|
if(!json.isPresent()) return quickJSONRespond.getRespond400("Invalid JSON Form");
|
||||||
|
|
||||||
|
|
||||||
UserLoginChecker loginChecker = json.get().toJavaObject(UserLoginChecker.class);
|
UserLoginChecker loginChecker = json.get().toJavaObject(UserLoginChecker.class);
|
||||||
@ -77,12 +74,22 @@ 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()));
|
||||||
@ -92,8 +99,6 @@ public class LoginController {
|
|||||||
// 返回失败对象
|
// 返回失败对象
|
||||||
return quickJSONRespond.getRespond400("CheckType Mismatch");
|
return quickJSONRespond.getRespond400("CheckType Mismatch");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,222 @@
|
|||||||
|
package com.codesdream.ase.controller;
|
||||||
|
|
||||||
|
import com.codesdream.ase.component.datamanager.JsonPathParameter;
|
||||||
|
import com.codesdream.ase.component.json.model.JsonablePCCList;
|
||||||
|
import com.codesdream.ase.component.json.model.JsonableTag;
|
||||||
|
import com.codesdream.ase.component.json.model.JsonableUserList;
|
||||||
|
import com.codesdream.ase.component.json.model.JsonableUser;
|
||||||
|
import com.codesdream.ase.exception.badrequest.AlreadyExistException;
|
||||||
|
import com.codesdream.ase.exception.conflict.RelatedObjectsExistException;
|
||||||
|
import com.codesdream.ase.exception.notfound.NotFoundException;
|
||||||
|
import com.codesdream.ase.model.permission.PermissionContainersCollection;
|
||||||
|
import com.codesdream.ase.model.permission.Tag;
|
||||||
|
import com.codesdream.ase.model.permission.User;
|
||||||
|
import com.codesdream.ase.service.IUserService;
|
||||||
|
import com.codesdream.ase.service.PermissionService;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.github.fge.jsonpatch.JsonPatch;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import springfox.documentation.spring.web.json.Json;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("pmt")
|
||||||
|
@Api(tags = "权限管理接口")
|
||||||
|
public class PermissionController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PermissionService permissionService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IUserService userService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private JsonPathParameter pathParameter;
|
||||||
|
|
||||||
|
// 根据名字创建新的标签
|
||||||
|
@PostMapping("tag")
|
||||||
|
@ResponseStatus(HttpStatus.CREATED)
|
||||||
|
@ApiOperation(value = "创建新的标签", notes = "创建标签时其ID自动分配,指定ID无效")
|
||||||
|
public JsonableTag createTag(@RequestBody JsonableTag tag){
|
||||||
|
String tagName = tag.getName();
|
||||||
|
Optional<Tag> tagOptional = permissionService.findTag(tagName);
|
||||||
|
if(tagOptional.isPresent()) throw new AlreadyExistException(tagName);
|
||||||
|
Tag newTag = permissionService.getDefaultTag(tagName);
|
||||||
|
if(tag.getDescription() != null) {
|
||||||
|
newTag.setDescription(tag.getDescription());
|
||||||
|
}
|
||||||
|
return new JsonableTag(permissionService.save(newTag));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据名字搜索标签的简要信息
|
||||||
|
@GetMapping("tag")
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
@ApiOperation("搜索标签信息")
|
||||||
|
@ApiImplicitParam(name = "name", value = "标签名")
|
||||||
|
public JsonableTag checkTag(@RequestParam(value = "name") String name){
|
||||||
|
Optional<Tag> tagOptional = permissionService.findTag(name);
|
||||||
|
if(tagOptional.isPresent()){
|
||||||
|
return new JsonableTag(tagOptional.get());
|
||||||
|
}
|
||||||
|
else throw new NotFoundException(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据名字搜索标签的简要信息
|
||||||
|
@GetMapping("tags")
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
@ApiOperation("列出所有的标签信息")
|
||||||
|
@ApiImplicitParam(name = "name", value = "标签名")
|
||||||
|
public Set<JsonableTag> listTag(){
|
||||||
|
Iterable<Tag> tagIterable = permissionService.findAllTag();
|
||||||
|
Set<JsonableTag> jsonableTagSet = new HashSet<>();
|
||||||
|
for(Tag tag : tagIterable){
|
||||||
|
jsonableTagSet.add(new JsonableTag(tag));
|
||||||
|
}
|
||||||
|
return jsonableTagSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据名字搜索标签的简要信息
|
||||||
|
@DeleteMapping("tag")
|
||||||
|
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||||
|
@ApiOperation("删除标签")
|
||||||
|
@ApiImplicitParam(name = "name", value = "标签名")
|
||||||
|
public void deleteTag(@RequestParam(value = "name") String name){
|
||||||
|
Optional<Tag> tag = permissionService.findTag(name);
|
||||||
|
if(!tag.isPresent()) throw new NotFoundException(name);
|
||||||
|
|
||||||
|
// 检查外键关联
|
||||||
|
if(tag.get().getUsers().size() > 0) throw new RelatedObjectsExistException();
|
||||||
|
if(tag.get().getPermissionContainersCollections().size() > 0) throw new RelatedObjectsExistException();
|
||||||
|
|
||||||
|
permissionService.delete(tag.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据名字搜索标签的简要信息
|
||||||
|
@PatchMapping(path = "tag", consumes = "application/json-patch+json")
|
||||||
|
@ResponseStatus(HttpStatus.CREATED)
|
||||||
|
@ApiOperation("修改标签属性")
|
||||||
|
@ApiImplicitParam(name = "name", value = "标签名")
|
||||||
|
public JsonableTag updateTag(@RequestParam(value = "name") String name, @RequestBody JsonPatch patch){
|
||||||
|
Optional<Tag> tag = permissionService.findTag(name);
|
||||||
|
if(!tag.isPresent()) throw new NotFoundException(name);
|
||||||
|
|
||||||
|
JsonableTag jsonableTag = new JsonableTag(tag.get());
|
||||||
|
jsonableTag = pathParameter.parsePathToObject(patch, jsonableTag);
|
||||||
|
|
||||||
|
tag.get().setName(jsonableTag.getName());
|
||||||
|
tag.get().setDescription(jsonableTag.getDescription());
|
||||||
|
|
||||||
|
return new JsonableTag(permissionService.save(tag.get()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("tag/users")
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
@ApiOperation("搜索单个标签所属用户集合信息")
|
||||||
|
public JsonableUserList getUserTag(@RequestParam(value = "name") String name){
|
||||||
|
Optional<Tag> tag = permissionService.findTag(name);
|
||||||
|
if(!tag.isPresent()) throw new NotFoundException(name);
|
||||||
|
return new JsonableUserList(tag.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("tag/users")
|
||||||
|
@ApiOperation("更新索单个标签所属用户集合信息")
|
||||||
|
public JsonableUserList setUserTag(@RequestParam String name, @RequestBody JsonableUserList userList){
|
||||||
|
Optional<Tag> tag = permissionService.findTag(name);
|
||||||
|
if(!tag.isPresent()) throw new NotFoundException(name);
|
||||||
|
|
||||||
|
Set<Integer> userSet = new HashSet<>(userList.getUsers());
|
||||||
|
tag.get().setUsers(userService.findUsersById(userSet));
|
||||||
|
|
||||||
|
return new JsonableUserList(permissionService.save(tag.get()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("tag/users")
|
||||||
|
@ApiOperation("更新单个标签所属用户集合中添加一个或多个用户")
|
||||||
|
public JsonableUserList addUserTag(@RequestParam String name, @RequestBody JsonableUserList userList){
|
||||||
|
Optional<Tag> tag = permissionService.findTag(name);
|
||||||
|
if(!tag.isPresent()) throw new NotFoundException(name);
|
||||||
|
Set<User> newUserSet = userService.findUsersById(new HashSet<>(userList.getUsers()));
|
||||||
|
|
||||||
|
Set<User> userSet = tag.get().getUsers();
|
||||||
|
|
||||||
|
userSet.addAll(newUserSet);
|
||||||
|
tag.get().setUsers(userSet);
|
||||||
|
|
||||||
|
return new JsonableUserList(permissionService.save(tag.get()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("tag/users")
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
@ApiOperation("从单个标签所属用户集合中删除一个或多个用户")
|
||||||
|
@ApiImplicitParam(name = "name", value = "标签名")
|
||||||
|
public JsonableUserList deleteUserTag(@RequestParam String name, @RequestBody JsonableUserList userList){
|
||||||
|
Optional<Tag> tag = permissionService.findTag(name);
|
||||||
|
if(!tag.isPresent()) throw new NotFoundException(name);
|
||||||
|
Set<User> userSet = tag.get().getUsers();
|
||||||
|
Set<User> deleteUserSet = userService.findUsersById(new HashSet<>(userList.getUsers()));
|
||||||
|
|
||||||
|
userSet.removeAll(deleteUserSet);
|
||||||
|
tag.get().setUsers(userSet);
|
||||||
|
|
||||||
|
return new JsonableUserList(permissionService.save(tag.get()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("tags/users")
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
@ApiOperation("搜索多个标签所属用户集合信息")
|
||||||
|
public Set<JsonableUser> getUserTags(@RequestParam(value = "name") List<String> names){
|
||||||
|
Set<Tag> tagSet = permissionService.findTags(names);
|
||||||
|
Set<User> userSet = new HashSet<>();
|
||||||
|
Set<JsonableUser> jsonableUsers = new HashSet<>();
|
||||||
|
for(Tag tag : tagSet){
|
||||||
|
userSet.addAll(tag.getUsers());
|
||||||
|
}
|
||||||
|
for(User user : userSet){
|
||||||
|
jsonableUsers.add(new JsonableUser(user));
|
||||||
|
}
|
||||||
|
return jsonableUsers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("tag/pcc")
|
||||||
|
@ResponseStatus(HttpStatus.OK)
|
||||||
|
@ApiOperation("获取标签所含权限容器集合列表")
|
||||||
|
public JsonablePCCList getPCCTag(@RequestParam(value = "name") String name){
|
||||||
|
Optional<Tag> tagOptional = permissionService.findTag(name);
|
||||||
|
if(!tagOptional.isPresent()) throw new NotFoundException(name);
|
||||||
|
|
||||||
|
return new JsonablePCCList(tagOptional.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("tag/pcc")
|
||||||
|
@ResponseStatus(HttpStatus.CREATED)
|
||||||
|
@ApiOperation("在指定标签的权限列表中添加一个或多个权限容器")
|
||||||
|
public JsonablePCCList addPCCTag(@RequestParam(value = "name") String name, JsonablePCCList jsonablePCCList){
|
||||||
|
Optional<Tag> tagOptional = permissionService.findTag(name);
|
||||||
|
if(!tagOptional.isPresent()) throw new NotFoundException(name);
|
||||||
|
|
||||||
|
Set<PermissionContainersCollection> pccs = tagOptional.get().getPermissionContainersCollections();
|
||||||
|
pccs.addAll(permissionService.findPCCs(new HashSet<Integer>(jsonablePCCList.getPccIdList())));
|
||||||
|
|
||||||
|
tagOptional.get().setPermissionContainersCollections(pccs);
|
||||||
|
|
||||||
|
return new JsonablePCCList(permissionService.save(tagOptional.get()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -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.datamanager.QuickJSONRespond;
|
import com.codesdream.ase.component.api.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;
|
||||||
@ -78,7 +78,7 @@ public class RegisterController {
|
|||||||
BaseStudentInfo studentInfo = baseInformationService.findStudentInfoByStudentId(student_id);
|
BaseStudentInfo studentInfo = baseInformationService.findStudentInfoByStudentId(student_id);
|
||||||
|
|
||||||
// 根据基本信息生成对应用户
|
// 根据基本信息生成对应用户
|
||||||
User user = userService.getUserByStudentInfo(studentInfo);
|
User user = userService.createUserByStudentInfo(studentInfo);
|
||||||
|
|
||||||
// 填充密保问题
|
// 填充密保问题
|
||||||
user.getUserAuth().setUserQuestion(user_question);
|
user.getUserAuth().setUserQuestion(user_question);
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.codesdream.ase.controller.activity;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class ActivityAttendanceController {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,153 @@
|
|||||||
|
package com.codesdream.ase.controller.activity;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.codesdream.ase.component.ASESpringUtil;
|
||||||
|
import com.codesdream.ase.component.activity.ActivityConverter;
|
||||||
|
import com.codesdream.ase.component.activity.NullValueAttributes;
|
||||||
|
import com.codesdream.ase.component.datamanager.JSONParameter;
|
||||||
|
import com.codesdream.ase.component.json.respond.JSONStandardFailedRespond;
|
||||||
|
import com.codesdream.ase.configure.ActivityFormConfigure;
|
||||||
|
import com.codesdream.ase.exception.innerservererror.InvalidFormFormatException;
|
||||||
|
import com.codesdream.ase.model.activity.Activity;
|
||||||
|
import com.codesdream.ase.model.activity.UserActivity;
|
||||||
|
import com.codesdream.ase.model.permission.User;
|
||||||
|
import com.codesdream.ase.repository.activity.UserActivityRepository;
|
||||||
|
import com.codesdream.ase.service.ActivityService;
|
||||||
|
import com.codesdream.ase.service.UserService;
|
||||||
|
import com.codesdream.ase.validator.ActivityValidator;
|
||||||
|
import com.codesdream.ase.validator.NullValueValidator;
|
||||||
|
import com.codesdream.ase.validator.JSONFormValidator;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class ActivityCreatorController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ActivityService activityService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
JSONParameter jsonParameter;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ASESpringUtil aseSpringUtil;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ActivityFormConfigure activityFormConfigure;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
JSONFormValidator jsonFormValidator;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
NullValueValidator nullValueValidator;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
NullValueAttributes nullValueAttributes;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ActivityValidator activityValidator;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
UserService userService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
UserActivityRepository userActivityRepository;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ActivityConverter activityConverter;
|
||||||
|
|
||||||
|
private final String url = "/forget/activity";
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(value = url + "/activity_creator")
|
||||||
|
@ResponseBody
|
||||||
|
@ApiOperation(value = "创建活动", notes = "所有有关用户的数据传递均使用id,类型为int")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "title", value = "活动标题", required = true),
|
||||||
|
@ApiImplicitParam(name = "type", value = "活动类型", required = true),
|
||||||
|
@ApiImplicitParam(name = "start-time", value = "活动开始时间,格式为yyyy-MM-dd HH:mm:ss", required = true),
|
||||||
|
@ApiImplicitParam(name = "end-time", value = "活动结束时间,格式为yyyy-MM-dd HH:mm:ss", required = true),
|
||||||
|
@ApiImplicitParam(name = "chief-manager", value = "主要负责人", required = true),
|
||||||
|
@ApiImplicitParam(name = "assist-managers", value = "次要负责人"),
|
||||||
|
@ApiImplicitParam(name = "description", value = "活动描述"),
|
||||||
|
@ApiImplicitParam(name = "cycle", value = "活动周期,格式为阿拉伯数字数字+单位,0表示无周期"),
|
||||||
|
@ApiImplicitParam(name = "participate-group", value = "预定参与人员"),
|
||||||
|
@ApiImplicitParam(name = "sign-group", value = "可参与人员"),
|
||||||
|
@ApiImplicitParam(name = "inform-group", value = "通知人群,若为空,则默认为预定参与人员和可报名人员的并集"),
|
||||||
|
@ApiImplicitParam(name = "visible-group", value = "活动可见人群,若为空,则默认为负责人、活动创建者预定参和可报名人员以及通知人员的并集"),
|
||||||
|
@ApiImplicitParam(name = "remind-time", defaultValue = "30m", value = "活动提醒时间,格式为数字+单位,可接受的单位从大到小有:w,d,h,m,s"),
|
||||||
|
})
|
||||||
|
String activityCreator(HttpServletRequest request) throws InvalidFormFormatException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
|
||||||
|
|
||||||
|
JSONObject error = new JSONObject();
|
||||||
|
aseSpringUtil = new ASESpringUtil();
|
||||||
|
Optional<JSONObject> json = jsonParameter.getJSONByRequest(request);
|
||||||
|
if (!json.isPresent()) return jsonParameter.getJSONString(new JSONStandardFailedRespond());
|
||||||
|
|
||||||
|
List<String> formatCheckResult = jsonFormValidator.check(activityFormConfigure.getStdActivityForm(), json.get());
|
||||||
|
|
||||||
|
if (!formatCheckResult.isEmpty()) {
|
||||||
|
error.put("error", formatCheckResult);
|
||||||
|
return error.toJSONString();
|
||||||
|
}
|
||||||
|
// 需要检查JSON是否合法
|
||||||
|
Activity activity = activityConverter.convertToActivity(json);
|
||||||
|
List<String> nullValues = nullValueValidator.checkNullValues(activity);
|
||||||
|
|
||||||
|
for (String str : nullValues){
|
||||||
|
if(str.equals("title")){
|
||||||
|
nullValueAttributes.getNullValueAttributes().add("title");
|
||||||
|
}
|
||||||
|
else if(str.equals("creator")){
|
||||||
|
nullValueAttributes.getNullValueAttributes().add("creator");
|
||||||
|
}
|
||||||
|
else if(str.equals("type")){
|
||||||
|
nullValueAttributes.getNullValueAttributes().add("type");
|
||||||
|
}
|
||||||
|
else if(str.equals("planPeriod")){
|
||||||
|
nullValueAttributes.getNullValueAttributes().add("planPeriod");
|
||||||
|
}
|
||||||
|
else if(str.equals("chiefManager")){
|
||||||
|
nullValueAttributes.getNullValueAttributes().add("chiefManager");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//如果为空,存下此活动并跳转至成功创建页面
|
||||||
|
if (!nullValueAttributes.getNullValueAttributes().isEmpty()) {
|
||||||
|
|
||||||
|
String[] errorParameters = activityValidator.check(json);
|
||||||
|
if(errorParameters != null){
|
||||||
|
JSONObject invalidParameters = new JSONObject();
|
||||||
|
invalidParameters.put("invalid_parameters", errorParameters);
|
||||||
|
return invalidParameters.toJSONString();
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
activity = activityService.createActivity(activity);
|
||||||
|
String username = json.get().get("creator").toString();
|
||||||
|
Optional<User> user = userService.findUserByUsername(username);
|
||||||
|
UserActivity userActivity = userActivityRepository.findByUser(user.get());
|
||||||
|
userActivity.getCreatedActivities().add(activity);
|
||||||
|
userActivityRepository.save(userActivity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//否则返回一个JSON对象给前端
|
||||||
|
else{
|
||||||
|
JSONObject nullParameters = new JSONObject();
|
||||||
|
nullParameters.put("null_values",nullValueAttributes.getNullValueAttributes());
|
||||||
|
return nullParameters.toJSONString();
|
||||||
|
}
|
||||||
|
return url + "/act_created";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.codesdream.ase.controller.activity;
|
||||||
|
|
||||||
|
import com.codesdream.ase.component.ASESpringUtil;
|
||||||
|
import com.codesdream.ase.component.datamanager.JSONParameter;
|
||||||
|
import com.codesdream.ase.model.activity.Activity;
|
||||||
|
import com.codesdream.ase.repository.activity.ActivityRepository;
|
||||||
|
import com.codesdream.ase.service.ActivityService;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.security.Principal;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class ActivityViewerController {
|
||||||
|
|
||||||
|
private final String url = "/forget/activity";
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ActivityService activityService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ActivityRepository activityRepository;
|
||||||
|
|
||||||
|
@RequestMapping(value = url + "/my/participated", method = RequestMethod.GET)
|
||||||
|
String showParticipated(Model model, HttpServletRequest request){
|
||||||
|
Principal principal = request.getUserPrincipal();
|
||||||
|
String username = principal.getName();
|
||||||
|
ASESpringUtil aseSpringUtil = new ASESpringUtil();
|
||||||
|
activityRepository = aseSpringUtil.getBean(ActivityRepository.class);
|
||||||
|
//List<Activity> participatedActivities = activityRepository.findc
|
||||||
|
return "/my/participated";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.codesdream.ase.controller.activity;
|
||||||
|
|
||||||
|
import com.codesdream.ase.component.activity.QrCodeUtils;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class QRCodeController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二维码
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
*/
|
||||||
|
@GetMapping("/qrcode")
|
||||||
|
public void qrCode(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
StringBuffer url = request.getRequestURL();
|
||||||
|
// 域名
|
||||||
|
String tempContextUrl = url.delete(url.length() - request.getRequestURI().length(), url.length()).append("/").toString();
|
||||||
|
|
||||||
|
// 再加上请求链接
|
||||||
|
String requestUrl = tempContextUrl + "/index";
|
||||||
|
try {
|
||||||
|
OutputStream os = response.getOutputStream();
|
||||||
|
QrCodeUtils.encode(requestUrl, "", os, true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +0,0 @@
|
|||||||
package com.codesdream.ase.exception;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
|
||||||
public class DataFileNotFoundException extends RuntimeException {
|
|
||||||
private String path;
|
|
||||||
|
|
||||||
public DataFileNotFoundException(String filePath){
|
|
||||||
super();
|
|
||||||
this.path = filePath;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package com.codesdream.ase.exception;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
|
||||||
public class DataIOException extends RuntimeException {
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package com.codesdream.ase.exception;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
|
||||||
public class DataIllegalTableFormatException extends RuntimeException {
|
|
||||||
}
|
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.codesdream.ase.exception;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class StringFileConvertException extends RuntimeException {
|
||||||
|
public StringFileConvertException(String msg){
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.codesdream.ase.exception.badrequest;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class AlreadyExistException extends RuntimeException {
|
||||||
|
public AlreadyExistException(String msg){
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
@ -1,16 +1,16 @@
|
|||||||
package com.codesdream.ase.exception;
|
package com.codesdream.ase.exception.badrequest;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class BaseInformationAlreadyExistException extends RuntimeException {
|
public class BaseInformationAlreadyExistException extends AlreadyExistException {
|
||||||
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();
|
super(String.format("%s: %s", aClass.getName(), value));
|
||||||
this.className = aClass.getName();
|
this.className = aClass.getName();
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
@ -1,11 +1,11 @@
|
|||||||
package com.codesdream.ase.exception;
|
package com.codesdream.ase.exception.badrequest;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class BaseInformationIllegalException extends RuntimeException {
|
public class BaseInformationIllegalException extends IllegalException {
|
||||||
String type;
|
String type;
|
||||||
String value;
|
String value;
|
||||||
|
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.codesdream.ase.exception.badrequest;
|
||||||
|
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class IllegalException extends RuntimeException {
|
||||||
|
public IllegalException(String msg){
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
package com.codesdream.ase.exception;
|
package com.codesdream.ase.exception.badrequest;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class UserInformationIllegalException extends RuntimeException {
|
public class UserInformationIllegalException extends IllegalException {
|
||||||
|
|
||||||
String username;
|
String username;
|
||||||
|
|
@ -1,16 +1,16 @@
|
|||||||
package com.codesdream.ase.exception;
|
package com.codesdream.ase.exception.badrequest;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class UsernameAlreadyExistException extends RuntimeException {
|
public class UsernameAlreadyExistException extends AlreadyExistException {
|
||||||
|
|
||||||
String username;
|
String username;
|
||||||
|
|
||||||
public UsernameAlreadyExistException(String username){
|
public UsernameAlreadyExistException(String username){
|
||||||
super();
|
super(username);
|
||||||
this.username = username;
|
this.username = username;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.codesdream.ase.exception.conflict;
|
||||||
|
|
||||||
|
public class FileNameConflict extends RuntimeException {
|
||||||
|
public String conflictName;
|
||||||
|
public FileNameConflict(String msg,String conflictName)
|
||||||
|
{
|
||||||
|
super(msg);
|
||||||
|
this.conflictName = conflictName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.codesdream.ase.exception.conflict;
|
||||||
|
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存在与之相关联的对象
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class RelatedObjectsExistException extends RuntimeException {
|
||||||
|
public RelatedObjectsExistException(String msg){
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.codesdream.ase.exception.innerservererror;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class DataIOException extends RuntimeIOException {
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.codesdream.ase.exception.innerservererror;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class DataIllegalTableFormatException extends FormatException {
|
||||||
|
}
|
@ -1,15 +1,19 @@
|
|||||||
package com.codesdream.ase.exception;
|
package com.codesdream.ase.exception.innerservererror;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class DataInvalidFormatException extends RuntimeException {
|
public class DataInvalidFormatException extends FormatException {
|
||||||
String information;
|
String information;
|
||||||
|
|
||||||
public DataInvalidFormatException(Exception e){
|
public DataInvalidFormatException(Exception e){
|
||||||
super();
|
super();
|
||||||
information = e.getMessage();
|
information = e.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DataInvalidFormatException(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.codesdream.ase.exception.innerservererror;
|
||||||
|
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class FormatException extends RuntimeException {
|
||||||
|
public FormatException(String msg){
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.codesdream.ase.exception.innerservererror;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
// 处理错误对应的异常类
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class HandlingErrorsException extends RuntimeException {
|
||||||
|
public HandlingErrorsException(String msg){
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.codesdream.ase.exception;
|
package com.codesdream.ase.exception.innerservererror;
|
||||||
|
|
||||||
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 Throwable {
|
public class InvalidFormFormatException extends FormatException {
|
||||||
|
|
||||||
private String message = "";
|
private String message = "Invalid form format";
|
||||||
|
|
||||||
public InvalidFormFormatException(){
|
public InvalidFormFormatException(){
|
||||||
super();
|
super();
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.codesdream.ase.exception.innerservererror;
|
||||||
|
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class RuntimeIOException extends RuntimeException {
|
||||||
|
public RuntimeIOException(String msg){
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.codesdream.ase.exception.notfound;
|
||||||
|
|
||||||
|
import com.codesdream.ase.model.activity.AppendixFile;
|
||||||
|
|
||||||
|
public class AppendixFileNotFoundException extends NotFoundException {
|
||||||
|
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,16 +1,16 @@
|
|||||||
package com.codesdream.ase.exception;
|
package com.codesdream.ase.exception.notfound;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class BaseInformationNotExistException extends RuntimeException {
|
public class BaseInformationNotFoundException extends NotFoundException {
|
||||||
private String className;
|
private String className;
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
public BaseInformationNotExistException(Class<?> baseInformationClass, String value){
|
public BaseInformationNotFoundException(Class<?> baseInformationClass, String value){
|
||||||
super();
|
super(String.format("%s: %s", baseInformationClass.getName(), value));
|
||||||
this.className = baseInformationClass.getName();
|
this.className = baseInformationClass.getName();
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.codesdream.ase.exception.notfound;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class DataFileNotFoundException extends NotFoundException {
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
public DataFileNotFoundException(String msg){
|
||||||
|
super(msg);
|
||||||
|
this.path = msg;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.codesdream.ase.exception.notfound;
|
||||||
|
|
||||||
|
|
||||||
|
public class NotFoundException extends RuntimeException {
|
||||||
|
public NotFoundException(String msg){
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotFoundException(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.codesdream.ase.exception.notfound;
|
||||||
|
|
||||||
|
|
||||||
|
public class TagNotFoundException extends NotFoundException {
|
||||||
|
String tagName;
|
||||||
|
|
||||||
|
public TagNotFoundException(String tagName){
|
||||||
|
super(tagName);
|
||||||
|
this.tagName = tagName;
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,20 @@
|
|||||||
package com.codesdream.ase.exception;
|
package com.codesdream.ase.exception.notfound;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class UserNotFoundException extends RuntimeException {
|
public class UserNotFoundException extends NotFoundException {
|
||||||
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);
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,8 +2,6 @@ package com.codesdream.ase.model.activity;
|
|||||||
|
|
||||||
import com.codesdream.ase.model.permission.User;
|
import com.codesdream.ase.model.permission.User;
|
||||||
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.time.LocalDateTime;
|
||||||
@ -129,6 +127,7 @@ public class Activity {
|
|||||||
|
|
||||||
//计划开始时间
|
//计划开始时间
|
||||||
@OneToOne(cascade = CascadeType.ALL)
|
@OneToOne(cascade = CascadeType.ALL)
|
||||||
|
@JoinColumn(nullable = false)
|
||||||
private Period planPeriod;
|
private Period planPeriod;
|
||||||
|
|
||||||
//实际开始时间
|
//实际开始时间
|
||||||
@ -154,11 +153,11 @@ public class Activity {
|
|||||||
private Set<User> assistManagers;
|
private Set<User> assistManagers;
|
||||||
|
|
||||||
//是否开始
|
//是否开始
|
||||||
@Column//(name = "is_on", nullable = false)
|
@Column(name = "is_on", nullable = false)
|
||||||
boolean isOn;
|
boolean isOn;
|
||||||
|
|
||||||
//是否结束
|
//是否结束
|
||||||
@Column//(name = "is_off", nullable = false)
|
@Column(name = "is_off", nullable = false)
|
||||||
boolean isOff;
|
boolean isOff;
|
||||||
|
|
||||||
//考勤安排
|
//考勤安排
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.codesdream.ase.model.activity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
@Table(name = "appendixFile")
|
||||||
|
public class AppendixFile {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
@Column(name = "file_name")
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
@Column(name = "type")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
@Column(name = "last_edit_time")//, nullable = false)
|
||||||
|
private LocalDateTime lastEditTime = LocalDateTime.of(2020,2,18,16,36);
|
||||||
|
}
|
@ -15,10 +15,6 @@ public class Attendance {
|
|||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
//二维码url
|
|
||||||
@Column(name = "qr_code")//, nullable = false, unique = true)
|
|
||||||
private String QRCode;
|
|
||||||
|
|
||||||
//是否在线
|
//是否在线
|
||||||
@Column(name = "is_online")//, nullable = false)
|
@Column(name = "is_online")//, nullable = false)
|
||||||
private boolean isOnline;
|
private boolean isOnline;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.codesdream.ase.model.activity;
|
package com.codesdream.ase.model.activity;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
|
|
||||||
@ -18,10 +20,12 @@ public class Period {
|
|||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
//开始时间
|
//开始时间
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
@Column(name = "start_time")//, nullable = false)
|
@Column(name = "start_time")//, nullable = false)
|
||||||
private LocalDateTime startTime = LocalDateTime.of(2020,2,18,16,36);
|
private LocalDateTime startTime = LocalDateTime.of(2020,2,18,16,36);
|
||||||
|
|
||||||
//结束时间
|
//结束时间
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
@Column(name = "end_time")//, nullable = false)
|
@Column(name = "end_time")//, nullable = false)
|
||||||
private LocalDateTime endTime = LocalDateTime.of(2020,2,18,16,37);
|
private LocalDateTime endTime = LocalDateTime.of(2020,2,18,16,37);
|
||||||
|
|
||||||
@ -29,4 +33,13 @@ public class Period {
|
|||||||
@Column(name = "enabled")//, nullable = false)
|
@Column(name = "enabled")//, nullable = false)
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
|
public Period(LocalDateTime startTime, LocalDateTime endTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Period(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public class UserActivity {
|
|||||||
|
|
||||||
//关联的用户
|
//关联的用户
|
||||||
@OneToOne(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY, mappedBy = "userActivity")
|
@OneToOne(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY, mappedBy = "userActivity")
|
||||||
@JoinColumn(nullable = false)
|
@JoinColumn(nullable = false, unique = true)
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
//主要负责的活动
|
//主要负责的活动
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.codesdream.ase.model.auth;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
@Table(name = "pre_validation_code")
|
||||||
|
public class PreValidationCode {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
private Date date = new Date();
|
||||||
|
|
||||||
|
}
|
@ -12,7 +12,7 @@ import javax.persistence.*;
|
|||||||
@Table(name = "base_major")
|
@Table(name = "base_major")
|
||||||
public class BaseMajor {
|
public class BaseMajor {
|
||||||
@Id
|
@Id
|
||||||
private int id;
|
private String id;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
}
|
}
|
||||||
|
@ -4,28 +4,40 @@ import com.codesdream.ase.model.permission.User;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "leaves_archive")
|
@Table(name = "leaves")
|
||||||
public class Leave {
|
public class Leave {
|
||||||
|
//请假的编号
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
private int id;
|
private int id;
|
||||||
//发出人
|
//发出人
|
||||||
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
@Column
|
||||||
private User userFrom;
|
private String userFrom;
|
||||||
//审批人容器
|
//审批人容器
|
||||||
@ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
|
@ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
|
||||||
private Set <User> userTo;
|
private Set <User> userTo;
|
||||||
|
//请假原因
|
||||||
|
@Column
|
||||||
|
private String reasonToLeave;
|
||||||
|
|
||||||
|
|
||||||
//请假类型 病假,事假等
|
//请假类型 病假,事假等
|
||||||
@Column(name = "type", nullable = false)
|
@Column(nullable = false)
|
||||||
private String type;
|
private String type;
|
||||||
//批准状态
|
//批准状态
|
||||||
@Column(name = "Authentication", nullable = false)
|
@Column(nullable = false)
|
||||||
private Boolean Authentication;
|
private String authentication="Pending";
|
||||||
|
|
||||||
|
//审核备注
|
||||||
|
@Column
|
||||||
|
private String comment;
|
||||||
//开始时间
|
//开始时间
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private Date startTime;
|
private Date startTime;
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private Date endTime;
|
private Date endTime;
|
||||||
//申请时间
|
//申请时间
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
package com.codesdream.ase.model.leaves;
|
|
||||||
/**
|
|
||||||
请假信息的管理系统
|
|
||||||
*/
|
|
||||||
public class LeavesSystem {
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.codesdream.ase.repository.activity;
|
||||||
|
|
||||||
|
import com.codesdream.ase.model.activity.AppendixFile;
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface AppendixFileRespository extends CrudRepository<AppendixFile, Integer> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.codesdream.ase.repository.activity;
|
||||||
|
|
||||||
|
import com.codesdream.ase.model.activity.Attendance;
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface AttendanceRepository extends CrudRepository<Attendance, Integer> {
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.codesdream.ase.repository.activity;
|
||||||
|
|
||||||
|
import com.codesdream.ase.model.activity.Period;
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface PeriodRepository extends CrudRepository<Period, Integer> {
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.codesdream.ase.repository.activity;
|
||||||
|
|
||||||
|
import com.codesdream.ase.model.activity.UserActivity;
|
||||||
|
import com.codesdream.ase.model.permission.User;
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface UserActivityRepository extends CrudRepository<UserActivity, Integer> {
|
||||||
|
|
||||||
|
UserActivity findByUser(User user);
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.codesdream.ase.repository.auth;
|
||||||
|
|
||||||
|
import com.codesdream.ase.model.auth.PreValidationCode;
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface PreValidationCodeRepository extends CrudRepository<PreValidationCode, Integer> {
|
||||||
|
Optional<PreValidationCode> findByValue(String value);
|
||||||
|
}
|
@ -7,6 +7,6 @@ import org.springframework.stereotype.Repository;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface BaseMajorRepository extends CrudRepository<BaseMajor, Integer> {
|
public interface BaseMajorRepository extends CrudRepository<BaseMajor, String> {
|
||||||
Optional<BaseMajor> findByName(String name);
|
Optional<BaseMajor> findByName(String name);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.codesdream.ase.repository.leaves;
|
||||||
|
import com.codesdream.ase.model.activity.Report;
|
||||||
|
import com.codesdream.ase.model.leaves.Leave;
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface LeaveRepository extends CrudRepository<Leave, Integer>{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,16 +1,16 @@
|
|||||||
package com.codesdream.ase.service;
|
package com.codesdream.ase.service;
|
||||||
|
|
||||||
import com.codesdream.ase.component.permission.UserAuthoritiesGenerator;
|
import com.codesdream.ase.component.permission.UserAuthoritiesGenerator;
|
||||||
import com.codesdream.ase.exception.UserNotFoundException;
|
import com.codesdream.ase.exception.notfound.UserNotFoundException;
|
||||||
import com.codesdream.ase.model.permission.User;
|
import com.codesdream.ase.model.permission.User;
|
||||||
import org.springframework.security.authentication.AuthenticationServiceException;
|
import org.springframework.security.authentication.AuthenticationServiceException;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ASEUserDetailsService implements UserDetailsService {
|
public class ASEUserDetailsService implements UserDetailsService {
|
||||||
@ -25,7 +25,9 @@ public class ASEUserDetailsService implements UserDetailsService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public UserDetails loadUserByUsername(String s) {
|
public UserDetails loadUserByUsername(String s) {
|
||||||
try {
|
try {
|
||||||
User user = userService.findUserByUsername(s);
|
Optional<User> userOptional = userService.findUserByUsername(s);
|
||||||
|
if(!userOptional.isPresent()) throw new UserNotFoundException(s);
|
||||||
|
User user = userOptional.get();
|
||||||
user.setAuthorities(userAuthoritiesGenerator.grantedAuthorities(user));
|
user.setAuthorities(userAuthoritiesGenerator.grantedAuthorities(user));
|
||||||
return user;
|
return user;
|
||||||
} catch (UserNotFoundException e){
|
} catch (UserNotFoundException e){
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.codesdream.ase.service;
|
||||||
|
|
||||||
|
import com.codesdream.ase.model.activity.AppendixFile;
|
||||||
|
import com.codesdream.ase.repository.activity.AppendixFileRespository;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AppendixFileService implements IAppendixFileService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AppendixFileRespository appendixFileRespository;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AppendixFile save(AppendixFile appendixFile) {
|
||||||
|
return appendixFileRespository.save(appendixFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(AppendixFile appendixFile) {
|
||||||
|
appendixFileRespository.delete(appendixFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<AppendixFile> findById(int id) {
|
||||||
|
return appendixFileRespository.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<AppendixFile> findAll() {
|
||||||
|
return appendixFileRespository.findAll();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.codesdream.ase.service;
|
||||||
|
|
||||||
|
import com.codesdream.ase.model.activity.Attendance;
|
||||||
|
import com.codesdream.ase.repository.activity.AttendanceRepository;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AttendanceService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
AttendanceRepository attendanceRepository;
|
||||||
|
|
||||||
|
public Attendance save(Attendance attendance) {
|
||||||
|
return attendanceRepository.save(attendance);
|
||||||
|
}
|
||||||
|
}
|
@ -1,16 +1,19 @@
|
|||||||
package com.codesdream.ase.service;
|
package com.codesdream.ase.service;
|
||||||
|
|
||||||
import com.codesdream.ase.component.auth.AuthTokenGenerator;
|
import com.codesdream.ase.component.auth.AuthTokenGenerator;
|
||||||
|
import com.codesdream.ase.component.auth.TimestampExpiredChecker;
|
||||||
import com.codesdream.ase.model.auth.JSONToken;
|
import com.codesdream.ase.model.auth.JSONToken;
|
||||||
|
import com.codesdream.ase.model.auth.PreValidationCode;
|
||||||
import com.codesdream.ase.model.permission.User;
|
import com.codesdream.ase.model.permission.User;
|
||||||
import com.codesdream.ase.repository.auth.JSONTokenRepository;
|
import com.codesdream.ase.repository.auth.JSONTokenRepository;
|
||||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
import com.codesdream.ase.repository.auth.PreValidationCodeRepository;
|
||||||
import javafx.util.Pair;
|
import javafx.util.Pair;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
// 认证服务
|
// 认证服务
|
||||||
@Service
|
@Service
|
||||||
@ -25,6 +28,12 @@ public class AuthService implements IAuthService {
|
|||||||
@Resource
|
@Resource
|
||||||
private AuthTokenGenerator authTokenGenerator;
|
private AuthTokenGenerator authTokenGenerator;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PreValidationCodeRepository preValidationCodeRepository;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TimestampExpiredChecker timestampExpiredChecker;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<JSONToken> findTokenByUserName(String username) {
|
public Optional<JSONToken> findTokenByUserName(String username) {
|
||||||
return jsonTokenRepository.findByUsername(username);
|
return jsonTokenRepository.findByUsername(username);
|
||||||
@ -60,4 +69,24 @@ public class AuthService implements IAuthService {
|
|||||||
}
|
}
|
||||||
else return Optional.empty();
|
else return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String preValidationCodeGetter() {
|
||||||
|
PreValidationCode preValidationCode = new
|
||||||
|
PreValidationCode();
|
||||||
|
preValidationCode.setValue(UUID.randomUUID().toString());
|
||||||
|
preValidationCode = preValidationCodeRepository.save(preValidationCode);
|
||||||
|
return preValidationCode.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean preValidationCodeChecker(String pvc) {
|
||||||
|
Optional<PreValidationCode> preValidationCode =
|
||||||
|
preValidationCodeRepository.findByValue(pvc);
|
||||||
|
if(preValidationCode.filter(validationCode -> timestampExpiredChecker.checkDateBeforeMaxTime(validationCode.getDate(), 60)).isPresent()){
|
||||||
|
preValidationCodeRepository.delete(preValidationCode.get());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package com.codesdream.ase.service;
|
package com.codesdream.ase.service;
|
||||||
|
|
||||||
import com.codesdream.ase.component.datamanager.DataTable;
|
import com.codesdream.ase.component.datamanager.DataTable;
|
||||||
import com.codesdream.ase.exception.BaseInformationAlreadyExistException;
|
import com.codesdream.ase.exception.badrequest.BaseInformationAlreadyExistException;
|
||||||
import com.codesdream.ase.exception.BaseInformationIllegalException;
|
import com.codesdream.ase.exception.badrequest.BaseInformationIllegalException;
|
||||||
import com.codesdream.ase.exception.BaseInformationNotExistException;
|
import com.codesdream.ase.exception.notfound.BaseInformationNotFoundException;
|
||||||
import com.codesdream.ase.model.information.*;
|
import com.codesdream.ase.model.information.*;
|
||||||
import com.codesdream.ase.repository.information.*;
|
import com.codesdream.ase.repository.information.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -103,7 +103,7 @@ public class BaseInformationService implements IBaseInformationService {
|
|||||||
if(administrativeDivision.isPresent()) {
|
if(administrativeDivision.isPresent()) {
|
||||||
return administrativeDivision.get();
|
return administrativeDivision.get();
|
||||||
}
|
}
|
||||||
else throw new BaseInformationNotExistException(BaseAdministrativeDivision.class, name);
|
else throw new BaseInformationNotFoundException(BaseAdministrativeDivision.class, name);
|
||||||
|
|
||||||
}
|
}
|
||||||
return administrativeDivision.get();
|
return administrativeDivision.get();
|
||||||
@ -114,7 +114,7 @@ public class BaseInformationService implements IBaseInformationService {
|
|||||||
Optional<BaseCollege> college =
|
Optional<BaseCollege> college =
|
||||||
collegeRepository.findByName(name);
|
collegeRepository.findByName(name);
|
||||||
// 检查
|
// 检查
|
||||||
if(!college.isPresent()) throw new BaseInformationNotExistException(BaseCollege.class, name);
|
if(!college.isPresent()) throw new BaseInformationNotFoundException(BaseCollege.class, name);
|
||||||
return college.get();
|
return college.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ public class BaseInformationService implements IBaseInformationService {
|
|||||||
public BaseEthnic findEthnicByName(String name) {
|
public BaseEthnic findEthnicByName(String name) {
|
||||||
Optional<BaseEthnic> ethnic =
|
Optional<BaseEthnic> ethnic =
|
||||||
ethnicRepository.findByName(name);
|
ethnicRepository.findByName(name);
|
||||||
if(!ethnic.isPresent()) throw new BaseInformationNotExistException(BaseEthnic.class, name);
|
if(!ethnic.isPresent()) throw new BaseInformationNotFoundException(BaseEthnic.class, name);
|
||||||
return ethnic.get();
|
return ethnic.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ public class BaseInformationService implements IBaseInformationService {
|
|||||||
public BaseMajor findMajorByName(String name) {
|
public BaseMajor findMajorByName(String name) {
|
||||||
Optional<BaseMajor> major =
|
Optional<BaseMajor> major =
|
||||||
majorRepository.findByName(name);
|
majorRepository.findByName(name);
|
||||||
if(!major.isPresent()) throw new BaseInformationNotExistException(BaseMajor.class, name);
|
if(!major.isPresent()) throw new BaseInformationNotFoundException(BaseMajor.class, name);
|
||||||
return major.get();
|
return major.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ public class BaseInformationService implements IBaseInformationService {
|
|||||||
Optional<BasePoliticalStatus> politicalStatus =
|
Optional<BasePoliticalStatus> politicalStatus =
|
||||||
politicalStatusRepository.findByName(name);
|
politicalStatusRepository.findByName(name);
|
||||||
if(!politicalStatus.isPresent())
|
if(!politicalStatus.isPresent())
|
||||||
throw new BaseInformationNotExistException(BasePoliticalStatus.class, name);
|
throw new BaseInformationNotFoundException(BasePoliticalStatus.class, name);
|
||||||
return politicalStatus.get();
|
return politicalStatus.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ public class BaseInformationService implements IBaseInformationService {
|
|||||||
Optional<BaseCandidateCategory> candidateCategory =
|
Optional<BaseCandidateCategory> candidateCategory =
|
||||||
candidateCategoryRepository.findByName(name);
|
candidateCategoryRepository.findByName(name);
|
||||||
if(!candidateCategory.isPresent())
|
if(!candidateCategory.isPresent())
|
||||||
throw new BaseInformationNotExistException(BaseCandidateCategory.class, name);
|
throw new BaseInformationNotFoundException(BaseCandidateCategory.class, name);
|
||||||
return candidateCategory.get();
|
return candidateCategory.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ public class BaseInformationService implements IBaseInformationService {
|
|||||||
Optional<BaseStudentInfo> studentInfo =
|
Optional<BaseStudentInfo> studentInfo =
|
||||||
studentInfoRepository.findByStudentId(studentId);
|
studentInfoRepository.findByStudentId(studentId);
|
||||||
if(!studentInfo.isPresent())
|
if(!studentInfo.isPresent())
|
||||||
throw new BaseInformationNotExistException(BaseStudentInfo.class, studentId);
|
throw new BaseInformationNotFoundException(BaseStudentInfo.class, studentId);
|
||||||
return studentInfo.get();
|
return studentInfo.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ public class BaseInformationService implements IBaseInformationService {
|
|||||||
row.elementAt(infoIndex.elementAt(7)),
|
row.elementAt(infoIndex.elementAt(7)),
|
||||||
row.elementAt(infoIndex.elementAt(8)));
|
row.elementAt(infoIndex.elementAt(8)));
|
||||||
save(studentInfo);
|
save(studentInfo);
|
||||||
} catch (BaseInformationNotExistException e){
|
} catch (BaseInformationNotFoundException e){
|
||||||
String log_info = String.format("一项学生信息的某项基本信息未在数据库找到, 该项数据无效." +
|
String log_info = String.format("一项学生信息的某项基本信息未在数据库找到, 该项数据无效." +
|
||||||
" %s: %s",e.getClassName(), e.getValue());
|
" %s: %s",e.getClassName(), e.getValue());
|
||||||
log.warn(log_info);
|
log.warn(log_info);
|
||||||
@ -281,7 +281,7 @@ public class BaseInformationService implements IBaseInformationService {
|
|||||||
public BaseStudentInfo update(BaseStudentInfo baseStudentInfo) {
|
public BaseStudentInfo update(BaseStudentInfo baseStudentInfo) {
|
||||||
// 更新前检查
|
// 更新前检查
|
||||||
if(!checkStudentInfo(baseStudentInfo.getStudentId()))
|
if(!checkStudentInfo(baseStudentInfo.getStudentId()))
|
||||||
throw new BaseInformationNotExistException(BaseStudentInfo.class, baseStudentInfo.getStudentId());
|
throw new BaseInformationNotFoundException(BaseStudentInfo.class, baseStudentInfo.getStudentId());
|
||||||
return studentInfoRepository.save(baseStudentInfo);
|
return studentInfoRepository.save(baseStudentInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.codesdream.ase.service;
|
||||||
|
|
||||||
|
import com.codesdream.ase.model.activity.AppendixFile;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface IAppendixFileService {
|
||||||
|
|
||||||
|
//存储磁盘文件条目
|
||||||
|
AppendixFile save(AppendixFile appendixFile);
|
||||||
|
|
||||||
|
//删除磁盘文件条目
|
||||||
|
void delete(AppendixFile appendixFile);
|
||||||
|
|
||||||
|
//通过ID寻找文件条目
|
||||||
|
Optional<AppendixFile> findById(int id);
|
||||||
|
|
||||||
|
//找到所有文件条目
|
||||||
|
Iterable<AppendixFile> findAll();
|
||||||
|
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user