package com.sooka.system.controller;

import java.util.List;
import com.sooka.common.annotation.Log;
import com.sooka.common.core.controller.BaseController;
import com.sooka.common.core.domain.AjaxResult;
import com.sooka.common.core.page.TableDataInfo;
import com.sooka.common.enums.BusinessType;
import com.sooka.common.utils.poi.ExcelUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.sooka.system.domain.TGuijiHousingconstructionZlskfrx;
import com.sooka.system.service.ITGuijiHousingconstructionZlskfrxService;

/**
 * 自来水客服热线Controller
 * 
 * @author lei
 * @date 2021-11-05
 */
@Controller
@RequestMapping("/system/zlskfrx")
public class TGuijiHousingconstructionZlskfrxController extends BaseController
{
    private String prefix = "system/zlskfrx";

    @Autowired
    private ITGuijiHousingconstructionZlskfrxService tGuijiHousingconstructionZlskfrxService;

    @RequiresPermissions("system:zlskfrx:view")
    @GetMapping()
    public String zlskfrx()
    {
        return prefix + "/zlskfrx";
    }

    /**
     * 查询自来水客服热线列表
     */
    @RequiresPermissions("system:zlskfrx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TGuijiHousingconstructionZlskfrx tGuijiHousingconstructionZlskfrx)
    {
        startPage();
        List<TGuijiHousingconstructionZlskfrx> list = tGuijiHousingconstructionZlskfrxService.selectTGuijiHousingconstructionZlskfrxList(tGuijiHousingconstructionZlskfrx);
        return getDataTable(list);
    }

    /**
     * 导出自来水客服热线列表
     */
    @RequiresPermissions("system:zlskfrx:export")
    @Log(title = "自来水客服热线", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TGuijiHousingconstructionZlskfrx tGuijiHousingconstructionZlskfrx)
    {
        List<TGuijiHousingconstructionZlskfrx> list = tGuijiHousingconstructionZlskfrxService.selectTGuijiHousingconstructionZlskfrxList(tGuijiHousingconstructionZlskfrx);
        ExcelUtil<TGuijiHousingconstructionZlskfrx> util = new ExcelUtil<TGuijiHousingconstructionZlskfrx>(TGuijiHousingconstructionZlskfrx.class);
        return util.exportExcel(list, "zlskfrx");
    }

    /**
     * 新增自来水客服热线
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存自来水客服热线
     */
    @RequiresPermissions("system:zlskfrx:add")
    @Log(title = "自来水客服热线", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TGuijiHousingconstructionZlskfrx tGuijiHousingconstructionZlskfrx)
    {
        return toAjax(tGuijiHousingconstructionZlskfrxService.insertTGuijiHousingconstructionZlskfrx(tGuijiHousingconstructionZlskfrx));
    }

    /**
     * 修改自来水客服热线
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TGuijiHousingconstructionZlskfrx tGuijiHousingconstructionZlskfrx = tGuijiHousingconstructionZlskfrxService.selectTGuijiHousingconstructionZlskfrxById(id);
        mmap.put("tGuijiHousingconstructionZlskfrx", tGuijiHousingconstructionZlskfrx);
        return prefix + "/edit";
    }

    /**
     * 修改保存自来水客服热线
     */
    @RequiresPermissions("system:zlskfrx:edit")
    @Log(title = "自来水客服热线", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TGuijiHousingconstructionZlskfrx tGuijiHousingconstructionZlskfrx)
    {
        return toAjax(tGuijiHousingconstructionZlskfrxService.updateTGuijiHousingconstructionZlskfrx(tGuijiHousingconstructionZlskfrx));
    }

    /**
     * 删除自来水客服热线
     */
    @RequiresPermissions("system:zlskfrx:remove")
    @Log(title = "自来水客服热线", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tGuijiHousingconstructionZlskfrxService.deleteTGuijiHousingconstructionZlskfrxByIds(ids));
    }
}
