package com.jwipc.finance.controller.rest;


import com.jwipc.finance.logic.CompanyAccountStatementApproveLogic;
import com.jwipc.finance.logic.CompanyAccountStatementDetailLogic;
import com.jwipc.finance.model.query.AsApproveQuery;
import com.jwipc.page.PageView;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static com.jwipc.finance.constant.ModuleConst.MODULE_ROOT;

/**
 * <p>
 *     对账模块-对账单 前端控制器
 * </p>
 *
 * @author JT
 * @since 2020-07-31
 */
@RestController
@RequestMapping(MODULE_ROOT + "/company/account/statement/detail/rest")
@RequiredArgsConstructor
public class CompanyAccountStatementDetailRestController {
    private final CompanyAccountStatementDetailLogic costAccountStatementDetailLogic;
    private final CompanyAccountStatementApproveLogic costAccountStatementApproveLogic;

    /**
     * 根据对账单ID获取对账单明细数据
     *
     * @param asId 对账单ID
     * @return 结果
     */
    @PostMapping("/find/by/statement/id")
    public ResponseEntity findByStatementId(Long asId){
        return ResponseEntity.ok(costAccountStatementDetailLogic.findByStatementIdPage(asId));
    }

    /**
     * 获取对账单审批确认备注
     *
     * @param query 查询参数
     * @return 结果
     */
    @PostMapping("/find/as/approve/log")
    public PageView findStatementApproveLog(AsApproveQuery query){
        return costAccountStatementApproveLogic.findByPage(query);
    }
}
