package me.zhengjie.modules.dm.order.rest;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.Log;
import me.zhengjie.modules.dm.order.domain.DmOrderPayment;
import me.zhengjie.modules.dm.order.domain.DmOrderRecord;
import me.zhengjie.modules.dm.order.service.DmOrderPaymentService;
import me.zhengjie.modules.dm.order.service.dto.DmOrderPaymentQueryCriteria;
import me.zhengjie.modules.dm.order.service.dto.DmOrderRecordQueryCriteria;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@Api(tags = "orderPayment管理")
@RequestMapping("/api/dmOrderPayment")
public class DmOrderPaymentController {
    private final DmOrderPaymentService dmOrderPaymentService;

    @GetMapping
    @Log("查询order")
    @ApiOperation("查询order")
    @PreAuthorize("@el.check('dmOrderPayment:list')")
    public ResponseEntity<Object> query(DmOrderPaymentQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity<>(dmOrderPaymentService.queryAll(criteria,pageable), HttpStatus.OK);
    }

    @PostMapping
    @Log("新增order")
    @ApiOperation("新增order")
    @PreAuthorize("@el.check('dmOrderPayment:add')")
    public ResponseEntity<Object> create(@Validated @RequestBody DmOrderPayment resources){
        return new ResponseEntity<>(dmOrderPaymentService.create(resources),HttpStatus.CREATED);
    }
}
