package com.ruoyi.web.controller.projectV2.common;

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

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.projectV2.common.SendSmsConfig;
import com.ruoyi.system.service.projectV2.common.ISendSmsConfigService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 短信人员配置Controller
 * 
 * @author boman
 * @date 2023-03-07
 */
@RestController
@RequestMapping("/projectV2/config")
public class SendSmsConfigController extends BaseController
{
    @Autowired
    private ISendSmsConfigService sendSmsConfigService;

    /**
     * 查询短信人员配置列表
     */
    @PreAuthorize("@ss.hasPermi('projectV2:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(SendSmsConfig sendSmsConfig)
    {
        startPage();
        List<SendSmsConfig> list = sendSmsConfigService.selectSendSmsConfigList(sendSmsConfig);
        return getDataTable(list);
    }

    /**
     * 导出短信人员配置列表
     */
    @PreAuthorize("@ss.hasPermi('projectV2:config:export')")
    @Log(title = "短信人员配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SendSmsConfig sendSmsConfig)
    {
        List<SendSmsConfig> list = sendSmsConfigService.selectSendSmsConfigList(sendSmsConfig);
        ExcelUtil<SendSmsConfig> util = new ExcelUtil<SendSmsConfig>(SendSmsConfig.class);
        util.exportExcel(response, list, "短信人员配置数据");
    }

    /**
     * 获取短信人员配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectV2:config:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sendSmsConfigService.selectSendSmsConfigById(id));
    }

    /**
     * 新增短信人员配置
     */
    @PreAuthorize("@ss.hasPermi('projectV2:config:add')")
    @Log(title = "短信人员配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SendSmsConfig sendSmsConfig)
    {
        return toAjax(sendSmsConfigService.insertSendSmsConfig(sendSmsConfig));
    }

    /**
     * 修改短信人员配置
     */
    @PreAuthorize("@ss.hasPermi('projectV2:config:edit')")
    @Log(title = "短信人员配置", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody SendSmsConfig sendSmsConfig)
    {
        return toAjax(sendSmsConfigService.updateSendSmsConfig(sendSmsConfig));
    }

    /**
     * 删除短信人员配置
     */
    @PreAuthorize("@ss.hasPermi('projectV2:config:remove')")
    @Log(title = "短信人员配置", businessType = BusinessType.DELETE)
	@GetMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sendSmsConfigService.deleteSendSmsConfigByIds(ids));
    }
}
