package com.njzscloud.dispose.finance.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.dispose.finance.pojo.entity.MoneyAccountEntity;
import com.njzscloud.dispose.finance.pojo.param.RechargeParam;
import com.njzscloud.dispose.finance.pojo.param.SearchMoneyAccountParam;
import com.njzscloud.dispose.finance.pojo.result.MoneyAccountResult;
import com.njzscloud.dispose.finance.service.MoneyAccountService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 资金账户表
 * @author ljw
 */
@Slf4j
@RestController
@RequestMapping("/money_account")
@RequiredArgsConstructor
public class MoneyAccountController {

    private final MoneyAccountService moneyAccountService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody MoneyAccountEntity moneyAccountEntity) {
        moneyAccountService.add(moneyAccountEntity);
        return R.success();
    }

    /**
     * 充值
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody RechargeParam param) {
        moneyAccountService.modify(param);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        moneyAccountService.del(ids);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<MoneyAccountResult> detail(@RequestParam("id") Long id) {
        return R.success(moneyAccountService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<MoneyAccountResult>> paging(PageParam pageParam, SearchMoneyAccountParam param) {
        return R.success(moneyAccountService.paging(pageParam, param));
    }
}


