subject.controller.js 629 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Subject } from '../db/index.js';

const addsubject = async (req, res) => {
  console.log('server/addsubject req.body', req.body)
  const { lectureName, prof, classRoom } = req.body;
  try {
    const findName = await Subject.findOne({ where: { name: lectureName } });
    if (findName) {
      throw new Error("이미 있는 과목입니다.")
    }
    await Subject.create({
      name: lectureName,
      prof: prof,
      room: classRoom,
      
    })

  } catch (error) {
    console.log(error)
    return res.status(500).send(error.message || "과목저장 에러발생")
  }



}

export default {
  addsubject
}