package com.zcloud.modules.kangzai.controller;

import com.zcloud.common.annotation.SysLog;
import com.zcloud.common.utils.PageUtils;
import com.zcloud.common.utils.R;
import com.zcloud.common.utils.Tools;
import com.zcloud.modules.kangzai.entity.BusRiverRiskVillagesEntity;
import com.zcloud.modules.kangzai.service.BusRiverRiskVillagesService;
import com.zcloud.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.Map;

/**
 * @Author fangjiakai
 * @Desc 河道行洪隐患区村庄清单(BusRiverRiskVillages)表控制层
 * @Date 2025-06-09 09:44:24
 */
@Api(tags = "河道行洪隐患区村庄清单")
@RestController
@RequestMapping("busRiverRiskVillages")
public class BusRiverRiskVillagesController extends AbstractController {

    @Autowired
    private BusRiverRiskVillagesService busRiverRiskVillagesService;

    @ApiOperation("河道行洪隐患区村庄清单-新增数据")
    @SysLog("河道行洪隐患区村庄清单-新增数据")
    @PostMapping("/save")
    public R insert(@RequestBody BusRiverRiskVillagesEntity param) {
        busRiverRiskVillagesService.save(param);

        return R.ok();
    }

    @ApiOperation("河道行洪隐患区村庄清单-编辑数据")
    @SysLog("河道行洪隐患区村庄清单-编辑数据")
    @PostMapping("/update")
    public R update(@RequestBody BusRiverRiskVillagesEntity param) {
        busRiverRiskVillagesService.updateById(param);

        return R.ok();
    }


    @ApiOperation("河道行洪隐患区村庄清单-删除数据")
    @SysLog("河道行洪隐患区村庄清单-删除数据")
    @PostMapping("/delete")
    public R delete(@RequestBody BusRiverRiskVillagesEntity param) {
        busRiverRiskVillagesService.delete(param.getRiverRiskVillagesId(), getUserId());
        return R.ok();
    }

    @ApiOperation("河道行洪隐患区村庄清单-分页查询")
    @SysLog("河道行洪隐患区村庄清单-分页查询")
    @PostMapping("/listPage")
    public R listPage(@RequestBody Map<String, Object> params) {
        PageUtils page = busRiverRiskVillagesService.listPage(params);

        return R.ok().put("page", page);
    }


    @ApiOperation("河道行洪隐患区村庄清单-根据ID查详情")
    @SysLog("河道行洪隐患区村庄清单-根据ID查详情")
    @PostMapping("/info")
    public R info(@RequestBody BusRiverRiskVillagesEntity param) {
        BusRiverRiskVillagesEntity busRiverRiskVillages = busRiverRiskVillagesService.getById(param.getRiverRiskVillagesId());
        return R.ok().put("busRiverRiskVillages", busRiverRiskVillages);
    }

}
