This commit is contained in:
yourtree 2020-04-05 21:46:51 +08:00
commit 62f52e0709
16 changed files with 567 additions and 59 deletions

View File

@ -1,9 +1,7 @@
package com.codesdream.ase.component.api; package com.codesdream.ase.component.api;
import com.codesdream.ase.component.datamanager.JSONParameter; import com.codesdream.ase.component.datamanager.JSONParameter;
import com.codesdream.ase.component.json.respond.EmptyDataObjectRespond;
import com.codesdream.ase.component.json.respond.JSONBaseRespondObject; import com.codesdream.ase.component.json.respond.JSONBaseRespondObject;
import com.sun.deploy.net.HttpResponse;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;

View File

@ -0,0 +1,30 @@
package com.codesdream.ase.component.json.model;
import com.codesdream.ase.model.permission.FunctionalPermissionContainer;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.NoArgsConstructor;
import springfox.documentation.spring.web.json.Json;
@Data
@NoArgsConstructor
@ApiModel("功能性权限容器")
public class JsonableFPC {
private Integer id;
private String name;
private String description;
private boolean enabled;
private boolean deleted;
public JsonableFPC(FunctionalPermissionContainer fpc){
this.id = fpc.getId();
this.name = fpc.getName();
this.description = fpc.getDescription();
this.enabled = fpc.isEnabled();
this.deleted = fpc.isDeleted();
}
}

View File

@ -0,0 +1,24 @@
package com.codesdream.ase.component.json.model;
import com.codesdream.ase.model.permission.FunctionalPermissionContainer;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.HashSet;
import java.util.Set;
@Data
@NoArgsConstructor
@ApiModel("功能性权限容器所属角色集合")
public class JsonableRoleList {
private Integer id;
private Set<String> roles = new HashSet<>();
public JsonableRoleList(FunctionalPermissionContainer fpc){
this.id = fpc.getId();
if(fpc.getRoles() != null) {
this.roles.addAll(fpc.getRoles());
}
}
}

View File

@ -0,0 +1,30 @@
package com.codesdream.ase.component.json.model;
import com.codesdream.ase.model.permission.ScopePermissionContainer;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@ApiModel("范围性权限容器")
public class JsonableSPC {
private Integer id;
private String name;
private String description;
private boolean enabled;
private boolean deleted;
public JsonableSPC(ScopePermissionContainer spc){
this.id = spc.getId();
this.name = spc.getName();
this.description = spc.getDescription();
this.enabled = spc.isEnabled();
this.deleted = spc.isDeleted();
}
}

View File

@ -0,0 +1,77 @@
package com.codesdream.ase.controller.permission;
import com.codesdream.ase.component.json.model.JsonableFPC;
import com.codesdream.ase.component.json.model.JsonableRoleList;
import com.codesdream.ase.exception.badrequest.AlreadyExistException;
import com.codesdream.ase.exception.notfound.NotFoundException;
import com.codesdream.ase.model.permission.FunctionalPermissionContainer;
import com.codesdream.ase.service.PermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
@RestController
@RequestMapping(value = "pmt")
@Api(tags = "功能性权限容器接口")
public class FPCController {
@Resource
private PermissionService permissionService;
@GetMapping("fpc")
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "查找功能性权限容器")
public JsonableFPC getFPC(@RequestParam(value = "id") Integer id){
Optional<FunctionalPermissionContainer> fpc = permissionService.findFPC(id);
if(!fpc.isPresent()) throw new NotFoundException(id.toString());
return new JsonableFPC(fpc.get());
}
@PostMapping("fpc")
@ResponseStatus(HttpStatus.CREATED)
@ApiOperation(value = "创建新的功能性权限容器")
public JsonableFPC createFPC(@RequestBody JsonableFPC fpc){
if(permissionService.findFPC(fpc.getName()).isPresent()) throw new AlreadyExistException(fpc.getName());
FunctionalPermissionContainer functionalPermissionContainer = new FunctionalPermissionContainer();
functionalPermissionContainer.setName(fpc.getName());
functionalPermissionContainer.setDescription(fpc.getDescription());
functionalPermissionContainer.setEnabled(fpc.isEnabled());
functionalPermissionContainer.setDeleted(fpc.isDeleted());
return new JsonableFPC(permissionService.save(functionalPermissionContainer));
}
@GetMapping("fpcs")
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "获得所有功能性权限容器的信息")
public Set<JsonableFPC> listFPC(){
Iterable<FunctionalPermissionContainer> fpcs = permissionService.findAllFPC();
Set<JsonableFPC> jsonableFPCS = new HashSet<>();
for(FunctionalPermissionContainer fpc : fpcs){
jsonableFPCS.add(new JsonableFPC(fpc));
}
return jsonableFPCS;
}
@GetMapping("fpc/role")
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "获得功能性权限容器所属角色")
public JsonableRoleList getFPCRoleList(@RequestParam(value = "id") Integer id){
Optional<FunctionalPermissionContainer> functionalPermissionContainer =
permissionService.findFPC(id);
if(!functionalPermissionContainer.isPresent()) throw new NotFoundException(id.toString());
return new JsonableRoleList(functionalPermissionContainer.get());
}
}

View File

@ -0,0 +1,79 @@
package com.codesdream.ase.controller.permission;
import com.codesdream.ase.component.json.model.JsonableSPC;
import com.codesdream.ase.component.json.model.JsonableTag;
import com.codesdream.ase.exception.badrequest.AlreadyExistException;
import com.codesdream.ase.exception.notfound.NotFoundException;
import com.codesdream.ase.model.permission.ScopePermissionContainer;
import com.codesdream.ase.model.permission.Tag;
import com.codesdream.ase.service.PermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
@RestController
@RequestMapping(value = "pmt")
@Api(tags = "范围性权限容器接口")
public class SPCController {
@Resource
private PermissionService permissionService;
@GetMapping(value = "spc")
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "获得范围性权限容器信息")
public JsonableSPC getSPC(@RequestParam(value = "id") Integer id){
Optional<ScopePermissionContainer> spc = permissionService.findSPC(id);
if(!spc.isPresent()) throw new NotFoundException(id.toString());
return new JsonableSPC(spc.get());
}
@GetMapping(value = "spcs")
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "获得所有的范围性权限容器信息")
public Set<JsonableSPC> listSPC(){
Iterable<ScopePermissionContainer> spcs = permissionService.findALLSPC();
Set<JsonableSPC> jsonableSPCS = new HashSet<>();
for(ScopePermissionContainer spc : spcs){
jsonableSPCS.add(new JsonableSPC(spc));
}
return jsonableSPCS;
}
@GetMapping(value = "spc/tag")
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "查询范围性权限容器下的所有标签集合")
public Set<JsonableTag> listSPCTag(@RequestParam(value = "id") Integer id){
Optional<ScopePermissionContainer> spc = permissionService.findSPC(id);
if(!spc.isPresent()) throw new NotFoundException(id.toString());
Set<JsonableTag> tags = new HashSet<>();
for(Tag tag : spc.get().getTags()){
tags.add(new JsonableTag(tag));
}
return tags;
}
@PostMapping(value = "spc")
@ResponseStatus(HttpStatus.CREATED)
@ApiOperation(value = "创建范围性权限容器")
public JsonableSPC createSPC(@RequestBody JsonableSPC spc) {
if(permissionService.findSPC(spc.getName()).isPresent()) throw new AlreadyExistException(spc.getName());
ScopePermissionContainer defaultSPC = permissionService.getDefaultSPC(spc.getName());
defaultSPC.setDeleted(spc.isDeleted());
defaultSPC.setEnabled(spc.isEnabled());
defaultSPC.setDescription(spc.getDescription());
return new JsonableSPC(permissionService.save(defaultSPC));
}
}

View File

@ -1,4 +1,4 @@
package com.codesdream.ase.controller; package com.codesdream.ase.controller.permission;
import com.codesdream.ase.component.datamanager.JsonPathParameter; import com.codesdream.ase.component.datamanager.JsonPathParameter;
import com.codesdream.ase.component.json.model.JsonablePCCList; import com.codesdream.ase.component.json.model.JsonablePCCList;
@ -14,18 +14,17 @@ import com.codesdream.ase.model.permission.User;
import com.codesdream.ase.service.IUserService; import com.codesdream.ase.service.IUserService;
import com.codesdream.ase.service.PermissionService; import com.codesdream.ase.service.PermissionService;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.fge.jsonpatch.JsonPatch; import com.github.fge.jsonpatch.JsonPatch;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T; import io.swagger.models.auth.In;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.spring.web.json.Json; import springfox.documentation.spring.web.json.Json;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.jws.soap.SOAPBinding;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -33,8 +32,8 @@ import java.util.Set;
@RestController @RestController
@RequestMapping("pmt") @RequestMapping("pmt")
@Api(tags = "权限管理接口") @Api(tags = "标签管理接口")
public class PermissionController { public class TagController {
@Resource @Resource
private PermissionService permissionService; private PermissionService permissionService;
@ -64,20 +63,18 @@ public class PermissionController {
@GetMapping("tag") @GetMapping("tag")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
@ApiOperation("搜索标签信息") @ApiOperation("搜索标签信息")
@ApiImplicitParam(name = "name", value = "标签名") public JsonableTag checkTag(@RequestParam(value = "id") Integer id){
public JsonableTag checkTag(@RequestParam(value = "name") String name){ Optional<Tag> tagOptional = permissionService.findTag(id);
Optional<Tag> tagOptional = permissionService.findTag(name);
if(tagOptional.isPresent()){ if(tagOptional.isPresent()){
return new JsonableTag(tagOptional.get()); return new JsonableTag(tagOptional.get());
} }
else throw new NotFoundException(name); else throw new NotFoundException(id.toString());
} }
// 根据名字搜索标签的简要信息 // 根据名字搜索标签的简要信息
@GetMapping("tags") @GetMapping("tags")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
@ApiOperation("列出所有的标签信息") @ApiOperation("列出所有的标签信息")
@ApiImplicitParam(name = "name", value = "标签名")
public Set<JsonableTag> listTag(){ public Set<JsonableTag> listTag(){
Iterable<Tag> tagIterable = permissionService.findAllTag(); Iterable<Tag> tagIterable = permissionService.findAllTag();
Set<JsonableTag> jsonableTagSet = new HashSet<>(); Set<JsonableTag> jsonableTagSet = new HashSet<>();
@ -91,10 +88,9 @@ public class PermissionController {
@DeleteMapping("tag") @DeleteMapping("tag")
@ResponseStatus(HttpStatus.NO_CONTENT) @ResponseStatus(HttpStatus.NO_CONTENT)
@ApiOperation("删除标签") @ApiOperation("删除标签")
@ApiImplicitParam(name = "name", value = "标签名") public void deleteTag(@RequestParam(value = "id") Integer id){
public void deleteTag(@RequestParam(value = "name") String name){ Optional<Tag> tag = permissionService.findTag(id);
Optional<Tag> tag = permissionService.findTag(name); if(!tag.isPresent()) throw new NotFoundException(id.toString());
if(!tag.isPresent()) throw new NotFoundException(name);
// 检查外键关联 // 检查外键关联
if(tag.get().getUsers().size() > 0) throw new RelatedObjectsExistException(); if(tag.get().getUsers().size() > 0) throw new RelatedObjectsExistException();
@ -104,13 +100,12 @@ public class PermissionController {
} }
// 根据名字搜索标签的简要信息 // 根据名字搜索标签的简要信息
@PatchMapping(path = "tag", consumes = "application/json-patch+json") @PatchMapping(path = "tag")
@ResponseStatus(HttpStatus.CREATED) @ResponseStatus(HttpStatus.CREATED)
@ApiOperation("修改标签属性") @ApiOperation("修改标签属性")
@ApiImplicitParam(name = "name", value = "标签名") public JsonableTag updateTag(@RequestParam(value = "id") Integer id, @RequestBody JsonPatch patch){
public JsonableTag updateTag(@RequestParam(value = "name") String name, @RequestBody JsonPatch patch){ Optional<Tag> tag = permissionService.findTag(id);
Optional<Tag> tag = permissionService.findTag(name); if(!tag.isPresent()) throw new NotFoundException(id.toString());
if(!tag.isPresent()) throw new NotFoundException(name);
JsonableTag jsonableTag = new JsonableTag(tag.get()); JsonableTag jsonableTag = new JsonableTag(tag.get());
jsonableTag = pathParameter.parsePathToObject(patch, jsonableTag); jsonableTag = pathParameter.parsePathToObject(patch, jsonableTag);
@ -122,34 +117,42 @@ public class PermissionController {
} }
@GetMapping("tag/users") @GetMapping("tag/users")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
@ApiOperation("搜索单个标签所属用户集合信息") @ApiOperation("搜索单个标签所属用户集合信息")
public JsonableUserList getUserTag(@RequestParam(value = "name") String name){ public Set<JsonableUser> getUserTag(@RequestParam(value = "id") Integer id){
Optional<Tag> tag = permissionService.findTag(name); Optional<Tag> tag = permissionService.findTag(id);
if(!tag.isPresent()) throw new NotFoundException(name); if(!tag.isPresent()) throw new NotFoundException(id.toString());
return new JsonableUserList(tag.get()); Set<JsonableUser> jsonableUsers = new HashSet<>();
for(User user : tag.get().getUsers()){
jsonableUsers.add(new JsonableUser(user));
}
return jsonableUsers;
} }
@PutMapping("tag/users") @PutMapping("tag/users")
@ApiOperation("更新索单个标签所属用户集合信息") @ApiOperation("更新索单个标签所属用户集合信息")
public JsonableUserList setUserTag(@RequestParam String name, @RequestBody JsonableUserList userList){ public Set<JsonableUser> setUserTag(@RequestParam(value = "id") Integer id,
Optional<Tag> tag = permissionService.findTag(name); @RequestBody JsonableUserList userList){
if(!tag.isPresent()) throw new NotFoundException(name); Optional<Tag> tag = permissionService.findTag(id);
if(!tag.isPresent()) throw new NotFoundException(id.toString());
Set<Integer> userSet = new HashSet<>(userList.getUsers()); Set<Integer> userSet = new HashSet<>(userList.getUsers());
tag.get().setUsers(userService.findUsersById(userSet)); tag.get().setUsers(userService.findUsersById(userSet));
return new JsonableUserList(permissionService.save(tag.get())); Set<JsonableUser> jsonableUsers = new HashSet<>();
for(User user : tag.get().getUsers()){
jsonableUsers.add(new JsonableUser(user));
}
return jsonableUsers;
} }
@PostMapping("tag/users") @PostMapping("tag/users")
@ApiOperation("更新单个标签所属用户集合中添加一个或多个用户") @ApiOperation("更新单个标签所属用户集合中添加一个或多个用户")
public JsonableUserList addUserTag(@RequestParam String name, @RequestBody JsonableUserList userList){ public Set<JsonableUser> addUserTag(@RequestParam(value = "id") Integer id,
Optional<Tag> tag = permissionService.findTag(name); @RequestBody JsonableUserList userList){
if(!tag.isPresent()) throw new NotFoundException(name); Optional<Tag> tag = permissionService.findTag(id);
if(!tag.isPresent()) throw new NotFoundException(id.toString());
Set<User> newUserSet = userService.findUsersById(new HashSet<>(userList.getUsers())); Set<User> newUserSet = userService.findUsersById(new HashSet<>(userList.getUsers()));
Set<User> userSet = tag.get().getUsers(); Set<User> userSet = tag.get().getUsers();
@ -157,30 +160,38 @@ public class PermissionController {
userSet.addAll(newUserSet); userSet.addAll(newUserSet);
tag.get().setUsers(userSet); tag.get().setUsers(userSet);
return new JsonableUserList(permissionService.save(tag.get())); Set<JsonableUser> jsonableUsers = new HashSet<>();
for(User user : tag.get().getUsers()){
jsonableUsers.add(new JsonableUser(user));
}
return jsonableUsers;
} }
@DeleteMapping("tag/users") @DeleteMapping("tag/users")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
@ApiOperation("从单个标签所属用户集合中删除一个或多个用户") @ApiOperation("从单个标签所属用户集合中删除一个或多个用户")
@ApiImplicitParam(name = "name", value = "标签名") public Set<JsonableUser> deleteUserTag(@RequestParam Integer id,
public JsonableUserList deleteUserTag(@RequestParam String name, @RequestBody JsonableUserList userList){ @RequestBody JsonableUserList userList){
Optional<Tag> tag = permissionService.findTag(name); Optional<Tag> tag = permissionService.findTag(id);
if(!tag.isPresent()) throw new NotFoundException(name); if(!tag.isPresent()) throw new NotFoundException(id.toString());
Set<User> userSet = tag.get().getUsers(); Set<User> userSet = tag.get().getUsers();
Set<User> deleteUserSet = userService.findUsersById(new HashSet<>(userList.getUsers())); Set<User> deleteUserSet = userService.findUsersById(new HashSet<>(userList.getUsers()));
userSet.removeAll(deleteUserSet); userSet.removeAll(deleteUserSet);
tag.get().setUsers(userSet); tag.get().setUsers(userSet);
return new JsonableUserList(permissionService.save(tag.get())); Set<JsonableUser> jsonableUsers = new HashSet<>();
for(User user : tag.get().getUsers()){
jsonableUsers.add(new JsonableUser(user));
}
return jsonableUsers;
} }
@GetMapping("tags/users") @GetMapping("tags/users")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
@ApiOperation("搜索多个标签所属用户集合信息") @ApiOperation("搜索多个标签所属用户集合信息")
public Set<JsonableUser> getUserTags(@RequestParam(value = "name") List<String> names){ public Set<JsonableUser> getUserTags(@RequestParam(value = "id") List<Integer> ids){
Set<Tag> tagSet = permissionService.findTags(names); Set<Tag> tagSet = permissionService.findTags(ids);
Set<User> userSet = new HashSet<>(); Set<User> userSet = new HashSet<>();
Set<JsonableUser> jsonableUsers = new HashSet<>(); Set<JsonableUser> jsonableUsers = new HashSet<>();
for(Tag tag : tagSet){ for(Tag tag : tagSet){
@ -195,9 +206,9 @@ public class PermissionController {
@GetMapping("tag/pcc") @GetMapping("tag/pcc")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
@ApiOperation("获取标签所含权限容器集合列表") @ApiOperation("获取标签所含权限容器集合列表")
public JsonablePCCList getPCCTag(@RequestParam(value = "name") String name){ public JsonablePCCList getPCCTag(@RequestParam(value = "id") Integer id){
Optional<Tag> tagOptional = permissionService.findTag(name); Optional<Tag> tagOptional = permissionService.findTag(id);
if(!tagOptional.isPresent()) throw new NotFoundException(name); if(!tagOptional.isPresent()) throw new NotFoundException(id.toString());
return new JsonablePCCList(tagOptional.get()); return new JsonablePCCList(tagOptional.get());
} }
@ -205,9 +216,9 @@ public class PermissionController {
@PostMapping("tag/pcc") @PostMapping("tag/pcc")
@ResponseStatus(HttpStatus.CREATED) @ResponseStatus(HttpStatus.CREATED)
@ApiOperation("在指定标签的权限列表中添加一个或多个权限容器") @ApiOperation("在指定标签的权限列表中添加一个或多个权限容器")
public JsonablePCCList addPCCTag(@RequestParam(value = "name") String name, JsonablePCCList jsonablePCCList){ public JsonablePCCList addPCCTag(@RequestParam(value = "id") Integer id, JsonablePCCList jsonablePCCList){
Optional<Tag> tagOptional = permissionService.findTag(name); Optional<Tag> tagOptional = permissionService.findTag(id);
if(!tagOptional.isPresent()) throw new NotFoundException(name); if(!tagOptional.isPresent()) throw new NotFoundException(id.toString());
Set<PermissionContainersCollection> pccs = tagOptional.get().getPermissionContainersCollections(); Set<PermissionContainersCollection> pccs = tagOptional.get().getPermissionContainersCollections();
pccs.addAll(permissionService.findPCCs(new HashSet<Integer>(jsonablePCCList.getPccIdList()))); pccs.addAll(permissionService.findPCCs(new HashSet<Integer>(jsonablePCCList.getPccIdList())));

View File

@ -0,0 +1,42 @@
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

@ -0,0 +1,34 @@
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

@ -0,0 +1,44 @@
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

@ -0,0 +1,43 @@
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

@ -0,0 +1,33 @@
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

@ -0,0 +1,23 @@
package com.codesdream.ase.service;
import com.codesdream.ase.component.auth.ASEPasswordEncoder;
import com.codesdream.ase.component.auth.ASEUsernameEncoder;
import com.codesdream.ase.component.permission.UserRolesListGenerator;
import com.codesdream.ase.exception.badrequest.UserInformationIllegalException;
import com.codesdream.ase.exception.notfound.UserNotFoundException;
import com.codesdream.ase.exception.badrequest.UsernameAlreadyExistException;
import com.codesdream.ase.model.information.BaseStudentInfo;
import com.codesdream.ase.model.permission.User;
import com.codesdream.ase.repository.permission.UserRepository;
import javafx.util.Pair;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
@Service
public class AchievementService {
}

View File

@ -3,10 +3,7 @@ package com.codesdream.ase.service;
import com.codesdream.ase.model.permission.*; import com.codesdream.ase.model.permission.*;
import javafx.util.Pair; import javafx.util.Pair;
import java.util.Collection; import java.util.*;
import java.util.List;
import java.util.Optional;
import java.util.Set;
public interface IPermissionService { public interface IPermissionService {
@ -27,17 +24,21 @@ public interface IPermissionService {
// 列出所有的标签 // 列出所有的标签
Iterable<Tag> findAllTag(); Iterable<Tag> findAllTag();
Set<Tag> findTags(List<String> names); Set<Tag> findTags(List<Integer> ids);
// 查找功能性权限容器 // 查找功能性权限容器
Optional<FunctionalPermissionContainer> findFPC(String name); Optional<FunctionalPermissionContainer> findFPC(String name);
Iterable<FunctionalPermissionContainer> findAllFPC();
// 查找范围性权限容器 // 查找范围性权限容器
Optional<ScopePermissionContainer> findSPC(String name); Optional<ScopePermissionContainer> findSPC(String name);
// 根据id查找功能性权限容器 // 根据id查找功能性权限容器
Optional<FunctionalPermissionContainer> findFPC(int id); Optional<FunctionalPermissionContainer> findFPC(int id);
Iterable<ScopePermissionContainer> findALLSPC();
// 根据id查找范围性权限容器 // 根据id查找范围性权限容器
Optional<ScopePermissionContainer> findSPC(int id); Optional<ScopePermissionContainer> findSPC(int id);

View File

@ -9,7 +9,6 @@ import com.codesdream.ase.repository.permission.PermissionContainersCollectionRe
import com.codesdream.ase.repository.permission.ScopePermissionContainerRepository; import com.codesdream.ase.repository.permission.ScopePermissionContainerRepository;
import com.codesdream.ase.repository.permission.TagRepository; import com.codesdream.ase.repository.permission.TagRepository;
import javafx.util.Pair; import javafx.util.Pair;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -75,11 +74,11 @@ public class PermissionService implements IPermissionService {
} }
@Override @Override
public Set<Tag> findTags(List<String> names) { public Set<Tag> findTags(List<Integer> ids) {
Set<Tag> tagSet = new HashSet<>(); Set<Tag> tagSet = new HashSet<>();
for(String name : names){ for(Integer id : ids){
Optional<Tag> tag = findTag(name); Optional<Tag> tag = findTag(id);
if(!tag.isPresent()) throw new NotFoundException(name); if(!tag.isPresent()) throw new NotFoundException(id.toString());
tagSet.add(tag.get()); tagSet.add(tag.get());
} }
return tagSet; return tagSet;
@ -90,6 +89,10 @@ public class PermissionService implements IPermissionService {
return fpcRepository.findByName(name); return fpcRepository.findByName(name);
} }
public Iterable<FunctionalPermissionContainer> findAllFPC() {
return fpcRepository.findAll();
}
@Override @Override
public Optional<ScopePermissionContainer> findSPC(String name) { public Optional<ScopePermissionContainer> findSPC(String name) {
return spcRepository.findByName(name); return spcRepository.findByName(name);
@ -100,6 +103,11 @@ public class PermissionService implements IPermissionService {
return fpcRepository.findById(id); return fpcRepository.findById(id);
} }
@Override
public Iterable<ScopePermissionContainer> findALLSPC() {
return spcRepository.findAll();
}
@Override @Override
public Optional<ScopePermissionContainer> findSPC(int id) { public Optional<ScopePermissionContainer> findSPC(int id) {
return spcRepository.findById(id); return spcRepository.findById(id);

View File

@ -0,0 +1,31 @@
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;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
/**
* 成绩管理子系统单元测试
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles("test")
public class AchievementServiceTest {
@Resource
private AchievementService achievementService;
}