/**
 * @filename:SeparateAccountsController 2024-10-23
 * @project KJT v1.1.0 Copyright(c) 2024 wanglang Co. Ltd. All right reserved.
 */
package com.trade.admin.business.separateaccounts.controller;

import com.trade.admin.business.separateaccounts.dto.SubmitSeparateAccountsDto;
import com.trade.admin.business.separateaccounts.service.BSeparateAccountsService;
import com.trade.admin.business.separateaccounts.vo.SeparateAccountsDetailVo;
import com.trade.admin.business.separateaccounts.vo.SeparateAccountsSubmitVo;
import com.trade.common.core.domain.ResponseResult;
import com.trade.common.core.page.GridPage;
import com.trade.service.business.separateaccounts.dto.SeparateAccountsSearchDto;
import com.trade.service.business.separateaccounts.vo.SeparateAccountsPageVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 说明： 分账表API接口层
 * </P>
 * 
 * @version: v1.1.0
 * @author: wanglang
 * @time 2024-10-24
 */
@Api(tags = "分账管理", value = "分账管理")
@RestController
@RequestMapping("/separateAccounts")
public class SeparateAccountsController {

    @Resource
    private BSeparateAccountsService separateAccountsService;

    /**
     * 获取分账列表分页信息
     *
     * @param searchDto 分账列表分页信息条件
     * @return 分账列表分页信息
     */
    @ApiOperation(value = "获取分账分页", notes = "获取分账分页")
    @PostMapping("/get/page")
    @PreAuthorize("@ss.hasPermi('business.separateaccounts:pages')")
    public ResponseResult<GridPage<SeparateAccountsPageVo>> getSeparateAccountsPage(
            @RequestBody SeparateAccountsSearchDto searchDto) {
        return ResponseResult.success(separateAccountsService.queryListByPage(searchDto));
    }

    @ApiOperation(value = "获取分账提交页面", notes = "获取分账提交页面")
    @GetMapping("/get/submitPage")
    @PreAuthorize("@ss.hasPermi('business.separateaccounts:query')")
    public ResponseResult<SeparateAccountsSubmitVo> querySubmitSeparateAccounts(Long id) {
        return ResponseResult.success(separateAccountsService.querySubmitSeparateAccounts(id));
    }

    @ApiOperation(value = "分账提交", notes = "分账提交")
    @PostMapping("/submit")
    @PreAuthorize("@ss.hasPermi('business.separateaccounts:submit')")
    public ResponseResult<Boolean> submitSeparateAccounts(
            @RequestBody @Validated List<SubmitSeparateAccountsDto> separateAccountsDto) {
        return ResponseResult.success(separateAccountsService.submitSeparateAccounts(separateAccountsDto));
    }

    @ApiOperation(value = "获取分账详情页面", notes = "获取分账详情页面")
    @GetMapping("/get/detail")
    @PreAuthorize("@ss.hasPermi('business.separateaccounts:detail')")
    public ResponseResult<SeparateAccountsDetailVo> querySeparateAccountsDetail(Long id) {
        return ResponseResult.success(separateAccountsService.querySeparateAccountsDetail(id));
    }
}
