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

import com.zanxiang.game.platform.serve.pojo.req.PlatformSyncRequest;
import com.zanxiang.game.platform.serve.service.platform.PlatformBaseService;
import com.zanxiang.game.platform.serve.utils.SpringUtils;
import com.zanxiang.module.util.pojo.ResultVO;
import lombok.extern.slf4j.Slf4j;
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("/game/platform/sync")
public class GamePlatformSyncController {

    @PostMapping("/user")
    public ResultVO<Boolean> syncUserInfo(@RequestBody @Validated PlatformSyncRequest request) {
        PlatformBaseService service = SpringUtils.getBean(request.getGamePlatformEnum().getClazz());
        service.syncPlatformUser(request.getAccountIdList(), request.getStartDate(), request.getEndDate());
        return ResultVO.ok(Boolean.TRUE);
    }

    @PostMapping("/order")
    public ResultVO<Boolean> syncOrderInfo(@RequestBody @Validated PlatformSyncRequest request) {
        PlatformBaseService service = SpringUtils.getBean(request.getGamePlatformEnum().getClazz());
        service.syncPlatformOrder(request.getAccountIdList(), request.getStartDate(), request.getEndDate());
        return ResultVO.ok(Boolean.TRUE);
    }
}
