package com.ruoyi.ibs.list.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.ibs.list.domain.SysGroupBusiness;
import com.ruoyi.ibs.list.service.ISysGroupBusinessService;
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.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.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 分群客户关联关系,导入的企业与商户客群用户存放在这里Controller
 * 
 * @author ruoyi
 * @date 2024-10-29
 */
@RestController
@RequestMapping("/system/group/business")
public class SysGroupBusinessController extends BaseController
{
    @Autowired
    private ISysGroupBusinessService sysGroupBusinessService;

    /**
     * 查询分群客户关联关系,导入的企业与商户客群用户存放在这里列表
     */
    @PreAuthorize("@ss.hasPermi('system:business:list')")
    @Log(title = "走访-查询分群客户关联关系", businessType = BusinessType.EXPORT)
    @GetMapping("/list")
    public TableDataInfo list(SysGroupBusiness sysGroupBusiness)
    {
        startPage();
        List<SysGroupBusiness> list = sysGroupBusinessService.selectSysGroupBusinessList(sysGroupBusiness);
        return getDataTable(list);
    }

    /**
     * 导出分群客户关联关系,导入的企业与商户客群用户存放在这里列表
     */
    @PreAuthorize("@ss.hasPermi('system:business:export')")
    @Log(title = "走访-分群客户关联关系,导入的企业与商户客群用户存放在这里", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysGroupBusiness sysGroupBusiness)
    {
        List<SysGroupBusiness> list = sysGroupBusinessService.selectSysGroupBusinessList(sysGroupBusiness);
        ExcelUtil<SysGroupBusiness> util = new ExcelUtil<SysGroupBusiness>(SysGroupBusiness.class);
        util.exportExcel(response, list, "分群客户关联关系,导入的企业与商户客群用户存放在这里数据");
    }

    /**
     * 获取分群客户关联关系,导入的企业与商户客群用户存放在这里详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:business:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysGroupBusinessService.selectSysGroupBusinessById(id));
    }

    /**
     * 新增分群客户关联关系,导入的企业与商户客群用户存放在这里
     */
    @PreAuthorize("@ss.hasPermi('system:business:add')")
    @Log(title = "走访-分群客户关联关系,导入的企业与商户客群用户存放在这里", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysGroupBusiness sysGroupBusiness)
    {
        return toAjax(sysGroupBusinessService.insertSysGroupBusiness(sysGroupBusiness));
    }

    /**
     * 修改分群客户关联关系,导入的企业与商户客群用户存放在这里
     */
    @PreAuthorize("@ss.hasPermi('system:business:edit')")
    @Log(title = "走访-分群客户关联关系,导入的企业与商户客群用户存放在这里", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysGroupBusiness sysGroupBusiness)
    {
        return toAjax(sysGroupBusinessService.updateSysGroupBusiness(sysGroupBusiness));
    }

    /**
     * 删除分群客户关联关系,导入的企业与商户客群用户存放在这里
     */
    @PreAuthorize("@ss.hasPermi('system:business:remove')")
    @Log(title = "走访-分群客户关联关系,导入的企业与商户客群用户存放在这里", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysGroupBusinessService.deleteSysGroupBusinessByIds(ids));
    }
}
