first deletion

This commit is contained in:
chuyan 2020-09-01 14:57:04 +08:00
parent 615c5a8f42
commit b17a11009f
33 changed files with 0 additions and 1507 deletions

View File

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

View File

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

View File

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

View File

@ -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<int>", value = "可参与人员"),
@ApiImplicitParam(name = "inform-group", dataType = "List<int>", value = "通知人群,若为空,则默认为预定参与人员和可报名人员的并集"),
@ApiImplicitParam(name = "visible-group", dataType = "List<int>", 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<JSONObject> json = jsonParameter.getJSONByRequest(request);
if (!json.isPresent()) return jsonParameter.getJSONString(new JSONStandardFailedRespond());
List<String> 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<String> nullValues = nullValueValidator.checkNullValues(activity);
for (String str : nullValues){
if(str.equals("title")){
nullValueAttributes.getNullValueAttributes().add("title");
}
else if(str.equals("creator")){
nullValueAttributes.getNullValueAttributes().add("creator");
}
else if(str.equals("type")){
nullValueAttributes.getNullValueAttributes().add("type");
}
else if(str.equals("planPeriod")){
nullValueAttributes.getNullValueAttributes().add("planPeriod");
}
else if(str.equals("chiefManager")){
nullValueAttributes.getNullValueAttributes().add("chiefManager");
}
}
//如果为空存下此活动并跳转至成功创建页面
if (!nullValueAttributes.getNullValueAttributes().isEmpty()) {
String[] errorParameters = activityValidator.check(json);
if(errorParameters != null){
JSONObject invalidParameters = new JSONObject();
invalidParameters.put("invalid_parameters", errorParameters);
return invalidParameters.toJSONString();
}
else{
activity = activityService.createActivity(activity);
String username = json.get().get("creator").toString();
Optional<User> user = userService.findUserByUsername(username);
UserActivity userActivity = userActivityRepository.findByUser(user.get());
userActivity.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();
}
}

View File

@ -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<Activity> activities = activityService.findCreatedActs(user);
return JSONObject.toJSONString(activities);
}
@GetMapping("/parting_acts")
String showParticipate(HttpServletRequest request) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
List<Activity> activities = activityService.findParticipatingActs(user);
return JSONObject.toJSONString(activities);
}
@GetMapping("/parted_acts")
String showParticipated() {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
List<Activity> activities = activityService.findParticipatedActs(user);
return JSONObject.toJSONString(activities);
}
@GetMapping("/sign_acts")
String showSign() {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
List<Activity> activities = activityService.findSignActs(user);
return JSONObject.toJSONString(activities);
}
@GetMapping("/vis_acts")
String showVisible() {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
List<Activity> activities = activityService.findVisibleActs(user);
return JSONObject.toJSONString(activities);
}
@GetMapping("/all")
String showAll() {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
List<Activity> activities = activityService.findAll(user);
return JSONObject.toJSONString(activities);
}
@GetMapping("/main_responsible_acts")
String showMainResponsible() {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
List<Activity> activities = activityService.findMainResponsibleActs(user);
return JSONObject.toJSONString(activities);
}
@GetMapping("/sec_responsible_acts")
String showSecondaryResponsible() {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
List<Activity> 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<Activity> activities = activityService.findActivityByType(user, type);
return JSONObject.toJSONString(activities);
}
}

View File

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

View File

@ -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<ExamResult> examResults = new HashSet<>();
// 个人学分积
@JoinColumn(nullable = true)
private float accumulatedGPA;
//除数为零exception待加
public AccumulatedGPA(Set<ExamResult> initExamResults) {
int totalProduct = 0, totalCredit = 0;
for(ExamResult er : initExamResults){
totalProduct += er.getCredit() * er.getScore();
totalCredit += er.getCredit();
}
this.accumulatedGPA = totalProduct / totalCredit;
}
}

View File

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

View File

@ -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<Award> awards = new HashSet<>();
}

View File

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

View File

@ -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<ExamResult> examResults = new HashSet<>();
// 个人学分积
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(nullable = true)
private AccumulatedGPA accumulatedGPA;
}

View File

@ -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<User> volunteers;
//参与人列表
@ManyToMany(cascade = CascadeType.DETACH)
@JoinTable(name = "act_participate",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "participate_id")
}
)
private Set<User> participateGroup;
//实际参与人列表
@ManyToMany(cascade = CascadeType.DETACH)
@JoinTable(name = "act_participated",
joinColumns = {
@JoinColumn(name = "act_id" )
},
inverseJoinColumns = {
@JoinColumn(name = "participated_id")
}
)
private Set<User> participatedGroup;
//可报名人员列表
@ManyToMany(cascade = CascadeType.DETACH)
@JoinTable(name = "act_sign",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "sign_id")
}
)
private Set<User> signGroup;
//已报名人员列表
@ManyToMany(cascade = CascadeType.MERGE)
@JoinTable(name = "act_signed",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "signed_id")
}
)
private Set<User> signedGroup;
//可见人员列表
@ManyToMany(cascade = CascadeType.DETACH)
@JoinTable(name = "act_vis",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "vis_id")
}
)
private Set<User> visibleGroup;
//通知人员列表
@ManyToMany(cascade = CascadeType.DETACH)
@JoinTable(name = "act_inform",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "inform_id")
}
)
private Set<User> informGroup;
//已通知人员列表
@ManyToMany(cascade = CascadeType.DETACH)
@JoinTable(name = "act_informed",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "informed_id")
}
)
private Set<User> informedGroup;
//计划开始时间
@OneToOne(cascade = CascadeType.ALL)
@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<String> enclosures;
//主要负责人
@OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
@JoinColumn(nullable = false)
private User chiefManager;
//次要负责人
@OneToMany(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
@JoinColumn(name = "act_id")
private Set<User> assistManagers;
//是否开始
@Column(name = "is_on", nullable = false)
boolean isOn;
//是否结束
@Column(name = "is_off", nullable = false)
boolean isOff;
//考勤安排
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Attendance attendance;
//活动报告
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Report report;
public Activity(){
initDefault();
}
private void initDefault(){
this.title = "";
this.creator = new User();
this.type = "";
this.description = "";
this.cycle = "";
this.volunteers = new HashSet<>();
this.participateGroup = new HashSet<>();
this.participatedGroup = new HashSet<>();
this.participatedGroup = new HashSet<>();
this.signGroup = new HashSet<>();
this.signedGroup = new HashSet<>();
this.visibleGroup = new HashSet<>();
this.informGroup = new HashSet<>();
this.informedGroup = new HashSet<>();
this.planPeriod = new Period();
this.realPeriod = new Period();
this.enclosures = new ArrayList<>();
this.chiefManager = new User();
this.assistManagers = new HashSet<>();
this.isOn = false;
this.isOff = false;
}
}

View File

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

View File

@ -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<Period> clockInPeriods;
//打卡方式0表示被扫1表示扫
@Column//(nullable = false)
private boolean means;
}

View File

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

View File

@ -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<User> volunteers;
//参与人列表
@ManyToMany(cascade = CascadeType.MERGE)
@JoinTable(name = "act_participate",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "participate_id")
}
)
private Set<User> participateGroup;
//实际参与人列表
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "act_participated",
joinColumns = {
@JoinColumn(name = "act_id" )
},
inverseJoinColumns = {
@JoinColumn(name = "participated_id")
}
)
private Set<User> participatedGroup;
//可报名人员列表
@ManyToMany(cascade = CascadeType.MERGE)
@JoinTable(name = "act_sign",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "sign_id")
}
)
private Set<User> signGroup;
//已报名人员列表
@ManyToMany(cascade = CascadeType.MERGE)
@JoinTable(name = "act_signed",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "signed_id")
}
)
private Set<User> signedGroup;
//可见人员列表
@ManyToMany(cascade = CascadeType.MERGE)
@JoinTable(name = "act_vis",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "vis_id")
}
)
private Set<User> visibleGroup;
//通知人员列表
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "act_inform",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "inform_id")
}
)
private Set<User> informGroup;
//已通知人员列表
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "act_informed",
joinColumns = {
@JoinColumn(name = "act_id")
},
inverseJoinColumns = {
@JoinColumn(name = "informed_id")
}
)
private Set<User> informedGroup;
//计划开始时间
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "plan_period")
private Period planPeriod;
//实际开始时间
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "real_period")
private Period realPeriod;
//主要负责人
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "chief_manager", nullable = false)
private User chiefManager;
//次要负责人
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "act_id")
private List<User> assistManagers;
//考勤安排
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "attendance")
private Attendance attendance;
//活动笔记
@Column(name = "notes")
private String notes;
//图表
@ElementCollection(targetClass = java.lang.String.class)
@Column(name = "charts")
private List<String> charts;
//附件url
@Column(name = "enclosure")
private String enclosure;
//活动
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "activity")
private Activity activity;
}

View File

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

View File

@ -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<Activity, Integer> {
Optional<Activity> findByTitle(String Title);
Optional<Activity> findByCreator(String creatorName);
}

View File

@ -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<AppendixFile, Integer> {
}

View File

@ -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<Attendance, Integer> {
}

View File

@ -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<Period, Integer> {
}

View File

@ -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<Report, Integer> {
Optional<Report> findByTitle(String reportTitle);
Optional<Report> findByCreator(String creatorName);
}

View File

@ -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, Integer> {
UserActivity findByUser(User user);
}

View File

@ -1,8 +0,0 @@
package com.codesdream.ase.service;
import org.springframework.stereotype.Service;
@Service
public class AchievementService {
}

View File

@ -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<Activity> findActivityByTitle(String title) {
return activityRepository.findByTitle(title);
}
@Override
public Optional<Activity> findActivityByCreator(String creatorName) {
return activityRepository.findByCreator(creatorName);
}
@Override
public List<Activity> findActivityByType(User user, String type) {
List<Activity> activities = this.findAll(user);
List<Activity> 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<Activity> findMainResponsibleActs(User user) {
UserActivity userActivity = userActivityRepository.findByUser(user);
List<Activity> acts = userActivity.getMainResponsibleActs();
Collections.sort(acts, new ActivityComparator());
return acts;
}
@Override
public List<Activity> findSecondaryResponsibleActs(User user) {
UserActivity userActivity = userActivityRepository.findByUser(user);
List<Activity> acts = userActivity.getSecondaryResponsibleActs();
Collections.sort(acts, new ActivityComparator());
return acts;
}
@Override
public List<Activity> findVisibleActs(User user) {
UserActivity userActivity = userActivityRepository.findByUser(user);
List<Activity> acts = userActivity.getVisibleActs();
Collections.sort(acts, new ActivityComparator());
return acts;
}
@Override
public List<Activity> findSignActs(User user) {
UserActivity userActivity = userActivityRepository.findByUser(user);
List<Activity> acts = userActivity.getSignUpActs();
Collections.sort(acts, new ActivityComparator());
return acts;
}
@Override
public List<Activity> findParticipatedActs(User user) {
UserActivity userActivity = userActivityRepository.findByUser(user);
List<Activity> acts = userActivity.getParticipatedActs();
Collections.sort(acts, new ActivityComparator());
return acts;
}
@Override
public List<Activity> findParticipatingActs(User user) {
UserActivity userActivity = userActivityRepository.findByUser(user);
List<Activity> acts = userActivity.getParticipatingActs();
Collections.sort(acts, new ActivityComparator());
return acts;
}
@Override
public List<Activity> findCreatedActs(User user) {
UserActivity userActivity = userActivityRepository.findByUser(user);
List<Activity> acts = userActivity.getCreatedActs();
Collections.sort(acts, new ActivityComparator());
return acts;
}
@Override
public List<Activity> findAll(User user) {
List<Activity> activities = findCreatedActs(user);
List<Activity> activities1 = findMainResponsibleActs(user);
List<Activity> activities2 = findSecondaryResponsibleActs(user);
List<Activity> activities3 = findParticipatingActs(user);
List<Activity> activities4 = findParticipatedActs(user);
List<Activity> activities5 = findParticipatingActs(user);
List<Activity> activities6 = findSignActs(user);
List<Activity> activities7 = findVisibleActs(user);
Set<Activity> 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<Activity> res = new ArrayList<>(activitySet);
Collections.sort(res, new ActivityComparator());
return res;
}
}
class ActivityComparator implements Comparator<Activity> {
@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;
}
}

View File

@ -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<AppendixFile> findById(int id) {
return appendixFileRespository.findById(id);
}
@Override
public Iterable<AppendixFile> findAll() {
return appendixFileRespository.findAll();
}
}

View File

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

View File

@ -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<Activity> findActivityByTitle(String title);
//通过创建人姓名查找活动
Optional<Activity> findActivityByCreator(String creatorName);
//通过活动类型查找活动
List<Activity> 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<Activity> findMainResponsibleActs(User user);
//查询次要负责的活动
List<Activity> findSecondaryResponsibleActs(User user);
//查询所有可见活动即可报名活动主次要负责的活动参与过的活动等等之外却仍然可见的活动并集
List<Activity> findVisibleActs(User user);
//查找可报名的活动
List<Activity> findSignActs(User user);
//查询参与过的活动
List<Activity> findParticipatedActs(User user);
//查询将要参与的活动
List<Activity> findParticipatingActs(User user);
//查询创建的活动
List<Activity> findCreatedActs(User user);
//查询所有活动权限内
List<Activity> findAll(User user);
}

View File

@ -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<AppendixFile> findById(int id);
//找到所有文件条目
Iterable<AppendixFile> findAll();
}

View File

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

View File

@ -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<Report> findByTitle(String title) {
return reportRepository.findByTitle(title);
}
@Override
public Optional<Report> 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;
}
}

View File

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

View File

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