Skip to content

Commit

Permalink
all done,毕设定稿
Browse files Browse the repository at this point in the history
  • Loading branch information
“mokeeqian committed Jun 8, 2021
1 parent 761cfb5 commit e8a1f9d
Show file tree
Hide file tree
Showing 27 changed files with 981 additions and 193 deletions.
142 changes: 142 additions & 0 deletions src/main/java/cn/edu/ahut/copydetector/check_class.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
@startuml
'https://plantuml.com/class-diagram


interface TeacherService
interface InformService
interface FileService
interface CheckService

interface InformDao
interface FileDao

class TeacherServiceImpl
class InformServiceImpl
class FileServiceImpl
class CheckServiceImpl

'class TeacherController

TeacherService <|. TeacherServiceImpl
InformService <|. InformServiceImpl
FileService <|. FileServiceImpl
'TeacherService <.. TeacherController
InformDao <.. InformServiceImpl
InformService <.. TeacherServiceImpl
FileService <.. TeacherServiceImpl
FileDao <.. FileServiceImpl
'FileService <. TeacherController
CheckService <|..CheckServiceImpl
CheckService <. TeacherServiceImpl
FileService <... CheckServiceImpl

interface TeacherService {
loadUserByUsername(String) : UserDetails
updateUser(User) : Integer
selectUserById(Integer) : User
updatePassword(User) : Integer
selectUserByRealname(String) : User
teachCourseById(String)) : Integer
pushInform(Map<String, Object>) : Integer
checkSubmition(Map<String, Object>) : Map<String, Object>
askForSubmition(Map<String, Object>) : Map<String, Object>
checkDuplication(Map<String, Object>) : Map<String, Object>
}

class TeacherServiceImpl {
TeacherDao : TeacherDao
informService : InformService
courseService : CourseService
fileService : FileService
checkService : CheckService

loadUserByUsername(String) : UserDetails
updateUser(User) : Integer
selectUserById(Integer) : User
updatePassword(User) : Integer
selectUserByRealname(String) : User
teachCourseById(String)) : Integer
pushInform(Map<String, Object>) : Integer
checkSubmition(Map<String, Object>) : Map<String, Object>
askForSubmition(Map<String, Object>) : Map<String, Object>
checkDuplication(Map<String, Object>) : Map<String, Object>
}

interface InformService {
pushInform(Inform) : Integer
delInform(String) : Integer
getInformByTeacher(String) : List<Inform>
getInformByCourse(String) : List<Inform>
}
class InformServiceImpl {
informDao : InformDao
pushInform(Inform) : Integer
delInform(String) : Integer
getInformByTeacher(String) : List<Inform>
getInformByCourse(String) : List<Inform>
}
interface InformDao {
pushInform(Inform) : Integer
delInform(String) : Integer
getInformByTeacher(String) : List<Inform>
getInformByCourse(String) : List<Inform>
}
'class TeacherController {
' TeacherService : TeacherService
'
' updateUser(User) : Integer
' selectUserById(Integer) : User
' updatePassword(User) : Integer
' selectUserByRealname(String) : User
' teachCourseById(String)) : Integer
' pushInform(Map<String, Object>) : Integer
' checkSubmition(Map<String, Object>) : Map<String, Object>
' askForSubmition(Map<String, Object>) : Map<String, Object>
' checkDuplication(Map<String, Object>) : Map<String, Object>
'}

interface FileDao {
getAllFiles() : List<File>
getFileById(String) : File
getFileByName(String) : File
getFileByPath(String) : File
getFilesBySubmitter(String) : List<File>
saveOne(File) : Integer
updateOneById(String) : Integer
deleteOneById(String) : Integer
}
interface FileService {
getAllFiles() : List<File>
getFileById(String) : File
getFileByName(String) : File
getFileByPath(String) : File
getFilesBySubmitter(String) : List<File>
upload(File) : Integer
upload(List<File>) : Integer
updateOneById(String) : Integer
deleteOneById(String) : Integer
}
class FileServiceImpl {
fileDao : FileDao

getAllFiles() : List<File>
getFileById(String) : File
getFileByName(String) : File
getFileByPath(String) : File
getFilesBySubmitter(String) : List<File>
upload(File) : Integer
upload(List<File>) : Integer
updateOneById(String) : Integer
deleteOneById(String) : Integer
}

interface CheckService {
check(List<String>, String) : String
}
class CheckServiceImpl {
fileService : FileService
check(List<String>, String) : String
}


@enduml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,22 @@
import cn.edu.ahut.copydetector.service.InformService;
import cn.edu.ahut.copydetector.service.UserService;
import cn.edu.ahut.copydetector.util.ExcelUtil;
import cn.edu.ahut.copydetector.util.PageBean;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.data.web.SpringDataWebProperties;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.security.PrivateKey;
import java.util.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import cn.edu.ahut.copydetector.constant.BasicConstant;
import cn.edu.ahut.copydetector.constant.OtherConstant;
import cn.edu.ahut.copydetector.entity.LayuiDtree;
import cn.edu.ahut.copydetector.entity.PageBean;
import cn.edu.ahut.copydetector.util.LayuiDtree;
import cn.edu.ahut.copydetector.util.PageBean;
import cn.edu.ahut.copydetector.entity.User;
import cn.edu.ahut.copydetector.service.FileService;
import cn.edu.ahut.copydetector.util.Doc2PdfUtil;
Expand All @@ -29,7 +29,6 @@

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
import java.io.*;
import java.net.ConnectException;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
import cn.edu.ahut.copydetector.service.InformService;
import cn.edu.ahut.copydetector.service.SimResultService;
import cn.edu.ahut.copydetector.service.UserService;
import cn.edu.ahut.copydetector.util.PageBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.ws.rs.GET;
import java.util.*;

/**
Expand Down Expand Up @@ -260,6 +260,7 @@ public Map showInforms(@RequestParam(value = "type", required = false) int type
if (realname != null) {
User teacher = (User) userService.selectUserByRealname(realname.trim()).get("user");
if (teacher == null) {
log.error("====当前user为空");
pageBean.getList().clear();
pageBean.setTotalRecord(0);
} else {
Expand All @@ -282,6 +283,39 @@ public Map showInforms(@RequestParam(value = "type", required = false) int type
return informMap;
}


@RequestMapping(value = "/recentInform", method = RequestMethod.GET)
@ResponseBody
public Map recentInform(
@RequestParam(value = "realname") String realname,
@RequestParam(value = "limit") int limit
) {
Map<String, Object> json = new HashMap<>();
User teacher = (User) userService.selectUserByRealname(realname.trim()).get("user");
PageBean<Inform> pageBean = informService.selectInforms(teacher.getUsername(), 1, limit);
if (teacher == null) {
log.error("====当前user为空");
pageBean.getList().clear();
pageBean.setTotalRecord(0);
} else {
List<Inform> informs = pageBean.getList();
Iterator<Inform> iterator = informs.iterator();
while (iterator.hasNext()) {
Inform current = iterator.next();
if (!current.getPublisher().equals(teacher.getUsername())) {
iterator.remove();
}
}
pageBean.setList(informs);
pageBean.setTotalRecord(informs.size());
}
json.put("data", pageBean.getList());
json.put("code", 0);
json.put("msg", "");
json.put("count", pageBean.getTotalRecord());
return json;
}

/**
* 修改密码
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
import cn.edu.ahut.copydetector.constant.DatabaseConstant;
import cn.edu.ahut.copydetector.constant.OtherConstant;
import cn.edu.ahut.copydetector.entity.*;
import cn.edu.ahut.copydetector.service.FileService;
import cn.edu.ahut.copydetector.service.InformService;
import cn.edu.ahut.copydetector.service.SimResultService;
import cn.edu.ahut.copydetector.service.UserService;
import cn.edu.ahut.copydetector.service.*;
import cn.edu.ahut.copydetector.util.ExcelUtil;
import cn.edu.ahut.copydetector.util.PageBean;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -49,13 +47,16 @@ public class TeacherController {
private UserService userService;
private InformService informService;
private SimResultService simResultService;
private CourseService courseService;

public TeacherController(FileService fileService, UserService userService,
InformService informService, SimResultService simResultService) {
InformService informService, SimResultService simResultService,
CourseService courseService) {
this.fileService = fileService;
this.userService = userService;
this.informService = informService;
this.simResultService = simResultService;
this.courseService = courseService;
}

/**
Expand Down Expand Up @@ -218,6 +219,7 @@ public String courses(Model model) {
return "redirect:logout";
} else {
user = (User) a;
log.info("当前用户: "+ user.toString());
model.addAttribute("current", user);
return "teacher/courses";
}
Expand Down Expand Up @@ -539,7 +541,8 @@ public Map renameFile(@RequestParam String name, @RequestParam String path) {
public Map recentWorks(@RequestParam int page, @RequestParam int limit) {
Map<String, Object> json = new HashMap<>();
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
PageBean<File> pageBean = fileService.selectRecent(user.getId(), page, limit, "update_time");
// PageBean<File> pageBean = fileService.selectRecent(user.getId(), page, limit, "update_time");
PageBean<File> pageBean = fileService.selectRecent(1, page, limit, "update_time");
List<File> list = pageBean.getList();
Iterator<File> iterator = list.iterator();
while (iterator.hasNext()){
Expand All @@ -552,7 +555,7 @@ public Map recentWorks(@RequestParam int page, @RequestParam int limit) {
json.put("code", 0);
json.put("msg", "");
json.put("count", pageBean.getTotalRecord());
log.info(json.toString());
log.info("最近未批改: "+json.toString());
return json;
}

Expand Down Expand Up @@ -582,11 +585,13 @@ public Map recentInform(@RequestParam int limit) {
public Map recentSubmit(@RequestParam int limit) {
Map<String, Object> json = new HashMap<>();
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
PageBean<File> pageBean = fileService.selectRecent(user.getId(), 1, limit, "id");
// PageBean<File> pageBean = fileService.selectRecent(user.getId(), 1, limit, "id");
PageBean<File> pageBean = fileService.selectRecent(1, 1, limit, "id");
json.put("data", pageBean.getList());
json.put("code", 0);
json.put("msg", "");
json.put("count", pageBean.getTotalRecord());
log.info("最近提交: " + json.toString());
return json;
}

Expand Down Expand Up @@ -691,5 +696,21 @@ public Map recentSubmits() {
public void showOffice() {
}

@RequestMapping(value = "/getMyCourses", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> getMyCourses(HttpServletRequest request) {
Map<String, Object> res = new HashMap<>();
User user = (User) request.getSession().getAttribute("user");
List<Course> courseList = courseService.getCoursesByTno(user.getUsername());
// log.info(courseList.toString());
res.put("code", 0);
res.put("msg", "");
res.put("data", courseList);
res.put("count", courseList.size());
return res;
}



}

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package cn.edu.ahut.copydetector.dao;

import cn.edu.ahut.copydetector.entity.PageBean;
import cn.edu.ahut.copydetector.entity.SimResult;
import org.apache.ibatis.annotations.Mapper;

Expand Down
1 change: 1 addition & 0 deletions src/main/java/cn/edu/ahut/copydetector/entity/File.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package cn.edu.ahut.copydetector.entity;

import cn.edu.ahut.copydetector.util.HaiMingDistance;
import lombok.Data;

import java.io.Serializable;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/cn/edu/ahut/copydetector/entity/SimResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ public class SimResult implements Serializable {
private String user2;
private Double sim;


public SimResult(String user1, String user2, Double sim) {
this.user1 = user1;
this.user2 = user2;
this.sim = sim;
}

}
Loading

0 comments on commit e8a1f9d

Please sign in to comment.