package com.zehong.web.controller.system;

import java.util.List;

import com.zehong.system.domain.TDetectorUser;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.TYehuaqiUser;
import com.zehong.system.service.ITYehuaqiUserService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;

/**
 * 燃气用户Controller
 * 
 * @author zehong
 * @date 2022-09-14
 */
@RestController
@RequestMapping("/system/yehuaqiUser")
public class TYehuaqiUserController extends BaseController
{
    @Autowired
    private ITYehuaqiUserService tYehuaqiUserService;

    /**
     * 查询燃气用户列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TYehuaqiUser tYehuaqiUser)
    {
        startPage();
        List<TYehuaqiUser> list = tYehuaqiUserService.selectTYehuaqiUserList(tYehuaqiUser);
        return getDataTable(list);
    }

    /**
     * 导出燃气用户列表
     */
    @Log(title = "燃气用户", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TYehuaqiUser tYehuaqiUser)
    {
        List<TYehuaqiUser> list = tYehuaqiUserService.selectTYehuaqiUserList(tYehuaqiUser);
        ExcelUtil<TYehuaqiUser> util = new ExcelUtil<TYehuaqiUser>(TYehuaqiUser.class);
        return util.exportExcel(list, "燃气用户数据");
    }

    /**
     * 获取燃气用户详细信息
     */
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return AjaxResult.success(tYehuaqiUserService.selectTYehuaqiUserById(userId));
    }

    /**
     * 新增燃气用户
     */
    @Log(title = "燃气用户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TYehuaqiUser tYehuaqiUser)
    {
        return toAjax(tYehuaqiUserService.insertTYehuaqiUser(tYehuaqiUser));
    }

    /**
     * 修改燃气用户
     */
    @Log(title = "燃气用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TYehuaqiUser tYehuaqiUser)
    {
        return toAjax(tYehuaqiUserService.updateTYehuaqiUser(tYehuaqiUser));
    }

    /**
     * 删除燃气用户
     */
    @Log(title = "燃气用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(tYehuaqiUserService.deleteTYehuaqiUserByIds(userIds));
    }
    @GetMapping("/allList")
    public TableDataInfo allList(TYehuaqiUser tYehuaqiUser)
    {
        List<TYehuaqiUser> list = tYehuaqiUserService.selectAllUserList(tYehuaqiUser);
        return getDataTable(list);
    }
}
