当前位置: 首页 > 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;"…...

三维GIS开发cesium智慧地铁教程(5)Cesium相机控制

一、环境搭建 <script src"../cesium1.99/Build/Cesium/Cesium.js"></script> <link rel"stylesheet" href"../cesium1.99/Build/Cesium/Widgets/widgets.css"> 关键配置点&#xff1a; 路径验证&#xff1a;确保相对路径.…...

遍历 Map 类型集合的方法汇总

1 方法一 先用方法 keySet() 获取集合中的所有键。再通过 gey(key) 方法用对应键获取值 import java.util.HashMap; import java.util.Set;public class Test {public static void main(String[] args) {HashMap hashMap new HashMap();hashMap.put("语文",99);has…...

Unit 1 深度强化学习简介

Deep RL Course ——Unit 1 Introduction 从理论和实践层面深入学习深度强化学习。学会使用知名的深度强化学习库&#xff0c;例如 Stable Baselines3、RL Baselines3 Zoo、Sample Factory 和 CleanRL。在独特的环境中训练智能体&#xff0c;比如 SnowballFight、Huggy the Do…...

Map相关知识

数据结构 二叉树 二叉树&#xff0c;顾名思义&#xff0c;每个节点最多有两个“叉”&#xff0c;也就是两个子节点&#xff0c;分别是左子 节点和右子节点。不过&#xff0c;二叉树并不要求每个节点都有两个子节点&#xff0c;有的节点只 有左子节点&#xff0c;有的节点只有…...

Linux C语言网络编程详细入门教程:如何一步步实现TCP服务端与客户端通信

文章目录 Linux C语言网络编程详细入门教程&#xff1a;如何一步步实现TCP服务端与客户端通信前言一、网络通信基础概念二、服务端与客户端的完整流程图解三、每一步的详细讲解和代码示例1. 创建Socket&#xff08;服务端和客户端都要&#xff09;2. 绑定本地地址和端口&#x…...

基于Java+MySQL实现(GUI)客户管理系统

客户资料管理系统的设计与实现 第一章 需求分析 1.1 需求总体介绍 本项目为了方便维护客户信息为了方便维护客户信息&#xff0c;对客户进行统一管理&#xff0c;可以把所有客户信息录入系统&#xff0c;进行维护和统计功能。可通过文件的方式保存相关录入数据&#xff0c;对…...

安全突围:重塑内生安全体系:齐向东在2025年BCS大会的演讲

文章目录 前言第一部分&#xff1a;体系力量是突围之钥第一重困境是体系思想落地不畅。第二重困境是大小体系融合瓶颈。第三重困境是“小体系”运营梗阻。 第二部分&#xff1a;体系矛盾是突围之障一是数据孤岛的障碍。二是投入不足的障碍。三是新旧兼容难的障碍。 第三部分&am…...

NPOI操作EXCEL文件 ——CAD C# 二次开发

缺点:dll.版本容易加载错误。CAD加载插件时&#xff0c;没有加载所有类库。插件运行过程中用到某个类库&#xff0c;会从CAD的安装目录找&#xff0c;找不到就报错了。 【方案2】让CAD在加载过程中把类库加载到内存 【方案3】是发现缺少了哪个库&#xff0c;就用插件程序加载进…...

Scrapy-Redis分布式爬虫架构的可扩展性与容错性增强:基于微服务与容器化的解决方案

在大数据时代&#xff0c;海量数据的采集与处理成为企业和研究机构获取信息的关键环节。Scrapy-Redis作为一种经典的分布式爬虫架构&#xff0c;在处理大规模数据抓取任务时展现出强大的能力。然而&#xff0c;随着业务规模的不断扩大和数据抓取需求的日益复杂&#xff0c;传统…...

LOOI机器人的技术实现解析:从手势识别到边缘检测

LOOI机器人作为一款创新的AI硬件产品&#xff0c;通过将智能手机转变为具有情感交互能力的桌面机器人&#xff0c;展示了前沿AI技术与传统硬件设计的完美结合。作为AI与玩具领域的专家&#xff0c;我将全面解析LOOI的技术实现架构&#xff0c;特别是其手势识别、物体识别和环境…...