package com.school.eduservice.service.impl; import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.school.eduservice.entity.EduSubject; import com.school.eduservice.entity.excel.SubjectData; import com.school.eduservice.entity.vo.OneSubject; import com.school.eduservice.entity.vo.TwoSubject; import com.school.eduservice.listener.SubjectExcelListener; import com.school.eduservice.mapper.EduSubjectMapper; import com.school.eduservice.service.EduSubjectService; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import java.io.InputStream; import java.util.ArrayList; import java.util.List; @Service public class EduSubjectServiceImpl extends ServiceImplimplements EduSubjectService { @Override public void addFiles(MultipartFile file,EduSubjectService eduSubjectService) { try { //文件输入流 InputStream inputStream = file.getInputStream(); //调用方法读取 EasyExcel.read(inputStream,SubjectData.class,new SubjectExcelListener(eduSubjectService)).sheet().doRead(); }catch (Exception e){ e.printStackTrace(); } } @Override public List subTree() { //查询出一级分类 QueryWrapper objectQueryWrapper = new QueryWrapper<>(); objectQueryWrapper.eq("parent_id",0); //怎么在 service 中调用 mapper 中的方法查询 //1.方法一 因为service 类 已经继承的 ServiceImpl 中 // 已经帮我们注入了 mapper 所以 我们可以直接用 // List eduSubjects = baseMapper.selectList(objectQueryWrapper); //方法二 用 this(当前类)也可以调用 mapper中的方法 List eduSubjects1 = this.list(objectQueryWrapper); List eduSubject2=this.list(new QueryWrapper ().ne("parent_id",0)); List list= new ArrayList<>(); for (int i=0;i twoSubjects=new ArrayList<>(); for(int j=0;j 欢迎分享,转载请注明来源:内存溢出
SpringBoot 中Service类中的方法 总结
赞
(0)
打赏
微信扫一扫
支付宝扫一扫
Java的基本数据类型
上一篇
2022-12-16
第七课:java类与对象
下一篇
2022-12-16
评论列表(0条)