package cn.ezhizao.project.business.consult.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.consult.domain.BizDayworkItemConsult;
import cn.ezhizao.project.business.consult.service.IBizDayworkItemConsultService;
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-11-19
 */
@RestController
@RequestMapping("/business/consult")
public class BizDayworkItemConsultController extends BaseController
{
    @Resource
    private IBizDayworkItemConsultService bizDayworkItemConsultService;

    /**
     * 查询报工技术咨询列表
     */
    @Log(title = "报工技术咨询查询", businessType = BusinessType.SELECT)
    @PreAuthorize("@ss.hasPermi('business:consult:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizDayworkItemConsult bizDayworkItemConsult) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizDayworkItemConsult);
        startPage();
        List<BizDayworkItemConsult> list = bizDayworkItemConsultService.getList(bizDayworkItemConsult);
        return getDataTable(list);
    }

    /**
     * 导出报工技术咨询列表
     */
    @PreAuthorize("@ss.hasPermi('business:consult:export')")
    @Log(title = "报工技术咨询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizDayworkItemConsult bizDayworkItemConsult) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizDayworkItemConsult);
        List<BizDayworkItemConsult> list = bizDayworkItemConsultService.getList(bizDayworkItemConsult);
        ExcelUtil<BizDayworkItemConsult> util = new ExcelUtil<BizDayworkItemConsult>(BizDayworkItemConsult.class);
        util.exportExcel(response, list, "报工技术咨询数据");
    }

    /**
     * 获取报工技术咨询详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:consult:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizDayworkItemConsultService.getById(id));
    }

    /**
     * 新增报工技术咨询
     */
    @PreAuthorize("@ss.hasPermi('business:consult:add')")
    @Log(title = "报工技术咨询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizDayworkItemConsult bizDayworkItemConsult) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizDayworkItemConsult);
        return toAjax(bizDayworkItemConsultService.save(bizDayworkItemConsult));
    }

    /**
     * 修改报工技术咨询
     */
    @PreAuthorize("@ss.hasPermi('business:consult:edit')")
    @Log(title = "报工技术咨询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizDayworkItemConsult bizDayworkItemConsult) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizDayworkItemConsult);
        return toAjax(bizDayworkItemConsultService.updateById(bizDayworkItemConsult));
    }

    /**
     * 删除报工技术咨询
     */
    @PreAuthorize("@ss.hasPermi('business:consult:remove')")
    @Log(title = "报工技术咨询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(bizDayworkItemConsultService.removeBatchByIds(ids));
    }
}
