package com.xinelu.manage.controller.batchsendtaskrecordinfo;

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.batchsendtaskrecordinfo.BatchSendTaskRecordInfo;
import com.xinelu.manage.service.batchsendtaskrecordinfo.IBatchSendTaskRecordInfoService;
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-26
 */
@RestController
@RequestMapping("/system/batchSendTaskRecordInfo")
public class BatchSendTaskRecordInfoController extends BaseController {
    @Resource
    private IBatchSendTaskRecordInfoService batchSendTaskRecordInfoService;

    /**
     * 查询批量推送任务记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:batchSendTaskRecordInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(BatchSendTaskRecordInfo batchSendTaskRecordInfo) {
        startPage();
        List<BatchSendTaskRecordInfo> list = batchSendTaskRecordInfoService.selectBatchSendTaskRecordInfoList(batchSendTaskRecordInfo);
        return getDataTable(list);
    }

    /**
     * 导出批量推送任务记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:batchSendTaskRecordInfo:export')")
    @Log(title = "批量推送任务记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BatchSendTaskRecordInfo batchSendTaskRecordInfo) {
        List<BatchSendTaskRecordInfo> list = batchSendTaskRecordInfoService.selectBatchSendTaskRecordInfoList(batchSendTaskRecordInfo);
        ExcelUtil<BatchSendTaskRecordInfo> util = new ExcelUtil<>(BatchSendTaskRecordInfo.class);
        util.exportExcel(response, list, "批量推送任务记录数据");
    }

    /**
     * 获取批量推送任务记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:batchSendTaskRecordInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(batchSendTaskRecordInfoService.selectBatchSendTaskRecordInfoById(id));
    }

    /**
     * 新增批量推送任务记录
     */
    @PreAuthorize("@ss.hasPermi('system:batchSendTaskRecordInfo:add')")
    @Log(title = "批量推送任务记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BatchSendTaskRecordInfo batchSendTaskRecordInfo) {
        return toAjax(batchSendTaskRecordInfoService.insertBatchSendTaskRecordInfo(batchSendTaskRecordInfo));
    }

    /**
     * 修改批量推送任务记录
     */
    @PreAuthorize("@ss.hasPermi('system:batchSendTaskRecordInfo:edit')")
    @Log(title = "批量推送任务记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BatchSendTaskRecordInfo batchSendTaskRecordInfo) {
        return toAjax(batchSendTaskRecordInfoService.updateBatchSendTaskRecordInfo(batchSendTaskRecordInfo));
    }

    /**
     * 删除批量推送任务记录
     */
    @PreAuthorize("@ss.hasPermi('system:batchSendTaskRecordInfo:remove')")
    @Log(title = "批量推送任务记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(batchSendTaskRecordInfoService.deleteBatchSendTaskRecordInfoByIds(ids));
    }

    /**
     * 获取短信或电话模板
     */
    @GetMapping("/getTemplate")
    public List<BatchSendTaskRecordInfo> getTemplate(String batchTaskSource) {
        return batchSendTaskRecordInfoService.getTemplate(batchTaskSource);
    }
}
