前端添加、删除文件和反馈提示改为服务器回调信息,去除无用文件,前端版本信息改为由服务器获取,后台可批量插入版本日志
This commit is contained in:
@@ -7,14 +7,13 @@ import com.fjy.spring.service.*;
|
||||
import com.fjy.spring.untils.CodingUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -51,6 +50,9 @@ public class DataController {
|
||||
@Autowired
|
||||
private NoticeService noticeService;
|
||||
|
||||
@Autowired
|
||||
private VersionService versionService;
|
||||
|
||||
@Resource
|
||||
private HttpServletRequest httpServletRequest;
|
||||
|
||||
@@ -180,4 +182,20 @@ public class DataController {
|
||||
public List<TbNotice> findAllNotice(){
|
||||
return noticeService.findAll();
|
||||
}
|
||||
|
||||
@PostMapping("/home/admin/addoneversion")
|
||||
public boolean addOneVersion(TbVersion version){
|
||||
log.info(version.toString());
|
||||
return versionService.addOneVersion(version)!=null;
|
||||
}
|
||||
|
||||
@PostMapping("/home/admin/addversion")
|
||||
public boolean addVersion(@RequestBody List<TbVersion> versions){
|
||||
return versionService.addAllVersion(versions)!=null;
|
||||
}
|
||||
|
||||
@GetMapping("/home/findallversion")
|
||||
public List<TbVersion> findAllVersion(){
|
||||
return versionService.findAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,20 +33,25 @@ public class DeleteController {
|
||||
*/
|
||||
@RequestMapping("/home/filedelete")
|
||||
@ResponseBody
|
||||
public void delete(@RequestParam(value = "fileid") Integer fileid)throws Exception {
|
||||
public boolean delete(@RequestParam(value = "fileid") Integer fileid)throws Exception {
|
||||
TbFile tbFile = new TbFile();
|
||||
tbFile.setColfileid(fileid);
|
||||
TbFile resfile = fileService.findFileById(tbFile);
|
||||
File filepath = new File(resfile.getColfilepath());
|
||||
if (!filepath.exists()) {
|
||||
log.error("删除文件失败:" + resfile.getColfilename() + "不存在!");
|
||||
return false;
|
||||
} else {
|
||||
if (filepath.isFile()){
|
||||
deleteFile(resfile.getColfilepath(),resfile.getColfileid());
|
||||
new UserException(ResultEnum.SUCCESS);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
else{
|
||||
deleteDirectory(resfile.getColfilepath());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class FeedBackController {
|
||||
HttpServletRequest request;
|
||||
|
||||
@PostMapping("/home/dofeedback")
|
||||
public void doFeedBack(@RequestParam(value = "content") String content){
|
||||
public boolean doFeedBack(@RequestParam(value = "content") String content){
|
||||
Date date = new Date();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateNowStr = sdf.format(date);
|
||||
@@ -45,7 +45,9 @@ public class FeedBackController {
|
||||
RedirectUtil red = new RedirectUtil();
|
||||
if (feedBackService.addContent(feedBack)){
|
||||
log.info("反馈信息写入数据库成功");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class NavController {
|
||||
|
||||
@GetMapping(value = {"/home"})
|
||||
public String toHomePage(){
|
||||
return "/home/home";
|
||||
return "home/home";
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/logout"})
|
||||
@@ -41,41 +41,41 @@ public class NavController {
|
||||
|
||||
@GetMapping(value = {"/home/feedback"})
|
||||
public String toFeedbackPage(){
|
||||
return "/home/feedback";
|
||||
return "home/feedback";
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/home/about"})
|
||||
public String toAboutPage(){
|
||||
return "/home/about";
|
||||
return "home/about";
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/home/admin"})
|
||||
public String toAdminPage(){
|
||||
return "/home/admin";
|
||||
return "home/admin";
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/home/managecourse"})
|
||||
public String toManageCoursePage(){
|
||||
return "/home/managecourse";
|
||||
return "home/managecourse";
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/home/manageuser"})
|
||||
public String toManageUserPage(){
|
||||
return "/home/manageuser";
|
||||
return "home/manageuser";
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/home/homework"})
|
||||
public String toHomeworkPage(){
|
||||
return "/home/homework";
|
||||
return "home/homework";
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/home/user"})
|
||||
public String toUserPage(){
|
||||
return "/home/user";
|
||||
return "home/user";
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/error"})
|
||||
public String toErrorPage(){
|
||||
return "/error";
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,16 +42,6 @@ public class UpLoadController {
|
||||
@Resource
|
||||
HttpServletRequest httpServletRequest;
|
||||
|
||||
@GetMapping("/toOneUpload")
|
||||
public String toOneUpload() {
|
||||
return "oneUpload";
|
||||
}
|
||||
|
||||
@GetMapping("/toMoreUpload")
|
||||
public String toMoreUpload() {
|
||||
return "moreUpload";
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试文件上传路径地址
|
||||
*
|
||||
|
||||
27
src/main/java/com/fjy/spring/domain/TbVersion.java
Normal file
27
src/main/java/com/fjy/spring/domain/TbVersion.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.fjy.spring.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class TbVersion {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Integer versionid;
|
||||
|
||||
private String date;
|
||||
|
||||
private String content;
|
||||
|
||||
private String version;
|
||||
|
||||
private String user;
|
||||
|
||||
public TbVersion() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/*@Configuration*/
|
||||
@Configuration
|
||||
public class WebAppConfig implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.fjy.spring.repository;
|
||||
|
||||
import com.fjy.spring.domain.TbVersion;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface TbVersionRepository extends JpaRepository<TbVersion,Integer> {
|
||||
|
||||
}
|
||||
27
src/main/java/com/fjy/spring/service/VersionService.java
Normal file
27
src/main/java/com/fjy/spring/service/VersionService.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.fjy.spring.service;
|
||||
|
||||
import com.fjy.spring.domain.TbVersion;
|
||||
import com.fjy.spring.repository.TbVersionRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class VersionService {
|
||||
|
||||
@Autowired
|
||||
private TbVersionRepository versionRepository;
|
||||
|
||||
public TbVersion addOneVersion(TbVersion tbVersion){
|
||||
return versionRepository.save(tbVersion);
|
||||
}
|
||||
|
||||
public List<TbVersion> addAllVersion(List<TbVersion> versions){
|
||||
return versionRepository.saveAll(versions);
|
||||
}
|
||||
|
||||
public List<TbVersion> findAll(){
|
||||
return versionRepository.findAll();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user