package com.game.business.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.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 com.game.common.annotation.DataSource;
import com.game.common.enums.DataSourceType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.game.business.domain.AppUsersCharge;
import com.game.business.service.IAppUsersChargeService;
import com.game.common.utils.poi.ExcelUtil;
import com.game.common.core.page.TableDataInfo;

/**
 * 充值记录Controller
 * 
 * @author game
 * @date 2024-06-18
 */
@RestController
@RequestMapping("/business/charge")
@Api(value = "AppUsersChargeController", description = "充值记录接口", tags = {"充值记录"})
public class AppUsersChargeController extends BaseController
{
    @Autowired
    private IAppUsersChargeService appUsersChargeService;

    /**
     * 查询充值记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:charge:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询充值记录列表", notes = "获取充值记录列表")
    public TableDataInfo list(AppUsersCharge appUsersCharge)
    {
        startPage();
        List<AppUsersCharge> list = appUsersChargeService.selectAppUsersChargeList(appUsersCharge);
        return getDataTable(list);
    }

    /**
     * 导出充值记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:charge:export')")
    @Log(title = "充值记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出充值记录列表", notes = "导出充值记录列表")
    public void export(HttpServletResponse response, AppUsersCharge appUsersCharge)
    {
        List<AppUsersCharge> list = appUsersChargeService.selectAppUsersChargeList(appUsersCharge);
        ExcelUtil<AppUsersCharge> util = new ExcelUtil<AppUsersCharge>(AppUsersCharge.class);
        util.exportExcel(response, list, "充值记录数据");
    }

    /**
     * 获取充值记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:charge:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取充值记录详细信息", notes = "获取充值记录详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appUsersChargeService.selectAppUsersChargeById(id));
    }

    /**
     * 新增充值记录
     */
    @PreAuthorize("@ss.hasPermi('business:charge:add')")
    @Log(title = "充值记录", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增充值记录", notes = "新增充值记录")
    @PostMapping
    public AjaxResult add(@RequestBody AppUsersCharge appUsersCharge)
    {
        return toAjax(appUsersChargeService.insertAppUsersCharge(appUsersCharge));
    }

    /**
     * 修改充值记录
     */
    @PreAuthorize("@ss.hasPermi('business:charge:edit')")
    @Log(title = "充值记录", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改充值记录", notes = "修改充值记录")
    @PutMapping
    public AjaxResult edit(@RequestBody AppUsersCharge appUsersCharge)
    {
        return toAjax(appUsersChargeService.updateAppUsersCharge(appUsersCharge));
    }

    /**
     * 删除充值记录
     */
    @PreAuthorize("@ss.hasPermi('business:charge:remove')")
    @Log(title = "充值记录", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除充值记录", notes = "删除充值记录")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appUsersChargeService.deleteAppUsersChargeByIds(ids));
    }
}
