Browse Source

增加删除班级学生接口

周箭河 5 years ago
parent
commit
af6fd76ead

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

@@ -88,4 +88,12 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
      * @date 2019/10/19
      */
     List<StudentAttendanceViewDto> findStudentByCourse(Long courseScheduleId);
+
+    /**
+     * 查找班级学生对应关系
+     * @param userId
+     * @param classGroupId
+     * @return
+     */
+    ClassGroupStudentMapper findClassStudentMapperByUserIdAndClassGroupId(@Param("userId") Integer userId, @Param("classGroupId") Integer classGroupId);
 }

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

@@ -8,4 +8,12 @@ import org.apache.ibatis.annotations.Param;
 import java.util.List;
 
 public interface ClassGroupStudentMapperService extends BaseService<Long, ClassGroupStudentMapper> {
+
+    /**
+     * 查找班级学生对应关系
+     * @param userId
+     * @param classGroupId
+     * @return
+     */
+    ClassGroupStudentMapper findClassStudentMapperByUserIdAndClassGroupId(Integer userId, Integer classGroupId);
 }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -21,4 +21,9 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
 	public BaseDAO<Long, ClassGroupStudentMapper> getDAO() {
 		return classGroupStudentMapperDao;
 	}
+
+    @Override
+    public ClassGroupStudentMapper findClassStudentMapperByUserIdAndClassGroupId(Integer userId, Integer classGroupId) {
+        return classGroupStudentMapperDao.findClassStudentMapperByUserIdAndClassGroupId(userId,classGroupId);
+    }
 }

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml

@@ -141,4 +141,8 @@
     <delete id="deleteStudentByClassGroupId">
         DELETE FROM class_group_student_mapper WHERE class_group_id_=#{classGroupId} AND user_id_=#{userId}
     </delete>
+
+    <select id="findClassStudentMapperByUserIdAndClassGroupId" resultMap="ClassGroupStudentMapper">
+        SELECT * FROM class_group_student_mapper WHERE user_id_=#{userId} AND class_group_id_=#{classGroupId} AND status_ = 'NORMAL'
+    </select>
 </mapper>

+ 40 - 0
mec-web/src/main/java/com/ym/mec/web/controller/ClassGroupStudentController.java

@@ -0,0 +1,40 @@
+package com.ym.mec.web.controller;
+
+
+import com.ym.mec.biz.dal.entity.ClassGroup;
+import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
+import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
+import com.ym.mec.biz.service.ClassGroupStudentMapperService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RequestMapping("classGroupStudent")
+@Api(tags = "班级学生服务")
+@RestController
+public class ClassGroupStudentController extends BaseController {
+
+    @Autowired
+    private ClassGroupStudentMapperService classGroupStudentMapperService;
+
+
+    @ApiOperation(value = "删除班级学生")
+    @PostMapping("/del")
+    @PreAuthorize("@pcs.hasPermissions('classGroupStudent/del')")
+    public HttpResponseResult add(Integer userId, Integer classGroupId) throws Exception {
+        ClassGroupStudentMapper classStudentMapper = classGroupStudentMapperService.findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupId);
+        if (classStudentMapper == null) {
+            return failed("班级学生不存在");
+        }
+        classStudentMapper.setStatus(ClassGroupStudentStatusEnum.QUIT);
+        return succeed(classGroupStudentMapperService.update(classStudentMapper));
+    }
+
+}