package com.hw.ems.base.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.hw.ems.base.domain.BaseLineMonitor;
import com.hw.ems.base.service.IBaseLineMonitorService;
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.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.common.security.annotation.RequiresPermissions;
import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.core.utils.poi.ExcelUtil;

/**
 * 线路计量信息Controller
 *
 * @author YinQ
 * @date 2023-05-06
 */
@RestController
@RequestMapping("/lineMonitor")
public class BaseLineMonitorController extends BaseController
{
    @Autowired
    private IBaseLineMonitorService baseLineMonitorService;

    /**
     * 查询线路计量信息列表
     */
    @RequiresPermissions("base:lineMonitor:list")
    @GetMapping("/list")
    public AjaxResult list(BaseLineMonitor baseLineMonitor)
    {
        List<BaseLineMonitor> list = baseLineMonitorService.selectBaseLineMonitorList(baseLineMonitor);
        return success(list);
    }

    /**
     * 导出线路计量信息列表
     */
    @RequiresPermissions("base:lineMonitor:export")
    @Log(title = "线路计量信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseLineMonitor baseLineMonitor)
    {
        List<BaseLineMonitor> list = baseLineMonitorService.selectBaseLineMonitorList(baseLineMonitor);
        ExcelUtil<BaseLineMonitor> util = new ExcelUtil<BaseLineMonitor>(BaseLineMonitor.class);
        util.exportExcel(response, list, "线路计量信息数据");
    }

    /**
     * 获取线路计量信息详细信息
     */
    @RequiresPermissions("base:lineMonitor:query")
    @GetMapping(value = "/{objid}")
    public AjaxResult getInfo(@PathVariable("objid") Long objid)
    {
        return success(baseLineMonitorService.selectBaseLineMonitorByObjid(objid));
    }

    /**
     * 新增线路计量信息
     */
    @RequiresPermissions("base:lineMonitor:add")
    @Log(title = "线路计量信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseLineMonitor baseLineMonitor)
    {
        return toAjax(baseLineMonitorService.insertBaseLineMonitor(baseLineMonitor));
    }

    /**
     * 修改线路计量信息
     */
    @RequiresPermissions("base:lineMonitor:edit")
    @Log(title = "线路计量信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseLineMonitor baseLineMonitor)
    {
        return toAjax(baseLineMonitorService.updateBaseLineMonitor(baseLineMonitor));
    }

    /**
     * 删除线路计量信息
     */
    @RequiresPermissions("base:lineMonitor:remove")
    @Log(title = "线路计量信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{objids}")
    public AjaxResult remove(@PathVariable Long[] objids)
    {
        return toAjax(baseLineMonitorService.deleteBaseLineMonitorByObjids(objids));
    }
}
