package com.yinet.web.controller.touchscreen;

import com.yinet.common.core.controller.BaseController;
import com.yinet.common.core.domain.AjaxResult;
import com.yinet.common.core.page.TableDataInfo;
import com.yinet.system.domain.TouchScreenHelpInfo;
import com.yinet.system.service.TouchScreenHelpInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ruoyi
 */
@Controller
@RequestMapping("/system/touchscreen/helpinfo")
public class HelpInfoAdminController extends BaseController {
    static String prefix = "touchscreen/admin/helpinfo";
    @Autowired
    private TouchScreenHelpInfoService touchScreenHelpInfoService;

    /**
     * 中心介绍
     *
     * @return
     */
    @GetMapping()
    public String GetInfoList() {
        return prefix + "/list";
    }

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list() {
        startPage();
        List<TouchScreenHelpInfo> touchScreenHelpInfos = touchScreenHelpInfoService.selectHelpInfoList();
        return getDataTable(touchScreenHelpInfos);
    }

    /**
     * 新增中心介绍
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增中心介绍
     */
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(@Validated TouchScreenHelpInfo touchScreenHelpInfo) {
        return toAjax(touchScreenHelpInfoService.insertHelpInfo(touchScreenHelpInfo));
    }

    /**
     * 编辑中心介绍
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap) {
        TouchScreenHelpInfo touchScreenHelpInfo = touchScreenHelpInfoService.selectHelpInfoById(id);
        mmap.addAttribute("infoNode", touchScreenHelpInfo);
        return prefix + "/edit";
    }

    /**
     * 编辑中心介绍
     */
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@Validated TouchScreenHelpInfo touchScreenHelpInfo) {
        return toAjax(touchScreenHelpInfoService.updateHelpInfo(touchScreenHelpInfo));
    }

    /**
     * 删除中心介绍
     */
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult deletHelpInfo(String ids) {
        return toAjax(touchScreenHelpInfoService.deletHelpInfo(ids));
    }

}
