package com.zanxiang.game.module.sdk.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zanxiang.game.module.mybatis.entity.GameShellLog;
import com.zanxiang.game.module.mybatis.mapper.GameShellLogMapper;
import com.zanxiang.game.module.sdk.pojo.param.GameShellLogParam;
import com.zanxiang.game.module.sdk.service.IGameShellLogService;
import com.zanxiang.module.web.util.IpUtil;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * @author : lingfeng
 * @time : 2023-08-17
 * @description : 游戏壳包日志
 */
@Slf4j
@Service
public class GameShellLogServiceImpl extends ServiceImpl<GameShellLogMapper, GameShellLog> implements IGameShellLogService {

    @Override
    public boolean gameShellLogAdd(GameShellLogParam param, HttpServletRequest request) {
        return super.save(GameShellLog.builder()
                .version(param.getVersion())
                .ip(IpUtil.getRealIp(request))
                .data(param.getData())
                .createTime(LocalDateTime.now())
                .build());
    }
}
