提交 89703846 authored 作者: wzj's avatar wzj

11

上级 b53044fc
......@@ -11,6 +11,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @author wen
......@@ -23,7 +24,7 @@ public class StudentController {
private StudentService studentService;
@ApiOperation(value = "查询单个")
@GetMapping("/findone")
@GetMapping("/findOne")
public Student finOne(Integer integer){
return studentService.findOne(integer);
}
......@@ -35,7 +36,7 @@ public class StudentController {
}
@ApiOperation(value = "条件查询")
@GetMapping("/findTj")
@PostMapping("/findTj")
public ResponseEntity<Page<Student>> findTj(@RequestBody Student student){
Page<Student> students =studentService.findTj(student);
return ResponseEntity.ok(students);
......@@ -61,7 +62,52 @@ public class StudentController {
@ApiOperation(value = "删除全部")
@DeleteMapping("/deleteAll")
public void deleteAll(Student student) {
studentService.deleteAll(student);
public void deleteAll( ) {
studentService.deleteAll();
}
@ApiOperation(value = "随机保存姓名年龄")
@PostMapping("/saveRandomly")
public Student saveRandomly(){
return studentService.saveRandomly();
}
@ApiOperation(value = "查询各个年龄段")
@GetMapping("/findAge")
public Map<String,List<Student>> findDigit(){
return studentService.findDigit();
}
@ApiOperation(value = "查询各个年龄段男女数量")
@GetMapping("/findGender")
public Map<String,List<Student>> findGender(){
return studentService.findGender();
}
@ApiOperation(value = "查询男女各个年龄段数量")
@GetMapping("/findGenderAge")
public Map<String,List<Student>> findDigitGender(){
return studentService.findDigitGender();
}
@ApiOperation(value = "用*替换名字")
@GetMapping("/replace")
public List<Student> replace(){
return studentService.replaceName();
}
@ApiOperation(value = "用*替换中间字")
@GetMapping("/replaceMiddle")
public List<Student> replaceMiddle(){
return studentService.replace();
}
@ApiOperation(value = "按年查出每年的人数")
@GetMapping("/findYear")
public Map<String, List<Student>> findYear(){
return studentService.findYear();
}
@ApiOperation(value = "分页查询模糊查询名字 根据年份查询人数")
@GetMapping("/findNameYear")
public Page<Student> findNameYear(String name ,Integer page, Integer pageSize,Integer year){
return studentService.findNameYear(name,page,pageSize,year);
}
}
package com.example.demo.dao;
import com.example.demo.pojo.Student;
import io.swagger.models.auth.In;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;
import java.util.List;
......
package com.example.demo.pojo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.List;
/**
......@@ -14,8 +17,7 @@ import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@Entity
/*@SQLDelete(sql = "update ass_taskdetail set is_deleted =1 where id =?")
@Where(clause = "is_delete = 0")*/
public class Student {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
......@@ -24,5 +26,6 @@ public class Student {
private Integer age;
private String gender;
private String height;
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate date;
}
......@@ -3,7 +3,9 @@ package com.example.demo.service;
import com.example.demo.pojo.Student;
import org.springframework.data.domain.Page;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
/**
* @author wen
......@@ -50,7 +52,58 @@ public interface StudentService {
/**
* 删除全部
* @param student
* @param
*/
void deleteAll();
/**
* 随机保存姓名年龄等字段
* @param
* @return
*/
Student saveRandomly();
/**
* 查询排序0-10 11-20 21-30 31-40 41-50 51-60
* @param
* @return
*/
Map<String,List<Student>> findDigit();
/**
* 查询各个年龄段的人男女
* @return
*/
Map<String,List<Student>> findGender();
/**
* 查询男女各个年龄段的数量
* @return0
*/
Map<String,List<Student>> findDigitGender();
/**替换最后一个字为*
*
* @return
*/
List<Student> replaceName();
/**
* 替换中间字为*
* @return
*/
List<Student> replace();
/**
* /按年过滤出每年有那些人
* @return
*/
Map<String, List<Student>> findYear();
/**
* 分页查询 名字模糊查询 输入年份查询人数
* @param
* @return
*/
void deleteAll(Student student);
Page<Student> findNameYear(String name ,Integer page, Integer pageSize,Integer year);
}
server.port=8081
server.port=8089
# mysql jdbc
spring.datasource.url=jdbc:mysql://localhost:3306/demo?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论