因此,当我访问 enpoint(POST 请求)时,我首先检查数据库中是否已存在条目。如果是,我想将其返回给用户(用于跟踪目的)并继续操作。但我想将 id 返回给用户并继续此过程。如何实现这一目标?
@RestController
public class StudentController {
@Autowired
private StudentService service;
@PostMapping("/storeInDB")
@ResponseBody
public File_Tracking saveStudentDetails(@RequestBody Student student ) throws IOException {
List<Students> student = new ArrayList<>();
int continue = 0;
int id = 0;
id = service.getId(); // I want to return this and continue some other process which follows
Run Code Online (Sandbox Code Playgroud) 我有一个控制器类和一个服务类。控制器具有端点,服务层具有执行特定操作的功能(插入、加载文件和计算行数、更新等)。
现在我想知道的是,我应该将端点(控制器)作为整体还是服务层中存在的单个功能进行单元测试?我真的很困惑。请帮忙。