-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserCompanyStatusController.java
More file actions
32 lines (25 loc) · 1.25 KB
/
UserCompanyStatusController.java
File metadata and controls
32 lines (25 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.example.spring.app.userCompanyStatus;
import com.example.spring.app.company.enums.Status;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import static com.example.spring.common.utils.JwtUtil.extractUserIdFromToken;
@RestController
@RequestMapping("/v1/companies-status")
public class UserCompanyStatusController {
@Autowired
private UserCompanyStatusService userCompanyStatusService;
@PostMapping("/update-status")
public ResponseEntity<UserCompanyStatusModel> updateStatus(@RequestParam Integer companyId,
@RequestParam Status status) {
String userId = extractUserIdFromToken();
UserCompanyStatusModel updated = userCompanyStatusService.updateCompanyStatus(userId, companyId, status);
if (updated == null) {
return ResponseEntity.noContent().build(); // deleted or no-op
}
return ResponseEntity.ok(updated);
}
}