diff --git a/client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/ClientServiceTeachersApplication.java b/client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/ClientServiceTeachersApplication.java index 5af4106..fdd1cce 100644 --- a/client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/ClientServiceTeachersApplication.java +++ b/client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/ClientServiceTeachersApplication.java @@ -9,5 +9,4 @@ public class ClientServiceTeachersApplication { public static void main(String[] args) { SpringApplication.run(ClientServiceTeachersApplication.class, args); } - } diff --git a/client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/controllers/TeachersController.java b/client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/controllers/TeachersController.java index b10b958..cfbce8c 100644 --- a/client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/controllers/TeachersController.java +++ b/client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/controllers/TeachersController.java @@ -10,7 +10,6 @@ import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; diff --git a/resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/controllers/ProgramCretareaController.java b/resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/controllers/ProgramCretareaController.java new file mode 100644 index 0000000..1384336 --- /dev/null +++ b/resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/controllers/ProgramCretareaController.java @@ -0,0 +1,65 @@ +package ru.molokoin.resourceserviceapi.controllers; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import ru.molokoin.resourceserviceapi.entities.ProgramCretarea; +import ru.molokoin.resourceserviceapi.repositories.ProgramCretareaRepositoryFace; + +@RestController +@RequestMapping(path = "/", consumes = {"*/*"}) +public class ProgramCretareaController { + @Autowired + private ProgramCretareaRepositoryFace repo; + + @GetMapping("/cretarea/list") + public ResponseEntity> getTeachers(){ + return new ResponseEntity<>(repo.findAll(), HttpStatus.OK); + } + + @GetMapping("/cretarea/{id}") + public ResponseEntity getTeacherByID(@PathVariable Integer id){ + return new ResponseEntity<>(repo.findCretareaById(id), HttpStatus.OK); + } + + @PostMapping(path = "/cretarea/create", + consumes = MediaType.APPLICATION_JSON_VALUE, + produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity saveTeacher(@RequestBody ProgramCretarea cretarea) { + repo.save(cretarea); + return new ResponseEntity<>(cretarea, HttpStatus.CREATED); + } + + @PutMapping(path = "/cretarea/update/{id}", + consumes = MediaType.APPLICATION_JSON_VALUE, + produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity updateCretarea(@PathVariable Integer id, @RequestBody ProgramCretarea cretarea) { + ProgramCretarea pc = repo.findCretareaById(id); + pc.setName(cretarea.getName()); + pc.setName_short(cretarea.getName_short()); + repo.save(pc); + return new ResponseEntity<>(repo.findCretareaById(id), HttpStatus.CREATED); + } + + @DeleteMapping("/cretarea/delete/{id}") + public ResponseEntity deleteCretarea(@PathVariable Long id){ + ProgramCretarea pc = repo.findCretareaById(id); + System.out.println(pc.toString()); + repo.delete(pc); + return new ResponseEntity<>("Запись id#" + id + " удалена ... ", HttpStatus.NOT_FOUND); + } + + +} diff --git a/resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/controllers/TeacherController.java b/resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/controllers/TeacherController.java index df58d2a..b0e7a90 100644 --- a/resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/controllers/TeacherController.java +++ b/resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/controllers/TeacherController.java @@ -1,7 +1,6 @@ package ru.molokoin.resourceserviceapi.controllers; import java.util.List; -import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -16,7 +15,6 @@ import org.springframework.web.bind.annotation.RestController; import ru.molokoin.resourceserviceapi.entities.Teacher; import ru.molokoin.resourceserviceapi.repositories.TeachersRepositoryFace; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; /** diff --git a/resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/entities/ProgramCretarea.java b/resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/entities/ProgramCretarea.java new file mode 100644 index 0000000..b06addc --- /dev/null +++ b/resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/entities/ProgramCretarea.java @@ -0,0 +1,44 @@ +package ru.molokoin.resourceserviceapi.entities; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Сущность критериев программы обучения: + * - от + * - в + * - стр + * - птм + * - итд ... + * + * Одному критерию может соответствовать группа программ обучения. + */ +@NoArgsConstructor +@AllArgsConstructor +@Entity +@Data +public class ProgramCretarea { + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + private long id; + // @Column(length=500) + private String name;//Наименование + // @Column(length=5) + private String name_short;//Наименование : сокращенно + + /** + * подготовить конструкторы на все варианты внесения информации о преподавателях + * + * @param name + * @param name_short + */ + public ProgramCretarea(String name, String name_short) { + this.name = name; + this.name_short = name_short; + } +} diff --git a/resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/repositories/ProgramCretareaRepositoryFace.java b/resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/repositories/ProgramCretareaRepositoryFace.java new file mode 100644 index 0000000..5e80f6b --- /dev/null +++ b/resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/repositories/ProgramCretareaRepositoryFace.java @@ -0,0 +1,14 @@ +package ru.molokoin.resourceserviceapi.repositories; + +import java.util.List; + +import org.springframework.data.repository.ListCrudRepository; +import org.springframework.stereotype.Repository; + +import ru.molokoin.resourceserviceapi.entities.ProgramCretarea; + +@Repository +public interface ProgramCretareaRepositoryFace extends ListCrudRepository{ + List findAll(); + ProgramCretarea findCretareaById(long id); +} diff --git a/resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/repositories/TeachersRepositoryFace.java b/resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/repositories/TeachersRepositoryFace.java index 2992fe7..8917329 100644 --- a/resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/repositories/TeachersRepositoryFace.java +++ b/resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/repositories/TeachersRepositoryFace.java @@ -2,7 +2,6 @@ package ru.molokoin.resourceserviceapi.repositories; import java.util.List; -import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.repository.ListCrudRepository; import org.springframework.stereotype.Repository;