package com.fs.company.controller;

import java.util.List;
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.CompanyPost;
import com.fs.company.service.ICompanyPostService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 岗位信息Controller
 * 
 * @author fs
 * @date 2021-10-04
 */
@RestController
@RequestMapping("/company/companyPost")
public class CompanyPostController extends BaseController
{
    @Autowired
    private ICompanyPostService companyPostService;

    /**
     * 查询岗位信息列表
     */
    @PreAuthorize("@ss.hasPermi('company:companyPost:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanyPost companyPost)
    {
        startPage();
        List<CompanyPost> list = companyPostService.selectCompanyPostList(companyPost);
        return getDataTable(list);
    }

    /**
     * 导出岗位信息列表
     */
    @PreAuthorize("@ss.hasPermi('company:companyPost:export')")
    @Log(title = "岗位信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CompanyPost companyPost)
    {
        List<CompanyPost> list = companyPostService.selectCompanyPostList(companyPost);
        ExcelUtil<CompanyPost> util = new ExcelUtil<CompanyPost>(CompanyPost.class);
        return util.exportExcel(list, "companyPost");
    }

    /**
     * 获取岗位信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('company:companyPost:query')")
    @GetMapping(value = "/{postId}")
    public AjaxResult getInfo(@PathVariable("postId") Long postId)
    {
        return AjaxResult.success(companyPostService.selectCompanyPostById(postId));
    }

    /**
     * 新增岗位信息
     */
    @PreAuthorize("@ss.hasPermi('company:companyPost:add')")
    @Log(title = "岗位信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanyPost companyPost)
    {
        return toAjax(companyPostService.insertCompanyPost(companyPost));
    }

    /**
     * 修改岗位信息
     */
    @PreAuthorize("@ss.hasPermi('company:companyPost:edit')")
    @Log(title = "岗位信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyPost companyPost)
    {
        return toAjax(companyPostService.updateCompanyPost(companyPost));
    }

    /**
     * 删除岗位信息
     */
    @PreAuthorize("@ss.hasPermi('company:companyPost:remove')")
    @Log(title = "岗位信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{postIds}")
    public AjaxResult remove(@PathVariable Long[] postIds)
    {
        return toAjax(companyPostService.deleteCompanyPostByIds(postIds));
    }
}
