32 lines
769 B
Java
32 lines
769 B
Java
package cn.allms.config;
|
|
|
|
import lombok.Data;
|
|
|
|
import java.util.List;
|
|
import java.util.Random;
|
|
|
|
|
|
/**
|
|
* 随机图片配置类
|
|
*
|
|
* @author josxy
|
|
*/
|
|
@Data
|
|
public class RandomPicturesConfig {
|
|
private List<String> pictures;
|
|
private final static String DEFAULT = "https://tva1.sinaimg.cn/large/0072Vf1pgy1foxk3rxvthj31kw0w0x3c";
|
|
|
|
/**
|
|
* TODO
|
|
* 随机获取一种图片
|
|
* @return
|
|
*/
|
|
public String getRandomPicAddr() {
|
|
Random random = new Random();
|
|
System.out.println(this.pictures);
|
|
System.out.println(this.pictures.get(random.nextInt(2)) + System.currentTimeMillis());
|
|
return this.pictures.size() > 0 ?
|
|
this.pictures.get(random.nextInt(2)) + System.currentTimeMillis() : DEFAULT;
|
|
}
|
|
}
|