Merge branch 'master' of http://39.100.94.111:8082/root/ASE into master_zone

This commit is contained in:
MusingZone 2020-04-02 00:12:22 +08:00
commit 6a813c9bdb
43 changed files with 805 additions and 130 deletions

View File

@ -177,6 +177,12 @@
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.github.java-json-tools</groupId>
<artifactId>json-patch</artifactId>
<version>1.12</version>
</dependency>
</dependencies>

View File

@ -1,21 +1,18 @@
package com.codesdream.ase.component.activity;
import com.alibaba.fastjson.JSONObject;
import com.codesdream.ase.exception.DataInvalidFormatException;
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.repository.activity.ActivityRepository;
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 javafx.util.converter.LocalDateTimeStringConverter;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
@ -24,9 +21,6 @@ import java.util.*;
@Component
public class ActivityConverter {
@Resource
ActivityService activityService;
@Resource
UserService userService;
@ -43,14 +37,14 @@ public class ActivityConverter {
Activity activity = new Activity();
JSONObject jsonObject = json.get();
String username = (String) jsonObject.get("creator");
Optional<User> creator = userService.findUserByUsername(username);
int userId = (int) jsonObject.get("creator");
Optional<User> creator = userService.findUserById(userId);
activity.setCreator(creator.get());
List<String> participateGroupFromJson = (List) jsonObject.get("participate-group");
List<Integer> participateGroupFromJson = (List<Integer>) jsonObject.get("participate-group");
Set<User> participateGroup = new HashSet<>();
for (String name : participateGroupFromJson) {
Optional<User> user = userService.findUserByUsername(name);
for (int id : participateGroupFromJson) {
Optional<User> user = userService.findUserById(id);
participateGroup.add(user.get());
}
activity.setParticipateGroup(participateGroup);
@ -58,14 +52,14 @@ public class ActivityConverter {
String title = (String) jsonObject.get("title");
activity.setTitle(title);
String chiefManagerName = (String) jsonObject.get("chief-manager");
Optional<User> chiefManager = userService.findUserByUsername(chiefManagerName);
int chiefManagerId = (int) jsonObject.get("chief-manager");
Optional<User> chiefManager = userService.findUserById(chiefManagerId);
activity.setChiefManager(chiefManager.get());
List<String> assistManagerFromJSON = (List) jsonObject.get("assist-manager");
List<Integer> assistManagersFromJSON = (List<Integer>) jsonObject.get("assist-managers");
Set<User> assistManager = new HashSet<>();
for (String name : assistManagerFromJSON) {
Optional<User> user = userService.findUserByUsername(name);
for (int id : assistManagersFromJSON) {
Optional<User> user = userService.findUserById(id);
assistManager.add(user.get());
}
activity.setAssistManagers(assistManager);
@ -88,26 +82,31 @@ public class ActivityConverter {
String description = (String) jsonObject.get("description");
activity.setDescription(description);
List<String> signGroupFromJSON = (List) jsonObject.get("sign-group");
List<Integer> signGroupFromJSON = (List<Integer>) jsonObject.get("sign-group");
Set<User> signGroup = new HashSet<>();
for (String name : signGroupFromJSON) {
Optional<User> user = userService.findUserByUsername(name);
for (int id : signGroupFromJSON) {
Optional<User> user = userService.findUserById(id);
signGroup.add(user.get());
}
activity.setSignGroup(signGroup);
List<String> informGroupFromJSON = (List) jsonObject.get("inform-group");
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 (String name : informGroupFromJSON) {
Optional<User> user = userService.findUserByUsername(name);
for (int id : informGroupFromJSON) {
Optional<User> user = userService.findUserById(id);
informGroup.add(user.get());
}
activity.setInformGroup(informGroup);
List<String> visibleGroupFromJSON = (List) jsonObject.get("visible-group");
List<Integer> visibleGroupFromJSON = (List<Integer>) jsonObject.get("visible-group");
Set<User> visibleGroup = new HashSet<>();
for (String name : visibleGroupFromJSON) {
Optional<User> user = userService.findUserByUsername(name);
for (int id : visibleGroupFromJSON) {
Optional<User> user = userService.findUserById(id);
visibleGroup.add(user.get());
}
activity.setVisibleGroup(informGroup);

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -1,7 +1,7 @@
package com.codesdream.ase.component.datamanager;
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.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

View File

@ -2,6 +2,9 @@ package com.codesdream.ase.component.datamanager;
import com.codesdream.ase.exception.*;
import com.codesdream.ase.exception.innerservererror.DataIOException;
import com.codesdream.ase.exception.innerservererror.DataIllegalTableFormatException;
import com.codesdream.ase.exception.innerservererror.DataInvalidFormatException;
import com.codesdream.ase.exception.notfound.DataFileNotFoundException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
@ -48,7 +51,7 @@ public class DataExcelReader implements DataReader {
Row titleRow = sheet.getRow(0);
colNumber = titleRow.getLastCellNum();
// 表头项目个数不可为0
if(colNumber == 0) throw new DataIllegalTableFormatException();
if(colNumber == 0) throw new DataIllegalTableFormatException();
Collection<String> title = new ArrayList<>();
for(int cellIdx = 0; cellIdx < colNumber; cellIdx++){
title.add(readCell(titleRow.getCell(cellIdx)));

View File

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

View File

@ -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());
}
}
}

View File

@ -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());
}
}
}

View File

@ -12,13 +12,13 @@ import java.util.List;
@Data
@NoArgsConstructor
@ApiModel("标签所属用户集合")
public class JsonableTagUserList {
public class JsonableUserList {
@ApiModelProperty(name = "用户列表")
private List<Integer> users;
public JsonableTagUserList(Tag tag){
public JsonableUserList(Tag tag){
for(User user : tag.getUsers()){
users.add(user.getId());
}

View File

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

View File

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

View File

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

View File

@ -3,7 +3,11 @@ package com.codesdream.ase.controller;
import com.codesdream.ase.component.api.QuickJSONRespond;
import com.codesdream.ase.component.json.respond.ErrorInfoJSONRespond;
import com.codesdream.ase.exception.badrequest.AlreadyExistException;
import com.codesdream.ase.exception.badrequest.IllegalException;
import com.codesdream.ase.exception.conflict.RelatedObjectsExistException;
import com.codesdream.ase.exception.innerservererror.FormatException;
import com.codesdream.ase.exception.innerservererror.HandlingErrorsException;
import com.codesdream.ase.exception.innerservererror.RuntimeIOException;
import com.codesdream.ase.exception.notfound.NotFoundException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -21,7 +25,8 @@ public class ASEControllerAdvice {
@ExceptionHandler(value = {
NullPointerException.class,
AlreadyExistException.class
AlreadyExistException.class,
IllegalException.class
})
public ResponseEntity<Object> handleBadRequest(Exception ex) {
return getResponse(HttpStatus.BAD_REQUEST, ex);
@ -43,6 +48,14 @@ public class ASEControllerAdvice {
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));

View File

@ -1,9 +1,17 @@
package com.codesdream.ase.controller;
import com.alibaba.fastjson.JSONObject;
import com.codesdream.ase.component.datamanager.JSONParameter;
import com.codesdream.ase.component.json.request.UserLeaveRequest;
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;
@ -14,6 +22,8 @@ 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;
@ -27,34 +37,79 @@ public class LeavesController {
@Resource
private JSONParameter jsonParameter;
@Resource
private QuickJSONRespond quickJSONRespond;
@Resource
private LeavesService leavesService;
@Resource
private ASEUsernameEncoder usernameEncoder;
@RequestMapping(value = "/leave")
/* @RequestMapping(value = "/")
String printLeave(Model model) {
return "Leave";
}
}*/
//提交请假申请
@RequestMapping(value = "/leave/check", method = RequestMethod.POST)
@RequestMapping(value = "/Leave/check", method = RequestMethod.POST)
@ResponseBody
String requestLeave(HttpServletRequest request){
String leaveRequest(HttpServletRequest request){
// 检查是否为JSON
Optional<JSONObject> json = jsonParameter.getJSONByRequest(request);
// if(!json.isPresent()) return jsonParameter.getJSONString(new FailedSONRespond());
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);
UserLeaveRequest LeaveChecker = json.get().toJavaObject(UserLeaveRequest.class);
return quickJSONRespond.getRespond200("申请已提交");
// 检查类型
return jsonParameter.getJSONString(request);
}
//列出某辅导员待审核名单
@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");
}
}
//列出某人
}

View File

@ -1,30 +1,31 @@
package com.codesdream.ase.controller;
import com.alibaba.fastjson.JSONObject;
import com.codesdream.ase.component.datamanager.JSONParameter;
import com.codesdream.ase.component.api.QuickJSONRespond;
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.JsonableTagUserList;
import com.codesdream.ase.component.json.model.JsonableUserList;
import com.codesdream.ase.component.json.model.JsonableUser;
import com.codesdream.ase.component.json.respond.PermissionJSONRespond;
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.exception.notfound.TagNotFoundException;
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 javax.servlet.http.HttpServletRequest;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
@ -41,6 +42,9 @@ public class PermissionController {
@Resource
private IUserService userService;
@Resource
private JsonPathParameter pathParameter;
// 根据名字创建新的标签
@PostMapping("tag")
@ResponseStatus(HttpStatus.CREATED)
@ -99,31 +103,51 @@ public class PermissionController {
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 JsonableTagUserList getUserTag(@RequestParam(value = "name") String name){
public JsonableUserList getUserTag(@RequestParam(value = "name") String name){
Optional<Tag> tag = permissionService.findTag(name);
if(!tag.isPresent()) throw new NotFoundException(name);
return new JsonableTagUserList(tag.get());
return new JsonableUserList(tag.get());
}
@PutMapping("tag/users")
@ApiOperation("更新索单个标签所属用户集合信息")
public JsonableTagUserList setUserTag(@RequestParam String name, @RequestBody JsonableTagUserList userList){
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 JsonableTagUserList(permissionService.save(tag.get()));
return new JsonableUserList(permissionService.save(tag.get()));
}
@PostMapping("tag/users")
@ApiOperation("更新单个标签所属用户集合中添加一个或多个用户")
public JsonableTagUserList addUserTag(@RequestParam String name, @RequestBody JsonableTagUserList userList){
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()));
@ -133,13 +157,14 @@ public class PermissionController {
userSet.addAll(newUserSet);
tag.get().setUsers(userSet);
return new JsonableTagUserList(permissionService.save(tag.get()));
return new JsonableUserList(permissionService.save(tag.get()));
}
@DeleteMapping("tag/users")
@ResponseStatus(HttpStatus.OK)
@ApiOperation("从单个标签所属用户集合中删除一个或多个用户")
@ApiImplicitParam(name = "name", value = "标签名")
public JsonableTagUserList deleteUserTag(@RequestParam String name, @RequestBody JsonableTagUserList userList){
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();
@ -148,7 +173,7 @@ public class PermissionController {
userSet.removeAll(deleteUserSet);
tag.get().setUsers(userSet);
return new JsonableTagUserList(permissionService.save(tag.get()));
return new JsonableUserList(permissionService.save(tag.get()));
}
@GetMapping("tags/users")
@ -167,6 +192,31 @@ public class PermissionController {
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()));
}
}

View File

@ -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 {
}

View File

@ -7,28 +7,27 @@ 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.InvalidFormFormatException;
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.repository.permission.UserRepository;
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.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
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.Map;
import java.util.Optional;
@Controller
@ -59,7 +58,7 @@ public class ActivityCreatorController {
ActivityValidator activityValidator;
@Resource
UserRepository userRepository;
UserService userService;
@Resource
UserActivityRepository userActivityRepository;
@ -69,12 +68,25 @@ public class ActivityCreatorController {
private final String url = "/forget/activity";
@RequestMapping(value = url + "/activity_creator")
String activityCreatorView(Model model){return "activity_creator";}
@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();
@ -82,19 +94,16 @@ public class ActivityCreatorController {
Optional<JSONObject> json = jsonParameter.getJSONByRequest(request);
if (!json.isPresent()) return jsonParameter.getJSONString(new JSONStandardFailedRespond());
//WebFormValidator webFormValidator = aseSpringUtil.getBean(WebFormValidator.class);
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);
//NullValueValidator nullValueValidator = aseSpringUtil.getBean(NullValueValidator.class);
List<String> nullValues = nullValueValidator.checkNullValues(activity);
//= aseSpringUtil.getBean(NullValueAttributes.class);
for (String str : nullValues){
if(str.equals("title")){
nullValueAttributes.getNullValueAttributes().add("title");
@ -113,9 +122,8 @@ public class ActivityCreatorController {
}
}
//如果为空存下此活动并跳转至成功创建页面
if(nullValueAttributes.getNullValueAttributes().isEmpty()){
if (!nullValueAttributes.getNullValueAttributes().isEmpty()) {
//ActivityValidator activityValidator = aseSpringUtil.getBean(ActivityValidator.class);
String[] errorParameters = activityValidator.check(json);
if(errorParameters != null){
JSONObject invalidParameters = new JSONObject();
@ -124,12 +132,9 @@ public class ActivityCreatorController {
}
else{
//UserRepository userRepository = aseSpringUtil.getBean(UserRepository.class);
//activityService = aseSpringUtil.getBean(ActivityService.class);
activity = activityService.createActivity(activity);
String username = json.get().get("creator").toString();
Optional<User> user = userRepository.findByUsername(username);
//UserActivityRepository userActivityRepository = aseSpringUtil.getBean(UserActivityRepository.class);
Optional<User> user = userService.findUserByUsername(username);
UserActivity userActivity = userActivityRepository.findByUser(user.get());
userActivity.getCreatedActivities().add(activity);
userActivityRepository.save(userActivity);

View File

@ -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();
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,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);
}
}

View File

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

View File

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

View File

@ -2,8 +2,6 @@ package com.codesdream.ase.model.activity;
import com.codesdream.ase.model.permission.User;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.parameters.P;
import javax.persistence.*;
import java.time.LocalDateTime;

View File

@ -15,10 +15,6 @@ public class Attendance {
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
//二维码url
@Column(name = "qr_code")//, nullable = false, unique = true)
private String QRCode;
//是否在线
@Column(name = "is_online")//, nullable = false)
private boolean isOnline;

View File

@ -1,5 +1,7 @@
package com.codesdream.ase.model.activity;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
@ -18,10 +20,12 @@ public class Period {
private int id;
//开始时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Column(name = "start_time")//, nullable = false)
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)
private LocalDateTime endTime = LocalDateTime.of(2020,2,18,16,37);

View File

@ -9,12 +9,13 @@ import javax.persistence.*;
@Entity
@Table(name = "leaves")
public class Leave {
//请假的编号
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
//发出人
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private User userFrom;
@Column
private String userFrom;
//审批人容器
@ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY)
private Set <User> userTo;
@ -28,7 +29,7 @@ public class Leave {
private String type;
//批准状态
@Column(nullable = false)
private String authentication;
private String authentication="Pending";
//审核备注
@Column

View File

@ -2,7 +2,7 @@ package com.codesdream.ase.service;
import com.codesdream.ase.component.datamanager.DataTable;
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.notfound.BaseInformationNotFoundException;
import com.codesdream.ase.model.information.*;
import com.codesdream.ase.repository.information.*;

View File

@ -4,6 +4,7 @@ import com.codesdream.ase.model.leaves.Leave;
import java.util.Optional;
import java.util.OptionalInt;
public interface ILeavesService {
//通过标题查找活动
@ -12,6 +13,8 @@ public interface ILeavesService {
//通过创建人姓名查找活动
Optional<Leave> findLeaveByCreator(String creatorName);
Optional<Leave>findLeaveById(int id);
//活动
Leave save(Leave leave);
@ -21,7 +24,6 @@ public interface ILeavesService {
//请假信息更新
Leave update(Leave Leave);
//创建请假条目
Leave createLeave(Leave Leave);

View File

@ -44,6 +44,10 @@ public interface IPermissionService {
// 标签下所有的获得权限容器集合列表
Collection<PermissionContainersCollection> getPCCs(Tag tag);
Set<PermissionContainersCollection> findPCCs(Set<Integer> pccs);
Optional<PermissionContainersCollection> findPCC(Integer id);
// 获得范围性权限容器下的所有标签列表
Collection<Tag> getTagsFromSPC(
ScopePermissionContainer spc);

View File

@ -8,7 +8,7 @@ import javax.annotation.Resource;
import java.util.Optional;
@Service
public class LeavesService implements ILeavesService {
public class LeavesService implements ILeavesService {
@Resource
private LeaveRepository leaveRepository;
@ -25,10 +25,16 @@ public class LeavesService implements ILeavesService {
}
@Override
public Leave save(Leave leave) {
public Leave save( Leave leave) {
return leaveRepository.save(leave);
}
@Override
public Optional<Leave> findLeaveById(int id) {
return leaveRepository.findById(id);
}
@Override
public void delete(Leave leave) {
@ -45,7 +51,8 @@ public class LeavesService implements ILeavesService {
return leaveRepository.save(leave);
}
/*@Override
/*@Override
public Leave findActivitiesInTheCharge(User user) {
}*/

View File

@ -110,6 +110,22 @@ public class PermissionService implements IPermissionService {
return new ArrayList<>(tag.getPermissionContainersCollections());
}
@Override
public Set<PermissionContainersCollection> findPCCs(Set<Integer> pccs) {
Set<PermissionContainersCollection> set = new HashSet<>();
for(Integer id : pccs){
Optional<PermissionContainersCollection> pcc = findPCC(id);
if(!pcc.isPresent()) throw new NotFoundException(String.format("PCCId: %d",id));
set.add(pcc.get());
}
return set;
}
@Override
public Optional<PermissionContainersCollection> findPCC(Integer id) {
return pccRepository.findById(id);
}
@Override
public Collection<Tag> getTagsFromSPC(ScopePermissionContainer spc) {
return new ArrayList<>(spc.getTags());

View File

@ -3,7 +3,7 @@ package com.codesdream.ase.service;
import com.codesdream.ase.component.auth.ASEPasswordEncoder;
import com.codesdream.ase.component.auth.ASEUsernameEncoder;
import com.codesdream.ase.component.permission.UserRolesListGenerator;
import com.codesdream.ase.exception.UserInformationIllegalException;
import com.codesdream.ase.exception.badrequest.UserInformationIllegalException;
import com.codesdream.ase.exception.notfound.UserNotFoundException;
import com.codesdream.ase.exception.badrequest.UsernameAlreadyExistException;
import com.codesdream.ase.model.information.BaseStudentInfo;

View File

@ -1,8 +1,6 @@
package com.codesdream.ase.validator;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.codesdream.ase.exception.DataIllegalTableFormatException;
import org.springframework.stereotype.Component;
import java.util.*;

View File

@ -2,13 +2,10 @@ package com.codesdream.ase.test;
import com.alibaba.fastjson.JSONObject;
import com.codesdream.ase.component.ASESpringUtil;
import com.codesdream.ase.component.json.respond.JSONBaseRespondObject;
import com.codesdream.ase.configure.ActivityFormConfigure;
import com.codesdream.ase.exception.InvalidFormFormatException;
import com.codesdream.ase.exception.innerservererror.InvalidFormFormatException;
import com.codesdream.ase.validator.JSONFormValidator;
import com.fasterxml.jackson.databind.util.JSONPObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;