package com.fs.company.controller;

import java.util.List;

import com.fs.company.param.CompanyDomainBindUserParam;
import com.fs.company.vo.CompanyDomainBindUserVo;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.company.domain.CompanyDomainBindUser;
import com.fs.company.service.ICompanyDomainBindUserService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 企业域名分配中间表Controller
 *
 * @author fs
 * @date 2025-06-19
 */
@RestController
@RequestMapping("/company/companyBindUser")
public class CompanyDomainBindUserController extends BaseController {
    @Autowired
    private ICompanyDomainBindUserService companyDomainBindUserService;

    /**
     * 查询企业域名分配中间表列表
     */
    @PreAuthorize("@ss.hasPermi('company:companyBindUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanyDomainBindUserParam companyDomainBindUser) {
        startPage();
        List<CompanyDomainBindUserVo> list = companyDomainBindUserService.selectCompanyDomainBindUserList(companyDomainBindUser);
        return getDataTable(list);
    }

    /**
     * 导出企业域名分配中间表列表
     */
    @PreAuthorize("@ss.hasPermi('company:companyBindUser:export')")
    @Log(title = "企业域名分配中间表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CompanyDomainBindUserParam companyDomainBindUser) {
        List<CompanyDomainBindUserVo> list = companyDomainBindUserService.selectCompanyDomainBindUserList(companyDomainBindUser);
        ExcelUtil<CompanyDomainBindUserVo> util = new ExcelUtil<CompanyDomainBindUserVo>(CompanyDomainBindUserVo.class);
        return util.exportExcel(list, "企业域名分配中间表数据");
    }

    /**
     * 获取企业域名分配中间表详细信息
     */
    @PreAuthorize("@ss.hasPermi('company:companyBindUser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(companyDomainBindUserService.selectCompanyDomainBindUserById(id));
    }

    /**
     * 新增企业域名分配中间表
     */
    @PreAuthorize("@ss.hasPermi('company:companyBindUser:add')")
    @Log(title = "企业域名分配中间表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanyDomainBindUser companyDomainBindUser) {
        return toAjax(companyDomainBindUserService.insertCompanyDomainBindUser(companyDomainBindUser));
    }

    /**
     * 修改企业域名分配中间表
     */
    @PreAuthorize("@ss.hasPermi('company:companyBindUser:edit')")
    @Log(title = "企业域名分配中间表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyDomainBindUser companyDomainBindUser) {
        return toAjax(companyDomainBindUserService.updateCompanyDomainBindUser(companyDomainBindUser));
    }

    /**
     * 删除企业域名分配中间表
     */
    @PreAuthorize("@ss.hasPermi('company:companyBindUser:remove')")
    @Log(title = "企业域名分配中间表", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(companyDomainBindUserService.deleteCompanyDomainBindUserByIds(ids));
    }
}
