package com.ruoyi.mall.controller;

import java.util.List;
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.MallAppSalesmanAchievement;
import com.ruoyi.mall.service.IMallAppSalesmanAchievementService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * app-业务员业绩Controller
 *
 * @author ruoyi
 * @date 2024-07-04
 */
@RestController
@RequestMapping("/mall/mallAppSalesmanAchievement")
public class MallAppSalesmanAchievementController extends BaseController
{
    @Resource
    private IMallAppSalesmanAchievementService mallAppSalesmanAchievementService;

    /**
     * 查询app-业务员业绩列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallAppSalesmanAchievement:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallAppSalesmanAchievement mallAppSalesmanAchievement)
    {
        startPage();
        mallAppSalesmanAchievement.setDelFlag("0");
        List<MallAppSalesmanAchievement> list = mallAppSalesmanAchievementService.selectMallAppSalesmanAchievementList(mallAppSalesmanAchievement);
        return getDataTable(list);
    }

    /**
     * 导出app-业务员业绩列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallAppSalesmanAchievement:export')")
    @Log(title = "app-业务员业绩", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallAppSalesmanAchievement mallAppSalesmanAchievement)
    {
        List<MallAppSalesmanAchievement> list = mallAppSalesmanAchievementService.selectMallAppSalesmanAchievementList(mallAppSalesmanAchievement);
        ExcelUtil<MallAppSalesmanAchievement> util = new ExcelUtil<MallAppSalesmanAchievement>(MallAppSalesmanAchievement.class);
        return util.exportExcel(list, "app-业务员业绩数据");
    }

    /**
     * 获取app-业务员业绩详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallAppSalesmanAchievement:query')")
    @GetMapping(value = "/{achievementId}")
    public AjaxResult getInfo(@PathVariable("achievementId") Long achievementId)
    {
        return AjaxResult.success(mallAppSalesmanAchievementService.selectMallAppSalesmanAchievementByAchievementId(achievementId));
    }

    /**
     * 新增app-业务员业绩
     */
    @PreAuthorize("@ss.hasPermi('mall:mallAppSalesmanAchievement:add')")
    @Log(title = "app-业务员业绩", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallAppSalesmanAchievement mallAppSalesmanAchievement)
    {
        return toAjax(mallAppSalesmanAchievementService.insertMallAppSalesmanAchievement(mallAppSalesmanAchievement));
    }

    /**
     * 修改app-业务员业绩
     */
    @PreAuthorize("@ss.hasPermi('mall:mallAppSalesmanAchievement:edit')")
    @Log(title = "app-业务员业绩", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallAppSalesmanAchievement mallAppSalesmanAchievement)
    {
        return toAjax(mallAppSalesmanAchievementService.updateMallAppSalesmanAchievement(mallAppSalesmanAchievement));
    }

    /**
     * 删除app-业务员业绩
     */
    @PreAuthorize("@ss.hasPermi('mall:mallAppSalesmanAchievement:remove')")
    @Log(title = "app-业务员业绩", businessType = BusinessType.DELETE)
	@DeleteMapping("/{achievementIds}")
    public AjaxResult remove(@PathVariable Long[] achievementIds)
    {
        return toAjax(mallAppSalesmanAchievementService.deleteMallAppSalesmanAchievementByAchievementIds(achievementIds));
    }
}
