package com.diagbot.web;

import com.diagbot.annotation.SysLogger;
import com.diagbot.dto.ProductLineDTO;
import com.diagbot.dto.RespDTO;
import com.diagbot.facade.LantoneProductFacade;
import com.diagbot.facade.ProductOrderFacade;
import com.diagbot.facade.UserRenewalsFacade;
import com.diagbot.vo.AddOrderVO;
import com.diagbot.vo.AddRenewalsInfoVO;
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;

import java.util.List;

/**
 * @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;
    @Autowired
    private UserRenewalsFacade userRenewalsFacade;

    @ApiOperation(value = "用户更多服务——显示产品[by:wangyu]"
            , notes = "根据用户id查询已开通信息")
    @PostMapping("/showProductInfo")
    @SysLogger("showProductInfo")
    public RespDTO<List<ProductLineDTO>> showProductInfo() {
        return lantoneProductFacade.productLine();
    }

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

    @ApiOperation(value = "用户更多服务——产品续费[by:wangyu]",
            notes = "根据用户点击的产品提交续费申请" +
                    "id：产品id，必填<br>")
    @PostMapping("/addRenewalsInfo")
    @SysLogger("addRenewalsInfo")
    @Transactional
    public RespDTO<Boolean> addRenewalsInfo(@RequestBody AddRenewalsInfoVO addRenewalsInfoVO) {
        return userRenewalsFacade.addRenewalsInfos(addRenewalsInfoVO);
    }

}


