package cn.zhou.student.service.impl;
import cn.zhou.student.bean.PageBean;
import cn.zhou.student.bean.Student;
import cn.zhou.student.bean.pageCondition;
import cn.zhou.student.dao.StudentMapper;
import cn.zhou.student.service.StudentService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Set;
@Service
public class StudentServiceImp implements StudentService {
@Autowired
private StudentMapper mapper;
@Autowired
private RedisTemplate redisTemplate;
public List getAll(){
QueryWrapper<Student> studentQueryWrapper = new QueryWrapper<>();
studentQueryWrapper.like("name","李%");
List<Student> students = mapper.selectList(studentQueryWrapper);
return students;
}
@Override
public PageBean getConditionPageStudent(pageCondition pageCondition,String currentPage) {
// //redis获取数据
// PageBean<Student> studentPageBean = (PageBean)redisTemplate.opsForValue().get("student:" + currentPage);
// if(StringUtils.isEmpty(pageCondition.getDept())&&StringUtils.isEmpty(pageCondition.getName())
// &&StringUtils.isEmpty(pageCondition.getSubject())
// &&StringUtils.isEmpty(pageCondition.getId())&&studentPageBean!=null){
// return studentPageBean;
// }
PageBean<Student> studentPageBean=new PageBean<Student>();
//创建mybatis分页对象
Page<Student> studentPage = new Page<Student>(pageCondition.getCurrentPage(),studentPageBean.getNum());
//创建条件对象
QueryWrapper<Student> studentQueryWrapper = new QueryWrapper<>();
if(pageCondition.getId()!=null&&pageCondition.getId()!=""){
studentQueryWrapper.eq("id",pageCondition.getId());
}
if(pageCondition.getName()!=null&&pageCondition.getName()!=""){
// studentQueryWrapper.eq("name",pageCondition.getName());
studentQueryWrapper.like("name",pageCondition.getName());
}
if(pageCondition.getSubject()!=null&&pageCondition.getSubject()!=""){
// studentQueryWrapper.eq("subject",pageCondition.getSubject());
studentQueryWrapper.like("subject",pageCondition.getSubject());
}
if(pageCondition.getDept()!=null&&pageCondition.getDept()!=""){
// studentQueryWrapper.eq("dept",pageCondition.getDept());
studentQueryWrapper.like("dept",pageCondition.getDept());
}
//查询
mapper.selectPage(studentPage, studentQueryWrapper);
//封装结果集对象
studentPageBean.setCurrentPage(studentPage.getCurrent());
studentPageBean.setAllPage(studentPage.getPages());
studentPageBean.setAll(studentPage.getTotal());
studentPageBean.setResults(studentPage.getRecords());
// if(StringUtils.isEmpty(pageCondition.getDept())&&StringUtils.isEmpty(pageCondition.getName())&&StringUtils.isEmpty(pageCondition.getSubject())
// &&StringUtils.isEmpty(pageCondition.getId())&&studentPageBean.getResults().size()!=0){
// redisTemplate.opsForValue().set("student:"+currentPage,studentPageBean);
// }
return studentPageBean;
}
@Override
public void addStudent(Student student) {
int insert = mapper.insert(student);
// if(insert>0){
// Set keys = redisTemplate.keys("*");
// redisTemplate.delete(keys);
// }
}
@Override
public Student getById(String id) {
Student student = mapper.selectById(id);
return student;
}
@Override
public void update(Student student) {
mapper.updateById(student);
// Set keys = redisTemplate.keys("*");
// redisTemplate.delete(keys);
}
@Override
public void delete(String id) {
mapper.deleteById(id);
// Set keys = redisTemplate.keys("*");
// redisTemplate.delete(keys);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
springboot 学生信息管理系统.zip (578个子文件)
SecurityConfig.class 5KB
StudentServiceImp.class 4KB
StudentController.class 3KB
PageBean.class 2KB
Student.class 2KB
StudentApplication.class 2KB
pageCondition.class 2KB
LoginController.class 1KB
StudentApplicationTests.class 931B
ErrorController.class 867B
StudentService.class 604B
StudentMapper.class 304B
mvnw.cmd 6KB
bootstrap.min.css 106KB
bootstrap.min.css 106KB
materialdesignicons.min.css 105KB
materialdesignicons.min.css 105KB
style.min.css 105KB
style.min.css 105KB
animate.css 71KB
animate.css 71KB
bootstrap-datepicker3.css 22KB
bootstrap-datepicker3.css 22KB
jquery-confirm.min.css 22KB
jquery-confirm.min.css 22KB
bootstrap-datepicker3.min.css 21KB
bootstrap-datepicker3.min.css 21KB
layer.css 14KB
layer.css 14KB
ion.rangeSlider.min.css 11KB
ion.rangeSlider.min.css 11KB
bootstrap-datetimepicker.css 9KB
bootstrap-datetimepicker.css 9KB
bootstrap-datetimepicker.min.css 8KB
bootstrap-datetimepicker.min.css 8KB
layer.css 5KB
layer.css 5KB
jquery.tagsinput.min.css 903B
jquery.tagsinput.min.css 903B
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
.DS_Store 6KB
materialdesignicons.eot 286KB
materialdesignicons.eot 286KB
loading-0.gif 6KB
loading-0.gif 6KB
loading-2.gif 2KB
loading-2.gif 2KB
loading-1.gif 701B
loading-1.gif 701B
.gitignore 333B
.gitignore 214B
userList.html 11KB
userList.html 11KB
userProfile.html 6KB
userProfile.html 6KB
changePassword.html 5KB
changePassword.html 5KB
userEdit.html 5KB
userEdit.html 5KB
userAdd.html 4KB
userAdd.html 4KB
login.html 3KB
login.html 3KB
_fragment.html 3KB
_fragment.html 3KB
unauth.html 2KB
unauth.html 2KB
40004.html 2KB
40004.html 2KB
500.html 1KB
500.html 1KB
404.html 1KB
userIndex.html 1KB
404.html 1KB
userIndex.html 1KB
student.iml 13KB
StudentServiceImp.java 4KB
SecurityConfig.java 2KB
StudentController.java 2KB
Student.java 2KB
StudentApplication.java 2KB
PageBean.java 1KB
pageCondition.java 1KB
LoginController.java 983B
StudentApplicationTests.java 639B
ErrorController.java 621B
StudentService.java 543B
StudentMapper.java 198B
avatar.jpg 22KB
avatar.jpg 22KB
Chart.js 536KB
Chart.js 536KB
bootstrap-datetimepicker.js 101KB
bootstrap-datetimepicker.js 101KB
共 578 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
程序员的成长之路
- 粉丝: 1982
- 资源: 21
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功