package com.ruoyi.mall.controller;

import java.util.List;
import javax.annotation.Resource;
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.MallLinkCareerMajor;
import com.ruoyi.mall.service.IMallLinkCareerMajorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 职业与专业关联Controller
 *
 * @author LCL
 * @date 2023-10-19
 */
@RestController
@RequestMapping("/mall/mallLinkCareerMajor")
public class MallLinkCareerMajorController extends BaseController
{
    @Resource
    private IMallLinkCareerMajorService mallLinkCareerMajorService;

    /**
     * 查询职业与专业关联列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallLinkCareerMajor:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallLinkCareerMajor mallLinkCareerMajor)
    {
        startPage();
        List<MallLinkCareerMajor> list = mallLinkCareerMajorService.selectMallLinkCareerMajorList(mallLinkCareerMajor);
        return getDataTable(list);
    }

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

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

    /**
     * 新增职业与专业关联
     */
    @PreAuthorize("@ss.hasPermi('mall:mallLinkCareerMajor:add')")
    @Log(title = "职业与专业关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallLinkCareerMajor mallLinkCareerMajor)
    {
        return toAjax(mallLinkCareerMajorService.insertMallLinkCareerMajor(mallLinkCareerMajor));
    }

    /**
     * 修改职业与专业关联
     */
    @PreAuthorize("@ss.hasPermi('mall:mallLinkCareerMajor:edit')")
    @Log(title = "职业与专业关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallLinkCareerMajor mallLinkCareerMajor)
    {
        return toAjax(mallLinkCareerMajorService.updateMallLinkCareerMajor(mallLinkCareerMajor));
    }

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