package com.huashe.park.application.web.controller.cons;

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

import com.huashe.common.domain.AjaxResult;
import com.huashe.park.core.service.IProjectCoordinateInfoService;
import com.huashe.park.domain.entity.ProjectCoordinateInfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工程坐标配置Controller
 * 
 * @author ruoyi
 * @date 2025-02-14
 */
@RestController
@RequestMapping("/cons/projectCoordinateInfo")
public class ProjectCoordinateInfoController extends BaseController {
    @Autowired
    private IProjectCoordinateInfoService projectCoordinateInfoService;

    /**
     * 查询工程坐标配置列表
     */

    @GetMapping("/list")
    public TableDataInfo list(ProjectCoordinateInfo projectCoordinateInfo) {
        startPage();
        List<ProjectCoordinateInfo> list = projectCoordinateInfoService
            .selectProjectCoordinateInfoList(projectCoordinateInfo);
        return getDataTable(list);
    }

    /**
     * 导出工程坐标配置列表
     */

    @Log(title = "工程坐标配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectCoordinateInfo projectCoordinateInfo) {
        List<ProjectCoordinateInfo> list = projectCoordinateInfoService
            .selectProjectCoordinateInfoList(projectCoordinateInfo);
        ExcelUtil<ProjectCoordinateInfo> util = new ExcelUtil<ProjectCoordinateInfo>(ProjectCoordinateInfo.class);
        util.exportExcel(response, list, "工程坐标配置数据");
    }

    /**
     * 获取工程坐标配置详细信息
     */

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(projectCoordinateInfoService.selectProjectCoordinateInfoById(id));
    }

    /**
     * 新增工程坐标配置
     */

    @Log(title = "工程坐标配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectCoordinateInfo projectCoordinateInfo) {
        return toAjax(projectCoordinateInfoService.insertProjectCoordinateInfo(projectCoordinateInfo));
    }

    /**
     * 修改工程坐标配置
     */

    @Log(title = "工程坐标配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectCoordinateInfo projectCoordinateInfo) {
        return toAjax(projectCoordinateInfoService.updateProjectCoordinateInfo(projectCoordinateInfo));
    }

    /**
     * 删除工程坐标配置
     */

    @Log(title = "工程坐标配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(projectCoordinateInfoService.deleteProjectCoordinateInfoByIds(ids));
    }
}
