package org.springblade.gateway.common_gateway.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.tool.api.R;
import org.springblade.gateway.common_gateway.service.IOrderUrlAndColorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RequestMapping("/app/yeepay")
@RestController
@AllArgsConstructor
public class OrderUrlAndColorController {
	@Autowired
	private IOrderUrlAndColorService orderUrlAndColorService;

	@ApiLog("保存微信订单号")
	@PostMapping("/saveOrderUrlAndColor")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "保存", notes = "传入orderId,orderUrl,color")
	public R saveOrderUrlAndColor(@ApiParam(value = "订单id", required = true) @RequestParam Long orderId,
									 @ApiParam(value = "url", required = true) @RequestParam String orderUrl,
									 @ApiParam(value = "type", required = true) @RequestParam String type,
									 @ApiParam(value = "color", required = true) @RequestParam String color) {
		orderUrlAndColorService.SaveOrderUrlAndColor(orderId, orderUrl, color,type);
		return R.status(true);
	}

	@ApiLog("查询微信订单号")
	@GetMapping("/getOrderUrlAndColor")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "查询", notes = "传入orderId")
	public R<HashMap<String, Object>> getOrderUrlAndColor(@ApiParam(value = "订单id", required = true) @RequestParam Long orderId) {
		return R.data(orderUrlAndColorService.getSaveOrderUrlAndColor(orderId));
	}
}
