Ver Fonte

完善 /papers 页面

insomniaLee há 5 anos atrás
pai
commit
7ec98cf2ae

+ 10 - 0
src/main/java/com/mooctest/controller/PaperController.java

@@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import java.sql.Timestamp;
+
 @Controller
 public class PaperController {
 
@@ -43,6 +45,10 @@ public class PaperController {
     @GetMapping("/papers")
     public String auditTask ( Model model){
         JSONArray jsonArray = paperService.getPaperData(); // 所有的数据。
+        for (Object single : jsonArray){
+            single = (JSONObject) single;
+            changeTime2Long(single); // 修改创建时间的格式  以便前段展示
+        }
         model.addAttribute("tasks",jsonArray);
         return "paper_list";
     }
@@ -73,4 +79,8 @@ public class PaperController {
 //        JSONObject res = auditTaskService.getSingleTask(id);
 //        return res;
 //    }
+private void changeTime2Long ( Object input){
+    JSONObject temp = (JSONObject) input;
+    temp.put("create_time",new Timestamp(Long.parseLong(temp.get("create_time").toString()))); // 修改创建时间的格式  以便前段展示
+}
 }

+ 7 - 2
src/main/resources/templates/paper_list.html

@@ -121,7 +121,11 @@
                         <td><span  class="label label-info" th:text="${task.get('type')}" ></span></td>
                         <!--                        <td><span  class="label label-info" th:text="${task.caseId}">题号</span></td>-->
 
-                        <td><span  class=" " th:text="${task.get('create_time')}" ></span></td>
+                        <td>
+                            <span  class=" " th:if="${task.get('create_time')!=null}" th:text="${#dates.format(task.get('create_time'),'yyyy-MM-dd HH:mm:ss')} " ></span>
+
+<!--                            <span  class=" " th:text="${task.get('create_time')}" ></span>-->
+                        </td>
                         <td>
                             <button th:onclick="'showYulan( \''+${task.get('id')}+'\' )'" class="btn btn-default">预览</button>
                             <a type="button" class="btn btn-default" th:href="'/changePaper?id='+${task.get('id')}">修改</a>
@@ -157,7 +161,8 @@
 
         var taskListTable = $('#task-list').DataTable({
             searching: true,
-            pageLength: 25
+            pageLength: 25,
+            "order": []
         });
     });