package com.app.controller.api;

import com.app.annotation.platform.OperationLog;
import com.app.constant.SystemConstant;
import com.app.dto.Result;
import com.app.dto.order.operation.RefundDto;
import com.app.entity.order.OpenCourseRefund;
import com.app.service.order.OpenCourseRefundService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
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;

import javax.validation.Valid;

@Api(description = "开课 - 退课")
@Slf4j
@Validated
@RestController("ApiOpenCourseRefundController")
@RequestMapping("/api/open-course-order/refund")
public class OpenCourseRefundController {

    @Autowired
    private OpenCourseRefundService openCourseRefundService;

    @OperationLog("更新 - 申请退课")
    @ApiOperation(value = "申请退课")
    @PostMapping("/apply")
    public ResponseEntity<Result<OpenCourseRefund>> apply(@Valid @RequestBody RefundDto dto) {
        String organId = SystemConstant.organId;
        String accountId = "";
        return new ResponseEntity(new Result().ok(openCourseRefundService.apply(organId, dto.getOpenCourseOrderItemId(), dto.getRemarks(), accountId, dto.getWxmpFormId())), HttpStatus.OK);
    }

}
