Ого, вау сделал отчет
This commit is contained in:
parent
58280603ce
commit
a47d810d48
BIN
data.mv.db
BIN
data.mv.db
Binary file not shown.
@ -2,6 +2,7 @@
|
|||||||
<div class="container mt-4">
|
<div class="container mt-4">
|
||||||
<h1 class="text-center mb-4">Group Table</h1>
|
<h1 class="text-center mb-4">Group Table</h1>
|
||||||
<button class="btn btn-primary mr-2" @click="openModal('create')">Добавить</button>
|
<button class="btn btn-primary mr-2" @click="openModal('create')">Добавить</button>
|
||||||
|
<button class="btn btn-primary mr-2" @click="openReport()">Отчет</button>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -36,6 +37,41 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<!--Форма для отчета -->
|
||||||
|
<div class="modal" tabindex="-1" id="openReport">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Отчет</h5>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Группа</th>
|
||||||
|
<th>Студенты</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="[key, value] in Object.entries(getAllInfo)" :key="key">
|
||||||
|
<td>{{ key }}</td>
|
||||||
|
<td>
|
||||||
|
<ul>
|
||||||
|
<li v-for="book in value" :key="book">{{ book }}</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="editModal" @click="closeReport()">Закрыть</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<!--Форма для привязки предмета и групп -->
|
<!--Форма для привязки предмета и групп -->
|
||||||
<div class="modal" tabindex="-1" id="openModalForAddSubjects">
|
<div class="modal" tabindex="-1" id="openModalForAddSubjects">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
@ -206,6 +242,7 @@ export default {
|
|||||||
created() {
|
created() {
|
||||||
this.getGroups();
|
this.getGroups();
|
||||||
this.getSubjects();
|
this.getSubjects();
|
||||||
|
this.getAll();
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return{
|
return{
|
||||||
@ -219,9 +256,20 @@ export default {
|
|||||||
groupId: undefined,
|
groupId: undefined,
|
||||||
selectedSubjects: [],
|
selectedSubjects: [],
|
||||||
subjectsInGroup: [],
|
subjectsInGroup: [],
|
||||||
|
getAllInfo: new Object() ,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
getAll(){
|
||||||
|
axios.get(this.URL + "group/getAll")
|
||||||
|
.then(response => {
|
||||||
|
this.getAllInfo = response.data;
|
||||||
|
console.log(response.data);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
getSubjectsInGroup(id){
|
getSubjectsInGroup(id){
|
||||||
axios.get(this.URL + `group/${id}/getAllSubjects`)
|
axios.get(this.URL + `group/${id}/getAllSubjects`)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
@ -314,6 +362,12 @@ export default {
|
|||||||
CloseModalForAddStudents() {
|
CloseModalForAddStudents() {
|
||||||
document.getElementById("ModalForAddStudents").style.display = "none";
|
document.getElementById("ModalForAddStudents").style.display = "none";
|
||||||
},
|
},
|
||||||
|
openReport() {
|
||||||
|
document.getElementById("openReport").style.display = "block";
|
||||||
|
},
|
||||||
|
closeReport() {
|
||||||
|
document.getElementById("openReport").style.display = "none";
|
||||||
|
},
|
||||||
saveStudents(id) {
|
saveStudents(id) {
|
||||||
axios.post(this.URL + `group/${id}/addStudents`, this.selectedStudents)
|
axios.post(this.URL + `group/${id}/addStudents`, this.selectedStudents)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -10,6 +10,7 @@ import ru.IP_LabWorks.IP.University.Model.Subject;
|
|||||||
import ru.IP_LabWorks.IP.University.Service.GroupService;
|
import ru.IP_LabWorks.IP.University.Service.GroupService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/group")
|
@RequestMapping("/group")
|
||||||
@ -79,11 +80,8 @@ public class GroupController {
|
|||||||
public void addSubjectToGroup(@PathVariable Long id, @RequestBody @Valid List<Long> subjectIds){
|
public void addSubjectToGroup(@PathVariable Long id, @RequestBody @Valid List<Long> subjectIds){
|
||||||
groupService.addSubjectToGroup(id, subjectIds);
|
groupService.addSubjectToGroup(id, subjectIds);
|
||||||
}
|
}
|
||||||
|
@GetMapping("/getAll")
|
||||||
|
public Map<String, List<String>> getAll(){
|
||||||
// @PostMapping("/{id}/student")
|
return groupService.getAll();
|
||||||
// public StudentDTO setStudentToGroup(@PathVariable Long id,
|
}
|
||||||
// @RequestParam("studentId") Long studentId) {
|
|
||||||
// return new StudentDTO(groupService.addStudentToGroup(id, studentId));
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
package ru.IP_LabWorks.IP.University.Repository;
|
package ru.IP_LabWorks.IP.University.Repository;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import ru.IP_LabWorks.IP.University.Model.Group;
|
import ru.IP_LabWorks.IP.University.Model.Group;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface GroupRepository extends JpaRepository<Group, Long> {
|
public interface GroupRepository extends JpaRepository<Group, Long> {
|
||||||
|
@Query("select g.name as group, s.name as students " +
|
||||||
|
"from Group g " +
|
||||||
|
"join g.students s " +
|
||||||
|
"group by g.id, g.name, s.name")
|
||||||
|
List<Object[]> getAll();
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,9 @@ import ru.IP_LabWorks.IP.University.Service.NotFoundException.GroupNotFoundExcep
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class GroupService {
|
public class GroupService {
|
||||||
@ -126,30 +128,14 @@ public class GroupService {
|
|||||||
groupRepository.save(currentGroup);
|
groupRepository.save(currentGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @Transactional
|
@Transactional
|
||||||
public Group addStudentToGroup(Long groupId, Long studentId) {
|
public Map<String, List<String>> getAll(){
|
||||||
Group group = findGroup(groupId);
|
return groupRepository.getAll().stream()
|
||||||
Student student = studentService.findStudent(studentId);
|
.collect(
|
||||||
if (group == null || student == null) {
|
Collectors.groupingBy(
|
||||||
throw new EntityNotFoundException("Group or Student not found");
|
o -> (String) o[0],
|
||||||
}
|
Collectors.mapping( o -> (String) o[1], Collectors.toList() )
|
||||||
group.setStudent(student);
|
)
|
||||||
return group;
|
);
|
||||||
}*/
|
}
|
||||||
//
|
|
||||||
// @Transactional
|
|
||||||
// public void removeStudentFromGroup(Long groupId, Long studentId) {
|
|
||||||
// Group group = findGroup(groupId);
|
|
||||||
// Student student = em.find(Student.class, studentId);
|
|
||||||
// group.getStudents().remove(student);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Transactional(readOnly = true)
|
|
||||||
// public List<Student> findStudentsInGroup(Long groupId) {
|
|
||||||
// Group group = findGroup(groupId);
|
|
||||||
// if (group == null) {
|
|
||||||
// throw new EntityNotFoundException("Group not found");
|
|
||||||
// }
|
|
||||||
// return group.getStudents();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user