parent
461d9fc87c
commit
d1208401fe
@ -0,0 +1,77 @@
|
||||
package cc.aspark.controller;
|
||||
|
||||
|
||||
import cc.aspark.domain.dto.PageQueryDTO;
|
||||
import cc.aspark.domain.dto.StudentDTO;
|
||||
import cc.aspark.domain.entity.Student;
|
||||
import cc.aspark.result.PageResult;
|
||||
import cc.aspark.result.Result;
|
||||
import cc.aspark.service.StudentService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.Builder;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/student")
|
||||
@RequiredArgsConstructor
|
||||
@Builder
|
||||
@Tag(name = "学生表相关操作")
|
||||
public class StudentController {
|
||||
|
||||
private final StudentService studentService;
|
||||
|
||||
@Operation(summary = "查询全部学生信息")
|
||||
@GetMapping
|
||||
public Result<List<Student>> list() {
|
||||
List<Student> studentList = studentService.list();
|
||||
return Result.success(studentList);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据 id 查询学生信息")
|
||||
@GetMapping("/{id}")
|
||||
public Result<Student> getStuInfoById(@PathVariable Integer id) {
|
||||
Student stuInfo = studentService.getById(id);
|
||||
return Result.success(stuInfo);
|
||||
}
|
||||
|
||||
@Operation(summary = "学生信息分页查询")
|
||||
@GetMapping("/page")
|
||||
public Result<PageResult<Student>> pageStuInfo(PageQueryDTO pageQueryDTO) {
|
||||
log.info("学生信息分页查询: {}", pageQueryDTO);
|
||||
PageResult<Student> pageResult = studentService.page(pageQueryDTO);
|
||||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "新增学生信息")
|
||||
@PostMapping
|
||||
public Result save(@RequestBody StudentDTO studentDTO) {
|
||||
studentService.save(studentDTO);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "更新学生信息")
|
||||
@PutMapping
|
||||
public Result updateStu(@RequestBody StudentDTO studentDTO) {
|
||||
studentService.updateStu(studentDTO);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "删除学生信息")
|
||||
@DeleteMapping("/{ids}")
|
||||
public Result deleteStus(@PathVariable List<Integer> ids) {
|
||||
studentService.removeByIds(ids);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package cc.aspark.mapper;
|
||||
|
||||
import cc.aspark.domain.entity.Student;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author night
|
||||
* @description 针对表【tb_stu(学生信息表)】的数据库操作Mapper
|
||||
* @createDate 2024-10-02 16:31:44
|
||||
* @Entity generator.domain.TbStu
|
||||
*/
|
||||
public interface StudentMapper extends BaseMapper<Student> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
package cc.aspark.service;
|
||||
|
||||
import cc.aspark.domain.dto.PageQueryDTO;
|
||||
import cc.aspark.domain.dto.StudentDTO;
|
||||
import cc.aspark.domain.entity.Student;
|
||||
import cc.aspark.result.PageResult;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @author night
|
||||
* @description 针对表【tb_stu(学生信息表)】的数据库操作Service
|
||||
* @createDate 2024-10-02 16:31:44
|
||||
*/
|
||||
public interface StudentService extends IService<Student> {
|
||||
|
||||
void updateStu(StudentDTO studentDTO);
|
||||
|
||||
PageResult<Student> page(PageQueryDTO pageQueryDTO);
|
||||
|
||||
void save(StudentDTO studentDTO);
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?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="cc.aspark.mapper.StudentMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="cc.aspark.domain.entity.Student">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="gender" column="gender" jdbcType="TINYINT"/>
|
||||
<result property="major" column="major" jdbcType="VARCHAR"/>
|
||||
<result property="class" column="class" jdbcType="INTEGER"/>
|
||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,name,gender,
|
||||
major,class,create_time,
|
||||
update_time
|
||||
</sql>
|
||||
</mapper>
|
Loading…
Reference in new issue