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

告别虚拟机!Windows WSL2+GNU Radio玩转HackRF-One无线接收(避坑指南)

告别虚拟机&#xff01;Windows WSL2GNU Radio玩转HackRF-One无线接收&#xff08;避坑指南&#xff09; 在软件定义无线电&#xff08;SDR&#xff09;领域&#xff0c;HackRF-One因其开源设计和亲民价格成为入门首选。然而传统虚拟机方案常因性能损耗、驱动兼容性问题让新手望…...

SDMatte效果对比评测:与传统抠图工具及在线API的全面比拼

SDMatte效果对比评测&#xff1a;与传统抠图工具及在线API的全面比拼 1. 开篇&#xff1a;为什么需要新的抠图方案 在数字内容创作领域&#xff0c;抠图一直是个让人又爱又恨的技术活。记得去年帮朋友做电商产品图&#xff0c;光是给20个商品抠图就花了我整整一个周末。传统工…...

Mirage Flow 与卷积神经网络(CNN)的跨模态融合应用

Mirage Flow 与卷积神经网络&#xff08;CNN&#xff09;的跨模态融合应用 你有没有想过&#xff0c;让机器不仅能“看见”图片&#xff0c;还能像人一样“理解”并“描述”图片里的故事&#xff1f;比如&#xff0c;给一张复杂的医学影像&#xff0c;它不仅能圈出病灶&#x…...

Phi-3-mini-4k-instruct-gguf应用落地:教育场景中的作业辅导与知识点提炼

Phi-3-mini-4k-instruct-gguf应用落地&#xff1a;教育场景中的作业辅导与知识点提炼 1. 教育场景中的AI助手需求 想象一下这样的场景&#xff1a;晚上10点&#xff0c;孩子还在为数学作业发愁&#xff0c;家长已经精疲力尽&#xff1b;老师批改着第50份作文&#xff0c;眼睛…...

霞鹜文楷GB:开源楷体字体的国标规范解决方案

霞鹜文楷GB&#xff1a;开源楷体字体的国标规范解决方案 【免费下载链接】LxgwWenkaiGB An open-source Simplified Chinese font derived from Klee One. 项目地址: https://gitcode.com/gh_mirrors/lx/LxgwWenkaiGB 在数字时代的中文排版领域&#xff0c;如何在保持视…...

QuickSnap:提升三维建模效率的快速对齐工具——三维建模爱好者的精准对齐解决方案

QuickSnap&#xff1a;提升三维建模效率的快速对齐工具——三维建模爱好者的精准对齐解决方案 【免费下载链接】quicksnap Blender addon to quickly snap objects/vertices/points to object origins/vertices/points 项目地址: https://gitcode.com/gh_mirrors/qu/quicksna…...

告别复制粘贴!用Qwen Code在终端里直接重构500行烂代码(附真实项目截图)

告别复制粘贴&#xff01;用Qwen Code在终端里直接重构500行烂代码&#xff08;附真实项目截图&#xff09; 接手一个满是技术债的项目&#xff0c;就像走进一间多年无人打扫的仓库——到处是随意堆放的代码、重复的逻辑、难以理解的函数命名。更糟的是&#xff0c;传统的AI辅助…...

半导体器件入门:金半接触的5个关键概念解析(附手稿能带图)

半导体器件入门&#xff1a;金半接触的5个关键概念解析&#xff08;附手稿能带图&#xff09; 第一次翻开半导体物理教材时&#xff0c;金半接触那一章总是让人既兴奋又困惑。那些弯曲的能带图、费米能级的移动、神秘的势垒高度&#xff0c;就像一道通往微电子世界的大门。本文…...

Word转HTML图片处理全攻略:Base64 vs 文件存储的实战对比

Word转HTML图片处理全攻略&#xff1a;Base64 vs 文件存储的实战对比 在文档处理领域&#xff0c;Word转HTML的需求日益增长&#xff0c;尤其是需要将文档内容嵌入网页或富文本编辑器时。图片作为文档的重要组成部分&#xff0c;其处理方式直接影响转换效果和系统性能。本文将深…...

Qwen3.5-9B惊艳案例:上传X光片→识别骨折位置→标注解剖结构→生成诊断报告草稿

Qwen3.5-9B惊艳案例&#xff1a;上传X光片→识别骨折位置→标注解剖结构→生成诊断报告草稿 1. 医疗影像分析的革命性突破 想象一下这样的场景&#xff1a;一位急诊医生面对堆积如山的X光片&#xff0c;需要在短时间内做出准确诊断。传统方法需要医生逐张查看、标注异常部位、…...