package com.umbrella.controller;
import com.umbrella.model.Student;
import com.umbrella.service.StudentService;
import com.umbrella.util.Result;
import groovy.util.logging.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import java.util.List;
@RestController
@RequestMapping("/v1/login")
@Slf4j
public class TestController {
@Autowired
private StudentService studentService;
@RequestMapping("/register")
public Result Register(@RequestBody Student student){
studentService.insert(student);
return new Result(Result.OK,"保存成功");
}
@RequestMapping("/findAllStudent")
public Result test1(){
Result result = new Result();
List<Student> student = studentService.findAllStudent();
result.setData(student);
return result;
}
@RequestMapping("findSomeColumn")
public Result test2(){
Result result = new Result();
List<Student> stu = studentService.findSomeColumn();
result.setData(stu);
return result;
}
@RequestMapping("deleteById/{id}")
public Result test3(@PathVariable Integer id){
Result result = new Result();
studentService.deleteById(id);
result.setMsg("删除成功");
return result;
}
@RequestMapping("updateByPrimarKeySelective")
public Result test4(@RequestBody Student student){
Result result = new Result();
EntityWrapper<Student> entityWrapper = new EntityWrapper<>();
entityWrapper.eq("stu_mobile", student.getStuMobile());
Student stu = studentService.selectOne(entityWrapper);
if (null != stu) {
stu.setParName("my hero");
stu.setStuName("zxs");
}
studentService.updateByPrimarKeySelective(stu);
result.setData(stu);
return result;
}
@RequestMapping("/saveStudent")
public Result<Student> test5(@RequestBody Student student){
Result<Student> result = new Result<Student>();
studentService.saveStudent(student);
result.setData(student);
return result;
}
/**
* 分页的方法
* @param pageNumber
* @param pageSize
* @return
*/
@RequestMapping("page/{pageNumber}")
public Result findAllStuPage(@PathVariable Integer pageNumber,
@RequestParam(defaultValue="6") Integer pageSize){
Result result = new Result();
Page page = new Page(pageNumber,pageSize);
Page<Student> pageStu = studentService.findAllStudentPage(page);
result.setData(pageStu.getRecords());
return result;
}
@RequestMapping("pageByGender/{pageNumber}")
public Result findStuByGender(@PathVariable Integer pageNumber,
@RequestParam(defaultValue="6") Integer pageSize){
Result result = new Result<>();
EntityWrapper<Student> wrapper = new EntityWrapper<>();
wrapper.eq("gender", 1);
Page<Student> page = getPage(pageNumber, pageSize);
Page<Student> stuPage = studentService.selectPage(page, wrapper);
result.setData(stuPage.getRecords());
return result;
}
/**
* 获取分页对象
* 每页显示数量
*/
private <T> Page<T> getPage(int pageNum,int pageSize){
return new Page<T>(pageNum,pageSize);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Maven+SpringBoot+Mybatis+MybatisPlus+MySQL的web项目

共111个文件
xml:87个
java:16个
gitignore:1个


温馨提示
Maven+SpringBoot+Mybatis+MybatisPlus+MySQL的web项目,执行SpringbootMybatisDemoApplication.java文件的main方法即可把项目跑起来了,数据库相关sql放在了resources的sql文件夹里,记得执行
资源推荐
资源详情
资源评论






















收起资源包目录





































































































共 111 条
- 1
- 2
资源评论

- wutaoj2019-10-09可以用的,很不错的
- jameswjw2020-09-21相当不错呀
- java攻城师_Charles2019-12-23跑起来了,让我学习了

umbrellasoft
- 粉丝: 344
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 超宽带抗干扰通信定位技术研究的开题报告.docx
- 北京交通大学2021年9月《电子商务概论》作业考核试题及答案参考9.docx
- 互联网+模式下高校工会个性化福利模式探究.docx
- 平面设计考证-CorelDRAW练习题+答案.docx
- 东北大学2021年9月《热工仪表及自动化》作业考核试题及答案参考8.docx
- MATLAB重点归纳.doc
- 计算机网络管理技术讲课资料.ppt
- 信息点间通信-内外网络的通信都是企业网络中必不可少的业务需求-但是为了保证内网的安全性-需要通过教学幻.ppt
- 第三章HTML控件和Web服务器控件-HTML控件Web服务器控件教学提纲.ppt
- 主讲教师许燕青闽南理工学院实践教学中心计算机教研室复习课程.ppt
- 基于信息技术的通信传输资源管理信息技术.docx
- 《Dreamweaver网页设计》第15章.ppt
- Wonderware InTouch编程入门教学 PPT.pptx
- 商品库MySQL优化实践备课讲稿.ppt
- 第一讲JAVA语言概述说课材料.ppt
- XXXX公司网站网络推广计划方案教学讲义.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
