package com.tongran.system.controller;

import com.tongran.common.core.utils.poi.ExcelUtil;
import com.tongran.common.core.web.controller.BaseController;
import com.tongran.common.core.web.domain.AjaxResult;
import com.tongran.common.core.web.page.PageDomain;
import com.tongran.common.core.web.page.TableDataInfo;
import com.tongran.common.log.annotation.Log;
import com.tongran.common.log.enums.BusinessType;
import com.tongran.common.security.annotation.RequiresPermissions;
import com.tongran.system.domain.EpsBusinessDeploy;
import com.tongran.system.service.IEpsBusinessDeployService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 业务下发管理Controller
 * 
 * @author tongran
 * @date 2025-10-13
 */
@RestController
@RequestMapping("/businessDeploy")
@RequiresPermissions("system:businessDeploy")
public class EpsBusinessDeployController extends BaseController
{
    @Autowired
    private IEpsBusinessDeployService epsBusinessDeployService;

    /**
     * 查询业务下发管理列表
     */
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody EpsBusinessDeploy epsBusinessDeploy)
    {
        PageDomain pageDomain = new PageDomain();
        pageDomain.setPageNum(epsBusinessDeploy.getPageNum());
        pageDomain.setPageSize(epsBusinessDeploy.getPageSize());
        startPage(pageDomain);
        List<EpsBusinessDeploy> list = epsBusinessDeployService.selectEpsBusinessDeployList(epsBusinessDeploy);
        return getDataTable(list);
    }

    /**
     * 导出
     * @param response
     * @param epsBusinessDeploy
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestBody EpsBusinessDeploy epsBusinessDeploy)
    {
        List<EpsBusinessDeploy> list = epsBusinessDeployService.selectEpsBusinessDeployList(epsBusinessDeploy);
        ExcelUtil<EpsBusinessDeploy> util = new ExcelUtil<EpsBusinessDeploy>(EpsBusinessDeploy.class);
        util.showColumn(epsBusinessDeploy.getProperties());
        util.exportExcel(response, list, "业务下发管理");
    }


    /**
     * 获取业务下发管理详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(epsBusinessDeployService.selectEpsBusinessDeployById(id));
    }

    /**
     * 新增业务下发管理
     */
    @Log(title = "业务下发管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EpsBusinessDeploy epsBusinessDeploy)
    {
        return toAjax(epsBusinessDeployService.insertEpsBusinessDeploy(epsBusinessDeploy));
    }

    /**
     * 修改业务下发管理
     */
    @Log(title = "业务下发管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EpsBusinessDeploy epsBusinessDeploy)
    {
        return toAjax(epsBusinessDeployService.updateEpsBusinessDeploy(epsBusinessDeploy));
    }

    /**
     * 删除业务下发管理
     */
    @Log(title = "业务下发管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(epsBusinessDeployService.deleteEpsBusinessDeployByIds(ids));
    }

    /**
     * 审核
     * @param epsBusinessDeploy
     * @return
     */
    @PostMapping("/reviewBusiness")
    public AjaxResult reviewBusiness(@RequestBody EpsBusinessDeploy epsBusinessDeploy){
        return toAjax(epsBusinessDeployService.reviewBusiness(epsBusinessDeploy));
    }
}
