package com.njzscloud.supervisory.money.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.supervisory.money.pojo.entity.MoneyAccountEntity;
import com.njzscloud.supervisory.money.pojo.result.MoneyAccountResult;
import com.njzscloud.supervisory.money.service.MoneyAccountService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 资金管理
 */
@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 MoneyAccountEntity moneyAccountEntity) {
        moneyAccountService.modify(moneyAccountEntity);
        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 Long id) {
        return R.success(moneyAccountService.detail(id));
    }

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

}
