parent
a6a3d670c2
commit
c6e0894bcc
@ -0,0 +1,56 @@ |
||||
package com.app.service; |
||||
|
||||
import com.app.bean.Region; |
||||
import com.app.bean.Users; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.PostConstruct; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service |
||||
public class ConstantsService { |
||||
|
||||
public static final Map<Integer, Region> regionMap=new HashMap<>(); |
||||
|
||||
public static final Map<Integer, Users> usersMap=new HashMap<>(); |
||||
|
||||
@Autowired |
||||
private RegionService regionService; |
||||
|
||||
@Autowired |
||||
private UsersService usersService; |
||||
|
||||
@PostConstruct |
||||
public void init(){ |
||||
initRegion(); |
||||
|
||||
initUsers(); |
||||
} |
||||
|
||||
public void initRegion(){ |
||||
regionMap.clear(); |
||||
List<Region> regionList= regionService.list(); |
||||
for (Region region:regionList){ |
||||
regionMap.put(region.getId(),region); |
||||
} |
||||
} |
||||
|
||||
public void initUsers() { |
||||
usersMap.clear(); |
||||
List<Users> usersList=usersService.list(); |
||||
for(Users users:usersList){ |
||||
usersMap.put(users.getId(),users); |
||||
} |
||||
} |
||||
|
||||
public static Map<Integer, Region> getRegionMap() { |
||||
return regionMap; |
||||
} |
||||
|
||||
public static Map<Integer, Users> getUsersMap() { |
||||
return usersMap; |
||||
} |
||||
} |
Loading…
Reference in new issue