毕设难度级java项目!(傻瓜版)(万字详解)StudentCourseService
▼javascript复制代码public void add(StudentCourse studentCourse) { StudentCourse course = studentCourseMapper.selectByCondition(studentCourse);// 通过学生ID和课程ID做一次查询的筛选,看看这个学生之前有没有选过这个课程 if (course != null) { throw new CustomException("您已选过这个课程"); } studentCourseMapper.insert(studentCourse); }
public void add(StudentCourse studentCourse):“新开课窗口”,参数是 “选课申请单”(包含学生 ID 和课程 ID)。StudentCourse course = studentCourseMapper.selectByCondition(studentCourse);:让管理员查一下 “这个学生是不是已经选过这门课了”—— 比如查 “学生 101 是否选过课程 201”。if (course != null) { ... }:如果查到记录(说明已选),就掏出 “定制退课单”(CustomException),写上 “您已选过这个课程”,告诉学生 “别重复选了”。throw new CustomException(...):把退课单 “递出去”,程序到这就停了,避免重复录入。studentCourseMapper.insert(studentCourse);:如果没选过,就让管理员把选课记录录入系统(数据库)。
▼javascript复制代码public PageInfo<StudentCourse> selectPage(Integer pageNum, Integer pageSize, StudentCourse studentCourse) { PageHelper.startPage(pageNum, pageSize); List<StudentCourse> list = studentCourseMapper.selectAll(studentCourse); return PageInfo.of(list); } public void deleteById(Integer id) { studentCourseMapper.deleteById(id); }
- 方法作用:支持分页查询选课记录,可按条件筛选(如按学生 ID、课程 ID 查询)。
PageHelper.startPage(pageNum, pageSize):启动分页插件,拦截后续 SQL 查询,自动添加分页条件(如LIMIT),无需手动编写分页 SQL。List<StudentCourse> list = studentCourseMapper.selectAll(studentCourse):按条件查询选课记录列表(已被分页插件处理,仅返回当前页数据)。return PageInfo.of(list):将列表包装为PageInfo对象,包含总条数、总页数等分页元信息,供前端渲染分页控件(页码导航、上 / 下一页按钮)。
评论
问答助学
相关内容
0个评论
全部评论
点击登录,快来和大家讨论吧~
表情
图片
暂无评论
内容推荐
🔥前端干货|程序员必看,5 段可直接复用代码,面试开发两不误
3
【Nexus 数字中枢】企业协作平台 · 公测通知信息散落各处、审批流程卡壳、跨部门协作像在玩传声筒?Nexus 来了——一个真正把「简单留给用户、复杂交给系统」的统一工作入口。🔥 我们解决什么问题?痛点一:信息孤岛。IM 在一个 App,文档在另一个,审批又跳到第三个,一天切换几十次。 痛点二:体验恶化。功能堆砌但每个都半成品,用起来比不用还累。 痛点三:管理内卷。考勤打卡要开三个系统,流程审
2
DeepSeek Harness
1
在OD待了两年,我成功跳槽大厂
6
DeepSeek 开源 DSH 框架:终于有了国产可自由折腾的本地代码 Agent
2
