package com.sooka.system.controller;

import java.util.List;

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.common.annotation.Log;
import com.sooka.system.domain.TGuijiHousingconstructionYslxx;
import com.sooka.system.service.ITGuijiHousingconstructionYslxxService;

/**
 * 用水量信息Controller
 * 
 * @author lei
 * @date 2021-11-05
 */
@Controller
@RequestMapping("/system/yslxx")
public class TGuijiHousingconstructionYslxxController extends BaseController
{
    private String prefix = "system/yslxx";

    @Autowired
    private ITGuijiHousingconstructionYslxxService tGuijiHousingconstructionYslxxService;

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

    /**
     * 查询用水量信息列表
     */
    @RequiresPermissions("system:yslxx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TGuijiHousingconstructionYslxx tGuijiHousingconstructionYslxx)
    {
        startPage();
        List<TGuijiHousingconstructionYslxx> list = tGuijiHousingconstructionYslxxService.selectTGuijiHousingconstructionYslxxList(tGuijiHousingconstructionYslxx);
        return getDataTable(list);
    }

    /**
     * 导出用水量信息列表
     */
    @RequiresPermissions("system:yslxx:export")
    @Log(title = "用水量信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TGuijiHousingconstructionYslxx tGuijiHousingconstructionYslxx)
    {
        List<TGuijiHousingconstructionYslxx> list = tGuijiHousingconstructionYslxxService.selectTGuijiHousingconstructionYslxxList(tGuijiHousingconstructionYslxx);
        ExcelUtil<TGuijiHousingconstructionYslxx> util = new ExcelUtil<TGuijiHousingconstructionYslxx>(TGuijiHousingconstructionYslxx.class);
        return util.exportExcel(list, "yslxx");
    }

    /**
     * 新增用水量信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用水量信息
     */
    @RequiresPermissions("system:yslxx:add")
    @Log(title = "用水量信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TGuijiHousingconstructionYslxx tGuijiHousingconstructionYslxx)
    {
        return toAjax(tGuijiHousingconstructionYslxxService.insertTGuijiHousingconstructionYslxx(tGuijiHousingconstructionYslxx));
    }

    /**
     * 修改用水量信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TGuijiHousingconstructionYslxx tGuijiHousingconstructionYslxx = tGuijiHousingconstructionYslxxService.selectTGuijiHousingconstructionYslxxById(id);
        mmap.put("tGuijiHousingconstructionYslxx", tGuijiHousingconstructionYslxx);
        return prefix + "/edit";
    }

    /**
     * 修改保存用水量信息
     */
    @RequiresPermissions("system:yslxx:edit")
    @Log(title = "用水量信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TGuijiHousingconstructionYslxx tGuijiHousingconstructionYslxx)
    {
        return toAjax(tGuijiHousingconstructionYslxxService.updateTGuijiHousingconstructionYslxx(tGuijiHousingconstructionYslxx));
    }

    /**
     * 删除用水量信息
     */
    @RequiresPermissions("system:yslxx:remove")
    @Log(title = "用水量信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tGuijiHousingconstructionYslxxService.deleteTGuijiHousingconstructionYslxxByIds(ids));
    }
}
