Skip to content
This repository has been archived by the owner on Feb 4, 2025. It is now read-only.

Commit

Permalink
Merge pull request #247 from CampusDual/BFS42024-297
Browse files Browse the repository at this point in the history
297 estilo asistencias
  • Loading branch information
JoseMRLC authored Jan 15, 2025
2 parents 0462cb2 + d52cd1d commit eda758d
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ public interface IStudentBootcampService {
EntityResult studentBootcampUpdate(Map<String, Object> attrMap, Map<String, Object> keyMap) throws OntimizeJEERuntimeException;
AdvancedEntityResult studentsWithBootcampPaginationQuery(final Map<String, Object> keyMap, final List<?> attrList, final int recordNumber, final int startIndex, final List<?> orderBy) throws OntimizeJEERuntimeException;

EntityResult studentsWithComputableQuery(Map<String, Object> keysValues, List<String> attributes);

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
gap:20px;
}

.no-computable {
background-color: rgb(255, 108, 108);
color: white;
}


.calendar-timestamps-container {
display: flex;
flex-direction: row;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ <h1 mat-dialog-title class="center-select h1-spacing">{{'Registrar Asistencia' |
*ngFor="let student of students"
class="student_row days"
[ngStyle]="{'grid-template-columns': updateDayGridColumns()}"
[ngClass]="{'no-computable': !student.isComputable}"

>
<div>
{{ student.name }} {{ student.surname1 }} {{ student.surname2 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface Student {
start_date: Date;
end_date: Date;
status: string;

}

interface AttendanceStatus {
Expand Down Expand Up @@ -133,24 +134,31 @@ export class CalendarAttendanceComponent {
}
getStudents() {
if (this.service && this.bootcampId) {
const columns = ['student_id', 'name', 'surname1', 'surname2'];

const filter = {
'bootcamp_id': this.bootcampId
}
this.service.query(filter, columns, 'studentsWithBootcamp').subscribe(resp => {
if (resp.code === 0) {
if (resp.data.length > 0) {
this.students = resp.data;
} else {
this.students = [];
}
} else {
this.snackBarService.open('Error al cargar los datos de los estudiantes.');
}
});
const columns = ['student_id', 'name', 'surname1', 'surname2', 'computable'];
const filter = { 'bootcamp_id': this.bootcampId };

this.service.query(filter, columns, 'studentsWithComputable').subscribe(resp => {
if (resp.code === 0) {
if (resp.data.length > 0) {
console.log('Respuesta con computable:', resp.data);

this.students = resp.data.map((stu: any) => {
return {
...stu,
isComputable: stu.computable
};
});
} else {
this.students = [];
}
} else {
this.snackBarService.open('Error al cargar los datos de los estudiantes.');
}
});
}
}
}



loadAttendanceStatus(): void {
this.configureAttendanceStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ public class StudentBootcampDao extends OntimizeJdbcDaoSupport {
public static final String END_DATE = "end_date";
public static final String SB_START_DATE = "sb_start_date";
public static final String SB_END_DATE = "sb_end_date";
public static final String QUERY_STUDENTS_WITH_COMPUTABLE = "studentsWithComputable";


}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public class StudentBootcampService implements IStudentBootcampService {
@Autowired
private DefaultOntimizeDaoHelper daoHelper;

@Override
public EntityResult studentsWithComputableQuery(Map<String, Object> keysValues, List<String> attributes) {
return this.daoHelper.query(this.studentBootcampDao, keysValues, attributes, StudentBootcampDao.QUERY_STUDENTS_WITH_COMPUTABLE);
}

@Override
public EntityResult studentBootcampInsert(Map<String, Object> attrMap) throws OntimizeJEERuntimeException {

Expand All @@ -45,6 +50,8 @@ public EntityResult studentBootcampInsert(Map<String, Object> attrMap) throws On
}
}



@Override
public EntityResult studentsWithBootcampDelete(Map<String, Object> keyMap) throws OntimizeJEERuntimeException {
return this.daoHelper.delete(this.studentBootcampDao, keyMap);
Expand Down
48 changes: 48 additions & 0 deletions cd2024bfs4g1-model/src/main/resources/dao/StudentBootcampDao.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<AmbiguousColumn name="student_status" prefix="sbs" databaseName="student_bootcamp_status"/>
<AmbiguousColumn name="bootcampstatus" prefix="bs" databaseName="status"/>
<AmbiguousColumn name="userphotostudent" prefix="uu" databaseName="usr_photo"/>
<AmbiguousColumn name="computable" prefix="sbs" databaseName="computable"/>

</AmbiguousColumns>

<Sentence>
Expand All @@ -49,5 +51,51 @@
]]>
</Sentence>
</Query>
<Query id="studentsWithComputable">
<AmbiguousColumns>
<AmbiguousColumn name="id" prefix="sb"/>
<AmbiguousColumn name="name" prefix="s"/>
<AmbiguousColumn name="start_date" prefix="b"/>
<AmbiguousColumn name="end_date" prefix="b"/>
<AmbiguousColumn name="studentname" prefix="s" databaseName="name" />
<AmbiguousColumn name="bootcampname" prefix="b" databaseName="name" />
<AmbiguousColumn name="sb_start_date" prefix="sb" databaseName="start_date"/>
<AmbiguousColumn name="sb_end_date" prefix="sb" databaseName="end_date"/>
<AmbiguousColumn name="status" prefix="sb" />
<AmbiguousColumn name="student_status" prefix="sbs" databaseName="student_bootcamp_status"/>
<AmbiguousColumn name="bootcampstatus" prefix="bs" databaseName="status"/>
<AmbiguousColumn name="userphotostudent" prefix="uu" databaseName="usr_photo"/>
<AmbiguousColumn name="computable" prefix="sbs" databaseName="computable"/>
</AmbiguousColumns>
<Sentence>
<![CDATA[
select
#COLUMNS#
from
students s
inner join
student_bootcamp sb on s.id = sb.student_id
left join
student_bootcamp_status sbs on sb.status_id = sbs.id
inner join
bootcamps b on sb.bootcamp_id = b.id
left join
${mainschema}.usr_user uu ON s.user_id = uu.usr_id
inner join
bootcamp_status bs on b.id = bs.id
WHERE
sb.bootcamp_id = ?
GROUP BY
sb.bootcamp_id, sb.id, s.name, s.surname1, s.surname2, s.personal_email, sb.student_id, sb.status, sb.start_date, sb.end_date, sbs.computable
ORDER BY
sbs.computable desc,
s.name,s.surname1,s.surname2
]]>
</Sentence>
</Query>

</Queries>
</JdbcEntitySetup>
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
package com.campusdual.cd2024bfs4g1.ws.core.rest;

import com.campusdual.cd2024bfs4g1.api.core.service.IStudentBootcampService;
import com.campusdual.cd2024bfs4g1.model.core.service.StudentBootcampService;
import com.ontimize.jee.common.dto.EntityResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import com.ontimize.jee.server.rest.ORestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/studentbootcamp")
public class StudentBootcampController extends ORestController<IStudentBootcampService>{
Expand All @@ -20,4 +29,19 @@ public IStudentBootcampService getService() {
return this.studentBootcampSrv;
}

@Autowired
private IStudentBootcampService studentBootcampService;


@PostMapping("/with-computable")
public ResponseEntity<?> getStudentsWithComputable(@RequestBody Map<String, Object> filter) {
try {
List<String> columns = List.of("student_id", "name", "surname1", "surname2", "computable");
EntityResult result = studentBootcampService.studentsWithComputableQuery(filter, columns);
return ResponseEntity.ok(result);
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
}
}

}

0 comments on commit eda758d

Please sign in to comment.