package com.sooka.system.controller;

import java.util.List;
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.TGuijiHousingconstructionYhjbxx;
import com.sooka.system.service.ITGuijiHousingconstructionYhjbxxService;
import com.sooka.common.core.controller.BaseController;
import com.sooka.common.core.page.TableDataInfo;
import com.sooka.common.annotation.Log;
import com.sooka.common.core.domain.AjaxResult;
import com.sooka.common.enums.BusinessType;
import com.sooka.common.utils.poi.ExcelUtil;

/**
 * 自来水人员基本信息Controller
 * 
 * @author lei
 * @date 2021-10-27
 */
@Controller
@RequestMapping("/system/yhjbxx")
public class TGuijiHousingconstructionYhjbxxController extends BaseController
{
    private String prefix = "system/yhjbxx";

    @Autowired
    private ITGuijiHousingconstructionYhjbxxService tGuijiHousingconstructionYhjbxxService;

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

    @RequiresPermissions("system:yhjbxx:view")
    @GetMapping("/yhjbxxpz")
    public String yhjbxxpz()
    {
        return prefix + "/pzyhjbxx";
    }
    /**
     * 查询自来水人员基本信息列表
     */
    @RequiresPermissions("system:yhjbxx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TGuijiHousingconstructionYhjbxx tGuijiHousingconstructionYhjbxx)
    {
        startPage();
        List<TGuijiHousingconstructionYhjbxx> list = tGuijiHousingconstructionYhjbxxService.selectTGuijiHousingconstructionYhjbxxList(tGuijiHousingconstructionYhjbxx);
        return getDataTable(list);
    }

    /**
     * 查询自来水人员基本信息列表
     */
    @RequiresPermissions("system:yhjbxx:listpz")
    @PostMapping("/listpz")
    @ResponseBody
    public TableDataInfo listpz(TGuijiHousingconstructionYhjbxx tGuijiHousingconstructionYhjbxx)
    {
        System.out.println("listpz");
        startPage();
        List<TGuijiHousingconstructionYhjbxx> list = tGuijiHousingconstructionYhjbxxService.selectTGuijiHousingconstructionYhjbxxList(tGuijiHousingconstructionYhjbxx);
        return getDataTable(list);
    }
    /**
     * 导出自来水人员基本信息列表
     */
    @RequiresPermissions("system:yhjbxx:export")
    @Log(title = "自来水人员基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TGuijiHousingconstructionYhjbxx tGuijiHousingconstructionYhjbxx)
    {
        List<TGuijiHousingconstructionYhjbxx> list = tGuijiHousingconstructionYhjbxxService.selectTGuijiHousingconstructionYhjbxxList(tGuijiHousingconstructionYhjbxx);
        ExcelUtil<TGuijiHousingconstructionYhjbxx> util = new ExcelUtil<TGuijiHousingconstructionYhjbxx>(TGuijiHousingconstructionYhjbxx.class);
        return util.exportExcel(list, "yhjbxx");
    }

    /**
     * 新增自来水人员基本信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存自来水人员基本信息
     */
    @RequiresPermissions("system:yhjbxx:add")
    @Log(title = "自来水人员基本信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TGuijiHousingconstructionYhjbxx tGuijiHousingconstructionYhjbxx)
    {
        return toAjax(tGuijiHousingconstructionYhjbxxService.insertTGuijiHousingconstructionYhjbxx(tGuijiHousingconstructionYhjbxx));
    }

    /**
     * 修改自来水人员基本信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TGuijiHousingconstructionYhjbxx tGuijiHousingconstructionYhjbxx = tGuijiHousingconstructionYhjbxxService.selectTGuijiHousingconstructionYhjbxxById(id);
        mmap.put("tGuijiHousingconstructionYhjbxx", tGuijiHousingconstructionYhjbxx);
        return prefix + "/edit";
    }

    /**
     * 修改保存自来水人员基本信息
     */
    @RequiresPermissions("system:yhjbxx:edit")
    @Log(title = "自来水人员基本信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TGuijiHousingconstructionYhjbxx tGuijiHousingconstructionYhjbxx)
    {
        return toAjax(tGuijiHousingconstructionYhjbxxService.updateTGuijiHousingconstructionYhjbxx(tGuijiHousingconstructionYhjbxx));
    }

    /**
     * 删除自来水人员基本信息
     */
    @RequiresPermissions("system:yhjbxx:remove")
    @Log(title = "自来水人员基本信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tGuijiHousingconstructionYhjbxxService.deleteTGuijiHousingconstructionYhjbxxByIds(ids));
    }

    /**
     * 查询自来水人员基本信息详细
     */
    @RequiresPermissions("system:yhjbxx:detail")
    @GetMapping("/detail/{id}")
    public String detail(@PathVariable("id") String id, ModelMap mmap)
    {
        TGuijiHousingconstructionYhjbxx tGuijiHousingconstructionYhjbxx = tGuijiHousingconstructionYhjbxxService.selectTGuijiHousingconstructionYhjbxxById(id);
        mmap.put("tGuijiHousingconstructionYhjbxx", tGuijiHousingconstructionYhjbxx);
        return prefix + "/detail";
    }
}
