package org.jeecg.modules.api.controller2;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.apiBean.PageBean;
import org.jeecg.modules.apiService.ExaminationService;
import org.jeecg.modules.apiService.ExchangeService;
import org.jeecg.modules.employExchange.entity.EmployExchange;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags="兑换码相关接口")
@RestController
@RequestMapping("/employ/exchange")
@Slf4j
public class ExchangeController {

    /******************************************************************************************************************/
    //兑换码信息
    @Resource
    private ExchangeService exchangeService;
    /******************************************************************************************************************/

    @ApiOperation(value="我的服务-查询兑换码列表", notes="我的服务-查询兑换码列表")
    @RequestMapping(value = "/queryExchangeList", method = {RequestMethod.GET})
    public Result<?> queryExchangeList(PageBean pageBean){
        return exchangeService.queryExchangeList(pageBean);
    }

    @ApiOperation(value="我的服务-使用兑换码", notes="我的服务-使用兑换码")
    @RequestMapping(value = "/useExchange", method = {RequestMethod.POST})
    public Result<?> useExchange(@RequestHeader("X-Access-Token") String token, String code){
        return exchangeService.useExchange(token, code);
    }

    @ApiOperation(value="我的服务-生成兑换码", notes="我的服务-生成兑换码")
    @RequestMapping(value = "/addExchange", method = {RequestMethod.POST})
    public Result<?> addExchange(EmployExchange employExchange){
        return exchangeService.addExchange(employExchange);
    }

}
