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

/**
 * 目标学校Controller
 * 
 * @author ruoyi
 * @date 2023-10-26
 */
@RestController
@RequestMapping("/mall/memberTargetSchool")
public class MallMemberTargetSchoolController extends BaseController
{
    @Autowired
    private IMallMemberTargetSchoolService mallMemberTargetSchoolService;

    /**
     * 查询目标学校列表
     */
    @PreAuthorize("@ss.hasPermi('mall:memberTargetSchool:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallMemberTargetSchool mallMemberTargetSchool)
    {
        startPage();
        List<MallMemberTargetSchool> list = mallMemberTargetSchoolService.selectMallMemberTargetSchoolList(mallMemberTargetSchool);
        return getDataTable(list);
    }

    /**
     * 导出目标学校列表
     */
    @PreAuthorize("@ss.hasPermi('mall:memberTargetSchool:export')")
    @Log(title = "目标学校", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallMemberTargetSchool mallMemberTargetSchool)
    {
        List<MallMemberTargetSchool> list = mallMemberTargetSchoolService.selectMallMemberTargetSchoolList(mallMemberTargetSchool);
        ExcelUtil<MallMemberTargetSchool> util = new ExcelUtil<MallMemberTargetSchool>(MallMemberTargetSchool.class);
        util.exportExcel(response, list, "目标学校数据");
    }

    /**
     * 获取目标学校详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:memberTargetSchool:query')")
    @GetMapping(value = "/{targetId}")
    public AjaxResult getInfo(@PathVariable("targetId") Long targetId)
    {
        return AjaxResult.success(mallMemberTargetSchoolService.selectMallMemberTargetSchoolByTargetId(targetId));
    }

    /**
     * 新增目标学校
     */
    @PreAuthorize("@ss.hasPermi('mall:memberTargetSchool:add')")
    @Log(title = "目标学校", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallMemberTargetSchool mallMemberTargetSchool)
    {
        return toAjax(mallMemberTargetSchoolService.insertMallMemberTargetSchool(mallMemberTargetSchool));
    }

    /**
     * 修改目标学校
     */
    @PreAuthorize("@ss.hasPermi('mall:memberTargetSchool:edit')")
    @Log(title = "目标学校", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallMemberTargetSchool mallMemberTargetSchool)
    {
        return toAjax(mallMemberTargetSchoolService.updateMallMemberTargetSchool(mallMemberTargetSchool));
    }

    /**
     * 删除目标学校
     */
    @PreAuthorize("@ss.hasPermi('mall:memberTargetSchool:remove')")
    @Log(title = "目标学校", businessType = BusinessType.DELETE)
	@DeleteMapping("/{targetIds}")
    public AjaxResult remove(@PathVariable Long[] targetIds)
    {
        return toAjax(mallMemberTargetSchoolService.deleteMallMemberTargetSchoolByTargetIds(targetIds));
    }
}
