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

import com.hotwj.platform.operationManagement.smsRechargeRecord.domain.bo.HotSmsRechargeRecordBo;
import com.hotwj.platform.operationManagement.smsRechargeRecord.domain.vo.HotSmsRechargeRecordVo;
import com.hotwj.platform.operationManagement.smsRechargeRecord.service.IHotSmsRechargeRecordService;
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/smsRechargeRecord")
@Tag(name = "短信充值记录", description = "短信充值记录管理")
public class HotSmsRechargeRecordController extends BaseController {

    private final IHotSmsRechargeRecordService hotSmsRechargeRecordService;

    /**
     * 查询短信充值记录列表
     */
    //@SaCheckPermission("operationManagement:smsRechargeRecord:list")
    @GetMapping("/list")
    @Operation(summary = "分页查询短信充值记录列表")
    public TableDataInfo<HotSmsRechargeRecordVo> list(HotSmsRechargeRecordBo bo, PageQuery pageQuery) {
        return hotSmsRechargeRecordService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出短信充值记录列表
     */
    //@SaCheckPermission("operationManagement:smsRechargeRecord:export")
    @Log(title = "短信充值记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出短信充值记录列表")
    public void export(HotSmsRechargeRecordBo bo, HttpServletResponse response) {
        List<HotSmsRechargeRecordVo> list = hotSmsRechargeRecordService.queryList(bo);
        ExcelUtil.exportExcel(list, "短信充值记录", HotSmsRechargeRecordVo.class, response);
    }

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

    /**
     * 新增短信充值记录
     */
    //@SaCheckPermission("operationManagement:smsRechargeRecord:add")
    @Log(title = "短信充值记录", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增短信充值记录")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotSmsRechargeRecordBo bo) {
        return toAjax(hotSmsRechargeRecordService.insertByBo(bo));
    }

    /**
     * 修改短信充值记录
     */
    //@SaCheckPermission("operationManagement:smsRechargeRecord:edit")
    @Log(title = "短信充值记录", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改短信充值记录")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotSmsRechargeRecordBo bo) {
        return toAjax(hotSmsRechargeRecordService.updateByBo(bo));
    }

    /**
     * 删除短信充值记录
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("operationManagement:smsRechargeRecord: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(hotSmsRechargeRecordService.deleteWithValidByIds(List.of(ids), true));
    }
}
