增加文件前缀和后缀的设置,修缮部分代码规范
This commit is contained in:
@@ -56,82 +56,83 @@ public class DataController {
|
||||
private HttpServletRequest httpServletRequest;
|
||||
|
||||
@GetMapping("/home/findAllHomework")
|
||||
public List<VWorkDetail> findAllHomework(){
|
||||
public List<VWorkDetail> findAllHomework() {
|
||||
List<VWorkDetail> homeworks = workDetailService.findAll();
|
||||
if (homeworks!=null){
|
||||
if (homeworks != null) {
|
||||
return homeworks;
|
||||
}
|
||||
throw new UserException(ResultEnum.EMPTY_DATA);
|
||||
}
|
||||
|
||||
@GetMapping("/home/findvlog")
|
||||
public List<VLog> findlog(){
|
||||
public List<VLog> findlog() {
|
||||
List<VLog> vlogs = logService.findvlog();
|
||||
if (vlogs!=null){
|
||||
if (vlogs != null) {
|
||||
return vlogs;
|
||||
}
|
||||
throw new UserException(ResultEnum.EMPTY_DATA);
|
||||
}
|
||||
|
||||
@GetMapping("/home/admin/findvfeedback")
|
||||
public List<VFeedBack> findAllVFeedback(){
|
||||
public List<VFeedBack> findAllVFeedback() {
|
||||
List<VFeedBack> feedBacks = feedBackService.findAllVFeedback();
|
||||
if (feedBacks!=null){
|
||||
if (feedBacks != null) {
|
||||
return feedBacks;
|
||||
}
|
||||
throw new UserException(ResultEnum.EMPTY_DATA);
|
||||
}
|
||||
|
||||
@GetMapping("/home/findvcourse")
|
||||
public List<VCourse> findVCourse(){
|
||||
public List<VCourse> findVCourse() {
|
||||
List<VCourse> vCourses = courseService.findAllVCourse();
|
||||
if (vCourses!=null){
|
||||
if (vCourses != null) {
|
||||
return vCourses;
|
||||
}
|
||||
throw new UserException(ResultEnum.EMPTY_DATA);
|
||||
}
|
||||
|
||||
@GetMapping("/home/admin/findalluser")
|
||||
public List<TbUser> findAllUser(){
|
||||
public List<TbUser> findAllUser() {
|
||||
List<TbUser> users = userService.findAllUser();
|
||||
if (users!=null){
|
||||
if (users != null) {
|
||||
return users;
|
||||
}
|
||||
throw new UserException(ResultEnum.EMPTY_DATA);
|
||||
}
|
||||
|
||||
@GetMapping("/home/findallvhomework")
|
||||
public List<VHomework> findAllVHomework(){
|
||||
public List<VHomework> findAllVHomework() {
|
||||
List<VHomework> vHomeworks = homeworkService.findAllVHomework();
|
||||
if (vHomeworks!=null){
|
||||
if (vHomeworks != null) {
|
||||
return vHomeworks;
|
||||
}
|
||||
throw new UserException(ResultEnum.EMPTY_DATA);
|
||||
}
|
||||
|
||||
@GetMapping("/home/admin/findStudentInCourseFile")
|
||||
public List<TbStudentlist> findStudentInCourseFile(
|
||||
@RequestParam(value = "Folder") String Folder,@RequestParam(value = "CourseName") String CourseName){
|
||||
List<TbStudentlist> files = vUserfileService.findStudentNoByWorkFolderAndCourseName(Folder,CourseName);
|
||||
if (files!=null){
|
||||
public List<TbStudentlist> findStudentInCourseFile(
|
||||
@RequestParam(value = "Folder") String Folder, @RequestParam(value = "CourseName") String CourseName) {
|
||||
List<TbStudentlist> files = vUserfileService.findStudentNoByWorkFolderAndCourseName(Folder, CourseName);
|
||||
if (files != null) {
|
||||
return files;
|
||||
}
|
||||
throw new UserException(ResultEnum.EMPTY_DATA);
|
||||
}
|
||||
|
||||
@GetMapping("/home/userinfo")
|
||||
public VUserinfo findUserInfo(){
|
||||
TbUser user= (TbUser)httpServletRequest.getSession().getAttribute(USER_SESSION_KEY);
|
||||
public VUserinfo findUserInfo() {
|
||||
TbUser user = (TbUser) httpServletRequest.getSession().getAttribute(USER_SESSION_KEY);
|
||||
return userService.findUserInfo(user.getColuserid());
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储密保问题
|
||||
*
|
||||
* @param userque
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/home/adduserque")
|
||||
public boolean adduserque(TbUserque userque)throws Exception{
|
||||
public boolean adduserque(TbUserque userque) throws Exception {
|
||||
//对密保问题加密存储
|
||||
userque.setAnswer(new BigInteger(CodingUtil.encryptSHA(userque.getAnswer().getBytes())).toString(32));
|
||||
return userService.addUserQue(userque);
|
||||
@@ -139,6 +140,7 @@ public class DataController {
|
||||
|
||||
/**
|
||||
* 判断密保问题是否正确,正确返回true,错误返回false,其余反馈异常对象
|
||||
*
|
||||
* @param name
|
||||
* @param question
|
||||
* @param answer
|
||||
@@ -146,18 +148,19 @@ public class DataController {
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping("/finduserque")
|
||||
public boolean findUserQue(@RequestParam(value = "name")String name
|
||||
,@RequestParam(value = "question")String question
|
||||
,@RequestParam(value = "answer")String answer)throws Exception{
|
||||
public boolean findUserQue(@RequestParam(value = "name") String name
|
||||
, @RequestParam(value = "question") String question
|
||||
, @RequestParam(value = "answer") String answer) throws Exception {
|
||||
Optional<VUserque> userque = userService.findUserQueByName(name);
|
||||
if (!userque.isPresent()){
|
||||
if (!userque.isPresent()) {
|
||||
throw new UserException(ResultEnum.EMPTY_QUESTION);
|
||||
}else if(question.equals(userque.get().getQuestion())){
|
||||
if(new BigInteger(CodingUtil.encryptSHA(answer.getBytes())).toString(32).equals(userque.get().getAnswer()))
|
||||
} else if (question.equals(userque.get().getQuestion())) {
|
||||
if (new BigInteger(CodingUtil.encryptSHA(answer.getBytes())).toString(32).equals(userque.get().getAnswer())) {
|
||||
return true;
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}else{
|
||||
}
|
||||
} else {
|
||||
throw new UserException(ResultEnum.QUESTION_ERROR);
|
||||
}
|
||||
}
|
||||
@@ -165,53 +168,53 @@ public class DataController {
|
||||
@PostMapping("/resetPass")
|
||||
public boolean resetPass(@RequestParam(value = "name") String name
|
||||
, @RequestParam(value = "password") String password,
|
||||
@RequestParam(value = "question") String question
|
||||
@RequestParam(value = "question") String question
|
||||
, @RequestParam(value = "answer") String answer) throws Exception {
|
||||
//log.info("name:{}, password:{}, question:{}, answer:{}",name,password,question,answer);
|
||||
if (findUserQue(name,question,answer)){
|
||||
if (findUserQue(name, question, answer)) {
|
||||
//service方法内含有对密码加密的操作
|
||||
return userService.updateColpasswordByColname(password,name);
|
||||
}else {
|
||||
return userService.updateColpasswordByColname(password, name);
|
||||
} else {
|
||||
throw new UserException(ResultEnum.ILLEGAL_ACCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/home/findAllNotice")
|
||||
public List<TbNotice> findAllNotice(){
|
||||
public List<TbNotice> findAllNotice() {
|
||||
return noticeService.findAll();
|
||||
}
|
||||
|
||||
@PostMapping("/home/admin/addNotice")
|
||||
public boolean addNotice(String content){
|
||||
TbUser user= (TbUser)httpServletRequest.getSession().getAttribute(USER_SESSION_KEY);
|
||||
public boolean addNotice(String content) {
|
||||
TbUser user = (TbUser) httpServletRequest.getSession().getAttribute(USER_SESSION_KEY);
|
||||
TbNotice notice = new TbNotice();
|
||||
Date date = new Date();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateNowStr = sdf.format(date);
|
||||
Optional<VAdmin> vAdmin = adminService.findAdminByUserId(user.getColuserid());
|
||||
if (vAdmin.isPresent()){
|
||||
if (vAdmin.isPresent()) {
|
||||
VAdmin admin = vAdmin.get();
|
||||
notice.setAdminid(admin.getAdminid());
|
||||
notice.setIssueTime(dateNowStr);
|
||||
notice.setNoticeContent(content);
|
||||
return noticeService.addOne(notice)!=null;
|
||||
}else
|
||||
return noticeService.addOne(notice) != null;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/home/admin/addoneversion")
|
||||
public boolean addOneVersion(TbVersion version){
|
||||
return versionService.addOneVersion(version)!=null;
|
||||
public boolean addOneVersion(TbVersion version) {
|
||||
return versionService.addOneVersion(version) != null;
|
||||
}
|
||||
|
||||
@PostMapping("/home/admin/addversion")
|
||||
public boolean addVersion(@RequestBody List<TbVersion> versions){
|
||||
return versionService.addAllVersion(versions)!=null;
|
||||
public boolean addVersion(@RequestBody List<TbVersion> versions) {
|
||||
return versionService.addAllVersion(versions) != null;
|
||||
}
|
||||
|
||||
@GetMapping("/home/findallversion")
|
||||
public List<TbVersion> findAllVersion(){
|
||||
public List<TbVersion> findAllVersion() {
|
||||
return versionService.findAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,8 +46,9 @@ public class DownLoadController {
|
||||
@ResponseBody
|
||||
public List<TbFile> toDownloadAll() {
|
||||
List<TbFile> files = fileService.findAllFile();//此处做空指针判断并抛出错误
|
||||
if (files != null)
|
||||
if (files != null) {
|
||||
return files;
|
||||
}
|
||||
new UserException(ResultEnum.EMPTY_DATA);
|
||||
return null;
|
||||
}
|
||||
@@ -59,8 +60,9 @@ public class DownLoadController {
|
||||
//log.info(user.toString());
|
||||
List<TbFile> files = fileService.findByColuserid(user.getColuserid());
|
||||
//此处做空指针判断并抛出错误
|
||||
if (files != null)
|
||||
if (files != null) {
|
||||
return files;
|
||||
}
|
||||
new UserException(ResultEnum.EMPTY_DATA);
|
||||
return null;
|
||||
}
|
||||
@@ -103,20 +105,22 @@ public class DownLoadController {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (bis != null)
|
||||
if (bis != null) {
|
||||
try {
|
||||
bis.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (bos != null)
|
||||
}
|
||||
if (bos != null) {
|
||||
try {
|
||||
bos.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -184,9 +188,15 @@ public class DownLoadController {
|
||||
} finally {
|
||||
//关闭流
|
||||
try {
|
||||
if (null != bufferStream) bufferStream.close();
|
||||
if (null != zipStream) zipStream.close();
|
||||
if (null != zipSource) zipSource.close();
|
||||
if (null != bufferStream) {
|
||||
bufferStream.close();
|
||||
}
|
||||
if (null != zipStream) {
|
||||
zipStream.close();
|
||||
}
|
||||
if (null != zipSource) {
|
||||
zipSource.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -209,20 +219,22 @@ public class DownLoadController {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (bis != null)
|
||||
if (bis != null) {
|
||||
try {
|
||||
bis.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (bos != null)
|
||||
}
|
||||
if (bos != null) {
|
||||
try {
|
||||
bos.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,8 +63,9 @@ public class RegisterController {
|
||||
@ResponseBody
|
||||
public boolean doCheckStudentNo(@RequestParam(value = "studentno") String studentno){
|
||||
TbStudentlist studentlist = studentService.findStudentByNo(studentno);
|
||||
if (studentlist!=null)
|
||||
if (studentlist!=null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -73,8 +74,9 @@ public class RegisterController {
|
||||
public boolean doCheckStudent(@RequestParam(value = "studentno") String studentno,
|
||||
@RequestParam(value = "realname") String realname){
|
||||
TbStudentlist studentlist = studentService.findByColstudentnoAndColrealname(studentno,realname);
|
||||
if (studentlist!=null&&studentlist.getRegistered()!= RegisteredEnum.REGISTERED.getCode())
|
||||
if (studentlist!=null&&studentlist.getRegistered()!= RegisteredEnum.REGISTERED.getCode()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -87,8 +89,9 @@ public class RegisterController {
|
||||
@ResponseBody
|
||||
public boolean doUserName(@RequestParam(value = "name") String name){
|
||||
Optional<TbUser> user = userService.findByColname(name);
|
||||
if (user.isPresent())
|
||||
if (user.isPresent()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.fjy.spring.controller;
|
||||
|
||||
import com.fjy.spring.constant.GlobalConstant;
|
||||
import com.fjy.spring.domain.Homework;
|
||||
import com.fjy.spring.domain.TbFile;
|
||||
import com.fjy.spring.domain.TbLog;
|
||||
import com.fjy.spring.domain.TbUser;
|
||||
import com.fjy.spring.properties.ServerProperties;
|
||||
import com.fjy.spring.service.FileService;
|
||||
import com.fjy.spring.service.HomeworkService;
|
||||
import com.fjy.spring.service.LogService;
|
||||
import com.fjy.spring.untils.FormatFileSizeUtil;
|
||||
import com.fjy.spring.untils.GetIPAddrUtil;
|
||||
@@ -31,11 +33,20 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
public class UpLoadController {
|
||||
|
||||
/**
|
||||
* 服务器配置信息
|
||||
*/
|
||||
@Autowired
|
||||
private ServerProperties serverProperties;//服务器配置信息
|
||||
private ServerProperties serverProperties;
|
||||
|
||||
/**
|
||||
* 文件相关数据库操作
|
||||
*/
|
||||
@Autowired
|
||||
private FileService fileService;
|
||||
|
||||
@Autowired
|
||||
private FileService fileService;//文件相关数据库操作
|
||||
private HomeworkService homeworkService;
|
||||
|
||||
@Autowired
|
||||
private LogService logService;
|
||||
@@ -79,20 +90,22 @@ public class UpLoadController {
|
||||
* 存储文件信息
|
||||
*/
|
||||
TbFile file = new TbFile();
|
||||
file.setColfilesize(new FormatFileSizeUtil().GetFileSize(imageFile.getSize()));
|
||||
file.setColfilesize(FormatFileSizeUtil.GetFileSize(imageFile.getSize()));
|
||||
file.setColfilename(filename);
|
||||
file.setColfilepath(uploadUrl + filename);
|
||||
file.setColip(request.getRemoteAddr());
|
||||
file.setColuserid(user.getColuserid());
|
||||
if (fileService.addFile(file))
|
||||
if (fileService.addFile(file)) {
|
||||
log.info("记录写入数据库成功");
|
||||
//System.out.println("记录写入数据库成功");
|
||||
else
|
||||
}
|
||||
//System.out.println("记录写入数据库成功");
|
||||
else {
|
||||
log.error("记录写入数据库失败");
|
||||
}
|
||||
//System.out.println("记录写入数据库失败");
|
||||
|
||||
log.info("文件上传到: " + uploadUrl + filename);
|
||||
log.info("文件大小: " + new FormatFileSizeUtil().GetFileSize(imageFile.getSize()));
|
||||
log.info("文件大小: " + FormatFileSizeUtil.GetFileSize(imageFile.getSize()));
|
||||
log.info("文件名: " + filename);
|
||||
|
||||
File targetFile = new File(uploadUrl + filename);
|
||||
@@ -130,6 +143,7 @@ public class UpLoadController {
|
||||
public void moreUpload(HttpServletRequest request,
|
||||
@RequestParam(value = "courseName", required = false) String courseName,
|
||||
@RequestParam(value = "folder", required = false) String folder,
|
||||
@RequestParam(value = "workid") Integer workId,
|
||||
@RequestParam(value = "rename", required = true) boolean rename) {
|
||||
|
||||
MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest) request;
|
||||
@@ -158,13 +172,21 @@ public class UpLoadController {
|
||||
List<String> fileList = new ArrayList<String>();
|
||||
|
||||
for (MultipartFile file : files.values()) {
|
||||
Homework homework = homeworkService.findById(workId);
|
||||
String filePrefix = homework.getFilePrefix();
|
||||
String fileSuffix = homework.getFileSuffix();
|
||||
String filename = file.getOriginalFilename();
|
||||
String suffix = "." + filename.substring(filename.lastIndexOf(".") + 1);//获取文件后缀
|
||||
|
||||
//获取文件后缀
|
||||
String suffix = "." + filename.substring(filename.lastIndexOf(".") + 1);
|
||||
TbFile tbFile = new TbFile();
|
||||
String pathname;
|
||||
|
||||
|
||||
//文件重命名
|
||||
if (rename) {
|
||||
pathname = uploadUrl + user.getColstudentno() + user.getColrealname() + suffix;
|
||||
tbFile.setColfilename(user.getColstudentno() + user.getColrealname() + suffix);
|
||||
pathname = uploadUrl + filePrefix + user.getColstudentno() + user.getColrealname() + fileSuffix + suffix;
|
||||
tbFile.setColfilename(filePrefix + user.getColstudentno() + user.getColrealname() + fileSuffix + suffix);
|
||||
} else {
|
||||
pathname = uploadUrl + filename;
|
||||
tbFile.setColfilename(filename);
|
||||
@@ -172,39 +194,41 @@ public class UpLoadController {
|
||||
|
||||
File targetFile = new File(pathname);
|
||||
//若文件已存在则自动重命名
|
||||
if (targetFile.exists()){
|
||||
if (targetFile.exists()) {
|
||||
String bakpathname;
|
||||
if (rename) {
|
||||
bakpathname = uploadUrl + "bak/" +user.getColstudentno() + user.getColrealname() + suffix;
|
||||
bakpathname = uploadUrl + "bak/" + user.getColstudentno() + user.getColrealname() + suffix;
|
||||
} else {
|
||||
bakpathname = uploadUrl +"bak/"+ filename;
|
||||
bakpathname = uploadUrl + "bak/" + filename;
|
||||
}
|
||||
log.info("源文件路径:"+pathname);
|
||||
log.info("源文件路径:" + pathname);
|
||||
TbFile file1 = fileService.findByFilepath(pathname);
|
||||
file1.setColfilepath(bakpathname+"."+dateNowStr2+".bak");
|
||||
file1.setColfilename(file1.getColfilename()+"."+dateNowStr2+".bak");
|
||||
if (fileService.addFile(file1))
|
||||
file1.setColfilepath(bakpathname + "." + dateNowStr2 + ".bak");
|
||||
file1.setColfilename(file1.getColfilename() + "." + dateNowStr2 + ".bak");
|
||||
if (fileService.addFile(file1)) {
|
||||
log.info("重命名文件数据库更新成功");
|
||||
else
|
||||
} else {
|
||||
log.error("重命名文件数据库更新失败");
|
||||
File mvfile = new File(bakpathname+"."+dateNowStr2+".bak");
|
||||
}
|
||||
File mvfile = new File(bakpathname + "." + dateNowStr2 + ".bak");
|
||||
try {
|
||||
FileUtils.moveFile(targetFile, mvfile);
|
||||
log.info("源文件:"+targetFile.getName()+"已重命名为:"+ mvfile.getName());
|
||||
log.info("源文件:" + targetFile.getName() + "已重命名为:" + mvfile.getName());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
log.info("文件上传到: " + uploadUrl + filename);
|
||||
log.info("文件大小: " + new FormatFileSizeUtil().GetFileSize(file.getSize()));
|
||||
log.info("文件大小: " + FormatFileSizeUtil.GetFileSize(file.getSize()));
|
||||
log.info("文件名: " + filename);
|
||||
|
||||
tbFile.setColfilesize(new FormatFileSizeUtil().GetFileSize(file.getSize()));
|
||||
tbFile.setColfilesize(FormatFileSizeUtil.GetFileSize(file.getSize()));
|
||||
|
||||
tbFile.setColtime(dateNowStr);
|
||||
tbFile.setColrealname(filename);
|
||||
tbFile.setColfilepath(pathname);//文件自动学号+姓名命名
|
||||
//文件自动学号+姓名命名
|
||||
tbFile.setColfilepath(pathname);
|
||||
tbFile.setColip(request.getRemoteAddr());
|
||||
tbFile.setColuserid(user.getColuserid());
|
||||
tbFile.setCourseName(courseName);
|
||||
@@ -217,10 +241,11 @@ public class UpLoadController {
|
||||
logs.setColheader(user.getColname() + "上传了'" + filename + "'文件");
|
||||
logService.addLogRec(logs);
|
||||
|
||||
if (fileService.addFile(tbFile))
|
||||
if (fileService.addFile(tbFile)) {
|
||||
log.info("记录写入数据库成功");
|
||||
else
|
||||
} else {
|
||||
log.error("记录写入数据库失败");
|
||||
}
|
||||
|
||||
if (!targetFile.exists()) {
|
||||
try {
|
||||
|
||||
@@ -30,4 +30,10 @@ public class Homework {
|
||||
|
||||
@Column(name = "workremark")
|
||||
private String Remark;
|
||||
|
||||
@Column(name = "pre")
|
||||
private String filePrefix;
|
||||
|
||||
@Column(name = "suf")
|
||||
private String fileSuffix;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ public class AdminInterceptor implements HandlerInterceptor {
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
TbUser user = (TbUser)request.getSession().getAttribute(GlobalConstant.USER_SESSION_KEY);
|
||||
//log.info(user.getColuserid()+"");
|
||||
if (adminService == null) {//解决service为null无法注入问题
|
||||
//解决service为null无法注入问题
|
||||
if (adminService == null) {
|
||||
BeanFactory factory = WebApplicationContextUtils.getRequiredWebApplicationContext(request.getServletContext());
|
||||
adminService = (AdminService) factory.getBean("adminService");
|
||||
}
|
||||
@@ -33,8 +34,9 @@ public class AdminInterceptor implements HandlerInterceptor {
|
||||
if (!admin.isPresent()){
|
||||
response.sendRedirect("/cms/home");
|
||||
return false;
|
||||
}else
|
||||
}else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,15 +15,17 @@ public class FileService {
|
||||
|
||||
public boolean addFile(TbFile tbFile) {
|
||||
TbFile file = tbFileRepository.save(tbFile);
|
||||
if (file != null)
|
||||
if (file != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<TbFile> findFile(TbFile tbFile){
|
||||
List<TbFile> files = tbFileRepository.findByColfilename(tbFile.getColfilename());
|
||||
if (files!=null)
|
||||
if (files!=null) {
|
||||
return files;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@ package com.fjy.spring.service;
|
||||
|
||||
import com.fjy.spring.domain.Homework;
|
||||
import com.fjy.spring.domain.VHomework;
|
||||
import com.fjy.spring.domain.VWorkDetail;
|
||||
import com.fjy.spring.repository.HomeworkRepository;
|
||||
import com.fjy.spring.repository.VHomeworkRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class HomeworkService {
|
||||
@@ -25,4 +25,12 @@ public class HomeworkService {
|
||||
public List<VHomework> findAllVHomework(){
|
||||
return vHomeworkRepository.findAll();
|
||||
}
|
||||
|
||||
public Homework findById(Integer id){
|
||||
Optional<Homework> homework = homeworkRepository.findById(id);
|
||||
if (homework.isPresent()){
|
||||
return (Homework)homework.get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,8 +81,9 @@ public class UserService {
|
||||
|
||||
public boolean addUserQue(TbUserque userque) {
|
||||
TbUserque tbUserque = userqueRepository.save(userque);
|
||||
if (tbUserque != null)
|
||||
if (tbUserque != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user