package cn.ezhizao.project.business.technologicalProcessDetailDrawingUser.controller;

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

import cn.ezhizao.common.utils.poi.ExcelUtil;
import cn.ezhizao.framework.aspectj.lang.annotation.Log;
import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
import cn.ezhizao.framework.web.controller.BaseController;
import cn.ezhizao.framework.web.domain.AjaxResult;
import cn.ezhizao.framework.web.page.TableDataInfo;
import cn.ezhizao.project.business.technologicalProcessDetailDrawingUser.domain.BizTechnologicalProcessDetailDrawingUser;
import cn.ezhizao.project.business.technologicalProcessDetailDrawingUser.service.IBizTechnologicalProcessDetailDrawingUserService;
import org.springframework.security.access.prepost.PreAuthorize;
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;

/**
 * 电子图纸操作人员Controller
 *
 * @author ezhizao
 * @date 2024-07-31
 */
@RestController
@RequestMapping("/business/user")
public class BizTechnologicalProcessDetailDrawingUserController extends BaseController
{
    @Resource
    private IBizTechnologicalProcessDetailDrawingUserService bizTechnologicalProcessDetailDrawingUserService;

    /**
     * 查询电子图纸操作人员列表
     */
    @PreAuthorize("@ss.hasPermi('business:user:list')")
    @Log(title = "电子图纸操作人员查询", businessType = BusinessType.EXPORT)
    @GetMapping("/list")
    public TableDataInfo list(BizTechnologicalProcessDetailDrawingUser bizTechnologicalProcessDetailDrawingUser) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizTechnologicalProcessDetailDrawingUser);
        startPage();
        List<BizTechnologicalProcessDetailDrawingUser> list = bizTechnologicalProcessDetailDrawingUserService.getList(bizTechnologicalProcessDetailDrawingUser);
        return getDataTable(list);
    }

    /**
     * 导出电子图纸操作人员列表
     */
    @PreAuthorize("@ss.hasPermi('business:user:export')")
    @Log(title = "电子图纸操作人员导出", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizTechnologicalProcessDetailDrawingUser bizTechnologicalProcessDetailDrawingUser) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizTechnologicalProcessDetailDrawingUser);
        List<BizTechnologicalProcessDetailDrawingUser> list = bizTechnologicalProcessDetailDrawingUserService.getList(bizTechnologicalProcessDetailDrawingUser);
        ExcelUtil<BizTechnologicalProcessDetailDrawingUser> util = new ExcelUtil<BizTechnologicalProcessDetailDrawingUser>(BizTechnologicalProcessDetailDrawingUser.class);
        util.exportExcel(response, list, "电子图纸操作人员数据");
    }

    /**
     * 获取电子图纸操作人员详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:user:query')")
    @Log(title = "电子图纸操作人员查询详细信息", businessType = BusinessType.EXPORT)
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizTechnologicalProcessDetailDrawingUserService.getById(id));
    }

    /**
     * 新增电子图纸操作人员
     */
    @PreAuthorize("@ss.hasPermi('business:user:add')")
    @Log(title = "电子图纸操作人员新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizTechnologicalProcessDetailDrawingUser bizTechnologicalProcessDetailDrawingUser) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizTechnologicalProcessDetailDrawingUser);
        return toAjax(bizTechnologicalProcessDetailDrawingUserService.save(bizTechnologicalProcessDetailDrawingUser));
    }

    /**
     * 修改电子图纸操作人员
     */
    @PreAuthorize("@ss.hasPermi('business:user:edit')")
    @Log(title = "电子图纸操作人员修改", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizTechnologicalProcessDetailDrawingUser bizTechnologicalProcessDetailDrawingUser) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizTechnologicalProcessDetailDrawingUser);
        return toAjax(bizTechnologicalProcessDetailDrawingUserService.updateById(bizTechnologicalProcessDetailDrawingUser));
    }

    /**
     * 删除电子图纸操作人员
     */
    @PreAuthorize("@ss.hasPermi('business:user:remove')")
    @Log(title = "电子图纸操作人员删除", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(bizTechnologicalProcessDetailDrawingUserService.removeBatchByIds(ids));
    }
}
