Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: student schema changes #41

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@
"jwt-decode": "^3.1.2",
"moment": "^2.29.3",
"multer": "^1.4.4",
"mysql2": "^2.3.3",
"node-cron": "^3.0.1",
"node-schedule": "^2.1.0",
"object-resolve-path": "^1.1.1",
"pg": "^8.7.3",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0",
"swagger-ui-express": "^4.3.0",
"templates.js": "^0.3.11"
"templates.js": "^0.3.11",
"typeorm": "^0.3.6"
},
"devDependencies": {
"@nestjs/cli": "^8.0.0",
Expand Down
95 changes: 95 additions & 0 deletions src/adapters/postgres/attendance.postgres.adapter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { Injectable } from "@nestjs/common";
import { HttpService } from "@nestjs/axios";
import { AttendanceDto } from "src/attendance/dto/attendance.dto";
import { SuccessResponse } from "src/success-response";
import { AttendanceSearchDto } from "src/attendance/dto/attendance-search.dto";
import { Client } from "pg";
@Injectable()
export class AttendanceService {
constructor(private httpService: HttpService) {}
url = `${process.env.BASEAPIURL}/Attendance`;
studentAPIUrl = `${process.env.BASEAPIURL}/Student`;

public async getAttendance(attendanceId: string) {
const client = new Client();
client.connect();
client.query(
`SELECT * FROM attendance WHERE id = '${attendanceId}'`,
(err, res) => {
if (err) {
console.log(err);
} else {
console.log(res.rows);
}
}
);
client.end();
return new SuccessResponse({
statusCode: 200,
message: "Ok.",
data: [],
});
}

public async createAttendance(attendanceDto: AttendanceDto) {
const client = new Client();
client.connect();
client.query(
`INSERT INTO attendance (attendanceRecordId, studentId, attendance, date) VALUES ('${attendanceDto.attendanceId}', '${attendanceDto.userId}', '${attendanceDto.attendanceDate}', '${attendanceDto.attendance}')`,
(err, res) => {
if (err) {
console.log(err);
} else {
console.log(res.rows);
}
}
);
client.end();
}

public async updateAttendance(
attendanceId: string,
attendanceDto: AttendanceDto
) {
const client = new Client();
client.connect();
client.query(
`UPDATE attendance SET attendance = '${attendanceDto.attendance}' WHERE id = '${attendanceId}'`,
(err) => {
if (err) {
console.log(err);
}
}
);
client.end();
return new SuccessResponse({
statusCode: 200,
message: "Ok.",
data: [],
});
}

public async searchAttendance(
request: any,
attendanceSearchDto: AttendanceSearchDto
) {
const client = new Client();
client.connect();
client.query(
`SELECT * FROM attendance WHERE attendanceDate >= '${attendanceSearchDto.attendanceFromDate}' AND attendanceDate <= '${attendanceSearchDto.attendanceToDate} AND studentId = '${attendanceSearchDto.studentId}'`,
(err, res) => {
if (err) {
console.log(err);
} else {
console.log(res.rows);
}
}
);
client.end();
return new SuccessResponse({
statusCode: 200,
message: "Ok.",
data: [],
});
}
}
15 changes: 15 additions & 0 deletions src/adapters/postgres/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
config = {
user?: string, // default process.env.PGUSER || process.env.USER
password?: string or function, //default process.env.PGPASSWORD
host?: string, // default process.env.PGHOST
database?: string, // default process.env.PGDATABASE || user
port?: number, // default process.env.PGPORT
connectionString?: string, // e.g. postgres://user:password@host:5432/database
ssl?: any, // passed directly to node.TLSSocket, supports all tls.connect options
types?: any, // custom type parsers
statement_timeout?: number, // number of milliseconds before a statement in query will time out, default is no timeout
query_timeout?: number, // number of milliseconds before a query call will timeout, default is no timeout
application_name?: string, // The name of the application that created this Client instance
connectionTimeoutMillis?: number, // number of milliseconds to wait for connection, default is no timeout
idle_in_transaction_session_timeout?: number // number of milliseconds before terminating any session with an open idle transaction, default is no timeout
}
8 changes: 4 additions & 4 deletions src/attendance/attendance.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AttendanceController } from './attendance.controller';
import { Test, TestingModule } from "@nestjs/testing";
import { AttendanceController } from "./attendance.controller";

describe('AttendanceController', () => {
describe("AttendanceController", () => {
let controller: AttendanceController;

beforeEach(async () => {
Expand All @@ -12,7 +12,7 @@ describe('AttendanceController', () => {
controller = module.get<AttendanceController>(AttendanceController);
});

it('should be defined', () => {
it("should be defined", () => {
expect(controller).toBeDefined();
});
});
18 changes: 9 additions & 9 deletions src/attendance/dto/attendance-response.dto.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export interface AttendanceResponseDto {
attendanceId: string
attendance: string
date: string
subjectId: string
studentId: string
classId: string
teacherId: string
attendanceNote: string
}
attendanceId: string;
attendance: string;
date: string;
subjectId: string;
studentId: string;
classId: string;
teacherId: string;
attendanceNote: string;
}
30 changes: 30 additions & 0 deletions src/attendance/dto/attendance-search.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,36 @@ export class AttendanceSearchDto {
})
limit: string;

@ApiProperty({
shikharvashistha marked this conversation as resolved.
Show resolved Hide resolved
type: String,
description: "Student Id",
})
studentId: string;

@ApiProperty({
type: String,
description: "attendanceRecordId",
})
attendanceRecordId: string;

@ApiProperty({
type: Date,
description: "attendanceToDate",
})
attendanceToDate: Date;

@ApiProperty({
type: Date,
description: "attendanceFromDate",
})
attendanceFromDate: Date;

@ApiProperty({
type: String,
description: "attendance",
})
attendance: string;

@ApiProperty({
type: Object,
description: "Filters",
Expand Down
19 changes: 9 additions & 10 deletions src/attendance/interfaces/attendance.interface.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
export interface AttendanceInterface {
attendanceId?: string
attendance?: string
date?: string
subjectId?: string
studentId?: string
classId?: string
teacherId?: string
attendanceNote?: string

}
attendanceId?: string;
attendance?: string;
date?: string;
subjectId?: string;
studentId?: string;
classId?: string;
teacherId?: string;
attendanceNote?: string;
}
18 changes: 8 additions & 10 deletions src/error-response.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { Expose } from "class-transformer";

export class ErrorResponse {
@Expose()
errorCode: string;

@Expose()
errorCode: string
@Expose()
errorMessage: string;

@Expose()
errorMessage : string


constructor(partial: Partial<ErrorResponse>) {
Object.assign(this, partial);
}
}
constructor(partial: Partial<ErrorResponse>) {
Object.assign(this, partial);
}
}
10 changes: 5 additions & 5 deletions src/group/dto/group-response.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface GroupResponseDto {
groupId: string
name: string
type: string
status: string
}
groupId: string;
name: string;
type: string;
status: string;
}
10 changes: 5 additions & 5 deletions src/group/interfaces/group.interface.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface GroupInterface {
groupId?: string
name?: string
type?: string
status?: string
}
groupId?: string;
name?: string;
type?: string;
status?: string;
}
40 changes: 20 additions & 20 deletions src/interfaces/entities/IStudent.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
interface IStudent {
studentId: string
refId: string
aadhaar: string
firstName: string
lastName: string
schoolId: string
currentClassId: string
gender: string
socialCategory: string
iscwsn: string
religion: string
singleGirl: string
weight: string
height: string
bloodGroup: string
birthDate: string
homeless: string
bpl: string
migrant: string
status: string
studentId: string;
refId: string;
aadhaar: string;
firstName: string;
lastName: string;
schoolId: string;
currentClassId: string;
gender: string;
socialCategory: string;
iscwsn: string;
religion: string;
singleGirl: string;
weight: string;
height: string;
bloodGroup: string;
birthDate: string;
homeless: string;
bpl: string;
migrant: string;
status: string;
}
28 changes: 14 additions & 14 deletions src/school/dto/school-response.dto.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export interface SchoolResponseDto {
schoolId: string
schoolName: string
email: string
schoolRefId: string
instituteManagement: string
address: string
schoolType: string
website: string
street: string
city:string
district: string
state: string
pincode: string
}
schoolId: string;
schoolName: string;
email: string;
schoolRefId: string;
instituteManagement: string;
address: string;
schoolType: string;
website: string;
street: string;
city: string;
district: string;
state: string;
pincode: string;
}
28 changes: 14 additions & 14 deletions src/school/interfaces/school.interface.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export interface SchoolInterface {
schoolId?: string
schoolName?: string
email?: string
schoolRefId?: string
instituteManagement?: string
address?: string
schoolType?: string
website?: string
street?: string
city?:string
district?: string
state?: string
pincode?: string
}
schoolId?: string;
schoolName?: string;
email?: string;
schoolRefId?: string;
instituteManagement?: string;
address?: string;
schoolType?: string;
website?: string;
street?: string;
city?: string;
district?: string;
state?: string;
pincode?: string;
}
Loading