package com.project.zcustom.controller.backManager.engineering;
import com.project.zcustom.controller.core.AjaxResult;
import com.project.zcustom.controller.core.BaseController;
import com.project.zcustom.domain.addional.LargePlan;
import com.project.zcustom.service.unit.ILargePlanService;
import lombok.RequiredArgsConstructor;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * 工程计划Controller
 *
 * @author change
 * @date 2024-12-30
 */
@RestController
@RequestMapping("/zcustom/plan")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class LargePlanController extends BaseController {

    private final ILargePlanService largePlanService;

    @GetMapping("/list")
    public AjaxResult list(LargePlan entity) {
        return AjaxResult.success("查询成功", largePlanService.pagingLargePlanList(entity));
    }

    @GetMapping("/listAll")
    public AjaxResult listAll(LargePlan entity) {
        return AjaxResult.success("查询成功", largePlanService.selectLargePlanList(entity));
    }


    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success("查询成功", largePlanService.getById(id));
    }


    @PostMapping("add")
    public AjaxResult add(@RequestBody LargePlan entity) {
        return toAjax(largePlanService.save(entity));
    }


    @PostMapping("edit")
    public AjaxResult edit(@RequestBody LargePlan entity) {
        return toAjax(largePlanService.updateById(entity));
    }


	@GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(largePlanService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
    }

    /**
     * 本周检查项目数
     */
    @GetMapping(value = "/getCheckProjectNum")
    public AjaxResult getCheckProjectNum(@RequestParam Date startDate, @RequestParam Date endDate){
        return AjaxResult.success("查询成功", largePlanService.getCheckProjectNum(startDate, endDate));
    }
}
