From b17a11009f2e94ca07bd060bb29e5d6e870cddae Mon Sep 17 00:00:00 2001 From: chuyan <1047381936@qq.com> Date: Tue, 1 Sep 2020 14:57:04 +0800 Subject: [PATCH] first deletion --- .../component/activity/ActivityConverter.java | 2 - .../ase/component/activity/FileSystem.java | 3 - .../ActivityAttendanceController.java | 16 -- .../activity/ActivityCreatorController.java | 155 -------------- .../activity/ActivityViewerController.java | 94 --------- .../controller/activity/QRCodeController.java | 36 ---- .../ase/model/achievement/AccumulatedGPA.java | 42 ---- .../ase/model/achievement/Award.java | 34 --- .../achievement/ComprehensiveEvaluation.java | 44 ---- .../ase/model/achievement/ExamResult.java | 43 ---- .../model/achievement/StudentScoreReport.java | 33 --- .../ase/model/activity/Activity.java | 198 ------------------ .../ase/model/activity/AppendixFile.java | 27 --- .../ase/model/activity/Attendance.java | 29 --- .../codesdream/ase/model/activity/Period.java | 45 ---- .../codesdream/ase/model/activity/Report.java | 174 --------------- .../ase/model/activity/UserActivity.java | 55 ----- .../activity/ActivityRepository.java | 21 -- .../activity/AppendixFileRespository.java | 10 - .../activity/AttendanceRepository.java | 9 - .../repository/activity/PeriodRepository.java | 9 - .../repository/activity/ReportRepository.java | 14 -- .../activity/UserActivityRepository.java | 17 -- .../ase/service/AchievementService.java | 8 - .../ase/service/ActivityService.java | 180 ---------------- .../ase/service/AppendixFileService.java | 36 ---- .../ase/service/AttendanceService.java | 18 -- .../ase/service/IActivityService.java | 59 ------ .../ase/service/IAppendixFileService.java | 21 -- .../codesdream/ase/service/PeriodService.java | 22 -- .../codesdream/ase/service/ReportService.java | 46 ---- .../ase/test/AchievementServiceTest.java | 5 - .../codesdream/ase/test/FileSystemTest.java | 2 - 33 files changed, 1507 deletions(-) delete mode 100644 src/main/java/com/codesdream/ase/controller/activity/ActivityAttendanceController.java delete mode 100644 src/main/java/com/codesdream/ase/controller/activity/ActivityCreatorController.java delete mode 100644 src/main/java/com/codesdream/ase/controller/activity/ActivityViewerController.java delete mode 100644 src/main/java/com/codesdream/ase/controller/activity/QRCodeController.java delete mode 100644 src/main/java/com/codesdream/ase/model/achievement/AccumulatedGPA.java delete mode 100644 src/main/java/com/codesdream/ase/model/achievement/Award.java delete mode 100644 src/main/java/com/codesdream/ase/model/achievement/ComprehensiveEvaluation.java delete mode 100644 src/main/java/com/codesdream/ase/model/achievement/ExamResult.java delete mode 100644 src/main/java/com/codesdream/ase/model/achievement/StudentScoreReport.java delete mode 100644 src/main/java/com/codesdream/ase/model/activity/Activity.java delete mode 100644 src/main/java/com/codesdream/ase/model/activity/AppendixFile.java delete mode 100644 src/main/java/com/codesdream/ase/model/activity/Attendance.java delete mode 100644 src/main/java/com/codesdream/ase/model/activity/Period.java delete mode 100644 src/main/java/com/codesdream/ase/model/activity/Report.java delete mode 100644 src/main/java/com/codesdream/ase/model/activity/UserActivity.java delete mode 100644 src/main/java/com/codesdream/ase/repository/activity/ActivityRepository.java delete mode 100644 src/main/java/com/codesdream/ase/repository/activity/AppendixFileRespository.java delete mode 100644 src/main/java/com/codesdream/ase/repository/activity/AttendanceRepository.java delete mode 100644 src/main/java/com/codesdream/ase/repository/activity/PeriodRepository.java delete mode 100644 src/main/java/com/codesdream/ase/repository/activity/ReportRepository.java delete mode 100644 src/main/java/com/codesdream/ase/repository/activity/UserActivityRepository.java delete mode 100644 src/main/java/com/codesdream/ase/service/AchievementService.java delete mode 100644 src/main/java/com/codesdream/ase/service/ActivityService.java delete mode 100644 src/main/java/com/codesdream/ase/service/AppendixFileService.java delete mode 100644 src/main/java/com/codesdream/ase/service/AttendanceService.java delete mode 100644 src/main/java/com/codesdream/ase/service/IActivityService.java delete mode 100644 src/main/java/com/codesdream/ase/service/IAppendixFileService.java delete mode 100644 src/main/java/com/codesdream/ase/service/PeriodService.java delete mode 100644 src/main/java/com/codesdream/ase/service/ReportService.java diff --git a/src/main/java/com/codesdream/ase/component/activity/ActivityConverter.java b/src/main/java/com/codesdream/ase/component/activity/ActivityConverter.java index 5d2783f..b3eb1e2 100644 --- a/src/main/java/com/codesdream/ase/component/activity/ActivityConverter.java +++ b/src/main/java/com/codesdream/ase/component/activity/ActivityConverter.java @@ -7,8 +7,6 @@ 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; diff --git a/src/main/java/com/codesdream/ase/component/activity/FileSystem.java b/src/main/java/com/codesdream/ase/component/activity/FileSystem.java index f0fab48..01dd25b 100644 --- a/src/main/java/com/codesdream/ase/component/activity/FileSystem.java +++ b/src/main/java/com/codesdream/ase/component/activity/FileSystem.java @@ -5,14 +5,11 @@ 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 diff --git a/src/main/java/com/codesdream/ase/controller/activity/ActivityAttendanceController.java b/src/main/java/com/codesdream/ase/controller/activity/ActivityAttendanceController.java deleted file mode 100644 index 568e2cb..0000000 --- a/src/main/java/com/codesdream/ase/controller/activity/ActivityAttendanceController.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.codesdream.ase.controller.activity; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; - -import javax.annotation.Resource; - -@Controller -@RequestMapping("/act") -public class ActivityAttendanceController { - - private final String url = "/forget"; - - -} diff --git a/src/main/java/com/codesdream/ase/controller/activity/ActivityCreatorController.java b/src/main/java/com/codesdream/ase/controller/activity/ActivityCreatorController.java deleted file mode 100644 index a1ea1e2..0000000 --- a/src/main/java/com/codesdream/ase/controller/activity/ActivityCreatorController.java +++ /dev/null @@ -1,155 +0,0 @@ -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.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.Optional; - -@Controller -@RequestMapping("/forget/act") -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; - - - @PostMapping(value = "/creator") - @ResponseBody - @ApiOperation(value = "创建活动", notes = "所有有关用户的数据传递均使用id,类型为int") - @ApiImplicitParams({ - @ApiImplicitParam(name = "title", value = "活动标题", dataType = "String", required = true), - @ApiImplicitParam(name = "type", value = "活动类型", dataType = "String", 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", dataType = "int", value = "主要负责人", required = true), - @ApiImplicitParam(name = "assist-managers", dataType = "int", value = "次要负责人"), - @ApiImplicitParam(name = "description", dataType = "String", value = "活动描述"), - @ApiImplicitParam(name = "cycle", dataType = "String", value = "活动周期,格式为阿拉伯数字数字+单位,0表示无周期"), - @ApiImplicitParam(name = "participate-group", value = "预定参与人员"), - @ApiImplicitParam(name = "sign-group", dataType = "List", value = "可参与人员"), - @ApiImplicitParam(name = "inform-group", dataType = "List", value = "通知人群,若为空,则默认为预定参与人员和可报名人员的并集"), - @ApiImplicitParam(name = "visible-group", dataType = "List", value = "活动可见人群,若为空,则默认为负责人、活动创建者预定参和可报名人员以及通知人员的并集"), - @ApiImplicitParam(name = "remind-time", dataType = "String", defaultValue = "30m", value = "活动提醒时间,格式为数字+单位,可接受的单位从大到小有:w,d,h,m,s"), - }) - String activityCreator(HttpServletRequest request) throws InvalidFormFormatException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { - - JSONObject error = new JSONObject(); - aseSpringUtil = new ASESpringUtil(); - //判断是否为JSON对象 - Optional json = jsonParameter.getJSONByRequest(request); - if (!json.isPresent()) return jsonParameter.getJSONString(new JSONStandardFailedRespond()); - - List formatCheckResult = jsonFormValidator.check(activityFormConfigure.getStdActivityForm(), json.get()); - - //检验JSON格式是否有误 - if (!formatCheckResult.isEmpty()) { - error.put("error", formatCheckResult); - throw new InvalidFormFormatException(error.toJSONString()); - } - Activity activity = activityConverter.convertToActivity(json); - List 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 = userService.findUserByUsername(username); - UserActivity userActivity = userActivityRepository.findByUser(user.get()); - userActivity.getCreatedActs().add(activity); - userActivityRepository.save(userActivity); - } - } - //否则返回一个JSON对象给前端 - else{ - JSONObject nullParameters = new JSONObject(); - nullParameters.put("null_values",nullValueAttributes.getNullValueAttributes()); - return nullParameters.toJSONString(); - } - JSONObject jsonObject = (JSONObject) JSONObject.toJSON(activity); - return jsonObject.toJSONString(); - } -} - - diff --git a/src/main/java/com/codesdream/ase/controller/activity/ActivityViewerController.java b/src/main/java/com/codesdream/ase/controller/activity/ActivityViewerController.java deleted file mode 100644 index 27ffa82..0000000 --- a/src/main/java/com/codesdream/ase/controller/activity/ActivityViewerController.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.codesdream.ase.controller.activity; - -import com.alibaba.fastjson.JSONObject; -import com.codesdream.ase.model.activity.Activity; -import com.codesdream.ase.model.permission.User; -import com.codesdream.ase.service.ActivityService; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.util.List; - -@Controller -@RequestMapping("/forget/act") -public class ActivityViewerController { - - - @Resource - ActivityService activityService; - - @GetMapping("/created_acts") - String showCreated() { - - User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); - List activities = activityService.findCreatedActs(user); - return JSONObject.toJSONString(activities); - } - - @GetMapping("/parting_acts") - String showParticipate(HttpServletRequest request) { - - User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); - List activities = activityService.findParticipatingActs(user); - return JSONObject.toJSONString(activities); - } - - @GetMapping("/parted_acts") - String showParticipated() { - - User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); - List activities = activityService.findParticipatedActs(user); - return JSONObject.toJSONString(activities); - } - - @GetMapping("/sign_acts") - String showSign() { - - User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); - List activities = activityService.findSignActs(user); - return JSONObject.toJSONString(activities); - } - - @GetMapping("/vis_acts") - String showVisible() { - - User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); - List activities = activityService.findVisibleActs(user); - return JSONObject.toJSONString(activities); - } - - @GetMapping("/all") - String showAll() { - - User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); - List activities = activityService.findAll(user); - return JSONObject.toJSONString(activities); - } - - @GetMapping("/main_responsible_acts") - String showMainResponsible() { - - User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); - List activities = activityService.findMainResponsibleActs(user); - return JSONObject.toJSONString(activities); - } - - @GetMapping("/sec_responsible_acts") - String showSecondaryResponsible() { - - User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); - List activities = activityService.findSecondaryResponsibleActs(user); - return JSONObject.toJSONString(activities); - } - - @GetMapping("/acts_by_type") - String showInType(@RequestParam(defaultValue = "考勤", name = "type") String type) { - - User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); - List activities = activityService.findActivityByType(user, type); - return JSONObject.toJSONString(activities); - } -} diff --git a/src/main/java/com/codesdream/ase/controller/activity/QRCodeController.java b/src/main/java/com/codesdream/ase/controller/activity/QRCodeController.java deleted file mode 100644 index 3c5d7d0..0000000 --- a/src/main/java/com/codesdream/ase/controller/activity/QRCodeController.java +++ /dev/null @@ -1,36 +0,0 @@ -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(); - } - } -} diff --git a/src/main/java/com/codesdream/ase/model/achievement/AccumulatedGPA.java b/src/main/java/com/codesdream/ase/model/achievement/AccumulatedGPA.java deleted file mode 100644 index aa89fcf..0000000 --- a/src/main/java/com/codesdream/ase/model/achievement/AccumulatedGPA.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.codesdream.ase.model.achievement; - -import com.codesdream.ase.model.activity.Period; -import lombok.Data; - -import javax.persistence.*; -import java.time.LocalDateTime; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -@Data -@Entity -@Table(name = "accumulated_gpa") - -public class AccumulatedGPA { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private int id; - - // 课程-得分集合 - @OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH}, fetch = FetchType.LAZY) - private Set examResults = new HashSet<>(); - - // 个人学分积 - @JoinColumn(nullable = true) - private float accumulatedGPA; - - - //除数为零exception待加 - public AccumulatedGPA(Set initExamResults) { - int totalProduct = 0, totalCredit = 0; - for(ExamResult er : initExamResults){ - totalProduct += er.getCredit() * er.getScore(); - totalCredit += er.getCredit(); - } - this.accumulatedGPA = totalProduct / totalCredit; - } - - -} diff --git a/src/main/java/com/codesdream/ase/model/achievement/Award.java b/src/main/java/com/codesdream/ase/model/achievement/Award.java deleted file mode 100644 index 8a6026c..0000000 --- a/src/main/java/com/codesdream/ase/model/achievement/Award.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.codesdream.ase.model.achievement; - -import com.codesdream.ase.model.permission.User; -import com.codesdream.ase.model.permission.UserDetail; -import lombok.Data; - -import javax.persistence.*; -import java.util.HashSet; -import java.util.Set; - -@Data -@Entity -@Table(name = "award") - -public class Award { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private int id; - - // 标题 - private String title = ""; - - // 描述 - private String description = ""; - - // 分类 - private String type = ""; - - // 加分 - private int bonus; - - -} diff --git a/src/main/java/com/codesdream/ase/model/achievement/ComprehensiveEvaluation.java b/src/main/java/com/codesdream/ase/model/achievement/ComprehensiveEvaluation.java deleted file mode 100644 index 0393edd..0000000 --- a/src/main/java/com/codesdream/ase/model/achievement/ComprehensiveEvaluation.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.codesdream.ase.model.achievement; - -import com.codesdream.ase.model.permission.User; -import com.codesdream.ase.model.permission.UserDetail; -import lombok.Data; - -import javax.persistence.*; -import java.util.HashSet; -import java.util.Set; - -@Data -@Entity -@Table(name = "comprehensive_evaluation") - -public class ComprehensiveEvaluation { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private int id; - - // 学分积 - @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - private AccumulatedGPA accumulatedGPA; - - // G2项得分 - private int g2; - - // G3项得分 - private int g3; - - // G4项得分 - private int g4; - - // G5项得分 - private int g5; - - // G6项得分 - private int g6; - - // 获奖 - @OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH}, fetch = FetchType.LAZY) - private Set awards = new HashSet<>(); - -} diff --git a/src/main/java/com/codesdream/ase/model/achievement/ExamResult.java b/src/main/java/com/codesdream/ase/model/achievement/ExamResult.java deleted file mode 100644 index 2543fca..0000000 --- a/src/main/java/com/codesdream/ase/model/achievement/ExamResult.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.codesdream.ase.model.achievement; - -import com.codesdream.ase.model.activity.Period; -import lombok.Data; - -import javax.persistence.*; - -@Data -@Entity -@Table(name = "exam_result") - -public class ExamResult { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private int id; - - // 课程名称 - @Column(name = "subject", nullable = false) - private String subject = ""; - - // 课程学分 - @Column(name = "credit", nullable = false) - private float credit; - - // 课程成绩 - @Column(name = "score", nullable = true) - private int score; - - // 课程绩点 - @Column(name = "grade_point", nullable = true) - private float gradePoint; - - - public float getCredit() { - return credit; - } - - public int getScore() { - return score; - } - -} diff --git a/src/main/java/com/codesdream/ase/model/achievement/StudentScoreReport.java b/src/main/java/com/codesdream/ase/model/achievement/StudentScoreReport.java deleted file mode 100644 index 32550ba..0000000 --- a/src/main/java/com/codesdream/ase/model/achievement/StudentScoreReport.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.codesdream.ase.model.achievement; - -import com.codesdream.ase.model.activity.Period; -import com.codesdream.ase.model.permission.Tag; -import com.codesdream.ase.model.permission.User; -import lombok.Data; - -import javax.persistence.*; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -@Data -@Entity -@Table(name = "student_score_report") - -public class StudentScoreReport { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private int id; - - // 课程-得分集合 - @OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH}, fetch = FetchType.LAZY) - private Set examResults = new HashSet<>(); - - // 个人学分积 - @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(nullable = true) - private AccumulatedGPA accumulatedGPA; - -} diff --git a/src/main/java/com/codesdream/ase/model/activity/Activity.java b/src/main/java/com/codesdream/ase/model/activity/Activity.java deleted file mode 100644 index a99a6e6..0000000 --- a/src/main/java/com/codesdream/ase/model/activity/Activity.java +++ /dev/null @@ -1,198 +0,0 @@ -package com.codesdream.ase.model.activity; - -import com.codesdream.ase.model.permission.User; -import lombok.Data; - -import javax.persistence.*; -import java.time.LocalDateTime; -import java.util.*; - -@Data -@Entity -@Table(name = "activity") -public class Activity { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private int id; - - //活动标题 - @Column(name = "title", nullable = false) - private String title; - - //创建人 - @ManyToOne(cascade = CascadeType.MERGE) - @JoinColumn(nullable = false) - private User creator; - - //活动类型 - @Column(nullable = false) - private String type; - - //活动描述 - @Column - private String description; - - //活动周期,格式:阿拉伯数字数字+单位,0表示无周期 - @Column - private String cycle; - - //自愿参与人列表 - @ManyToMany(cascade = CascadeType.DETACH) - @JoinTable(name = "act_volunteer") - private Set volunteers; - - //参与人列表 - @ManyToMany(cascade = CascadeType.DETACH) - @JoinTable(name = "act_participate", - joinColumns = { - @JoinColumn(name = "act_id") - }, - inverseJoinColumns = { - @JoinColumn(name = "participate_id") - } - ) - private Set participateGroup; - - //实际参与人列表 - @ManyToMany(cascade = CascadeType.DETACH) - @JoinTable(name = "act_participated", - joinColumns = { - @JoinColumn(name = "act_id" ) - }, - inverseJoinColumns = { - @JoinColumn(name = "participated_id") - } - ) - private Set participatedGroup; - - //可报名人员列表 - @ManyToMany(cascade = CascadeType.DETACH) - @JoinTable(name = "act_sign", - joinColumns = { - @JoinColumn(name = "act_id") - }, - inverseJoinColumns = { - @JoinColumn(name = "sign_id") - } - ) - private Set signGroup; - - //已报名人员列表 - @ManyToMany(cascade = CascadeType.MERGE) - @JoinTable(name = "act_signed", - joinColumns = { - @JoinColumn(name = "act_id") - }, - inverseJoinColumns = { - @JoinColumn(name = "signed_id") - } - ) - private Set signedGroup; - - //可见人员列表 - @ManyToMany(cascade = CascadeType.DETACH) - @JoinTable(name = "act_vis", - joinColumns = { - @JoinColumn(name = "act_id") - }, - inverseJoinColumns = { - @JoinColumn(name = "vis_id") - } - ) - private Set visibleGroup; - - //通知人员列表 - @ManyToMany(cascade = CascadeType.DETACH) - @JoinTable(name = "act_inform", - joinColumns = { - @JoinColumn(name = "act_id") - }, - inverseJoinColumns = { - @JoinColumn(name = "inform_id") - } - ) - private Set informGroup; - - //已通知人员列表 - @ManyToMany(cascade = CascadeType.DETACH) - @JoinTable(name = "act_informed", - joinColumns = { - @JoinColumn(name = "act_id") - }, - inverseJoinColumns = { - @JoinColumn(name = "informed_id") - } - ) - private Set informedGroup; - - //计划开始时间 - @OneToOne(cascade = CascadeType.ALL) - @JoinColumn(nullable = false) - private Period planPeriod; - - //实际开始时间 - @OneToOne(cascade = CascadeType.ALL) - private Period realPeriod; - - //提前提醒时间 - @Column(name = "remind_time", nullable = true) - private LocalDateTime remindTime; - - //附件组(名字) - @ElementCollection(targetClass = String.class) - private List enclosures; - - //主要负责人 - @OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY) - @JoinColumn(nullable = false) - private User chiefManager; - - //次要负责人 - @OneToMany(cascade = CascadeType.DETACH, fetch = FetchType.LAZY) - @JoinColumn(name = "act_id") - private Set assistManagers; - - //是否开始 - @Column(name = "is_on", nullable = false) - boolean isOn; - - //是否结束 - @Column(name = "is_off", nullable = false) - boolean isOff; - - //考勤安排 - @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - private Attendance attendance; - - //活动报告 - @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - private Report report; - - public Activity(){ - initDefault(); - } - - private void initDefault(){ - this.title = ""; - this.creator = new User(); - this.type = ""; - this.description = ""; - this.cycle = ""; - this.volunteers = new HashSet<>(); - this.participateGroup = new HashSet<>(); - this.participatedGroup = new HashSet<>(); - this.participatedGroup = new HashSet<>(); - this.signGroup = new HashSet<>(); - this.signedGroup = new HashSet<>(); - this.visibleGroup = new HashSet<>(); - this.informGroup = new HashSet<>(); - this.informedGroup = new HashSet<>(); - this.planPeriod = new Period(); - this.realPeriod = new Period(); - this.enclosures = new ArrayList<>(); - this.chiefManager = new User(); - this.assistManagers = new HashSet<>(); - this.isOn = false; - this.isOff = false; - } -} \ No newline at end of file diff --git a/src/main/java/com/codesdream/ase/model/activity/AppendixFile.java b/src/main/java/com/codesdream/ase/model/activity/AppendixFile.java deleted file mode 100644 index f9e075b..0000000 --- a/src/main/java/com/codesdream/ase/model/activity/AppendixFile.java +++ /dev/null @@ -1,27 +0,0 @@ -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); -} diff --git a/src/main/java/com/codesdream/ase/model/activity/Attendance.java b/src/main/java/com/codesdream/ase/model/activity/Attendance.java deleted file mode 100644 index d72852c..0000000 --- a/src/main/java/com/codesdream/ase/model/activity/Attendance.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.codesdream.ase.model.activity; - -import lombok.Data; - -import javax.persistence.*; -import java.util.List; -import java.util.Set; - -@Data -@Entity -@Table(name = "attendance") -public class Attendance { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private int id; - - //是否在线 - @Column(name = "is_online")//, nullable = false) - private boolean isOnline; - - //打卡时段列表 - @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) - private Set clockInPeriods; - - //打卡方式,0表示被扫,1表示扫 - @Column//(nullable = false) - private boolean means; -} diff --git a/src/main/java/com/codesdream/ase/model/activity/Period.java b/src/main/java/com/codesdream/ase/model/activity/Period.java deleted file mode 100644 index c0ec4d7..0000000 --- a/src/main/java/com/codesdream/ase/model/activity/Period.java +++ /dev/null @@ -1,45 +0,0 @@ -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; - -import javax.persistence.*; -import java.time.LocalDateTime; -import java.util.Calendar; -import java.util.Date; -import java.util.Objects; - -@Entity -@Table(name = "period_container") -@Data -public class Period { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private int id; - - //开始时间 - @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); - - //启用状态 - @Column(name = "enabled")//, nullable = false) - private boolean enabled; - - public Period(LocalDateTime startTime, LocalDateTime endTime) { - this.startTime = startTime; - this.endTime = endTime; - } - - public Period(){ - - } - -} diff --git a/src/main/java/com/codesdream/ase/model/activity/Report.java b/src/main/java/com/codesdream/ase/model/activity/Report.java deleted file mode 100644 index 2bc6a0f..0000000 --- a/src/main/java/com/codesdream/ase/model/activity/Report.java +++ /dev/null @@ -1,174 +0,0 @@ -package com.codesdream.ase.model.activity; - -import com.codesdream.ase.model.permission.User; -import lombok.Data; - -import javax.persistence.*; -import java.awt.*; -import java.util.Date; -import java.util.List; -import java.util.Set; - -@Data -@Entity -@Table(name = "report") -public class Report { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private int id; - - //活动标题 - @Column(nullable = false, unique = true) - private String title; - - //创建人 - @OneToOne(cascade = CascadeType.MERGE) - private User creator; - - //活动类型 - @Column(nullable = false) - private String type; - - //活动描述 - @Column(nullable = true) - private String description; - - //活动周期,格式:阿拉伯数字数字+单位,0表示无周期 - @Column(nullable = true) - private String cycle; - - //自愿参与人列表 - @ManyToMany(cascade = CascadeType.MERGE) - @JoinTable(name = "act_volunteer") - private Set volunteers; - - //参与人列表 - @ManyToMany(cascade = CascadeType.MERGE) - @JoinTable(name = "act_participate", - joinColumns = { - @JoinColumn(name = "act_id") - }, - inverseJoinColumns = { - @JoinColumn(name = "participate_id") - } - ) - private Set participateGroup; - - //实际参与人列表 - @ManyToMany(cascade = CascadeType.ALL) - @JoinTable(name = "act_participated", - joinColumns = { - @JoinColumn(name = "act_id" ) - }, - inverseJoinColumns = { - @JoinColumn(name = "participated_id") - } - ) - private Set participatedGroup; - - //可报名人员列表 - @ManyToMany(cascade = CascadeType.MERGE) - @JoinTable(name = "act_sign", - joinColumns = { - @JoinColumn(name = "act_id") - }, - inverseJoinColumns = { - @JoinColumn(name = "sign_id") - } - ) - private Set signGroup; - - //已报名人员列表 - @ManyToMany(cascade = CascadeType.MERGE) - @JoinTable(name = "act_signed", - joinColumns = { - @JoinColumn(name = "act_id") - }, - inverseJoinColumns = { - @JoinColumn(name = "signed_id") - } - ) - private Set signedGroup; - - //可见人员列表 - @ManyToMany(cascade = CascadeType.MERGE) - @JoinTable(name = "act_vis", - joinColumns = { - @JoinColumn(name = "act_id") - }, - inverseJoinColumns = { - @JoinColumn(name = "vis_id") - } - ) - private Set visibleGroup; - - //通知人员列表 - @ManyToMany(cascade = CascadeType.ALL) - @JoinTable(name = "act_inform", - joinColumns = { - @JoinColumn(name = "act_id") - }, - inverseJoinColumns = { - @JoinColumn(name = "inform_id") - } - ) - private Set informGroup; - - //已通知人员列表 - @ManyToMany(cascade = CascadeType.ALL) - @JoinTable(name = "act_informed", - joinColumns = { - @JoinColumn(name = "act_id") - }, - inverseJoinColumns = { - @JoinColumn(name = "informed_id") - } - ) - private Set informedGroup; - - //计划开始时间 - @OneToOne(cascade = CascadeType.ALL) - @JoinColumn(name = "plan_period") - private Period planPeriod; - - //实际开始时间 - @OneToOne(cascade = CascadeType.ALL) - @JoinColumn(name = "real_period") - private Period realPeriod; - - //主要负责人 - @OneToOne(cascade = CascadeType.ALL) - @JoinColumn(name = "chief_manager", nullable = false) - private User chiefManager; - - //次要负责人 - @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "act_id") - private List assistManagers; - - - //考勤安排 - @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "attendance") - private Attendance attendance; - - //活动笔记 - @Column(name = "notes") - private String notes; - - //图表 - @ElementCollection(targetClass = java.lang.String.class) - @Column(name = "charts") - private List charts; - - //附件url - @Column(name = "enclosure") - private String enclosure; - - //活动 - @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) - @JoinColumn(name = "activity") - private Activity activity; - -} diff --git a/src/main/java/com/codesdream/ase/model/activity/UserActivity.java b/src/main/java/com/codesdream/ase/model/activity/UserActivity.java deleted file mode 100644 index 7e54c53..0000000 --- a/src/main/java/com/codesdream/ase/model/activity/UserActivity.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.codesdream.ase.model.activity; - -import com.codesdream.ase.model.permission.User; -import javafx.scene.chart.ScatterChart; -import lombok.Data; - -import javax.persistence.*; -import java.util.List; - -@Data -@Entity -@Table(name = "user_act") -public class UserActivity { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private int id; - - //关联的用户 - @OneToOne(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY, mappedBy = "userActivity") - @JoinColumn(nullable = false, unique = true) - private User user; - - //主要负责的活动 - @OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY) - private List mainResponsibleActs; - - //次要负责的活动 - @ManyToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY) - private List secondaryResponsibleActs; - - //可见的活动 - @OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY) - private List visibleActs; - - //创建的活动 - @OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY) - private List createdActs; - - //可报名的活动 - @OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY) - private List signUpActs; - - //已经参与的活动 - @OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY) - private List participatedActs; - - //正在(将要)参与的活动 - @OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY) - private List participatingActs; - - //打卡签到活动 - @OneToMany(cascade = {CascadeType.MERGE, CascadeType.DETACH, CascadeType.PERSIST}, fetch = FetchType.LAZY) - private List clockIns; -} diff --git a/src/main/java/com/codesdream/ase/repository/activity/ActivityRepository.java b/src/main/java/com/codesdream/ase/repository/activity/ActivityRepository.java deleted file mode 100644 index aa5ea5b..0000000 --- a/src/main/java/com/codesdream/ase/repository/activity/ActivityRepository.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.codesdream.ase.repository.activity; - -import com.codesdream.ase.model.activity.Activity; -import com.codesdream.ase.model.permission.User; -import org.springframework.data.domain.Sort; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; - -import java.util.List; -import java.util.Optional; - -@Repository -public interface ActivityRepository extends JpaRepository { - - Optional findByTitle(String Title); - - Optional findByCreator(String creatorName); - -} \ No newline at end of file diff --git a/src/main/java/com/codesdream/ase/repository/activity/AppendixFileRespository.java b/src/main/java/com/codesdream/ase/repository/activity/AppendixFileRespository.java deleted file mode 100644 index d7b2b58..0000000 --- a/src/main/java/com/codesdream/ase/repository/activity/AppendixFileRespository.java +++ /dev/null @@ -1,10 +0,0 @@ -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 { - -} diff --git a/src/main/java/com/codesdream/ase/repository/activity/AttendanceRepository.java b/src/main/java/com/codesdream/ase/repository/activity/AttendanceRepository.java deleted file mode 100644 index 31776a3..0000000 --- a/src/main/java/com/codesdream/ase/repository/activity/AttendanceRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -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 { -} diff --git a/src/main/java/com/codesdream/ase/repository/activity/PeriodRepository.java b/src/main/java/com/codesdream/ase/repository/activity/PeriodRepository.java deleted file mode 100644 index 24a45ad..0000000 --- a/src/main/java/com/codesdream/ase/repository/activity/PeriodRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -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 { -} diff --git a/src/main/java/com/codesdream/ase/repository/activity/ReportRepository.java b/src/main/java/com/codesdream/ase/repository/activity/ReportRepository.java deleted file mode 100644 index fd2e581..0000000 --- a/src/main/java/com/codesdream/ase/repository/activity/ReportRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.codesdream.ase.repository.activity; - -import com.codesdream.ase.model.activity.Report; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - -import java.util.Optional; - -@Repository -public interface ReportRepository extends CrudRepository { - Optional findByTitle(String reportTitle); - - Optional findByCreator(String creatorName); -} diff --git a/src/main/java/com/codesdream/ase/repository/activity/UserActivityRepository.java b/src/main/java/com/codesdream/ase/repository/activity/UserActivityRepository.java deleted file mode 100644 index dbbef67..0000000 --- a/src/main/java/com/codesdream/ase/repository/activity/UserActivityRepository.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.codesdream.ase.repository.activity; - -import com.codesdream.ase.model.activity.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.List; -import java.util.Optional; - -@Repository -public interface UserActivityRepository extends CrudRepository { - - UserActivity findByUser(User user); - -} diff --git a/src/main/java/com/codesdream/ase/service/AchievementService.java b/src/main/java/com/codesdream/ase/service/AchievementService.java deleted file mode 100644 index e2f7a0a..0000000 --- a/src/main/java/com/codesdream/ase/service/AchievementService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.codesdream.ase.service; - -import org.springframework.stereotype.Service; - -@Service -public class AchievementService { - -} diff --git a/src/main/java/com/codesdream/ase/service/ActivityService.java b/src/main/java/com/codesdream/ase/service/ActivityService.java deleted file mode 100644 index 9c42112..0000000 --- a/src/main/java/com/codesdream/ase/service/ActivityService.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.codesdream.ase.service; - -import com.codesdream.ase.model.activity.Activity; -import com.codesdream.ase.model.activity.Period; -import com.codesdream.ase.model.activity.Report; -import com.codesdream.ase.model.activity.UserActivity; -import com.codesdream.ase.model.permission.User; -import com.codesdream.ase.repository.activity.ActivityRepository; -import com.codesdream.ase.repository.activity.UserActivityRepository; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.time.LocalDateTime; -import java.util.*; - -@Service -public class ActivityService implements IActivityService { - - @Resource - private ActivityRepository activityRepository; - - @Resource - private UserActivityRepository userActivityRepository; - - @Override - public Optional findActivityByTitle(String title) { - return activityRepository.findByTitle(title); - } - - @Override - public Optional findActivityByCreator(String creatorName) { - return activityRepository.findByCreator(creatorName); - } - - - @Override - public List findActivityByType(User user, String type) { - - List activities = this.findAll(user); - List actsByType = new ArrayList<>(); - for (Activity activity : activities) { - if (activity.getType().equals(type)) { - actsByType.add(activity); - } - } - return actsByType; - } - - @Override - public Activity save(Activity activity) { - return activityRepository.save(activity); - } - - @Override - public Activity addReport(Activity activity, Report report) { - activity.setReport(report); - return update(activity); - } - - @Override - public void delete(Activity activity) { - activityRepository.delete(activity); - } - - @Override - public Activity update(Activity activity) { - return activityRepository.save(activity); - } - - @Override - public Activity createActivity(Activity activity) { - return activityRepository.save(activity); - } - - @Override - public List findMainResponsibleActs(User user) { - - UserActivity userActivity = userActivityRepository.findByUser(user); - List acts = userActivity.getMainResponsibleActs(); - Collections.sort(acts, new ActivityComparator()); - return acts; - } - - @Override - public List findSecondaryResponsibleActs(User user) { - - UserActivity userActivity = userActivityRepository.findByUser(user); - List acts = userActivity.getSecondaryResponsibleActs(); - Collections.sort(acts, new ActivityComparator()); - return acts; - } - - @Override - public List findVisibleActs(User user) { - - UserActivity userActivity = userActivityRepository.findByUser(user); - List acts = userActivity.getVisibleActs(); - Collections.sort(acts, new ActivityComparator()); - return acts; - } - - @Override - public List findSignActs(User user) { - - UserActivity userActivity = userActivityRepository.findByUser(user); - List acts = userActivity.getSignUpActs(); - Collections.sort(acts, new ActivityComparator()); - return acts; - } - - @Override - public List findParticipatedActs(User user) { - - UserActivity userActivity = userActivityRepository.findByUser(user); - List acts = userActivity.getParticipatedActs(); - Collections.sort(acts, new ActivityComparator()); - return acts; - } - - @Override - public List findParticipatingActs(User user) { - - UserActivity userActivity = userActivityRepository.findByUser(user); - List acts = userActivity.getParticipatingActs(); - Collections.sort(acts, new ActivityComparator()); - return acts; - } - - @Override - public List findCreatedActs(User user) { - - UserActivity userActivity = userActivityRepository.findByUser(user); - List acts = userActivity.getCreatedActs(); - Collections.sort(acts, new ActivityComparator()); - return acts; - } - - @Override - public List findAll(User user) { - - List activities = findCreatedActs(user); - List activities1 = findMainResponsibleActs(user); - List activities2 = findSecondaryResponsibleActs(user); - List activities3 = findParticipatingActs(user); - List activities4 = findParticipatedActs(user); - List activities5 = findParticipatingActs(user); - List activities6 = findSignActs(user); - List activities7 = findVisibleActs(user); - Set activitySet = new HashSet<>(); - activitySet.addAll(activities); - activitySet.addAll(activities1); - activitySet.addAll(activities2); - activitySet.addAll(activities3); - activitySet.addAll(activities4); - activitySet.addAll(activities5); - activitySet.addAll(activities6); - activitySet.addAll(activities7); - List res = new ArrayList<>(activitySet); - Collections.sort(res, new ActivityComparator()); - return res; - } - - -} - -class ActivityComparator implements Comparator { - - - @Override - public int compare(Activity o1, Activity o2) { - - Period p1 = o1.getRealPeriod(); - Period p2 = o2.getRealPeriod(); - LocalDateTime s1 = p1.getStartTime(); - LocalDateTime s2 = p2.getStartTime(); - if (s1.isBefore(s2)) return -1; - else if (s1.isAfter(s2)) return 1; - else return 0; - } -} \ No newline at end of file diff --git a/src/main/java/com/codesdream/ase/service/AppendixFileService.java b/src/main/java/com/codesdream/ase/service/AppendixFileService.java deleted file mode 100644 index a146cd9..0000000 --- a/src/main/java/com/codesdream/ase/service/AppendixFileService.java +++ /dev/null @@ -1,36 +0,0 @@ -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 findById(int id) { - return appendixFileRespository.findById(id); - } - - @Override - public Iterable findAll() { - return appendixFileRespository.findAll(); - } -} diff --git a/src/main/java/com/codesdream/ase/service/AttendanceService.java b/src/main/java/com/codesdream/ase/service/AttendanceService.java deleted file mode 100644 index 5484358..0000000 --- a/src/main/java/com/codesdream/ase/service/AttendanceService.java +++ /dev/null @@ -1,18 +0,0 @@ -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); - } -} diff --git a/src/main/java/com/codesdream/ase/service/IActivityService.java b/src/main/java/com/codesdream/ase/service/IActivityService.java deleted file mode 100644 index 0e85465..0000000 --- a/src/main/java/com/codesdream/ase/service/IActivityService.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.codesdream.ase.service; - -import com.codesdream.ase.model.activity.Activity; -import com.codesdream.ase.model.activity.Report; -import com.codesdream.ase.model.permission.User; - -import java.util.List; -import java.util.Optional; - -public interface IActivityService { - //通过标题查找活动 - Optional findActivityByTitle(String title); - - //通过创建人姓名查找活动 - Optional findActivityByCreator(String creatorName); - - //通过活动类型查找活动 - List findActivityByType(User user, String type); - - //活动持久化 - Activity save(Activity activity); - - //添加活动报告 - Activity addReport(Activity activity, Report report); - - //活动删除 - void delete(Activity activity); - - //活动信息更新 - Activity update(Activity activity); - - //活动创建 - Activity createActivity(Activity activity); - - //查询主要负责的活动 - List findMainResponsibleActs(User user); - - //查询次要负责的活动 - List findSecondaryResponsibleActs(User user); - - //查询所有可见活动(即可报名活动、主次要负责的活动、参与过的活动等等之外却仍然可见的活动并集) - List findVisibleActs(User user); - - //查找可报名的活动 - List findSignActs(User user); - - //查询参与过的活动 - List findParticipatedActs(User user); - - //查询将要参与的活动 - List findParticipatingActs(User user); - - //查询创建的活动 - List findCreatedActs(User user); - - //查询所有活动(权限内) - List findAll(User user); - -} diff --git a/src/main/java/com/codesdream/ase/service/IAppendixFileService.java b/src/main/java/com/codesdream/ase/service/IAppendixFileService.java deleted file mode 100644 index 65e4c75..0000000 --- a/src/main/java/com/codesdream/ase/service/IAppendixFileService.java +++ /dev/null @@ -1,21 +0,0 @@ -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 findById(int id); - - //找到所有文件条目 - Iterable findAll(); - -} diff --git a/src/main/java/com/codesdream/ase/service/PeriodService.java b/src/main/java/com/codesdream/ase/service/PeriodService.java deleted file mode 100644 index 879de10..0000000 --- a/src/main/java/com/codesdream/ase/service/PeriodService.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.codesdream.ase.service; - -import com.codesdream.ase.model.activity.Period; -import com.codesdream.ase.repository.activity.PeriodRepository; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; - -@Service -public class PeriodService { - - @Resource - PeriodRepository periodRepository; - - public Period save(Period period) { - return periodRepository.save(period); - } - - public void delete(Period period) { - periodRepository.delete(period); - } -} diff --git a/src/main/java/com/codesdream/ase/service/ReportService.java b/src/main/java/com/codesdream/ase/service/ReportService.java deleted file mode 100644 index 4077aff..0000000 --- a/src/main/java/com/codesdream/ase/service/ReportService.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.codesdream.ase.service; - -import com.codesdream.ase.model.activity.Activity; -import com.codesdream.ase.model.activity.Report; -import com.codesdream.ase.repository.activity.ReportRepository; - -import javax.annotation.Resource; -import java.util.Optional; - -public class ReportService implements IReportService { - - @Resource - ReportRepository reportRepository; - ActivityService activityService; - - @Override - public Optional findByTitle(String title) { - return reportRepository.findByTitle(title); - } - - @Override - public Optional findByCreator(String creatorName) { - return reportRepository.findByCreator(creatorName); - } - - @Override - public Report save(Activity activity, Report report) { - if(activity == null){ - throw new RuntimeException("Activity does not exist."); - } - activityService.addReport(activity, report); - return reportRepository.save(report); - } - - @Override - public void delete(Report report) { - if(reportRepository.findById(report.getId()).isPresent()) reportRepository.delete(report); - else throw new RuntimeException("Report does not exist."); - } - - @Override - public Report update(Report report) { - reportRepository.save(report); - return report; - } -} diff --git a/src/test/java/com/codesdream/ase/test/AchievementServiceTest.java b/src/test/java/com/codesdream/ase/test/AchievementServiceTest.java index 381f586..adc90c1 100644 --- a/src/test/java/com/codesdream/ase/test/AchievementServiceTest.java +++ b/src/test/java/com/codesdream/ase/test/AchievementServiceTest.java @@ -2,12 +2,7 @@ package com.codesdream.ase.test; import com.codesdream.ase.model.activity.Activity; import com.codesdream.ase.model.activity.Report; -import com.codesdream.ase.model.permission.User; -import com.codesdream.ase.service.AchievementService; import com.codesdream.ase.service.ActivityService; -import com.codesdream.ase.service.UserService; -import javafx.util.Pair; -import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; diff --git a/src/test/java/com/codesdream/ase/test/FileSystemTest.java b/src/test/java/com/codesdream/ase/test/FileSystemTest.java index 01e66d6..bd9d714 100644 --- a/src/test/java/com/codesdream/ase/test/FileSystemTest.java +++ b/src/test/java/com/codesdream/ase/test/FileSystemTest.java @@ -4,14 +4,12 @@ import com.codesdream.ase.component.activity.FileSystem; import com.codesdream.ase.exception.notfound.AppendixFileNotFoundException; import com.codesdream.ase.model.activity.AppendixFile; import com.codesdream.ase.repository.activity.AppendixFileRespository; -import com.codesdream.ase.service.AppendixFileService; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import javax.annotation.Resource; -import java.io.IOException; import java.io.InputStream; import java.util.Scanner;