|
|
@@ -1,8 +1,10 @@
|
|
|
package com.seecoder.BlueWhale.serviceImpl;
|
|
|
|
|
|
+import com.seecoder.BlueWhale.enums.RoleEnum;
|
|
|
import com.seecoder.BlueWhale.exception.BlueWhaleException;
|
|
|
import com.seecoder.BlueWhale.repository.StoreRepository;
|
|
|
import com.seecoder.BlueWhale.repository.UserRepository;
|
|
|
+import com.seecoder.BlueWhale.po.Store;
|
|
|
import com.seecoder.BlueWhale.po.User;
|
|
|
import com.seecoder.BlueWhale.service.UserService;
|
|
|
import com.seecoder.BlueWhale.util.SecurityUtil;
|
|
|
@@ -59,7 +61,11 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
|
@Override
|
|
|
public UserVO getInformation() {
|
|
|
- return wrapWithStoreName(securityUtil.getCurrentUser().toVO());
|
|
|
+ User user=securityUtil.getCurrentUser();
|
|
|
+ if (user.getRole()==RoleEnum.STAFF) {
|
|
|
+ return wrapWithStoreName(user.toVO());
|
|
|
+ }
|
|
|
+ return user.toVO();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -80,8 +86,14 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
|
private UserVO wrapWithStoreName(UserVO userVO){
|
|
|
Integer storeId = userVO.getStoreId();
|
|
|
- String storeName = storeRepository.findById(storeId).get().getName();
|
|
|
- userVO.setStoreName(storeName);
|
|
|
+ if (storeId==null){
|
|
|
+ return userVO;
|
|
|
+ }
|
|
|
+ Store store = storeRepository.findById(storeId).get();
|
|
|
+ if (store==null){
|
|
|
+ return userVO;
|
|
|
+ }
|
|
|
+ userVO.setStoreName(store.getName());
|
|
|
return userVO;
|
|
|
}
|
|
|
}
|