瀏覽代碼

Merge remote-tracking branch 'origin/master'

周箭河 5 年之前
父節點
當前提交
7fe7182226
共有 16 個文件被更改,包括 170 次插入16 次删除
  1. 5 5
      edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysUser.java
  2. 1 0
      edu-im/edu-im-server/src/main/java/com/keao/edu/im/config/IMProperties.java
  3. 39 0
      edu-im/edu-im-server/src/main/java/com/keao/edu/im/http/HttpHelper.java
  4. 72 0
      edu-im/edu-im-server/src/main/java/com/keao/edu/im/mec/im/IMHelper.java
  5. 1 0
      edu-im/edu-im-server/src/main/resources/application.yml
  6. 2 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/EmployeeController.java
  7. 1 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRegistrationController.java
  8. 2 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/SysUserDao.java
  9. 2 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/EmployeeService.java
  10. 2 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamRegistrationService.java
  11. 12 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/EmployeeServiceImpl.java
  12. 20 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRegistrationServiceImpl.java
  13. 5 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/OrganizationServiceImpl.java
  14. 3 2
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/TenantInfoServiceImpl.java
  15. 1 1
      edu-user/edu-user-server/src/main/resources/config/mybatis/EmployeeMapper.xml
  16. 2 4
      edu-user/edu-user-server/src/main/resources/config/mybatis/ExamRegistrationMapper.xml

+ 5 - 5
edu-auth/edu-auth-api/src/main/java/com/keao/edu/auth/api/entity/SysUser.java

@@ -1,12 +1,12 @@
 package com.keao.edu.auth.api.entity;
 
 import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import java.io.Serializable;
 import java.util.Date;
 import java.util.List;
-
-import org.apache.commons.lang3.builder.ToStringBuilder;
+import java.util.Set;
 
 /**
  * 对应数据库表(sys_user):
@@ -95,7 +95,7 @@ public class SysUser implements Serializable{
 	private Boolean isSuperAdmin = false;
 
 	@ApiModelProperty(value = "用户角色",required = false)
-	private List<Integer> roles;
+	private Set<Integer> roles;
 
 	private String tenantId;
 
@@ -299,11 +299,11 @@ public class SysUser implements Serializable{
 		this.isSuperAdmin = isSuperAdmin;
 	}
 
-	public List<Integer> getRoles() {
+	public Set<Integer> getRoles() {
 		return roles;
 	}
 
-	public void setRoles(List<Integer> roles) {
+	public void setRoles(Set<Integer> roles) {
 		this.roles = roles;
 	}
 

+ 1 - 0
edu-im/edu-im-server/src/main/java/com/keao/edu/im/config/IMProperties.java

@@ -14,4 +14,5 @@ public class IMProperties {
     private String appKey;
     private String secret;
     private String host;
+    private String rtcHost;
 }

+ 39 - 0
edu-im/edu-im-server/src/main/java/com/keao/edu/im/http/HttpHelper.java

@@ -144,6 +144,38 @@ public class HttpHelper {
         return conn;
     }
 
+    public HttpURLConnection createCommonRtcPostHttpConnection(String host, String appKey,
+        String appSecret, String uri, String contentType,String roomId)
+        throws MalformedURLException, IOException, ProtocolException {
+        String nonce = String.valueOf(Math.random() * 1000000);
+        String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
+        StringBuilder toSign = new StringBuilder(appSecret).append(nonce).append(timestamp);
+        String sign = CodeUtil.hexSHA1(toSign.toString());
+        uri = host + uri;
+        URL url = new URL(uri);
+        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+        if (conn == null) {
+            log.info("open url connectin fail, url={}", uri);
+            return null;
+        }
+
+        conn.setUseCaches(false);
+        conn.setDoInput(true);
+        conn.setDoOutput(true);
+        conn.setRequestMethod("POST");
+        conn.setInstanceFollowRedirects(true);
+        conn.setConnectTimeout(30000);
+        conn.setReadTimeout(30000);
+
+        conn.setRequestProperty("App-Key", appKey);
+        conn.setRequestProperty("Nonce", nonce);
+        conn.setRequestProperty("Timestamp", timestamp);
+        conn.setRequestProperty("Signature", sign);
+        conn.setRequestProperty("Room-Id", roomId);
+        conn.setRequestProperty("Content-Type", contentType);
+        return conn;
+    }
+
     public HttpURLConnection createCommonGetHttpConnection(String host, String appKey,
         String appSecret, String uri, String contentType)
         throws MalformedURLException, IOException, ProtocolException {
@@ -189,6 +221,13 @@ public class HttpHelper {
             contentType);
     }
 
+    public HttpURLConnection createIMRtcPostHttpConnection(String uri, String contentType,String roomId)
+        throws MalformedURLException, IOException, ProtocolException {
+        return createCommonRtcPostHttpConnection(imProperties.getRtcHost(),
+                imProperties.getAppKey(), imProperties.getSecret(), uri,
+            contentType,roomId);
+    }
+
     public byte[] readInputStream(InputStream inStream) throws Exception {
         ByteArrayOutputStream outStream = new ByteArrayOutputStream();
         byte[] buffer = new byte[1024];

+ 72 - 0
edu-im/edu-im-server/src/main/java/com/keao/edu/im/mec/im/IMHelper.java

@@ -1,6 +1,8 @@
 package com.keao.edu.im.mec.im;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.JsonObject;
 import com.keao.edu.im.http.HttpHelper;
 import com.keao.edu.im.pojo.IMApiResultInfo;
 import com.keao.edu.im.pojo.IMTokenInfo;
@@ -216,6 +218,76 @@ public class IMHelper {
         return JSON.parseObject(httpHelper.returnResult(conn, body), IMApiResultInfo.class);
     }
 
+    /**
+     * 开始录制
+     * @param hostUserId
+     * @param sessionId
+     * @return
+     * @throws Exception
+     */
+    public IMApiResultInfo startRecord(String hostUserId, String sessionId, String roomId) throws Exception {
+        if (hostUserId == null) {
+            throw new IllegalArgumentException("Paramer 'userId' is required");
+        }
+
+        if (hostUserId == null) {
+            throw new IllegalArgumentException("Paramer 'groupId' is required");
+        }
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("mode","3");
+        jsonObject.put("videoFormat","mp4");
+        jsonObject.put("audioFormat","mp3");
+        jsonObject.put("videoResolution","640x480");
+        jsonObject.put("mixLayout","3");
+        jsonObject.put("sliceMin","60");
+        jsonObject.put("hostUserId",hostUserId);
+        JSONObject json = new JSONObject();
+        json.put("sessionId",sessionId);
+        json.put("config",jsonObject);
+
+        String body = json.toJSONString();
+
+        HttpURLConnection conn = httpHelper.createIMRtcPostHttpConnection("/rtc/record/start.json", "application/x-www-form-urlencoded",roomId);
+        httpHelper.setBodyParameter(body, conn);
+
+        return JSON.parseObject(httpHelper.returnResult(conn, body), IMApiResultInfo.class);
+    }
+
+    /**
+     * 结束录制
+     * @param hostUserId
+     * @param sessionId
+     * @return
+     * @throws Exception
+     */
+    public IMApiResultInfo stopRecord(String hostUserId, String sessionId, String roomId) throws Exception {
+        if (hostUserId == null) {
+            throw new IllegalArgumentException("Paramer 'userId' is required");
+        }
+
+        if (hostUserId == null) {
+            throw new IllegalArgumentException("Paramer 'groupId' is required");
+        }
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("mode","3");
+        jsonObject.put("videoFormat","mp4");
+        jsonObject.put("audioFormat","mp3");
+        jsonObject.put("videoResolution","640x480");
+        jsonObject.put("mixLayout","3");
+        jsonObject.put("sliceMin","60");
+        jsonObject.put("hostUserId",hostUserId);
+        JSONObject json = new JSONObject();
+        json.put("sessionId",sessionId);
+        json.put("config",jsonObject);
+
+        String body = json.toJSONString();
+
+        HttpURLConnection conn = httpHelper.createIMRtcPostHttpConnection("/rtc/record/stop.json", "application/x-www-form-urlencoded",roomId);
+        httpHelper.setBodyParameter(body, conn);
+
+        return JSON.parseObject(httpHelper.returnResult(conn, body), IMApiResultInfo.class);
+    }
+
 
     /**
      * 发送群组消息方法(以一个用户身份向群组发送消息,单条消息最大 128k.每秒钟最多发送 20 条消息,每次最多向 3 个群组发送,如:一次向 3 个群组发送消息,示为 3 条消息。)

+ 1 - 0
edu-im/edu-im-server/src/main/resources/application.yml

@@ -98,6 +98,7 @@ cn:
       appkey: 8luwapkv84g3l
       secret: 7s6m56VCL6Pi
       host: http://api-cn.ronghub.com
+      rtcHost: http://rtcapi-cn.ronghub.com
     whiteboard:
       host: https://sealclass.rongcloud.cn/ewb
     hereWhite:

+ 2 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/EmployeeController.java

@@ -71,7 +71,8 @@ public class EmployeeController extends BaseController {
 	@ApiOperation("删除")
 	@PostMapping(value = "/del/{id}")
 	public HttpResponseResult add(@PathVariable("id") Integer id) {
-		return succeed(employeeService.delete(id));
+		employeeService.del(id);
+		return succeed();
 	}
 
 }

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRegistrationController.java

@@ -77,7 +77,7 @@ public class ExamRegistrationController extends BaseController {
     @PostMapping(value = "update")
     @PreAuthorize("@pcs.hasPermissions('examRegistration/update')")
     public HttpResponseResult update(@RequestBody ExamRegistration examRegistration) {
-        examRegistrationService.update(examRegistration);
+        examRegistrationService.updateExamRegistration(examRegistration);
         return succeed();
     }
 

+ 2 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/SysUserDao.java

@@ -6,6 +6,7 @@ import com.keao.edu.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Set;
 
 public interface SysUserDao extends BaseDAO<Integer, SysUser> {
 
@@ -48,6 +49,6 @@ public interface SysUserDao extends BaseDAO<Integer, SysUser> {
 	 * @param id
 	 * @param roles
 	 */
-	void batchAddEmployeeRole(@Param("userId") Integer id, @Param("roles") List<Integer> roles);
+	void batchAddEmployeeRole(@Param("userId") Integer id, @Param("roles") Set<Integer> roles);
 
 }

+ 2 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/EmployeeService.java

@@ -17,4 +17,6 @@ public interface EmployeeService extends BaseService<Integer, Employee> {
      * @param employee
      */
     void updateEmployee(Employee employee);
+
+    void del(Integer id);
 }

+ 2 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamRegistrationService.java

@@ -25,6 +25,8 @@ public interface ExamRegistrationService extends BaseService<Long, ExamRegistrat
     */
    PageInfo<ExamRegistration> queryExamRegistrationStudents(ExamRegistrationQueryInfo queryInfo);
 
+   void updateExamRegistration(ExamRegistration examRegistration);
+
    /**
     * @describe 统计招生信息
     * @author Joburgess

+ 12 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/EmployeeServiceImpl.java

@@ -12,6 +12,7 @@ import com.keao.edu.im.api.entity.ImUserModel;
 import com.keao.edu.user.dao.EmployeeDao;
 import com.keao.edu.user.dao.SysUserDao;
 import com.keao.edu.user.entity.Employee;
+import com.keao.edu.user.entity.ExamRegistration;
 import com.keao.edu.user.service.EmployeeService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -49,6 +50,9 @@ public class EmployeeServiceImpl extends BaseServiceImpl<Integer, Employee> impl
 			if(!user.getTenantId().equals(tenantId)){
 				throw new BizException("手机号已被占用");
 			}
+			if(user.getUserType().contains("SYSTEM")){
+				throw new BizException("手机号已被占用");
+			}
 			Employee employee1 = employeeDao.get(user.getId());
 			if(employee1 == null){
 				if(StringUtils.isEmpty(user.getPassword())){
@@ -106,4 +110,12 @@ public class EmployeeServiceImpl extends BaseServiceImpl<Integer, Employee> impl
 		sysUserDao.update(sysUser);
 		imFeignService.update(new ImUserModel(sysUser.getId().toString(),sysUser.getRealName(),sysUser.getAvatar()));
 	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void del(Integer id) {
+		Employee employee = employeeDao.get(id);
+		sysUserDao.delEmployeeRole(employee.getUserId());
+		employeeDao.delete(id);
+	}
 }

+ 20 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRegistrationServiceImpl.java

@@ -175,7 +175,7 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
             for (ExamRegistration examRegistration : dataList) {
                 examRegistration.setOrganization(new Organization(examRegistration.getOrganId(), organIdNameMap.get(examRegistration.getOrganId())));
                 examRegistration.getSubject().setName(subjectIdNameMap.get(examRegistration.getSubjectId()));
-                examRegistration.getSysUser().setCertificatePhoto(idPhotoMap.get(examRegistration.getSubjectId()));
+                examRegistration.getSysUser().setCertificatePhoto(idPhotoMap.get(examRegistration.getStudentId()));
                 examRegistration.setExaminationBasic(new ExaminationBasic(examRegistration.getExaminationBasicId(), examIdNameMap.get(examRegistration.getExaminationBasicId())));
             }
         }
@@ -251,6 +251,25 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
     }
 
     @Override
+    public void updateExamRegistration(ExamRegistration examRegistration) {
+        if(Objects.isNull(examRegistration.getId())){
+            throw new BizException("请指定学员报名信息");
+        }
+        ExamRegistration er = examRegistrationDao.get(examRegistration.getId().longValue());
+        if(Objects.isNull(er)) {
+            throw new BizException("学员报名信息不存在");
+        }
+        if(!StudentRegistrationStatusEnum.AUDIT_WAIT.equals(er.getStatus())){
+            throw new BizException("审核状态错误");
+        }
+        if(!StudentRegistrationStatusEnum.AUDIT_PASS.equals(examRegistration.getStatus())
+            &&!StudentRegistrationStatusEnum.AUDIT_REJECT.equals(examRegistration.getStatus())){
+            throw new BizException("审核状态错误");
+        }
+        examRegistrationDao.update(examRegistration);
+    }
+
+    @Override
     public ExamRegistrationDto getExamRegistration(Long examRegistrationId) {
         return examRegistrationDao.getExamRegistration(examRegistrationId);
     }

+ 5 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/OrganizationServiceImpl.java

@@ -68,6 +68,9 @@ public class OrganizationServiceImpl extends BaseServiceImpl<Integer, Organizati
 			if(!user.getTenantId().equals(tenantId)){
 				throw new BizException("手机号已被占用");
 			}
+			if(user.getUserType().contains("SYSTEM")){
+				throw new BizException("手机号已被占用");
+			}
 			Organization organization = organDao.get(user.getId());
 			if(organization == null){
 				organ.setParentOrganIdTag(currentOrganization.getParentOrganIdTag() + "," + user.getId());
@@ -196,7 +199,9 @@ public class OrganizationServiceImpl extends BaseServiceImpl<Integer, Organizati
 	@Transactional(rollbackFor = Exception.class)
 	public void del(Integer id) {
 		Integer count = examOrganizationRelationDao.findByOrganId(id);
+		Organization organization = organDao.get(id);
 		if(count == null || count == 0){
+			sysUserDao.delEmployeeRole(organization.getUserId());
 			organDao.delete(id);
 		}else {
 			throw new BizException("删除失败:存在考试项目,无法删除");

+ 3 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/TenantInfoServiceImpl.java

@@ -70,7 +70,7 @@ public class TenantInfoServiceImpl extends BaseServiceImpl<Integer, TenantInfo>
 		sysUser.setPhone(tenantInfo.getContactPhone());
 		sysUserDao.insert(sysUser);
 		if(StringUtils.isNotBlank(tenantInfo.getRoleIds())){
-			List<Integer> roleIds = Arrays.stream(tenantInfo.getRoleIds().split(",")).map(e -> Integer.valueOf(e)).collect(Collectors.toList());
+			Set<Integer> roleIds = Arrays.stream(tenantInfo.getRoleIds().split(",")).map(e -> Integer.valueOf(e)).collect(Collectors.toSet());
 			sysUserDao.batchAddEmployeeRole(sysUser.getId(), roleIds);
 		}
 
@@ -110,7 +110,8 @@ public class TenantInfoServiceImpl extends BaseServiceImpl<Integer, TenantInfo>
 			throw new BizException("机构账户不存在");
 		}
 		if(StringUtils.isNotBlank(newTenantInfo.getRoleIds())){
-			List<Integer> roleIds = Arrays.stream(newTenantInfo.getRoleIds().split(",")).map(e -> Integer.valueOf(e)).collect(Collectors.toList());
+
+			Set<Integer> roleIds = Arrays.stream(newTenantInfo.getRoleIds().split(",")).map(e -> Integer.valueOf(e)).collect(Collectors.toSet());
 			//删除当前用户角色
 			sysUserDao.delEmployeeRole(sysUser.getId());
 			//新增用户角色

+ 1 - 1
edu-user/edu-user-server/src/main/resources/config/mybatis/EmployeeMapper.xml

@@ -32,7 +32,7 @@
 	<select id="get" resultMap="Employee" >
 		SELECT e.*,su.*,sur.role_id_ FROM employee e
 		LEFT JOIN sys_user su ON e.user_id_ = su.id_
-		LEFT JOIN sys_user_role sur ON e.user_id_ = sur.id_
+		LEFT JOIN sys_user_role sur ON e.user_id_ = sur.user_id_
 		WHERE e.user_id_ = #{userId}
 	</select>
 	

+ 2 - 4
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamRegistrationMapper.xml

@@ -71,9 +71,6 @@
 			<if test="lastExamLevel != null">
 				last_exam_level_ = #{lastExamLevel},
 			</if>
-			<if test="id != null">
-				id_ = #{id},
-			</if>
 			<if test="tenantId != null">
 				tenant_id_ = #{tenantId},
 			</if>
@@ -102,7 +99,7 @@
 				status_ = #{status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
 			</if>
 			<if test="memo!=null">
-				memo_ = #{memo}
+				memo_ = #{memo},
 			</if>
 				update_time_ = NOW()
 		</set> WHERE id_ = #{id}
@@ -147,6 +144,7 @@
 			er.exam_music_theory_level_,
 			er.card_no_,
 			er.student_id_,
+			er.memo_,
 			su.real_name_ sys_user_real_name_,
 			er.last_exam_certificate_url_,
 			er.last_music_theory_certificate_url_,