zouxuan 5 rokov pred
rodič
commit
abc6eaa9c9

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupDao.java

@@ -507,4 +507,9 @@ public interface ClassGroupDao extends BaseDAO<Integer, ClassGroup> {
      */
     List<ClassGroup> findByClassGroupIds(@Param("classGroupIds") List<Integer> classGroupIds);
 
+    List<ImGroupModel> queryStudentGroup();
+
+    List<ImGroupModel> queryTeacherGroup();
+
+    List<ImUserModel> queryImUser();
 }

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/ChargeTypeOrganizationFeeMapper.xml

@@ -58,7 +58,7 @@
 
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="chargeTypeOrganizationFee" parameterType="map">
-		SELECT * FROM charge_type_organization_fee ORDER BY ctof.create_time_ DESC
+		SELECT * FROM charge_type_organization_fee ORDER BY create_time_ DESC
 		<include refid="global.limit" />
 	</select>
 

+ 36 - 0
mec-biz/src/main/resources/config/mybatis/ClassGroupMapper.xml

@@ -824,6 +824,7 @@
             AND group_type_ = #{groupType}
         GROUP BY music_group_id_,group_type_
     </select>
+
     <select id="findByClassGroupIds" resultMap="ClassGroup">
       SELECT * FROM class_group where id_ IN
       <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
@@ -831,4 +832,39 @@
       </foreach>
     </select>
 
+    <resultMap id="ImGroupModelMap" type="com.ym.mec.common.entity.ImGroupModel">
+        <result property="name" column="class_group_name_"/>
+        <result property="id" column="class_group_id_"/>
+        <collection property="members" ofType="com.ym.mec.common.entity.ImGroupMember">
+            <result property="id" column="user_id_"/>
+        </collection>
+    </resultMap>
+
+    <select id="queryStudentGroup" resultMap="ImGroupModelMap">
+        SELECT cg.name_ class_group_name_,cg.id_ class_group_id_,su.id_ user_id_
+        FROM class_group cg
+        LEFT JOIN class_group_student_mapper cgsm ON cg.id_ = cgsm.class_group_id_
+        LEFT JOIN sys_user su ON su.id_ = cgsm.user_id_
+        WHERE su.id_ IS NOT NULL
+    </select>
+
+    <select id="queryTeacherGroup" resultMap="ImGroupModelMap">
+        SELECT cg.name_ class_group_name_,cg.id_ class_group_id_,su.id_ user_id_
+        FROM class_group cg
+        LEFT JOIN class_group_teacher_mapper cgtm ON cg.id_ = cgtm.class_group_id_
+        LEFT JOIN sys_user su ON su.id_ = cgtm.user_id_
+        WHERE su.id_ IS NOT NULL
+    </select>
+    <resultMap id="ImUserModelMap" type="com.ym.mec.common.entity.ImUserModel">
+        <result property="name" column="real_name_"/>
+        <result property="id" column="id_"/>
+        <result property="portrait" column="head_url_"/>
+    </resultMap>
+    <select id="queryImUser" resultMap="ImUserModelMap">
+        SELECT su.id_,su.real_name_,
+        IF(su.avatar_ IS NULL OR su.avatar_ = '','https://daya-online.oss-cn-beijing.aliyuncs.com/201910/RgHwgKc.jpg',su.avatar_) head_url_
+        FROM sys_user su
+        WHERE su.id_ IS NOT NULL
+    </select>
+
 </mapper>

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -137,6 +137,9 @@
             <if test="classDate != null">
                 class_date_ = #{classDate},
             </if>
+            <if test="musicGroupId != null">
+                music_group_id_ = #{musicGroupId},
+            </if>
             <if test="endClassTime != null">
                 end_class_time_ = #{endClassTime},
             </if>

+ 2 - 2
mec-im/src/main/java/com/ym/controller/GroupController.java

@@ -58,8 +58,8 @@ public class GroupController{
     }
 
     @RequestMapping(value = "/batchCreate", method = RequestMethod.POST)
-    public Object batchCreate(@RequestBody List<GroupModel> groupModels) throws Exception {
-        return groupService.batchCreate(groupModels);
+    public Object batchCreate() throws Exception {
+        return groupService.batchCreate();
     }
 
     @RequestMapping(value = "/get", method = RequestMethod.POST)

+ 2 - 9
mec-im/src/main/java/com/ym/controller/UserController.java

@@ -26,15 +26,8 @@ public class UserController {
     }
 
     @RequestMapping(value = "/batchRegister", method = RequestMethod.POST)
-    public Object register(@RequestBody List<UserModel> userModels){
-        userModels.forEach(e->{
-            try {
-                userService.register(e);
-            } catch (Exception e1) {
-                e1.printStackTrace();
-            }
-        });
-        return null;
+    public Object batchRegister(){
+        return userService.batchRegister();
     }
 
     @RequestMapping(value = "/update", method = RequestMethod.POST)

+ 1 - 2
mec-im/src/main/java/com/ym/service/GroupService.java

@@ -59,8 +59,7 @@ public interface GroupService {
 
     /**
      * 初始化群数据
-     * @param groupModels
      * @return
      */
-    Result batchCreate(List<GroupModel> groupModels);
+    Result batchCreate();
 }

+ 19 - 3
mec-im/src/main/java/com/ym/service/Impl/GroupServiceImpl.java

@@ -1,5 +1,8 @@
 package com.ym.service.Impl;
 
+import com.alibaba.fastjson.JSONObject;
+import com.ym.mec.biz.dal.dao.ClassGroupDao;
+import com.ym.mec.common.entity.ImGroupModel;
 import com.ym.service.GroupService;
 import io.rong.RongCloud;
 import io.rong.methods.conversation.Conversation;
@@ -12,6 +15,7 @@ import io.rong.models.conversation.ConversationModel;
 import io.rong.models.group.GroupModel;
 import io.rong.models.group.UserGroup;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
@@ -26,6 +30,9 @@ public class GroupServiceImpl implements GroupService {
     @Value("${cn.rongcloud.im.secret}")
     private String appSecret;
 
+    @Autowired
+    private ClassGroupDao classGroupDao;
+
     private Group getGroup(){
         RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret);
         return new Group(appKey,appSecret,rongCloud);
@@ -145,9 +152,18 @@ public class GroupServiceImpl implements GroupService {
     }
 
     @Override
-    public Result batchCreate(List<GroupModel> groupModels) {
-
-//        return getGroup().create();
+    public Result batchCreate() {
+        List<ImGroupModel> studentGroup = classGroupDao.queryStudentGroup();
+        List<ImGroupModel> teacherGroup = classGroupDao.queryTeacherGroup();
+        studentGroup.addAll(teacherGroup);
+        List<GroupModel> groupModels1 = JSONObject.parseArray(JSONObject.toJSONString(studentGroup), GroupModel.class);
+        groupModels1.forEach(e->{
+            try {
+                getGroup().join(e);
+            } catch (Exception e1) {
+                e1.printStackTrace();
+            }
+        });
         return null;
     }
 }

+ 14 - 0
mec-im/src/main/java/com/ym/service/Impl/UserServiceImpl.java

@@ -1,6 +1,9 @@
 package com.ym.service.Impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.ym.dao.UserDao;
+import com.ym.mec.biz.dal.dao.ClassGroupDao;
+import com.ym.mec.common.entity.ImUserModel;
 import com.ym.mec.im.IMHelper;
 import com.ym.service.UserService;
 import io.rong.RongCloud;
@@ -23,6 +26,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * Created by weiqinxiao on 2019/2/25.
  */
@@ -35,6 +40,8 @@ public class UserServiceImpl implements UserService {
     private String appSecret;
     @Autowired
     UserDao userDao;
+    @Autowired
+    private ClassGroupDao classGroupDao;
 
     @Autowired
     IMHelper imHelper;
@@ -148,4 +155,11 @@ public class UserServiceImpl implements UserService {
     public Result muteChatroomsGetList() throws Exception {
         return getMuteChatrooms().getList();
     }
+
+    @Override
+    public Result batchRegister() {
+        List<ImUserModel> userModels = classGroupDao.queryImUser();
+        List<UserModel> userModelList = JSONObject.parseArray(JSONObject.toJSONString(userModels), UserModel.class);
+        return null;
+    }
 }

+ 2 - 0
mec-im/src/main/java/com/ym/service/UserService.java

@@ -61,4 +61,6 @@ public interface UserService {
     Result muteChatroomsRemove(ChatroomModel chatroomModel) throws Exception;
 
     Result muteChatroomsGetList() throws Exception;
+
+    Result batchRegister();
 }