package com.yinet.web.controller.yyqh;

import com.yinet.common.annotation.Log;
import com.yinet.common.core.controller.BaseController;
import com.yinet.common.core.domain.AjaxResult;
import com.yinet.common.core.page.TableDataInfo;
import com.yinet.common.enums.BusinessType;
import com.yinet.common.utils.poi.ExcelUtil;
import com.yinet.yyqh.domain.Yyqh;
import com.yinet.yyqh.service.YyqhService;
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("/yyqh/yyqh")
public class YyqhController extends BaseController {
    private String prefix = "yyqh/admin";

    @Autowired
    private YyqhService yyqhService;

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

    /**
     * 查询网上预约列表列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Yyqh yyqh) {
        startPage();
        List<Yyqh> list = yyqhService.selectYyqhList(yyqh);
        return getDataTable(list);
    }

    /**
     * 导出网上预约列表列表
     */
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Yyqh yyqh) {
        List<Yyqh> list = yyqhService.selectYyqhListExcel(yyqh);
        ExcelUtil<Yyqh> util = new ExcelUtil<Yyqh>(Yyqh.class);
        String beginTime = yyqh.getParams().get("beginTime").toString();
        String endTime = yyqh.getParams().get("endTime").toString();
        return util.exportExcel(list, "yyqh", beginTime, endTime);
    }

    /**
     * 删除网上预约列表
     */
    @Log(title = "网上预约列表", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(yyqhService.deleteYyqhByIds(ids));
    }

}
