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

Student后台管理系统查询接口

实体类student代码

package org.example.studentback01.entity;import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;@Data
@TableName("student")
public class Student {@TableId(type = IdType.AUTO)private Integer id;private String no;private String name;private String password;private int sex;private int roleId;private String phone;@TableField(exist = false)private String isValid;@Overridepublic String toString() {return "Student{" +"id=" + id +", no='" + no + '\'' +", name='" + name + '\'' +", password='" + password + '\'' +", sex=" + sex +", roleId=" + roleId +", phone='" + phone + '\'' +", isValid='" + isValid + '\'' +'}';}public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getNo() {return no;}public void setNo(String no) {this.no = no;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}public int getSex() {return sex;}public void setSex(int sex) {this.sex = sex;}public int getRoleId() {return roleId;}public void setRoleId(int roleId) {this.roleId = roleId;}public String getPhone() {return phone;}public void setPhone(String phone) {this.phone = phone;}public String getIsValid() {return isValid;}public void setIsValid(String isValid) {this.isValid = isValid;}
}

controller代码

package org.example.studentback01.controller;import org.example.studentback01.entity.Student;
import org.example.studentback01.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;import java.util.List;@RestController
public class helloController {@GetMappingpublic String hello(){return "hello world";}@Autowiredprivate StudentService studentService;@GetMapping("/list")public List<Student> list(){return studentService.listAllStudent();}
}

StudentMapper

package org.example.studentback01.mapper;import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.example.studentback01.entity.Student;import java.util.List;
@Mapper
public interface StudentMapper extends BaseMapper<Student> {List<Student> listAllStudent();
}

StudentService

package org.example.studentback01.service;import com.baomidou.mybatisplus.extension.service.IService;
import org.example.studentback01.entity.Student;import java.util.List;public interface StudentService extends IService<Student> {List<Student> listAllStudent();}

StudentServiceImpl

package org.example.studentback01.service.impl;import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.studentback01.entity.Student;
import org.example.studentback01.mapper.StudentMapper;
import org.example.studentback01.service.StudentService;
import org.springframework.stereotype.Service;import javax.annotation.Resource;
import java.util.List;@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student> implements StudentService {@Resourceprivate StudentMapper studentMapper;@Overridepublic List<Student> listAllStudent() {return list();}
}

StudentMapper.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org..example.studentback01.mapper.StudentMapper"><select id="listAllStudent" resultType="org.example.studentback01.entity.Student">select * from student</select></mapper>

数据库学生表结构

DROP TABLE IF EXISTS `student`;
CREATE TABLE `student`  (`id` int NOT NULL AUTO_INCREMENT COMMENT '主键',`no` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '账号',`name` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '名字',`PASSWORD` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '密码',`age` int NULL DEFAULT NULL,`sex` int NULL DEFAULT NULL COMMENT '性别',`phone` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT NULL COMMENT '电话',`role_id` int NULL DEFAULT NULL COMMENT '角色 0超级管理员,1管理员,2普通账号',`isValid` varchar(4) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL DEFAULT 'Y' COMMENT '是否有效,Y有效,其他无效',PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci ROW_FORMAT = Dynamic;SET FOREIGN_KEY_CHECKS = 1;

http://www.xdnf.cn/news/15404.html

相关文章:

  • CentOS服务器安装Supervisor使队列可以在后台运行
  • GAMES101 lec2-数学基础1(线性代数)
  • 为何说分布式 AI 推理已成为下一代计算方式
  • 特殊的整数-水仙花数
  • 【c++】c++11新特性(右值引用和移动语义)
  • Java报表导出框架
  • 详解BIO,NIO,AIO
  • 【git fetch submodule报错】Errors during submodule fetch 如何解决?
  • 【Java EE】多线程-初阶 认识线程(Thread)
  • urlencode、html实体编码、unicode
  • 进程---基础知识+命令+函数(fork+getpid+exit+wait+exec)
  • ACL流量控制实验
  • 12.如何判断字符串是否为空?
  • 记字节前端面试一道简单的算法题
  • 游戏玩法的专利博弈
  • 大话数据结构之 <链表>(C语言)
  • 使用 keytool 在服务器上导入证书操作指南(SSL 证书验证错误处理)
  • 【DOCKER】-4 dockerfile镜像管理
  • Python数据容器-通用功能
  • grpo nl2sql qwen3 模型强化学习训练有效果的成立条件有哪些
  • java--ThreadLocal创建以及get源码解析
  • 131. Java 泛型 - 目标类型与泛型推断
  • RNN(循环神经网络)
  • js与vue基础学习
  • Cesium源码打包
  • 从数据库到播放器:Java视频续播功能完整实现解析
  • Netty编程模型介绍
  • 聚宽sql数据库传递
  • 【WPF】WPF 自定义控件 实战详解,含命令实现
  • Node.js + Express的数据库AB View切换方案设计