zouxuan 5 years ago
parent
commit
86a41e014b

+ 40 - 0
mec-im/src/main/java/com/ym/controller/HereWhiteController.java

@@ -0,0 +1,40 @@
+package com.ym.controller;
+
+import com.ym.mec.common.controller.BaseController;
+import com.ym.service.HereWhiteService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/hereWhite")
+public class HereWhiteController  extends BaseController {
+
+    @Autowired
+    private HereWhiteService hereWhiteService;
+
+    /**
+     * 创建白板,默认全部采用零时白板
+     * @param name 白板名称
+     * @param userNum 白板人数上限,0不限制
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "create", method = RequestMethod.POST)
+    public Object userAdd(String name,Integer userNum) throws Exception {
+        return hereWhiteService.create(name, userNum);
+    }
+
+    /**
+     * 获取特定白板 room Token
+     * @param courseScheduleId
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "join", method = RequestMethod.POST)
+    public Object join(Integer courseScheduleId) throws Exception {
+        return succeed(hereWhiteService.join(courseScheduleId));
+    }
+
+}

+ 11 - 0
mec-im/src/main/java/com/ym/dao/HereWhiteDao.java

@@ -0,0 +1,11 @@
+package com.ym.dao;
+
+import com.ym.pojo.HereWhite;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface HereWhiteDao extends JpaRepository<HereWhite, Long> {
+
+    HereWhite findById(Integer id);
+}

+ 34 - 0
mec-im/src/main/java/com/ym/pojo/HereWhite.java

@@ -0,0 +1,34 @@
+package com.ym.pojo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Created by weiqinxiao on 2019/2/28.
+ */
+@Entity
+@Table(name = "rongyun_here_white")
+public class HereWhite implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Getter @Setter
+    private Integer id;
+
+    private @Getter @Setter String name;
+    private @Getter @Setter int limit;
+    private @Getter @Setter int teamId;
+    private @Getter @Setter int adminId;
+    private @Getter @Setter String mode;
+    private @Getter @Setter String template;
+    private @Getter @Setter String region;
+    private @Getter @Setter String uuid;
+    private @Getter @Setter String roomToken;
+    private @Getter @Setter Date updatedAt;
+    private @Getter @Setter Date createdAt;
+}

+ 23 - 0
mec-im/src/main/java/com/ym/service/HereWhiteService.java

@@ -0,0 +1,23 @@
+package com.ym.service;
+
+import com.ym.pojo.HereWhite;
+
+import java.io.IOException;
+
+public interface HereWhiteService {
+
+    /**
+     * 创建白板
+     * @param name
+     * @param userNum
+     * @return
+     */
+    String create(String name,Integer userNum) throws Exception;
+
+    /**
+     * 获取特定白板 room Token
+     * @param courseScheduleId
+     * @return
+     */
+    HereWhite join(Integer courseScheduleId) throws Exception;
+}

+ 46 - 0
mec-im/src/main/java/com/ym/service/Impl/HereWhiteServiceImpl.java

@@ -0,0 +1,46 @@
+package com.ym.service.Impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.ym.dao.HereWhiteDao;
+import com.ym.mec.util.http.HttpUtil;
+import com.ym.pojo.HereWhite;
+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 java.util.HashMap;
+import java.util.Map;
+
+@Service
+public class HereWhiteServiceImpl implements HereWhiteService {
+
+    @Value("${cn.rongcloud.hereWhite.url}")
+    private String hereWhiteUrl;
+    @Value("${cn.rongcloud.hereWhite.token}")
+    private String hereWhiteToken;
+
+    @Autowired
+    private HereWhiteDao hereWhiteDao;
+
+    @Override
+    public String create(String name, Integer userNum) 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);
+    }
+
+    private String requestParam(JSONObject json,String url) throws Exception {
+        Map<String, String> headers = new HashMap<>(1);
+        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);
+    }
+}

+ 3 - 0
mec-im/src/main/resources/application.yml

@@ -89,6 +89,9 @@ cn:
       host: http://api-cn.ronghub.com
     whiteboard:
       host: https://sealclass.rongcloud.cn/ewb
+    hereWhite:
+      url: https://cloudcapiv4.herewhite.com
+      token: WHITEcGFydG5lcl9pZD1EUzdrQ3JOenJnRU1Hc1ZnelV5T1czOFl3ZlJuTUF5MjMyMmkmc2lnPTUwMjEwNDVjNzY3Mzc1YjEyZDEzYWY4MDM4M2Q5MTA0YTJhNGQwYjM6YWRtaW5JZD00ODkmcm9sZT1taW5pJmV4cGlyZV90aW1lPTE2MDI0MDIzMDUmYWs9RFM3a0NyTnpyZ0VNR3NWZ3pVeU9XMzhZd2ZSbk1BeTIzMjJpJmNyZWF0ZV90aW1lPTE1NzA4NDUzNTMmbm9uY2U9MTU3MDg0NTM1Mjc1MzAw
     web:
       enableCors: true
     room: