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

AI Agent与Agentic AI:原理、应用、挑战与未来展望

文章目录 一、引言二、AI Agent与Agentic AI的兴起2.1 技术契机与生态成熟2.2 Agent的定义与特征2.3 Agent的发展历程 三、AI Agent的核心技术栈解密3.1 感知模块代码示例&#xff1a;使用Python和OpenCV进行图像识别 3.2 认知与决策模块代码示例&#xff1a;使用OpenAI GPT-3进…...

【Linux】C语言执行shell指令

在C语言中执行Shell指令 在C语言中&#xff0c;有几种方法可以执行Shell指令&#xff1a; 1. 使用system()函数 这是最简单的方法&#xff0c;包含在stdlib.h头文件中&#xff1a; #include <stdlib.h>int main() {system("ls -l"); // 执行ls -l命令retu…...

Cilium动手实验室: 精通之旅---20.Isovalent Enterprise for Cilium: Zero Trust Visibility

Cilium动手实验室: 精通之旅---20.Isovalent Enterprise for Cilium: Zero Trust Visibility 1. 实验室环境1.1 实验室环境1.2 小测试 2. The Endor System2.1 部署应用2.2 检查现有策略 3. Cilium 策略实体3.1 创建 allow-all 网络策略3.2 在 Hubble CLI 中验证网络策略源3.3 …...

服务器硬防的应用场景都有哪些?

服务器硬防是指一种通过硬件设备层面的安全措施来防御服务器系统受到网络攻击的方式&#xff0c;避免服务器受到各种恶意攻击和网络威胁&#xff0c;那么&#xff0c;服务器硬防通常都会应用在哪些场景当中呢&#xff1f; 硬防服务器中一般会配备入侵检测系统和预防系统&#x…...

unix/linux,sudo,其发展历程详细时间线、由来、历史背景

sudo 的诞生和演化,本身就是一部 Unix/Linux 系统管理哲学变迁的微缩史。来,让我们拨开时间的迷雾,一同探寻 sudo 那波澜壮阔(也颇为实用主义)的发展历程。 历史背景:su的时代与困境 ( 20 世纪 70 年代 - 80 年代初) 在 sudo 出现之前,Unix 系统管理员和需要特权操作的…...

EtherNet/IP转DeviceNet协议网关详解

一&#xff0c;设备主要功能 疆鸿智能JH-DVN-EIP本产品是自主研发的一款EtherNet/IP从站功能的通讯网关。该产品主要功能是连接DeviceNet总线和EtherNet/IP网络&#xff0c;本网关连接到EtherNet/IP总线中做为从站使用&#xff0c;连接到DeviceNet总线中做为从站使用。 在自动…...

2023赣州旅游投资集团

单选题 1.“不登高山&#xff0c;不知天之高也&#xff1b;不临深溪&#xff0c;不知地之厚也。”这句话说明_____。 A、人的意识具有创造性 B、人的认识是独立于实践之外的 C、实践在认识过程中具有决定作用 D、人的一切知识都是从直接经验中获得的 参考答案: C 本题解…...

2025季度云服务器排行榜

在全球云服务器市场&#xff0c;各厂商的排名和地位并非一成不变&#xff0c;而是由其独特的优势、战略布局和市场适应性共同决定的。以下是根据2025年市场趋势&#xff0c;对主要云服务器厂商在排行榜中占据重要位置的原因和优势进行深度分析&#xff1a; 一、全球“三巨头”…...

Yolov8 目标检测蒸馏学习记录

yolov8系列模型蒸馏基本流程&#xff0c;代码下载&#xff1a;这里本人提交了一个demo:djdll/Yolov8_Distillation: Yolov8轻量化_蒸馏代码实现 在轻量化模型设计中&#xff0c;**知识蒸馏&#xff08;Knowledge Distillation&#xff09;**被广泛应用&#xff0c;作为提升模型…...

iview框架主题色的应用

1.下载 less要使用3.0.0以下的版本 npm install less2.7.3 npm install less-loader4.0.52./src/config/theme.js文件 module.exports {yellow: {theme-color: #FDCE04},blue: {theme-color: #547CE7} }在sass中使用theme配置的颜色主题&#xff0c;无需引入&#xff0c;直接可…...