lxw
2022-09-07 ac665d31e7df794f604f722e8364a08b940243d1
src/main/java/com/whyc/service/SoftwareService.java
@@ -1,8 +1,13 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.whyc.dto.Response;
import com.whyc.mapper.SoftwareMapper;
import com.whyc.pojo.Software;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
@@ -12,6 +17,8 @@
@Service
public class SoftwareService {
    @Autowired
    private SoftwareMapper mapper;
    public List<Software> excelParse(InputStream inputStream) throws IOException, InvalidFormatException {
        List<Software> softwareList = new LinkedList<>();
@@ -52,5 +59,24 @@
        return softwareList;
    }
    //查询软件列表的信息
    public Response getAllSoftware(String fileName, int pageCurr, int pageSize) {
        PageHelper.startPage(pageCurr,pageSize);
        QueryWrapper wrapper=new QueryWrapper();
        if(fileName!=null&&!fileName.isEmpty()){
            wrapper.like("file_name",fileName);
        }
        wrapper.orderByAsc("file_name");
        wrapper.orderByAsc("version");
        List list=mapper.selectList(wrapper);
        return new Response().setII(1,list.size()>0,list,"软件信息返回");
    }
    //根据subcode查询软件列表
    public Response getSoftBySubCode(String subCode) {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("sub_code",subCode);
        wrapper.orderByAsc("version");
        List list=mapper.selectList(wrapper);
        return new Response().setII(1,list.size()>0,list,"软件信息返回");
    }
}