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

/**
 * 专业管理Controller
 * 
 * @author goomood
 * @date 2024-11-16
 */
@RestController
@RequestMapping("/basic/speciality")
public class BasicSpecialityController extends BaseController
{
    @Autowired
    private IBasicSpecialityService basicSpecialityService;

    /**
     * 查询专业管理列表
     */
    @PreAuthorize("@ss.hasPermi('basic:speciality:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasicSpeciality basicSpeciality)
    {
        startPage();
        List<BasicSpeciality> list = basicSpecialityService.selectBasicSpecialityList(basicSpeciality);
        return getDataTable(list);
    }

    /**
     * 导出专业管理列表
     */
    @PreAuthorize("@ss.hasPermi('basic:speciality:export')")
    @Log(title = "专业管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasicSpeciality basicSpeciality)
    {
        List<BasicSpeciality> list = basicSpecialityService.selectBasicSpecialityList(basicSpeciality);
        ExcelUtil<BasicSpeciality> util = new ExcelUtil<BasicSpeciality>(BasicSpeciality.class);
        util.exportExcel(response, list, "专业管理数据");
    }

    /**
     * 获取专业管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:speciality:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(basicSpecialityService.selectBasicSpecialityById(id));
    }

    /**
     * 新增专业管理
     */
    @PreAuthorize("@ss.hasPermi('basic:speciality:add')")
    @Log(title = "专业管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasicSpeciality basicSpeciality)
    {
        return toAjax(basicSpecialityService.insertBasicSpeciality(basicSpeciality));
    }

    /**
     * 修改专业管理
     */
    @PreAuthorize("@ss.hasPermi('basic:speciality:edit')")
    @Log(title = "专业管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasicSpeciality basicSpeciality)
    {
        return toAjax(basicSpecialityService.updateBasicSpeciality(basicSpeciality));
    }

    /**
     * 删除专业管理
     */
    @PreAuthorize("@ss.hasPermi('basic:speciality:remove')")
    @Log(title = "专业管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(basicSpecialityService.deleteBasicSpecialityByIds(ids));
    }
}
