| | |
| | | |
| | | 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.whyc.dto.Response; |
| | | import com.whyc.mapper.AttachLockMapper; |
| | | import com.whyc.pojo.AttachLock; |
| | |
| | | UpdateWrapper uwrapper=new UpdateWrapper(); |
| | | uwrapper.set("lock_flag",attachLock.getLockFlag()); |
| | | uwrapper.set("local_reason",attachLock.getLocalReason()); |
| | | uwrapper.eq("attach_name",attachLock.getAttachName()); |
| | | uwrapper.eq("material_id",attachLock.getMaterialId()); |
| | | mapper.update(null,uwrapper); |
| | | }else{ |
| | |
| | | UpdateWrapper uwrapper=new UpdateWrapper(); |
| | | uwrapper.set("lock_flag",attachLock.getLockFlag()); |
| | | uwrapper.set("local_reason",attachLock.getLocalReason()); |
| | | uwrapper.set("product_id",attachLock.getProductId()); |
| | | uwrapper.eq("attach_name",attachLock.getAttachName()); |
| | | uwrapper.eq("product_id",attachLock.getProductId()); |
| | | mapper.update(null,uwrapper); |
| | | }else{ |
| | | mapper.insert(attachLock); |
| | |
| | | }); |
| | | return new Response().set(1,true,""); |
| | | } |
| | | |
| | | public void getAndInsert(Integer materialIdInDB, Integer materialId) { |
| | | QueryWrapper<AttachLock> query = Wrappers.query(); |
| | | query.eq("material_id",materialIdInDB).eq("lock_flag",1).eq("product_id",0); |
| | | List<AttachLock> attachLocksInDB = mapper.selectList(query); |
| | | |
| | | attachLocksInDB.forEach(attachLock -> { |
| | | attachLock.setId(null); |
| | | attachLock.setMaterialId(materialId); |
| | | }); |
| | | if(attachLocksInDB.size()!=0) { |
| | | mapper.insertBatchSomeColumn(attachLocksInDB); |
| | | } |
| | | } |
| | | } |