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

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

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