package com.ruoyi.web.controller.chuchai;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BusinessUser;
import com.ruoyi.system.service.IBusinessUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 出差人员信息Controller
 * 
 * @author ruoyi
 * @date 2025-06-23
 */
@RestController
@RequestMapping("/business/user")
public class BusinessUserController extends BaseController
{
    @Autowired
    private IBusinessUserService businessUserService;

    /**
     * 查询出差人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusinessUser businessUser)
    {
        startPage();
        List<BusinessUser> list = businessUserService.selectBusinessUserList(businessUser);
        return getDataTable(list);
    }

    /**
     * 导出出差人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:user:export')")
    @Log(title = "出差人员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusinessUser businessUser)
    {
        List<BusinessUser> list = businessUserService.selectBusinessUserList(businessUser);
        ExcelUtil<BusinessUser> util = new ExcelUtil<BusinessUser>(BusinessUser.class);
        util.exportExcel(response, list, "出差人员信息数据");
    }

    /**
     * 获取出差人员信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:user:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(businessUserService.selectBusinessUserById(id));
    }

    /**
     * 新增出差人员信息
     */
    @PreAuthorize("@ss.hasPermi('business:user:add')")
    @Log(title = "出差人员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusinessUser businessUser)
    {
        return toAjax(businessUserService.insertBusinessUser(businessUser));
    }

    /**
     * 修改出差人员信息
     */
    @PreAuthorize("@ss.hasPermi('business:user:edit')")
    @Log(title = "出差人员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusinessUser businessUser)
    {
        return toAjax(businessUserService.updateBusinessUser(businessUser));
    }

    /**
     * 删除出差人员信息
     */
    @PreAuthorize("@ss.hasPermi('business:user:remove')")
    @Log(title = "出差人员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(businessUserService.deleteBusinessUserByIds(ids));
    }
}
