|
@@ -8,7 +8,9 @@ import com.ym.service.HereWhiteService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -24,13 +26,39 @@ public class HereWhiteServiceImpl implements HereWhiteService {
|
|
|
private HereWhiteDao hereWhiteDao;
|
|
|
|
|
|
@Override
|
|
|
- public String create(String name, Integer userNum) throws Exception {
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public HereWhite create(String name, Integer userNum,Integer courseScheduleId) throws Exception {
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("name",name);
|
|
|
json.put("limit",userNum);
|
|
|
json.put("mode","transitory");
|
|
|
String url = "/room?token=" + hereWhiteToken;
|
|
|
- return requestParam(json,url);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(requestParam(json, url));
|
|
|
+ if(jsonObject.getString("code").equals("200")){
|
|
|
+ JSONObject room = jsonObject.getJSONObject("msg").getJSONObject("room");
|
|
|
+ HereWhite hereWhite = new HereWhite();
|
|
|
+ Date date = new Date();
|
|
|
+ hereWhite.setCourseScheduleId(courseScheduleId);
|
|
|
+ hereWhite.setName(room.getString("name"));
|
|
|
+ hereWhite.setLimit(room.getInteger("limit"));
|
|
|
+ hereWhite.setTeamId(room.getInteger("teamId"));
|
|
|
+ hereWhite.setAdminId(room.getInteger("adminId"));
|
|
|
+ hereWhite.setMode(room.getString("mode"));
|
|
|
+ hereWhite.setTemplate(room.getString("template"));
|
|
|
+ hereWhite.setRegion(room.getString("region"));
|
|
|
+ hereWhite.setUuid(room.getString("uuid"));
|
|
|
+ hereWhite.setRoomToken(jsonObject.getJSONObject("msg").getString("roomToken"));
|
|
|
+ hereWhite.setUpdatedAt(date);
|
|
|
+ hereWhite.setCreatedAt(date);
|
|
|
+ return hereWhiteDao.save(hereWhite);
|
|
|
+ }else {
|
|
|
+ throw new Exception(jsonObject.getString("msg"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HereWhite getByClassId(Integer courseScheduleId) {
|
|
|
+ return hereWhiteDao.findByCourseScheduleId(courseScheduleId);
|
|
|
}
|
|
|
|
|
|
private String requestParam(JSONObject json,String url) throws Exception {
|
|
@@ -38,9 +66,4 @@ public class HereWhiteServiceImpl implements HereWhiteService {
|
|
|
headers.put("Content-Type","application/json");
|
|
|
return HttpUtil.postForHttps(hereWhiteUrl + url, json.toJSONString(), headers);
|
|
|
}
|
|
|
-
|
|
|
- @Override
|
|
|
- public HereWhite join(Integer courseScheduleId) throws Exception {
|
|
|
- return hereWhiteDao.findById(courseScheduleId);
|
|
|
- }
|
|
|
}
|