package com.zanxiang.game.platform.serve.controller.api;

import com.zanxiang.game.platform.serve.pojo.dto.PlatformDeYangOrderDTO;
import com.zanxiang.game.platform.serve.pojo.dto.PlatformDeYangUserDTO;
import com.zanxiang.game.platform.serve.service.IPlatformDeYangOrderService;
import com.zanxiang.game.platform.serve.service.IPlatformDeYangUserService;
import com.zanxiang.module.util.JsonUtil;
import com.zanxiang.module.util.pojo.ResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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;

/**
 * @author : lingfeng
 * @time : 2023-05-22
 * @description : 德扬接口
 */
@Slf4j
@RestController
@RequestMapping("/api/deYang/game")
public class PlatformDeYangApiController {

    @Autowired
    private IPlatformDeYangOrderService platformDeYangOrderService;

    @Autowired
    private IPlatformDeYangUserService platformDeYangUserService;

    @PostMapping("/user")
    public ResultVO<Boolean> pushUserInfo(@RequestBody @Validated PlatformDeYangUserDTO userDTO) {
        log.error("接收到德扬用户信息推送, userDTO : {}", JsonUtil.toString(userDTO));
        return ResultVO.ok(platformDeYangUserService.addOrUpdate(userDTO));
    }

    @PostMapping("/order")
    public ResultVO<Boolean> pushOrderInfo(@RequestBody @Validated PlatformDeYangOrderDTO orderDTO) {
        log.error("接收到德扬订单信息推送, orderParam : {}", JsonUtil.toString(orderDTO));
        return ResultVO.ok(platformDeYangOrderService.addOrUpdate(orderDTO));
    }

}
