package com.hotwj.platform.operationManagement.smsSendDetail.controller;

import com.hotwj.platform.operationManagement.smsSendDetail.domain.bo.HotSmsSendDetailBo;
import com.hotwj.platform.operationManagement.smsSendDetail.domain.vo.HotSmsSendDetailVo;
import com.hotwj.platform.operationManagement.smsSendDetail.service.IHotSmsSendDetailService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
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 2026-04-28
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/operationManagement/smsSendDetail")
@Tag(name = "短信发送明细", description = "短信发送明细管理")
public class HotSmsSendDetailController extends BaseController {

    private final IHotSmsSendDetailService hotSmsSendDetailService;

    /**
     * 查询短信发送明细列表
     */
    //@SaCheckPermission("operationManagement:smsSendDetail:list")
    @GetMapping("/list")
    @Operation(summary = "分页查询短信发送明细列表")
    public TableDataInfo<HotSmsSendDetailVo> list(HotSmsSendDetailBo bo, PageQuery pageQuery) {
        return hotSmsSendDetailService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出短信发送明细列表
     */
    //@SaCheckPermission("operationManagement:smsSendDetail:export")
    @Log(title = "短信发送明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出短信发送明细列表")
    public void export(HotSmsSendDetailBo bo, HttpServletResponse response) {
        List<HotSmsSendDetailVo> list = hotSmsSendDetailService.queryList(bo);
        ExcelUtil.exportExcel(list, "短信发送明细", HotSmsSendDetailVo.class, response);
    }

    /**
     * 获取短信发送明细详细信息
     *
     * @param id 主键
     */
    //@SaCheckPermission("operationManagement:smsSendDetail:query")
    @GetMapping("/{id}")
    @Operation(summary = "获取短信发送明细详细信息")
    public R<HotSmsSendDetailVo> getInfo(@NotNull(message = "主键不能为空")
                                         @Parameter(name = "id", description = "主键", required = true, example = "1")
                                         @PathVariable Long id) {
        return R.ok(hotSmsSendDetailService.queryById(id));
    }

    /**
     * 新增短信发送明细
     */
    //@SaCheckPermission("operationManagement:smsSendDetail:add")
    @Log(title = "短信发送明细", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增短信发送明细")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotSmsSendDetailBo bo) {
        return toAjax(hotSmsSendDetailService.insertByBo(bo));
    }

    /**
     * 修改短信发送明细
     */
    //@SaCheckPermission("operationManagement:smsSendDetail:edit")
    @Log(title = "短信发送明细", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改短信发送明细")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotSmsSendDetailBo bo) {
        return toAjax(hotSmsSendDetailService.updateByBo(bo));
    }

    /**
     * 删除短信发送明细
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("operationManagement:smsSendDetail:remove")
    @Log(title = "短信发送明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除短信发送明细")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @Parameter(name = "ids", description = "主键串", required = true, example = "1,2,3")
                          @PathVariable Long[] ids) {
        return toAjax(hotSmsSendDetailService.deleteWithValidByIds(List.of(ids), true));
    }
}
