package com.ruoyi.web.modules.industryservice.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
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.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.modules.industryservice.domain.BizThreeAssetsProblemReport;
import com.ruoyi.web.modules.industryservice.service.IBizThreeAssetsProblemReportService;

/**
 * 三资具体问题上报 REST。
 * <p>Base：{@code /dataModel/threeAssetsProblemReport}；权限 {@code dataModel:threeAssetsProblemReport:*}；无导入导出。</p>
 */
@RestController
@RequestMapping("/dataModel/threeAssetsProblemReport")
public class BizThreeAssetsProblemReportController extends BaseController
{
    @Autowired
    private IBizThreeAssetsProblemReportService service;

    @PreAuthorize("@ss.hasPermi('dataModel:threeAssetsProblemReport:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizThreeAssetsProblemReport query)
    {
        startPage();
        List<BizThreeAssetsProblemReport> list = service.selectBizThreeAssetsProblemReportList(query);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('dataModel:threeAssetsProblemReport:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(service.selectBizThreeAssetsProblemReportById(id));
    }

    @PreAuthorize("@ss.hasPermi('dataModel:threeAssetsProblemReport:add')")
    @Log(title = "三资具体问题上报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody BizThreeAssetsProblemReport row)
    {
        row.setCreateBy(getUsername());
        return toAjax(service.insertBizThreeAssetsProblemReport(row));
    }

    @PreAuthorize("@ss.hasPermi('dataModel:threeAssetsProblemReport:edit')")
    @Log(title = "三资具体问题上报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody BizThreeAssetsProblemReport row)
    {
        row.setUpdateBy(getUsername());
        return toAjax(service.updateBizThreeAssetsProblemReport(row));
    }

    @PreAuthorize("@ss.hasPermi('dataModel:threeAssetsProblemReport:remove')")
    @Log(title = "三资具体问题上报", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(service.deleteBizThreeAssetsProblemReportByIds(ids, getUsername()));
    }

    @PreAuthorize("@ss.hasPermi('dataModel:threeAssetsProblemReport:list')")
    @GetMapping("/townOptions")
    public AjaxResult townOptions()
    {
        return success(service.listTownOptions());
    }

    @PreAuthorize("@ss.hasPermi('dataModel:threeAssetsProblemReport:list')")
    @GetMapping("/villageTree")
    public AjaxResult villageTree()
    {
        return success(service.listVillageTree());
    }
}
