package com.oo.demo.service;

import lombok.Builder;
import lombok.Data;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;

/**
 * @BelongsProject: onlyoffice-demo
 * @BelongsPackage: com.oo.demo.service
 * @CreateTime: 2023-08-05 17:14
 * @Description: TODO
 * @Version: 1.0
 */
@Data
@Builder
public class Oprator {
    private static Logger logger = LoggerFactory.getLogger(Oprator.class);
    private static List<Map<String, String>> cache1 = new ArrayList<>();
    private static Integer index;

    static {
        for (int i = 0; i < 1; i++) {
            Map<String, String> map = new HashMap<>();
//            map.put("userId", IdUtil.simpleUUID().substring(0,6));
//            map.put("userName","TongHui"+map.get("userId"));
            map.put("userId", "0");
            map.put("userName", "OnlyOfficeUser1");
            cache1.add(map);
        }
        logger.info("用户初始完毕");
//        Random random = new Random();
//        index = random.nextInt(10);
        index = 0;
        logger.info("获取用户完毕" + index);
    }

    public static String getUserName() {
        return cache1.get(index).get("userName");
    }

    public static String getUserId() {
        return cache1.get(index).get("userId");
    }
}
