From 9c156eea23d8bdf7d2378c3f7fb3557b06a7cd33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cfeng=E2=80=9D?= <“feng@123.com”> Date: Wed, 27 Oct 2021 19:30:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E9=80=9A=E8=AE=AF?= =?UTF-8?q?=E5=BD=95=E6=8E=A5=E5=8F=A3=E7=9A=84CRUD=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AddressListGroupController.java | 166 +++++++++++++++++- .../controller/ClassSubjectController.java | 36 ---- .../controller/StudentClassController.java | 54 +++++- .../mapper/AddressListGroupMapper.java | 10 ++ .../pojo/dto/AddressListGroupDto.java | 47 +++++ .../pojo/vo/ParentGroupVO.java | 58 ++++++ .../pojo/vo/StudentGroupVO.java | 45 +++++ .../pojo/vo/TeacherGroupVO.java | 43 +++++ .../service/AddressListGroupService.java | 14 ++ .../impl/AddressListGroupServiceImpl.java | 33 ++++ .../mapper/AddressListGroupMapper.xml | 31 ++++ 11 files changed, 494 insertions(+), 43 deletions(-) create mode 100644 src/main/java/com/mobile_education_platform/pojo/dto/AddressListGroupDto.java create mode 100644 src/main/java/com/mobile_education_platform/pojo/vo/ParentGroupVO.java create mode 100644 src/main/java/com/mobile_education_platform/pojo/vo/StudentGroupVO.java create mode 100644 src/main/java/com/mobile_education_platform/pojo/vo/TeacherGroupVO.java diff --git a/src/main/java/com/mobile_education_platform/controller/AddressListGroupController.java b/src/main/java/com/mobile_education_platform/controller/AddressListGroupController.java index e30b13b..bc5f2df 100644 --- a/src/main/java/com/mobile_education_platform/controller/AddressListGroupController.java +++ b/src/main/java/com/mobile_education_platform/controller/AddressListGroupController.java @@ -1,10 +1,27 @@ package com.mobile_education_platform.controller; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.mobile_education_platform.common.ParamException; +import com.mobile_education_platform.common.R; +import com.mobile_education_platform.pojo.AddressListGroup; +import com.mobile_education_platform.pojo.StudentClass; +import com.mobile_education_platform.pojo.dto.AddressListGroupDto; +import com.mobile_education_platform.pojo.vo.ParentGroupVO; +import com.mobile_education_platform.pojo.vo.StudentGroupVO; +import com.mobile_education_platform.pojo.vo.TeacherGroupVO; +import com.mobile_education_platform.service.AddressListGroupService; +import com.mobile_education_platform.service.ClassService; import io.swagger.annotations.Api; -import org.springframework.web.bind.annotation.RequestMapping; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; -import org.springframework.web.bind.annotation.RestController; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** *

@@ -16,8 +33,151 @@ import org.springframework.web.bind.annotation.RestController; */ @RestController @RequestMapping("/address-list-group") -@Api(tags = "") +@Api(tags = "前台班级通讯录信息") public class AddressListGroupController { + + @Autowired + private ClassService classService; + + @Autowired + private AddressListGroupService addressListGroupService; + + /** + * @description: 为班级人员标签页新增标签页分组 + * @param: 添加標籤頁對象 + * @return: + * @author feng + * @date: 2021/10/27 8:30 + */ + @PostMapping ("/{headTeacherId}") + @ApiOperation(value="为班级人员标签页新增标签页分组") + @ApiImplicitParam(name = "headTeacherId",value = "班主任id") + public R insertGroup(@PathVariable String headTeacherId,@RequestBody AddressListGroupDto addressListGroupDto){ + if(headTeacherId==null){ + throw new ParamException("参数为空"); + } + //判断是否为该班的班主任 + if (classService.whetherTheHeadTeacher(headTeacherId, addressListGroupDto.getClassId()) != 0) { + int result = addressListGroupService.insert(new AddressListGroup() + .setClassId(addressListGroupDto.getClassId()) + .setGroupName(addressListGroupDto.getGroupName()) + .setGroupNum(addressListGroupDto.getGroupNum()) + .setRole(addressListGroupDto.getRole()) + ); + if (result == 1) { + return R.ok(200, "添加成功"); + } + return R.error(500, "添加失败"); + } else { + return R.error(500, "用户不是本班级的班主任"); + } + } + + /** + * @description: 为班级人员标签页新增标签页分组 + * @param: 班主任id,標籤頁id + * @return: + * @author feng + * @date: 2021/10/27 8:30 + */ + @DeleteMapping ("/{headTeacherId}/{groupId}") + @ApiOperation(value="根据标签页id删除标签页分组") + @ApiImplicitParams({ + @ApiImplicitParam(name = "headTeacherId",value = "班主任id"), + @ApiImplicitParam(name = "groupId",value = "标签页id")} + ) + public R deleteGroup(@PathVariable String headTeacherId,@PathVariable String groupId){ + if(headTeacherId==null || groupId==null){ + throw new ParamException("参数为空"); + } + //根据标签页id查询班级id + String classId = addressListGroupService.selectClassIdByID(groupId).getClassId(); + //判断是否为该班的班主任 + if (classService.whetherTheHeadTeacher(headTeacherId,classId) != 0) { + boolean result = addressListGroupService.removeById(groupId); + if (result) { + return R.ok(200, "刪除成功"); + } + return R.error(500, "刪除失败"); + } else { + return R.error(500, "用户不是本班级的班主任"); + } + } + + + /** + * @description: 根据班级id查询班级标签页分组 + * @param: + * @return: + * @author feng + * @date: 2021/10/27 8:30 + */ + @GetMapping ("/{classId}") + @ApiOperation(value="根据班级id删除标签页分组") + @ApiImplicitParam(name = "classId",value = "班級id") + public R selectByClassId(@PathVariable String classId){ + if( classId == null){ + throw new ParamException("参数为空"); + } + QueryWrapper queryWrapper =new QueryWrapper<>(); + queryWrapper.in("class_id",classId); + List list = addressListGroupService.list(queryWrapper); + if(list.size()>=1){ + Map map = new HashMap(); + map.put("data",list); + return R.ok(200,"查詢成功",map); + } + return R.ok(200,"查询到0条记录"); + } + + /** + * @description: 根据班级id查询班级标签页分组 + * @param: + * @return: + * @author feng + * @date: 2021/10/27 8:30 + */ + @GetMapping ("/{role}/{groupId}/") + @ApiOperation(value="根据标签页id删除标签页分组") + @ApiImplicitParams({ + @ApiImplicitParam(name = "role",value = "身份(教师1,学生2)"), + @ApiImplicitParam(name = "groupId",value = "id")}) + public R selectByGroupId(@PathVariable String role, @PathVariable String groupId){ + if( role == null ||groupId == null){ + throw new ParamException("参数为空"); + } + AddressListGroup addressListGroup = addressListGroupService.selectClassIdByID(groupId); + if (addressListGroup==null){ + return R.error(500,"查询失败"); + } + String classId = addressListGroup.getClassId(); + Map map =new HashMap(); +// 获取学生对象合集 + List studentList = addressListGroupService.selectStudentGroup(classId); + +// 获取教师对象合集 + List teacherList = addressListGroupService.selectTeacherGroup(classId); + +// 获取家长对象合集 + if(role.equals("1")){ + List parentList = addressListGroupService.selectParentGroupVO(classId); + map.put("parentList",parentList); + + } + + map.put("studentList",studentList); + map.put("teacherList",teacherList); + + return R.ok(200,map); + +// return R.ok(200,"查询到0条记录"); + } + + + + + + } diff --git a/src/main/java/com/mobile_education_platform/controller/ClassSubjectController.java b/src/main/java/com/mobile_education_platform/controller/ClassSubjectController.java index f133302..6f94f41 100644 --- a/src/main/java/com/mobile_education_platform/controller/ClassSubjectController.java +++ b/src/main/java/com/mobile_education_platform/controller/ClassSubjectController.java @@ -25,42 +25,6 @@ import org.springframework.web.bind.annotation.*; @RequestMapping("/class-subject") @Api(tags = "前台班级学科管理") public class ClassSubjectController { - @Autowired - private StudentClassService studentClassService; - @Autowired - private ClassService classService; - /** - * @description: 添加学生班级信息 - * @param: 学生班级对象 - * @return: 是否添加成功 - * @author feng - * @date: 2021/10/26 16:04 - */ - @PostMapping("/{headTeacherId}") - @ApiOperation(value="添加学生班级信息",httpMethod = "POST") - @ApiImplicitParam(name = "headTeacherId",value = "班主任id") - public R insert(@PathVariable String headTeacherId, @RequestBody(required = false) StudentClassDto studentClassDto){ - if(studentClassDto==null){ - throw new ParamException("参数为空"); - } - //判断是否为该班的班主任 - if (classService.whetherTheHeadTeacher(headTeacherId, studentClassDto.getClassId()) != 0) {//判断此同學是否已是同年级下其他班的学生 - Boolean isExistOrderClass = studentClassService.selectIsExistOrtherClassOnOneGrade(studentClassDto); - if (isExistOrderClass == false) { - return R.error(500, "添加失败,该学生已在同年级加入其他班级"); - } - int result = studentClassService.insert(new StudentClass() - .setClassId(studentClassDto.getClassId()) - .setStudentId(studentClassDto.getStudentId()) - ); - if (result == 1) { - return R.ok(200, "添加成功"); - } - return R.error(500, "添加失败"); - } else { - return R.error(500, "用户不是本班级的班主任"); - } - } } diff --git a/src/main/java/com/mobile_education_platform/controller/StudentClassController.java b/src/main/java/com/mobile_education_platform/controller/StudentClassController.java index 5e9a8b3..8a2333b 100644 --- a/src/main/java/com/mobile_education_platform/controller/StudentClassController.java +++ b/src/main/java/com/mobile_education_platform/controller/StudentClassController.java @@ -1,10 +1,17 @@ package com.mobile_education_platform.controller; +import com.mobile_education_platform.common.ParamException; +import com.mobile_education_platform.common.R; +import com.mobile_education_platform.pojo.StudentClass; +import com.mobile_education_platform.pojo.dto.StudentClassDto; +import com.mobile_education_platform.service.ClassService; +import com.mobile_education_platform.service.StudentClassService; import io.swagger.annotations.Api; -import org.springframework.web.bind.annotation.RequestMapping; - -import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; /** *

@@ -16,8 +23,47 @@ import org.springframework.web.bind.annotation.RestController; */ @RestController @RequestMapping("/student-class") -@Api(tags = "") +@Api(tags = "前台学生班级管理") public class StudentClassController { + @Autowired + private StudentClassService studentClassService; + + @Autowired + private ClassService classService; + /** + * @description: 添加学生班级信息 + * @param: 学生班级对象 + * @return: 是否添加成功 + * @author feng + * @date: 2021/10/26 16:04 + */ + @PostMapping("/{headTeacherId}") + @ApiOperation(value="添加学生班级信息",httpMethod = "POST") + @ApiImplicitParam(name = "headTeacherId",value = "班主任id") + public R insert(@PathVariable String headTeacherId, @RequestBody(required = false) StudentClassDto studentClassDto){ + if(studentClassDto==null){ + throw new ParamException("参数为空"); + } + //判断是否为该班的班主任 + if (classService.whetherTheHeadTeacher(headTeacherId, studentClassDto.getClassId()) != 0) { + //判断此同學是否已是同年级下其他班的学生 + Boolean isExistOrderClass = studentClassService.selectIsExistOrtherClassOnOneGrade(studentClassDto); + if (isExistOrderClass == false) { + return R.error(500, "添加失败,该学生已在同年级加入其他班级"); + } + int result = studentClassService.insert(new StudentClass() + .setClassId(studentClassDto.getClassId()) + .setStudentId(studentClassDto.getStudentId()) + ); + if (result == 1) { + return R.ok(200, "添加成功"); + } + return R.error(500, "添加失败"); + } else { + return R.error(500, "用户不是本班级的班主任"); + } + } + } diff --git a/src/main/java/com/mobile_education_platform/mapper/AddressListGroupMapper.java b/src/main/java/com/mobile_education_platform/mapper/AddressListGroupMapper.java index 68464f3..a3b274b 100644 --- a/src/main/java/com/mobile_education_platform/mapper/AddressListGroupMapper.java +++ b/src/main/java/com/mobile_education_platform/mapper/AddressListGroupMapper.java @@ -2,8 +2,13 @@ package com.mobile_education_platform.mapper; import com.mobile_education_platform.pojo.AddressListGroup; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mobile_education_platform.pojo.vo.ParentGroupVO; +import com.mobile_education_platform.pojo.vo.StudentGroupVO; +import com.mobile_education_platform.pojo.vo.TeacherGroupVO; import org.springframework.stereotype.Repository; +import java.util.List; + /** *

* Mapper 接口 @@ -15,4 +20,9 @@ import org.springframework.stereotype.Repository; @Repository public interface AddressListGroupMapper extends BaseMapper { + List selectStudentGroupByClassId(String classId); + + List selectTeacherGroupByClassId(String classId); + + List selectParentGroupByClassId(String classId); } diff --git a/src/main/java/com/mobile_education_platform/pojo/dto/AddressListGroupDto.java b/src/main/java/com/mobile_education_platform/pojo/dto/AddressListGroupDto.java new file mode 100644 index 0000000..0f55ce1 --- /dev/null +++ b/src/main/java/com/mobile_education_platform/pojo/dto/AddressListGroupDto.java @@ -0,0 +1,47 @@ +package com.mobile_education_platform.pojo.dto; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * + *

+ * + * @author 元架構 + * @since 2021-10-25 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = true) +@ApiModel(value="AddressListGroupDto对象", description="") +public class AddressListGroupDto implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "分组名称") + private String groupName; + + @ApiModelProperty(value = "分组人数") + private Integer groupNum; + + @ApiModelProperty(value = "分组类型(1教师、2学生、3家长)") + private Integer role; + + @ApiModelProperty(value = "班级id") + private String classId; + + +} diff --git a/src/main/java/com/mobile_education_platform/pojo/vo/ParentGroupVO.java b/src/main/java/com/mobile_education_platform/pojo/vo/ParentGroupVO.java new file mode 100644 index 0000000..b687b22 --- /dev/null +++ b/src/main/java/com/mobile_education_platform/pojo/vo/ParentGroupVO.java @@ -0,0 +1,58 @@ +package com.mobile_education_platform.pojo.vo; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * + *

+ * + * @author 元架構 + * @since 2021-10-25 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = true) +@ApiModel(value="Parent通讯录对象", description="") +public class ParentGroupVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "家长id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + private String pid; + + @ApiModelProperty(value = "中文名") + @TableField("name_CN") + private String nameCn; + + @ApiModelProperty(value = "外文名") + @TableField("name_PT") + private String namePt; + + @ApiModelProperty(value = "家长编号") + private String number; + + @ApiModelProperty(value = "个人照片") + private String photo; + + @ApiModelProperty(value = "联系电话") + private String phone; + + + + +} diff --git a/src/main/java/com/mobile_education_platform/pojo/vo/StudentGroupVO.java b/src/main/java/com/mobile_education_platform/pojo/vo/StudentGroupVO.java new file mode 100644 index 0000000..a4179a1 --- /dev/null +++ b/src/main/java/com/mobile_education_platform/pojo/vo/StudentGroupVO.java @@ -0,0 +1,45 @@ +package com.mobile_education_platform.pojo.vo; + + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = true) +@ApiModel(value="学生通讯录对象", description="") +public class StudentGroupVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "学生id") + @TableId(value = "sid", type = IdType.ASSIGN_ID) + private String sid; + + @ApiModelProperty(value = "中文名") + @TableField("name_CN") + private String nameCn; + + @ApiModelProperty(value = "外文名") + @TableField("name_PT") + private String namePt; + + @ApiModelProperty(value = "联系电话") + private String phone; + + @ApiModelProperty(value = "个人照片") + private String photo; + +} diff --git a/src/main/java/com/mobile_education_platform/pojo/vo/TeacherGroupVO.java b/src/main/java/com/mobile_education_platform/pojo/vo/TeacherGroupVO.java new file mode 100644 index 0000000..5bc63b1 --- /dev/null +++ b/src/main/java/com/mobile_education_platform/pojo/vo/TeacherGroupVO.java @@ -0,0 +1,43 @@ +package com.mobile_education_platform.pojo.vo; + + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = true) +@ApiModel(value="教师通讯录对象", description="") +public class TeacherGroupVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "教师id") + @TableId(value = "sid", type = IdType.ASSIGN_ID) + private String tid; + + @ApiModelProperty(value = "中文名") + @TableField("name_CN") + private String nameCn; + + @ApiModelProperty(value = "外文名") + @TableField("name_PT") + private String namePt; + + @ApiModelProperty(value = "联系电话") + private String phone; + + @ApiModelProperty(value = "个人照片") + private String photo; + +} diff --git a/src/main/java/com/mobile_education_platform/service/AddressListGroupService.java b/src/main/java/com/mobile_education_platform/service/AddressListGroupService.java index 882b42a..d70576f 100644 --- a/src/main/java/com/mobile_education_platform/service/AddressListGroupService.java +++ b/src/main/java/com/mobile_education_platform/service/AddressListGroupService.java @@ -2,6 +2,11 @@ package com.mobile_education_platform.service; import com.mobile_education_platform.pojo.AddressListGroup; import com.baomidou.mybatisplus.extension.service.IService; +import com.mobile_education_platform.pojo.vo.ParentGroupVO; +import com.mobile_education_platform.pojo.vo.StudentGroupVO; +import com.mobile_education_platform.pojo.vo.TeacherGroupVO; + +import java.util.List; /** *

@@ -13,4 +18,13 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface AddressListGroupService extends IService { + int insert(AddressListGroup addressListGroup); + + AddressListGroup selectClassIdByID(String groupId); + + List selectStudentGroup(String classId); + + List selectTeacherGroup(String classId); + + List selectParentGroupVO(String classId); } diff --git a/src/main/java/com/mobile_education_platform/service/impl/AddressListGroupServiceImpl.java b/src/main/java/com/mobile_education_platform/service/impl/AddressListGroupServiceImpl.java index e1b01c7..027528f 100644 --- a/src/main/java/com/mobile_education_platform/service/impl/AddressListGroupServiceImpl.java +++ b/src/main/java/com/mobile_education_platform/service/impl/AddressListGroupServiceImpl.java @@ -2,10 +2,16 @@ package com.mobile_education_platform.service.impl; import com.mobile_education_platform.pojo.AddressListGroup; import com.mobile_education_platform.mapper.AddressListGroupMapper; +import com.mobile_education_platform.pojo.vo.ParentGroupVO; +import com.mobile_education_platform.pojo.vo.StudentGroupVO; +import com.mobile_education_platform.pojo.vo.TeacherGroupVO; import com.mobile_education_platform.service.AddressListGroupService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + /** *

* 服务实现类 @@ -17,4 +23,31 @@ import org.springframework.stereotype.Service; @Service public class AddressListGroupServiceImpl extends ServiceImpl implements AddressListGroupService { + @Autowired + private AddressListGroupMapper addressListGroupMapper; + + @Override + public int insert(AddressListGroup addressListGroup) { + return addressListGroupMapper.insert(addressListGroup); + } + + @Override + public AddressListGroup selectClassIdByID(String groupId) { + return addressListGroupMapper.selectById(groupId); + } + + @Override + public List selectStudentGroup(String classId) { + return addressListGroupMapper.selectStudentGroupByClassId(classId); + } + + @Override + public List selectTeacherGroup(String classId) { + return addressListGroupMapper.selectTeacherGroupByClassId(classId); + } + + @Override + public List selectParentGroupVO(String classId) { + return addressListGroupMapper.selectParentGroupByClassId(classId); + } } diff --git a/src/main/resources/mapper/AddressListGroupMapper.xml b/src/main/resources/mapper/AddressListGroupMapper.xml index 5e79551..8ed7690 100644 --- a/src/main/resources/mapper/AddressListGroupMapper.xml +++ b/src/main/resources/mapper/AddressListGroupMapper.xml @@ -2,4 +2,35 @@ + + + + + + -- Gitee