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 e30b13b95ae82a6a08fa39c85d74d6ba11399ced..bc5f2df064d24f81f04e2166e4dd114647a9cc89 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 d1d3b3247e76911623a8723bb4fa0393ae229eb8..c297e3e51628610470b859d388fead04d5ae273e 100644 --- a/src/main/java/com/mobile_education_platform/controller/ClassSubjectController.java +++ b/src/main/java/com/mobile_education_platform/controller/ClassSubjectController.java @@ -25,8 +25,6 @@ import org.springframework.web.bind.annotation.*; @RequestMapping("/class-subject") @Api(tags = "前台班级学科管理") public class ClassSubjectController { - @Autowired - private StudentClassService studentClassService; @Autowired private ClassService classService; 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 5e9a8b339683026f11d98b8341adc06da0a0ed71..8a2333bda6ef7596e2498dbe654b24ddc9723185 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 68464f39cde7f1164bb59d8cc2493b95442d40e3..a3b274b20f4c7d2ce25d5cbd81e7ebdb5f4dbc99 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 0000000000000000000000000000000000000000..0f55ce142b5a7232d55ed30324a496d24770a65b --- /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 0000000000000000000000000000000000000000..b687b226f5e153700491d89f5edaaf4253e86e1c --- /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 0000000000000000000000000000000000000000..a4179a1ba9cecbb3b039e2900f996907fc1bf79c --- /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 0000000000000000000000000000000000000000..5bc63b16bed3e727aa10f9e378a550ad515323d9 --- /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 882b42a9c8cd7155cf5eb086366008edf4a4310c..d70576ff095d12c81c5891adc73d610912f7fa70 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 e1b01c77be3a0b9022502adfcdaa9d23952b4fe0..027528f15d43e0053069ff67ade914fd16bb8989 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 5e795517c012d3ac76220876d3298f0e9c17238e..8ed7690176f35f984fb471664e4dbfc584dfad27 100644 --- a/src/main/resources/mapper/AddressListGroupMapper.xml +++ b/src/main/resources/mapper/AddressListGroupMapper.xml @@ -2,4 +2,35 @@ + + + + + +