|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.zy.asrs.wms.common.domain.BaseParam; | 
|---|
|  |  |  | import com.zy.asrs.wms.system.entity.User; | 
|---|
|  |  |  | import com.zy.asrs.wms.system.entity.UserLogin; | 
|---|
|  |  |  | import com.zy.asrs.wms.system.service.UserLoginService; | 
|---|
|  |  |  | import com.zy.asrs.wms.system.service.UserRoleService; | 
|---|
|  |  |  | import com.zy.asrs.wms.system.service.UserService; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.security.core.Authentication; | 
|---|
|  |  |  | import org.springframework.security.core.context.SecurityContextHolder; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Created by vincent on 1/30/2024 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public class BaseController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | protected static final String RANGE_TIME_LINK = " - "; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private UserLoginService userLoginService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private UserRoleService userRoleService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private UserService userService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public User getLoginUser() { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | 
|---|
|  |  |  | Object object = authentication.getPrincipal(); | 
|---|
|  |  |  | if (object instanceof User) { | 
|---|
|  |  |  | return (User) object; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(object instanceof UserLogin) { | 
|---|
|  |  |  | UserLogin userLogin = (UserLogin) object; | 
|---|
|  |  |  | User user = userService.superGetById(userLogin.getUserId()); | 
|---|
|  |  |  | return user; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Long getHostId() { | 
|---|
|  |  |  | User loginUser = getLoginUser(); | 
|---|
|  |  |  | return loginUser == null ? null : loginUser.getHostId(); | 
|---|
|  |  |  | return loginUser.getHostId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public <T extends BaseParam> T buildParam(Map<String, Object> map, Class<T> clz) { | 
|---|