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.modules.kangzai.entity.BusRiverStructuresEntity;
import com.zcloud.modules.kangzai.service.BusRiverStructuresService;
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 河流覆盖物(BusRiverStructures)表控制层
 * @Date 2025-06-10 16:25:26
 */
@Api(tags = "河流覆盖物")
@RestController
@RequestMapping("busRiverStructures")
public class BusRiverStructuresController extends AbstractController {

    @Autowired
    private BusRiverStructuresService busRiverStructuresService;

    @ApiOperation("河流覆盖物-新增数据")
    @SysLog("河流覆盖物-新增数据")
    @PostMapping("/save")
    public R insert(@RequestBody BusRiverStructuresEntity param) {
        busRiverStructuresService.save(param);

        return R.ok();
    }

    @ApiOperation("河流覆盖物-编辑数据")
    @SysLog("河流覆盖物-编辑数据")
    @PostMapping("/update")
    public R update(@RequestBody BusRiverStructuresEntity param) {
        busRiverStructuresService.updateById(param);

        return R.ok();
    }


    @ApiOperation("河流覆盖物-删除数据")
    @SysLog("河流覆盖物-删除数据")
    @PostMapping("/delete")
    public R delete(@RequestBody BusRiverStructuresEntity param) {
        busRiverStructuresService.delete(param.getRiverStructuresId(), getUserId());
        return R.ok();
    }

    @ApiOperation("河流覆盖物-分页查询")
    @SysLog("河流覆盖物-分页查询")
    @PostMapping("/listPage")
    public R listPage(@RequestBody Map<String, Object> params) {
        PageUtils page = busRiverStructuresService.listPage(params);

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


    @ApiOperation("河流覆盖物-根据ID查详情")
    @SysLog("河流覆盖物-根据ID查详情")
    @PostMapping("/info")
    public R info(@RequestBody BusRiverStructuresEntity param) {
        BusRiverStructuresEntity busRiverStructures = busRiverStructuresService.getById(param.getRiverStructuresId());
        return R.ok().put("busRiverStructures", busRiverStructures);
    }

}
