package com.fs.store.controller;

import java.util.List;

import com.fs.store.param.FsUsePromoterApplyParam;
import com.fs.store.vo.FsUserPromoterApplyVO;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.store.domain.FsUserPromoterApply;
import com.fs.store.service.IFsUserPromoterApplyService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 推广员申请Controller
 * 
 * @author fs
 * @date 2023-02-28
 */
@RestController
@RequestMapping("/store/userPromoterApply")
public class FsUserPromoterApplyController extends BaseController
{
    @Autowired
    private IFsUserPromoterApplyService fsUserPromoterApplyService;

    /**
     * 查询推广员申请列表
     */
    @PreAuthorize("@ss.hasPermi('store:userPromoterApply:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsUsePromoterApplyParam fsUserPromoterApply)
    {
        startPage();
        List<FsUserPromoterApplyVO> list = fsUserPromoterApplyService.selectFsUserPromoterApplyListVO(fsUserPromoterApply);
        return getDataTable(list);
    }

    /**
     * 导出推广员申请列表
     */
    @PreAuthorize("@ss.hasPermi('store:userPromoterApply:export')")
    @Log(title = "推广员申请", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsUserPromoterApply fsUserPromoterApply)
    {
        List<FsUserPromoterApply> list = fsUserPromoterApplyService.selectFsUserPromoterApplyList(fsUserPromoterApply);
        ExcelUtil<FsUserPromoterApply> util = new ExcelUtil<FsUserPromoterApply>(FsUserPromoterApply.class);
        return util.exportExcel(list, "userPromoterApply");
    }

    /**
     * 获取推广员申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('store:userPromoterApply:query')")
    @GetMapping(value = "/{applyId}")
    public AjaxResult getInfo(@PathVariable("applyId") Long applyId)
    {
        return AjaxResult.success(fsUserPromoterApplyService.selectFsUserPromoterApplyById(applyId));
    }

    /**
     * 新增推广员申请
     */
    @PreAuthorize("@ss.hasPermi('store:userPromoterApply:add')")
    @Log(title = "推广员申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsUserPromoterApply fsUserPromoterApply)
    {
        return toAjax(fsUserPromoterApplyService.insertFsUserPromoterApply(fsUserPromoterApply));
    }

    /**
     * 修改推广员申请
     */
    @PreAuthorize("@ss.hasPermi('store:userPromoterApply:edit')")
    @Log(title = "推广员申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsUserPromoterApply fsUserPromoterApply)
    {
        return toAjax(fsUserPromoterApplyService.updateFsUserPromoterApply(fsUserPromoterApply));
    }

    /**
     * 删除推广员申请
     */
    @PreAuthorize("@ss.hasPermi('store:userPromoterApply:remove')")
    @Log(title = "推广员申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{applyIds}")
    public AjaxResult remove(@PathVariable Long[] applyIds)
    {
        return toAjax(fsUserPromoterApplyService.deleteFsUserPromoterApplyByIds(applyIds));
    }
}
