板材接口修改

This commit is contained in:
lym
2024-04-19 18:27:55 +08:00
parent 836c9358e3
commit af59e4d830
3 changed files with 23 additions and 11 deletions
@@ -59,10 +59,14 @@ public class PlateController {
@DeleteMapping("/delete")
@Operation(summary = "删除板材信息表 plate_{N}")
@Parameter(name = "id", description = "编号", required = true)
@Parameters({
@Parameter(name = "id", description = "编号", required = true),
@Parameter(name = "organId", description = "板材所属组织ID")
})
@PreAuthorize("@ss.hasPermission('manage:plate:delete')")
public CommonResult<Boolean> deletePlate(@RequestParam("id") Long id) {
plateService.deletePlate(id);
public CommonResult<Boolean> deletePlate(@RequestParam("id") Long id,
@RequestParam(value = "organId",required = false) Long organId) {
plateService.deletePlate(id,organId);
return success(true);
}
@@ -38,7 +38,7 @@ public interface PlateService {
*
* @param id 编号
*/
void deletePlate(Long id);
void deletePlate(Long id,Long organId);
/**
* 获得板材信息表 plate_{N}
@@ -58,23 +58,31 @@ public class PlateServiceImpl implements PlateService {
@Override
public void updatePlate(PlateSaveReqVO updateReqVO) {
// 校验存在
validatePlateExists(updateReqVO.getId());
// 更新 判断是否有组织id
if (updateReqVO.getOrganId() == null || updateReqVO.getOrganId() == 0){
updateReqVO.setOrganId(OrganContextHolder.getOrganId());
}else {
validateOrganExists(updateReqVO.getOrganId());
}
// 校验存在
validatePlateExists(updateReqVO.getId(), updateReqVO.getOrganId());
PlateDO updateObj = BeanUtils.toBean(updateReqVO, PlateDO.class);
plateMapper.updateById(updateObj);
}
@Override
public void deletePlate(Long id) {
public void deletePlate(Long id,Long organId) {
if (organId == null || organId == 0){
organId = OrganContextHolder.getOrganId();
}
// 校验存在
validatePlateExists(id);
validatePlateExists(id,organId);
// 删除
plateMapper.deleteById(id);
}
private void validatePlateExists(Long id) {
if (plateMapper.selectById(id) == null) {
private void validatePlateExists(Long id,Long organId) {
if (plateMapper.selectOneById(id,organId) == null) {
throw exception(PLATE_NOT_EXISTS);
}
}
@@ -139,7 +147,7 @@ public class PlateServiceImpl implements PlateService {
}
}
// 当前组织中板材是否存在
// 当前组织中板材是否存在
private void validateGoodExists(String goodsId ,Long organId) {
if (plateMapper.selectByGoodID(goodsId ,organId) != null){
throw exception(ErrorCodeConstants.PLATE_EXISTS);