package com.ruoyi.mall.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.mall.domain.Bo.MallSchoolAppraiseExcelBo;
import com.ruoyi.mall.domain.MallSchoolIntroduce;
import com.ruoyi.mall.service.IMallSchoolIntroduceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 学校介绍关联Controller
 *
 * @author lsm
 * @date 2023-10-18
 */
@RestController
@RequestMapping("/mall/mallSchoolIntroduce")
public class MallSchoolIntroduceController extends BaseController
{
    @Autowired
    private IMallSchoolIntroduceService mallSchoolIntroduceService;


//    /**
//     * 导入校考院校列表
//     */
//    @Log(title = "用户管理", businessType = BusinessType.IMPORT)
//    @PostMapping("/importData")
//    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
//    {
//        ExcelUtil<MallSchoolAppraiseExcelBo> util = new ExcelUtil<MallSchoolAppraiseExcelBo>(MallSchoolAppraiseExcelBo.class);
//        List<MallSchoolAppraiseExcelBo> list = util.importExcel(file.getInputStream());
//        LoginUser loginUser = getLoginUser();
//        String operName = loginUser.getUsername();
//        String message = mallSchoolAppraiseService.importSchoolAppraise(list, updateSupport, operName);
//        return AjaxResult.success(message);
//    }
//
//
//    @PostMapping("/importTemplate")
//    public void importTemplate(HttpServletResponse response) throws IOException
//    {
//        ExcelUtil<MallSchoolAppraiseExcelBo> util = new ExcelUtil<MallSchoolAppraiseExcelBo>(MallSchoolAppraiseExcelBo.class);
//        util.importTemplateExcel(response, "院校评估数据");
//    }
//


    /**
     * 查询学校介绍关联列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolIntroduce:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallSchoolIntroduce mallSchoolIntroduce)
    {
        startPage();
        List<MallSchoolIntroduce> list = mallSchoolIntroduceService.selectMallSchoolIntroduceList(mallSchoolIntroduce);
        return getDataTable(list);
    }

    /**
     * 导出学校介绍关联列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolIntroduce:export')")
    @Log(title = "学校介绍关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallSchoolIntroduce mallSchoolIntroduce)
    {
        List<MallSchoolIntroduce> list = mallSchoolIntroduceService.selectMallSchoolIntroduceList(mallSchoolIntroduce);
        ExcelUtil<MallSchoolIntroduce> util = new ExcelUtil<MallSchoolIntroduce>(MallSchoolIntroduce.class);
        util.exportExcel(response, list, "学校介绍关联数据");
    }

    /**
     * 获取学校介绍关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolIntroduce:query')")
    @GetMapping(value = "/{schoolIntroduceId}")
    public AjaxResult getInfo(@PathVariable("schoolIntroduceId") Long schoolIntroduceId)
    {
        return AjaxResult.success(mallSchoolIntroduceService.selectMallSchoolIntroduceBySchoolIntroduceId(schoolIntroduceId));
    }

    /**
     * 新增学校介绍关联
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolIntroduce:add')")
    @Log(title = "学校介绍关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallSchoolIntroduce mallSchoolIntroduce)
    {
        return toAjax(mallSchoolIntroduceService.insertMallSchoolIntroduce(mallSchoolIntroduce));
    }

    /**
     * 修改学校介绍关联
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolIntroduce:edit')")
    @Log(title = "学校介绍关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallSchoolIntroduce mallSchoolIntroduce)
    {
        return toAjax(mallSchoolIntroduceService.updateMallSchoolIntroduce(mallSchoolIntroduce));
    }

    /**
     * 删除学校介绍关联
     */
    @PreAuthorize("@ss.hasPermi('mall:mallSchoolIntroduce:remove')")
    @Log(title = "学校介绍关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{schoolIntroduceIds}")
    public AjaxResult remove(@PathVariable Long[] schoolIntroduceIds)
    {
        return toAjax(mallSchoolIntroduceService.deleteMallSchoolIntroduceBySchoolIntroduceIds(schoolIntroduceIds));
    }
}
