package com.njzscloud.dispose.cst.station.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.dispose.cst.station.pojo.param.AddStationParam;
import com.njzscloud.dispose.cst.station.pojo.param.ModifyStationParam;
import com.njzscloud.dispose.cst.station.pojo.param.StationQueryParam;
import com.njzscloud.dispose.cst.station.pojo.result.StationResult;
import com.njzscloud.dispose.cst.station.service.StationService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 站点信息
 * @author ljw
 */
@Slf4j
@RestController
@RequestMapping("/station")
@RequiredArgsConstructor
public class StationController {

    private final StationService stationService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody AddStationParam addStationParam) {
        stationService.add(addStationParam);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody ModifyStationParam modifyStationParam) {
        stationService.modify(modifyStationParam);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<StationResult> detail(@RequestParam("id") Long id) {
        return R.success(stationService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<StationResult>> paging(PageParam pageParam, StationQueryParam queryParam) {
        return R.success(stationService.paging(pageParam, queryParam));
    }
}


