package com.jianshui.web.controller.system;

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

import com.jianshui.common.core.domain.entity.Companyservice;
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.ICompanyserviceService;
import com.jianshui.common.utils.poi.ExcelUtil;
import com.jianshui.common.core.page.TableDataInfo;

/**
 * 销方信息Controller
 * 
 * @author jianshui
 * @date 2021-12-21
 */
@RestController
@RequestMapping("/system/companyservice")
public class CompanyserviceController extends BaseController
{
    @Autowired
    private ICompanyserviceService companyserviceService;

    /**
     * 查询销方信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:companyservice:list')")
    @GetMapping("/list")
    public TableDataInfo list(Companyservice companyservice)
    {
        startPage();
        List<Companyservice> list = companyserviceService.selectCompanyserviceList(companyservice);
        return getDataTable(list);
    }

    /**
     * 导出销方信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:companyservice:export')")
    @Log(title = "销方信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Companyservice companyservice)
    {
        List<Companyservice> list = companyserviceService.selectCompanyserviceList(companyservice);
        ExcelUtil<Companyservice> util = new ExcelUtil<Companyservice>(Companyservice.class);
        util.exportExcel(response, list, "销方信息数据");
    }

    /**
     * 获取销方信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:companyservice:query')")
    @GetMapping(value = "/{companyid}")
    public AjaxResult getInfo(@PathVariable("companyid") Long companyid)
    {
        return AjaxResult.success(companyserviceService.selectCompanyserviceByCompanyid(companyid));
    }

    /**
     * 新增销方信息
     */
    @PreAuthorize("@ss.hasPermi('system:companyservice:add')")
    @Log(title = "销方信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Companyservice companyservice)
    {
        return toAjax(companyserviceService.insertCompanyservice(companyservice));
    }

    /**
     * 修改销方信息
     */
    @PreAuthorize("@ss.hasPermi('system:companyservice:edit')")
    @Log(title = "销方信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Companyservice companyservice)
    {
        return toAjax(companyserviceService.updateCompanyservice(companyservice));
    }

    /**
     * 删除销方信息
     */
    @PreAuthorize("@ss.hasPermi('system:companyservice:remove')")
    @Log(title = "销方信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{companyids}")
    public AjaxResult remove(@PathVariable Long[] companyids)
    {
        return toAjax(companyserviceService.deleteCompanyserviceByCompanyids(companyids));
    }
}
