package com.ruoyi.web.controller.baseinfo;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.baseinfo.domain.BasePosttypeInfo;
import com.ruoyi.baseinfo.service.IBasePosttypeInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 职位类型基础信息Controller
 * 
 * @author CaesarBao
 * @date 2020-10-20
 */
@Controller
@RequestMapping("/baseinfo/posttypeinfo")
public class BasePosttypeInfoController extends BaseController
{
    private String prefix = "baseinfo/posttypeinfo";

    @Autowired
    private IBasePosttypeInfoService basePosttypeInfoService;

    @RequiresPermissions("baseinfo:posttypeinfo:view")
    @GetMapping()
    public String posttypeinfo()
    {
        return prefix + "/posttypeinfo";
    }

    /**
     * 查询职位类型基础信息列表
     */
    @RequiresPermissions("baseinfo:posttypeinfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BasePosttypeInfo basePosttypeInfo)
    {
        startPage();
        List<BasePosttypeInfo> list = basePosttypeInfoService.selectBasePosttypeInfoList(basePosttypeInfo);
        return getDataTable(list);
    }

    /**
     * 导出职位类型基础信息列表
     */
    @RequiresPermissions("baseinfo:posttypeinfo:export")
    @Log(title = "职位类型基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BasePosttypeInfo basePosttypeInfo)
    {
        List<BasePosttypeInfo> list = basePosttypeInfoService.selectBasePosttypeInfoList(basePosttypeInfo);
        ExcelUtil<BasePosttypeInfo> util = new ExcelUtil<BasePosttypeInfo>(BasePosttypeInfo.class);
        return util.exportExcel(list, "posttypeinfo");
    }

    /**
     * 新增职位类型基础信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存职位类型基础信息
     */
    @RequiresPermissions("baseinfo:posttypeinfo:add")
    @Log(title = "职位类型基础信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BasePosttypeInfo basePosttypeInfo)
    {
        return toAjax(basePosttypeInfoService.insertBasePosttypeInfo(basePosttypeInfo));
    }

    /**
     * 修改职位类型基础信息
     */
    @GetMapping("/edit/{objid}")
    public String edit(@PathVariable("objid") Long objid, ModelMap mmap)
    {
        BasePosttypeInfo basePosttypeInfo = basePosttypeInfoService.selectBasePosttypeInfoById(objid);
        mmap.put("basePosttypeInfo", basePosttypeInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存职位类型基础信息
     */
    @RequiresPermissions("baseinfo:posttypeinfo:edit")
    @Log(title = "职位类型基础信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BasePosttypeInfo basePosttypeInfo)
    {
        return toAjax(basePosttypeInfoService.updateBasePosttypeInfo(basePosttypeInfo));
    }

    /**
     * 删除职位类型基础信息
     */
    @RequiresPermissions("baseinfo:posttypeinfo:remove")
    @Log(title = "职位类型基础信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(basePosttypeInfoService.deleteBasePosttypeInfoByIds(ids));
    }
}
