package cn.ezhizao.project.business.technologicalProcessDetailDrawingRecords.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.technologicalProcessDetailDrawingRecords.domain.BizTechnologicalProcessDetailDrawingRecords;
import cn.ezhizao.project.business.technologicalProcessDetailDrawingRecords.service.IBizTechnologicalProcessDetailDrawingRecordsService;
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-06-03
 */
@RestController
@RequestMapping("/business/records")
public class BizTechnologicalProcessDetailDrawingRecordsController extends BaseController
{
    @Resource
    private IBizTechnologicalProcessDetailDrawingRecordsService bizTechnologicalProcessDetailDrawingRecordsService;

    /**
     * 查询电子图纸操作记录列表
     */
//    @PreAuthorize("@ss.hasPermi('business:records:list')")
    @Log(title = "电子图纸操作记录查询", businessType = BusinessType.SELECT)
    @GetMapping("/list")
    public TableDataInfo list(BizTechnologicalProcessDetailDrawingRecords bizTechnologicalProcessDetailDrawingRecords) throws NoSuchFieldException, IllegalAccessException
    {
//        setTenantId(bizTechnologicalProcessDetailDrawingRecords);
        startPage();
        List<BizTechnologicalProcessDetailDrawingRecords> list = bizTechnologicalProcessDetailDrawingRecordsService.getList(bizTechnologicalProcessDetailDrawingRecords);
        return getDataTable(list);
    }

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

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

    /**
     * 新增电子图纸操作记录
     */
//    @PreAuthorize("@ss.hasPermi('business:records:add')")
    @Log(title = "电子图纸操作记录新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizTechnologicalProcessDetailDrawingRecords bizTechnologicalProcessDetailDrawingRecords) throws NoSuchFieldException, IllegalAccessException
    {
//        setTenantId(bizTechnologicalProcessDetailDrawingRecords);
        return toAjax(bizTechnologicalProcessDetailDrawingRecordsService.save(bizTechnologicalProcessDetailDrawingRecords));
    }

    /**
     * 修改电子图纸操作记录
     */
//    @PreAuthorize("@ss.hasPermi('business:records:edit')")
    @Log(title = "电子图纸操作记录修改", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizTechnologicalProcessDetailDrawingRecords bizTechnologicalProcessDetailDrawingRecords) throws NoSuchFieldException, IllegalAccessException
    {
//        setTenantId(bizTechnologicalProcessDetailDrawingRecords);
        return toAjax(bizTechnologicalProcessDetailDrawingRecordsService.updateById(bizTechnologicalProcessDetailDrawingRecords));
    }

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