package com.ruoyi.web.controller.common;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.InvestigateTable;
import com.ruoyi.system.domain.InvestigateUser;
import com.ruoyi.system.service.IInvestigateTableService;
import com.ruoyi.system.service.IInvestigateUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: tjf
 * @Date: 2023/10/13 17:15
 * @Describe:
 */
@RestController
@RequestMapping("/sendSms")
public class SendSmsController {

    @Autowired
    private IInvestigateUserService investigateUserService;
    @Autowired
    private IInvestigateTableService investigateTableService;

    /**
     * 给对应考察团发送密码短信
     *
     * @param investigateUser
     * @return
     */
    @PostMapping("/investigateTable")
    public AjaxResult sendSmsInvestigateTable(@RequestBody InvestigateUser investigateUser) {
        return investigateUserService.sendSmsInvestigateTable(investigateUser);
    }

    /**
     * 给对应考察团发送通知短信
     *
     * @param
     * @return
     */
    @PostMapping("/sendBatchSmsTable")
    public AjaxResult investigateTableNotice(@RequestBody InvestigateTable investigateTable) {
        Long investigateTableId = investigateTable.getInvestigateTableId();
        List<InvestigateUser> investigateUserList = investigateTable.getInvestigateUserList();
        investigateTableService.sendBatchSmsTable(investigateTableId, investigateUserList);
        return AjaxResult.success();
    }

    /**
     * 给对应考察团发送更新通知短信
     *
     * @param
     * @return
     */
    @PostMapping("/sendBatchSmsTableUpdate")
    public AjaxResult sendBatchSmsTableUpdate(@RequestBody InvestigateTable investigateTable) {
        Long investigateTableId = investigateTable.getInvestigateTableId();
        List<InvestigateUser> investigateUserList = investigateTable.getInvestigateUserList();
        investigateTableService.sendBatchSmsTableUpdate(investigateTableId, investigateUserList);
        return AjaxResult.success();
    }
}