Skip to content

Commit

Permalink
更改一些API路徑,使其更直觀
Browse files Browse the repository at this point in the history
  • Loading branch information
GsTio86 committed Nov 12, 2024
1 parent 42a3e0c commit 6da2af9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public ResponseEntity<List<Order>> getAllOrders() {
}

@Operation(summary = "查詢訂單")
@GetMapping("/order/{id}")
@GetMapping("/info/{id}")
public ResponseEntity<Order> getOrder(@PathVariable("id") String id) {
return ResponseEntity.ok(orderService.getOrderByOrderId(id));
}

@Operation(summary = "更新訂單狀態")
@PostMapping("/order/{id}")
@PostMapping("/update/{id}")
public ResponseEntity<String> updateOrderStatus(@PathVariable("id") String id, @RequestBody Order.Status status) {
OrderService.ActionStatus action = orderService.updateOrderStatus(id, status);
if (action == OrderService.ActionStatus.UPDATE_SUCCESS) {
Expand All @@ -60,7 +60,7 @@ public ResponseEntity<String> updateOrderStatus(@PathVariable("id") String id, @
}

@Operation(summary = "刪除訂單")
@DeleteMapping("/order/{id}")
@DeleteMapping("/delete/{id}")
public ResponseEntity<String> deleteOrder(@PathVariable("id") String id) {
orderService.deleteOrder(id);
return ResponseEntity.ok("刪除成功");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public ResponseEntity<Payment> getPaymentByOrderId(@PathVariable("orderId") Stri
}

@Operation(summary = "查詢指定條件的付款資料")
@GetMapping(value = "/payments/search")
@GetMapping(value = "/search")
public ResponseEntity<List<Payment>> searchPayments(
@RequestParam(value = "paymentId", required = false) String paymentId,
@RequestParam(value = "orderId", required = false) String orderId,
Expand All @@ -80,7 +80,7 @@ public ResponseEntity<List<Payment>> searchPayments(
}

@Operation(summary = "更新付款資料狀態")
@PutMapping(value = "/payments/{id}")
@PutMapping(value = "/update/{id}")
public ResponseEntity<String> updatePaymentStatus(@PathVariable("id") String id, @RequestParam("status") Payment.Status status) {
try {
paymentService.updatePaymentStatus(id, status.getName());
Expand All @@ -91,7 +91,7 @@ public ResponseEntity<String> updatePaymentStatus(@PathVariable("id") String id,
}

@Operation(summary = "刪除付款資料")
@DeleteMapping(value = "/payments/{id}")
@DeleteMapping(value = "/delete/{id}")
public ResponseEntity<String> deletePayment(@PathVariable("id") String id) {
try {
paymentService.deletePayment(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public ResponseEntity<String> uploadImage(@PathVariable String id, @RequestPart
}

@Operation(summary = "獲取票券資料")
@GetMapping("/{id}")
@GetMapping("/info/{id}")
public ResponseEntity<Object> getTicketById(@PathVariable String id) {
Ticket ticket = ticketService.getByTicketId(id);
if (ticket == null) {
Expand All @@ -93,7 +93,7 @@ public ResponseEntity<Object> getAllTickets() {
}

@Operation(summary = "更新票券")
@PutMapping(value = "/{id}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@PutMapping(value = "/update/{id}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<String> updateTicket(@PathVariable String id, @RequestBody TicketDto ticketDto) {
TicketService.ActionStatus status = ticketService.updateTicket(ticketDto.convertToTicket(id));
if (status == TicketService.ActionStatus.UPDATE_FAILED) {
Expand All @@ -103,7 +103,7 @@ public ResponseEntity<String> updateTicket(@PathVariable String id, @RequestBody
}

@Operation(summary = "刪除票券")
@DeleteMapping("/{id}")
@DeleteMapping("/delete/{id}")
public ResponseEntity<String> deleteTicket(@PathVariable String id) {
TicketService.ActionStatus status = ticketService.deleteTicket(id);
if (status == TicketService.ActionStatus.DELETE_FAILED) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/me/gt/snaptickets/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class UserController {
private UserTicketService userTicketService;


@Value("${jwt.secret}")
@Value("${jwt.user.secret}")
private String jwtSecret;

@Operation(summary = "註冊帳號")
Expand Down Expand Up @@ -62,7 +62,7 @@ public ResponseEntity<Object> loginUser(@RequestParam String identifier, @Reques
return ResponseEntity.ok().body(Map.of("username", user.getUsername(), "token", token));
}

@Operation(summary = "透過帳號查詢資料")
@Operation(summary = "查詢帳號資料")
@GetMapping("/user/info/{username}")
public ResponseEntity<Object> getUserByUsername(@PathVariable String username) {
User user = userService.getByUsername(username);
Expand Down Expand Up @@ -91,7 +91,7 @@ public ResponseEntity<List<UserTicket>> getTicketByUsernameAndOrderId(@PathVaria
}

@Operation(summary = "更新帳號資訊")
@PutMapping("/user")
@PutMapping("/user/update")
public ResponseEntity<Object> updateUser(@RequestBody UserDto user) {
boolean success = userService.updateUser(user.convertToUser());
if (success) {
Expand All @@ -101,7 +101,7 @@ public ResponseEntity<Object> updateUser(@RequestBody UserDto user) {
}

@Operation(summary = "更改帳號密碼")
@PutMapping("/change-password/{username}")
@PutMapping("/user/change-password/{username}")
public ResponseEntity<String> updatePassword(@PathVariable String username, @RequestParam String oldPassword, @RequestParam String newPassword) {
String validationMessage = PasswordUtil.validatePassword(newPassword); // 驗證新密碼是否符合安全性要求
if (validationMessage != null) {
Expand All @@ -117,7 +117,7 @@ public ResponseEntity<String> updatePassword(@PathVariable String username, @Req
}

@Operation(summary = "刪除帳號")
@DeleteMapping("/user/{username}")
@DeleteMapping("/user/delete/{username}")
public ResponseEntity<String> deleteUser(@PathVariable String username) {
userService.deleteUser(username);
return ResponseEntity.ok("帳號已刪除");
Expand Down

0 comments on commit 6da2af9

Please sign in to comment.