Skip to content

Commit

Permalink
FEAT:fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
rivo pelu committed Dec 9, 2024
1 parent c33066f commit ec82dd6
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/pos/app/controller/ClientController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.pos.app.model.request.ReqCreateClient;
import com.pos.app.model.response.BaseResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;

@BaseController("client")
Expand All @@ -15,4 +16,7 @@ public interface ClientController {
@PostMapping("v1/create-by-user")
BaseResponse createClientByUser(@RequestBody ReqCreateClient req);

@PutMapping("v1/edit")
BaseResponse editClient(@RequestBody ReqCreateClient req);

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class AuthControllerImpl implements AuthController {
private final SimpMessagingTemplate simpMessagingTemplate;



@Override
public BaseResponse signInStaff(RequestSignIn req) {
return ResponseHelper.createBaseResponse(authService.signInStaff(req));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ public BaseResponse createClient(ReqCreateClient req) {
public BaseResponse createClientByUser(ReqCreateClient req) {
return ResponseHelper.createBaseResponse(clientService.createClientByUser(req));
}

@Override
public BaseResponse editClient(ReqCreateClient req) {

return ResponseHelper.createBaseResponse(clientService.editClient(req));
}
}
2 changes: 2 additions & 0 deletions src/main/java/com/pos/app/service/ClientService.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ public interface ClientService {
ResponseEnum createClient(ReqCreateClient req);

ResponseEnum createClientByUser(ReqCreateClient req);

ResponseEnum editClient(ReqCreateClient req);
}
19 changes: 19 additions & 0 deletions src/main/java/com/pos/app/service/impl/ClientServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,23 @@ public ResponseEnum createClientByUser(ReqCreateClient req) {
throw new SystemErrorException(e);
}
}

@Override
public ResponseEnum editClient(ReqCreateClient req) {
String clientId = accountService.getCurrentClientIdOrNull();
Optional<Client> findClient = clientRepository.findById(clientId);
if (findClient.isEmpty()) {
throw new BadRequestException(ResponseEnum.CLIENT_NOT_FOUND.name());
}
Client client = findClient.get();
try {
client.setName(req.getName());
client.setLogo(req.getLogo());
client.setNote(req.getNote());
clientRepository.save(client);
return ResponseEnum.SUCCESS;
} catch (Exception e) {
throw new SystemErrorException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ public SnapPaymentResponse createPayment(ReqPaymentObject req) {

@Override
public ResponseEnum postNotificationFromMidTrans(ReqNotificationMidTrans req) {



Optional<SubscriptionOrder> findOrder = subscriptionOrderRepository.findById(req.getOrderId());
SubscriptionOrder subscriptionOrder = null;

Expand Down

0 comments on commit ec82dd6

Please sign in to comment.