package com.njzscloud.supervisory.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.supervisory.station.pojo.entity.StationManageEntity;
import com.njzscloud.supervisory.station.pojo.param.AddStationManageParam;
import com.njzscloud.supervisory.station.pojo.param.SearchStationManageParam;
import com.njzscloud.supervisory.station.pojo.result.ListManagerResult;
import com.njzscloud.supervisory.station.pojo.result.SearchStationManageResult;
import com.njzscloud.supervisory.station.service.StationManageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 站点管理员
 */
@Slf4j
@RestController
@RequestMapping("/station_manage")
@RequiredArgsConstructor
public class StationManageController {

    private final StationManageService stationManageService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody AddStationManageParam addStationManageParam) {
        stationManageService.add(addStationManageParam);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody StationManageEntity stationManageEntity) {
        stationManageService.modify(stationManageEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        stationManageService.del(ids);
        return R.success();
    }

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


    /**
     * 查询可用的管理员
     */
    @GetMapping("/list_manager")
    public R<ListManagerResult> listManager(SearchStationManageParam searchStationManageParam) {
        return R.success(stationManageService.listManager(searchStationManageParam));
    }

    /**
     * 查询当前登录人拥有的站点
     */
    @GetMapping("/my_station")
    public R<List<SearchStationManageResult>> myStation() {
        return R.success(stationManageService.myStation());
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<SearchStationManageResult>> paging(PageParam pageParam, SearchStationManageParam searchStationManageParam) {
        return R.success(stationManageService.paging(pageParam, searchStationManageParam));
    }

}
