新
This commit is contained in:
@@ -37,6 +37,16 @@
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-system</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>cn.hutool</groupId>-->
|
||||
<!-- <artifactId>hutool-all</artifactId>-->
|
||||
<!-- <version>5.8.25</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.poi</groupId>-->
|
||||
<!-- <artifactId>poi-ooxml</artifactId>-->
|
||||
<!-- <version>5.3.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@@ -60,7 +60,6 @@ public class FileController {
|
||||
*/
|
||||
@GetMapping("/download/{fileName}")
|
||||
public Result download(@PathVariable String fileName , HttpServletResponse response){
|
||||
|
||||
try {
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8));
|
||||
response.setContentType("application/octet-stream");
|
||||
|
@@ -1,17 +1,18 @@
|
||||
package org.dromara.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.dromara.common.Result;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.domain.Student;
|
||||
import org.dromara.service.IStudentService;
|
||||
import org.dromara.service.impl.StudentService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -57,14 +58,6 @@ public class StudentController {
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@PostMapping("/selectPage")
|
||||
public R<IPage<Student>> selectPage(@RequestBody Student student) {
|
||||
IPage<Student> list = studentService.selectPage(student);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单个数据
|
||||
@@ -75,5 +68,35 @@ public class StudentController {
|
||||
return Result.success(student);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@PostMapping("/selectPage")
|
||||
public R<IPage<Student>> selectPage(@RequestBody Student student) {
|
||||
IPage<Student> list = studentService.selectPage(student);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
// //导出excel
|
||||
// @GetMapping("/export")
|
||||
// public void export(HttpServletResponse response) throws Exception {
|
||||
// // 1.拿到学生所有数据
|
||||
// List<Student> studentList = studentService.selectAll(null);
|
||||
// // 2. 构建ExcelWriter
|
||||
// // 在内存操作,写出到浏览器
|
||||
// ExcelWriter writer = ExcelUtil.getWriter(true);
|
||||
// // 3. 设置中文表头
|
||||
// writer.addHeaderAlias("name","姓名");
|
||||
// // 4.写出数据到writer
|
||||
// writer.write(studentList,true);
|
||||
// // 5. 设置输出文件的名称, 以及输出流的头信息
|
||||
// // 设置浏览器响应格式
|
||||
// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
||||
// String fileName = URLEncoder.encode("学生信息", "UTF-8");
|
||||
// response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
|
||||
// // 6. 写出到输出流, 并关闭
|
||||
// ServletOutputStream os = response.getOutputStream();
|
||||
// writer.flush(os);
|
||||
// writer.close();
|
||||
// }
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@ import org.dromara.domain.Student;
|
||||
import java.util.List;
|
||||
|
||||
public interface StudentMapper {
|
||||
|
||||
List<Student> selectAll(Student student);
|
||||
@Select("select * from student where id = #{id}")
|
||||
Student selectById(Integer id);
|
||||
@@ -21,6 +22,7 @@ public interface StudentMapper {
|
||||
|
||||
@Delete("delete from `student` where id = #{id}")
|
||||
void deleteById(Integer id);
|
||||
|
||||
@Select("select * from student where username = #{username}")
|
||||
Student selectByUsername(String username);
|
||||
|
||||
|
@@ -23,7 +23,5 @@ public interface IStudentService {
|
||||
List<Student> selectAll(Student student);
|
||||
|
||||
Student selectById( Integer id);
|
||||
|
||||
|
||||
IPage<Student> selectPage(Student student);
|
||||
}
|
||||
|
@@ -5,7 +5,10 @@
|
||||
<mapper namespace="org.dromara.mapper.StudentMapper">
|
||||
<select id="selectAll" resultType="org.dromara.domain.Student" parameterType="org.dromara.domain.Student">
|
||||
select
|
||||
student.id, student.username, student.password, student.role, student.name, student.age, student.sex, student.address, student.cls_id, student.course_id, student.avatar, student.create_dept, student.create_by, student.create_time, student.update_by, student.update_time, student.remark, student.del_flag, cls.name as clsName from student
|
||||
student.id, student.username, student.password, student.role, student.name, student.age, student.sex,
|
||||
student.address, student.cls_id, student.course_id, student.avatar, student.create_dept, student.create_by,
|
||||
student.create_time, student.update_by, student.update_time, student.remark, student.del_flag, cls.name as
|
||||
clsName from student
|
||||
left join cls on student.cls_id = cls.id
|
||||
<where>
|
||||
<if test="name != null">student.name like concat('%', #{name}, '%')</if>
|
||||
@@ -21,26 +24,26 @@
|
||||
|
||||
<select id="selectPage" resultType="org.dromara.domain.Student">
|
||||
select s.id,
|
||||
s.username,
|
||||
s.password,
|
||||
s.role,
|
||||
s.name,
|
||||
s.age,
|
||||
s.sex,
|
||||
s.address,
|
||||
s.cls_id,
|
||||
s.course_id,
|
||||
s.avatar,
|
||||
s.create_dept,
|
||||
s.create_by,
|
||||
s.create_time,
|
||||
s.update_by,
|
||||
s.update_time,
|
||||
s.remark,
|
||||
s.del_flag,
|
||||
c.name as clsName
|
||||
s.username,
|
||||
s.password,
|
||||
s.role,
|
||||
s.name,
|
||||
s.age,
|
||||
s.sex,
|
||||
s.address,
|
||||
s.cls_id,
|
||||
s.course_id,
|
||||
s.avatar,
|
||||
s.create_dept,
|
||||
s.create_by,
|
||||
s.create_time,
|
||||
s.update_by,
|
||||
s.update_time,
|
||||
s.remark,
|
||||
s.del_flag,
|
||||
c.name as clsName
|
||||
from student as s
|
||||
left join cls as c on s.cls_id = c.id
|
||||
left join cls as c on s.cls_id = c.id
|
||||
<where>
|
||||
<if test="student.name != null">s.name like concat('%', #{student.name}, '%')</if>
|
||||
</where>
|
||||
|
Reference in New Issue
Block a user