package org.dromara.ems.info.controller;

import org.dromara.common.log.annotation.Log;
import org.dromara.ems.common.web.EmsBaseController;
import org.dromara.common.core.domain.R;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.ems.info.domain.LuggageSystemSecurityDoorBatteryLifecycle;
import org.dromara.ems.info.service.ILuggageSystemSecurityDoorBatteryLifecycleService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.List;

/**
 * 行李系统安全门铅酸电池生命周期Controller
 * 
 * @author Yinq
 * @date 2025-06-05
 */
@RestController
@RequiredArgsConstructor

@RequestMapping("/ems/info/securityDoorBatteryLifecycle")
public class LuggageSystemSecurityDoorBatteryLifecycleController extends EmsBaseController
{

    private final ILuggageSystemSecurityDoorBatteryLifecycleService luggageSystemSecurityDoorBatteryLifecycleService;

    /**
     * 查询行李系统安全门铅酸电池生命周期列表
     */
    @SaCheckPermission("ems/info:securityDoorBatteryLifecycle:list")
    @GetMapping("/list")
    public TableDataInfo list(LuggageSystemSecurityDoorBatteryLifecycle luggageSystemSecurityDoorBatteryLifecycle)
    {
        startPage();
        List<LuggageSystemSecurityDoorBatteryLifecycle> list = luggageSystemSecurityDoorBatteryLifecycleService.selectLuggageSystemSecurityDoorBatteryLifecycleList(luggageSystemSecurityDoorBatteryLifecycle);
        return getDataTable(list);
    }

    /**
     * 导出行李系统安全门铅酸电池生命周期列表
     */
    @SaCheckPermission("ems/info:securityDoorBatteryLifecycle:export")
    @Log(title = "行李系统安全门铅酸电池生命周期", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LuggageSystemSecurityDoorBatteryLifecycle luggageSystemSecurityDoorBatteryLifecycle)
    {
        List<LuggageSystemSecurityDoorBatteryLifecycle> list = luggageSystemSecurityDoorBatteryLifecycleService.selectLuggageSystemSecurityDoorBatteryLifecycleList(luggageSystemSecurityDoorBatteryLifecycle);
        ExcelUtil.exportExcel(list, "行李系统安全门铅酸电池生命周期数据", LuggageSystemSecurityDoorBatteryLifecycle.class, response);
    }

    /**
     * 获取行李系统安全门铅酸电池生命周期详细信息
     */
    @SaCheckPermission("ems/info:securityDoorBatteryLifecycle:query")
    @GetMapping(value = "/{objid}")
    public R<?> getInfo(@PathVariable("objid") Long objid)
    {
        return success(luggageSystemSecurityDoorBatteryLifecycleService.selectLuggageSystemSecurityDoorBatteryLifecycleByObjid(objid));
    }

    /**
     * 新增行李系统安全门铅酸电池生命周期
     */
    @SaCheckPermission("ems/info:securityDoorBatteryLifecycle:add")
    @Log(title = "行李系统安全门铅酸电池生命周期", businessType = BusinessType.INSERT)
    @PostMapping
    public R<?> add(@RequestBody LuggageSystemSecurityDoorBatteryLifecycle luggageSystemSecurityDoorBatteryLifecycle)
    {
        return toAjax(luggageSystemSecurityDoorBatteryLifecycleService.insertLuggageSystemSecurityDoorBatteryLifecycle(luggageSystemSecurityDoorBatteryLifecycle));
    }

    /**
     * 修改行李系统安全门铅酸电池生命周期
     */
    @SaCheckPermission("ems/info:securityDoorBatteryLifecycle:edit")
    @Log(title = "行李系统安全门铅酸电池生命周期", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<?> edit(@RequestBody LuggageSystemSecurityDoorBatteryLifecycle luggageSystemSecurityDoorBatteryLifecycle)
    {
        return toAjax(luggageSystemSecurityDoorBatteryLifecycleService.updateLuggageSystemSecurityDoorBatteryLifecycle(luggageSystemSecurityDoorBatteryLifecycle));
    }

    /**
     * 删除行李系统安全门铅酸电池生命周期
     */
    @SaCheckPermission("ems/info:securityDoorBatteryLifecycle:remove")
    @Log(title = "行李系统安全门铅酸电池生命周期", businessType = BusinessType.DELETE)
	@DeleteMapping("/{objids}")
    public R<?> remove(@PathVariable Long[] objids)
    {
        return toAjax(luggageSystemSecurityDoorBatteryLifecycleService.deleteLuggageSystemSecurityDoorBatteryLifecycleByObjids(objids));
    }

    /**
     * 导入行李系统安全门铅酸电池生命周期数据
     */
    @SaCheckPermission("ems/info:securityDoorBatteryLifecycle:add")
    @Log(title = "行李系统安全门铅酸电池生命周期", businessType = BusinessType.IMPORT)
    @PostMapping("/importData")
    public R<?> importData(MultipartFile file, @RequestParam(value = "updateSupport", defaultValue = "false") boolean updateSupport) throws Exception
    {
        List<LuggageSystemSecurityDoorBatteryLifecycle> dataList = ExcelUtil.importExcel(file.getInputStream(), LuggageSystemSecurityDoorBatteryLifecycle.class);
        String message = luggageSystemSecurityDoorBatteryLifecycleService.importLuggageSystemSecurityDoorBatteryLifecycle(dataList, updateSupport, getUsername());
        return R.ok(message);
    }

    /**
     * 获取行李系统安全门铅酸电池生命周期导入模板
     */
    @SaCheckPermission("ems/info:securityDoorBatteryLifecycle:add")
    @PostMapping("/importTemplate")
    public void importTemplate(HttpServletResponse response)
    {
        ExcelUtil.exportExcel(new ArrayList<>(), "行李系统安全门铅酸电池生命周期数据", LuggageSystemSecurityDoorBatteryLifecycle.class, response);
    }
}
