package com.ruoyi.mall.controller;

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

import com.ruoyi.mall.domain.Vo.OfflineServicesRegisterVo;
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.OfflineServicesRegister;
import com.ruoyi.mall.service.IOfflineServicesRegisterService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报名管理Controller
 * 
 * @author ruoyi
 * @date 2023-10-16
 */
@RestController
@RequestMapping("/mall/OfflineServicesRegister")
public class OfflineServicesRegisterController extends BaseController
{
    @Autowired
    private IOfflineServicesRegisterService offlineServicesRegisterService;

    /**
     * 查询报名管理列表
     */
    @PreAuthorize("@ss.hasPermi('mall:OfflineServicesRegister:list')")
    @GetMapping("/list")
    public TableDataInfo list(OfflineServicesRegister offlineServicesRegister)
    {
        startPage();
        List<OfflineServicesRegister> list = offlineServicesRegisterService.selectOfflineServicesRegisterList(offlineServicesRegister);
        return getDataTable(list);
    }

    /**
     *查询已报名Vo列表(包含活动名、用户名)
     * 后台+xcx
     */
    @PreAuthorize("@ss.hasPermi('mall:OfflineServicesRegister:list')")
    @GetMapping("/getVolist")
    public TableDataInfo getVolist(OfflineServicesRegister offlineServicesRegister)
    {
        startPage();
        List<OfflineServicesRegisterVo> list = offlineServicesRegisterService.selectVoList(offlineServicesRegister);
        return getDataTable(list);
    }

    /**
     * 导出报名管理列表
     */
    @PreAuthorize("@ss.hasPermi('mall:OfflineServicesRegister:export')")
    @Log(title = "报名管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OfflineServicesRegister offlineServicesRegister)
    {
        List<OfflineServicesRegister> list = offlineServicesRegisterService.selectOfflineServicesRegisterList(offlineServicesRegister);
        ExcelUtil<OfflineServicesRegister> util = new ExcelUtil<OfflineServicesRegister>(OfflineServicesRegister.class);
        util.exportExcel(response, list, "报名管理数据");
    }

    /**
     * 获取报名管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:OfflineServicesRegister:query')")
    @GetMapping(value = "/{registerId}")
    public AjaxResult getInfo(@PathVariable("registerId") Long registerId)
    {
        return AjaxResult.success(offlineServicesRegisterService.selectOfflineServicesRegisterByRegisterId(registerId));
    }

    /**
     * 新增报名管理
     */
    @PreAuthorize("@ss.hasPermi('mall:OfflineServicesRegister:add')")
    @Log(title = "报名管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OfflineServicesRegister offlineServicesRegister)
    {
        return toAjax(offlineServicesRegisterService.insertOfflineServicesRegister(offlineServicesRegister));
    }

    /**
     * 修改报名管理
     */
    @PreAuthorize("@ss.hasPermi('mall:OfflineServicesRegister:edit')")
    @Log(title = "报名管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OfflineServicesRegister offlineServicesRegister)
    {
        return toAjax(offlineServicesRegisterService.updateOfflineServicesRegister(offlineServicesRegister));
    }

    /**
     * 删除报名管理
     */
    @PreAuthorize("@ss.hasPermi('mall:OfflineServicesRegister:remove')")
    @Log(title = "报名管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{registerIds}")
    public AjaxResult remove(@PathVariable Long[] registerIds)
    {
        return toAjax(offlineServicesRegisterService.deleteOfflineServicesRegisterByRegisterIds(registerIds));
    }
}
