Skip to content
This repository was archived by the owner on Mar 4, 2022. It is now read-only.

Commit 903dd3f

Browse files
author
itning
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # pom.xml
2 parents 9f4d1b7 + b913f92 commit 903dd3f

36 files changed

Lines changed: 896 additions & 192 deletions

README.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,25 @@
1313
[![HitCount](http://hits.dwyl.io/itning/Student-Homework-Management-System.svg)](http://hits.dwyl.io/itning/Student-Homework-Management-System)
1414
[![language](https://img.shields.io/badge/language-JAVA-green.svg)](https://github.com/itning/Student-Homework-Management-System)
1515

16-
**实现功能:**
17-
18-
学生上传文件到系统中,后台统一命名存储文件,管理员登陆后可以批量下载后台打包过后的文件。
16+
### 原本功能
17+
18+
1. 管理员在后台数据库中准备好学生学号(10位)后,学生可以用学号登录系统,首次登录需要自行设置密码(大于8位)
19+
2. 学生可以上传文件到系统中,上传功能基于bootstrap-fileinput
20+
3. 后台统一命名存储文件
21+
4. 管理员登陆后可以批量下载后台打包过后的文件
22+
23+
### 新增功能
24+
25+
by tomriddle_1234
26+
1. 添加截止时间设置,截止时间过后学生无法上传作业
27+
```
28+
ALTER TABLE `shw`.`orderinfo`
29+
ADD COLUMN `odeadline` DATETIME NOT NULL DEFAULT '2022-01-01 00:00:00' AFTER `otime`;
30+
```
31+
2. 管理员删除作业任务时,增加确认对话框
32+
3. 一些界面的小优化
33+
4. 添加编辑作业任务功能
34+
5. 作业名称可以用[]()添加链接
1935
2036
## 架构
2137
@@ -24,6 +40,8 @@
2440
1. jQuery
2541
2. Bootstrap3
2642
3. Bootstrap-fileinput
43+
4. moment.js
44+
5. bootstrap-datepicker (bootstrap 3 v4)
2745
2846
### 后端
2947
@@ -75,11 +93,16 @@
7593
[官方下载互联SDK](http://qzonestyle.gtimg.cn/qzone/vas/opensns/res/doc/qqConnect_Server_SDK_java_v2.0.zip)
7694
7795
```shell
78-
mvn install:install-file -Dfile=D:\a.jar -DgroupId=com.qq.connect -DartifactId=qq-connect -Dversion=2.0.0.RELEASE -Dpackaging=jar
96+
mvn install:install-file -Dfile=<path_to_your_manually_downloaded_jar_file>.jar -DgroupId=com.qq.connect -DartifactId=qq-connect -Dversion=2.0.0.RELEASE -Dpackaging=jar
7997
```
8098

8199
6. 运行
82100

101+
```
102+
mvn install
103+
mvn package
104+
```
105+
83106
项目使用的Tomcat版本为8.5.20,你最好与我同步。[下载该版本](https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.20/bin/)
84107

85108
7. 查看Druid管理面板
@@ -135,6 +158,7 @@
135158
`osubject` varchar(255) NOT NULL,
136159
`ostate` bit(1) NOT NULL,
137160
`otime` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP,
161+
`odeadline` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP,
138162
PRIMARY KEY (`oid`)
139163
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
140164

@@ -175,6 +199,6 @@
175199

176200
![上传界面](https://raw.githubusercontent.com/itning/Student-Homework-Management-System/master/pic/sahngchuan.png)
177201

178-
![添加科目](https://raw.githubusercontent.com/itning/Student-Homework-Management-System/master/pic/addkemu.png)
202+
![添加课程](https://raw.githubusercontent.com/itning/Student-Homework-Management-System/master/pic/addkemu.png)
179203

180204
![druid](https://raw.githubusercontent.com/itning/Student-Homework-Management-System/master/pic/druid.png)

src/main/java/com/ning/admin/action/AdminAction.java

Lines changed: 71 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import java.io.FileInputStream;
2222
import java.io.InputStream;
2323
import java.nio.charset.StandardCharsets;
24+
import java.text.DateFormat;
25+
import java.text.SimpleDateFormat;
2426
import java.util.*;
2527
import java.util.zip.ZipEntry;
2628
import java.util.zip.ZipOutputStream;
@@ -34,7 +36,7 @@
3436
@Controller
3537
public class AdminAction {
3638
/**
37-
* 科目批次状态名
39+
* 课程名称状态名
3840
*/
3941
private static final String O_STATE = "ostate";
4042

@@ -62,10 +64,10 @@ public String admin(Model model) {
6264
}
6365

6466
/**
65-
* 根据科目名查找所有科目信息
67+
* 根据课程名查找所有课程信息
6668
*
67-
* @param subject 科目名
68-
* @return 所有科目信息集合
69+
* @param subject 课程名
70+
* @return 所有课程信息集合
6971
* @throws Exception Exception
7072
*/
7173
@RequestMapping("getOnameBysubjectOfAll")
@@ -96,7 +98,7 @@ public String subjectui(Model model) {
9698
* 获取已上传文件列表方法
9799
* 管理员权限访问
98100
*
99-
* @param hoid 作业批次ID
101+
* @param hoid 作业名称ID
100102
* @param model 模型
101103
* @param session HttpSession
102104
* @return jsp/downfileui.jsp
@@ -132,7 +134,10 @@ public void downAllFile(HttpServletResponse response, HttpSession session) throw
132134
throw new FileException("下载失败:未找到数据!");
133135
}
134136
OrderInfo orderInfo = fileService.getOrderInfoEntityByOID(fileListByHoid.get(0).getHoid());
135-
String zipfilename = orderInfo.getOsubject() + orderInfo.getOname();
137+
138+
String filteredOname = PropertiesUtil.filterOutUrl(orderInfo.getOname());
139+
String zipfilename = orderInfo.getOsubject() + "_" + filteredOname;
140+
136141
List<String> filesname = new ArrayList<>(fileListByHoid.size());
137142
for (History history : fileListByHoid) {
138143
filesname.add(history.getFilepath());
@@ -150,11 +155,29 @@ public void downAllFile(HttpServletResponse response, HttpSession session) throw
150155
zipOut.close();
151156
}
152157

158+
// 更改截止时间
159+
160+
@RequestMapping("updateDeadlineByOID")
161+
@RequiresPermissions("admin")
162+
public @ResponseBody
163+
Boolean updateDeadlineByOID(Integer oid, Date deadlineDate) throws Exception{
164+
if (oid == null || deadlineDate == null){
165+
throw new FileException("更改失败:参数不正确");
166+
}
167+
168+
Map<String, Object> map = new HashMap<>(2);
169+
map.put("odeadline", deadlineDate);
170+
map.put("oid", oid);
171+
172+
adminService.updateDeadlineByOID(map);
173+
return true;
174+
}
175+
153176
/**
154-
* 更改科目批次启用状态
177+
* 更改课程名称启用状态
155178
* 该方法需要管理员权限
156179
*
157-
* @param oid 科目批次ID
180+
* @param oid 课程名称ID
158181
* @param key key
159182
* @param value value
160183
* @return 更改是否成功
@@ -178,11 +201,38 @@ Boolean changeKeyByOID(Integer oid, String key, String value) throws Exception {
178201
return true;
179202
}
180203

204+
205+
@RequestMapping("updateOrderByOID")
206+
@RequiresPermissions("admin")
207+
public @ResponseBody
208+
Boolean updateOrderByOID(Integer oid, String osubject, String oname, String ostate, String odeadlinestr) throws Exception{
209+
210+
if (oid == null ||
211+
osubject == null || "".equals(osubject) ||
212+
oname == null || "".equals(oname) ||
213+
ostate == null || "".equals(ostate) ||
214+
odeadlinestr == null || "".equals(odeadlinestr)) {
215+
throw new FileException("更改失败:参数不正确");
216+
}
217+
218+
Map<String, Object> map = new HashMap<>(6);
219+
map.put("oid", oid);
220+
map.put("osubject", osubject);
221+
map.put("oname", oname);
222+
map.put("ostate", Boolean.parseBoolean(ostate));
223+
map.put("otime", new Date());
224+
225+
map.put("odeadline", new Date(Long.parseLong(odeadlinestr) * 1000));
226+
227+
adminService.updateOrderByOID(map);
228+
return true;
229+
}
230+
181231
/**
182-
* 根据批次ID删除批次
232+
* 根据名称ID删除名称
183233
* 该方法需要管理员权限
184234
*
185-
* @param oid 批次ID
235+
* @param oid 名称ID
186236
* @return ResponseBody 是否删除成功
187237
* @throws Exception Exception
188238
*/
@@ -198,10 +248,10 @@ Boolean delOrderinfoByOID(Integer oid) throws Exception {
198248
}
199249

200250
/**
201-
* 添加科目批次信息
251+
* 添加课程名称信息
202252
* 该方法需要管理员权限
203253
*
204-
* @param orderInfo 科目批次实体
254+
* @param orderInfo 课程名称实体
205255
* @return 是否添加成功
206256
* @throws Exception Exception
207257
*/
@@ -221,9 +271,18 @@ Boolean addOrderInfo(OrderInfo orderInfo) throws Exception {
221271
if (orderInfo.getOstate() == null) {
222272
return false;
223273
}
274+
if (orderInfo.getOdeadlinestr() == null){
275+
return false;
276+
}
277+
278+
// here is problem, could get negative result because oname too long and causing overflow
279+
// this is fine for MySQL, should be fine for url encoding, change it is easy but maybe not necessary
224280
int oid = (orderInfo.getOname().hashCode()) + (orderInfo.getOsubject().hashCode());
281+
225282
orderInfo.setOid(oid);
226283
orderInfo.setOtime(new Date());
284+
285+
orderInfo.setOdeadlineFromStr(orderInfo.getOdeadlinestr());
227286
adminService.addOrderInfo(orderInfo);
228287
return true;
229288
}

src/main/java/com/ning/admin/service/AdminService.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.ning.file.entity.History;
44
import com.ning.file.entity.OrderInfo;
55

6+
import java.util.Date;
67
import java.util.List;
78
import java.util.Map;
89

@@ -23,30 +24,36 @@ public interface AdminService {
2324
List<History> findFileListByHoid(Integer hoid);
2425

2526
/**
26-
* 获取所有科目批次信息
27+
* 获取所有课程名称信息
2728
*
28-
* @return 所有科目批次信息集合
29+
* @return 所有课程名称信息集合
2930
*/
3031
List<OrderInfo> getOrderInfoEntity();
3132

33+
34+
35+
void updateDeadlineByOID(Map<String, Object> map);
36+
3237
/**
3338
* 更新状态
3439
*
3540
* @param map map
3641
*/
3742
void changeKeyByOID(Map<String, Object> map);
3843

44+
void updateOrderByOID(Map<String, Object> map);
45+
3946
/**
40-
* 添加科目批次
47+
* 添加课程名称
4148
*
42-
* @param orderInfo 科目批次实体
49+
* @param orderInfo 课程名称实体
4350
*/
4451
void addOrderInfo(OrderInfo orderInfo);
4552

4653
/**
47-
* 删除科目批次
54+
* 删除课程名称
4855
*
49-
* @param oid 科目批次ID
56+
* @param oid 课程名称ID
5057
*/
5158
void delOrderinfoByOID(Integer oid);
5259

@@ -59,9 +66,9 @@ public interface AdminService {
5966
List<History> getAllUploadedByHoid(int hoid);
6067

6168
/**
62-
* 根据批次ID删除批次
69+
* 根据名称ID删除名称
6370
*
64-
* @param oid 批次ID
71+
* @param oid 名称ID
6572
* @throws Exception Exception
6673
*/
6774
void delOrderInfosAndFilesByOID(int oid) throws Exception;

src/main/java/com/ning/admin/service/impl/AdminServiceImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import javax.annotation.Resource;
1515
import java.io.File;
1616
import java.util.ArrayList;
17+
import java.util.Date;
1718
import java.util.List;
1819
import java.util.Map;
1920

@@ -48,11 +49,17 @@ public List<OrderInfo> getOrderInfoEntity() {
4849
return orderInfoDao.getOrderInfoEntity();
4950
}
5051

52+
@Override
53+
public void updateDeadlineByOID(Map<String, Object> map) { orderInfoDao.updateDeadlineByOID(map);}
54+
5155
@Override
5256
public void changeKeyByOID(Map<String, Object> map) {
5357
orderInfoDao.changeKeyByOID(map);
5458
}
5559

60+
@Override
61+
public void updateOrderByOID(Map<String, Object> map) { orderInfoDao.updateOrderByOID(map);}
62+
5663
@Override
5764
public void addOrderInfo(OrderInfo orderInfo) {
5865
orderInfoDao.addOrderInfo(orderInfo);
@@ -105,7 +112,7 @@ public void delOrderInfosAndFilesByOID(int oid) throws Exception {
105112
}
106113
//删除历史记录
107114
fileService.delEntityByHOID(oid);
108-
//删除科目
115+
//删除课程
109116
this.delOrderinfoByOID(oid);
110117
}
111118
}

src/main/java/com/ning/file/action/FileAction.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.ning.util.properties.PropertiesUtil;
1111
import org.apache.commons.io.IOUtils;
1212
import org.apache.shiro.SecurityUtils;
13+
import org.aspectj.weaver.ast.Or;
1314
import org.springframework.beans.propertyeditors.CustomDateEditor;
1415
import org.springframework.stereotype.Controller;
1516
import org.springframework.ui.Model;
@@ -75,6 +76,11 @@ public String index(Model model) {
7576
}
7677
//用户上传历史实体
7778
List<History> userHistoryList = fileService.getUserHistoryByUserId(user.getUid());
79+
80+
//Student浏览区数据
81+
// orderInfoList already filtered with state
82+
model.addAttribute("orderInfoStudentFullList", fileService.getOrderInfoFullEntity());
83+
7884
//下拉框数据
7985
model.addAttribute("orderInfoList", fileService.getOrderInfoEntity());
8086
model.addAttribute("user", user);
@@ -147,10 +153,10 @@ public String cpasswd(Model model) {
147153
}
148154

149155
/**
150-
* 根据科目名查找所有科目作业信息
156+
* 根据课程名查找所有课程作业信息
151157
*
152-
* @param subject 科目名
153-
* @return 科目作业信息集合
158+
* @param subject 课程名
159+
* @return 课程作业信息集合
154160
* @throws Exception Exception
155161
*/
156162
@RequestMapping("getOnameBysubject")
@@ -184,9 +190,9 @@ public String upfileByID(MultipartFile[] file) throws Exception {
184190
}
185191

186192
/**
187-
* 设置用户选择上传的科目ID
193+
* 设置用户选择上传的课程ID
188194
*
189-
* @param userSelectOid 科目批次ID
195+
* @param userSelectOid 课程名称ID
190196
* @return 设置成功返回<code>true</code>
191197
*/
192198
@RequestMapping("userselect")
@@ -220,7 +226,7 @@ public boolean delEntityByHID(String delHid) throws Exception {
220226
/**
221227
* 下载作业
222228
*
223-
* @param hid 科目批次ID
229+
* @param hid 课程名称ID
224230
* @param response {@link HttpServletResponse}
225231
* @throws Exception Exception
226232
*/

0 commit comments

Comments
 (0)