前端添加、删除文件和反馈提示改为服务器回调信息,去除无用文件,前端版本信息改为由服务器获取,后台可批量插入版本日志

This commit is contained in:
F嘉阳
2018-02-27 09:23:38 +08:00
parent b652389d4e
commit a93f63280b
29 changed files with 230 additions and 329 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -42,16 +42,6 @@ public class UpLoadController {
@Resource
HttpServletRequest httpServletRequest;
@GetMapping("/toOneUpload")
public String toOneUpload() {
return "oneUpload";
}
@GetMapping("/toMoreUpload")
public String toMoreUpload() {
return "moreUpload";
}
/**
* 测试文件上传路径地址
*

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

View File

@@ -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 {
/**

View File

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

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