package com.ruoyi.web.controller.jarvis;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
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.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.jarvis.domain.TgScalperPhone;
import com.ruoyi.jarvis.service.ITgScalperPhoneService;

/**
 * TG 管理 - 黄牛电话库
 */
@RestController
@RequestMapping("/jarvis/tgScalperPhone")
public class TgScalperPhoneController extends BaseController
{
    @Autowired
    private ITgScalperPhoneService tgScalperPhoneService;

    @PreAuthorize("@ss.hasPermi('jarvis:tg:scalperPhone:list')")
    @GetMapping("/list")
    public TableDataInfo list(TgScalperPhone q)
    {
        startPage();
        List<TgScalperPhone> list = tgScalperPhoneService.selectTgScalperPhoneList(q);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('jarvis:tg:scalperPhone:export')")
    @Log(title = "TG黄牛电话库", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TgScalperPhone q)
    {
        List<TgScalperPhone> list = tgScalperPhoneService.selectTgScalperPhoneList(q);
        ExcelUtil<TgScalperPhone> util = new ExcelUtil<>(TgScalperPhone.class);
        return util.exportExcel(list, "TG黄牛电话库");
    }

    @PreAuthorize("@ss.hasPermi('jarvis:tg:scalperPhone:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tgScalperPhoneService.selectTgScalperPhoneById(id));
    }

    @PreAuthorize("@ss.hasPermi('jarvis:tg:scalperPhone:add')")
    @Log(title = "TG黄牛电话库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TgScalperPhone row)
    {
        return toAjax(tgScalperPhoneService.insertTgScalperPhone(row));
    }

    @PreAuthorize("@ss.hasPermi('jarvis:tg:scalperPhone:edit')")
    @Log(title = "TG黄牛电话库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TgScalperPhone row)
    {
        return toAjax(tgScalperPhoneService.updateTgScalperPhone(row));
    }

    @PreAuthorize("@ss.hasPermi('jarvis:tg:scalperPhone:remove')")
    @Log(title = "TG黄牛电话库", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tgScalperPhoneService.deleteTgScalperPhoneByIds(ids));
    }
}
