package com.ruoyi.system.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.vo.ZsOperationSendconfigVo;
import com.ruoyi.system.domain.bo.ZsOperationSendconfigBo;
import com.ruoyi.system.service.IZsOperationSendconfigService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 发送信息配置
 *
 * @author 王强
 * @date 2025-05-09
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/operationSendconfig")
public class ZsOperationSendconfigController extends BaseController {

    private final IZsOperationSendconfigService iZsOperationSendconfigService;

    /**
     * 查询发送信息配置列表
     */
    @SaCheckPermission("system:operationSendconfig:list")
    @GetMapping("/list")
    public TableDataInfo<ZsOperationSendconfigVo> list(ZsOperationSendconfigBo bo, PageQuery pageQuery) {
        return iZsOperationSendconfigService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出发送信息配置列表
     */
    @SaCheckPermission("system:operationSendconfig:export")
    @Log(title = "发送信息配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(ZsOperationSendconfigBo bo, HttpServletResponse response) {
        List<ZsOperationSendconfigVo> list = iZsOperationSendconfigService.queryList(bo);
        ExcelUtil.exportExcel(list, "发送信息配置", ZsOperationSendconfigVo.class, response);
    }

    /**
     * 获取发送信息配置详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("system:operationSendconfig:query")
    @GetMapping("/{id}")
    public R<ZsOperationSendconfigVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long id) {
        return R.ok(iZsOperationSendconfigService.queryById(id));
    }

    /**
     * 新增发送信息配置
     */
    @SaCheckPermission("system:operationSendconfig:add")
    @Log(title = "发送信息配置", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody ZsOperationSendconfigBo bo) {
        return toAjax(iZsOperationSendconfigService.insertByBo(bo));
    }

    /**
     * 修改发送信息配置
     */
    @SaCheckPermission("system:operationSendconfig:edit")
    @Log(title = "发送信息配置", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody ZsOperationSendconfigBo bo) {
        return toAjax(iZsOperationSendconfigService.updateByBo(bo));
    }

    /**
     * 删除发送信息配置
     *
     * @param ids 主键串
     */
    @SaCheckPermission("system:operationSendconfig:remove")
    @Log(title = "发送信息配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(iZsOperationSendconfigService.deleteWithValidByIds(Arrays.asList(ids), true));
    }
}
