feat: bug-528 app端添加管理功能
This commit is contained in:
parent
5df11931f1
commit
63e1581a5e
|
|
@ -10,6 +10,7 @@ import com.nflg.mobilebroken.common.pojo.ApiResult;
|
|||
import com.nflg.mobilebroken.common.pojo.vo.AppLoginVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.MenuVO;
|
||||
import com.nflg.mobilebroken.common.util.AppUserUtil;
|
||||
import com.nflg.mobilebroken.common.util.MultilingualUtil;
|
||||
import com.nflg.mobilebroken.common.util.SaTokenAppUtil;
|
||||
import com.nflg.mobilebroken.common.util.VUtils;
|
||||
import com.nflg.mobilebroken.repository.entity.AdminUser;
|
||||
|
|
@ -57,8 +58,25 @@ public class AppController extends ControllerBase {
|
|||
*/
|
||||
@GetMapping("login")
|
||||
public ApiResult<AppLoginVO> login(String userName, String password) {
|
||||
AppUser user=appUserService.getUser(userName,password);
|
||||
if (Objects.nonNull(user)) {
|
||||
AdminUser adminUser =adminUserService.getUser(userName,password);
|
||||
if (Objects.nonNull(adminUser)){
|
||||
VUtils.trueThrow(Objects.equals(adminUser.getState(), UserState.Disabled.getState()))
|
||||
.throwMessage(STATE.PassportErr, dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_SYSTEMERROR, Constant.DICTIONARY_ITEM_ACCOUNT_DISABLED, MultilingualUtil.getLanguage()));
|
||||
VUtils.trueThrow(Objects.equals(adminUser.getState(), UserState.ToBeActivated.getState()))
|
||||
.throwMessage(STATE.PassportErr, dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_SYSTEMERROR, Constant.DICTIONARY_ITEM_ACCOUNT_HAS_EXPIRED, MultilingualUtil.getLanguage()));
|
||||
SaTokenAppUtil.login(adminUser.getId(), SaLoginConfig
|
||||
.setExtra("from", Constant.FROM_ADMIN)
|
||||
.setExtra("name", adminUser.getUserName())
|
||||
.setExtra("email", adminUser.getEmail()));
|
||||
SaTokenInfo tokenInfo = SaTokenAppUtil.getTokenInfo();
|
||||
return ApiResult.success(new AppLoginVO()
|
||||
.setUserId(adminUser.getId())
|
||||
.setToken(tokenInfo.getTokenValue())
|
||||
.setExpire(tokenInfo.getTokenTimeout())
|
||||
.setLanguageCode(Constant.DEFAULT_LANGUAGE_CODE)
|
||||
.setPlatform(Constant.FROM_ADMIN));
|
||||
}else {
|
||||
AppUser user=appUserService.getUser(userName,password);
|
||||
VUtils.trueThrow(Objects.equals(user.getState(), UserState.Disabled.getState()))
|
||||
.throwMessage(STATE.PassportErr, dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_SYSTEMERROR, Constant.DICTIONARY_ITEM_ACCOUNT_DISABLED, user.getLanguageCode()));
|
||||
VUtils.trueThrow(Objects.equals(user.getState(), UserState.ToBeActivated.getState()))
|
||||
|
|
@ -68,7 +86,7 @@ public class AppController extends ControllerBase {
|
|||
VUtils.trueThrow(user.getExpireTime().isBefore(ChronoLocalDate.from(LocalDateTime.now())) && !user.getIsPrimary())
|
||||
.throwMessage(STATE.PassportErr, dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_SYSTEMERROR, Constant.DICTIONARY_ITEM_ACCOUNT_HAS_EXPIRED, user.getLanguageCode()));
|
||||
SaTokenAppUtil.login(user.getId(), SaLoginConfig
|
||||
.setExtra("from", "app")
|
||||
.setExtra("from", Constant.FROM_APP)
|
||||
.setExtra("name", user.getName())
|
||||
.setExtra("email", user.getEmail())
|
||||
.setExtra("companyIds", StrUtil.split(user.getCompanyId(), ",").stream().map(Integer::valueOf).collect(Collectors.toList()))
|
||||
|
|
@ -81,26 +99,7 @@ public class AppController extends ControllerBase {
|
|||
.setToken(tokenInfo.getTokenValue())
|
||||
.setExpire(tokenInfo.getTokenTimeout())
|
||||
.setLanguageCode(user.getLanguageCode())
|
||||
.setPlatform("app"));
|
||||
}else {
|
||||
AdminUser adminUser =adminUserService.getUser(userName,password);
|
||||
VUtils.trueThrow(Objects.isNull(adminUser))
|
||||
.throwMessage(STATE.PassportErr, dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_SYSTEMERROR, Constant.DICTIONARY_ITEM_INCORRECTUSERNAMEORPASSWORD, Constant.DEFAULT_LANGUAGE_CODE));
|
||||
VUtils.trueThrow(Objects.equals(adminUser.getState(), UserState.Disabled.getState()))
|
||||
.throwMessage(STATE.PassportErr, dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_SYSTEMERROR, Constant.DICTIONARY_ITEM_ACCOUNT_DISABLED, Constant.DEFAULT_LANGUAGE_CODE));
|
||||
VUtils.trueThrow(Objects.equals(adminUser.getState(), UserState.ToBeActivated.getState()))
|
||||
.throwMessage(STATE.PassportErr, dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_SYSTEMERROR, Constant.DICTIONARY_ITEM_ACCOUNT_HAS_EXPIRED, Constant.DEFAULT_LANGUAGE_CODE));
|
||||
SaTokenAppUtil.login(adminUser.getId(), SaLoginConfig
|
||||
.setExtra("from", "admin")
|
||||
.setExtra("name", adminUser.getUserName())
|
||||
.setExtra("email", adminUser.getEmail()));
|
||||
SaTokenInfo tokenInfo = SaTokenAppUtil.getTokenInfo();
|
||||
return ApiResult.success(new AppLoginVO()
|
||||
.setUserId(adminUser.getId())
|
||||
.setToken(tokenInfo.getTokenValue())
|
||||
.setExpire(tokenInfo.getTokenTimeout())
|
||||
.setLanguageCode(Constant.DEFAULT_LANGUAGE_CODE)
|
||||
.setPlatform("admin"));
|
||||
.setPlatform(Constant.FROM_APP));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import com.nflg.mobilebroken.common.pojo.vo.AdminUserSimpleVO;
|
|||
import com.nflg.mobilebroken.common.pojo.vo.AdminUserVO;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.RoleSimpleVO;
|
||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||
import com.nflg.mobilebroken.common.util.MultilingualUtil;
|
||||
import com.nflg.mobilebroken.common.util.VUtils;
|
||||
import com.nflg.mobilebroken.repository.entity.*;
|
||||
import com.nflg.mobilebroken.repository.mapper.AdminUserMapper;
|
||||
|
|
@ -64,15 +65,22 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
|||
@Resource
|
||||
private ITBaseDeviceTypeService deviceTypeService;
|
||||
|
||||
@Resource
|
||||
private IDictionaryItemTranslateService dictionaryItemTranslateService;
|
||||
|
||||
@Override
|
||||
public AdminUser getUser(String userName, String password) {
|
||||
AdminUser user = lambdaQuery()
|
||||
.eq(AdminUser::getLoginName, userName)
|
||||
.one();
|
||||
if (Objects.nonNull(user) && PASSWORDENCODER.matches(password, user.getPassword())) {
|
||||
if (Objects.isNull(user)) return null;
|
||||
if (PASSWORDENCODER.matches(password, user.getPassword())) {
|
||||
return user;
|
||||
}else {
|
||||
VUtils.trueThrowBusinessError(true)
|
||||
.throwMessage(dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_SYSTEMERROR, Constant.DICTIONARY_ITEM_INCORRECTUSERNAMEORPASSWORD, MultilingualUtil.getLanguage()));
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -11,10 +11,7 @@ import com.nflg.mobilebroken.common.exception.NflgException;
|
|||
import com.nflg.mobilebroken.common.pojo.PageData;
|
||||
import com.nflg.mobilebroken.common.pojo.request.*;
|
||||
import com.nflg.mobilebroken.common.pojo.vo.*;
|
||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||
import com.nflg.mobilebroken.common.util.AppUserUtil;
|
||||
import com.nflg.mobilebroken.common.util.PageUtil;
|
||||
import com.nflg.mobilebroken.common.util.VUtils;
|
||||
import com.nflg.mobilebroken.common.util.*;
|
||||
import com.nflg.mobilebroken.repository.entity.*;
|
||||
import com.nflg.mobilebroken.repository.mapper.AppUserMapper;
|
||||
import com.nflg.mobilebroken.repository.service.*;
|
||||
|
|
@ -69,16 +66,18 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Resource
|
||||
private IDictionaryItemTranslateService dictionaryItemTranslateService;
|
||||
|
||||
@Override
|
||||
public AppUser getUser(String userName, String password) {
|
||||
AppUser user = lambdaQuery()
|
||||
.eq(AppUser::getIsDel, false)
|
||||
.eq(AppUser::getLoginName, userName)
|
||||
.one();
|
||||
if (Objects.nonNull(user) && PASSWORDENCODER.matches(password, user.getPassword())) {
|
||||
return user;
|
||||
}
|
||||
return null;
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(user) || !PASSWORDENCODER.matches(password, user.getPassword()))
|
||||
.throwMessage(dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_SYSTEMERROR, Constant.DICTIONARY_ITEM_INCORRECTUSERNAMEORPASSWORD, MultilingualUtil.getLanguage()));
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue