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

/**
 * 用户意向专业Controller
 *
 * @author LCL
 * @date 2023-10-25
 */
@RestController
@RequestMapping("/mall/mallUserMajorIntention")
public class MallUserMajorIntentionController extends BaseController
{
    @Resource
    private IMallUserMajorIntentionService mallUserMajorIntentionService;

    /**
     * 查询用户意向专业列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallUserMajorIntention:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallUserMajorIntention mallUserMajorIntention)
    {
        startPage();
        List<MallUserMajorIntention> list = mallUserMajorIntentionService.selectMallUserMajorIntentionList(mallUserMajorIntention);
        return getDataTable(list);
    }

    /**
     * 导出用户意向专业列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallUserMajorIntention:export')")
    @Log(title = "用户意向专业", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallUserMajorIntention mallUserMajorIntention)
    {
        List<MallUserMajorIntention> list = mallUserMajorIntentionService.selectMallUserMajorIntentionList(mallUserMajorIntention);
        ExcelUtil<MallUserMajorIntention> util = new ExcelUtil<MallUserMajorIntention>(MallUserMajorIntention.class);
        util.exportExcel(response, list, "用户意向专业数据");
    }

    /**
     * 获取用户意向专业详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallUserMajorIntention:query')")
    @GetMapping(value = "/{intentionId}")
    public AjaxResult getInfo(@PathVariable("intentionId") Long intentionId)
    {
        return AjaxResult.success(mallUserMajorIntentionService.selectMallUserMajorIntentionByIntentionId(intentionId));
    }

    /**
     * 新增用户意向专业
     */
    @PreAuthorize("@ss.hasPermi('mall:mallUserMajorIntention:add')")
    @Log(title = "用户意向专业", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallUserMajorIntention mallUserMajorIntention)
    {
        return toAjax(mallUserMajorIntentionService.insertMallUserMajorIntention(mallUserMajorIntention));
    }

    /**
     * 修改用户意向专业
     */
    @PreAuthorize("@ss.hasPermi('mall:mallUserMajorIntention:edit')")
    @Log(title = "用户意向专业", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallUserMajorIntention mallUserMajorIntention)
    {
        return toAjax(mallUserMajorIntentionService.updateMallUserMajorIntention(mallUserMajorIntention));
    }

    /**
     * 删除用户意向专业
     */
    @PreAuthorize("@ss.hasPermi('mall:mallUserMajorIntention:remove')")
    @Log(title = "用户意向专业", businessType = BusinessType.DELETE)
	@DeleteMapping("/{intentionIds}")
    public AjaxResult remove(@PathVariable Long[] intentionIds)
    {
        return toAjax(mallUserMajorIntentionService.deleteMallUserMajorIntentionByIntentionIds(intentionIds));
    }
}
