| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | private void insertBatch(List<Software> softwareList){ |
| | | mapper.insertBatchSomeColumn(softwareList); |
| | | } |
| | | |
| | | @Transactional |
| | | public Response updateApplyModel(List<Software> softwareList) { |
| | | QueryWrapper<Software> query = Wrappers.query(); |
| | | query.eq("file_name",softwareList.get(0).getFileName()).last(" limit 1"); |
| | | Software softwareDB = mapper.selectOne(query); |
| | | if(softwareDB == null){ |
| | | return new Response().set(1,false,"对应的软件并未上传过,无法更新适用机型"); |
| | | }else{ |
| | | //先删除对应的适用机型,再新增适用机型记录 |
| | | UpdateWrapper<Software> update = Wrappers.update(); |
| | | update.eq("file_name",softwareDB.getFileName()); |
| | | mapper.delete(update); |
| | | softwareList.forEach(software -> { |
| | | software.setFileUrl(softwareDB.getFileUrl()); |
| | | software.setExcelUrl(softwareDB.getExcelUrl()); |
| | | software.setCreateTime(new Date()); |
| | | }); |
| | | mapper.insertBatchSomeColumn(softwareList); |
| | | return new Response().set(1,true,"更新完成"); |
| | | } |
| | | } |
| | | } |