ru.foodtechlab.lib.auth.service.domain.roleAccess.usecase.UpdateRoleAccessUseCase Maven / Gradle / Ivy
package ru.foodtechlab.lib.auth.service.domain.roleAccess.usecase;
import com.rcore.domain.commons.usecase.UseCase;
import com.rcore.domain.commons.usecase.model.SingleOutput;
import com.rcore.domain.commons.validators.ValidationDomain;
import lombok.*;
import ru.foodtechlab.lib.auth.service.domain.Domain;
import ru.foodtechlab.lib.auth.service.domain.roleAccess.entity.RoleAccessEntity;
import ru.foodtechlab.lib.auth.service.domain.roleAccess.exception.RoleAccessNotFoundException;
import ru.foodtechlab.lib.auth.service.domain.roleAccess.port.RoleAccessRepository;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@RequiredArgsConstructor
public class UpdateRoleAccessUseCase extends UseCase> {
private final RoleAccessRepository repository;
@Override
public SingleOutput execute(InputValues inputValues) {
var access = repository.findById(inputValues.getId())
.orElseThrow(RoleAccessNotFoundException::new);
access.setServiceName(inputValues.getServiceName());
access.setMethod(inputValues.getMethod());
access.setRequestPathPattern(inputValues.getRequestPathPattern());
access.setDeleted(inputValues.isDeleted());
repository.save(access);
return SingleOutput.of(access);
}
@ValidationDomain(domainName = Domain.ROLE_ACCESS)
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Data
public static class InputValues implements UseCase.InputValues {
@NotNull
private String id;
@NotBlank
private String serviceName;
@NotNull
private RoleAccessEntity.Method method;
@NotBlank
private String requestPathPattern;
private boolean isDeleted;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy