package com.yuchen.saas.park.service.controller.building;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yuchen.saas.park.api.dto.building.PmgBatBuildingManagerQueryDto;
import com.yuchen.saas.park.api.entity.building.PmgBatBuildingManager;
import com.yuchen.saas.park.service.service.building.IPmgBatBuildingManagerService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 *
 * 客户经理表 相关接口
 *
 *
 * @author yuanzhelin
 * @since 2024-10-17
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/pmgBatBuildingManager")
public class PmgBatBuildingManagerController {

    @Resource
    private IPmgBatBuildingManagerService pmgBatBuildingManagerService;

    /**
     * 新增/修改
     * @tag pauly-lyz
     */
    @PostMapping("/save")
    @ApiOperation(value = "新增/修改")
    public R save(@Valid @RequestBody PmgBatBuildingManager dto) {
        return R.data(pmgBatBuildingManagerService.saveOrUpdate(dto));
    }
    /**
     * 分页查询
     * @tag pauly-lyz
     */
    @PostMapping("/page")
    @ApiOperation(value = "分页查询")
    public R<IPage<PmgBatBuildingManager>> page(@RequestBody PmgBatBuildingManagerQueryDto dto) {
        return R.data(pmgBatBuildingManagerService.pages(dto));
    }
    /**
     * 删除
     * @tag pauly-lyz
     */
    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "删除")
    public R delete(@PathVariable Long id) {
        pmgBatBuildingManagerService.removeById(id);
        return R.success();
    }
    /**
     * 详情
     * @tag pauly-lyz
     */
    @GetMapping("/detail/{id}")
    @ApiOperation(value = "详情")
    public R<PmgBatBuildingManager> detail(@PathVariable Long id) {
        return R.data(pmgBatBuildingManagerService.getById(id));
    }
}
