package com.hotwj.platform.securityManagement.violationInterview.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.hotwj.platform.securityManagement.violationInterview.domain.bo.HotViolationInterviewBo;
import com.hotwj.platform.securityManagement.violationInterview.domain.vo.HotViolationInterviewVo;
import com.hotwj.platform.securityManagement.violationInterview.service.IHotViolationInterviewService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 违规约谈记录
 *
 * @author shihongwei
 * @date 2025-12-17
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/securityManagement/violationInterview")
@Tag(name = "违规约谈记录", description = "违规约谈记录管理")
public class HotViolationInterviewController extends BaseController {

    private final IHotViolationInterviewService hotViolationInterviewService;

    /**
     * 查询违规约谈记录列表
     */
    //@SaCheckPermission("securityManagement:violationInterview:list")
    @GetMapping("/list")
    @Operation(summary = "查询违规约谈记录列表")
    public TableDataInfo<HotViolationInterviewVo> list(HotViolationInterviewBo bo, PageQuery pageQuery) {
        return hotViolationInterviewService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出违规约谈记录列表
     */
    //@SaCheckPermission("securityManagement:violationInterview:export")
    @Log(title = "违规约谈记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出违规约谈记录列表")
    public void export(HotViolationInterviewBo bo, HttpServletResponse response) {
        List<HotViolationInterviewVo> list = hotViolationInterviewService.queryList(bo);
        ExcelUtil.exportExcel(list, "违规约谈记录", HotViolationInterviewVo.class, response);
    }

    /**
     * 获取违规约谈记录详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("securityManagement:violationInterview:query")
    @GetMapping("/{id}")
    @Operation(summary = "获取违规约谈记录详细信息")
    public R<HotViolationInterviewVo> getInfo(@NotNull(message = "主键不能为空")
                                              @PathVariable Long id) {
        return R.ok(hotViolationInterviewService.queryById(id));
    }

    /**
     * 新增违规约谈记录
     */
    //@SaCheckPermission("securityManagement:violationInterview:add")
    @Log(title = "违规约谈记录", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增违规约谈记录")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotViolationInterviewBo bo) {
        return toAjax(hotViolationInterviewService.insertByBo(bo));
    }

    /**
     * 修改违规约谈记录
     */
    //@SaCheckPermission("securityManagement:violationInterview:edit")
    @Log(title = "违规约谈记录", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改违规约谈记录")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotViolationInterviewBo bo) {
        return toAjax(hotViolationInterviewService.updateByBo(bo));
    }

    /**
     * 删除违规约谈记录
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("securityManagement:violationInterview:remove")
    @Log(title = "违规约谈记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除违规约谈记录")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(hotViolationInterviewService.deleteWithValidByIds(List.of(ids), true));
    }
}
