package com.jy.business.capital.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jy.business.capital.model.dto.CapitalAccountDto;
import com.jy.business.capital.model.dto.CapitalAccountSelectDto;
import com.jy.business.capital.model.vo.CapitalAccountVo;
import com.jy.business.capital.service.CapitalAccountService;
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("/capitalAccount")
public class CapitalAccountController {

    @Resource
    private CapitalAccountService capitalAccountService;

    /**
     * 资金账户分页
     */
    @GetMapping("/getPage")
    public Page<CapitalAccountVo> getPage(CapitalAccountSelectDto dto) {
        return capitalAccountService.getPage(dto);
    }

    /**
     * 资金账户明细
     */
    @GetMapping("/getDetail")
    public CapitalAccountVo getDetail(@Validated(DetailGroup.class) BaseSelectDto dto) {
        return capitalAccountService.getDetail(dto.getId());
    }

    /**
     * 资金账户新增
     */
    @PostMapping("/add")
    public void add(@Validated(AddGroup.class) @RequestBody CapitalAccountDto dto) {
        capitalAccountService.add(dto);
    }

    /**
     * 资金账户编辑
     */
    @PostMapping("/edit")
    public void edit(@Validated(EditGroup.class) @RequestBody CapitalAccountDto dto) {
        capitalAccountService.edit(dto);
    }

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

}
