package com.aucma.web.controller.system;

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

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.aucma.common.annotation.Log;
import com.aucma.common.core.controller.BaseController;
import com.aucma.common.core.domain.AjaxResult;
import com.aucma.common.enums.BusinessType;
import com.aucma.system.domain.SysPortLog;
import com.aucma.system.service.ISysPortLogService;
import com.aucma.common.utils.poi.ExcelUtil;
import com.aucma.common.core.page.TableDataInfo;

/**
 * MES接口日志Controller
 *
 * @author Yinq
 * @date 2023-09-20
 */
@RestController
@RequestMapping("/system/portLog" )
public class SysPortLogController extends BaseController {
    @Autowired
    private ISysPortLogService sysPortLogService;

    /**
     * 查询MES接口日志列表
     */
    @PreAuthorize("@ss.hasPermi('system:portLog:list')" )
    @GetMapping("/list" )
    public TableDataInfo list(SysPortLog sysPortLog) {
        startPage();
        List<SysPortLog> list = sysPortLogService.selectSysPortLogList(sysPortLog);
        return getDataTable(list);
    }

    /**
     * 导出MES接口日志列表
     */
    @PreAuthorize("@ss.hasPermi('system:portLog:export')" )
    @Log(title = "MES接口日志" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, SysPortLog sysPortLog) {
        List<SysPortLog> list = sysPortLogService.selectSysPortLogList(sysPortLog);
        ExcelUtil<SysPortLog> util = new ExcelUtil<SysPortLog>(SysPortLog. class);
        util.exportExcel(response, list, "MES接口日志数据" );
    }

    /**
     * 获取MES接口日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:portLog:query')" )
    @GetMapping(value = "/{objId}" )
    public AjaxResult getInfo(@PathVariable("objId") Long objId) {
        return success(sysPortLogService.selectSysPortLogByObjId(objId));
    }

    /**
     * 新增MES接口日志
     */
    @PreAuthorize("@ss.hasPermi('system:portLog:add')" )
    @Log(title = "MES接口日志" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysPortLog sysPortLog) {
        return toAjax(sysPortLogService.insertSysPortLog(sysPortLog));
    }

    /**
     * 修改MES接口日志
     */
    @PreAuthorize("@ss.hasPermi('system:portLog:edit')" )
    @Log(title = "MES接口日志" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysPortLog sysPortLog) {
        return toAjax(sysPortLogService.updateSysPortLog(sysPortLog));
    }

    /**
     * 删除MES接口日志
     */
    @PreAuthorize("@ss.hasPermi('system:portLog:remove')" )
    @Log(title = "MES接口日志" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{objIds}" )
    public AjaxResult remove(@PathVariable Long[] objIds) {
        return toAjax(sysPortLogService.deleteSysPortLogByObjIds(objIds));
    }
}
