|
@@ -1,19 +1,28 @@
|
|
package com.ym.controller;
|
|
package com.ym.controller;
|
|
|
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
|
+import com.ym.pojo.HereWhite;
|
|
import com.ym.service.HereWhiteService;
|
|
import com.ym.service.HereWhiteService;
|
|
|
|
+import freemarker.cache.StringTemplateLoader;
|
|
|
|
+import org.apache.commons.lang3.RandomStringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
+
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/hereWhite")
|
|
@RequestMapping("/hereWhite")
|
|
public class HereWhiteController extends BaseController {
|
|
public class HereWhiteController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private HereWhiteService hereWhiteService;
|
|
private HereWhiteService hereWhiteService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private RedisTemplate<String,String> redisTemplate;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 创建白板,默认全部采用零时白板
|
|
* 创建白板,默认全部采用零时白板
|
|
@@ -28,7 +37,12 @@ public class HereWhiteController extends BaseController {
|
|
if(StringUtils.isEmpty(name) || userNum == null || courseScheduleId == null){
|
|
if(StringUtils.isEmpty(name) || userNum == null || courseScheduleId == null){
|
|
return failed("参数校验失败");
|
|
return failed("参数校验失败");
|
|
}
|
|
}
|
|
- return succeed(hereWhiteService.create(name, userNum,courseScheduleId));
|
|
|
|
|
|
+ HereWhite hereWhite = hereWhiteService.create(name, userNum, courseScheduleId);
|
|
|
|
+ String joinSuccessKey = "createHereWhite:" + courseScheduleId;
|
|
|
|
+ String randomNumeric = RandomStringUtils.randomNumeric(22);
|
|
|
|
+ redisTemplate.opsForValue().set(joinSuccessKey,randomNumeric,2, TimeUnit.HOURS);
|
|
|
|
+ hereWhite.setRandomNumeric(randomNumeric);
|
|
|
|
+ return succeed(hereWhite);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -39,7 +53,12 @@ public class HereWhiteController extends BaseController {
|
|
*/
|
|
*/
|
|
@RequestMapping(value = "get", method = RequestMethod.GET)
|
|
@RequestMapping(value = "get", method = RequestMethod.GET)
|
|
public Object join(Integer courseScheduleId){
|
|
public Object join(Integer courseScheduleId){
|
|
- return succeed(hereWhiteService.getByClassId(courseScheduleId));
|
|
|
|
|
|
+ HereWhite hereWhite = hereWhiteService.getByClassId(courseScheduleId);
|
|
|
|
+ if(Objects.nonNull(hereWhite)){
|
|
|
|
+ String joinSuccessKey = "createHereWhite:" + courseScheduleId;
|
|
|
|
+ hereWhite.setRandomNumeric(redisTemplate.opsForValue().get(joinSuccessKey));
|
|
|
|
+ }
|
|
|
|
+ return succeed(hereWhite);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|