package com.zd.chemical.controller;

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

import com.zd.chemical.domain.vo.HxpCabinetlockLogSearch;
import com.zd.chemical.domain.vo.HxpCabinetlockLogVo;
import com.zd.common.core.domain.per.PerFun;
import com.zd.common.core.domain.per.PerPrefix;
import com.zd.common.core.web.domain.ResultData;
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.zd.common.log.annotation.Log;
import com.zd.common.log.enums.BusinessType;
import com.zd.common.security.annotation.PreAuthorize;
import com.zd.chemical.domain.HxpCabinetlockLog;
import com.zd.chemical.service.IHxpCabinetlockLogService;
import com.zd.common.core.web.controller.BaseController;
import com.zd.common.core.web.domain.AjaxResult;
import com.zd.common.core.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.zd.common.core.web.page.TableDataInfo;

/**
 * 【柜锁日志】Controller
 *
 * @author zd
 * @date 2022-07-11
 */
@RestController
@Api(tags = "【【柜锁日志】】")
@RequestMapping("/locklog")
public class HxpCabinetlockLogController extends BaseController<HxpCabinetlockLog>
{
    @Autowired
    private IHxpCabinetlockLogService hxpCabinetlockLogService;

    /**
     * 查询【柜锁日志】列表
     */
    @PreAuthorize(hasAnyPermi = { PerPrefix.HPX_LOCKLOG + PerFun.LIST,PerPrefix.HPX_LOCKLOG2 + PerFun.LIST})
    @GetMapping("/list")
    @ApiOperation(value = "查询【柜锁日志】列表")
    public TableDataInfo<HxpCabinetlockLogVo> list(HxpCabinetlockLogSearch hxpCabinetlockLogSearch)
    {
        startPage();
        List<HxpCabinetlockLogVo> list = hxpCabinetlockLogService.selectHxpCabinetlockLogList(hxpCabinetlockLogSearch);
        TableDataInfo<HxpCabinetlockLogVo> info=new TableDataInfo<>();
        info.getDataTable(list);
        return info;
    }

    /**
     * 导出【柜锁日志】列表
     */
    @ApiOperation(value = "导出【柜锁日志】列表")
    @PreAuthorize(hasPermi = PerPrefix.HPX_LOCKLOG + PerFun.EXPORT)
    @Log(title = "【柜锁日志】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HxpCabinetlockLogSearch hxpCabinetlockLogSearch) throws IOException
    {
        List<HxpCabinetlockLogVo> list = hxpCabinetlockLogService.selectHxpCabinetlockLogList(hxpCabinetlockLogSearch);
        ExcelUtil<HxpCabinetlockLogVo> util = new ExcelUtil<HxpCabinetlockLogVo>(HxpCabinetlockLogVo.class);
        util.exportExcel(response, list, "【柜锁日志】数据");
    }

    /**
     * 获取【柜锁日志】详细信息
     */
    @ApiOperation(value = "获取【柜锁日志】详细信息")
    @PreAuthorize(hasPermi = PerPrefix.HPX_LOCKLOG + PerFun.QUERY)
    @GetMapping(value = "/{id}")
    public ResultData<HxpCabinetlockLog> getInfo(@PathVariable("id") Long id)
    {
        return ResultData.success(hxpCabinetlockLogService.selectHxpCabinetlockLogById(id));
    }

    /**
     * 新增【柜锁日志】
     */
    @ApiOperation(value = "新增【柜锁日志】")
    @PreAuthorize(hasPermi = PerPrefix.HPX_LOCKLOG + PerFun.ADD)
    @Log(title = "【柜锁日志】", businessType = BusinessType.INSERT)
    @PostMapping
    public ResultData add(@RequestBody HxpCabinetlockLog hxpCabinetlockLog)
    {
        return ResultData.result(hxpCabinetlockLogService.insertHxpCabinetlockLog(hxpCabinetlockLog));
    }

    /**
     * 修改【柜锁日志】
     */
    @ApiOperation(value = "修改【柜锁日志】")
    @PreAuthorize(hasPermi = PerPrefix.HPX_LOCKLOG + PerFun.EDIT)
    @Log(title = "【柜锁日志】", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResultData edit(@RequestBody HxpCabinetlockLog hxpCabinetlockLog)
    {
        return  ResultData.result(hxpCabinetlockLogService.updateHxpCabinetlockLog(hxpCabinetlockLog));
    }

    /**
     * 删除【柜锁日志】
     */
    @ApiOperation(value = "删除【柜锁日志】")
    @PreAuthorize(hasPermi = PerPrefix.HPX_LOCKLOG + PerFun.REMOVE)
    @Log(title = "【柜锁日志】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public ResultData remove(@PathVariable Long[] ids)
    {
        return ResultData.result(hxpCabinetlockLogService.deleteHxpCabinetlockLogByIds(ids));
    }
}
