package com.jianshui.web.controller.system;

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

import com.jianshui.common.core.domain.entity.CompanyserviceDetail;
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.jianshui.common.annotation.Log;
import com.jianshui.common.core.controller.BaseController;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.common.enums.BusinessType;
import com.jianshui.system.service.ICompanyserviceDetailService;
import com.jianshui.common.utils.poi.ExcelUtil;
import com.jianshui.common.core.page.TableDataInfo;

/**
 * 销方详情Controller
 * 
 * @author Gong Quanlin 
 * @date 2022-03-08
 */
@RestController
@RequestMapping("/system/companyservice_detail")
public class CompanyserviceDetailController extends BaseController
{
    @Autowired
    private ICompanyserviceDetailService companyserviceDetailService;

    /**
     * 查询销方详情列表
     */
    @PreAuthorize("@ss.hasPermi('system:companyservice_detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanyserviceDetail companyserviceDetail)
    {
        startPage();
        List<CompanyserviceDetail> list = companyserviceDetailService.selectCompanyserviceDetailList(companyserviceDetail);
        return getDataTable(list);
    }

    /**
     * 导出销方详情列表
     */
    @PreAuthorize("@ss.hasPermi('system:companyservice_detail:export')")
    @Log(title = "销方详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CompanyserviceDetail companyserviceDetail)
    {
        List<CompanyserviceDetail> list = companyserviceDetailService.selectCompanyserviceDetailList(companyserviceDetail);
        ExcelUtil<CompanyserviceDetail> util = new ExcelUtil<CompanyserviceDetail>(CompanyserviceDetail.class);
        util.exportExcel(response, list, "销方详情数据");
    }

    /**
     * 获取销方详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:companyservice_detail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(companyserviceDetailService.selectCompanyserviceDetailById(id));
    }

    /**
     * 新增销方详情
     */
    @PreAuthorize("@ss.hasPermi('system:companyservice_detail:add')")
    @Log(title = "销方详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanyserviceDetail companyserviceDetail)
    {
        return toAjax(companyserviceDetailService.insertCompanyserviceDetail(companyserviceDetail));
    }

    /**
     * 修改销方详情
     */
    @PreAuthorize("@ss.hasPermi('system:companyservice_detail:edit')")
    @Log(title = "销方详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyserviceDetail companyserviceDetail)
    {
        return toAjax(companyserviceDetailService.updateCompanyserviceDetail(companyserviceDetail));
    }

    /**
     * 删除销方详情
     */
    @PreAuthorize("@ss.hasPermi('system:companyservice_detail:remove')")
    @Log(title = "销方详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(companyserviceDetailService.deleteCompanyserviceDetailByIds(ids));
    }
}
