|
@@ -4,20 +4,25 @@ import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import ieven.server.webapp.domain.user.User;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.core.io.Resource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
+import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Service
|
|
|
public class UserService {
|
|
|
+ @Value("classpath:user.json")
|
|
|
+ private Resource userResources;
|
|
|
|
|
|
public List<User> users = new ArrayList<>();
|
|
|
|
|
|
@PostConstruct
|
|
|
- public void loadUsers() {
|
|
|
- List<String> strings = FileUtil.readLines("user.json", "utf-8");
|
|
|
+ public void loadUsers() throws IOException {
|
|
|
+ List<String> strings = FileUtil.readLines(userResources.getFile(), "utf-8");
|
|
|
JSONArray jsonArray = JSONUtil.parseArray(String.join("", strings));
|
|
|
this.users = JSONUtil.toList(jsonArray, User.class);
|
|
|
for (User user : users) {
|