package com.yinet.web.controller.wsyy;

import com.yinet.common.core.controller.BaseController;
import com.yinet.common.core.domain.AjaxResult;
import com.yinet.common.core.page.TableDataInfo;
import com.yinet.wsyy.domain.WsyyQuantum;
import com.yinet.wsyy.service.IWsyyQuantumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 时间段设置Controller
 *
 * @author yinet
 * @date 2019-09-02
 */
@Controller
@RequestMapping("/wsyy/quantum")
public class WsyyQuantumController extends BaseController {
    private String prefix = "wsyy/admin/quantum";

    @Autowired
    private IWsyyQuantumService wsyyQuantumService;

    @GetMapping()
    public String quantum() {
        return prefix + "/quantum";
    }

    /**
     * 查询时间段设置列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list() {
        startPage();
        List<WsyyQuantum> list = wsyyQuantumService.selectWsyyQuantumList(null);
        return getDataTable(list);
    }

    /**
     * 关闭与开启时间段
     */
    @PostMapping("/changeStatus")
    @ResponseBody
    public AjaxResult changeStatus(WsyyQuantum wsyyQuantum) {
        return toAjax(wsyyQuantumService.changeStatus(wsyyQuantum));
    }
}
