package com.xinelu.manage.controller.shortmessagesendrecord;

import com.xinelu.common.annotation.Log;
import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.core.page.TableDataInfo;
import com.xinelu.common.enums.BusinessType;
import com.xinelu.common.utils.poi.ExcelUtil;
import com.xinelu.manage.domain.shortmessagesendrecord.ShortMessageSendRecord;
import com.xinelu.manage.service.shortmessagesendrecord.IShortMessageSendRecordService;
import com.xinelu.manage.vo.shortmessagesendrecord.ShortMessageSendRecordVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 短信发送结果记录Controller
 *
 * @author zh
 * @date 2026-04-17
 */
@RestController
@RequestMapping("/system/shortMessageSendRecord")
public class ShortMessageSendRecordController extends BaseController {
    @Resource
    private IShortMessageSendRecordService shortMessageSendRecordService;

    /**
     * 查询短信发送结果记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:shortMessageSendRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShortMessageSendRecordVo shortMessageSendRecord) {
        startPage();
        List<ShortMessageSendRecordVo> list = shortMessageSendRecordService.selectShortMessageSendRecordList(shortMessageSendRecord);
        return getDataTable(list);
    }

    /**
     * 导出短信发送结果记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:shortMessageSendRecord:export')")
    @Log(title = "短信发送结果记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShortMessageSendRecordVo shortMessageSendRecord) {
        List<ShortMessageSendRecordVo> list = shortMessageSendRecordService.selectShortMessageSendRecordList(shortMessageSendRecord);
        ExcelUtil<ShortMessageSendRecordVo> util = new ExcelUtil<>(ShortMessageSendRecordVo.class);
        util.exportExcel(response, list, "短信发送结果记录数据");
    }

    /**
     * 获取短信发送结果记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:shortMessageSendRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(shortMessageSendRecordService.selectShortMessageSendRecordById(id));
    }

    /**
     * 新增短信发送结果记录
     */
    @PreAuthorize("@ss.hasPermi('system:shortMessageSendRecord:add')")
    @Log(title = "短信发送结果记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShortMessageSendRecord shortMessageSendRecord) {
        return toAjax(shortMessageSendRecordService.insertShortMessageSendRecord(shortMessageSendRecord));
    }

    /**
     * 修改短信发送结果记录
     */
    @PreAuthorize("@ss.hasPermi('system:shortMessageSendRecord:edit')")
    @Log(title = "短信发送结果记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShortMessageSendRecord shortMessageSendRecord) {
        return toAjax(shortMessageSendRecordService.updateShortMessageSendRecord(shortMessageSendRecord));
    }

    /**
     * 删除短信发送结果记录
     */
    @PreAuthorize("@ss.hasPermi('system:shortMessageSendRecord:remove')")
    @Log(title = "短信发送结果记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(shortMessageSendRecordService.deleteShortMessageSendRecordByIds(ids));
    }

    /**
     * 短信推送统计
     */
    @GetMapping("/messageCount")
    public AjaxResult messageCount() {
        return shortMessageSendRecordService.messageCount();
    }
}
