Skip to content

Commit

Permalink
Merge pull request #23 from EmTanIT/khoaBE
Browse files Browse the repository at this point in the history
router: examRoom, timeSLot
  • Loading branch information
bentran1vn committed Oct 4, 2023
2 parents 94b5885 + fb366df commit b2d2c35
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions models/ExamRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ const ExamRoom = sequelize.define(tableName, {
},
roomId: {
type: DataTypes.INTEGER,
allowNull: false,
allowNull: true,
references: {
model: Room,
key: 'id'
}
},
lecturerId: {
type: DataTypes.INTEGER,
allowNull: false,
allowNull: true,
references: {
model: Lecturer,
key: 'id'
Expand Down
22 changes: 11 additions & 11 deletions routes/examSlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import fs from 'fs'

const router = express.Router()

router.post('/create', async (req, res) => {
router.post('/', async (req, res) => {
const ePId = parseInt(req.body.ePId);
const timeSlotId = parseInt(req.body.timeSlotId);
const day = req.body.day;
Expand Down Expand Up @@ -106,28 +106,28 @@ router.get('/', async (req, res) => {
let dayCount = 0
let slotCount = 0



for (let i = 0; i < course.length; i++) {
let daySlot = dayList[dayCount]
let slot = slotList[slotCount].id
if (roomSlot > process.env.NUMBER_OF_ROOM_IN_FLOOR * process.env.NUMBER_OF_ROOM_IN_FLOOR){

if (roomSlot > process.env.NUMBER_OF_ROOM_IN_FLOOR * process.env.NUMBER_OF_ROOM_IN_FLOOR) {
roomSlot = 0
slotCount++;
if(slotCount > process.env.NUMBER_OF_SLOT - 1){

if (slotCount > process.env.NUMBER_OF_SLOT - 1) {
slotCount = 0
dayCount++;
}
}


const val = course[i];
let roomCourse = Math.ceil(val.numOfStu / process.env.NUMBER_OF_STUDENT_IN_ROOM)
fs.appendFileSync("test.txt", roomCourse + "\n");
roomSlot += roomCourse
if(roomSlot <= process.env.NUMBER_OF_STUDENT_IN_ROOM* process.env.NUMBER_OF_ROOM_IN_FLOOR){
if (roomSlot <= process.env.NUMBER_OF_STUDENT_IN_ROOM * process.env.NUMBER_OF_ROOM_IN_FLOOR) {
for (let i = 0; i < roomCourse; i++) {
let data = val.id + ".." + daySlot.getDate() + ".." + slot
fs.appendFileSync("test.txt", data + "\n");
Expand All @@ -136,9 +136,9 @@ router.get('/', async (req, res) => {
} else {
i--
}

}

}
res.json('hihi')
})
Expand Down
12 changes: 6 additions & 6 deletions routes/timeSlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,26 @@ router.get('/getAll', async (req, res) => {
//get All timeSlot
try {
const timeSlots = await TimeSlot.findAll();
if(!timeSlots){
if (!timeSlots) {
res.json(NotFoundResponse());
}else{
} else {
res.json(DataResponse(timeSlots));
}
} catch (error) {
console.log(error);
res.json(InternalErrResponse());
}
}
})

router.get('/getMultipleId', async (req,res) => {
router.get('/getMultipleId', async (req, res) => {
//tìm theo id khi người dùng nhập dạng "id" = "1,2,3,4,5,6,7"
const id = req.body.id.split(',');
console.log(id);
try {
const timeSlots = await TimeSlot.findAll({
where: {
id: {
[Op.or] : id
[Op.or]: id
}
}
}
Expand Down Expand Up @@ -127,7 +127,7 @@ router.delete('/deleteAll', async (req, res) => {
})


router.put('/update', async (req, res) => {
router.put('/', async (req, res) => {
//update time slot theo id
const id = parseInt(req.body.id)
const timeSlotData = req.body;
Expand Down

0 comments on commit b2d2c35

Please sign in to comment.