package org.springblade.gateway.point_gateway.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springblade.core.tool.api.R;
import org.springblade.gateway.point_gateway.service.PointExchangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("app/point")
@Api(value = "积分兑换", tags = "积分兑换接口")
public class PointExchangeController {

	@Autowired
	private PointExchangeService pointExchangeService;

	//积分兑换商品
	@PostMapping("/exchange")
	@ApiOperation("积分兑换")
	public R<Boolean> exchange(@ApiParam(value = "兑换类型",required = true) @RequestParam Integer type,
							   @ApiParam(value = "手机号",required = true) @RequestParam String phone,
							   @ApiParam(value = "兑换数量",required = true) @RequestParam Long num,
							   @ApiParam(value = "商品ID",required = true) @RequestParam Long goodsId,
						   @ApiParam(value = "收获地址ID",required = false) @RequestParam Long addressId){
		return R.status(pointExchangeService.exchange(type,phone,goodsId,addressId,num));

	}
}
