package com.xinelu.manage.controller.subscribemessagesendrecord;

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.subscribemessagesendrecord.SubscribeMessageSendRecord;
import com.xinelu.manage.service.subscribemessagesendrecord.ISubscribeMessageSendRecordService;
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 xinelu
 * @date 2024-03-19
 */
@RestController
@RequestMapping("/manage/sendResult")
public class SubscribeMessageSendRecordController extends BaseController {
    @Resource
    private ISubscribeMessageSendRecordService subscribeMessageSendRecordService;

    /**
     * 查询微信小程序订阅消息发送结果记录列表
     */
    @PreAuthorize("@ss.hasPermi('manage:sendResult:list')")
    @GetMapping("/list")
    public TableDataInfo list(SubscribeMessageSendRecord subscribeMessageSendRecord) {
        startPage();
        List<SubscribeMessageSendRecord> list = subscribeMessageSendRecordService.selectSubscribeMessageSendRecordList(subscribeMessageSendRecord);
        return getDataTable(list);
    }

    /**
     * 导出微信小程序订阅消息发送结果记录列表
     */
    @PreAuthorize("@ss.hasPermi('manage:sendResult:export')")
    @Log(title = "微信小程序订阅消息发送结果记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SubscribeMessageSendRecord subscribeMessageSendRecord) {
        List<SubscribeMessageSendRecord> list = subscribeMessageSendRecordService.selectSubscribeMessageSendRecordList(subscribeMessageSendRecord);
        ExcelUtil<SubscribeMessageSendRecord> util = new ExcelUtil<>(SubscribeMessageSendRecord.class);
        util.exportExcel(response, list, "微信小程序订阅消息发送结果记录数据");
    }

    /**
     * 获取微信小程序订阅消息发送结果记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:sendResult:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(subscribeMessageSendRecordService.selectSubscribeMessageSendRecordById(id));
    }

    /**
     * 新增微信小程序订阅消息发送结果记录
     */
    @PreAuthorize("@ss.hasPermi('manage:sendResult:add')")
    @Log(title = "微信小程序订阅消息发送结果记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SubscribeMessageSendRecord subscribeMessageSendRecord) {
        return toAjax(subscribeMessageSendRecordService.insertSubscribeMessageSendRecord(subscribeMessageSendRecord));
    }

    /**
     * 修改微信小程序订阅消息发送结果记录
     */
    @PreAuthorize("@ss.hasPermi('manage:sendResult:edit')")
    @Log(title = "微信小程序订阅消息发送结果记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SubscribeMessageSendRecord subscribeMessageSendRecord) {
        return toAjax(subscribeMessageSendRecordService.updateSubscribeMessageSendRecord(subscribeMessageSendRecord));
    }

    /**
     * 删除微信小程序订阅消息发送结果记录
     */
    @PreAuthorize("@ss.hasPermi('manage:sendResult:remove')")
    @Log(title = "微信小程序订阅消息发送结果记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(subscribeMessageSendRecordService.deleteSubscribeMessageSendRecordByIds(ids));
    }
}
