75修改还是提示“当前卫生机构下已存在该科室名称的诊室”。
This commit is contained in:
@@ -26,11 +26,11 @@ public class ClinicRoomAppServiceImpl implements IClinicRoomAppService {
|
||||
if (roomName != null && ObjectUtil.isNotEmpty(roomName)) {
|
||||
clinicRoom.setRoomName(roomName);
|
||||
}
|
||||
|
||||
|
||||
// 分页查询
|
||||
Page<ClinicRoom> page = new Page<>(pageNum, pageSize);
|
||||
Page<ClinicRoom> result = clinicRoomService.selectClinicRoomPage(page, clinicRoom);
|
||||
|
||||
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,12 @@ public class ClinicRoomAppServiceImpl implements IClinicRoomAppService {
|
||||
if (clinicRoom.getRemarks() != null && clinicRoom.getRemarks().length() > 500) {
|
||||
return R.fail(400, "备注长度不能超过500个字符");
|
||||
}
|
||||
|
||||
|
||||
// 检查诊室名称在同卫生机构下是否已存在
|
||||
if (clinicRoomService.existsByOrgNameAndRoomName(clinicRoom.getOrgName(), clinicRoom.getRoomName())) {
|
||||
return R.fail(400, "当前卫生机构下已存在该诊室名称");
|
||||
}
|
||||
|
||||
// 新增诊室
|
||||
int result = clinicRoomService.insertClinicRoom(clinicRoom);
|
||||
if (result > 0) {
|
||||
@@ -86,13 +91,18 @@ public class ClinicRoomAppServiceImpl implements IClinicRoomAppService {
|
||||
if (clinicRoom.getRemarks() != null && clinicRoom.getRemarks().length() > 500) {
|
||||
return R.fail(400, "备注长度不能超过500个字符");
|
||||
}
|
||||
|
||||
|
||||
// 检查诊室是否存在
|
||||
ClinicRoom existingClinicRoom = clinicRoomService.selectClinicRoomById(clinicRoom.getId());
|
||||
if (existingClinicRoom == null) {
|
||||
return R.fail(404, "诊室不存在");
|
||||
}
|
||||
|
||||
|
||||
// 检查诊室名称在同卫生机构下是否已存在(排除当前记录)
|
||||
if (clinicRoomService.existsByOrgNameAndRoomNameExcludeId(clinicRoom.getOrgName(), clinicRoom.getRoomName(), clinicRoom.getId())) {
|
||||
return R.fail(400, "当前卫生机构下已存在该诊室名称");
|
||||
}
|
||||
|
||||
// 更新诊室
|
||||
int result = clinicRoomService.updateClinicRoom(clinicRoom);
|
||||
if (result > 0) {
|
||||
@@ -109,7 +119,7 @@ public class ClinicRoomAppServiceImpl implements IClinicRoomAppService {
|
||||
if (existingClinicRoom == null) {
|
||||
return R.fail(404, "诊室不存在");
|
||||
}
|
||||
|
||||
|
||||
// 删除诊室
|
||||
int result = clinicRoomService.deleteClinicRoomById(id);
|
||||
if (result > 0) {
|
||||
|
||||
@@ -51,4 +51,23 @@ public interface IClinicRoomService extends IService<ClinicRoom> {
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteClinicRoomById(Long id);
|
||||
|
||||
/**
|
||||
* 检查指定卫生机构下是否已存在相同诊室名称(新增时使用)
|
||||
*
|
||||
* @param orgName 卫生机构名称
|
||||
* @param roomName 诊室名称
|
||||
* @return 是否存在
|
||||
*/
|
||||
boolean existsByOrgNameAndRoomName(String orgName, String roomName);
|
||||
|
||||
/**
|
||||
* 检查指定卫生机构下是否已存在相同诊室名称(编辑时使用,排除当前记录)
|
||||
*
|
||||
* @param orgName 卫生机构名称
|
||||
* @param roomName 诊室名称
|
||||
* @param id 当前记录ID
|
||||
* @return 是否存在
|
||||
*/
|
||||
boolean existsByOrgNameAndRoomNameExcludeId(String orgName, String roomName, Long id);
|
||||
}
|
||||
|
||||
@@ -44,4 +44,21 @@ public class ClinicRoomServiceImpl extends ServiceImpl<ClinicRoomMapper, ClinicR
|
||||
public int deleteClinicRoomById(Long id) {
|
||||
return baseMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existsByOrgNameAndRoomName(String orgName, String roomName) {
|
||||
LambdaQueryWrapper<ClinicRoom> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ClinicRoom::getOrgName, orgName)
|
||||
.eq(ClinicRoom::getRoomName, roomName);
|
||||
return count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existsByOrgNameAndRoomNameExcludeId(String orgName, String roomName, Long id) {
|
||||
LambdaQueryWrapper<ClinicRoom> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ClinicRoom::getOrgName, orgName)
|
||||
.eq(ClinicRoom::getRoomName, roomName)
|
||||
.ne(ClinicRoom::getId, id);
|
||||
return count(queryWrapper) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user