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

import com.ankaibei.workFlow.common.core.object.TokenData;
import com.ankaibei.workFlow.webadmin.ankaibei.api.ManHourInfoApi;
import com.ankaibei.workFlow.webadmin.ankaibei.enums.CodeEnum;
import com.ankaibei.workFlow.webadmin.ankaibei.vo.ManHourInfoVo;
import com.ankaibei.workFlow.webadmin.ankaibei.vo.ResMsg;
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.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author lwq
 * @version 1.0
 * @description: 工时管理
 * @date 2022/9/21 15:28
 */
@RestController
@RequestMapping("/manHour")
public class ManHourController {

    @Autowired
    private ManHourInfoApi manHourInfoApi;

    /**
     * 查询所有工时列表
     */
    @RequestMapping("/findManHourAll")
    public ResMsg findManHourAll(@RequestBody ManHourInfoVo manHourInfoVo) {

        return manHourInfoApi.findManHourAll(manHourInfoVo);
    }

    /**
     * 新建工时
     */
    @RequestMapping("/addManHour")
    public ResMsg addManHour(@RequestBody ManHourInfoVo manHourInfoVo, HttpServletRequest request) {
        Long userId = TokenData.takeFromRequest().getUserId();
        manHourInfoVo.setCreateUser(String.valueOf(userId));
        return manHourInfoApi.addManHour(manHourInfoVo);
    }

    /**
     * 删除
     *
     * @param manHourInfoVos
     * @return ResMsg
     */
    @RequestMapping("/deleteManHour")
    public ResMsg deleteManHour(@RequestBody List<ManHourInfoVo> manHourInfoVos) {
        return manHourInfoApi.deleteManHour(manHourInfoVos);
    }


}
