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.BusGeologicalDisasterEntity;
import com.zcloud.modules.kangzai.service.BusGeologicalDisasterService;
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 地质灾害点信息详情表(BusGeologicalDisaster)表控制层
 * @Date 2025-06-09 10:14:59
 */
@Api(tags = "地质灾害点信息详情表")
@RestController
@RequestMapping("busGeologicalDisaster")
public class BusGeologicalDisasterController extends AbstractController {

    @Autowired
    private BusGeologicalDisasterService busGeologicalDisasterService;

    @ApiOperation("地质灾害点信息详情表-新增数据")
    @SysLog("地质灾害点信息详情表-新增数据")
    @PostMapping("/save")
    public R insert(@RequestBody BusGeologicalDisasterEntity param) {
        param.setCreator(getUserId());
        param.setOperator(getUserId());
        busGeologicalDisasterService.save(param);

        return R.ok();
    }

    @ApiOperation("地质灾害点信息详情表-编辑数据")
    @SysLog("地质灾害点信息详情表-编辑数据")
    @PostMapping("/update")
    public R update(@RequestBody BusGeologicalDisasterEntity param) {
        param.setOperator(getUserId());
        busGeologicalDisasterService.updateById(param);

        return R.ok();
    }


    @ApiOperation("地质灾害点信息详情表-删除数据")
    @SysLog("地质灾害点信息详情表-删除数据")
    @PostMapping("/delete")
    public R delete(@RequestBody BusGeologicalDisasterEntity param) {
        busGeologicalDisasterService.delete(param.getGeologicalDisasterId(), getUserId());
        return R.ok();
    }

    @ApiOperation("地质灾害点信息详情表-分页查询")
    @SysLog("地质灾害点信息详情表-分页查询")
    @PostMapping("/listPage")
    public R listPage(@RequestBody Map<String, Object> params) {
        PageUtils page = busGeologicalDisasterService.listPage(params);

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


    @ApiOperation("地质灾害点信息详情表-根据ID查详情")
    @SysLog("地质灾害点信息详情表-根据ID查详情")
    @PostMapping("/info")
    public R info(@RequestBody BusGeologicalDisasterEntity param) {
        BusGeologicalDisasterEntity busGeologicalDisaster = busGeologicalDisasterService.getById(param.getGeologicalDisasterId());
        return R.ok().put("busGeologicalDisaster", busGeologicalDisaster);
    }

}
