package com.ruoyi.web.controller.jarvis;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
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.jarvis.service.IPhoneReplaceConfigService;

/**
 * 手机号替换配置Controller
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/jarvis/phoneReplaceConfig")
public class PhoneReplaceConfigController extends BaseController
{
    @Autowired
    private IPhoneReplaceConfigService phoneReplaceConfigService;

    /**
     * 获取指定类型的手机号列表
     */
    @GetMapping("/{type}")
    public AjaxResult getPhoneList(@PathVariable("type") String type)
    {
        List<String> phoneList = phoneReplaceConfigService.getPhoneList(type);
        return AjaxResult.success(phoneList);
    }

    /**
     * 设置指定类型的手机号列表
     */
    @Log(title = "手机号替换配置", businessType = BusinessType.UPDATE)
    @PutMapping("/{type}")
    public AjaxResult setPhoneList(@PathVariable("type") String type, @RequestBody List<String> phoneList)
    {
        return toAjax(phoneReplaceConfigService.setPhoneList(type, phoneList));
    }

    /**
     * 添加手机号到指定类型
     */
    @Log(title = "手机号替换配置", businessType = BusinessType.UPDATE)
    @PostMapping("/{type}/add")
    public AjaxResult addPhone(@PathVariable("type") String type, @RequestBody String phone)
    {
        return toAjax(phoneReplaceConfigService.addPhone(type, phone));
    }

    /**
     * 从指定类型删除手机号
     */
    @Log(title = "手机号替换配置", businessType = BusinessType.UPDATE)
    @PostMapping("/{type}/remove")
    public AjaxResult removePhone(@PathVariable("type") String type, @RequestBody String phone)
    {
        return toAjax(phoneReplaceConfigService.removePhone(type, phone));
    }
}

