Joburgess il y a 5 ans
Parent
commit
852d97f453

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

@@ -266,4 +266,12 @@ public interface ClassGroupDao extends BaseDAO<Integer, ClassGroup> {
      */
     List<TeacherClassGroupDto> findTeacherVipClassGroup(@Param("teacherId") Long teacherId);
 
+    /**
+     * @describe 查询班级下所有学生的部门编号列表
+     * @author Joburgess
+     * @date 2019/10/21
+     * @param classGroupId: 班级编号
+     * @return java.util.List<java.lang.Integer>
+     */
+    List<Integer> findStudentOrganIdsByClassGroup(Long classGroupId);
 }

+ 3 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseHomeworkDao.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.dal.dao;
 import com.ym.mec.biz.dal.dto.TeacherHomeworkListDto;
 import com.ym.mec.biz.dal.entity.CourseHomework;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
@@ -27,7 +28,7 @@ public interface CourseHomeworkDao extends BaseDAO<Long, CourseHomework> {
      * @param userId: 用户编号
      * @return com.ym.mec.biz.dal.entity.CourseHomework
      */
-    CourseHomework findByTeacherAndCourseHomewok(Long courseHomeworkId,
-                                                 Long userId);
+    CourseHomework findByTeacherAndCourseHomewok(@Param("courseHomeworkId") Long courseHomeworkId,
+                                                 @Param("userId") Long userId);
 
 }

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/VipGroupDao.java

@@ -13,6 +13,15 @@ import java.util.Map;
 public interface VipGroupDao extends BaseDAO<Long, VipGroup> {
 
 	/**
+	 * @describe 锁定指定vip课
+	 * @author Joburgess
+	 * @date 2019/10/21
+	 * @param vipGroupId: vip课编号
+	 * @return com.ym.mec.biz.dal.entity.VipGroup
+	 */
+	VipGroup getLockVipGroup(Long vipGroupId);
+
+	/**
 	 * @Author: Joburgess
 	 * @Date: 2019/10/9
 	 * @params [organId]

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CourseScheduleDto.java

@@ -20,6 +20,9 @@ public class CourseScheduleDto extends CourseSchedule {
     @ApiModelProperty(value = "学生总人数")
     private Integer totalStudentNum;
 
+    @ApiModelProperty(value = "学生姓名")
+    private String studentNames;
+
     @ApiModelProperty(value = "学校名称",required = false)
     private String schoolName;
 
@@ -32,6 +35,14 @@ public class CourseScheduleDto extends CourseSchedule {
     @ApiModelProperty(value = "签退状态(1已签到,0未签到)",required = false)
     private Integer signOutStatus;
 
+    public String getStudentNames() {
+        return studentNames;
+    }
+
+    public void setStudentNames(String studentNames) {
+        this.studentNames = studentNames;
+    }
+
     public Integer getTotalStudentNum() {
         return totalStudentNum;
     }

+ 8 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/VipGroupService.java

@@ -42,20 +42,20 @@ public interface VipGroupService extends BaseService<Long, VipGroup> {
     PageInfo findVipGroups(VipGroupQueryInfo queryInfo);
 
     /**
-     * @Author: Joburgess
-     * @Date: 2019/10/9
-     * @params [queryInfo]
-     * @return com.ym.mec.common.page.PageInfo
      * @describe 获取vip课教学记录
+     * @author Joburgess
+     * @date 2019/10/21
+     * @param queryInfo: 查询条件
+     * @return java.util.Map<java.lang.String,java.lang.Object>
      */
     Map<String, Object> findVipGroupTeachingRecord(VipGroupTeachingRecordQueryInfo queryInfo);
 
     /**
-     * @Author: Joburgess
-     * @Date: 2019/10/9
-     * @params [vipGroupId]
-     * @return com.ym.mec.biz.dal.dto.TeachingRecordBaseInfo
      * @describe 获取vip课教学记录基本信息
+     * @author Joburgess
+     * @date 2019/10/21
+     * @param vipGroupId: vip课编号
+     * @return com.ym.mec.biz.dal.dto.TeachingRecordBaseInfo
      */
     TeachingRecordBaseInfo findTeachingRecordBaseInfo(Long vipGroupId);
 

+ 11 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -2,10 +2,7 @@ package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.CourseScheduleComplaintsDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleDao;
-import com.ym.mec.biz.dal.dao.StudentAttendanceDao;
-import com.ym.mec.biz.dal.dao.SysConfigDao;
+import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.ClassDateAdjustDto;
 import com.ym.mec.biz.dal.dto.CourseScheduleDto;
 import com.ym.mec.biz.dal.dto.TeacherAttendanceDto;
@@ -54,7 +51,8 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 	private StudentAttendanceDao studentAttendanceDao;
 	@Autowired
 	private SysConfigService sysConfigService;
-	
+	@Autowired
+	private ClassGroupStudentMapperDao classGroupStudentMapperDao;
 	@Autowired
 	private SysMessageService sysMessageService;
 
@@ -226,7 +224,14 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		if(null==user){
 			throw new BizException("请登录");
 		}
-		return courseScheduleDao.getTeacherCourseSchedulesWithDate(classDate,user.getId().longValue());
+		List<CourseScheduleDto> teacherCourseSchedulesWithDate = courseScheduleDao.getTeacherCourseSchedulesWithDate(classDate, user.getId().longValue());
+		teacherCourseSchedulesWithDate.forEach(courseScheduleDto -> {
+			if(Objects.nonNull(courseScheduleDto.getClassGroupId())){
+				String[] studentNums = classGroupStudentMapperDao.findStudentNumByClassGroupId(courseScheduleDto.getClassGroupId().longValue());
+				courseScheduleDto.setStudentNames(org.apache.commons.lang3.StringUtils.join(studentNums, ","));
+			}
+		});
+		return teacherCourseSchedulesWithDate;
 	}
 
 	/**

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupDefaultClassesCycleServiceImpl.java

@@ -12,6 +12,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Comparator;
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 @Service
@@ -27,6 +28,10 @@ public class VipGroupDefaultClassesCycleServiceImpl extends BaseServiceImpl<Inte
 
 	@Override
 	public long insert(VipGroupDefaultClassesCycle bean) {
+		if(Objects.isNull(bean.getOrganId())){
+			throw new BizException("请指定部门");
+		}
+
 		if(vipGroupDefaultClassesCycleDao.countAll()<=0){
 			bean.setMinClassTimes(0);
 			return super.insert(bean);
@@ -50,7 +55,10 @@ public class VipGroupDefaultClassesCycleServiceImpl extends BaseServiceImpl<Inte
 
 	@Override
 	public int update(VipGroupDefaultClassesCycle bean) {
+		VipGroupDefaultClassesCycle vipGroupDefaultClassesCycle = vipGroupDefaultClassesCycleDao.get(bean.getId());
 		vipGroupDefaultClassesCycleDao.delete(bean.getId());
+		bean.setId(null);
+		bean.setOrganId(vipGroupDefaultClassesCycle.getOrganId());
 		return (int) insert(bean);
 	}
 
@@ -73,6 +81,7 @@ public class VipGroupDefaultClassesCycleServiceImpl extends BaseServiceImpl<Inte
 			}else{
 				vipGroupDefaultClassesCycles.get(i).setMinClassTimes(vipGroupDefaultClassesCycles.get(i-1).getMaxClassTimes()+1);
 			}
+			vipGroupDefaultClassesCycles.get(i).setId(null);
 		}
 		return vipGroupDefaultClassesCycles;
 	}

+ 16 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -515,7 +515,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 	@Override
 	public void updateVipGroupStudentNumAndStatus(Long vipGroupId, Integer num) {
-		VipGroup vipGroup = vipGroupDao.get(vipGroupId);
+		VipGroup vipGroup = vipGroupDao.getLockVipGroup(vipGroupId);
 		if(Objects.isNull(vipGroup)){
 			throw new BizException("指定的vip课程不存在");
 		}
@@ -596,6 +596,12 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		根据回调信息调整订单状态及vip课程状态等相关信息
 		 */
 		Long vipGroupId=1L,userId=1L;
+		boolean isOk=true;
+
+		//将学生加入到班级,更新班级报名状态及人数信息
+		if(!isOk){
+			updateVipGroupStudentNumAndStatus(vipGroupId,-1);
+		}
 
 		VipGroup vipGroup = vipGroupDao.get(vipGroupId);
 
@@ -609,16 +615,16 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
 		studentPaymentOrderDao.update(studentPaymentOrder);
 
-		//将学生加入到班级,更新班级报名状态及人数信息
-		ClassGroup classGroup = classGroupDao.get(vipGroupClassGroupMapper.getClassGroupId());
-		int classStudents = classGroupDao.countClassStudent(vipGroupClassGroupMapper.getClassGroupId().longValue());
-		if(classGroup.getExpectStudentNum()==classStudents){
-			vipGroup.setStatus(VipGroupStatusEnum.FINISH);
-			vipGroupDao.update(vipGroup);
-		}
-		classGroup.setStudentNum(classGroup.getStudentNum()+1);
-		classGroupDao.update(classGroup);
+		ClassGroupStudentMapper classGroupStudentMapper=new ClassGroupStudentMapper(vipGroupClassGroupMapper.getClassGroupId(),userId.intValue());
+		classGroupStudentMapperDao.insert(classGroupStudentMapper);
 
+		//更新所属分部列表
+		List<Integer> organIds = classGroupDao.findStudentOrganIdsByClassGroup(vipGroupClassGroupMapper.getClassGroupId().longValue());
+		organIds.add(vipGroup.getOrganId());
+		HashSet<Integer> hashSet = new HashSet<>(organIds);
+		String organIdsString = StringUtils.join(hashSet, ",");
+		vipGroup.setOrganIdList(organIdsString);
+		vipGroupDao.update(vipGroup);
 	}
 
 	@Transactional(rollbackFor = Exception.class)

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

@@ -516,6 +516,14 @@
 		LEFT JOIN teacher t ON t.id_ = cgtm.user_id_
         WHERE cgtm.user_id_ = #{search} AND cg.del_flag_ = 0 AND (cg.type_ = 'NORMAL' OR cg.type_ = 'MIX')
     </select>
+    <select id="findStudentOrganIdsByClassGroup" resultType="int">
+        SELECT
+            DISTINCT su.organ_id_
+        FROM
+            class_group_student_mapper cgsm
+            LEFT JOIN sys_user su ON cgsm.user_id_=su.id_
+            WHERE cgsm.class_group_id_=#{classGroupId}
+    </select>
 
     <!-- 增加实际学生人数 -->
     <update id="addStudentNum" parameterType="com.ym.mec.biz.dal.entity.ClassGroup">

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

@@ -354,6 +354,7 @@
         su.username_ teacher_name_,
         cs.type_,
         cs.id_,
+        cs.class_group_id_,
         cs.class_date_,
         CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
         CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,

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

@@ -103,6 +103,7 @@
         student_course_homework_reply schr
         LEFT JOIN sys_user suc ON schr.user_id_=suc.id_
         <include refid="queryCondition"/>
+        ORDER BY schr.id_ DESC
         <include refid="global.limit"/>
     </select>
 

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

@@ -76,6 +76,6 @@
         FROM
             vip_group_class_group_mapper vgcgm
             LEFT JOIN class_group cg ON vgcgm.class_group_id_=cg.id_
-            WHERE vgcgm.vip_group_id_=#{vipGroupId}
+            WHERE vgcgm.vip_group_id_=#{vipGroupId} FOR UPDATE
     </select>
 </mapper>

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

@@ -254,6 +254,7 @@
     <sql id="studentVipGroupQueryCondition">
         <where>
             vg.status_!=3
+            AND vg.audit_status_='PASS'
             <if test="subjectId!=null">
                AND FIND_IN_SET(#{subjectId},cg.subject_id_list_)
             </if>

+ 142 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/SysMessageController.java

@@ -0,0 +1,142 @@
+package com.ym.mec.teacher.controller;
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.entity.SysMessage;
+import com.ym.mec.biz.dal.entity.SysMessageConfig.MessageType;
+import com.ym.mec.biz.dal.enums.MessageSendMode;
+import com.ym.mec.biz.dal.page.SysMessageQueryInfo;
+import com.ym.mec.biz.service.SysMessageService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender;
+import com.ym.mec.util.validator.CommonValidator;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.io.IOException;
+
+@RestController
+@Api(tags = "消息服务")
+@RequestMapping("sysMessage")
+public class SysMessageController extends BaseController {
+
+	@Autowired
+	private SysMessageService sysMessageService;
+
+	@Autowired
+	private SysUserFeignService sysUserFeignService;
+
+	@ApiOperation("获取所有消息列表")
+	@GetMapping(value = "list")
+	public Object list(SysMessageQueryInfo queryInfo) throws IOException {
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (sysUser == null) {
+			return failed(HttpStatus.FORBIDDEN, "请登录");
+		}
+		queryInfo.setUserId(sysUser.getId());
+		queryInfo.setType(3);
+		PageInfo<SysMessage> pageInfo = sysMessageService.queryPage(queryInfo);
+		return succeed(pageInfo);
+	}
+
+	@ApiOperation("一键已读")
+	@PostMapping("batchSetRead")
+	public Object batchSetRead() {
+		int status = 1;
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (sysUser == null) {
+			return failed(HttpStatus.FORBIDDEN, "请登录");
+		}
+		return sysMessageService.updateStatus(sysUser.getId(), status) > 0 ? succeed() : failed();
+	}
+
+	@ApiOperation("设置已读")
+	@PostMapping("setRead")
+	public Object setRead(Long id) {
+		int status = 1;
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (sysUser == null) {
+			return failed(HttpStatus.FORBIDDEN, "请登录");
+		}
+		return sysMessageService.updateOneStatus(id, status) > 0 ? succeed() : failed();
+	}
+
+	@ApiOperation(value = "查询用户未读消息条数")
+	@GetMapping("/queryCountOfUnread")
+	public Object queryCountOfUnread() {
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (sysUser == null) {
+			return failed("请重新登录");
+		}
+		return succeed(sysMessageService.queryCountOfUnread(sysUser.getId()));
+	}
+
+	@ApiOperation(value = "发送短信验证码")
+	@PostMapping("/sendSmsCode")
+	public Object sendSmsCode(String sendCodeType, String mobileNo) {
+
+		SysUser sysUser;
+
+		if (StringUtils.isBlank(mobileNo)) {
+			sysUser = sysUserFeignService.queryUserInfo();
+		} else {
+			sysUser = sysUserFeignService.queryUserByMobile(mobileNo);
+		}
+		if (sysUser == null) {
+			return failed(HttpStatus.FORBIDDEN, "请登录");
+		}
+		Integer userId = sysUser.getId();
+
+		mobileNo = sysUser.getPhone();
+
+		MessageType messageType = MessageType.getMessageType(sendCodeType);
+		if (messageType == null) {
+			throw new BizException("消息类型参数错误");
+		}
+		if (StringUtils.isBlank(mobileNo) || !CommonValidator.isMobileNo(mobileNo)) {
+			throw new BizException("请输入正确的手机号");
+		}
+		sysMessageService.sendSecurityCode(MessageSender.YIMEI, userId, MessageSendMode.SMS, messageType, mobileNo);
+		return succeed();
+	}
+
+	@ApiOperation(value = "发送短信验证码")
+	@PostMapping("/noAuth/sendSmsCode")
+	public Object noAuthSendSmsCode(String sendCodeType, String mobileNo) {
+		MessageType messageType = MessageType.getMessageType(sendCodeType);
+		if (messageType == null) {
+			throw new BizException("消息类型参数错误");
+		}
+		if (StringUtils.isBlank(mobileNo) || !CommonValidator.isMobileNo(mobileNo)) {
+			throw new BizException("请输入正确的手机号");
+		}
+//		sysMessageService.sendSecurityCode(MessageSender.YIMEI, userId, MessageSendMode.SMS, messageType, mobileNo);
+		return succeed();
+	}
+
+	@ApiOperation(value = "发送消息")
+	@PostMapping("/sendMessage")
+	public Object sendMessage(MessageSender messageSender, MessageSendMode sendMode, String content, String receiver, int readStatus, String url) {
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (sysUser == null) {
+			return failed(HttpStatus.FORBIDDEN, "请登录");
+		}
+		Integer userId = sysUser.getId();
+
+		String mobileNo = sysUser.getPhone();
+		if (StringUtils.isBlank(mobileNo) || !CommonValidator.isMobileNo(mobileNo)) {
+			throw new BizException("请输入正确的手机号");
+		}
+		sysMessageService.sendMessage(messageSender, userId, sendMode, "", content, receiver, null, readStatus, url);
+		return succeed();
+	}
+}

+ 1 - 1
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherCourseHomeworkReplyController.java

@@ -31,7 +31,7 @@ public class TeacherCourseHomeworkReplyController extends BaseController {
 
     @ApiOperation(value = "新增回复")
     @PostMapping("/add")
-    public Object add(StudentCourseHomeworkReply studentCourseHomeworkReply) {
+    public Object add(@RequestBody StudentCourseHomeworkReply studentCourseHomeworkReply) {
         SysUser user = sysUserFeignService.queryUserInfo();
         if(Objects.isNull(user)){
             return failed(HttpStatus.FORBIDDEN,"请登录");