package com.kym.admin.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.kym.common.R;
import com.kym.common.annotation.SysLog;
import com.kym.entity.WashStation;
import com.kym.entity.queryParams.StationQueryParams;
import com.kym.service.WashStationService;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 洗车站点信息 前端控制器
 * </p>
 *
 * @author skyline
 * @since 2023-08-12
 */
@RestController
@RequestMapping("/washStation")
public class WashStationController {

    private final WashStationService washStationService;


    public WashStationController(WashStationService stationService) {
        this.washStationService = stationService;
    }

    @SaCheckPermission("washStation.list")
    @SysLog("站点列表")
    @PostMapping("list")
    R<?> listStation(@RequestBody StationQueryParams params) {
        return R.success(washStationService.list(params));
    }

    @SaCheckPermission("washStation.list")
    @SysLog("详情")
    @GetMapping("detail/{id}")
    R<?> detail(@PathVariable long id) {
        return R.success(washStationService.detail(id));
    }

    @SaCheckPermission("washStation.remove")
    @SysLog("删除")
    @GetMapping("remove/{id}")
    R<?> remove(@PathVariable long id) {
        washStationService.remove(id);
        return R.success();
    }

    @SaCheckPermission("washStation.modify")
    @SysLog("修改")
    @PostMapping("modify")
    R<?> modify(@RequestBody WashStation station) {
        washStationService.modify(station);
        return R.success();
    }

    @SaCheckPermission("washStation.add")
    @SysLog("新建")
    @PostMapping("add")
    R<?> add(@RequestBody @Validated WashStation station) {
        washStationService.add(station);
        return R.success();
    }




}
