package com.diagbot.web;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.diagbot.annotation.SysLogger;
import com.diagbot.dto.RespDTO;
import com.diagbot.entity.LantoneProduct;
import com.diagbot.facade.LantoneProductFacade;
import com.diagbot.facade.ProductOrderFacade;
import com.diagbot.vo.AddOrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
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;

/**
 * @Description: diagbot更多服务 前端控制器
 * @author: wangyu
 * @time: 2018/9/17 18:28
 */
@RestController
@Api(value="用户更多服务API", tags={"用户更多服务API"})
@RequestMapping("/morServices")
@SuppressWarnings("unchecked")
public class MoreServiceController {
    @Autowired
    private LantoneProductFacade lantoneProductFacade;
    @Autowired
    private ProductOrderFacade productOrderFacade;

    @ApiOperation(value = "根据用户id查询已开通信息[by:wangyu]", notes = "根据用户id查询已开通信息")
    @PostMapping("/showProductInfo")
    @SysLogger("showProductInfo")
    public RespDTO<IPage<LantoneProduct>> showProductInfo(Page page){
        IPage<LantoneProduct> diagLantoneProducts =lantoneProductFacade.productLine(page);
        return RespDTO.onSuc(diagLantoneProducts);
    }

    @ApiOperation(value = "生成订单[by:wangyu]", notes = "根据用户所选择的产品生成订单")
    @PostMapping("/addOrder")
    @SysLogger("addOrder")
    @Transactional
    public RespDTO<Boolean> addOrder( @RequestBody AddOrderVO addOrderVO){
        return RespDTO.onSuc(productOrderFacade.addOrders(addOrderVO));
    }

}


