package com.fastbee.data.controller.userRecharge;

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

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.fastbee.common.annotation.Log;
import com.fastbee.common.core.controller.BaseController;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.common.enums.BusinessType;
import com.fastbee.rechargecard.domain.UserConsumptionDetails;
import com.fastbee.rechargecard.service.IUserConsumptionDetailsService;
import com.fastbee.common.utils.poi.ExcelUtil;
import com.fastbee.common.core.page.TableDataInfo;

/**
 * 用户充值卡账单明细记录Controller
 *
 * @author kerwincui
 * @date 2024-12-18
 */
@RestController
@RequestMapping("/rechargecard/details")
@Api(tags = "用户充值卡账单明细记录")
public class UserConsumptionDetailsController extends BaseController
{
    @Autowired
    private IUserConsumptionDetailsService userConsumptionDetailsService;

    /**
     * 查询用户充值卡账单明细记录列表
     */
    @PreAuthorize("@ss.hasPermi('rechargecard:details:list')")
    @GetMapping("/list")
    @ApiOperation("查询用户充值卡账单明细记录列表")
    public TableDataInfo list(UserConsumptionDetails userConsumptionDetails)
    {
        startPage();
        List<UserConsumptionDetails> list = userConsumptionDetailsService.selectUserConsumptionDetailsList(userConsumptionDetails);
        return getDataTable(list);
    }

    /**
     * 导出用户充值卡账单明细记录列表
     */
    @ApiOperation("导出用户充值卡账单明细记录列表")
    @PreAuthorize("@ss.hasPermi('rechargecard:details:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserConsumptionDetails userConsumptionDetails)
    {
        List<UserConsumptionDetails> list = userConsumptionDetailsService.selectUserConsumptionDetailsList(userConsumptionDetails);
        ExcelUtil<UserConsumptionDetails> util = new ExcelUtil<UserConsumptionDetails>(UserConsumptionDetails.class);
        util.exportExcel(response, list, "用户充值卡账单明细记录数据");
    }

    /**
     * 获取用户充值卡账单明细记录详细信息列表
     */
    @PreAuthorize("@ss.hasPermi('rechargecard:details:query')")
    @GetMapping(value = "/list/{cardNumber}")
    @ApiOperation("获取用户充值卡账单明细记录详细信息列表")
    public AjaxResult getInfo(@PathVariable("cardNumber") String cardNumber)
    {
        //return success(userConsumptionDetailsService.selectUserConsumptionDetailsById(cardNumber));
        return success(userConsumptionDetailsService.selectUserConsumptionDetailsListById(cardNumber));
    }

    /**
     * 获取用户充值卡账单明细记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('rechargecard:details:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取用户充值卡账单明细记录详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        //return success(userConsumptionDetailsService.selectUserConsumptionDetailsById(cardNumber));
        return success(userConsumptionDetailsService.selectUserConsumptionDetailsById(id));
    }

    /**
     * 新增用户充值卡账单明细记录
     */
    @PreAuthorize("@ss.hasPermi('rechargecard:details:add')")
    @PostMapping
    @ApiOperation("新增用户充值卡账单明细记录")
    public AjaxResult add(@RequestBody UserConsumptionDetails userConsumptionDetails)
    {
        return toAjax(userConsumptionDetailsService.insertUserConsumptionDetails(userConsumptionDetails));
    }

    /**
     * 修改用户充值卡账单明细记录
     */
    @PreAuthorize("@ss.hasPermi('rechargecard:details:edit')")
    @PutMapping
    @ApiOperation("修改用户充值卡账单明细记录")
    public AjaxResult edit(@RequestBody UserConsumptionDetails userConsumptionDetails)
    {
        return toAjax(userConsumptionDetailsService.updateUserConsumptionDetails(userConsumptionDetails));
    }

    /**
     * 删除用户充值卡账单明细记录
     */
    @PreAuthorize("@ss.hasPermi('rechargecard:details:remove')")
    @DeleteMapping("/{ids}")
    @ApiOperation("删除用户充值卡账单明细记录")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(userConsumptionDetailsService.deleteUserConsumptionDetailsByIds(ids));
    }
}
