plan.controller.js 1.45 KB
Newer Older
Choi Ga Young's avatar
Choi Ga Young committed
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { Plan } from "../db/index.js";

const addPlan = async (req, res) => {
  console.log('server/addPlan req.body', req.body)
  try {
    let end = null;
    let tf = false;
    const { info } = req.body
    const { studyplanTitle, endDate, endTime, deadline, memo, selected } = info
    console.log('제목확인', studyplanTitle)
    if (deadline === "on") {
      end = new Date(endDate + " " + endTime)
      tf = true
    } else {
      end = new Date(endDate)
    }
    const result = await Plan.create({
      subjectId: selected,
      title: studyplanTitle,
      deadline: end,
      memo: memo,
      timeChecked: tf,
      checked: false
    })
    return res.json(result)
  } catch (error) {
    console.log(error)
    return res.status(500).send(error.message || "계획저장 에러발생")
  }
}

const editPlan = async (req, res) => {
  console.log('server/editPlan req.body', req.body)
  try {

  } catch (error) {
    console.log(error)
    return res.status(500).send(error.message || "계획수정 에러발생")
  }
}

const getInfo = async (req, res) => {
  console.log('server/getInfo req.params', req.params)
  try {
    const { planId } = req.params;
    const findInfo = await Plan.findOne({ where: { id: planId } })
    console.log('findInfo확인', findInfo.dataValues)
  } catch (error) {
    console.log(error)
    return res.status(500).send(error.message || "계획 가져오기 에러발생")
  }
}

export default {
  addPlan,
  editPlan,
  getInfo
}