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

import com.hotwj.platform.operationManagement.smsPackagePurchase.domain.bo.HotSmsPackagePurchaseBo;
import com.hotwj.platform.operationManagement.smsPackagePurchase.domain.vo.HotSmsPackagePurchaseVo;
import com.hotwj.platform.operationManagement.smsPackagePurchase.service.IHotSmsPackagePurchaseService;
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/smsPackagePurchase")
@Tag(name = "短信套餐购买记录", description = "短信套餐购买记录管理")
public class HotSmsPackagePurchaseController extends BaseController {

    private final IHotSmsPackagePurchaseService hotSmsPackagePurchaseService;

    /**
     * 查询短信套餐购买记录列表
     */
    //@SaCheckPermission("operationManagement:smsPackagePurchase:list")
    @GetMapping("/list")
    @Operation(summary = "分页查询短信套餐购买记录列表")
    public TableDataInfo<HotSmsPackagePurchaseVo> list(HotSmsPackagePurchaseBo bo, PageQuery pageQuery) {
        return hotSmsPackagePurchaseService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出短信套餐购买记录列表
     */
    //@SaCheckPermission("operationManagement:smsPackagePurchase:export")
    @Log(title = "短信套餐购买记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出短信套餐购买记录列表")
    public void export(HotSmsPackagePurchaseBo bo, HttpServletResponse response) {
        List<HotSmsPackagePurchaseVo> list = hotSmsPackagePurchaseService.queryList(bo);
        ExcelUtil.exportExcel(list, "短信套餐购买记录", HotSmsPackagePurchaseVo.class, response);
    }

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

    /**
     * 新增短信套餐购买记录
     */
    //@SaCheckPermission("operationManagement:smsPackagePurchase:add")
    @Log(title = "短信套餐购买记录", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增短信套餐购买记录")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody HotSmsPackagePurchaseBo bo) {
        return toAjax(hotSmsPackagePurchaseService.insertByBo(bo));
    }

    /**
     * 修改短信套餐购买记录
     */
    //@SaCheckPermission("operationManagement:smsPackagePurchase:edit")
    @Log(title = "短信套餐购买记录", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改短信套餐购买记录")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody HotSmsPackagePurchaseBo bo) {
        return toAjax(hotSmsPackagePurchaseService.updateByBo(bo));
    }

    /**
     * 删除短信套餐购买记录
     *
     * @param ids 主键串
     */
    //@SaCheckPermission("operationManagement:smsPackagePurchase: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(hotSmsPackagePurchaseService.deleteWithValidByIds(List.of(ids), true));
    }
}
