实现作业获取和展示
This commit is contained in:
28
src/main/java/com/fjy/spring/controller/DataController.java
Normal file
28
src/main/java/com/fjy/spring/controller/DataController.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.fjy.spring.controller;
|
||||
|
||||
import com.fjy.spring.domain.VWorkDetail;
|
||||
import com.fjy.spring.enums.ResultEnum;
|
||||
import com.fjy.spring.exception.UserException;
|
||||
import com.fjy.spring.service.WorkDetailService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
public class DataController {
|
||||
|
||||
@Autowired
|
||||
private WorkDetailService workDetailService;
|
||||
|
||||
@GetMapping("/home/findAllHomework")
|
||||
public List<VWorkDetail> findAllHomework(){
|
||||
List<VWorkDetail> homeworks = workDetailService.findAll();
|
||||
if (homeworks!=null){
|
||||
return homeworks;
|
||||
}
|
||||
new UserException(ResultEnum.EMPTY_DATA);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import static com.fjy.spring.constant.GlobalConstant.USER_SESSION_KEY;
|
||||
@@ -43,10 +44,12 @@ public class LoginController {
|
||||
request.getSession().setAttribute(USER_SESSION_KEY,user);
|
||||
//写入日志信息
|
||||
Date date = new Date();
|
||||
Timestamp currentTime = new Timestamp(date.getTime());
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateNowStr = sdf.format(date);
|
||||
System.out.println("当前时间:"+dateNowStr);
|
||||
TbLog log = new TbLog();
|
||||
log.setUserid(user.getColuserid());
|
||||
log.setColtime(currentTime);
|
||||
log.setColtime(dateNowStr);
|
||||
log.setColheader(request.getHeader("user-agent"));
|
||||
log.setColip(request.getRemoteAddr());
|
||||
logService.addLogRec(log);
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -129,7 +129,8 @@ public class UpLoadController {
|
||||
|
||||
TbUser user = (TbUser)request.getSession().getAttribute(GlobalConstant.USER_SESSION_KEY);
|
||||
Date date = new Date();
|
||||
Timestamp currentTime = new Timestamp(date.getTime());
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateNowStr = sdf.format(date);
|
||||
//String uploadUrl = request.getSession().getServletContext().getRealPath("/") + "upload/";
|
||||
String uploadUrl = serverProperties.getFilePath()+ "upload/";
|
||||
|
||||
@@ -151,7 +152,7 @@ public class UpLoadController {
|
||||
TbFile tbFile = new TbFile();
|
||||
tbFile.setColfilesize(new FormatFileSizeUtil().GetFileSize(file.getSize()));
|
||||
tbFile.setColfilename(filename);
|
||||
tbFile.setColtime(currentTime);
|
||||
tbFile.setColtime(dateNowStr);
|
||||
tbFile.setColfilepath(uploadUrl + filename);
|
||||
tbFile.setColip(request.getRemoteAddr());
|
||||
tbFile.setColuserid(user.getColuserid());
|
||||
|
||||
@@ -1,50 +1,55 @@
|
||||
package com.fjy.spring.domain;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "tb_homework")
|
||||
public class Homework {
|
||||
@Id
|
||||
@Column(name = "workid")
|
||||
@GeneratedValue
|
||||
private Integer workId;
|
||||
private Integer Id;
|
||||
|
||||
private String workName;
|
||||
@Column(name = "workname")
|
||||
private String Name;
|
||||
|
||||
private Timestamp workTime;
|
||||
@Column(name = "worktime")
|
||||
private String Time;
|
||||
|
||||
@Column(name = "colfileid")
|
||||
private Integer fileid;
|
||||
|
||||
private String workFolder;
|
||||
@Column(name = "workfolder")
|
||||
private String Folder;
|
||||
|
||||
@Column(name = "courseno")
|
||||
private Integer courseNo;
|
||||
|
||||
private String workRemark;
|
||||
@Column(name = "workremark")
|
||||
private String Remark;
|
||||
|
||||
public Integer getWorkId() {
|
||||
return workId;
|
||||
public Integer getId() {
|
||||
return Id;
|
||||
}
|
||||
|
||||
public void setWorkId(Integer workId) {
|
||||
this.workId = workId;
|
||||
public void setId(Integer id) {
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public String getWorkName() {
|
||||
return workName;
|
||||
public String getName() {
|
||||
return Name;
|
||||
}
|
||||
|
||||
public void setWorkName(String workName) {
|
||||
this.workName = workName;
|
||||
public void setName(String name) {
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public Timestamp getWorkTime() {
|
||||
return workTime;
|
||||
public String getTime() {
|
||||
return Time;
|
||||
}
|
||||
|
||||
public void setWorkTime(Timestamp workTime) {
|
||||
this.workTime = workTime;
|
||||
public void setTime(String time) {
|
||||
Time = time;
|
||||
}
|
||||
|
||||
public Integer getFileid() {
|
||||
@@ -55,12 +60,12 @@ public class Homework {
|
||||
this.fileid = fileid;
|
||||
}
|
||||
|
||||
public String getWorkFolder() {
|
||||
return workFolder;
|
||||
public String getFolder() {
|
||||
return Folder;
|
||||
}
|
||||
|
||||
public void setWorkFolder(String workFolder) {
|
||||
this.workFolder = workFolder;
|
||||
public void setFolder(String folder) {
|
||||
Folder = folder;
|
||||
}
|
||||
|
||||
public Integer getCourseNo() {
|
||||
@@ -71,11 +76,11 @@ public class Homework {
|
||||
this.courseNo = courseNo;
|
||||
}
|
||||
|
||||
public String getWorkRemark() {
|
||||
return workRemark;
|
||||
public String getRemark() {
|
||||
return Remark;
|
||||
}
|
||||
|
||||
public void setWorkRemark(String workRemark) {
|
||||
this.workRemark = workRemark;
|
||||
public void setRemark(String remark) {
|
||||
Remark = remark;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class TbAdmin {
|
||||
|
||||
@Column(name = "coluserid")
|
||||
private Integer userid;
|
||||
private Integer coltime;
|
||||
private String coltime;
|
||||
|
||||
public Integer getAdminid() {
|
||||
return adminid;
|
||||
@@ -33,11 +33,11 @@ public class TbAdmin {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public Integer getColtime() {
|
||||
public String getColtime() {
|
||||
return coltime;
|
||||
}
|
||||
|
||||
public void setColtime(Integer coltime) {
|
||||
public void setColtime(String coltime) {
|
||||
this.coltime = coltime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.fjy.spring.domain;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
@@ -8,11 +9,14 @@ import java.sql.Timestamp;
|
||||
@Entity
|
||||
public class TbCourse {
|
||||
@Id
|
||||
@Column(name = "courseno")
|
||||
@GeneratedValue
|
||||
private Integer courseNo;
|
||||
|
||||
@Column(name = "coursename")
|
||||
private String courseName;
|
||||
|
||||
@Column(name = "coursetime")
|
||||
private Timestamp courseTime;
|
||||
|
||||
private Integer teacherid;
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.fjy.spring.domain;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
public class TbFile {
|
||||
@@ -13,7 +12,7 @@ public class TbFile {
|
||||
|
||||
private int coluserid;
|
||||
|
||||
private Timestamp coltime;
|
||||
private String coltime;
|
||||
|
||||
private String colip;
|
||||
|
||||
@@ -36,11 +35,11 @@ public class TbFile {
|
||||
'}';
|
||||
}
|
||||
|
||||
public Timestamp getColtime() {
|
||||
public String getColtime() {
|
||||
return coltime;
|
||||
}
|
||||
|
||||
public void setColtime(Timestamp coltime) {
|
||||
public void setColtime(String coltime) {
|
||||
this.coltime = coltime;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.fjy.spring.domain;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
public class TbLog {
|
||||
@@ -12,7 +11,7 @@ public class TbLog {
|
||||
@Column(name = "coluserid")
|
||||
private Integer userid;
|
||||
|
||||
private Timestamp coltime;
|
||||
private String coltime;
|
||||
|
||||
private String colip;
|
||||
|
||||
@@ -34,11 +33,11 @@ public class TbLog {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public Timestamp getColtime() {
|
||||
public String getColtime() {
|
||||
return coltime;
|
||||
}
|
||||
|
||||
public void setColtime(Timestamp coltime) {
|
||||
public void setColtime(String coltime) {
|
||||
this.coltime = coltime;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class TbStudent {
|
||||
|
||||
@Column(name = "coluserid")
|
||||
private Integer userid;
|
||||
private Integer coltime;
|
||||
private String coltime;
|
||||
|
||||
public Integer getStudentid() {
|
||||
return studentid;
|
||||
@@ -33,11 +33,11 @@ public class TbStudent {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public Integer getColtime() {
|
||||
public String getColtime() {
|
||||
return coltime;
|
||||
}
|
||||
|
||||
public void setColtime(Integer coltime) {
|
||||
public void setColtime(String coltime) {
|
||||
this.coltime = coltime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class TbTeacher {
|
||||
@GeneratedValue
|
||||
private Integer teacherid;
|
||||
private Integer coluserid;
|
||||
private Integer coltime;
|
||||
private String coltime;
|
||||
|
||||
public Integer getTeacherid() {
|
||||
return teacherid;
|
||||
@@ -30,11 +30,11 @@ public class TbTeacher {
|
||||
this.coluserid = coluserid;
|
||||
}
|
||||
|
||||
public Integer getColtime() {
|
||||
public String getColtime() {
|
||||
return coltime;
|
||||
}
|
||||
|
||||
public void setColtime(Integer coltime) {
|
||||
public void setColtime(String coltime) {
|
||||
this.coltime = coltime;
|
||||
}
|
||||
}
|
||||
|
||||
89
src/main/java/com/fjy/spring/domain/VWorkDetail.java
Normal file
89
src/main/java/com/fjy/spring/domain/VWorkDetail.java
Normal file
@@ -0,0 +1,89 @@
|
||||
package com.fjy.spring.domain;
|
||||
|
||||
import org.hibernate.annotations.Immutable;
|
||||
import org.hibernate.annotations.Subselect;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
/**
|
||||
* 映射视图实体
|
||||
*/
|
||||
@Entity
|
||||
@Immutable
|
||||
@Subselect("SELECT * FROM v_workdetail")
|
||||
public class VWorkDetail {
|
||||
@Id
|
||||
private Integer workid;
|
||||
private Integer colfileid;
|
||||
private String workname;
|
||||
private String worktime;
|
||||
private String colfilename;
|
||||
private String coursename;
|
||||
private String workremark;
|
||||
private String workfolder;
|
||||
|
||||
public Integer getWorkid() {
|
||||
return workid;
|
||||
}
|
||||
|
||||
public void setWorkid(Integer workid) {
|
||||
this.workid = workid;
|
||||
}
|
||||
|
||||
public Integer getColfileid() {
|
||||
return colfileid;
|
||||
}
|
||||
|
||||
public void setColfileid(Integer colfileid) {
|
||||
this.colfileid = colfileid;
|
||||
}
|
||||
|
||||
public String getWorkname() {
|
||||
return workname;
|
||||
}
|
||||
|
||||
public void setWorkname(String workname) {
|
||||
this.workname = workname;
|
||||
}
|
||||
|
||||
public String getWorktime() {
|
||||
return worktime;
|
||||
}
|
||||
|
||||
public void setWorktime(String worktime) {
|
||||
this.worktime = worktime;
|
||||
}
|
||||
|
||||
public String getColfilename() {
|
||||
return colfilename;
|
||||
}
|
||||
|
||||
public void setColfilename(String colfilename) {
|
||||
this.colfilename = colfilename;
|
||||
}
|
||||
|
||||
public String getCoursename() {
|
||||
return coursename;
|
||||
}
|
||||
|
||||
public void setCoursename(String coursename) {
|
||||
this.coursename = coursename;
|
||||
}
|
||||
|
||||
public String getWorkremark() {
|
||||
return workremark;
|
||||
}
|
||||
|
||||
public void setWorkremark(String workremark) {
|
||||
this.workremark = workremark;
|
||||
}
|
||||
|
||||
public String getWorkfolder() {
|
||||
return workfolder;
|
||||
}
|
||||
|
||||
public void setWorkfolder(String workfolder) {
|
||||
this.workfolder = workfolder;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.fjy.spring.domain;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "tb_workstatus")
|
||||
@@ -13,6 +12,7 @@ public class Workstatus {
|
||||
@Column(name = "coluserid")
|
||||
private Integer userid;
|
||||
|
||||
@Column(name = "workid")
|
||||
private Integer workId;
|
||||
|
||||
private Integer colstatus;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,6 @@ package com.fjy.spring.repository;
|
||||
import com.fjy.spring.domain.Homework;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface HomeworkRepository extends JpaRepository<Homework,Integer> {
|
||||
|
||||
public interface HomeworkRepository extends JpaRepository<Homework,Integer> {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.fjy.spring.repository;
|
||||
|
||||
import com.fjy.spring.domain.VWorkDetail;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface WorkDetailRepository extends JpaRepository<VWorkDetail,Integer> {
|
||||
}
|
||||
19
src/main/java/com/fjy/spring/service/HomeworkService.java
Normal file
19
src/main/java/com/fjy/spring/service/HomeworkService.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.fjy.spring.service;
|
||||
|
||||
import com.fjy.spring.domain.Homework;
|
||||
import com.fjy.spring.domain.VWorkDetail;
|
||||
import com.fjy.spring.repository.HomeworkRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class HomeworkService {
|
||||
@Autowired
|
||||
private HomeworkRepository homeworkRepository;
|
||||
|
||||
public List<Homework> findAll(){
|
||||
return homeworkRepository.findAll();
|
||||
}
|
||||
}
|
||||
18
src/main/java/com/fjy/spring/service/WorkDetailService.java
Normal file
18
src/main/java/com/fjy/spring/service/WorkDetailService.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.fjy.spring.service;
|
||||
|
||||
import com.fjy.spring.domain.VWorkDetail;
|
||||
import com.fjy.spring.repository.WorkDetailRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class WorkDetailService {
|
||||
@Autowired
|
||||
private WorkDetailRepository workDetailRepository;
|
||||
|
||||
public List<VWorkDetail> findAll(){
|
||||
return workDetailRepository.findAll();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user