zouxuan 5 年之前
父节点
当前提交
846bd3296a

+ 3 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupDao.java

@@ -9,6 +9,7 @@ import com.ym.mec.common.dal.BaseDAO;
 
 import com.ym.mec.common.entity.ImGroupModel;
 import org.apache.ibatis.annotations.Param;
+import org.springframework.security.core.parameters.P;
 
 import java.util.List;
 import java.util.Map;
@@ -104,9 +105,10 @@ public interface ClassGroupDao extends BaseDAO<Integer, ClassGroup> {
     /**
      * 获取学员所在群组信息
      * @param userId
+     * @param search
      * @return
      */
-    List<ImGroupModel> queryUserGroups(Integer userId);
+    List<ImGroupModel> queryUserGroups(@Param("userId") Integer userId, @Param("search") String search);
 
     /**
      * 获取vip课的学生名称列表

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupDao.java

@@ -6,6 +6,7 @@ import com.ym.mec.biz.dal.dto.MusicCardDto;
 import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.entity.ImGroupModel;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -47,4 +48,18 @@ public interface MusicGroupDao extends BaseDAO<String, MusicGroup> {
      * @return
      */
     List<BasicUserDto> findTeachersByStuId(Integer studentId);
+
+    /**
+     * 获取用户所在乐团
+     * @param userId
+     * @return
+     */
+    List<ImGroupModel> queryUserGroups(@Param("userId") Integer userId,@Param("search") String search);
+
+    /**
+     * 获取乐团总人数
+     * @param musicGroupId
+     * @return
+     */
+    Integer countMusicGroupUserNum(String musicGroupId);
 }

+ 12 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroup.java

@@ -10,7 +10,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
 /**
  * 对应数据库表(music_group):
  */
-public class 	MusicGroup {
+public class MusicGroup {
 
 	/**  */
 	private String id;
@@ -87,6 +87,17 @@ public class 	MusicGroup {
 	@ApiModelProperty(value = "缴费月份(多个用,分开)",required = false)
 	private String paymentMonths;
 
+	@ApiModelProperty(value = "乐团图片",required = false)
+	private String img;
+
+	public String getImg() {
+		return img;
+	}
+
+	public void setImg(String img) {
+		this.img = img;
+	}
+
 	public String getPaymentMonths() {
 		return paymentMonths;
 	}

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupService.java

@@ -126,7 +126,8 @@ public interface ClassGroupService extends BaseService<Integer, ClassGroup> {
     /**
      * 获取学员所在群组信息
      * @param userId
+     * @param search
      * @return
      */
-    List<ImGroupModel> queryUserGroups(Integer userId);
+    List<ImGroupModel> queryUserGroups(Integer userId,String search);
 }

+ 18 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -1,7 +1,7 @@
 package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.biz.dal.dao.ClassGroupDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
 import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
 import com.ym.mec.biz.dal.dao.TeacherDao;
 import com.ym.mec.biz.dal.dto.*;
@@ -33,7 +33,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     @Autowired
     private TeacherDao teacherDao;
     @Autowired
-    private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
+    private MusicGroupDao musicGroupDao;
     @Autowired
     private ClassGroupRelationService classGroupRelationService;
     @Autowired
@@ -349,7 +349,21 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 
 
     @Override
-    public List<ImGroupModel> queryUserGroups(Integer userId) {
-        return classGroupDao.queryUserGroups(userId);
+    public List<ImGroupModel> queryUserGroups(Integer userId,String search) {
+        List<ImGroupModel> imGroupModels = musicGroupDao.queryUserGroups(userId,search);
+        List<ImGroupModel> imGroupModels1 = classGroupDao.queryUserGroups(userId,search);
+        if(imGroupModels.size() < 1 || imGroupModels == null){
+            return imGroupModels1;
+        }else {
+            imGroupModels.forEach(e->{
+                e.setCount(musicGroupDao.countMusicGroupUserNum(e.getId()));
+                e.setId("mg" + e.getId());
+            });
+            imGroupModels1.forEach(e->{
+                e.setId("cg" + e.getId());
+            });
+            imGroupModels.addAll(imGroupModels1);
+            return imGroupModels;
+        }
     }
 }

+ 12 - 4
mec-biz/src/main/resources/config/mybatis/ClassGroupMapper.xml

@@ -71,7 +71,7 @@
 
     <!-- 根据主键查询一条记录 -->
     <select id="get" resultMap="ClassGroup">
-        UPDATE class_group SET WHERE id_ = #{id}
+        SELECT * FROM class_group WHERE id_ = #{id}
     </select>
 
     <!-- 全查询 -->
@@ -289,12 +289,20 @@
     <resultMap id="imGroupModel" type="com.ym.mec.common.entity.ImGroupModel">
         <result column="id_" property="id"/>
         <result column="name_" property="name"/>
-        <result column="student_num_" property="minute"/>
+        <result column="student_num_" property="count"/>
+        <result column="img_" property="img"/>
     </resultMap>
     <select id="queryUserGroups" resultMap="imGroupModel">
-        SELECT cg.id_,cg.name_,cg.student_num_ FROM class_group_student_mapper cgsm
+        SELECT cg.id_,cg.name_,cg.student_num_,cg.img_ FROM class_group_student_mapper cgsm
         LEFT JOIN class_group cg ON cgsm.class_group_id_ = cg.id_
-        WHERE cgsm.user_id_ = #{userId}
+        <where>
+            <if test="userId != null">
+                cgsm.user_id_ = #{userId}
+            </if>
+            <if test="search != null and search != ''">
+                AND cg.name_ LIKE CONCAT('%',#{search},'%')
+            </if>
+        </where>
     </select>
     <select id="findVipStuNames" resultType="java.lang.String">
         SELECT su.username_ FROM vip_group_class_group_mapper vgcgm

+ 27 - 4
mec-biz/src/main/resources/config/mybatis/MusicGroupMapper.xml

@@ -24,6 +24,7 @@
 		<result column="cooperation_organ_id_" property="cooperationOrganId" />
 		<result column="enlightenment_course_time_" property="enlightenmentCourseTime" />
 		<result column="parent_meeting_time_" property="parentMeetingTime" />
+		<result column="img_" property="img" />
 	</resultMap>
 
 	<!-- 根据主键查询一条记录 -->
@@ -41,11 +42,12 @@
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroup"
 		useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		<!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval 
-			AS ID FROM DUAL </selectKey> -->
 		INSERT INTO music_group
-		(id_,name_,organ_id_,school_id_,apply_expire_date_,team_teacher_id_,educational_teacher_id_,charge_type_id_,course_form_,create_time_,update_time_,status_,bill_start_date_,improvent_classes_num_,enroll_classes_,payment_expire_date_,is_extra_class_,cooperation_organ_id_,enlightenment_course_time_,parent_meeting_time_)
-		VALUES(#{id},#{name},#{organId},#{schoolId},#{applyExpireDate},#{teamTeacherId},#{educationalTeacherId},#{chargeTypeId},#{courseForm},now(),now(),#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{billStartDate},#{improventClassesNum},#{enrollClasses},#{paymentExpireDate},#{isExtraClass, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{cooperationOrganId},#{enlightenmentCourseTime},#{parentMeetingTime})
+		(id_,name_,organ_id_,school_id_,apply_expire_date_,team_teacher_id_,educational_teacher_id_,charge_type_id_,course_form_,create_time_,update_time_,status_,
+		bill_start_date_,improvent_classes_num_,enroll_classes_,payment_expire_date_,is_extra_class_,cooperation_organ_id_,enlightenment_course_time_,parent_meeting_time_,img_)
+		VALUES(#{id},#{name},#{organId},#{schoolId},#{applyExpireDate},#{teamTeacherId},#{educationalTeacherId},#{chargeTypeId},#{courseForm},now(),now(),
+		#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{billStartDate},#{improventClassesNum},#{enrollClasses},#{paymentExpireDate},
+		#{isExtraClass, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{cooperationOrganId},#{enlightenmentCourseTime},#{parentMeetingTime},#{img})
 	</insert>
 
 	<!-- 根据主键查询一条记录 -->
@@ -106,6 +108,9 @@
 			<if test="parentMeetingTime != null">
 				parent_meeting_time_ = #{parentMeetingTime},
 			</if>
+			<if test="img != null">
+				img_ = #{img},
+			</if>
 		</set>
 		WHERE id_ = #{id}
 	</update>
@@ -174,6 +179,7 @@
 		<result column="head_url_" property="headUrl" />
 		<result column="gender_" property="gender"/>
 	</resultMap>
+
 	<select id="findTeachersByStuId" resultMap="BasicUserDto">
 		SELECT username_,id_ user_id_,avatar_ head_url_,gender_ FROM sys_user
 		WHERE id_ IN (SELECT DISTINCT(su.id_) FROM class_group_student_mapper cgsp
@@ -182,4 +188,21 @@
 		LEFT JOIN sys_user su ON cgtm.user_id_ = su.id_
 		WHERE cgsp.user_id_ = #{studentId})
 	</select>
+
+    <select id="queryUserGroups" resultMap="com.ym.mec.biz.dal.dao.ClassGroupDao.imGroupModel">
+        SELECT mg.id_,mg.name_,mg.img_
+		FROM student_registration sr
+		LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
+		<where>
+			<if test="userId != null">
+				sr.user_id_ = #{userId}
+			</if>
+			<if test="search != null">
+				AND mg.name_ LIKE CONCAT('%',#{search},'%')
+			</if>
+		</where>
+	</select>
+    <select id="countMusicGroupUserNum" resultType="java.lang.Integer">
+		SELECT SUM(student_num_) FROM class_group WHERE music_group_id_ = #{musicGroupId}
+    </select>
 </mapper>

+ 18 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/entity/ImGroupModel.java

@@ -4,12 +4,22 @@ public class ImGroupModel {
     private String id;
     private ImGroupMember[] members;
     private String name;
+    private String img;
     private Integer minute;
+    private Integer count;
     private Integer status;
 
     public ImGroupModel() {
     }
 
+    public Integer getCount() {
+        return count;
+    }
+
+    public void setCount(Integer count) {
+        this.count = count;
+    }
+
     public ImGroupModel(String id, ImGroupMember[] members, String name, Integer minute) {
         this.id = id;
         this.members = members;
@@ -22,6 +32,14 @@ public class ImGroupModel {
         this.status = status;
     }
 
+    public String getImg() {
+        return img;
+    }
+
+    public void setImg(String img) {
+        this.img = img;
+    }
+
     public String getId() {
         return this.id;
     }

+ 15 - 9
mec-student/src/main/java/com/ym/mec/student/controller/CourseController.java

@@ -3,9 +3,11 @@ package com.ym.mec.student.controller;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.service.ClassGroupService;
+import com.ym.mec.biz.service.MusicGroupService;
 import com.ym.mec.common.controller.BaseController;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -19,6 +21,8 @@ public class CourseController extends BaseController {
     @Autowired
     private ClassGroupService classGroupService;
     @Autowired
+    private MusicGroupService musicGroupService;
+    @Autowired
     private SysUserFeignService sysUserFeignService;
 
     @ApiOperation("获取学生所购买课程列表")
@@ -33,21 +37,23 @@ public class CourseController extends BaseController {
 
     @ApiOperation("获取学员所有聊天群组")
     @GetMapping(value = "/queryUserGroups")
-    public Object queryUserGroups(){
+    public Object queryUserGroups(String search){
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if(sysUser == null){
             return failed("获取用户信息失败");
         }
-        return succeed(classGroupService.queryUserGroups(sysUser.getId()));
+        return succeed(classGroupService.queryUserGroups(sysUser.getId(),search));
     }
 
-    /*@ApiOperation(value = "根据群编号,获取群组基本信息")
+    @ApiOperation(value = "根据群编号,获取群组基本信息")
     @GetMapping("/findGroupById")
-    public Object findGroupById(Integer classGroupId){
-        SysUser sysUser = sysUserFeignService.queryUserInfo();
-        if(sysUser == null){
-            return failed("获取用户信息失败");
+    public Object findGroupById(String groupId){
+        if(StringUtils.isEmpty(groupId)){
+            return failed("参数校验错误");
+        }
+        if(groupId.startsWith("mg")){
+            return succeed(musicGroupService.get(groupId.substring(2)));
         }
-        return succeed(musicGroupService.findTeachersByStuId(sysUser.getId()));
-    }*/
+        return succeed(classGroupService.get(Integer.parseInt(groupId.substring(2))));
+    }
 }