提交 f09151fe authored 作者: zhoushaopan's avatar zhoushaopan

feat(3d模块): 新增删除接口

新增删除接口
上级 8f3b6335
...@@ -68,7 +68,7 @@ public class DeviceLibraryPositionController { ...@@ -68,7 +68,7 @@ public class DeviceLibraryPositionController {
} }
@GetMapping("/delete") @GetMapping("/delete")
@ApiOperation(value = "根据id查询") @ApiOperation(value = "根据id删除")
public ResponseEntity<String> deleteByPosition(Integer id){ public ResponseEntity<String> deleteByPosition(Integer id){
deviceLibraryPositionService.deleteByPosition(id); deviceLibraryPositionService.deleteByPosition(id);
return ResponseEntity.ok("删除成功"); return ResponseEntity.ok("删除成功");
......
package com.tykj.dev.device.library.service.impl; //package com.tykj.dev.device.library.service.impl;
//
import com.tykj.dev.device.library.repository.DeviceLibraryPositionDao; //import com.tykj.dev.device.library.repository.DeviceLibraryPositionDao;
import com.tykj.dev.device.library.service.DeviceLibraryPositionService; //import com.tykj.dev.device.library.service.DeviceLibraryPositionService;
import com.tykj.dev.device.library.service.DeviceLibraryService; //import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary; //import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.domin.DeviceLibraryPosition; //import com.tykj.dev.device.library.subject.domin.DeviceLibraryPosition;
import com.tykj.dev.device.user.util.UserUtils; //import com.tykj.dev.device.user.util.UserUtils;
import lombok.val; //import lombok.val;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; //import org.springframework.stereotype.Service;
//
import java.util.List; //import java.util.List;
import java.util.Optional; //import java.util.Optional;
//
/** ///**
* @author zsp // * @author zsp
* @create 2021/12/13 16:23 // * @create 2021/12/13 16:23
*/ // */
@Service //@Service
public class DeviceLibraryPositionServiceImpl implements DeviceLibraryPositionService { //public class DeviceLibraryPositionServiceImpl implements DeviceLibraryPositionService {
//
@Autowired // @Autowired
private UserUtils userUtils; // private UserUtils userUtils;
//
@Autowired // @Autowired
private DeviceLibraryService deviceLibraryService; // private DeviceLibraryService deviceLibraryService;
//
@Autowired // @Autowired
private DeviceLibraryPositionDao deviceLibraryPositionDao; // private DeviceLibraryPositionDao deviceLibraryPositionDao;
//
@Override // @Override
public void addDeviceLibraryPosition(DeviceLibraryPosition deviceLibraryPosition) { // public void addDeviceLibraryPosition(DeviceLibraryPosition deviceLibraryPosition) {
deviceLibraryPositionDao.save(deviceLibraryPosition); // deviceLibraryPositionDao.save(deviceLibraryPosition);
} // }
//
@Override // @Override
public void updateDeviceLibraryPosition(DeviceLibraryPosition deviceLibraryPosition) { // public void updateDeviceLibraryPosition(DeviceLibraryPosition deviceLibraryPosition) {
deviceLibraryPositionDao.save(deviceLibraryPosition); // deviceLibraryPositionDao.save(deviceLibraryPosition);
} // }
//
@Override // @Override
public void batchDeviceLibraryPositions(List<DeviceLibraryPosition> deviceLibraryPositions) { // public void batchDeviceLibraryPositions(List<DeviceLibraryPosition> deviceLibraryPositions) {
deviceLibraryPositionDao.saveAll(deviceLibraryPositions); // deviceLibraryPositionDao.saveAll(deviceLibraryPositions);
} // }
//
@Override // @Override
public List<DeviceLibraryPosition> findByStorageLocationId(Integer StorageLocationId) { // public List<DeviceLibraryPosition> findByStorageLocationId(Integer StorageLocationId) {
return deviceLibraryPositionDao.findAllByStorageLocationId(StorageLocationId); // return deviceLibraryPositionDao.findAllByStorageLocationId(StorageLocationId);
//
} // }
//
@Override // @Override
public DeviceLibraryPosition findById(Integer id) { // public DeviceLibraryPosition findById(Integer id) {
DeviceLibraryPosition deviceLibraryPosition = new DeviceLibraryPosition(); // DeviceLibraryPosition deviceLibraryPosition = new DeviceLibraryPosition();
Optional<DeviceLibraryPosition> positionDaoById = deviceLibraryPositionDao.findById(id); // Optional<DeviceLibraryPosition> positionDaoById = deviceLibraryPositionDao.findById(id);
if(positionDaoById.isPresent()){ // if(positionDaoById.isPresent()){
deviceLibraryPosition = positionDaoById.get(); // deviceLibraryPosition = positionDaoById.get();
} // }
return deviceLibraryPosition; // return deviceLibraryPosition;
} // }
//
@Override // @Override
public void deleteByPosition(Integer id) { // public void deleteByPosition(Integer id) {
DeviceLibraryPosition deviceLibraryPosition= findById(id); // DeviceLibraryPosition deviceLibraryPosition= findById(id);
DeviceLibrary deviceLibrary = deviceLibraryService.getOne(deviceLibraryPosition.getDeviceId()); // DeviceLibrary deviceLibrary = deviceLibraryService.getOne(deviceLibraryPosition.getDeviceId());
deviceLibrary.setStorageLocation(null); // deviceLibrary.setStorageLocation(null);
deviceLibrary.setStorageLocationId(null); // deviceLibrary.setStorageLocationId(null);
deviceLibraryPositionDao.delete(deviceLibraryPosition); // deviceLibraryPositionDao.delete(deviceLibraryPosition);
deviceLibraryService.update(deviceLibrary); // deviceLibraryService.update(deviceLibrary);
} // }
} //}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论