package org.dromara.facility.controller;

import jakarta.annotation.Resource;
import org.dromara.common.core.domain.R;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.web.core.BaseController;
import org.dromara.facility.domain.dto.photovoltaicpanelparts.FacPhotovoltaicPanelPartsCreateByGeoJsonReq;
import org.dromara.facility.domain.dto.photovoltaicpanelparts.FacPhotovoltaicPanelPartsCreateReq;
import org.dromara.facility.service.IFacPhotovoltaicPanelPartsService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 设施-光伏板桩点、立柱、支架
 *
 * @author lcj
 * @date 2025/4/21
 */
@Validated
@RestController
@RequestMapping("/facility/photovoltaicPanelPoint/parts")
public class FacPhotovoltaicPanelPartsController extends BaseController {

    @Resource
    private IFacPhotovoltaicPanelPartsService photovoltaicPanelPartsService;

    /**
     * 通过GeoJson新增设施-光伏板桩点、立柱、支架
     */
    @Log(title = "设施-光伏板（桩点、立柱、支架）", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping("/geoJson")
    public R<Void> insertPartsByGeoJson(@RequestBody FacPhotovoltaicPanelPartsCreateByGeoJsonReq req) {
        return toAjax(photovoltaicPanelPartsService.insertPartsByGeoJson(req));
    }

    /**
     * 新增设施-光伏板桩点、立柱、支架
     */
    @Log(title = "设施-光伏板（桩点、立柱、支架）", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Boolean> insertPartsByBatch(FacPhotovoltaicPanelPartsCreateReq req) {
        return R.ok(photovoltaicPanelPartsService.insertPartsByBatch(req));
    }

}
