package com.jy.business.capital.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jy.business.capital.model.dto.CapitalTransactionsDto;
import com.jy.business.capital.model.dto.CapitalTransactionsSelectDto;
import com.jy.business.capital.model.vo.CapitalTransactionsVo;
import com.jy.business.capital.service.CapitalTransactionsService;
import com.jy.framework.model.base.BaseSelectDto;
import com.jy.framework.model.validation.AddGroup;
import com.jy.framework.model.validation.BatchDeleteGroup;
import com.jy.framework.model.validation.DetailGroup;
import com.jy.framework.model.validation.EditGroup;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 资金流水 前端控制器
 * </p>
 *
 * @author
 * @since 2024-10-16
 */
@RestController
@RequestMapping("/capitalTransactions")
public class CapitalTransactionsController {

    @Resource
    private CapitalTransactionsService capitalTransactionsService;

    /**
     * 资金流水分页
     */
    @GetMapping("/getPage")
    public Page<CapitalTransactionsVo> getPage(CapitalTransactionsSelectDto dto) {
        return capitalTransactionsService.getPage(dto);
    }

    /**
     * 资金流水明细
     */
    @GetMapping("/getDetail")
    public CapitalTransactionsVo getDetail(@Validated(DetailGroup.class) BaseSelectDto dto) {
        return capitalTransactionsService.getDetail(dto.getId());
    }

    /**
     * 资金流水新增
     */
    @PostMapping("/add")
    public void add(@Validated(AddGroup.class) @RequestBody CapitalTransactionsDto dto) {
        capitalTransactionsService.add(dto);
    }

    /**
     * 资金流水编辑
     */
    @PostMapping("/edit")
    public void edit(@Validated(EditGroup.class) @RequestBody CapitalTransactionsDto dto) {
        capitalTransactionsService.edit(dto);
    }

    /**
     * 资金流水删除
     */
    @PostMapping("/delete")
    public void delete(@Validated(BatchDeleteGroup.class) @RequestBody BaseSelectDto dto) {
        capitalTransactionsService.delete(dto.getIdList());
    }

}
