Skip to content

Commit

Permalink
[PDS-56] feat: fix: 비품 조회, 비품 수정 API 로직 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
dangnak2 committed Dec 1, 2023
1 parent 7f51e55 commit 1a48a6a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public class UpdateEquipmentReq {
private String quantity;
@Schema(type = "Long", description = "비품 담당자", example = "1", required = true)
private Long register;
@Schema(type = "Long", description = "비품 등록자", example = "1", required = true)
@NotNull(message = "E0003")
private Long userId;
@Schema(type = "String", description = "비품 위치", example = "s1350", required = true)
@NotBlank(message = "E0003")
private String location;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,15 @@ public void registerEquipment(RegisterEquipmentReq registerEquipmentReq, User us
}

public Page<SearchEquipmentRes> searchEquipment(String cond, Pageable pageable) {
Page<Equipment> equipments;

if(StringUtils.hasText(cond)) equipments = equipmentRepository.findByNameContainsAndIsEnable(cond, pageable, true);
else equipments = equipmentRepository.findAll(pageable);
Page<Equipment> equipments = equipmentRepository.findByNameContainsAndIsEnable(cond,pageable,true);
return equipments.map(SearchEquipmentRes::toDto);
}

@Transactional
public void updateEquipment(Long equipmentId, UpdateEquipmentReq updateEquipmentReq, User user) {
Equipment equipment = equipmentRepository.findByEquipmentIdAndIsEnable(equipmentId, true).orElseThrow(() -> new BaseException(BaseResponseCode.EQUIPMENT_NOT_FOUND));

User register = userRepository.findByUserIdAndIsEnable(updateEquipmentReq.getUserId(), true).orElseThrow(() -> new BaseException(BaseResponseCode.USER_NOT_FOUND));
EquipmentCategory updateCategory = extractCategory(updateEquipmentReq.getCategory());
equipment.toUpdateInfo(updateEquipmentReq, register, updateCategory);
equipment.toUpdateInfo(updateEquipmentReq, user, updateCategory);
}

private EquipmentCategory extractCategory(String name) {
Expand Down

0 comments on commit 1a48a6a

Please sign in to comment.