Browse Source

cretarea-api works

master
esoe 7 months ago
parent
commit
8fd70633b9
  1. 1
      client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/ClientServiceTeachersApplication.java
  2. 1
      client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/controllers/TeachersController.java
  3. 65
      resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/controllers/ProgramCretareaController.java
  4. 2
      resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/controllers/TeacherController.java
  5. 44
      resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/entities/ProgramCretarea.java
  6. 14
      resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/repositories/ProgramCretareaRepositoryFace.java
  7. 1
      resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/repositories/TeachersRepositoryFace.java

1
client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/ClientServiceTeachersApplication.java

@ -9,5 +9,4 @@ public class ClientServiceTeachersApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(ClientServiceTeachersApplication.class, args); SpringApplication.run(ClientServiceTeachersApplication.class, args);
} }
} }

1
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.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated; 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.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;

65
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<List<ProgramCretarea>> 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<String> 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);
}
}

2
resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/controllers/TeacherController.java

@ -1,7 +1,6 @@
package ru.molokoin.resourceserviceapi.controllers; package ru.molokoin.resourceserviceapi.controllers;
import java.util.List; import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; 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.entities.Teacher;
import ru.molokoin.resourceserviceapi.repositories.TeachersRepositoryFace; import ru.molokoin.resourceserviceapi.repositories.TeachersRepositoryFace;
import org.springframework.web.bind.annotation.PostMapping; 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.RequestBody;
/** /**

44
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;
}
}

14
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<ProgramCretarea, Long>{
List<ProgramCretarea> findAll();
ProgramCretarea findCretareaById(long id);
}

1
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 java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.ListCrudRepository; import org.springframework.data.repository.ListCrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

Loading…
Cancel
Save