|
@@ -2,17 +2,12 @@ package cn.com.qmth.examcloud.core.questions.api.controller;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.UserCloudService;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.request.GetUserReq;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.response.GetUserResp;
|
|
|
import cn.com.qmth.examcloud.core.questions.service.CopyDataService;
|
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
@@ -20,37 +15,30 @@ import cn.com.qmth.examcloud.web.support.ServletUtil;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("${api_cqb}/copy")
|
|
|
-public class CopyDataController extends ControllerSupport{
|
|
|
- private static int cacheLockTimeout=60*10;
|
|
|
+public class CopyDataController extends ControllerSupport {
|
|
|
+ private static int cacheLockTimeout = 60 * 10;
|
|
|
@Autowired
|
|
|
private CopyDataService copyDataService;
|
|
|
@Autowired
|
|
|
- private UserCloudService userCloudService;
|
|
|
- @Autowired
|
|
|
private RedisClient redisClient;
|
|
|
-
|
|
|
+
|
|
|
+ //西交大数据复制
|
|
|
@GetMapping("data")
|
|
|
- public void copyData(HttpServletResponse response, @RequestParam Long fromRootOrgId,
|
|
|
- @RequestParam Long toRootOrgId) {
|
|
|
- if(!isSuperAdmin()) {
|
|
|
+ public void copyData(HttpServletResponse response) {
|
|
|
+ Long fromRootOrgId = 371L;
|
|
|
+ Long toRootOrgId = 21595L;
|
|
|
+ User user = getAccessUser();
|
|
|
+ if (user.getRootOrgId().equals(toRootOrgId)) {
|
|
|
ServletUtil.returnJson("请求失败,没有权限", response);
|
|
|
return;
|
|
|
}
|
|
|
String cacheLock = "$_COPY_QUESTION_DATA_LOCK";
|
|
|
- Boolean lock = redisClient.setIfAbsent(cacheLock, cacheLock, cacheLockTimeout);
|
|
|
- if (!lock) {
|
|
|
- ServletUtil.returnJson("请求失败,正在处理数据", response);
|
|
|
+ Boolean lock = redisClient.setIfAbsent(cacheLock, cacheLock, cacheLockTimeout);
|
|
|
+ if (!lock) {
|
|
|
+ ServletUtil.returnJson("请求失败,正在处理数据", response);
|
|
|
return;
|
|
|
- }
|
|
|
- GetUserReq req=new GetUserReq();
|
|
|
- req.setUserId(1L);
|
|
|
- GetUserResp rs=userCloudService.getUser(req);
|
|
|
- if(rs.getUserBean()==null) {
|
|
|
- ServletUtil.returnJson("请求失败,未找到用户信息", response);
|
|
|
- }
|
|
|
- User user=new User();
|
|
|
- BeanUtils.copyProperties(rs.getUserBean(), user);
|
|
|
- copyDataService.copyData(user,fromRootOrgId, toRootOrgId);
|
|
|
+ }
|
|
|
+ copyDataService.copyData(getAccessUser(), fromRootOrgId, toRootOrgId);
|
|
|
ServletUtil.returnJson("请求成功", response);
|
|
|
}
|
|
|
|