|
@@ -9,17 +9,21 @@ package cn.com.qmth.examcloud.app.controller;
|
|
|
|
|
|
import cn.com.qmth.examcloud.app.model.DeviceRecord;
|
|
|
import cn.com.qmth.examcloud.app.model.DeviceRecordQuery;
|
|
|
+import cn.com.qmth.examcloud.app.model.LoginInfo;
|
|
|
import cn.com.qmth.examcloud.app.model.Result;
|
|
|
import cn.com.qmth.examcloud.app.service.DeviceRecordService;
|
|
|
+import cn.com.qmth.examcloud.app.service.UserAuthService;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.ui.Model;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import static cn.com.qmth.examcloud.app.model.Constants.PARAM_KEY;
|
|
|
+import static cn.com.qmth.examcloud.app.model.Constants.PARAM_TOKEN;
|
|
|
|
|
|
/**
|
|
|
* 设备访问记录Controller
|
|
@@ -30,15 +34,28 @@ public class DeviceRecordController {
|
|
|
private static Logger log = LoggerFactory.getLogger(DeviceRecordController.class);
|
|
|
@Autowired
|
|
|
private DeviceRecordService deviceRecordService;
|
|
|
+ @Autowired
|
|
|
+ private UserAuthService userAuthService;
|
|
|
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
|
- public String list() {
|
|
|
+ public String list(@RequestParam String key, @RequestParam String token, Model model) throws Exception {
|
|
|
+ model.addAttribute(PARAM_KEY, key);
|
|
|
+ model.addAttribute(PARAM_TOKEN, token);
|
|
|
return "deviceRecord/list";
|
|
|
}
|
|
|
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.POST)
|
|
|
- public Result<Page<DeviceRecord>> list(@RequestBody(required = false) DeviceRecordQuery params) throws Exception {
|
|
|
+ public Result<Page<DeviceRecord>> list(@RequestBody(required = false) DeviceRecordQuery params,
|
|
|
+ @RequestParam(required = false) String key,
|
|
|
+ @RequestParam(required = false) String token) throws Exception {
|
|
|
+ if (StringUtils.isBlank(key) || StringUtils.isBlank(token)) {
|
|
|
+ throw new IllegalArgumentException("[Param] key or token must be not null.");
|
|
|
+ }
|
|
|
+ /*LoginInfo loginInfo = userAuthService.getLoginInfo(key);
|
|
|
+ if (loginInfo == null || !token.equals(loginInfo.getToken())) {
|
|
|
+ throw new IllegalArgumentException("[Param] key or token is wrong.");
|
|
|
+ }*/
|
|
|
return deviceRecordService.getDeviceRecordList(params);
|
|
|
}
|
|
|
|