当前位置: 首页 > news >正文

Java项目学生管理系统六后端补充

班级管理

1 班级列表:后端

  • 编写JavaBean【已有】
  • 编写Mapper【已有】
  • 编写Service
  • 编写controller

在这里插入图片描述

  • 编写Service

    • 接口

      package com.czxy.service;import com.czxy.domain.Classes;import java.util.List;/*** @author 桐叔* @email liangtong@itcast.cn* @description*/
      public interface ClassesService {/*** 查询所有* @return*/public List<Classes> selectAll();
      }
    • 实现类

      package com.czxy.service.impl;import com.czxy.domain.Classes;
      import com.czxy.mapper.ClassesMapper;
      import com.czxy.service.ClassesService;
      import org.springframework.stereotype.Service;
      import org.springframework.transaction.annotation.Transactional;import javax.annotation.Resource;
      import java.util.List;/*** @author 桐叔* @email liangtong@itcast.cn* @description*/
      @Service
      @Transactional
      public class ClassesServiceImpl implements ClassesService {@Resourceprivate ClassesMapper classesMapper;@Overridepublic List<Classes> selectAll() {List<Classes> classesList = classesMapper.selectAll();return classesList;}
      }
  • 编写controller

    package com.czxy.controller;import com.czxy.domain.Classes;
    import com.czxy.service.ClassesService;
    import org.springframework.http.ResponseEntity;
    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("/classes")
    public class ClassesController {@Resourceprivate ClassesService classesService;@GetMappingpublic ResponseEntity<List<Classes>> selectAll() {// 查询List<Classes> classesList = classesService.selectAll();// 返回return ResponseEntity.ok(classesList);}
    }

城市管理

1 查询所有城市:后端

1 JavaBean

在这里插入图片描述

package com.czxy.domain;import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.ArrayList;
import java.util.List;/*** @author 桐叔* @email liangtong@itcast.cn* @description*/
@Table(name = "tb_city")
public class City {@Id@Column(name = "c_id")private String cid;                 //城市IDprivate String cityName;            //城市名称private String parentId;            //父ID//一对多:一个城市(省/市)拥有多个子城市(多个市/多个县) ,new对象为了操作【方便】private List<City> children = new ArrayList<>();//....
}/*
CREATE TABLE tb_city(c_id VARCHAR(32) PRIMARY KEY COMMENT '城市ID',city_name VARCHAR(20) COMMENT '城市名称' ,parent_id VARCHAR(32) COMMENT '父ID'
);*/

2 Mapper

在这里插入图片描述

package com.czxy.mapper;import com.czxy.domain.City;
import tk.mybatis.mapper.common.Mapper;/*** @author 桐叔* @email liangtong@itcast.cn* @description*/
public interface CityMapper extends Mapper<City> {
}

3 Service

在这里插入图片描述

  • 接口

    package com.czxy.service;import com.czxy.domain.City;import java.util.List;/*** @author 桐叔* @email liangtong@itcast.cn* @description*/
    public interface CityService {/*** 查询所有(省、市、县)* @return*/public List<City> selectAll();
    }
  • 实现类

    package com.czxy.service.impl;import com.czxy.domain.City;
    import com.czxy.mapper.CityMapper;
    import com.czxy.service.CityService;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;
    import tk.mybatis.mapper.entity.Example;import javax.annotation.Resource;
    import java.util.List;/*** @author 桐叔* @email liangtong@itcast.cn* @description*/
    @Service
    @Transactional
    public class CityServiceImpl implements CityService {@Resourceprivate CityMapper cityMapper;@Overridepublic List<City> selectAll() {//1 条件查询:排序Example example = new Example(City.class);example.orderBy("parentId").asc();      //升序//2 查询List<City> cityList = cityMapper.selectByExample(example);return cityList;}
    }

4 Controller

在这里插入图片描述

package com.czxy.controller;import com.czxy.domain.City;
import com.czxy.service.CityService;
import org.springframework.http.ResponseEntity;
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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;/*** @author 桐叔* @email liangtong@itcast.cn* @description*/
@RestController
@RequestMapping("/city")
public class CityController {@Resourceprivate CityService cityService;@GetMappingpublic ResponseEntity<List<City>> selectAll() {// 1 查询所有 省/市/县List<City> cityList = cityService.selectAll();// 2 处理数据 省(市(县))// 2.1.1 提供Map,用于缓存所有城市,目的:方便子城市找到父城市// map.id 城市id,方便子获得, map.value 城市Map<String, City> cacheMap = new HashMap<>();// 2.1.2 提供List,存放所有的省List<City> provinceList = new ArrayList<>();// 2.2 遍历所有城市for(City city: cityList) {// 2.3.1 从map获得父城市City parentCity = cacheMap.get(city.getParentId());if(parentCity == null) {// 2.3.2 1)如果没有获得父城市,表示就是省,直接添加ListprovinceList.add(city);} else {// 2.3.2 2)如果获得父城市,表示市、县,将器追加到父城市的子列表中parentCity.getChildren().add(city);}// 2.3.3 当前城市添加到map中,方便下一次自己的子城市可以获得自己cacheMap.put(city.getCid(), city);}//3 返回所有的省return ResponseEntity.ok(provinceList);}
}

查询指定父id的所有城市:后端

1 Service

  • 接口

    在这里插入图片描述

        /*** 通过父id查询所有* @param parentId* @return*/public List<City> selectByParentId(String parentId);
    
  • 实现类

    在这里插入图片描述

        @Overridepublic List<City> selectByParentId(String parentId) {//1 条件Example example = new Example(City.class);Example.Criteria criteria = example.createCriteria();criteria.andEqualTo("parentId", parentId);//2 查询List<City> cityList = cityMapper.selectByExample(example);//3 返回return cityList;}
    

2 Controller

在这里插入图片描述

    /*** 通过父id查询* @param pid* @return*/@GetMapping("/parent/{pid}")public ResponseEntity<List<City>> selectAllByParentId(@PathVariable("pid") String pid) {//查询List<City> cityList = cityService.selectByParentId(pid);//返回return ResponseEntity.ok(cityList);}

课程管理

1查询所有:后端

在这里插入图片描述

1 Service

  • 接口

    package com.czxy.service;import com.czxy.domain.Course;import java.util.List;/*** @author 桐叔* @email liangtong@itcast.cn* @description*/
    public interface CourseService {/*** 查询所有课程* @return*/public List<Course> selectAll();
    }
  • 实现类

    package com.czxy.service.impl;import com.czxy.domain.Course;
    import com.czxy.mapper.CourseMapper;
    import com.czxy.service.CourseService;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;import javax.annotation.Resource;
    import java.util.List;/*** @author 桐叔* @email liangtong@itcast.cn* @description*/
    @Service
    @Transactional
    public class CourseServiceImpl implements CourseService {@Resourceprivate CourseMapper courseMapper;@Overridepublic List<Course> selectAll() {List<Course> courseList = courseMapper.selectAll();return courseList;}
    }

2 Controller

package com.czxy.controller;import com.czxy.domain.Course;
import com.czxy.service.CourseService;
import org.springframework.http.ResponseEntity;
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("/course")
public class CourseController {@Resourceprivate CourseService courseService;/*** 查询所有课程* @return*/@GetMappingpublic ResponseEntity<List<Course>> selectAll() {//查询List<Course> courseList = courseService.selectAll();//返回return ResponseEntity.ok(courseList);}
}

2 查询指定学生的所有课程:后端

在这里插入图片描述

1 Mapper【已有】

2 Service

  • 接口

    在这里插入图片描述

        /*** 查询指定学生的所有课程* @param sid* @return*/public List<Course> selectAllBySid(Integer sid);
    
  • 实现类

    在这里插入图片描述

        @Overridepublic List<Course> selectAllBySid(Integer sid) {List<Course> courseList = courseMapper.selectAllBySid(sid);return courseList;}
    

相关文章:

Java项目学生管理系统六后端补充

班级管理 1 班级列表&#xff1a;后端 编写JavaBean【已有】编写Mapper【已有】编写Service编写controller 编写Service 接口 package com.czxy.service;import com.czxy.domain.Classes;import java.util.List;/*** author 桐叔* email liangtongitcast.cn* description*/ p…...

PDF控件Spire.PDF for .NET【转换】演示:将 PDF 转换为线性化

PDF 线性化&#xff0c;也称为“快速 Web 查看”&#xff0c;是一种优化 PDF 文件的方法。通常&#xff0c;只有当用户的网络浏览器从服务器下载了所有页面后&#xff0c;用户才能在线查看多页 PDF 文件。然而&#xff0c;如果 PDF 文件是线性化的&#xff0c;即使完整下载尚未…...

猫头虎博主深度探索:Amazon Q——2023 re:Invent大会的AI革新之星

猫头虎博主深度探索&#xff1a;Amazon Q——2023 re:Invent大会的AI革新之星 授权说明&#xff1a;本篇文章授权活动官方亚马逊云科技文章转发、改写权&#xff0c;包括不限于在 亚马逊云科技开发者社区, 知乎&#xff0c;自媒体平台&#xff0c;第三方开发者媒体等亚马逊云科…...

Spring框架-GOF代理模式之JDK动态代理

我们可以分成三步来完成jdk动态代理的实现 第一步&#xff1a;创建目标对象 第二步&#xff1a;创建代理对象 第三步&#xff1a;调用代理对象的代理方法 public class Client {public static void main(String[] args) {//创建目标对象final OrderService target new OrderS…...

基于JAVAEE技术校园车辆管理系统论文

摘 要 现代经济快节奏发展以及不断完善升级的信息化技术&#xff0c;让传统数据信息的管理升级为软件存储&#xff0c;归纳&#xff0c;集中处理数据信息的管理方式。本校园车辆管理系统就是在这样的大环境下诞生&#xff0c;其可以帮助管理者在短时间内处理完毕庞大的数据信息…...

基于FFmpeg,实现播放器功能

一、客户端选择音视频文件 MainActivity package com.anniljing.ffmpegnative;import android.Manifest; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.net.Ur…...

利用tf-idf对特征进行提取

TF-IDF是一种文本特征提取的方法&#xff0c;用于评估一个词在一组文档中的重要性。 一、代码 from sklearn.feature_extraction.text import TfidfVectorizer import numpy as npdef print_tfidf_words(documents):"""打印TF-IDF矩阵中每个文档中非零值对应…...

遇到运维故障,有没有排查和解决故障的正确流程?

稳定是偶然&#xff0c;异常才是常态&#xff0c;用来标注IT运维工作再适合不过。 因为对于IT运维来说&#xff0c;工作最常遇到的就是不稳定性带来的各种故障&#xff0c;经常围绕发现故障、响应故障、定位故障、恢复故障这四大步。 故障处理是最心跳的事情&#xff0c;没有…...

javaWebssh汽车销售管理系统myeclipse开发mysql数据库MVC模式java编程计算机网页设计

一、源码特点 java ssh汽车销售管理系统是一套完善的web设计系统&#xff08;系统采用ssh框架进行设计开发&#xff09;&#xff0c;对理解JSP java编程开发语言有帮助&#xff0c;系统具有完整的源代码和数据库&#xff0c;系统主要采用 B/S模式开发。开发环境为TOMCAT7.…...

基于pandoraNext使用chatgpt4

1.登陆GitHub 获取pandoraNext项目GitHub - pandora-next/deploy: Pandora Cloud Pandora Server Shared Chat BackendAPI Proxy Chat2API Signup Free PandoraNext. New GPTs(Gizmo) UI, All in one! 在release中选择相应版本操作系统的安装包进行下载 2.获取license_…...

12.视图

目录 1.视图的含义与作用 2.视图的创建与查看 1.创建视图的语法形式 2、查看视图&#xff1a; 1.使用DESCRIBE语句查看视图基本信息 2.使用SHOW TABLE STATUS语查看视图基本信息查看视图的信息 3.使用SHOW CREATE VIEW语查看视图详细信息 4.在views表中查看视图详细信息…...

Leetcode69 x的平方根

x的平方根 题解1 袖珍计算器算法题解2 二分查找题解3 牛顿迭代 给你一个非负整数 x &#xff0c;计算并返回 x 的 算术平方根 。 由于返回类型是整数&#xff0c;结果只保留 整数部分 &#xff0c;小数部分将被 舍去 。 注意&#xff1a;不允许使用任何内置指数函数和算符&…...

在Linux上安装配置Nginx高性能Web服务器

1 前言 Nginx是一个高性能的开源Web服务器&#xff0c;同时也可以作为反向代理服务器、负载均衡器、HTTP缓存以及作为一个邮件代理服务器。它以其出色的性能和灵活性而闻名&#xff0c;被广泛用于处理高流量的网站和应用程序。本文将介绍在Linux环境中安装Nginx的步骤&#xf…...

LeetCode 每日一题 Day 11||贪心

2697. 字典序最小回文串 给你一个由 小写英文字母 组成的字符串 s &#xff0c;你可以对其执行一些操作。在一步操作中&#xff0c;你可以用其他小写英文字母 替换 s 中的一个字符。 请你执行 尽可能少的操作 &#xff0c;使 s 变成一个 回文串 。如果执行 最少 操作次数的方…...

ocr表格文字识别软件怎么使用?

现在的OCR软件几乎是傻瓜式的设计&#xff0c;操作很简单&#xff0c;像金鸣识别的软件无论是网页版还是电脑客户端又或是小程序&#xff0c;界面都简单明了&#xff0c;用户只需提交待识别的图片&#xff0c;然后点击提交识别&#xff0c;等识别完成就直接打开或下载打开就行了…...

【QT 5 调试软件+Linux下调用脚本shell-经验总结+初步调试+基础样例】

【QT 5 调试软件Linux下调用脚本shell-经验总结初步调试基础样例】 1、前言2、实验环境3、自我总结4、实验过程&#xff08;1&#xff09;准备工作-脚本1&#xff09;、准备工作-编写运行脚本文件2&#xff09;、给权限3&#xff09;、运行脚本 &#xff08;2&#xff09;进入q…...

使用 Goroutine 和 Channel 构建高并发程序

使用 Goroutine 和 Channel 构建高并发程序 文章目的与概要Golang 并发模型的重要性 Goroutine 和 Channel 的基础Goroutine&#xff1a;轻量级线程Channel&#xff1a;通信机制Goroutine 与 Channel 的协同工作 构建高并发模型的策略有效使用 Goroutine使用 Channel 进行数据传…...

大数据机器学习与深度学习——过拟合、欠拟合及机器学习算法分类

大数据机器学习与深度学习——过拟合、欠拟合及机器学习算法分类 过拟合&#xff0c;欠拟合 针对模型的拟合&#xff0c;这里引入两个概念&#xff1a;过拟合&#xff0c;欠拟合。 过拟合&#xff1a;在机器学习任务中&#xff0c;我们通常将数据集分为两部分&#xff1a;训…...

Lenovo联想拯救者Legion Y9000X 2021款(82BD)原装出厂Windows10系统

链接&#xff1a;https://pan.baidu.com/s/1GRTR7CAAQJdnh4tHbhQaDQ?pwdl42u 提取码&#xff1a;l42u 联想原厂WIN10系统自带所有驱动、出厂主题壁纸、系统属性专属LOGO标志、Office办公软件、联想电脑管家等预装程序 所需要工具&#xff1a;16G或以上的U盘 文件格式&am…...

pytorch中的transpose用法

注意&#xff1a;维数从0开始&#xff0c;0维 1维2维…,负数代表从右往左数&#xff0c;-1代表第一维&#xff0c;以此类推 import torch import numpy as np# 创建一个二维数组 arr torch.tensor([[[1, 2],[3, 4]],[[5, 6],[7, 8]]]) print("原始数组&#xff1a;"…...

2026年西安市莲湖区Geo搜索优化排名,专业企业究竟谁能拔得头筹?

在数字化浪潮席卷的今天&#xff0c;Geo搜索优化&#xff08;地理搜索优化&#xff09;对于企业的重要性不言而喻。尤其在西安市莲湖区&#xff0c;企业们对于提升自身在Geo搜索中的排名需求愈发迫切。究竟哪家专业企业能够在2026年的竞争中脱颖而出&#xff0c;成为Geo搜索优化…...

新手入门指南:基于快马平台构建静电地板施工交互学习系统

作为一名刚接触机房建设的新手&#xff0c;第一次看到"静电地板施工"这个词时&#xff0c;整个人都是懵的。直到我在InsCode(快马)平台上尝试做了一个交互式学习系统&#xff0c;才发现原来掌握这项技能可以这么简单。下面分享下我的学习心得和系统构建过程。 为什么…...

MySQL InnoDB核心参数深度优化/性能调优

前言&#xff1a;MySQL中InnoDB引擎是绝大多数生产环境的首选&#xff0c;其性能表现直接决定了数据库的整体吞吐量和响应速度。而InnoDB的性能优化&#xff0c;核心就在于缓冲池、redo日志、事务相关参数的合理配置——很多时候&#xff0c;不是数据库硬件不行&#xff0c;而是…...

跨品牌机器人数据如何统一?详解RDT-1B的128维动作空间映射技巧

跨品牌机器人数据统一实战&#xff1a;RDT-1B的128维动作空间映射技术解析 当不同品牌的机械臂在实验室里协同完成一套茶艺表演时——六轴工业机器人负责倒水&#xff0c;协作机械臂完成茶叶称重&#xff0c;而仿人五指手执行最后的奉茶动作——这种科幻场景的实现核心&#xf…...

实战指南:利用wandb高效管理机器学习实验日志

1. 为什么你需要wandb来管理机器学习实验 第一次训练神经网络时&#xff0c;我把所有超参数和结果都记在了一个txt文件里。三天后当我尝试复现某个"还不错"的结果时&#xff0c;面对20多个版本的文件&#xff0c;完全分不清哪个是哪个。这种混乱的经历让我意识到&…...

Python 开发者“生存指令”速查表

&#x1f40d; Python 开发者“生存指令”速查表 这份清单分为**“系统终端”&#xff08;在 CMD/PowerShell 中操作&#xff09;和“Python 交互模式”**&#xff08;在 >>> 提示符下操作&#xff09;两部分。 1. 系统终端常用命令&#xff08;CMD / PowerShell&…...

GHelper:华硕笔记本终极性能调校指南 - 轻量级硬件控制神器

GHelper&#xff1a;华硕笔记本终极性能调校指南 - 轻量级硬件控制神器 【免费下载链接】g-helper Lightweight, open-source control tool for ASUS laptops and ROG Ally. Manage performance modes, fans, GPU, battery, and RGB lighting across Zephyrus, Flow, TUF, Stri…...

Python多线程详解:原理、应用场景与实战指南(I_O密集型首选)

Python多线程详解&#xff1a;原理、应用场景与实战指南&#xff08;I/O密集型首选&#xff09; 在Python并发编程领域&#xff0c;多线程是最基础、最常用的并发实现方式&#xff0c;凭借轻量、易上手、数据共享便捷等优势&#xff0c;成为处理I/O密集型任务的首选方案。很多P…...

ai辅助环境配置:让快马平台的kimi帮你智能编写jdk17安装脚本与验证程序

今天在配置JDK17开发环境时&#xff0c;发现手动设置环境变量和验证流程有点繁琐&#xff0c;于是尝试用InsCode(快马)平台的AI辅助功能来简化整个过程。这里记录下具体操作和心得&#xff0c;分享给同样需要配置Java环境的小伙伴们。 环境变量冲突检测 首先让AI帮我分析现有…...

艺术二维码生成工具实战指南:从技术实现到商业价值挖掘

艺术二维码生成工具实战指南&#xff1a;从技术实现到商业价值挖掘 【免费下载链接】control_v1p_sd15_qrcode_monster 项目地址: https://ai.gitcode.com/hf_mirrors/monster-labs/control_v1p_sd15_qrcode_monster 核心要点 解决传统二维码设计与功能性矛盾的完整技…...