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
}