package com.jeequan.jeepay.mgr.ctrl.order;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jeequan.jeepay.core.constants.ApiCodeEnum;
import com.jeequan.jeepay.core.model.ApiRes;
import com.jeequan.jeepay.db.entity.PayAlizftSettRecord;
import com.jeequan.jeepay.mgr.ctrl.CommonCtrl;
import com.jeequan.jeepay.service.impl.PayAlizftSettRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 直付通 二级商户结算记录
 *
 * @author yr
 * 
 * @date 2023-09-04 10:15
 */
@RestController
@RequestMapping("/api/zftSettRecords")
public class PayAlizftSettRecordController extends CommonCtrl {

    @Autowired private PayAlizftSettRecordService settRecordService;

    /**
     * @author: yr
     * @date: 2023-09-04 10:15
     * @describe: 直付通结算记录列表
     */
    @PreAuthorize("hasAuthority('ENT_ZFT_SETT_RECORD_LIST')")
    @RequestMapping(value="", method = RequestMethod.GET)
    public ApiRes list() {
        PayAlizftSettRecord settRecord = getObject(PayAlizftSettRecord.class);
        IPage<PayAlizftSettRecord> pages = settRecordService.listByPage(getIPage(), settRecord);
        return ApiRes.page(pages);
    }

    /**
     * @author: yr
     * @date: 2023-09-04 10:15
     * @describe: 直付通结算记录列表
     */
    @PreAuthorize("hasAuthority('ENT_ZFT_SETT_RECORD_VIEW')")
    @RequestMapping(value="/{recordId}", method = RequestMethod.GET)
    public ApiRes detail(@PathVariable("recordId") String recordId) {
        PayAlizftSettRecord settRecord = settRecordService.getById(recordId);
        if (settRecord == null) {
            return ApiRes.fail(ApiCodeEnum.SYS_OPERATION_FAIL_SEARCH);
        }
        return ApiRes.ok(settRecord);
    }
}
