2121import java .io .FileInputStream ;
2222import java .io .InputStream ;
2323import java .nio .charset .StandardCharsets ;
24+ import java .text .DateFormat ;
25+ import java .text .SimpleDateFormat ;
2426import java .util .*;
2527import java .util .zip .ZipEntry ;
2628import java .util .zip .ZipOutputStream ;
3436@ Controller
3537public 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 }
0 commit comments