package com.ruoyi.mall.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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mall.domain.MallCareerMajor;
import com.ruoyi.mall.service.IMallCareerMajorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 职业专业关联Controller
 * 
 * @author ruoyi
 * @date 2023-11-25
 */
@RestController
@RequestMapping("/mall/CareerMajor")
public class MallCareerMajorController extends BaseController
{
    @Autowired
    private IMallCareerMajorService mallCareerMajorService;

    /**
     * 查询职业专业关联列表
     */
    @PreAuthorize("@ss.hasPermi('mall:CareerMajor:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallCareerMajor mallCareerMajor)
    {
        startPage();
        List<MallCareerMajor> list = mallCareerMajorService.selectMallCareerMajorList(mallCareerMajor);
        return getDataTable(list);
    }

    /**
     * 导出职业专业关联列表
     */
    @PreAuthorize("@ss.hasPermi('mall:CareerMajor:export')")
    @Log(title = "职业专业关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallCareerMajor mallCareerMajor)
    {
        List<MallCareerMajor> list = mallCareerMajorService.selectMallCareerMajorList(mallCareerMajor);
        ExcelUtil<MallCareerMajor> util = new ExcelUtil<MallCareerMajor>(MallCareerMajor.class);
        util.exportExcel(response, list, "职业专业关联数据");
    }

    /**
     * 获取职业专业关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:CareerMajor:query')")
    @GetMapping(value = "/{linkId}")
    public AjaxResult getInfo(@PathVariable("linkId") Long linkId)
    {
        return AjaxResult.success(mallCareerMajorService.selectMallCareerMajorByLinkId(linkId));
    }

    /**
     * 新增职业专业关联
     */
    @PreAuthorize("@ss.hasPermi('mall:CareerMajor:add')")
    @Log(title = "职业专业关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallCareerMajor mallCareerMajor)
    {
        return toAjax(mallCareerMajorService.insertMallCareerMajor(mallCareerMajor));
    }

    /**
     * 修改职业专业关联
     */
    @PreAuthorize("@ss.hasPermi('mall:CareerMajor:edit')")
    @Log(title = "职业专业关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallCareerMajor mallCareerMajor)
    {
        return toAjax(mallCareerMajorService.updateMallCareerMajor(mallCareerMajor));
    }

    /**
     * 删除职业专业关联
     */
    @PreAuthorize("@ss.hasPermi('mall:CareerMajor:remove')")
    @Log(title = "职业专业关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{linkIds}")
    public AjaxResult remove(@PathVariable Long[] linkIds)
    {
        return toAjax(mallCareerMajorService.deleteMallCareerMajorByLinkIds(linkIds));
    }
}
