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.MallLinkMajorSchool;
import com.ruoyi.mall.service.IMallLinkMajorSchoolService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专业与学校关联Controller
 *
 * @author Lsm
 * @date 2023-10-23
 */
@RestController
@RequestMapping("/mall/mallLinkMajorSchool")
public class MallLinkMajorSchoolController extends BaseController
{
    @Autowired
    private IMallLinkMajorSchoolService mallLinkMajorSchoolService;

    /**
     * 查询专业与学校关联列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallLinkMajorSchool:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallLinkMajorSchool mallLinkMajorSchool)
    {
        startPage();
        List<MallLinkMajorSchool> list = mallLinkMajorSchoolService.selectMallLinkMajorSchoolList(mallLinkMajorSchool);
        return getDataTable(list);
    }

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

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

    /**
     * 新增专业与学校关联
     */
    @PreAuthorize("@ss.hasPermi('mall:mallLinkMajorSchool:add')")
    @Log(title = "专业与学校关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallLinkMajorSchool mallLinkMajorSchool)
    {
        return mallLinkMajorSchoolService.insertMallLinkMajorSchool(mallLinkMajorSchool);
    }

    /**
     * 修改专业与学校关联
     */
    @PreAuthorize("@ss.hasPermi('mall:mallLinkMajorSchool:edit')")
    @Log(title = "专业与学校关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallLinkMajorSchool mallLinkMajorSchool)
    {
        return mallLinkMajorSchoolService.updateMallLinkMajorSchool(mallLinkMajorSchool);
    }

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