package com.bonus.zlpt.equip.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.bonus.zlpt.common.core.utils.poi.ExcelUtil;
import com.bonus.zlpt.common.core.web.controller.BaseController;
import com.bonus.zlpt.common.core.web.domain.AjaxResult;
import com.bonus.zlpt.common.core.web.page.TableDataInfo;
import com.bonus.zlpt.common.log.annotation.Log;
import com.bonus.zlpt.common.log.enums.BusinessType;
import com.bonus.zlpt.common.security.annotation.RequiresPermissions;
import com.bonus.zlpt.equip.api.domain.TypeInfoRecord;
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.bonus.zlpt.equip.service.ITypeInfoRecordService;

/**
 * 设备类型Controller
 * 
 * @author xsheng
 * @date 2023-12-02
 */
@Deprecated
@RestController
@RequestMapping("/record")
public class TypeInfoRecordController extends BaseController
{
    @Autowired
    private ITypeInfoRecordService typeInfoRecordService;

    /**
     * 查询设备类型列表
     */
    @RequiresPermissions("equip:record:list")
    @GetMapping("/list")
    public TableDataInfo list(TypeInfoRecord typeInfoRecord)
    {
        startPage();
        List<TypeInfoRecord> list = typeInfoRecordService.selectTypeInfoRecordList(typeInfoRecord);
        return getDataTable(list);
    }

    /**
     * 导出设备类型列表
     */
    @RequiresPermissions("equip:record:export")
    @Log(title = "设备类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TypeInfoRecord typeInfoRecord)
    {
        List<TypeInfoRecord> list = typeInfoRecordService.selectTypeInfoRecordList(typeInfoRecord);
        ExcelUtil<TypeInfoRecord> util = new ExcelUtil<TypeInfoRecord>(TypeInfoRecord.class);
        util.exportExcel(response, list, "设备类型数据");
    }

    /**
     * 获取设备类型详细信息
     */
    @RequiresPermissions("equip:record:query")
    @GetMapping(value = "/{typeId}")
    public AjaxResult getInfo(@PathVariable("typeId") Long typeId)
    {
        return success(typeInfoRecordService.selectTypeInfoRecordByTypeId(typeId));
    }

    /**
     * 新增设备类型
     */
    @RequiresPermissions("equip:record:add")
    @Log(title = "设备类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TypeInfoRecord typeInfoRecord)
    {
        return toAjax(typeInfoRecordService.insertTypeInfoRecord(typeInfoRecord));
    }

    /**
     * 修改设备类型
     */
    @RequiresPermissions("equip:record:edit")
    @Log(title = "设备类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TypeInfoRecord typeInfoRecord)
    {
        return toAjax(typeInfoRecordService.updateTypeInfoRecord(typeInfoRecord));
    }

    /**
     * 删除设备类型
     */
    @RequiresPermissions("equip:record:remove")
    @Log(title = "设备类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{typeIds}")
    public AjaxResult remove(@PathVariable Long[] typeIds)
    {
        return toAjax(typeInfoRecordService.deleteTypeInfoRecordByTypeIds(typeIds));
    }
}
