package com.goomood.phm.controller;

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.goomood.common.annotation.Log;
import com.goomood.common.core.controller.BaseController;
import com.goomood.common.core.domain.AjaxResult;
import com.goomood.common.enums.BusinessType;
import com.goomood.phm.domain.TechType;
import com.goomood.phm.service.ITechTypeService;
import com.goomood.common.utils.poi.ExcelUtil;
import com.goomood.common.core.page.TableDataInfo;

/**
 * 资料类型Controller
 * 
 * @author goomood
 * @date 2024-11-16
 */
@RestController
@RequestMapping("/tech/techType")
public class TechTypeController extends BaseController
{
    @Autowired
    private ITechTypeService techTypeService;

    /**
     * 查询资料类型列表
     */
    @PreAuthorize("@ss.hasPermi('tech:techType:list')")
    @GetMapping("/list")
    public TableDataInfo list(TechType techType)
    {
        startPage();
        List<TechType> list = techTypeService.selectTechTypeList(techType);
        return getDataTable(list);
    }

    /**
     * 导出资料类型列表
     */
    @PreAuthorize("@ss.hasPermi('tech:techType:export')")
    @Log(title = "资料类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TechType techType)
    {
        List<TechType> list = techTypeService.selectTechTypeList(techType);
        ExcelUtil<TechType> util = new ExcelUtil<TechType>(TechType.class);
        util.exportExcel(response, list, "资料类型数据");
    }

    /**
     * 获取资料类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('tech:techType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(techTypeService.selectTechTypeById(id));
    }

    /**
     * 新增资料类型
     */
    @PreAuthorize("@ss.hasPermi('tech:techType:add')")
    @Log(title = "资料类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TechType techType)
    {
        return toAjax(techTypeService.insertTechType(techType));
    }

    /**
     * 修改资料类型
     */
    @PreAuthorize("@ss.hasPermi('tech:techType:edit')")
    @Log(title = "资料类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TechType techType)
    {
        return toAjax(techTypeService.updateTechType(techType));
    }

    /**
     * 删除资料类型
     */
    @PreAuthorize("@ss.hasPermi('tech:techType:remove')")
    @Log(title = "资料类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(techTypeService.deleteTechTypeByIds(ids));
    }
}
