/
The_Emperor
/
SberProject
Обзор
Документация
Войти
/
The_Emperor
/
SberProject
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
src/main/java/com/example/controller/ClientController.java
69 строк
3 KB
Leks
init
25 июн 2025, 12:34
25 июн 2025, 12:34
ca16b29
Код
Авторство
О чём код?
package com.example.controller; import com.example.dto.ClientDto; import com.example.dto.CreateResearchResponse; import com.example.dto.CreateResponse; import com.example.dto.ResearchDto; import com.example.entity.Research; import com.example.service.ClientService; import com.example.service.ResearchService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController @RequestMapping(value = "/sber", produces = MediaType.APPLICATION_JSON_VALUE) public class ClientController { @Autowired private ClientService service; @Autowired private ResearchService researchService; // @PostMapping(value = "/create", produces = MediaType.APPLICATION_JSON_VALUE) // public @ResponseBody CreateResponse createClient(@RequestBody ClientDto dto) { // Long id = service.getIdByNickName(dto.getName()); // CreateResponse response = new CreateResponse(); // if(service.getIdByNickName(dto.getName()) == -1L) { // service.createClient(dto.getName()); // response.setClientNickName(dto.getName()); // } else { // response.setClientId(id); // } // return response; // } // // @GetMapping(value = "/getByNick/{nickName}", produces = MediaType.APPLICATION_JSON_VALUE) // public @ResponseBody CreateResponse getClient(@PathVariable String nickName) { // CreateResponse response = new CreateResponse(); // response.setClientId(service.getIdByNickName(nickName)); // return response; // } // // @GetMapping(value = "/getById/{id}", produces = MediaType.APPLICATION_JSON_VALUE) // public @ResponseBody CreateResponse getClient(@PathVariable Long id) { // CreateResponse response = new CreateResponse(); // response.setClientNickName(service.getNickNameById(id)); // return response; // } @PostMapping(value = "/createResearch", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Research createResearch(@RequestBody ResearchDto dto) { return researchService.createResearch(dto); } @GetMapping(value = "/getByNick/{nickName}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List<Research> findAllByNickName(@PathVariable String nickName) { // CreateResponse response = new CreateResponse(); return researchService.findAllByNickName(nickName); } }