package com.yijia.station.controller;

import com.yijia.common.annotation.Log;
import com.yijia.common.core.controller.BaseController;
import com.yijia.common.core.domain.AjaxResult;
import com.yijia.common.core.domain.entity.SysDept;
import com.yijia.common.core.domain.model.LoginUser;
import com.yijia.common.core.page.TableDataInfo;
import com.yijia.common.enums.BusinessType;
import com.yijia.common.utils.SecurityUtils;
import com.yijia.common.utils.poi.ExcelUtil;
import com.yijia.station.domain.StationPay;
import com.yijia.station.service.IStationPayService;
import com.yijia.system.service.ISysDeptService;
import com.yijia.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 油站支付设置Controller
 *
 * @author yijia
 * @date 2020-12-10
 */
@RestController
@RequestMapping("/station/pay")
public class StationPayController extends BaseController
{
    @Autowired
    private ISysDeptService sysDeptService;

    /**
     * 获取油站设置详细信息
     */
    @GetMapping(value = "/{payId}")
    public AjaxResult getInfo(@PathVariable("payId") Long payId)
    {
        return AjaxResult.success(sysDeptService.selectDeptById(payId));
    }

    /**
     * 查询油站支付设置信息
     * @param
     * @return
     */
    @GetMapping(value = "/queryOne")
    public AjaxResult queryOne(SysDept sysDept)
    {
        LoginUser currentUser = SecurityUtils.getLoginUser();
        return AjaxResult.success(sysDeptService.selectDeptById(currentUser.getUser().getDeptId()));
    }
    /***
     * 根据油站id 查询出油站信息
     * @param
     * @return
     */
    @GetMapping(value = "/{stationId}")
    public AjaxResult getPayInfo(@PathVariable("stationId") Long stationId)
    {
        return AjaxResult.success(sysDeptService.selectDeptById(stationId));
    }
    /**
     * 修改油站支付设置
     */
    @Log(title = "油站设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysDept sysDept)
    {
        return toAjax(sysDeptService.updateDept(sysDept));
    }
}
