/**
 * 请假
 */

import * as asyncHandler from 'express-async-handler';
import * as askForLeaveBiz from '../biz/askForLeave';
import { checkFuHuaQiToken } from '../middleware/user';

export function setRouter(httpServer) {
    httpServer.post('/askforleave/add', checkFuHuaQiToken, asyncHandler(add));
    httpServer.post('/askforleave/list', checkFuHuaQiToken, asyncHandler(list));
}

async function add(req, res) {
    let userId = req.headers.userid;
    let { day, time, des, startTime, endTime, type} = req.body;
    let result = await askForLeaveBiz.askForLeave(userId, des, startTime, endTime, type, time, day);
    res.success(result);
}


async function list(req, res) {
    let userId = req.headers.userid;
   
    let result = await askForLeaveBiz.myAskForLeaveList(userId);
    res.success(result);
}