package com.shzg.project.unique.controller;

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.shzg.framework.aspectj.lang.annotation.Log;
import com.shzg.framework.aspectj.lang.enums.BusinessType;
import com.shzg.project.unique.domain.WornUniqueCodeEvent;
import com.shzg.project.unique.service.IWornUniqueCodeEventService;
import com.shzg.framework.web.controller.BaseController;
import com.shzg.framework.web.domain.AjaxResult;
import com.shzg.common.utils.poi.ExcelUtil;
import com.shzg.framework.web.page.TableDataInfo;

/**
 * 唯一码事件记录Controller
 * 
 * @author shzg
 * @date 2026-03-17
 */
@RestController
@RequestMapping("/unique/event")
public class WornUniqueCodeEventController extends BaseController
{
    @Autowired
    private IWornUniqueCodeEventService wornUniqueCodeEventService;

    /**
     * 查询唯一码事件记录列表
     */
    @PreAuthorize("@ss.hasPermi('unique:event:list')")
    @GetMapping("/list")
    public TableDataInfo list(WornUniqueCodeEvent wornUniqueCodeEvent)
    {
        startPage();
        List<WornUniqueCodeEvent> list = wornUniqueCodeEventService.selectWornUniqueCodeEventList(wornUniqueCodeEvent);
        return getDataTable(list);
    }

    /**
     * 导出唯一码事件记录列表
     */
    @PreAuthorize("@ss.hasPermi('unique:event:export')")
    @Log(title = "唯一码事件记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WornUniqueCodeEvent wornUniqueCodeEvent)
    {
        List<WornUniqueCodeEvent> list = wornUniqueCodeEventService.selectWornUniqueCodeEventList(wornUniqueCodeEvent);
        ExcelUtil<WornUniqueCodeEvent> util = new ExcelUtil<WornUniqueCodeEvent>(WornUniqueCodeEvent.class);
        util.exportExcel(response, list, "唯一码事件记录数据");
    }

    /**
     * 获取唯一码事件记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('unique:event:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wornUniqueCodeEventService.selectWornUniqueCodeEventById(id));
    }

    /**
     * 新增唯一码事件记录
     */
    @PreAuthorize("@ss.hasPermi('unique:event:add')")
    @Log(title = "唯一码事件记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WornUniqueCodeEvent wornUniqueCodeEvent)
    {
        return toAjax(wornUniqueCodeEventService.insertWornUniqueCodeEvent(wornUniqueCodeEvent));
    }

    /**
     * 修改唯一码事件记录
     */
    @PreAuthorize("@ss.hasPermi('unique:event:edit')")
    @Log(title = "唯一码事件记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WornUniqueCodeEvent wornUniqueCodeEvent)
    {
        return toAjax(wornUniqueCodeEventService.updateWornUniqueCodeEvent(wornUniqueCodeEvent));
    }

    /**
     * 删除唯一码事件记录
     */
    @PreAuthorize("@ss.hasPermi('unique:event:remove')")
    @Log(title = "唯一码事件记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wornUniqueCodeEventService.deleteWornUniqueCodeEventByIds(ids));
    }
}
