• 【学生管理系统】班级管理


    目录

    3. 班级管理

    3.1 需求

    3.1.1 添加班级

    3.1.2 班级列表

    3.2 搭建环境

    3.2.1 前端实现

    3.2.2 后端实现(9010)

    3.3 添加班级

    3.3.1 查询所有老师

    3.3.2 【难】前端:选择老师

    3.3.3 后端:添加班级

    3.3.4 前端:添加班级

    3.4 查询所有班级

    3.4.1 后端实现

    3.4.2 前端实现

    3.5 修改班级

    3.5.1 后端实现

    3.5.2 前端实现

    3. 班级管理

    3.1 需求

    3.1.1 添加班级

     

    3.1.2 班级列表

     

    3.2 搭建环境

    3.2.1 前端实现

    • 创建对应的页面

       

    3.2.2 后端实现(9010)

    • 项目名:nacos-nuxt-student-service-classes

    • pom文件

    • yml文件(端口号、服务名、数据库)

       

    • 启动类

    • 拷贝配置类

    • 基本结构

     

    3.3 添加班级

    3.3.1 查询所有老师

    1)后端

     

    package com.czxy.classes.controller;
    ​
    import com.czxy.classes.service.TbClassesService;
    import com.czxy.classes.service.TbTeacherService;
    import com.czxy.domain.TbTeacher;
    import com.czxy.vo.BaseResult;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    ​
    import javax.annotation.Resource;
    import java.util.List;
    ​
    /**
     * @author 桐叔
     * @email liangtong@itcast.cn
     * @description
     */
    @RestController
    @RequestMapping("/teacher")
    public class TbTeacherController {
    ​
        @Resource
        private TbTeacherService tbTeacherService;
    ​
        /**
         * 查询所有
         * @author 桐叔
         * @email liangtong@itcast.cn
         * @return
         */
        @GetMapping
        public BaseResult findAll() {
            List list = tbTeacherService.list();
            return BaseResult.ok("查询成功", list);
        }
    ​
    ​
    }
    ​

    2)前端

    • 显示表单

    • 展示所有老师

    • 显示表单

    • 展示所有老师

       

    3.3.2 【难】前端:选择老师

    • 需求:如果某类型的老师已选,将除当前老师,其他该类型的老师禁用

    • 实现:完善ClassesAdd.vue

       

    3.3.3 后端:添加班级

     

    package com.czxy.classes.controller;
    ​
    import com.czxy.classes.service.TbClassesService;
    import com.czxy.domain.TbClass;
    import com.czxy.vo.BaseResult;
    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;
    ​
    import javax.annotation.Resource;
    ​
    /**
     * @author 桐叔
     * @email liangtong@itcast.cn
     * @description
     */
    @RestController
    @RequestMapping("/classes")
    public class TbClassesController {
    ​
        @Resource
        private TbClassesService tbClassesService;
    ​
        @PostMapping
        public BaseResult add(@RequestBody TbClass tbClass) {
            boolean result = tbClassesService.save(tbClass);
            if(result) {
                return BaseResult.ok("添加成功");
            }
            return BaseResult.error("添加失败");
        }
    ​
    ​
    }
    ​

    3.3.4 前端:添加班级

     

    async classesAdd() {
      // ajax添加
      let { data:baseResult } = await this.$axios.post('/classes-service/classes', this.classes)
      // 处理
      if(baseResult.code == 20000) {
        this.$message.success(baseResult.message)
        // 跳转列表页
        this.$router.push('/classes/classesList')
      } else {
        this.$message.error(baseResult.message)
      }
    }

    3.4 查询所有班级

    3.4.1 后端实现

    3.4.2 前端实现

    3.5 修改班级

    3.5.1 后端实现

    3.5.2 前端实现

  • 相关阅读:
    Vue语法
    动态代理IP常见超时原因及解决方法
    easy_see
    android中输入系统之内核到InputManagerService过程(源码)
    微信小程序-request fail
    【CSP-J/S初赛知识点整理】
    C语言 指针
    使用字节豆包大模型在 Dify 上实现最简单的 Agent 应用(四):AI 信息检索
    MySQL binlog模式及主备的基本原理
    【Java八股文总结】之Java Web
  • 原文地址:https://blog.csdn.net/weixin_45481821/article/details/127374614