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.TechLingo;
import com.goomood.phm.service.ITechLingoService;
import com.goomood.common.utils.poi.ExcelUtil;
import com.goomood.common.core.page.TableDataInfo;

/**
 * 专业术语Controller
 * 
 * @author goomood
 * @date 2024-11-16
 */
@RestController
@RequestMapping("/tech/techLingo")
public class TechLingoController extends BaseController
{
    @Autowired
    private ITechLingoService techLingoService;

    /**
     * 查询专业术语列表
     */
    @PreAuthorize("@ss.hasPermi('tech:techLingo:list')")
    @GetMapping("/list")
    public TableDataInfo list(TechLingo techLingo)
    {
        startPage();
        List<TechLingo> list = techLingoService.selectTechLingoList(techLingo);
        return getDataTable(list);
    }

    /**
     * 导出专业术语列表
     */
    @PreAuthorize("@ss.hasPermi('tech:techLingo:export')")
    @Log(title = "专业术语", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TechLingo techLingo)
    {
        List<TechLingo> list = techLingoService.selectTechLingoList(techLingo);
        ExcelUtil<TechLingo> util = new ExcelUtil<TechLingo>(TechLingo.class);
        util.exportExcel(response, list, "专业术语数据");
    }

    /**
     * 获取专业术语详细信息
     */
    @PreAuthorize("@ss.hasPermi('tech:techLingo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(techLingoService.selectTechLingoById(id));
    }

    /**
     * 新增专业术语
     */
    @PreAuthorize("@ss.hasPermi('tech:techLingo:add')")
    @Log(title = "专业术语", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TechLingo techLingo)
    {
        return toAjax(techLingoService.insertTechLingo(techLingo));
    }

    /**
     * 修改专业术语
     */
    @PreAuthorize("@ss.hasPermi('tech:techLingo:edit')")
    @Log(title = "专业术语", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TechLingo techLingo)
    {
        return toAjax(techLingoService.updateTechLingo(techLingo));
    }

    /**
     * 删除专业术语
     */
    @PreAuthorize("@ss.hasPermi('tech:techLingo:remove')")
    @Log(title = "专业术语", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(techLingoService.deleteTechLingoByIds(ids));
    }
}
