package org.wfc.user.controller;

import cn.hutool.core.collection.CollUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wfc.common.core.web.controller.BaseController;
import org.wfc.common.core.web.domain.AjaxResult;
import org.wfc.common.core.web.page.TableDataInfo;
import org.wfc.user.domain.UPayment;
import org.wfc.user.service.IUPaymentService;

import java.util.List;

/**
 * <p>
 * 用户平台-支付表 前端控制器
 * </p>
 *
 * @author sys
 * @since 2025-01-09
 */
@RestController
@RequestMapping("/user/uPayment")
public class UPaymentController extends BaseController {

    @Autowired
    private IUPaymentService uPaymentService;

    @GetMapping("/page")
    public TableDataInfo page(UPayment uPayment) {
        startPage();
        List<UPayment> list = uPaymentService.list();
        return getDataTable(list);
    }

    @GetMapping("/list")
    public AjaxResult list(UPayment uPayment) {
        List<UPayment> list = uPaymentService.list();
        return success(list);
    }

    @GetMapping(value = "/{id}")
    public AjaxResult getById(@PathVariable("id") Long id) {
        return success(uPaymentService.getById(id));
    }

    @PostMapping
    public AjaxResult add(@RequestBody UPayment uPayment) {
        return toAjax(uPaymentService.save(uPayment));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody UPayment uPayment) {
        return toAjax(uPaymentService.updateById(uPayment));
    }

    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(uPaymentService.removeByIds(CollUtil.newArrayList(ids)));
    }

}
