package com.zyc.web.controller.api;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.zyc.common.annotation.Log;
import com.zyc.common.core.controller.BaseController;
import com.zyc.common.core.domain.AjaxResult;
import com.zyc.common.enums.BusinessType;
import com.zyc.system.domain.DomainResolution;
import com.zyc.system.service.IDomainResolutionService;
import com.zyc.common.utils.poi.ExcelUtil;
import com.zyc.common.core.page.TableDataInfo;

/**
 * 域名解析Controller
 * 
 * @author zyc
 * @date 2024-12-26
 */
@RestController
@RequestMapping("/system/DomainResolutionController")
public class DomainResolutionController extends BaseController
{
    @Autowired
    private IDomainResolutionService domainResolutionService;

    /**
     * 查询域名解析列表
     */
    @PreAuthorize("@ss.hasPermi('system:resolution:list')")
    @GetMapping("/list")
    public TableDataInfo list(DomainResolution domainResolution)
    {
        startPage();
        List<DomainResolution> list = domainResolutionService.selectDomainResolutionList(domainResolution);
        return getDataTable(list);
    }

    /**
     * 导出域名解析列表
     */
    @PreAuthorize("@ss.hasPermi('system:resolution:export')")
    @Log(title = "域名解析", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DomainResolution domainResolution)
    {
        List<DomainResolution> list = domainResolutionService.selectDomainResolutionList(domainResolution);
        ExcelUtil<DomainResolution> util = new ExcelUtil<DomainResolution>(DomainResolution.class);
        util.exportExcel(response, list, "域名解析数据");
    }

    /**
     * 获取域名解析详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:resolution:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(domainResolutionService.selectDomainResolutionById(id));
    }

    /**
     * 新增域名解析
     */
    @PreAuthorize("@ss.hasPermi('system:resolution:add')")
    @Log(title = "域名解析", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DomainResolution domainResolution)
    {
        return toAjax(domainResolutionService.insertDomainResolution(domainResolution));
    }

    /**
     * 修改域名解析
     */
    @PreAuthorize("@ss.hasPermi('system:resolution:edit')")
    @Log(title = "域名解析", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DomainResolution domainResolution)
    {
        return toAjax(domainResolutionService.updateDomainResolution(domainResolution));
    }

    /**
     * 删除域名解析
     */
    @PreAuthorize("@ss.hasPermi('system:resolution:remove')")
    @Log(title = "域名解析", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(domainResolutionService.deleteDomainResolutionByIds(ids));
    }
}
