package com.dayou.controller;

import com.dayou.entity.User;
import com.dayou.vo.ItemStageUserVO;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.RestController;
import com.dayou.controller.BaseController;
import com.dayou.service.IItemUserService;
import com.dayou.entity.ItemUser;
import com.dayou.common.RestResponse;
import org.springframework.web.bind.annotation.*;
import com.dayou.utils.ConvertUtil;
import com.dayou.utils.HttpKit;
import com.dayou.exception.ErrorCode;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.http.MediaType;
import org.springframework.web.multipart.MultipartFile;
/**
 * 项目人员表
 *
 * @author wucl
 * @since 2022-12-08
 */
@RestController
@RequestMapping("itemUser")
@Slf4j
public class ItemUserController extends BaseController {
    @Autowired
    private IItemUserService itemUserService;

    /**
    * 项目人员表列表
    */
    @GetMapping("")
    public RestResponse<Page<ItemUser>> page(ItemUser itemUser, Page page){
        Page<ItemUser> pages=itemUserService.selectPage(page,itemUser);
        return RestResponse.data(pages);
    }

    /**
     * 项目人员表详情
     */
    @GetMapping("/{id}")
    public RestResponse<ItemUser> detail(@PathVariable Long id){
        ItemUser xItemUser =itemUserService.detail(id);
        return RestResponse.data(xItemUser);
     }

    /**
     * 项目人员表新增
     */
    @PostMapping("")
    public RestResponse<Boolean> save(@RequestBody ItemUser itemUser) {
        Boolean ret = itemUserService.add(itemUser);
        return RestResponse.data(ret);
    }

    /**
     * 项目人员表更新
     */
    @PutMapping("")
    public RestResponse<Boolean> update(@RequestBody ItemUser itemUser) {
        Boolean ret = itemUserService.update(itemUser);
        return RestResponse.data(ret);
    }

    /**
     * 项目人员表删除
     */
    @DeleteMapping("/{id}")
    public RestResponse<Boolean> delete(@PathVariable Long id) {
        Boolean ret = itemUserService.delete(id);
        return RestResponse.data(ret);
    }


    /**
     * 获取项目参与人员
     * @return
     */
    @GetMapping("/user")
    public RestResponse<List<ItemStageUserVO>> userList(ItemStageUserVO itemStageUserVO){
        List<ItemStageUserVO> list = itemUserService.userList(itemStageUserVO);
        return RestResponse.data(list);
    }
}

