package com.game.business.controller;

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

import com.game.common.core.domain.R;
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.game.common.annotation.Log;
import com.game.common.core.controller.BaseController;
import com.game.common.core.domain.AjaxResult;
import com.game.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.game.business.domain.AppDealScale;
import com.game.business.service.IAppDealScaleService;
import com.game.common.utils.poi.ExcelUtil;
import com.game.common.core.page.TableDataInfo;

/**
 * 主播分成比例Controller
 * 
 * @author game
 * @date 2024-08-11
 */
@RestController
@RequestMapping("/business/scale")
@Api(value = "AppDealScaleController", description = "主播分成比例接口", tags = {"主播分成比例"})
public class AppDealScaleController extends BaseController
{
    @Autowired
    private IAppDealScaleService appDealScaleService;

    /**
     * 查询主播分成比例列表
     */
    @PreAuthorize("@ss.hasPermi('business:scale:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询主播分成比例列表", notes = "获取主播分成比例列表")
    public TableDataInfo<AppDealScale> list(AppDealScale appDealScale)
    {
        startPage();
        List<AppDealScale> list = appDealScaleService.selectAppDealScaleList(appDealScale);
        return getDataTable(list);
    }

    /**
     * 导出主播分成比例列表
     */
    @PreAuthorize("@ss.hasPermi('business:scale:export')")
    @Log(title = "主播分成比例", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出主播分成比例列表", notes = "导出主播分成比例列表")
    public void export(HttpServletResponse response, AppDealScale appDealScale)
    {
        List<AppDealScale> list = appDealScaleService.selectAppDealScaleList(appDealScale);
        ExcelUtil<AppDealScale> util = new ExcelUtil<AppDealScale>(AppDealScale.class);
        util.exportExcel(response, list, "主播分成比例数据");
    }

    /**
     * 获取主播分成比例详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:scale:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取主播分成比例详细信息", notes = "获取主播分成比例详细信息")
    public R<AppDealScale> getInfo(@PathVariable("id") Long id)
    {
        return R.ok(appDealScaleService.selectAppDealScaleById(id));
    }

    /**
     * 新增主播分成比例
     */
    @PreAuthorize("@ss.hasPermi('business:scale:add')")
    @Log(title = "主播分成比例", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增主播分成比例", notes = "新增主播分成比例")
    @PostMapping
    public R add(@RequestBody AppDealScale appDealScale)
    {
        return R.ok(appDealScaleService.insertAppDealScale(appDealScale));
    }

    /**
     * 修改主播分成比例
     */
    @PreAuthorize("@ss.hasPermi('business:scale:edit')")
    @Log(title = "主播分成比例", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改主播分成比例", notes = "修改主播分成比例")
    @PutMapping
    public R edit(@RequestBody AppDealScale appDealScale)
    {
        return R.ok(appDealScaleService.updateAppDealScale(appDealScale));
    }

    /**
     * 删除主播分成比例
     */
    @PreAuthorize("@ss.hasPermi('business:scale:remove')")
    @Log(title = "主播分成比例", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除主播分成比例", notes = "删除主播分成比例")
	@DeleteMapping("/{ids}")
    public R remove(@PathVariable Long[] ids)
    {
        return R.ok(appDealScaleService.deleteAppDealScaleByIds(ids));
    }
}
