master
bseayin 2019-08-19 20:53:28 +08:00
parent 88f7fd1ea5
commit d7138cd806
37 changed files with 287 additions and 369 deletions

View File

@ -0,0 +1,30 @@
package com.cy.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebAppConfig implements WebMvcConfigurer {
@Value("${imagesPath}")
private String mImagesPath;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
if(mImagesPath.equals("") || mImagesPath.equals("${imagesPath}")){
String imagesPath = WebAppConfig.class.getClassLoader().getResource("").getPath();
if(imagesPath.indexOf(".jar")>0){
imagesPath = imagesPath.substring(0, imagesPath.indexOf(".jar"));
}else if(imagesPath.indexOf("classes")>0){
imagesPath = "file:"+imagesPath.substring(0, imagesPath.indexOf("classes"));
}
imagesPath = imagesPath.substring(0, imagesPath.lastIndexOf("/"))+"/images/";
mImagesPath = imagesPath;
}
//LoggerFactory.getLogger(WebAppConfig.class).info("imagesPath="+mImagesPath);
registry.addResourceHandler("/homeworkrs/**").addResourceLocations(mImagesPath);
// TODO Auto-generated method stub
}
}

View File

@ -9,6 +9,8 @@ import com.cy.utils.KeyUtils;
import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -16,6 +18,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import java.io.*; import java.io.*;
import java.sql.Array; import java.sql.Array;
@ -34,6 +37,9 @@ public class HomeworkController {
@Resource @Resource
DTODao dd; DTODao dd;
@Value("${fileUpLoadPath}")
String filePath;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
@RequestMapping("showByType/{type}") @RequestMapping("showByType/{type}")
@ -122,9 +128,9 @@ public class HomeworkController {
String originalFilename = myFile.getOriginalFilename(); String originalFilename = myFile.getOriginalFilename();
int pos = originalFilename.lastIndexOf("."); int pos = originalFilename.lastIndexOf(".");
String suffix = originalFilename.substring(pos); String suffix = originalFilename.substring(pos);
String realPath = "D:/tmp";
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
String fullPath = realPath + File.separator + uuid + suffix; String fullPath = filePath + File.separator + uuid + suffix;
String homeworkid = File.separator + uuid + suffix; String homeworkid = File.separator + uuid + suffix;
InputStream in = null; InputStream in = null;
try { try {
@ -146,6 +152,28 @@ public class HomeworkController {
} }
@RequestMapping(value = "/download/{homeworkid}", method = RequestMethod.GET)
public void downLoad(@PathVariable("homeworkid") String homeworkid, HttpServletResponse response) {
List<Map<String, Object>> list = dd.queryfindhomework(homeworkid);
for (int i=0;i<list.size();i++){
String fileName = (String)list.get(i).get("homeworkid");
String fullPath = filePath + File.separator + fileName;
response.setContentType("application/force-download");
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);// 设置文件名;
//response.setHeader("Content-Disposition", "attachment;filename="+new String(fileName.getBytes("GBK"),"ISO-8859-1"));
try {
File downloadFile = new File(fullPath);
FileInputStream inputStream = new FileInputStream(downloadFile);
IOUtils.copy(inputStream, response.getOutputStream());
response.flushBuffer();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@RequestMapping("saveDetails/{uid}/{hid}/{result}") @RequestMapping("saveDetails/{uid}/{hid}/{result}")
public Map saveDetails(@PathVariable("uid") String uid, @PathVariable("hid") String hid, @PathVariable("result") String homeworkid) { public Map saveDetails(@PathVariable("uid") String uid, @PathVariable("hid") String hid, @PathVariable("result") String homeworkid) {
Map map = new HashMap(); Map map = new HashMap();

View File

@ -52,8 +52,7 @@ public class UserController {
public User login(@RequestBody User user) { public User login(@RequestBody User user) {
String loginName = user.getUsername(); String loginName = user.getUsername();
String password = user.getPassword(); String password = user.getPassword();
String type = user.getType(); User user1 = us.findByNameAndPassword(loginName, password);
User user1 = us.findByNameAndPassword(loginName, password,type);
if (user1 != null) { if (user1 != null) {
return user1; return user1;
} else { } else {

View File

@ -6,9 +6,9 @@ public class HomeworkUserDTO {
private String id; private String id;
private String username; private String username;
private String hid; private String hid;
private String completeTime;
private Date completeTime;
private String status; private String status;
private String homeworkid;
public String getId() { public String getId() {
@ -37,11 +37,11 @@ public class HomeworkUserDTO {
public Date getCompleteTime() { public String getCompleteTime() {
return completeTime; return completeTime;
} }
public void setCompleteTime(Date completeTime) { public void setCompleteTime(String completeTime) {
this.completeTime = completeTime; this.completeTime = completeTime;
} }
@ -52,4 +52,12 @@ public class HomeworkUserDTO {
public void setStatus(String status) { public void setStatus(String status) {
this.status = status; this.status = status;
} }
public String getHomeworkid() {
return homeworkid;
}
public void setHomeworkid(String homeworkid) {
this.homeworkid = homeworkid;
}
} }

View File

@ -16,7 +16,7 @@ public class DTODao {
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
public List<Map<String, Object>> queryHomeworkUserDTOListMap(Homework homework) { public List<Map<String, Object>> queryHomeworkUserDTOListMap(Homework homework) {
String sql = "SELECT u.id,u.username,uh.h_id,uh.complete_time from `user` u LEFT JOIN user_homework uh on (u.id=uh.u_id and uh.h_id= ? )where u.type='student'"; String sql = "SELECT u.id,u.username,uh.h_id,uh.complete_time,uh.homeworkid from `user` u LEFT JOIN user_homework uh on (u.id=uh.u_id and uh.h_id= ? )where u.type='student'";
Object[] args = {homework.getId()}; Object[] args = {homework.getId()};
int[] argTypes = {Types.VARCHAR}; int[] argTypes = {Types.VARCHAR};
@ -52,10 +52,19 @@ public class DTODao {
} }
} }
public List<Map<String, Object>> queryfindexist(String uid, String hid) { public List<Map<String, Object>> queryfindhomework(String homeworkid) {
String sql = ("select * from user_homework where h_id=? AND u_id=?"); String sql = ("select * from user_homework where homeworkid=? ");
Object[] args = {hid, uid}; Object[] args = {homeworkid};
int[] argTypes = {Types.VARCHAR};
return this.jdbcTemplate.queryForList(sql, args,argTypes);
}
public List<Map<String, Object>> queryfindexit(String uid,String hid) {
String sql = ("select * from user_homework where u_id=? AND h_id=? ");
Object[] args = {uid,hid};
int[] argTypes = {Types.VARCHAR,Types.VARCHAR}; int[] argTypes = {Types.VARCHAR,Types.VARCHAR};
return this.jdbcTemplate.queryForList(sql, args,argTypes); return this.jdbcTemplate.queryForList(sql, args,argTypes);
} }
} }

View File

@ -9,5 +9,5 @@ import java.util.List;
public interface UserRepository extends JpaRepository<User,String> { public interface UserRepository extends JpaRepository<User,String> {
List<User> findByUsername(String username); List<User> findByUsername(String username);
User findByUsernameAndPasswordAndType(String username, String password,String type); User findByUsernameAndPassword(String username, String password);
} }

View File

@ -60,13 +60,14 @@ public class HomeworkService {
String id = (String) listmap.get(i).get("id"); String id = (String) listmap.get(i).get("id");
String username = (String) listmap.get(i).get("username"); String username = (String) listmap.get(i).get("username");
String hid = (String) listmap.get(i).get("hid"); String hid = (String) listmap.get(i).get("hid");
String homeworkid = (String) listmap.get(i).get("homeworkid");
try { try {
if (listmap.get(i).get("complete_time") != null) { if (listmap.get(i).get("complete_time") != null) {
Date completeTime = new Date(sdf.parse(listmap.get(i).get("complete_time").toString()).getTime()); Date completeTime = new Date(sdf.parse(listmap.get(i).get("complete_time").toString()).getTime());
hud.setCompleteTime(completeTime); hud.setCompleteTime(sdf.format(completeTime));
} else { } else {
Date completeTime = null;
hud.setCompleteTime(completeTime); hud.setCompleteTime("");
} }
} catch (ParseException e) { } catch (ParseException e) {
@ -75,13 +76,13 @@ public class HomeworkService {
hud.setId(id); hud.setId(id);
hud.setUsername(username); hud.setUsername(username);
hud.setHid(hid); hud.setHid(hid);
if (hud.getCompleteTime() == null) { hud.setHomeworkid(homeworkid);
if (hud.getCompleteTime() == "") {
hud.setStatus("未完成"); hud.setStatus("未完成");
} else { } else {
hud.setStatus("完成"); hud.setStatus("完成");
} }
ah.add(hud); ah.add(hud);
} }
return ah; return ah;
} }
@ -109,7 +110,9 @@ public class HomeworkService {
if (new Date(System.currentTimeMillis()).getTime() > list.get(0).getFinishTime().getTime()) { if (new Date(System.currentTimeMillis()).getTime() > list.get(0).getFinishTime().getTime()) {
rs = -1; rs = -1;
} else { } else {
if (dd.queryfindexist(uid, hid).size() > 0) { // dd.queryuploadDTOListMap(uid, hid, homeworkid,new Timestamp(new java.util.Date().getTime()));
// rs = 1;
if (dd.queryfindexit(uid,hid).size() > 0) {
dd.queryuploadDTOListMap2(uid, hid, homeworkid,new Timestamp(new java.util.Date().getTime())); dd.queryuploadDTOListMap2(uid, hid, homeworkid,new Timestamp(new java.util.Date().getTime()));
rs = 1; rs = 1;
} else { } else {
@ -119,4 +122,6 @@ public class HomeworkService {
} }
return rs; return rs;
} }
} }

View File

@ -23,8 +23,8 @@ public class UserService {
return ur.findByUsername(name); return ur.findByUsername(name);
} }
public User findByNameAndPassword(String name,String password,String type){ public User findByNameAndPassword(String name,String password){
return ur.findByUsernameAndPasswordAndType(name,password,type); return ur.findByUsernameAndPassword(name,password);
} }

View File

@ -0,0 +1,2 @@
fileUpLoadPath=C://tmp//
imagesPath=file:/C:/tmp/

View File

@ -0,0 +1,2 @@
fileUpLoadPath=/usr/lib
imagesPath=file://usr/lib/

View File

@ -1,8 +1,10 @@
server.port=9084 server.port=9084
server.servlet.context-path=/SpringBootHomework server.servlet.context-path=/hw
spring.datasource.url=jdbc:mysql://118.24.99.140:3306/zzty?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai spring.datasource.url=jdbc:mysql://118.24.99.140:3306/zzty?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=root spring.datasource.username=root
spring.datasource.password=Aa_114514 spring.datasource.password=Aa_114514
spring.jpa.database=MYSQL spring.jpa.database=MYSQL
spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update
spring.profiles.active=dev
#spring.profiles.active=prod

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<img src="images/15642347670392018.jpg">
<a href="images/1564233497341jquery-ui-1.11.1.zip">下载</a>
</body>
</html>

View File

@ -319,6 +319,34 @@
</div> </div>
</div> </div>
<div class="modal fade" id="detailmodal">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<!-- 模态框头部 -->
<div class="modal-header">
<h4 class="modal-title">内容</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<!-- 模态框主体 -->
<div class="modal-body ">
<a id ="downloadbody" style="height:300px;overflow:auto; "></a>
</div>
<!-- 模态框底部 -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
<!-- ============================================================== --> <!-- ============================================================== -->

View File

@ -194,7 +194,6 @@ $(document).ready(function () {
}) })
$("button[name='checkbtn']").click(function () { $("button[name='checkbtn']").click(function () {
var fmt = SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
$.getJSON("homework/showdetails/" + this.id, {"id": this.id}, function (json) { $.getJSON("homework/showdetails/" + this.id, {"id": this.id}, function (json) {
$("#dtbodybtn").empty(); $("#dtbodybtn").empty();
for (var i = 0; i < json.length; i++) { for (var i = 0; i < json.length; i++) {
@ -204,20 +203,37 @@ $(document).ready(function () {
+ "</td>" + "</td>"
+ "<td>" + json[i].username + "<td>" + json[i].username
+ "</td>" + "</td>"
+ "<td>" + fmt.format(json[i].completeTime) + "<td>" + json[i].completeTime
+ "</td>" + "</td>"
+ "<td>" + json[i].status + "<td>" + json[i].status
+ "</td>" + "</td>"
+ "<td><button type='button' class='btn btn-primary' name='detailmodalbtn' id='" + json[i].homeworkid + "'>查看</button></td>"
+ "<td><a href='"+"http://localhost:9084/hw/homeworkrs/"+json[i].homeworkid+"'>下载</a></td>"
+ "</tr>" + "</tr>"
) )
if (logintype == "student") {
$("button[name='detailmodalbtn']").attr("style", "display:none;");
}
$("button[name='detailmodalbtn']").click(function () {
$("#downloadbody").empty();
$('#modalhwdetail2').modal("hide");
$('#detailmodal').modal("show");
console.log(this.id);
$.get("homework/download/"+this.id,function (json) {
$("#downloadbody").append(json);
})
})
} }
}) })
$('#modalhwdetail2').modal("show"); $('#modalhwdetail2').modal("show");
}) })
$("button[name='uploadbtn']").click(function () { $("button[name='uploadbtn']").click(function () {
var hid = this.id; var hid = this.id;
var uid = loginid; var uid = loginid;
@ -234,15 +250,12 @@ $(document).ready(function () {
if (resp.result != null) { if (resp.result != null) {
$.getJSON("homework/saveDetails/" + uid + "/" + hid + "/" + resp.result, function (json) { $.getJSON("homework/saveDetails/" + uid + "/" + hid + "/" + resp.result, function (json) {
if ("outtime" == json.rs) { if ("outtime" == json.rs) {
alert("已超时");
} else if ("fail" == json.rs) { } else if ("fail" == json.rs) {
alert("失败");
} else { } else {
alert(" 添加成功"); alert("上传成功");
$('#modalhwdetail2').modal('hide'); window.location.href = "index4.html";
} }
}) })
} else { } else {
alert("上传失败"); alert("上传失败");
} }
@ -261,150 +274,10 @@ $(document).ready(function () {
var type = $("#searchtype").val(); var type = $("#searchtype").val();
var finishTime = $("#searchfinishTime").val(); var finishTime = $("#searchfinishTime").val();
getdata(0,type,finishTime); getdata(0,type,finishTime);
// $.getJSON("homework/showByTypeAndFinishTime", {type: type, finishTime: finishTime}, function (json) {
// $("#tbodymainbtn").empty();
// for (var i = 0; i < json.length; i++) {
// $("#tbodymainbtn").append(
// "<tr id='tridval" + i + "'>"
// + "<td>" + json[i].id
// + "</td>"
// + "<td>" + json[i].title
// + "</td>"
// + "<td>" + json[i].type
// + "</td>"
// + "<td>" + json[i].updateTime
// + "</td>"
// + "<td>" + json[i].finishTime
// + "</td>"
// + "<td><button type='button' class='btn btn-primary' name='changebtn' id='" + json[i].id + "'>编辑</button></td>"
// + "<td><button type='button' class='btn btn-primary' name='checkbtn' id='" + json[i].id + "'>查看</button></td>"
// + "<td><button type='button' class='btn btn-primary' name='deletebtn' id='" + json[i].id + "'>删除</button></td>"
// + "<td><button type='button' class='btn btn-primary' name='uploadbtn' id='" + json[i].id + "'>上传</button></td>"
// + "</tr>"
// );
// }
// if (logintype == "student") {
// $("button[name='changebtn']").attr("style", "display:none;");
// $("button[name='deletebtn']").attr("style", "display:none;");
// }
// $("button[name='changebtn']").click(function () {
// var id = this.id
// var fmt = SimpleDateFormat("yyyy-MM-dd");
// $.getJSON("homework/findAllById/" + id, {id: id}, function (js) {
// $("#changebtn").empty();
// $("#id").attr("value", js[0].id);
// $("#hwtitle").attr("value", js[0].title);
// $("#hwtype").attr("value", js[0].type);
// $("#hwupdateTime").attr("value", fmt.format(js[0].updateTime));
// $("#hwfinishTime").attr("value", fmt.format(js[0].finishTime));
// document.getElementById("hwdetails").innerHTML = js[0].details;
// $('#modalhwdetail').modal("show");
// $("button[name='btnn']").click(function () {
// var adata = {
// "id": $("#id").val(),
// "title": $("#hwtitle").val(),
// "type": $("#hwtype").val(),
// "updateTime": $("#hwupdateTime").val(),
// "finishTime": $("#hwfinishTime").val(),
// "details": $("#hwdetails").val()
// }
// var data = JSON.stringify(adata);
// $.ajax({
// type: "POST",
// contentType: "application/json",
// data: data,
// url: "homework/update",
// success: function (res) {
// if (res != "") {
// alert("修改成功");
// window.location.href = "index4.html";
// } else {
// alert("修改失败");
// window.location.href = "index4.html";
// }
// },
// error: function () {
// alert("失败");
// window.location.href = "index4.html";
// }
// });
// })
// })
// })
//
// $("button[name='deletebtn']").click(function () {
// var id = this.id;
// console.log(id);
// $.getJSON("homework/deleteById/" + id, {id: id}, function (rs) {
// if (rs.rs == 'success') {
// window.location.href = "index4.html";
// } else {
// alert("删除失败");
// window.location.href = "index4.html";
// }
// });
// })
//
// $("button[name='checkbtn']").click(function () {
// var fmt = SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// $.getJSON("homework/showdetails/" + this.id, {"id": this.id}, function (json) {
// $("#dtbodybtn").empty();
// for (var i = 0; i < json.length; i++) {
// $("#dtbodybtn").append(
// "<tr id='tridval" + i + "'>"
// + "<td>" + json[i].id
// + "</td>"
// + "<td>" + json[i].username
// + "</td>"
// + "<td>" + fmt.format(json[i].completeTime)
// + "</td>"
// + "<td>" + json[i].status
// + "</td>"
// + "</tr>"
// )
// }
//
// })
// $('#modalhwdetail2').modal("show");
//
//
// })
//
// $("button[name='uploadbtn']").click(function () {
// var hid = this.id;
// var uid = loginid;
// $('#uploadmodal').modal("show");
// $("button[name='uploadbtn2']").click(function () {
// var formData = new FormData(document.getElementById("upload-form"));
// $.ajax({
// url: "homework/upload",
// method: 'POST',
// data: formData,
// contentType: false,
// processData: false,
// success: function (resp) {
// if (resp.result != null) {
// $.getJSON("homework/saveDetails/" + uid + "/" + hid + "/" + resp.result, function (json) {
// if ("outtime" == json.rs) {
// alert("已超时");
// } else if ("fail" == json.rs) {
// alert("失败");
// } else {
// alert(" 添加成功");
// $('#modalhwdetail2').modal('hide');
// }
// })
//
// } else {
// alert("上传失败");
// }
// }
// });
//
// })
// })
// })
}) })
}) })

View File

@ -33,8 +33,7 @@ $(function () {
var adata = { var adata = {
"username": $("#name").val(), "username": $("#name").val(),
"password": $("#pwd").val(), "password": $("#pwd").val()
"type": $("#type").val()
} }
var data = JSON.stringify(adata); var data = JSON.stringify(adata);
$.ajax({ $.ajax({

View File

@ -32,13 +32,6 @@
<input type="password" class="lowin-input" id="pwd" name="userpwd" > <input type="password" class="lowin-input" id="pwd" name="userpwd" >
<p style="color:red;display: none" id="pwdp" >密码不为空</p> <p style="color:red;display: none" id="pwdp" >密码不为空</p>
</div> </div>
<div class="lowin-group">
<label>类型 </label>
<select class="lowin-input" name="type" id="type">
<option value='teacher'>教师</option>
<option value='student'>学生</option>
</select>
</div>
<br> <br>
<button type="button" class="lowin-btn login-btn" id="btn" name="btn"> <button type="button" class="lowin-btn login-btn" id="btn" name="btn">
登陆 登陆

View File

@ -0,0 +1,12 @@
package com.cy.repository;
import org.junit.Test;
import static org.junit.Assert.*;
public class DTODaoTest {
@Test
public void queryuploadDTOListMap() {
}
}

View File

@ -1,5 +1,5 @@
#Generated by Maven Integration for Eclipse #Generated by Maven Integration for Eclipse
#Sat Aug 17 21:27:10 CST 2019 #Mon Aug 19 19:59:23 CST 2019
version=0.0.1-SNAPSHOT version=0.0.1-SNAPSHOT
groupId=zz groupId=zz
m2e.projectName=SpringBootHomework m2e.projectName=SpringBootHomework

View File

@ -0,0 +1,2 @@
fileUpLoadPath=C://tmp//
imagesPath=file:/C:/tmp/

View File

@ -0,0 +1,2 @@
fileUpLoadPath=/usr/lib
imagesPath=file://usr/lib/

View File

@ -1,8 +1,10 @@
server.port=9084 server.port=9084
server.servlet.context-path=/SpringBootHomework server.servlet.context-path=/hw
spring.datasource.url=jdbc:mysql://118.24.99.140:3306/zzty?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai spring.datasource.url=jdbc:mysql://118.24.99.140:3306/zzty?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=root spring.datasource.username=root
spring.datasource.password=Aa_114514 spring.datasource.password=Aa_114514
spring.jpa.database=MYSQL spring.jpa.database=MYSQL
spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update
spring.profiles.active=dev
#spring.profiles.active=prod

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<img src="images/15642347670392018.jpg">
<a href="images/1564233497341jquery-ui-1.11.1.zip">下载</a>
</body>
</html>

View File

@ -319,6 +319,34 @@
</div> </div>
</div> </div>
<div class="modal fade" id="detailmodal">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<!-- 模态框头部 -->
<div class="modal-header">
<h4 class="modal-title">内容</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<!-- 模态框主体 -->
<div class="modal-body ">
<a id ="downloadbody" style="height:300px;overflow:auto; "></a>
</div>
<!-- 模态框底部 -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
<!-- ============================================================== --> <!-- ============================================================== -->

View File

@ -194,7 +194,6 @@ $(document).ready(function () {
}) })
$("button[name='checkbtn']").click(function () { $("button[name='checkbtn']").click(function () {
var fmt = SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
$.getJSON("homework/showdetails/" + this.id, {"id": this.id}, function (json) { $.getJSON("homework/showdetails/" + this.id, {"id": this.id}, function (json) {
$("#dtbodybtn").empty(); $("#dtbodybtn").empty();
for (var i = 0; i < json.length; i++) { for (var i = 0; i < json.length; i++) {
@ -204,20 +203,37 @@ $(document).ready(function () {
+ "</td>" + "</td>"
+ "<td>" + json[i].username + "<td>" + json[i].username
+ "</td>" + "</td>"
+ "<td>" + fmt.format(json[i].completeTime) + "<td>" + json[i].completeTime
+ "</td>" + "</td>"
+ "<td>" + json[i].status + "<td>" + json[i].status
+ "</td>" + "</td>"
+ "<td><button type='button' class='btn btn-primary' name='detailmodalbtn' id='" + json[i].homeworkid + "'>查看</button></td>"
+ "<td><a href='"+"http://localhost:9084/hw/homeworkrs/"+json[i].homeworkid+"'>下载</a></td>"
+ "</tr>" + "</tr>"
) )
if (logintype == "student") {
$("button[name='detailmodalbtn']").attr("style", "display:none;");
}
$("button[name='detailmodalbtn']").click(function () {
$("#downloadbody").empty();
$('#modalhwdetail2').modal("hide");
$('#detailmodal').modal("show");
console.log(this.id);
$.get("homework/download/"+this.id,function (json) {
$("#downloadbody").append(json);
})
})
} }
}) })
$('#modalhwdetail2').modal("show"); $('#modalhwdetail2').modal("show");
}) })
$("button[name='uploadbtn']").click(function () { $("button[name='uploadbtn']").click(function () {
var hid = this.id; var hid = this.id;
var uid = loginid; var uid = loginid;
@ -234,15 +250,12 @@ $(document).ready(function () {
if (resp.result != null) { if (resp.result != null) {
$.getJSON("homework/saveDetails/" + uid + "/" + hid + "/" + resp.result, function (json) { $.getJSON("homework/saveDetails/" + uid + "/" + hid + "/" + resp.result, function (json) {
if ("outtime" == json.rs) { if ("outtime" == json.rs) {
alert("已超时");
} else if ("fail" == json.rs) { } else if ("fail" == json.rs) {
alert("失败");
} else { } else {
alert(" 添加成功"); alert("上传成功");
$('#modalhwdetail2').modal('hide'); window.location.href = "index4.html";
} }
}) })
} else { } else {
alert("上传失败"); alert("上传失败");
} }
@ -261,150 +274,10 @@ $(document).ready(function () {
var type = $("#searchtype").val(); var type = $("#searchtype").val();
var finishTime = $("#searchfinishTime").val(); var finishTime = $("#searchfinishTime").val();
getdata(0,type,finishTime); getdata(0,type,finishTime);
// $.getJSON("homework/showByTypeAndFinishTime", {type: type, finishTime: finishTime}, function (json) {
// $("#tbodymainbtn").empty();
// for (var i = 0; i < json.length; i++) {
// $("#tbodymainbtn").append(
// "<tr id='tridval" + i + "'>"
// + "<td>" + json[i].id
// + "</td>"
// + "<td>" + json[i].title
// + "</td>"
// + "<td>" + json[i].type
// + "</td>"
// + "<td>" + json[i].updateTime
// + "</td>"
// + "<td>" + json[i].finishTime
// + "</td>"
// + "<td><button type='button' class='btn btn-primary' name='changebtn' id='" + json[i].id + "'>编辑</button></td>"
// + "<td><button type='button' class='btn btn-primary' name='checkbtn' id='" + json[i].id + "'>查看</button></td>"
// + "<td><button type='button' class='btn btn-primary' name='deletebtn' id='" + json[i].id + "'>删除</button></td>"
// + "<td><button type='button' class='btn btn-primary' name='uploadbtn' id='" + json[i].id + "'>上传</button></td>"
// + "</tr>"
// );
// }
// if (logintype == "student") {
// $("button[name='changebtn']").attr("style", "display:none;");
// $("button[name='deletebtn']").attr("style", "display:none;");
// }
// $("button[name='changebtn']").click(function () {
// var id = this.id
// var fmt = SimpleDateFormat("yyyy-MM-dd");
// $.getJSON("homework/findAllById/" + id, {id: id}, function (js) {
// $("#changebtn").empty();
// $("#id").attr("value", js[0].id);
// $("#hwtitle").attr("value", js[0].title);
// $("#hwtype").attr("value", js[0].type);
// $("#hwupdateTime").attr("value", fmt.format(js[0].updateTime));
// $("#hwfinishTime").attr("value", fmt.format(js[0].finishTime));
// document.getElementById("hwdetails").innerHTML = js[0].details;
// $('#modalhwdetail').modal("show");
// $("button[name='btnn']").click(function () {
// var adata = {
// "id": $("#id").val(),
// "title": $("#hwtitle").val(),
// "type": $("#hwtype").val(),
// "updateTime": $("#hwupdateTime").val(),
// "finishTime": $("#hwfinishTime").val(),
// "details": $("#hwdetails").val()
// }
// var data = JSON.stringify(adata);
// $.ajax({
// type: "POST",
// contentType: "application/json",
// data: data,
// url: "homework/update",
// success: function (res) {
// if (res != "") {
// alert("修改成功");
// window.location.href = "index4.html";
// } else {
// alert("修改失败");
// window.location.href = "index4.html";
// }
// },
// error: function () {
// alert("失败");
// window.location.href = "index4.html";
// }
// });
// })
// })
// })
//
// $("button[name='deletebtn']").click(function () {
// var id = this.id;
// console.log(id);
// $.getJSON("homework/deleteById/" + id, {id: id}, function (rs) {
// if (rs.rs == 'success') {
// window.location.href = "index4.html";
// } else {
// alert("删除失败");
// window.location.href = "index4.html";
// }
// });
// })
//
// $("button[name='checkbtn']").click(function () {
// var fmt = SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// $.getJSON("homework/showdetails/" + this.id, {"id": this.id}, function (json) {
// $("#dtbodybtn").empty();
// for (var i = 0; i < json.length; i++) {
// $("#dtbodybtn").append(
// "<tr id='tridval" + i + "'>"
// + "<td>" + json[i].id
// + "</td>"
// + "<td>" + json[i].username
// + "</td>"
// + "<td>" + fmt.format(json[i].completeTime)
// + "</td>"
// + "<td>" + json[i].status
// + "</td>"
// + "</tr>"
// )
// }
//
// })
// $('#modalhwdetail2').modal("show");
//
//
// })
//
// $("button[name='uploadbtn']").click(function () {
// var hid = this.id;
// var uid = loginid;
// $('#uploadmodal').modal("show");
// $("button[name='uploadbtn2']").click(function () {
// var formData = new FormData(document.getElementById("upload-form"));
// $.ajax({
// url: "homework/upload",
// method: 'POST',
// data: formData,
// contentType: false,
// processData: false,
// success: function (resp) {
// if (resp.result != null) {
// $.getJSON("homework/saveDetails/" + uid + "/" + hid + "/" + resp.result, function (json) {
// if ("outtime" == json.rs) {
// alert("已超时");
// } else if ("fail" == json.rs) {
// alert("失败");
// } else {
// alert(" 添加成功");
// $('#modalhwdetail2').modal('hide');
// }
// })
//
// } else {
// alert("上传失败");
// }
// }
// });
//
// })
// })
// })
}) })
}) })

View File

@ -33,8 +33,7 @@ $(function () {
var adata = { var adata = {
"username": $("#name").val(), "username": $("#name").val(),
"password": $("#pwd").val(), "password": $("#pwd").val()
"type": $("#type").val()
} }
var data = JSON.stringify(adata); var data = JSON.stringify(adata);
$.ajax({ $.ajax({

View File

@ -20,7 +20,7 @@
<div class="lowin-box lowin-login"> <div class="lowin-box lowin-login">
<div class="lowin-box-inner"> <div class="lowin-box-inner">
<form> <form>
<p>Sign in to continue</p> <p>登录</p>
<div class="lowin-group"> <div class="lowin-group">
<label>用户名 <a href="#" class="login-back-link">Sign in?</a></label> <label>用户名 <a href="#" class="login-back-link">Sign in?</a></label>
<input type="text" class="lowin-input" id="name" name="username" > <input type="text" class="lowin-input" id="name" name="username" >