♻️ Refactoring code. 格式化代码
This commit is contained in:
1 parent
3119fe2a1e
commit
2cfc9c9a95
20 files changed
+32
-38
No files matched your search
+2
-6
@@ -19,7 +19,6 @@
|
||||
|
||||
package com.pig4cloud.pigx.app.api.feign;
|
||||
|
||||
|
||||
import com.pig4cloud.pigx.app.api.dto.AppUserInfo;
|
||||
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
|
||||
import com.pig4cloud.pigx.common.core.constant.ServiceNameConstants;
|
||||
@@ -39,9 +38,8 @@ public interface RemoteAppUserService {
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户、角色信息
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param from 调用标志
|
||||
* @param from 调用标志
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/appuser/info/{username}")
|
||||
@@ -56,12 +54,10 @@ public interface RemoteAppUserService {
|
||||
@GetMapping("/appuser/social/info/{inStr}")
|
||||
R<AppUserInfo> social(@PathVariable("inStr") String inStr, @RequestHeader(SecurityConstants.FROM) String from);
|
||||
|
||||
|
||||
/**
|
||||
* 锁定用户
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param from 调用标识
|
||||
* @param from 调用标识
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/user/lock/{username}")
|
||||
|
||||
+1
-1
@@ -121,7 +121,6 @@ public class AppRoleController {
|
||||
return R.ok(appRoleService.removeById(roleId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新角色菜单
|
||||
* @param roleVo 角色对象
|
||||
@@ -133,6 +132,7 @@ public class AppRoleController {
|
||||
public R saveRoleMenus(@RequestBody AppRoleVO roleVo) {
|
||||
return R.ok(appRoleService.updateRoleMenus(roleVo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param appRole 查询条件
|
||||
|
||||
-1
@@ -53,7 +53,6 @@ public class AppUserController {
|
||||
|
||||
private final AppUserService appUserService;
|
||||
|
||||
|
||||
@Inner
|
||||
@GetMapping("/info/{username}")
|
||||
public R info(@PathVariable String username) {
|
||||
|
||||
+2
-1
@@ -32,5 +32,6 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface AppMenuMapper extends PigxBaseMapper<AppMenu> {
|
||||
|
||||
List<AppMenu> listMenusByRoleId(Long roleId);
|
||||
List<AppMenu> listMenusByRoleId(Long roleId);
|
||||
|
||||
}
|
||||
-2
@@ -34,7 +34,6 @@ import java.util.Set;
|
||||
*/
|
||||
public interface AppMenuService extends IService<AppMenu> {
|
||||
|
||||
|
||||
/**
|
||||
* 通过角色编号查询URL 权限
|
||||
* @param roleId 角色ID
|
||||
@@ -72,5 +71,4 @@ public interface AppMenuService extends IService<AppMenu> {
|
||||
*/
|
||||
List<Tree<Long>> filterMenu(Set<AppMenu> voSet, String type, Long parentId);
|
||||
|
||||
|
||||
}
|
||||
+2
-1
@@ -28,5 +28,6 @@ import com.pig4cloud.pigx.app.api.entity.AppRoleMenu;
|
||||
*/
|
||||
public interface AppRoleMenuService extends IService<AppRoleMenu> {
|
||||
|
||||
Boolean saveRoleMenus(Long roleId, String menuIds);
|
||||
Boolean saveRoleMenus(Long roleId, String menuIds);
|
||||
|
||||
}
|
||||
+2
-1
@@ -32,7 +32,8 @@ import java.util.List;
|
||||
*/
|
||||
public interface AppRoleService extends IService<AppRole> {
|
||||
|
||||
Boolean updateRoleMenus(AppRoleVO roleVo);
|
||||
Boolean updateRoleMenus(AppRoleVO roleVo);
|
||||
|
||||
List<AppRole> findRolesByUserId(Long userId);
|
||||
|
||||
}
|
||||
+1
@@ -46,4 +46,5 @@ public interface AppUserService extends IService<AppUser> {
|
||||
Boolean deleteUserById(Long userId);
|
||||
|
||||
AppUserInfo findUserInfo(AppUser user);
|
||||
|
||||
}
|
||||
+1
@@ -55,4 +55,5 @@ public class AppRoleMenuServiceImpl extends ServiceImpl<AppRoleMenuMapper, AppRo
|
||||
this.saveBatch(roleMenuList);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
+2
@@ -36,6 +36,7 @@ import java.util.List;
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class AppRoleServiceImpl extends ServiceImpl<AppRoleMapper, AppRole> implements AppRoleService {
|
||||
|
||||
private final AppRoleMenuService appRoleMenuService;
|
||||
|
||||
@Override
|
||||
@@ -47,4 +48,5 @@ public class AppRoleServiceImpl extends ServiceImpl<AppRoleMapper, AppRole> impl
|
||||
public List<AppRole> findRolesByUserId(Long userId) {
|
||||
return baseMapper.listRolesByUserId(userId);
|
||||
}
|
||||
|
||||
}
|
||||
-1
@@ -30,7 +30,6 @@ public interface CacheConstants {
|
||||
*/
|
||||
String USER_DETAILS = "user_details";
|
||||
|
||||
|
||||
/**
|
||||
* 移动端用户信息缓存
|
||||
*/
|
||||
|
||||
-1
@@ -95,7 +95,6 @@ public interface SecurityConstants {
|
||||
*/
|
||||
String GRANT_MOBILE = "mobile";
|
||||
|
||||
|
||||
/**
|
||||
* 小程序授权
|
||||
*/
|
||||
|
||||
+2
-2
@@ -7,8 +7,7 @@ import lombok.Getter;
|
||||
@AllArgsConstructor
|
||||
public enum UserTypeEnum {
|
||||
|
||||
TOB("0","面向后台应用"),
|
||||
TOC("1","面向小程序");
|
||||
TOB("0", "面向后台应用"), TOC("1", "面向小程序");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
@@ -19,4 +18,5 @@ public enum UserTypeEnum {
|
||||
* 描述
|
||||
*/
|
||||
private final String description;
|
||||
|
||||
}
|
||||
-2
@@ -23,7 +23,6 @@ public interface ErrorCodes {
|
||||
*/
|
||||
String SYS_USER_USERNAME_EXISTING = "sys.user.username.existing";
|
||||
|
||||
|
||||
/**
|
||||
* 用户已存在
|
||||
*/
|
||||
@@ -106,7 +105,6 @@ public interface ErrorCodes {
|
||||
*/
|
||||
String SYS_CONNECT_CP_USER_SYNC_ERROR = "sys.connect.cp.user.sync.error";
|
||||
|
||||
|
||||
/**
|
||||
* 用户信息为空
|
||||
*/
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public class PigxDefaultDatascopeHandle implements DataScopeHandle {
|
||||
@Override
|
||||
public Boolean calcScope(DataScope dataScope) {
|
||||
PigxUser user = SecurityUtils.getUser();
|
||||
if(UserTypeEnum.TOC.getStatus().equals(user.getUserType())){
|
||||
if (UserTypeEnum.TOC.getStatus().equals(user.getUserType())) {
|
||||
return true;
|
||||
}
|
||||
List<String> roleIdList = user.getAuthorities().stream().map(GrantedAuthority::getAuthority)
|
||||
|
||||
+3
-3
@@ -54,6 +54,7 @@ import java.util.Set;
|
||||
public class PigxAppUserDetailsServiceImpl implements PigxUserDetailsService {
|
||||
|
||||
private final CacheManager cacheManager;
|
||||
|
||||
private final RemoteAppUserService remoteAppUserService;
|
||||
|
||||
/**
|
||||
@@ -70,13 +71,12 @@ public class PigxAppUserDetailsServiceImpl implements PigxUserDetailsService {
|
||||
}
|
||||
R<AppUserInfo> info = remoteAppUserService.info(username, SecurityConstants.FROM_IN);
|
||||
UserDetails userDetailsAppUser = this.getUserDetailsAppUser(info);
|
||||
if(cache != null){
|
||||
if (cache != null) {
|
||||
cache.put(username, userDetailsAppUser);
|
||||
}
|
||||
return userDetailsAppUser;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUser(PigxUser pigxUser) {
|
||||
return pigxUser;
|
||||
@@ -112,7 +112,7 @@ public class PigxAppUserDetailsServiceImpl implements PigxUserDetailsService {
|
||||
|
||||
return new PigxUser(user.getUserId(), user.getUsername(), null, user.getPhone(), user.getAvatar(),
|
||||
user.getNickname(), user.getName(), user.getEmail(), user.getTenantId(),
|
||||
SecurityConstants.BCRYPT + user.getPassword(), true, true, UserTypeEnum.TOC.getStatus(),true,
|
||||
SecurityConstants.BCRYPT + user.getPassword(), true, true, UserTypeEnum.TOC.getStatus(), true,
|
||||
!CommonConstants.STATUS_LOCK.equals(user.getLockFlag()), authorities);
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -52,7 +52,9 @@ import java.util.Set;
|
||||
public class PigxMobildAppUserDetailsServiceImpl implements PigxUserDetailsService {
|
||||
|
||||
private final UserDetailsService pigxAppUserDetailsServiceImpl;
|
||||
|
||||
private final CacheManager cacheManager;
|
||||
|
||||
private final RemoteAppUserService remoteAppUserService;
|
||||
|
||||
/**
|
||||
@@ -69,13 +71,12 @@ public class PigxMobildAppUserDetailsServiceImpl implements PigxUserDetailsServi
|
||||
}
|
||||
R<AppUserInfo> info = remoteAppUserService.social(phone, SecurityConstants.FROM_IN);
|
||||
UserDetails userDetailsAppUser = this.getUserDetailsAppUser(info);
|
||||
if(cache != null){
|
||||
if (cache != null) {
|
||||
cache.put(phone, userDetailsAppUser);
|
||||
}
|
||||
return userDetailsAppUser;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUser(PigxUser pigxUser) {
|
||||
return pigxAppUserDetailsServiceImpl.loadUserByUsername(pigxUser.getUsername());
|
||||
@@ -111,7 +112,7 @@ public class PigxMobildAppUserDetailsServiceImpl implements PigxUserDetailsServi
|
||||
|
||||
return new PigxUser(user.getUserId(), user.getUsername(), null, user.getPhone(), user.getAvatar(),
|
||||
user.getNickname(), user.getName(), user.getEmail(), user.getTenantId(),
|
||||
SecurityConstants.BCRYPT + user.getPassword(), true, true, UserTypeEnum.TOC.getStatus(),true,
|
||||
SecurityConstants.BCRYPT + user.getPassword(), true, true, UserTypeEnum.TOC.getStatus(), true,
|
||||
!CommonConstants.STATUS_LOCK.equals(user.getLockFlag()), authorities);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -20,9 +20,10 @@ import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
@RequiredArgsConstructor
|
||||
public class PigxMobileUserDetailServiceImpl implements PigxUserDetailsService {
|
||||
|
||||
|
||||
private final UserDetailsService pigxDefaultUserDetailsServiceImpl;
|
||||
|
||||
private final RemoteUserService remoteUserService;
|
||||
|
||||
private final CacheManager cacheManager;
|
||||
|
||||
@Override
|
||||
@@ -47,11 +48,9 @@ public class PigxMobileUserDetailServiceImpl implements PigxUserDetailsService {
|
||||
return pigxDefaultUserDetailsServiceImpl.loadUserByUsername(pigxUser.getUsername());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 支持所有的 mobile 类型
|
||||
*
|
||||
* @param clientId 目标客户端
|
||||
* @param clientId 目标客户端
|
||||
* @param grantType 授权类型
|
||||
* @return true/false
|
||||
*/
|
||||
@@ -59,4 +58,5 @@ public class PigxMobileUserDetailServiceImpl implements PigxUserDetailsService {
|
||||
public boolean support(String clientId, String grantType) {
|
||||
return SecurityConstants.GRANT_MOBILE.equals(grantType) && !SecurityConstants.CLIENT_MINI.equals(clientId);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -96,7 +96,7 @@ public interface PigxUserDetailsService extends UserDetailsService, Ordered {
|
||||
|
||||
return new PigxUser(user.getUserId(), user.getUsername(), user.getDeptId(), user.getPhone(), user.getAvatar(),
|
||||
user.getNickname(), user.getName(), user.getEmail(), user.getTenantId(),
|
||||
SecurityConstants.BCRYPT + user.getPassword(), true, true, UserTypeEnum.TOB.getStatus(),true,
|
||||
SecurityConstants.BCRYPT + user.getPassword(), true, true, UserTypeEnum.TOB.getStatus(), true,
|
||||
!CommonConstants.STATUS_LOCK.equals(user.getLockFlag()), authorities);
|
||||
}
|
||||
|
||||
|
||||
+4
-7
@@ -209,13 +209,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
public R<Boolean> updateUser(UserDTO userDto) {
|
||||
SysUser sysUser = new SysUser();
|
||||
|
||||
|
||||
boolean exists = baseMapper.exists(Wrappers.<SysUser>lambdaQuery()
|
||||
.eq(SysUser::getPhone, userDto.getPhone())
|
||||
.ne(SysUser::getUserId, userDto.getUserId())
|
||||
);
|
||||
if(exists){
|
||||
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_PHONE_EXISTING,userDto.getPhone()));
|
||||
boolean exists = baseMapper.exists(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getPhone, userDto.getPhone())
|
||||
.ne(SysUser::getUserId, userDto.getUserId()));
|
||||
if (exists) {
|
||||
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_PHONE_EXISTING, userDto.getPhone()));
|
||||
}
|
||||
|
||||
BeanUtils.copyProperties(userDto, sysUser);
|
||||
|
||||
Reference in new issue
Block a user