diff --git a/src/main/java/com/mobile_education_platform/controller/NoticeController.java b/src/main/java/com/mobile_education_platform/controller/NoticeController.java index 641587cd0698c2f6f480da2c0d6701d713b75921..53c4cd6554303bde62d520b0168ce664fb7479bb 100644 --- a/src/main/java/com/mobile_education_platform/controller/NoticeController.java +++ b/src/main/java/com/mobile_education_platform/controller/NoticeController.java @@ -1,14 +1,26 @@ package com.mobile_education_platform.controller; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.mobile_education_platform.common.R; +import com.mobile_education_platform.pojo.*; +import com.mobile_education_platform.pojo.Class; +import com.mobile_education_platform.service.*; 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.apache.commons.collections.map.LinkedMap; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; -import org.springframework.web.bind.annotation.RestController; +import java.text.SimpleDateFormat; +import java.util.*; /** *

- * 前端控制器 + * 前端控制器 *

* * @author 元架構 @@ -16,8 +28,172 @@ import org.springframework.web.bind.annotation.RestController; */ @RestController @RequestMapping("/notice") -@Api(tags = "") +@Api(tags = "前台通知模块接口") public class NoticeController { + @Autowired + public StudentClassService studentClassService; + + @Autowired + public NoticeService noticeService; + + @Autowired + public UserService userService; + + @Autowired + public TeacherService teacherService; + + @Autowired + public TeacherClassSubjectService teacherClassSubjectService; + + @Autowired + public ClassNoticeService classNoticeService; + + @Autowired + public GradeService gradeService; + + @Autowired + public ClassService classService; + + @ApiOperation(value = "系统消息-查询接口", notes = "查询本人参与的逻辑删除字段不为0的班级的通知,以学期为条件来排序查询。") + @RequestMapping(value = "/notices/{schoolSemester}/{id}", method = RequestMethod.GET) + public R inNotice(@PathVariable("id") String id, + @PathVariable("schoolSemester") String schoolSemester) { + Map data = new HashMap<>(); + //根据学年学期来确定grade + Date date = new Date(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy"); + String schoolYear = dateFormat.format(date); + //判断身份,根据身份不同来确定查询的方法 + User user = userService.getByUserNumber(id); + if (user==null){ + return R.error("请检查用户是否存在!"); + } + Integer userRole = user.getRole(); + if (userRole == 1) { + //身份为教师 + List teachClasses = teacherClassSubjectService.listByTeacherId(id); + for (TeacherClassSubject teachClass : teachClasses) { + //一条classId只存在于一个class_id_group中 + String classId=teachClass.getClassId(); + Grade grade = gradeService.getByConditions(schoolYear,schoolSemester,classId); + if (grade == null) { + return R.error("该学期无数据!"); + } + String gradeId=grade.getId(); + Class teacherClass = classService.getClassByIdAndGradeId(classId, gradeId); + List noticeIds = classNoticeService.listByClassId(teacherClass.getId()); + for (ClassNotice noticeId : noticeIds) { + Notice notice = noticeService.getById(noticeId); + if (notice.getIsDeleted()!=1){ + continue; + } + Map noticeInfo = new LinkedHashMap<>(); + noticeInfo.put("title", notice.getTitle()); + noticeInfo.put("content", notice.getContent()); + noticeInfo.put("create_time", notice.getCreateTime()); + data.put(notice.getTitle(), noticeInfo); + } + } + return R.ok("查询成功!", data); + } else if (userRole == 2) { + //身份为学生 + StudentClass student = studentClassService.getByStudentId(id); + if (student == null) { + return R.error("请检查资料是否有误!"); + } + String classId = student.getClassId(); + Grade grade = gradeService.getByConditions(schoolYear,schoolSemester,classId); + if (grade == null) { + return R.error("该学期无数据!"); + } + Class studentClass = classService.getClassByIdAndGradeId(classId,grade.getId()); + if (studentClass == null) { + return R.error("请检查是否有误!"); + } + List noticeIds = classNoticeService.listByClassId(classId); + for (ClassNotice noticeId : noticeIds) { + Notice notice = noticeService.getById(noticeId); + if (notice.getIsDeleted()!=1){ + continue; + } + Map noticeInfo = new LinkedHashMap<>(); + noticeInfo.put("title", notice.getTitle()); + noticeInfo.put("content", notice.getContent()); + noticeInfo.put("create_time", notice.getCreateTime()); + data.put(notice.getTitle(), noticeInfo); + } + return R.ok("查询成功!", data); + } + return R.error("查询失败!请检查资料是否关联!"); + } + + @ApiOperation(value = "发送通知-添加接口") + @RequestMapping(value = "/notice/{classId}", method = RequestMethod.POST) + public R addNotice(@RequestBody Notice notice, + @PathVariable("classId") String classId) { + boolean saveNotice = noticeService.save(notice); + if (!saveNotice) { + return R.error("保存通知失败!请检查是否有误!"); + } + ClassNotice classNotice = new ClassNotice(); + classNotice.setNoticeId(notice.getId()); + classNotice.setClassId(classId); + boolean saveClassNotice = classNoticeService.save(classNotice); + if (!saveClassNotice) { + return R.error("请检查班级是否有误!"); + } + List studentClassList = studentClassService.listByClassId(classId); + List studentIds = new ArrayList<>(); + for (StudentClass studentClass : studentClassList) { + studentIds.add(studentClass.getStudentId()); + } + //调用后台 + //****** + return R.ok("新发布通知已完成群发。"); + } + + @ApiOperation(value = "发送通知-查询接口") + @RequestMapping(value = "/notice/{id}/", method = RequestMethod.GET) + public R selectNotice(@PathVariable("classId") String classId, + @PathVariable("pageNum") Integer pageNum, + @PathVariable("pageCount") Integer pageCount) { + Map data=new HashMap<>(); + if (pageNum<=0) { + return R.error(404, "页数错误!"); + } + List noticeIds = classNoticeService.listNoticeIdsByClassId(classId); + Page noticePage = noticeService.getNoticePage(pageNum, pageCount, classId); + if (noticePage.getRecords().size()<=0){ + return R.error("查询失败!请检查当前页数是否超出范围!"); + } + if (noticePage.getTotal()<=0){ + return R.error("当前查无数据!"); + } + return R.ok("查询成功!",data); + } + + @ApiOperation(value = "发送通知-删除接口") + @ApiImplicitParam(name = "待删除的通知ID", value = "id", required = true, paramType = "string") + @RequestMapping(value = "/notice/{id}", method = RequestMethod.DELETE) + public R deleteNotice(@PathVariable("id") String id) { + Notice notice = noticeService.getById(id); + notice.setIsDeleted(0); + return R.ok("删除文章成功!"); + } + + public Map putNoticeInfo(List noticeIds){ + Map data=new HashMap<>(); + Map noticesInfo=new HashMap<>(); + int count=0; + List notices = noticeService.listByNoticeList(noticeIds); + for(Notice notice:notices){ + noticesInfo.put("title",notice.getTitle()); + noticesInfo.put("content",notice.getContent()); + noticesInfo.put("create_time",notice.getCreateTime()); + data.put(Integer.toString(++count),noticesInfo); + } + return data; + } } diff --git a/src/main/java/com/mobile_education_platform/service/ClassNoticeService.java b/src/main/java/com/mobile_education_platform/service/ClassNoticeService.java index 13c344825771badafa8c5d32b135debd402b996a..c1fb50be22311a292d33b7e12330933243b5c6cf 100644 --- a/src/main/java/com/mobile_education_platform/service/ClassNoticeService.java +++ b/src/main/java/com/mobile_education_platform/service/ClassNoticeService.java @@ -3,6 +3,8 @@ package com.mobile_education_platform.service; import com.mobile_education_platform.pojo.ClassNotice; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** *

* 服务类 @@ -13,4 +15,21 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface ClassNoticeService extends IService { + /** + * 功能: 根据班级ID获取List + * @author: 陈梓康 + * @Created: 2021/10/26 20:26 + * @param classId 班级ID + * @return List + */ + List listByClassId(String classId); + + /** + * 功能: 根据班级ID获取通知ID的List + * @author: 陈梓康 + * @Created: 2021/10/26 20:49 + * @param classId 班级ID + * @return 通知ID的List + */ + List listNoticeIdsByClassId(String classId); } diff --git a/src/main/java/com/mobile_education_platform/service/ClassService.java b/src/main/java/com/mobile_education_platform/service/ClassService.java index 282c65a859cfaf21ba85a2fd1567baeabd9c7483..7b9f0419e37c3cf5821a13ec2a0bf5801dad974f 100644 --- a/src/main/java/com/mobile_education_platform/service/ClassService.java +++ b/src/main/java/com/mobile_education_platform/service/ClassService.java @@ -23,4 +23,13 @@ public interface ClassService extends IService { */ int whetherTheHeadTeacher(String tId,String cId); + /** + * 功能: 根据classId和gradeId查询Class + * @author: 陈梓康 + * @Created: 2021/10/26 20:07 + * @param id class_id + * @param gradeId grade_id + * @return Class对象 + */ + Class getClassByIdAndGradeId(String id,String gradeId); } diff --git a/src/main/java/com/mobile_education_platform/service/GradeService.java b/src/main/java/com/mobile_education_platform/service/GradeService.java index a4f2afbcc2ad18f322e3f3f108768ce75005b4d1..1b540be0cf5948cda1c8d2df9d6504b7a3b848e4 100644 --- a/src/main/java/com/mobile_education_platform/service/GradeService.java +++ b/src/main/java/com/mobile_education_platform/service/GradeService.java @@ -13,4 +13,15 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface GradeService extends IService { + /** + * 功能: 根据学年,学期和classId进行查询 + * @author: 陈梓康 + * @Created: 2021/10/26 20:15 + * @param schoolYear 学年 + * @param schoolSemester 学期 + * @param classId 班级ID(模糊查询) + * @return Grade对象 + */ + Grade getByConditions(String schoolYear,String schoolSemester,String classId); + } diff --git a/src/main/java/com/mobile_education_platform/service/NoticeService.java b/src/main/java/com/mobile_education_platform/service/NoticeService.java index 15924ab05bc2a9a0d33a71925fd5b98249c0fd2f..21a0d9b7fa3395782b389078c93ef7df62cbd339 100644 --- a/src/main/java/com/mobile_education_platform/service/NoticeService.java +++ b/src/main/java/com/mobile_education_platform/service/NoticeService.java @@ -1,8 +1,11 @@ package com.mobile_education_platform.service; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.mobile_education_platform.pojo.Notice; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** *

* 服务类 @@ -13,4 +16,23 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface NoticeService extends IService { + /** + * 功能: 根据通知ID的List,来得到通知对象List + * @author: 陈梓康 + * @Created: 2021/10/26 20:57 + * @param noticeIds 通知ID集合 + * @return 通知对象List + */ + List listByNoticeList(List noticeIds); + + /** + * 功能: 根据班级ID给通知分页 + * @author: 陈梓康 + * @Created: 2021/10/26 22:08 + * @param pageNum 分页的通知总数 + * @param pageCount 分页的页数 + * @param classId 班级ID + * @return Page对象 + */ + Page getNoticePage(int pageNum,int pageCount,String classId); } diff --git a/src/main/java/com/mobile_education_platform/service/StudentClassService.java b/src/main/java/com/mobile_education_platform/service/StudentClassService.java index 7bf146d7e3fc12afde4465a0f2d0229f1d5bf8cf..2ed6b5099c1b049bdd937acf51b022739eee74fa 100644 --- a/src/main/java/com/mobile_education_platform/service/StudentClassService.java +++ b/src/main/java/com/mobile_education_platform/service/StudentClassService.java @@ -3,6 +3,8 @@ package com.mobile_education_platform.service; import com.mobile_education_platform.pojo.StudentClass; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** *

* 服务类 @@ -13,4 +15,21 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface StudentClassService extends IService { + /** + * 功能: 根据班级ID得到List + * @author: 陈梓康 + * @Created: 2021/10/26 20:33 + * @param classId 班级ID + * @return List + */ + List listByClassId(String classId); + + /** + * 功能: 根据学生ID得到一个StudentClass对象 + * @author: 陈梓康 + * @Created: 2021/10/26 20:34 + * @param studentId 学生ID + * @return StudentClass对象 + */ + StudentClass getByStudentId(String studentId); } diff --git a/src/main/java/com/mobile_education_platform/service/TeacherClassSubjectService.java b/src/main/java/com/mobile_education_platform/service/TeacherClassSubjectService.java index 50faed738d9779c35749479f98b582ecbb0eeb78..55bf308c337cf0c5a088708e55ed0494f313cd08 100644 --- a/src/main/java/com/mobile_education_platform/service/TeacherClassSubjectService.java +++ b/src/main/java/com/mobile_education_platform/service/TeacherClassSubjectService.java @@ -3,6 +3,8 @@ package com.mobile_education_platform.service; import com.mobile_education_platform.pojo.TeacherClassSubject; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** *

* 服务类 @@ -23,4 +25,12 @@ public interface TeacherClassSubjectService extends IService listByTeacherId(String teacherId); } diff --git a/src/main/java/com/mobile_education_platform/service/UserService.java b/src/main/java/com/mobile_education_platform/service/UserService.java index cbfa8606df22bc528e48bf2623bf15d6f0dfeb43..dcfd372e74f15c6bfa0d02679a045e77c75e8c0c 100644 --- a/src/main/java/com/mobile_education_platform/service/UserService.java +++ b/src/main/java/com/mobile_education_platform/service/UserService.java @@ -16,6 +16,13 @@ import java.util.Map; public interface UserService extends IService { /** + * 功能: 通过userNumber来获取User对象 + * @author: 陈梓康 + * @Created: 2021/10/26 20:20 + * @param userNumber 用户ID + * @return User对象 + */ + User getByUserNumber(String userNumber); * @Description: 根据openid判断该用户为新老用户 * @param openid 用户唯一id * @return 返回查询的结果(用户是否已保定身份,若已绑定需提供身份信息) diff --git a/src/main/java/com/mobile_education_platform/service/impl/ClassNoticeServiceImpl.java b/src/main/java/com/mobile_education_platform/service/impl/ClassNoticeServiceImpl.java index 0ab9ec16692689d175fa84e4ed8ee3ee27ab9ef2..7641e991e6fdd539e78ea1ef513e33b9e93f63c9 100644 --- a/src/main/java/com/mobile_education_platform/service/impl/ClassNoticeServiceImpl.java +++ b/src/main/java/com/mobile_education_platform/service/impl/ClassNoticeServiceImpl.java @@ -1,11 +1,15 @@ package com.mobile_education_platform.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mobile_education_platform.pojo.ClassNotice; import com.mobile_education_platform.mapper.ClassNoticeMapper; import com.mobile_education_platform.service.ClassNoticeService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.List; + /** *

* 服务实现类 @@ -17,4 +21,36 @@ import org.springframework.stereotype.Service; @Service public class ClassNoticeServiceImpl extends ServiceImpl implements ClassNoticeService { + /** + * 功能: 根据班级ID获取List + * @author: 陈梓康 + * @Created: 2021/10/26 20:26 + * @param classId 班级ID + * @return List + */ + @Override + public List listByClassId(String classId) { + QueryWrapper queryWrapper = new QueryWrapper().eq("class_id", classId); + return baseMapper.selectList(queryWrapper); + } + + /** + * 功能: 根据班级ID获取通知ID的List + * @author: 陈梓康 + * @Created: 2021/10/26 20:49 + * @param classId 班级ID + * @return 通知ID的List + */ + @Override + public List listNoticeIdsByClassId(String classId) { + QueryWrapper queryWrapper=new QueryWrapper<>(); + queryWrapper.select("notice_id"); + queryWrapper.eq("class_id",classId); + List classNotices = baseMapper.selectList(queryWrapper); + List noticeIds=new ArrayList<>(); + for (ClassNotice classNotice:classNotices){ + noticeIds.add(classNotice.getNoticeId()); + } + return noticeIds; + } } diff --git a/src/main/java/com/mobile_education_platform/service/impl/ClassServiceImpl.java b/src/main/java/com/mobile_education_platform/service/impl/ClassServiceImpl.java index 88b389682553631c2048253658e95d10fba00edb..f2d16b0f8dc5a23b9258d665b051ae3e8d016a68 100644 --- a/src/main/java/com/mobile_education_platform/service/impl/ClassServiceImpl.java +++ b/src/main/java/com/mobile_education_platform/service/impl/ClassServiceImpl.java @@ -35,4 +35,20 @@ public class ClassServiceImpl extends ServiceImpl implements } + /** + * 功能: 根据classId和gradeId查询Class + * @author: 陈梓康 + * @Created: 2021/10/26 20:07 + * @param id class_id + * @param gradeId grade_id + * @return Class对象 + */ + @Override + public Class getClassByIdAndGradeId(String id, String gradeId) { + QueryWrapper classQueryWrapper = new QueryWrapper<>(); + classQueryWrapper.eq("id", id); + classQueryWrapper.eq("grade_id", gradeId); + return baseMapper.selectOne(classQueryWrapper); + } + } diff --git a/src/main/java/com/mobile_education_platform/service/impl/GradeServiceImpl.java b/src/main/java/com/mobile_education_platform/service/impl/GradeServiceImpl.java index 6f249afd155199d1809ffb9df9644c7b385c4bfa..6c0ed2b1f8c82e4f09112f1b5796ef00eaa65db0 100644 --- a/src/main/java/com/mobile_education_platform/service/impl/GradeServiceImpl.java +++ b/src/main/java/com/mobile_education_platform/service/impl/GradeServiceImpl.java @@ -1,5 +1,6 @@ package com.mobile_education_platform.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mobile_education_platform.pojo.Grade; import com.mobile_education_platform.mapper.GradeMapper; import com.mobile_education_platform.service.GradeService; @@ -17,4 +18,21 @@ import org.springframework.stereotype.Service; @Service public class GradeServiceImpl extends ServiceImpl implements GradeService { + /** + * 功能: 根据学年,学期和classId进行查询 + * @author: 陈梓康 + * @Created: 2021/10/26 20:15 + * @param schoolYear 学年 + * @param schoolSemester 学期 + * @param classId 班级ID(模糊查询) + * @return Grade对象 + */ + @Override + public Grade getByConditions(String schoolYear, String schoolSemester, String classId) { + QueryWrapper gradeQueryWrapper = new QueryWrapper<>(); + gradeQueryWrapper.like("school_year", schoolYear + "-"); + gradeQueryWrapper.eq("school_semester", schoolSemester); + gradeQueryWrapper.like("class_id_group", classId); + return baseMapper.selectOne(gradeQueryWrapper); + } } diff --git a/src/main/java/com/mobile_education_platform/service/impl/NoticeServiceImpl.java b/src/main/java/com/mobile_education_platform/service/impl/NoticeServiceImpl.java index 067b95fac31031b52cf66ad9b4abaa331e75198e..85b6f0d10adb06d311e8517b9ac8b3688638cd3c 100644 --- a/src/main/java/com/mobile_education_platform/service/impl/NoticeServiceImpl.java +++ b/src/main/java/com/mobile_education_platform/service/impl/NoticeServiceImpl.java @@ -1,11 +1,16 @@ package com.mobile_education_platform.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.mobile_education_platform.pojo.Notice; import com.mobile_education_platform.mapper.NoticeMapper; import com.mobile_education_platform.service.NoticeService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.aspectj.weaver.ast.Not; import org.springframework.stereotype.Service; +import java.util.List; + /** *

* 服务实现类 @@ -17,4 +22,33 @@ import org.springframework.stereotype.Service; @Service public class NoticeServiceImpl extends ServiceImpl implements NoticeService { + /** + * 功能: 根据通知ID的List,来得到通知对象List + * @author: 陈梓康 + * @Created: 2021/10/26 20:57 + * @param noticeIds 通知ID集合 + * @return 通知对象List + */ + @Override + public List listByNoticeList(List noticeIds) { + List notices = baseMapper.selectBatchIds(noticeIds); + return notices; + } + + /** + * 功能: 根据班级ID给通知分页 + * @author: 陈梓康 + * @Created: 2021/10/26 22:08 + * @param pageNum 分页的通知总数 + * @param pageCount 分页的页数 + * @param classId 班级ID + * @return Page对象 + */ + @Override + public Page getNoticePage(int pageNum, int pageCount, String classId) { + Page page=new Page<>(pageNum,pageCount); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("class_id",classId); + return baseMapper.selectPage(page,queryWrapper); + } } diff --git a/src/main/java/com/mobile_education_platform/service/impl/StudentClassServiceImpl.java b/src/main/java/com/mobile_education_platform/service/impl/StudentClassServiceImpl.java index 2156841bf3ddcc969446abbb687fd5fc9dd114ef..51adef0c68c520b4a1d69fbf902198c87e026729 100644 --- a/src/main/java/com/mobile_education_platform/service/impl/StudentClassServiceImpl.java +++ b/src/main/java/com/mobile_education_platform/service/impl/StudentClassServiceImpl.java @@ -1,11 +1,14 @@ package com.mobile_education_platform.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mobile_education_platform.pojo.StudentClass; import com.mobile_education_platform.mapper.StudentClassMapper; import com.mobile_education_platform.service.StudentClassService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import java.util.List; + /** *

* 服务实现类 @@ -17,4 +20,31 @@ import org.springframework.stereotype.Service; @Service public class StudentClassServiceImpl extends ServiceImpl implements StudentClassService { + /** + * 功能: 根据班级ID得到List + * @author: 陈梓康 + * @Created: 2021/10/26 20:33 + * @param classId 班级ID + * @return List + */ + @Override + public List listByClassId(String classId) { + QueryWrapper queryWrapper=new QueryWrapper<>(); + queryWrapper.eq("class_id",classId); + return baseMapper.selectList(queryWrapper); + } + + /** + * 功能: 根据学生ID得到一个StudentClass对象 + * @author: 陈梓康 + * @Created: 2021/10/26 20:34 + * @param studentId 学生ID + * @return StudentClass对象 + */ + @Override + public StudentClass getByStudentId(String studentId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("student_id", studentId); + return baseMapper.selectOne(queryWrapper); + } } diff --git a/src/main/java/com/mobile_education_platform/service/impl/TeacherClassSubjectServiceImpl.java b/src/main/java/com/mobile_education_platform/service/impl/TeacherClassSubjectServiceImpl.java index 4c33a32e3c2e91dc5084303845cf27dae58212cf..a6549ae4505b4a8a7abe7496d861437638fda02e 100644 --- a/src/main/java/com/mobile_education_platform/service/impl/TeacherClassSubjectServiceImpl.java +++ b/src/main/java/com/mobile_education_platform/service/impl/TeacherClassSubjectServiceImpl.java @@ -1,11 +1,14 @@ package com.mobile_education_platform.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mobile_education_platform.pojo.TeacherClassSubject; import com.mobile_education_platform.mapper.TeacherClassSubjectMapper; import com.mobile_education_platform.service.TeacherClassSubjectService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import java.util.List; + /** *

* 服务实现类 @@ -30,4 +33,17 @@ public class TeacherClassSubjectServiceImpl extends ServiceImpl listByTeacherId(String teacherId) { + QueryWrapper queryWrapper = new QueryWrapper().eq("teacher_id", teacherId); + return baseMapper.selectList(queryWrapper); + } + } diff --git a/src/main/java/com/mobile_education_platform/service/impl/UserServiceImpl.java b/src/main/java/com/mobile_education_platform/service/impl/UserServiceImpl.java index cd3c97a7fc5883e3d26ddd4bc9f063461086a12a..db5df9abab92f4568e6d24cbdf92c187c32d42c5 100644 --- a/src/main/java/com/mobile_education_platform/service/impl/UserServiceImpl.java +++ b/src/main/java/com/mobile_education_platform/service/impl/UserServiceImpl.java @@ -1,5 +1,6 @@ package com.mobile_education_platform.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mobile_education_platform.mapper.ParentMapper; @@ -28,6 +29,17 @@ import java.util.Map; @Service public class UserServiceImpl extends ServiceImpl implements UserService { + /** + * 功能: 通过userNumber来获取User对象 + * @author: 陈梓康 + * @Created: 2021/10/26 20:20 + * @param userNumber 用户ID + * @return User对象 + */ + @Override + public User getByUserNumber(String userNumber) { + QueryWrapper queryWrapper = new QueryWrapper().eq("user_number", userNumber); + return baseMapper.selectOne(queryWrapper); @Resource private TeacherMapper teacherMapper;