package com.example.demo.test;

import com.example.demo.SmartBowBusinessServerApplication;
import com.example.demo.common.GlobalConfig;
import com.example.demo.common.GlobalRoot;
import com.example.demo.table.UserGameRecord;

import java.sql.Timestamp;
import java.util.Calendar;

/**
 * 测试
 */
public class Tester {

    public static void main(String[] args) {
        GlobalConfig.init();
        GlobalRoot.init();
        insertUserGameRecordsForTest(12);
//        insertUserGameRecordsForTest(21);
    }

    static void insertUserGameRecordsForTest(int userID) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MILLISECOND, 333);

        for (int j = 0; j < 30; j++) {
            if (j > 0) calendar.add(Calendar.DAY_OF_MONTH, -1);
            for (int i = 0; i < 24; i++) {
                UserGameRecord userGameRecord = new UserGameRecord();
                userGameRecord.setUserID(userID);
                calendar.set(Calendar.HOUR_OF_DAY, i);
                calendar.set(Calendar.MINUTE, i);
                calendar.set(Calendar.SECOND, i);
                userGameRecord.setDateTime(new Timestamp(calendar.getTimeInMillis()));
                userGameRecord.setGameType(i % 12 + 1);
                userGameRecord.setDuration(60);
                GlobalRoot.db.insert(userGameRecord);
            }
        }
        System.out.println("complete");
    }
}
