package com.ankaibei.workFlow.webadmin.ankaibei.controller;

import com.ankaibei.workFlow.common.core.object.TokenData;
import com.ankaibei.workFlow.webadmin.ankaibei.service.ApplyForCostService;
import com.ankaibei.workFlow.webadmin.ankaibei.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author lwq
 * @version 1.0
 * @description: 费用申请
 * @date 2022/9/26 16:14
 */
@RestController
@RequestMapping("/apply")
public class ApplyForCostController {

    @Autowired
    private ApplyForCostService applyForCostService;

    /**
     * 申请通讯费
     *
     * @param communicationInfoVo
     * @return ResMsg
     */
    @RequestMapping("/addCommunication")
    public ResMsg addCommunication(@RequestBody CommunicationInfoVo communicationInfoVo) {
        Long userId = TokenData.takeFromRequest().getUserId();
        communicationInfoVo.setCreateUser(String.valueOf(userId));
        return applyForCostService.addCommunication(communicationInfoVo);
    }

    /**
     * 申请采购费
     *
     * @param purchaseInfoVo
     * @return ResMsg
     */
    @RequestMapping("/addpurchase")
    public ResMsg addpurchase(@RequestBody PurchaseInfoVo purchaseInfoVo) {
        Long userId = TokenData.takeFromRequest().getUserId();
        purchaseInfoVo.setCreateUser(String.valueOf(userId));
        return applyForCostService.addpurchase(purchaseInfoVo);
    }

    /**
     * 申请其他费用
     *
     * @param restsInfoVo
     * @return ResMsg
     */
    @RequestMapping("/addRest")
    public ResMsg addRest(@RequestBody RestsInfoVo restsInfoVo) {
        Long userId = TokenData.takeFromRequest().getUserId();
        restsInfoVo.setCreateUser(String.valueOf(userId));
        return applyForCostService.addRest(restsInfoVo);
    }

    /**
     * 申请交通费用
     *
     * @param trafficExpenseVo
     * @return ResMsg
     */
    @RequestMapping("/trafficExpenseApply")
    public ResMsg trafficExpenseApply(@RequestBody TrafficExpenseVo trafficExpenseVo, HttpServletRequest request) {
        Long userId = TokenData.takeFromRequest().getUserId();
        trafficExpenseVo.setApplicant(String.valueOf(userId));
        return applyForCostService.trafficExpenseApply(trafficExpenseVo);
    }

    /**
     * 申请餐饮费用
     *
     * @param RepastExpenseVo
     * @return ResMsg
     */
    @RequestMapping("/repastExpenseApply")
    public ResMsg repastExpenseApply(@RequestBody RepastExpenseVo RepastExpenseVo, HttpServletRequest request) {
        Long userId = TokenData.takeFromRequest().getUserId();
        RepastExpenseVo.setApplicant(String.valueOf(userId));
        return applyForCostService.repastExpenseApply(RepastExpenseVo);
    }

    /**
     * 申请差旅费用
     *
     * @param travelExpenseVo
     * @return ResMsg
     */
    @RequestMapping("/travelExpenseApply")
    public ResMsg travelExpenseApply(@RequestBody TravelExpenseVo travelExpenseVo, HttpServletRequest request) {
        Long userId = TokenData.takeFromRequest().getUserId();
        travelExpenseVo.setApplicant(String.valueOf(userId));
        return applyForCostService.travelExpenseApply(travelExpenseVo);
    }

}
