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.LargeProject;
import com.project.zcustom.service.unit.ILargeProjectService;
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.List;

/**
 * 工程项目Controller
 *
 * @author change
 * @date 2024-12-30
 */
@RestController
@RequestMapping("/zcustom/project")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class LargeProjectController extends BaseController {

    private final ILargeProjectService largeProjectService;

    @GetMapping("/list")
    public AjaxResult list(LargeProject entity) {
        return AjaxResult.success("查询成功", largeProjectService.pagingLargeProjectList(entity));
    }

    @GetMapping("/listAll")
    public AjaxResult listAll(LargeProject entity) {
        return AjaxResult.success("查询成功", largeProjectService.selectLargeProjectList(entity));
    }



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


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


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


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