proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
Col-E_Recaf | Recaf/src/main/java/me/coley/recaf/util/ShortcutUtil.java | ShortcutUtil | parseLink | class ShortcutUtil {
private boolean isDirectory;
private boolean isLocal;
private String realFile;
/**
* Provides a quick test to see if this could be a valid link !
* If you try to instantiate a new WindowShortcut and the link is not valid,
* Exceptions may be thrown and Exceptions are extremely slow to g... |
try {
if(!isMagicPresent(link))
throw new ParseException("Invalid shortcut; magic is missing", 0);
// get the flags byte
final byte flags = link[0x14];
// get the file attributes byte
final int fileAttsOffset = 0x18;
final byte fileAtts = link[fileAttsOffset];
final byte isDirMask = (byte)... | 900 | 666 | 1,566 | <no_super_class> |
Col-E_Recaf | Recaf/src/main/java/me/coley/recaf/util/StringUtil.java | StringUtil | splitNewlineSkipEmpty | class StringUtil {
/**
* @param input
* Some text containing newlines.
*
* @return Input split by newline.
*/
public static String[] splitNewline(String input) {
return input.split("\\r\\n|\\n");
}
/**
* @param input
* Some text containing newlines.
*
* @return Input split by newline.
* E... |
String[] split = input.split("[\\r\\n]+");
// If the first line of the file is a newline split will still have
// one blank entry at the start.
if (split[0].isEmpty())
return Arrays.copyOfRange(split, 1, split.length);
return split;
| 1,050 | 83 | 1,133 | <no_super_class> |
Col-E_Recaf | Recaf/src/main/java/me/coley/recaf/util/ThreadUtil.java | ThreadUtil | runSupplyConsumer | class ThreadUtil {
private static final ScheduledExecutorService scheduledService =
Executors.newScheduledThreadPool(threadCount(),
new ThreadFactoryBuilder()
.setNameFormat("Recaf Scheduler Thread #%d")
.setDaemon(true).build());
private static final ExecutorService service = Executors.newWorkS... |
new Thread(() -> {
try {
// Attempt to compute value within given time
Future<T> future = service.submit(supplier::get);
T value = future.get(supplierTimeout, TimeUnit.MILLISECONDS);
// Execute action with value
Platform.runLater(() -> consumer.accept(value));
} catch(CancellationException ... | 1,233 | 246 | 1,479 | <no_super_class> |
Col-E_Recaf | Recaf/src/main/java/me/coley/recaf/util/TypeUtil.java | TypeUtil | sortToString | class TypeUtil {
private static final Type[] PRIMITIVES = new Type[]{
Type.VOID_TYPE,
Type.BOOLEAN_TYPE,
Type.BYTE_TYPE,
Type.CHAR_TYPE,
Type.SHORT_TYPE,
Type.INT_TYPE,
Type.FLOAT_TYPE,
Type.DOUBLE_TYPE,
Type.LONG_TYPE
};
/**
* Cosntant for object type.
*/
public static final Type OBJECT_TYPE... |
switch(sort) {
case Type.VOID:
return "VOID";
case Type.BOOLEAN:
return "BOOLEAN";
case Type.CHAR:
return "CHAR";
case Type.BYTE:
return "BYTE";
case Type.SHORT:
return "SHORT";
case Type.INT:
return "INT";
case Type.FLOAT:
return "FLOAT";
case Type.LONG:
retur... | 1,457 | 225 | 1,682 | <no_super_class> |
Col-E_Recaf | Recaf/src/main/java/me/coley/recaf/util/self/SelfReferenceUtil.java | SelfReferenceUtil | getFiles | class SelfReferenceUtil {
private final File file;
private final boolean isJar;
private SelfReferenceUtil(File file) {
this.file = file;
this.isJar = file.getName().toLowerCase().endsWith(".jar");
}
/**
* @return File reference to self.
*/
public File getFile() {
return file;
}
/**
* @return File... |
List<Resource> list = new ArrayList<>();
if (isJar()) {
// Read self as jar
try (ZipFile file = new ZipFile(getFile())) {
Enumeration<? extends ZipEntry> entries = file.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
// skip directories
if (entry.... | 530 | 399 | 929 | <no_super_class> |
Col-E_Recaf | Recaf/src/main/java/me/coley/recaf/util/struct/Expireable.java | Expireable | get | class Expireable<T> {
private final Supplier<T> getter;
private long threshold;
private long lastGet;
private T value;
/**
* Create an expirable value.
*
* @param threshold
* Time until the current value is invalidated.
* @param getter
* Supplier function for the value.
*/
public Expireable(lon... |
if(System.currentTimeMillis() - lastGet > threshold) {
value = getter.get();
lastGet = System.currentTimeMillis();
}
return value;
| 191 | 52 | 243 | <no_super_class> |
Col-E_Recaf | Recaf/src/main/java/me/coley/recaf/util/struct/ListeningMap.java | ListeningMap | putAll | class ListeningMap<K, V> implements Map<K, V> {
private final Set<BiConsumer<K, V>> putListeners = new HashSet<>();
private final Set<Consumer<Object>> removeListeners = new HashSet<>();
private Map<K, V> backing;
/**
* @param backing
* The map to contain the actual data.
*/
public void setBacking(Map<K, ... |
for(Map.Entry<? extends K, ? extends V> e : m.entrySet())
put(e.getKey(), e.getValue());
| 596 | 40 | 636 | <no_super_class> |
Col-E_Recaf | Recaf/src/main/java/me/coley/recaf/util/struct/Pair.java | Pair | equals | class Pair<K, V> {
private final K key;
private final V value;
/**
* Constructs a pair.
*
* @param key
* Left item.
* @param value
* Right item.
*/
public Pair(K key, V value) {
this.key = key;
this.value = value;
}
/**
* @return Left item.
*/
public K getKey() { return key; }
/**
... |
if(this == o) return true;
if(o instanceof Pair) {
Pair other = (Pair) o;
if(key != null && !key.equals(other.key)) return false;
if(value != null && !value.equals(other.value)) return false;
return true;
}
return false;
| 229 | 90 | 319 | <no_super_class> |
Col-E_Recaf | Recaf/src/main/java/me/coley/recaf/workspace/FileSystemResourceLocation.java | FileSystemResourceLocation | equals | class FileSystemResourceLocation extends ResourceLocation {
private final Path path;
/**
* Create the file system location.
*
* @param kind kind of the resource.
* @param path file system path.
*/
public FileSystemResourceLocation(ResourceKind kind, Path path) {
super(kind)... |
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FileSystemResourceLocation that = (FileSystemResourceLocation) o;
return Objects.equals(path, that.path);
| 452 | 65 | 517 | <methods>public void <init>(me.coley.recaf.workspace.ResourceKind) ,public abstract me.coley.recaf.workspace.ResourceLocation concat(me.coley.recaf.workspace.ResourceLocation) ,public abstract boolean equals(java.lang.Object) ,public abstract boolean isAbsolute() ,public me.coley.recaf.workspace.ResourceKind kind() ,pu... |
Col-E_Recaf | Recaf/src/main/java/me/coley/recaf/workspace/History.java | History | pop | class History {
// TODO: For large inputs it would make sense to offload this to the file system.
// - But only for large inputs. In-memory is much faster and should be the default.
/**
* Stack of changed content.
*/
private final Stack<byte[]> stack = new Stack<>();
/**
* Stack of when the content was chan... |
Instant time = times.pop();
byte[] content = stack.pop();
if (content != null) {
map.put(name, content);
// If the size is now 0, we just pop'd the initial state.
// Since we ALWAYS want to keep the initial state we will push it back.
if (size() == 0) {
times.push(time);
stack.push(content);
... | 722 | 199 | 921 | <no_super_class> |
Col-E_Recaf | Recaf/src/main/java/me/coley/recaf/workspace/LiteralResourceLocation.java | LiteralResourceLocation | equals | class LiteralResourceLocation extends ResourceLocation {
private final String literal;
/**
* No public constructions are allowed.
*/
private LiteralResourceLocation(ResourceKind kind, String literal) {
super(kind);
this.literal = literal;
}
@Override
public ResourceLo... |
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
LiteralResourceLocation that = (LiteralResourceLocation) o;
return Objects.equals(literal, that.literal);
| 389 | 66 | 455 | <methods>public void <init>(me.coley.recaf.workspace.ResourceKind) ,public abstract me.coley.recaf.workspace.ResourceLocation concat(me.coley.recaf.workspace.ResourceLocation) ,public abstract boolean equals(java.lang.Object) ,public abstract boolean isAbsolute() ,public me.coley.recaf.workspace.ResourceKind kind() ,pu... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java | RuoYiApplication | main | class RuoYiApplication
{
public static void main(String[] args)
{<FILL_FUNCTION_BODY>}
} |
// System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(RuoYiApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n"... | 41 | 284 | 325 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java | CaptchaController | getCode | class CaptchaController
{
@Resource(name = "captchaProducer")
private Producer captchaProducer;
@Resource(name = "captchaProducerMath")
private Producer captchaProducerMath;
@Autowired
private RedisCache redisCache;
@Autowired
private ISysConfigService configService;
... |
AjaxResult ajax = AjaxResult.success();
boolean captchaEnabled = configService.selectCaptchaEnabled();
ajax.put("captchaEnabled", captchaEnabled);
if (!captchaEnabled)
{
return ajax;
}
// 保存验证码信息
String uuid = IdUtils.simpleUUID();
... | 169 | 501 | 670 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java | CommonController | uploadFile | class CommonController
{
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
@Autowired
private ServerConfig serverConfig;
private static final String FILE_DELIMETER = ",";
/**
* 通用下载请求
*
* @param fileName 文件名称
* @param delete 是否删除
... |
try
{
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success();
... | 1,230 | 207 | 1,437 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java | CacheController | getInfo | class CacheController
{
@Autowired
private RedisTemplate<String, String> redisTemplate;
private final static List<SysCache> caches = new ArrayList<SysCache>();
{
caches.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "用户信息"));
caches.add(new SysCache(CacheConstants.SYS_CONFIG_K... |
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info());
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
Object dbSize = redisTemplate.execute((RedisCall... | 913 | 295 | 1,208 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java | SysLogininforController | export | class SysLogininforController extends BaseController
{
@Autowired
private ISysLogininforService logininforService;
@Autowired
private SysPasswordService passwordService;
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
@GetMapping("/list")
public TableDataInfo list(SysLog... |
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
util.exportExcel(response, list, "登录日志");
| 570 | 84 | 654 | <methods>public non-sealed void <init>() ,public com.ruoyi.common.core.domain.AjaxResult error() ,public com.ruoyi.common.core.domain.AjaxResult error(java.lang.String) ,public java.lang.Long getDeptId() ,public com.ruoyi.common.core.domain.model.LoginUser getLoginUser() ,public java.lang.Long getUserId() ,public java.... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java | SysOperlogController | export | class SysOperlogController extends BaseController
{
@Autowired
private ISysOperLogService operLogService;
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
@GetMapping("/list")
public TableDataInfo list(SysOperLog operLog)
{
startPage();
List<SysOperLog> list = ope... |
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
util.exportExcel(response, list, "操作日志");
| 420 | 76 | 496 | <methods>public non-sealed void <init>() ,public com.ruoyi.common.core.domain.AjaxResult error() ,public com.ruoyi.common.core.domain.AjaxResult error(java.lang.String) ,public java.lang.Long getDeptId() ,public com.ruoyi.common.core.domain.model.LoginUser getLoginUser() ,public java.lang.Long getUserId() ,public java.... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java | SysUserOnlineController | list | class SysUserOnlineController extends BaseController
{
@Autowired
private ISysUserOnlineService userOnlineService;
@Autowired
private RedisCache redisCache;
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
@GetMapping("/list")
public TableDataInfo list(String ipaddr, String u... |
Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
for (String key : keys)
{
LoginUser user = redisCache.getCacheObject(key);
if (StringUtils.isNotEmpty(ipadd... | 253 | 336 | 589 | <methods>public non-sealed void <init>() ,public com.ruoyi.common.core.domain.AjaxResult error() ,public com.ruoyi.common.core.domain.AjaxResult error(java.lang.String) ,public java.lang.Long getDeptId() ,public com.ruoyi.common.core.domain.model.LoginUser getLoginUser() ,public java.lang.Long getUserId() ,public java.... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java | SysConfigController | add | class SysConfigController extends BaseController
{
@Autowired
private ISysConfigService configService;
/**
* 获取参数配置列表
*/
@PreAuthorize("@ss.hasPermi('system:config:list')")
@GetMapping("/list")
public TableDataInfo list(SysConfig config)
{
startPage();
... |
if (!configService.checkConfigKeyUnique(config))
{
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
config.setCreateBy(getUsername());
return toAjax(configService.insertConfig(config));
| 968 | 83 | 1,051 | <methods>public non-sealed void <init>() ,public com.ruoyi.common.core.domain.AjaxResult error() ,public com.ruoyi.common.core.domain.AjaxResult error(java.lang.String) ,public java.lang.Long getDeptId() ,public com.ruoyi.common.core.domain.model.LoginUser getLoginUser() ,public java.lang.Long getUserId() ,public java.... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java | SysDeptController | excludeChild | class SysDeptController extends BaseController
{
@Autowired
private ISysDeptService deptService;
/**
* 获取部门列表
*/
@PreAuthorize("@ss.hasPermi('system:dept:list')")
@GetMapping("/list")
public AjaxResult list(SysDept dept)
{
List<SysDept> depts = deptService.sele... |
List<SysDept> depts = deptService.selectDeptList(new SysDept());
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
return success(depts);
| 1,133 | 98 | 1,231 | <methods>public non-sealed void <init>() ,public com.ruoyi.common.core.domain.AjaxResult error() ,public com.ruoyi.common.core.domain.AjaxResult error(java.lang.String) ,public java.lang.Long getDeptId() ,public com.ruoyi.common.core.domain.model.LoginUser getLoginUser() ,public java.lang.Long getUserId() ,public java.... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java | SysDictDataController | dictType | class SysDictDataController extends BaseController
{
@Autowired
private ISysDictDataService dictDataService;
@Autowired
private ISysDictTypeService dictTypeService;
@PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping("/list")
public TableDataInfo list(SysDictData dictDa... |
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
if (StringUtils.isNull(data))
{
data = new ArrayList<SysDictData>();
}
return success(data);
| 882 | 75 | 957 | <methods>public non-sealed void <init>() ,public com.ruoyi.common.core.domain.AjaxResult error() ,public com.ruoyi.common.core.domain.AjaxResult error(java.lang.String) ,public java.lang.Long getDeptId() ,public com.ruoyi.common.core.domain.model.LoginUser getLoginUser() ,public java.lang.Long getUserId() ,public java.... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java | SysDictTypeController | export | class SysDictTypeController extends BaseController
{
@Autowired
private ISysDictTypeService dictTypeService;
@PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping("/list")
public TableDataInfo list(SysDictType dictType)
{
startPage();
List<SysDictType> list = d... |
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
util.exportExcel(response, list, "字典类型");
| 1,017 | 81 | 1,098 | <methods>public non-sealed void <init>() ,public com.ruoyi.common.core.domain.AjaxResult error() ,public com.ruoyi.common.core.domain.AjaxResult error(java.lang.String) ,public java.lang.Long getDeptId() ,public com.ruoyi.common.core.domain.model.LoginUser getLoginUser() ,public java.lang.Long getUserId() ,public java.... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java | SysLoginController | getInfo | class SysLoginController
{
@Autowired
private SysLoginService loginService;
@Autowired
private ISysMenuService menuService;
@Autowired
private SysPermissionService permissionService;
/**
* 登录方法
*
* @param loginBody 登录信息
* @return 结果
*/
@PostM... |
SysUser user = SecurityUtils.getLoginUser().getUser();
// 角色集合
Set<String> roles = permissionService.getRolePermission(user);
// 权限集合
Set<String> permissions = permissionService.getMenuPermission(user);
AjaxResult ajax = AjaxResult.success();
ajax.put("use... | 426 | 135 | 561 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java | SysMenuController | remove | class SysMenuController extends BaseController
{
@Autowired
private ISysMenuService menuService;
/**
* 获取菜单列表
*/
@PreAuthorize("@ss.hasPermi('system:menu:list')")
@GetMapping("/list")
public AjaxResult list(SysMenu menu)
{
List<SysMenu> menus = menuService.sele... |
if (menuService.hasChildByMenuId(menuId))
{
return warn("存在子菜单,不允许删除");
}
if (menuService.checkMenuExistRole(menuId))
{
return warn("菜单已分配,不允许删除");
}
return toAjax(menuService.deleteMenuById(menuId));
| 1,178 | 104 | 1,282 | <methods>public non-sealed void <init>() ,public com.ruoyi.common.core.domain.AjaxResult error() ,public com.ruoyi.common.core.domain.AjaxResult error(java.lang.String) ,public java.lang.Long getDeptId() ,public com.ruoyi.common.core.domain.model.LoginUser getLoginUser() ,public java.lang.Long getUserId() ,public java.... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java | SysPostController | edit | class SysPostController extends BaseController
{
@Autowired
private ISysPostService postService;
/**
* 获取岗位列表
*/
@PreAuthorize("@ss.hasPermi('system:post:list')")
@GetMapping("/list")
public TableDataInfo list(SysPost post)
{
startPage();
List<SysPost>... |
if (!postService.checkPostNameUnique(post))
{
return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
}
else if (!postService.checkPostCodeUnique(post))
{
return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
post.setU... | 898 | 136 | 1,034 | <methods>public non-sealed void <init>() ,public com.ruoyi.common.core.domain.AjaxResult error() ,public com.ruoyi.common.core.domain.AjaxResult error(java.lang.String) ,public java.lang.Long getDeptId() ,public com.ruoyi.common.core.domain.model.LoginUser getLoginUser() ,public java.lang.Long getUserId() ,public java.... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java | SysProfileController | updatePwd | class SysProfileController extends BaseController
{
@Autowired
private ISysUserService userService;
@Autowired
private TokenService tokenService;
/**
* 个人信息
*/
@GetMapping
public AjaxResult profile()
{
LoginUser loginUser = getLoginUser();
SysUs... |
LoginUser loginUser = getLoginUser();
String userName = loginUser.getUsername();
String password = loginUser.getPassword();
if (!SecurityUtils.matchesPassword(oldPassword, password))
{
return error("修改密码失败,旧密码错误");
}
if (SecurityUtils.matchesP... | 924 | 233 | 1,157 | <methods>public non-sealed void <init>() ,public com.ruoyi.common.core.domain.AjaxResult error() ,public com.ruoyi.common.core.domain.AjaxResult error(java.lang.String) ,public java.lang.Long getDeptId() ,public com.ruoyi.common.core.domain.model.LoginUser getLoginUser() ,public java.lang.Long getUserId() ,public java.... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRegisterController.java | SysRegisterController | register | class SysRegisterController extends BaseController
{
@Autowired
private SysRegisterService registerService;
@Autowired
private ISysConfigService configService;
@PostMapping("/register")
public AjaxResult register(@RequestBody RegisterBody user)
{<FILL_FUNCTION_BODY>}
} |
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
{
return error("当前系统没有开启注册功能!");
}
String msg = registerService.register(user);
return StringUtils.isEmpty(msg) ? success() : error(msg);
| 95 | 84 | 179 | <methods>public non-sealed void <init>() ,public com.ruoyi.common.core.domain.AjaxResult error() ,public com.ruoyi.common.core.domain.AjaxResult error(java.lang.String) ,public java.lang.Long getDeptId() ,public com.ruoyi.common.core.domain.model.LoginUser getLoginUser() ,public java.lang.Long getUserId() ,public java.... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java | TestController | getUser | class TestController extends BaseController
{
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
{
users.put(1, new UserEntity(1, "admin", "admin123", "15888888888"));
users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
}
... |
if (!users.isEmpty() && users.containsKey(userId))
{
return R.ok(users.get(userId));
}
else
{
return R.fail("用户不存在");
}
| 903 | 69 | 972 | <methods>public non-sealed void <init>() ,public com.ruoyi.common.core.domain.AjaxResult error() ,public com.ruoyi.common.core.domain.AjaxResult error(java.lang.String) ,public java.lang.Long getDeptId() ,public com.ruoyi.common.core.domain.model.LoginUser getLoginUser() ,public java.lang.Long getUserId() ,public java.... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java | SwaggerConfig | securitySchemes | class SwaggerConfig
{
/** 系统基础配置 */
@Autowired
private RuoYiConfig ruoyiConfig;
/** 是否开启swagger */
@Value("${swagger.enabled}")
private boolean enabled;
/** 设置请求的统一前缀 */
@Value("${swagger.pathMapping}")
private String pathMapping;
/**
* 创建API
*/
... |
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue()));
return apiKeyList;
| 921 | 62 | 983 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/config/serializer/SensitiveJsonSerializer.java | SensitiveJsonSerializer | createContextual | class SensitiveJsonSerializer extends JsonSerializer<String> implements ContextualSerializer
{
private DesensitizedType desensitizedType;
@Override
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException
{
if (desensitization())
{
... |
Sensitive annotation = property.getAnnotation(Sensitive.class);
if (Objects.nonNull(annotation) && Objects.equals(String.class, property.getType().getRawClass()))
{
this.desensitizedType = annotation.desensitizedType();
return this;
}
return prov.findValu... | 263 | 94 | 357 | <methods>public void <init>() ,public void acceptJsonFormatVisitor(com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper, com.fasterxml.jackson.databind.JavaType) throws com.fasterxml.jackson.databind.JsonMappingException,public JsonSerializer<?> getDelegatee() ,public Class<java.lang.String> handl... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java | BaseController | startOrderBy | class BaseController
{
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
*/
@InitBinder
public void initBinder(WebDataBinder binder)
{
// Date 类型转换
binder.registerCustomEditor(Date.class, new PropertyEdi... |
PageDomain pageDomain = TableSupport.buildPageRequest();
if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
{
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
PageHelper.orderBy(orderBy);
}
| 1,172 | 80 | 1,252 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java | BaseEntity | getParams | class BaseEntity implements Serializable
{
private static final long serialVersionUID = 1L;
/** 搜索值 */
@JsonIgnore
private String searchValue;
/** 创建者 */
private String createBy;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
... |
if (params == null)
{
params = new HashMap<>();
}
return params;
| 652 | 37 | 689 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/R.java | R | restResult | class R<T> implements Serializable
{
private static final long serialVersionUID = 1L;
/** 成功 */
public static final int SUCCESS = HttpStatus.SUCCESS;
/** 失败 */
public static final int FAIL = HttpStatus.ERROR;
private int code;
private String msg;
private T data;
public static <... |
R<T> apiResult = new R<>();
apiResult.setCode(code);
apiResult.setData(data);
apiResult.setMsg(msg);
return apiResult;
| 635 | 52 | 687 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java | SysDept | toString | class SysDept extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 部门ID */
private Long deptId;
/** 父部门ID */
private Long parentId;
/** 祖级列表 */
private String ancestors;
/** 部门名称 */
private String deptName;
/** 显示顺序 */
private Intege... |
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("deptId", getDeptId())
.append("parentId", getParentId())
.append("ancestors", getAncestors())
.append("deptName", getDeptName())
.append("orderNum", getOrderNum())
... | 1,175 | 217 | 1,392 | <methods>public non-sealed void <init>() ,public java.lang.String getCreateBy() ,public java.util.Date getCreateTime() ,public Map<java.lang.String,java.lang.Object> getParams() ,public java.lang.String getRemark() ,public java.lang.String getSearchValue() ,public java.lang.String getUpdateBy() ,public java.util.Date g... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictData.java | SysDictData | toString | class SysDictData extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 字典编码 */
@Excel(name = "字典编码", cellType = ColumnType.NUMERIC)
private Long dictCode;
/** 字典排序 */
@Excel(name = "字典排序", cellType = ColumnType.NUMERIC)
private Long dictSort;
/** 字典标签 ... |
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("dictCode", getDictCode())
.append("dictSort", getDictSort())
.append("dictLabel", getDictLabel())
.append("dictValue", getDictValue())
.append("dictType", getDictType())
... | 1,181 | 219 | 1,400 | <methods>public non-sealed void <init>() ,public java.lang.String getCreateBy() ,public java.util.Date getCreateTime() ,public Map<java.lang.String,java.lang.Object> getParams() ,public java.lang.String getRemark() ,public java.lang.String getSearchValue() ,public java.lang.String getUpdateBy() ,public java.util.Date g... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictType.java | SysDictType | toString | class SysDictType extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 字典主键 */
@Excel(name = "字典主键", cellType = ColumnType.NUMERIC)
private Long dictId;
/** 字典名称 */
@Excel(name = "字典名称")
private String dictName;
/** 字典类型 */
@Excel(name = "字典类型")
... |
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("dictId", getDictId())
.append("dictName", getDictName())
.append("dictType", getDictType())
.append("status", getStatus())
.append("createBy", getCreateBy())
.... | 627 | 151 | 778 | <methods>public non-sealed void <init>() ,public java.lang.String getCreateBy() ,public java.util.Date getCreateTime() ,public Map<java.lang.String,java.lang.Object> getParams() ,public java.lang.String getRemark() ,public java.lang.String getSearchValue() ,public java.lang.String getUpdateBy() ,public java.util.Date g... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java | SysMenu | toString | class SysMenu extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 菜单ID */
private Long menuId;
/** 菜单名称 */
private String menuName;
/** 父菜单名称 */
private String parentName;
/** 父菜单ID */
private Long parentId;
/** 显示顺序 */
private Inte... |
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("menuId", getMenuId())
.append("menuName", getMenuName())
.append("parentId", getParentId())
.append("orderNum", getOrderNum())
.append("path", getPath())
.appe... | 1,539 | 257 | 1,796 | <methods>public non-sealed void <init>() ,public java.lang.String getCreateBy() ,public java.util.Date getCreateTime() ,public Map<java.lang.String,java.lang.Object> getParams() ,public java.lang.String getRemark() ,public java.lang.String getSearchValue() ,public java.lang.String getUpdateBy() ,public java.util.Date g... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java | SysRole | toString | class SysRole extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 角色ID */
@Excel(name = "角色序号", cellType = ColumnType.NUMERIC)
private Long roleId;
/** 角色名称 */
@Excel(name = "角色名称")
private String roleName;
/** 角色权限 */
@Excel(name = "角色权限")
... |
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("roleId", getRoleId())
.append("roleName", getRoleName())
.append("roleKey", getRoleKey())
.append("roleSort", getRoleSort())
.append("dataScope", getDataScope())
... | 1,679 | 227 | 1,906 | <methods>public non-sealed void <init>() ,public java.lang.String getCreateBy() ,public java.util.Date getCreateTime() ,public Map<java.lang.String,java.lang.Object> getParams() ,public java.lang.String getRemark() ,public java.lang.String getSearchValue() ,public java.lang.String getUpdateBy() ,public java.util.Date g... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java | PageDomain | setIsAsc | class PageDomain
{
/** 当前记录起始索引 */
private Integer pageNum;
/** 每页显示记录数 */
private Integer pageSize;
/** 排序列 */
private String orderByColumn;
/** 排序的方向desc或者asc */
private String isAsc = "asc";
/** 分页参数合理化 */
private Boolean reasonable = true;
public String getOrderBy()
... |
if (StringUtils.isNotEmpty(isAsc))
{
// 兼容前端排序类型
if ("ascending".equals(isAsc))
{
isAsc = "asc";
}
else if ("descending".equals(isAsc))
{
isAsc = "desc";
}
this.isAsc = isAsc;... | 447 | 104 | 551 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java | TableSupport | getPageDomain | class TableSupport
{
/**
* 当前记录起始索引
*/
public static final String PAGE_NUM = "pageNum";
/**
* 每页显示记录数
*/
public static final String PAGE_SIZE = "pageSize";
/**
* 排序列
*/
public static final String ORDER_BY_COLUMN = "orderByColumn";
/**
*... |
PageDomain pageDomain = new PageDomain();
pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1));
pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10));
pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN));
... | 275 | 152 | 427 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/core/text/CharsetKit.java | CharsetKit | convert | class CharsetKit
{
/** ISO-8859-1 */
public static final String ISO_8859_1 = "ISO-8859-1";
/** UTF-8 */
public static final String UTF_8 = "UTF-8";
/** GBK */
public static final String GBK = "GBK";
/** ISO-8859-1 */
public static final Charset CHARSET_ISO_8859_1 = Charset.for... |
if (null == srcCharset)
{
srcCharset = StandardCharsets.ISO_8859_1;
}
if (null == destCharset)
{
destCharset = StandardCharsets.UTF_8;
}
if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset))
{
... | 667 | 138 | 805 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/core/text/StrFormatter.java | StrFormatter | format | class StrFormatter
{
public static final String EMPTY_JSON = "{}";
public static final char C_BACKSLASH = '\\';
public static final char C_DELIM_START = '{';
public static final char C_DELIM_END = '}';
/**
* 格式化字符串<br>
* 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
* 如果想输出 {} 使用 \\转义 { 即可,... |
if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray))
{
return strPattern;
}
final int strPatternLength = strPattern.length();
// 初始化定义好的长度以获得更好的性能
StringBuilder sbuf = new StringBuilder(strPatternLength + 50);
int handledP... | 358 | 640 | 998 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/exception/base/BaseException.java | BaseException | getMessage | class BaseException extends RuntimeException
{
private static final long serialVersionUID = 1L;
/**
* 所属模块
*/
private String module;
/**
* 错误码
*/
private String code;
/**
* 错误码对应的参数
*/
private Object[] args;
/**
* 错误消息
*/
... |
String message = null;
if (!StringUtils.isEmpty(code))
{
message = MessageUtils.message(code, args);
}
if (message == null)
{
message = defaultMessage;
}
return message;
| 480 | 77 | 557 | <methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.Throwable) ,public void <init>(java.lang.String, java.lang.Throwable) <variables>static final long serialVersionUID |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileUploadException.java | FileUploadException | printStackTrace | class FileUploadException extends Exception
{
private static final long serialVersionUID = 1L;
private final Throwable cause;
public FileUploadException()
{
this(null, null);
}
public FileUploadException(final String msg)
{
this(msg, null);
}
public FileUploadExc... |
super.printStackTrace(writer);
if (cause != null)
{
writer.println("Caused by:");
cause.printStackTrace(writer);
}
| 246 | 49 | 295 | <methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.Throwable) ,public void <init>(java.lang.String, java.lang.Throwable) <variables>static final long serialVersionUID |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/filter/PropertyPreExcludeFilter.java | PropertyPreExcludeFilter | addExcludes | class PropertyPreExcludeFilter extends SimplePropertyPreFilter
{
public PropertyPreExcludeFilter()
{
}
public PropertyPreExcludeFilter addExcludes(String... filters)
{<FILL_FUNCTION_BODY>}
} |
for (int i = 0; i < filters.length; i++)
{
this.getExcludes().add(filters[i]);
}
return this;
| 71 | 53 | 124 | <methods>public transient void <init>(java.lang.String[]) ,public transient void <init>(Class<?>, java.lang.String[]) ,public Class<?> getClazz() ,public Set<java.lang.String> getExcludes() ,public Set<java.lang.String> getIncludes() ,public int getMaxLevel() ,public boolean process(com.alibaba.fastjson2.JSONWriter, ja... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java | RepeatableFilter | doFilter | class RepeatableFilter implements Filter
{
@Override
public void init(FilterConfig filterConfig) throws ServletException
{
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{<FIL... |
ServletRequest requestWrapper = null;
if (request instanceof HttpServletRequest
&& StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE))
{
requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, respons... | 122 | 140 | 262 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java | RepeatedlyRequestWrapper | getInputStream | class RepeatedlyRequestWrapper extends HttpServletRequestWrapper
{
private final byte[] body;
public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException
{
super(request);
request.setCharacterEncoding(Constants.UTF8);
response.set... |
final ByteArrayInputStream bais = new ByteArrayInputStream(body);
return new ServletInputStream()
{
@Override
public int read() throws IOException
{
return bais.read();
}
@Override
public int ava... | 199 | 191 | 390 | <methods>public void <init>(javax.servlet.http.HttpServletRequest) ,public boolean authenticate(javax.servlet.http.HttpServletResponse) throws java.io.IOException, javax.servlet.ServletException,public java.lang.String changeSessionId() ,public java.lang.String getAuthType() ,public java.lang.String getContextPath() ,p... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssFilter.java | XssFilter | init | class XssFilter implements Filter
{
/**
* 排除链接
*/
public List<String> excludes = new ArrayList<>();
@Override
public void init(FilterConfig filterConfig) throws ServletException
{<FILL_FUNCTION_BODY>}
@Override
public void doFilter(ServletRequest request, ServletRespo... |
String tempExcludes = filterConfig.getInitParameter("excludes");
if (StringUtils.isNotEmpty(tempExcludes))
{
String[] url = tempExcludes.split(",");
for (int i = 0; url != null && i < url.length; i++)
{
excludes.add(url[i]);
... | 386 | 105 | 491 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java | XssHttpServletRequestWrapper | getParameterValues | class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
{
/**
* @param request
*/
public XssHttpServletRequestWrapper(HttpServletRequest request)
{
super(request);
}
@Override
public String[] getParameterValues(String name)
{<FILL_FUNCTION_BODY>}
... |
String[] values = super.getParameterValues(name);
if (values != null)
{
int length = values.length;
String[] escapesValues = new String[length];
for (int i = 0; i < length; i++)
{
// 防xss攻击和过滤前后空格
escapesVa... | 549 | 145 | 694 | <methods>public void <init>(javax.servlet.http.HttpServletRequest) ,public boolean authenticate(javax.servlet.http.HttpServletResponse) throws java.io.IOException, javax.servlet.ServletException,public java.lang.String changeSessionId() ,public java.lang.String getAuthType() ,public java.lang.String getContextPath() ,p... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java | Arith | div | class Arith
{
/** 默认除法运算精度 */
private static final int DEF_DIV_SCALE = 10;
/** 这个类不能实例化 */
private Arith()
{
}
/**
* 提供精确的加法运算。
* @param v1 被加数
* @param v2 加数
* @return 两个参数的和
*/
public static double add(double v1, double v2)
{
BigDecimal b1 = new ... |
if (scale < 0)
{
throw new IllegalArgumentException(
"The scale must be a positive integer or zero");
}
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
if (b1.compareTo(BigDecimal.Z... | 886 | 145 | 1,031 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java | DateUtils | dateTime | class DateUtils extends org.apache.commons.lang3.time.DateUtils
{
public static String YYYY = "yyyy";
public static String YYYY_MM = "yyyy-MM";
public static String YYYY_MM_DD = "yyyy-MM-dd";
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
public static String YYYY_MM_DD_HH_MM_... |
try
{
return new SimpleDateFormat(format).parse(ts);
}
catch (ParseException e)
{
throw new RuntimeException(e);
}
| 1,615 | 58 | 1,673 | <methods>public void <init>() ,public static java.util.Date addDays(java.util.Date, int) ,public static java.util.Date addHours(java.util.Date, int) ,public static java.util.Date addMilliseconds(java.util.Date, int) ,public static java.util.Date addMinutes(java.util.Date, int) ,public static java.util.Date addMonths(ja... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/DesensitizedUtil.java | DesensitizedUtil | carLicense | class DesensitizedUtil
{
/**
* 密码的全部字符都用*代替,比如:******
*
* @param password 密码
* @return 脱敏后的密码
*/
public static String password(String password)
{
if (StringUtils.isBlank(password))
{
return StringUtils.EMPTY;
}
return StringUtils.repeat('*... |
if (StringUtils.isBlank(carLicense))
{
return StringUtils.EMPTY;
}
// 普通车牌
if (carLicense.length() == 7)
{
carLicense = StringUtils.hide(carLicense, 3, 6);
}
else if (carLicense.length() == 8)
{
// 新能源车牌
... | 199 | 128 | 327 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java | DictUtils | getDictValue | class DictUtils
{
/**
* 分隔符
*/
public static final String SEPARATOR = ",";
/**
* 设置字典缓存
*
* @param key 参数键
* @param dictDatas 字典数据列表
*/
public static void setDictCache(String key, List<SysDictData> dictDatas)
{
SpringUtils.getBean(RedisCach... |
StringBuilder propertyString = new StringBuilder();
List<SysDictData> datas = getDictCache(dictType);
if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas))
{
for (SysDictData dict : datas)
{
for (String label... | 1,299 | 258 | 1,557 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java | ExceptionUtil | getRootErrorMessage | class ExceptionUtil
{
/**
* 获取exception的详细错误信息。
*/
public static String getExceptionMessage(Throwable e)
{
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw, true));
return sw.toString();
}
public static String getRootErrorMessa... |
Throwable root = ExceptionUtils.getRootCause(e);
root = (root == null ? e : root);
if (root == null)
{
return "";
}
String msg = root.getMessage();
if (msg == null)
{
return "null";
}
return StringUtils.... | 120 | 104 | 224 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/LogUtils.java | LogUtils | getBlock | class LogUtils
{
public static String getBlock(Object msg)
{<FILL_FUNCTION_BODY>}
} |
if (msg == null)
{
msg = "";
}
return "[" + msg.toString() + "]";
| 38 | 42 | 80 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java | PageUtils | startPage | class PageUtils extends PageHelper
{
/**
* 设置请求分页数据
*/
public static void startPage()
{<FILL_FUNCTION_BODY>}
/**
* 清理分页的线程变量
*/
public static void clearPage()
{
PageHelper.clearPage();
}
} |
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
Boolean reasonable = pageDomain.getReasonable();
PageHelpe... | 90 | 100 | 190 | <methods>public void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStatement, java.la... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java | SecurityUtils | getLoginUser | class SecurityUtils
{
/**
* 用户ID
**/
public static Long getUserId()
{
try
{
return getLoginUser().getUserId();
}
catch (Exception e)
{
throw new ServiceException("获取用户ID异常", HttpStatus.UNAUTHORIZED);
}
}
... |
try
{
return (LoginUser) getAuthentication().getPrincipal();
}
catch (Exception e)
{
throw new ServiceException("获取用户信息异常", HttpStatus.UNAUTHORIZED);
}
| 1,219 | 70 | 1,289 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java | ServletUtils | isAjaxRequest | class ServletUtils
{
/**
* 获取String参数
*/
public static String getParameter(String name)
{
return getRequest().getParameter(name);
}
/**
* 获取String参数
*/
public static String getParameter(String name, String defaultValue)
{
return Convert.toS... |
String accept = request.getHeader("accept");
if (accept != null && accept.contains("application/json"))
{
return true;
}
String xRequestedWith = request.getHeader("X-Requested-With");
if (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequ... | 1,296 | 196 | 1,492 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java | Threads | shutdownAndAwaitTermination | class Threads
{
private static final Logger logger = LoggerFactory.getLogger(Threads.class);
/**
* sleep等待,单位为毫秒
*/
public static void sleep(long milliseconds)
{
try
{
Thread.sleep(milliseconds);
}
catch (InterruptedException e)
... |
if (pool != null && !pool.isShutdown())
{
pool.shutdown();
try
{
if (!pool.awaitTermination(120, TimeUnit.SECONDS))
{
pool.shutdownNow();
if (!pool.awaitTermination(120, TimeUnit.SECONDS... | 518 | 172 | 690 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java | BeanUtils | getGetterMethods | class BeanUtils extends org.springframework.beans.BeanUtils
{
/** Bean方法名中属性名开始的下标 */
private static final int BEAN_METHOD_PROP_INDEX = 3;
/** * 匹配getter方法的正则表达式 */
private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)");
/** * 匹配setter方法的正则表达式 */
pri... |
// getter方法列表
List<Method> getterMethods = new ArrayList<Method>();
// 获取所有方法
Method[] methods = obj.getClass().getMethods();
// 查找getter方法
for (Method method : methods)
{
Matcher m = GET_PATTERN.matcher(method.getName());
if (m.m... | 773 | 162 | 935 | <methods>public void <init>() ,public static void copyProperties(java.lang.Object, java.lang.Object) throws org.springframework.beans.BeansException,public static void copyProperties(java.lang.Object, java.lang.Object, Class<?>) throws org.springframework.beans.BeansException,public static transient void copyProperties... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanValidators.java | BeanValidators | validateWithException | class BeanValidators
{
public static void validateWithException(Validator validator, Object object, Class<?>... groups)
throws ConstraintViolationException
{<FILL_FUNCTION_BODY>}
} |
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object, groups);
if (!constraintViolations.isEmpty())
{
throw new ConstraintViolationException(constraintViolations);
}
| 62 | 67 | 129 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileTypeUtils.java | FileTypeUtils | getFileType | class FileTypeUtils
{
/**
* 获取文件类型
* <p>
* 例如: ruoyi.txt, 返回: txt
*
* @param file 文件名
* @return 后缀(不含".")
*/
public static String getFileType(File file)
{
if (null == file)
{
return StringUtils.EMPTY;
}
return ge... |
int separatorIndex = fileName.lastIndexOf(".");
if (separatorIndex < 0)
{
return "";
}
return fileName.substring(separatorIndex + 1).toLowerCase();
| 627 | 64 | 691 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java | FileUploadUtils | isAllowedExtension | class FileUploadUtils
{
/**
* 默认大小 50M
*/
public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024;
/**
* 默认的文件名最大长度 100
*/
public static final int DEFAULT_FILE_NAME_LENGTH = 100;
/**
* 默认上传的地址
*/
private static String defaultBaseDir = RuoYiConf... |
for (String str : allowedExtension)
{
if (str.equalsIgnoreCase(extension))
{
return true;
}
}
return false;
| 1,918 | 56 | 1,974 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/ImageUtils.java | ImageUtils | readFile | class ImageUtils
{
private static final Logger log = LoggerFactory.getLogger(ImageUtils.class);
public static byte[] getImage(String imagePath)
{
InputStream is = getFile(imagePath);
try
{
return IOUtils.toByteArray(is);
}
catch (Exception e)
... |
InputStream in = null;
try
{
if (url.startsWith("http"))
{
// 网络地址
URL urlObj = new URL(url);
URLConnection urlConnection = urlObj.openConnection();
urlConnection.setConnectTimeout(30 * 1000);
... | 344 | 293 | 637 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java | MimeTypeUtils | getExtension | class MimeTypeUtils
{
public static final String IMAGE_PNG = "image/png";
public static final String IMAGE_JPG = "image/jpg";
public static final String IMAGE_JPEG = "image/jpeg";
public static final String IMAGE_BMP = "image/bmp";
public static final String IMAGE_GIF = "image/gif";
... |
switch (prefix)
{
case IMAGE_PNG:
return "png";
case IMAGE_JPG:
return "jpg";
case IMAGE_JPEG:
return "jpeg";
case IMAGE_BMP:
return "bmp";
case IMAGE_GIF:
... | 461 | 117 | 578 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/EscapeUtil.java | EscapeUtil | encode | class EscapeUtil
{
public static final String RE_HTML_MARK = "(<[^<]*?>)|(<[\\s]*?/[^<]*?>)|(<[^<]*?/[\\s]*?>)";
private static final char[][] TEXT = new char[64][];
static
{
for (int i = 0; i < 64; i++)
{
TEXT[i] = new char[] { (char) i };
}
/... |
if (StringUtils.isEmpty(text))
{
return StringUtils.EMPTY;
}
final StringBuilder tmp = new StringBuilder(text.length() * 6);
char c;
for (int i = 0; i < text.length(); i++)
{
c = text.charAt(i);
if (c < 256)
... | 1,207 | 263 | 1,470 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java | HttpHelper | getBodyString | class HttpHelper
{
private static final Logger LOGGER = LoggerFactory.getLogger(HttpHelper.class);
public static String getBodyString(ServletRequest request)
{<FILL_FUNCTION_BODY>}
} |
StringBuilder sb = new StringBuilder();
BufferedReader reader = null;
try (InputStream inputStream = request.getInputStream())
{
reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
String line = "";
while ((... | 65 | 232 | 297 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java | AddressUtils | getRealAddressByIP | class AddressUtils
{
private static final Logger log = LoggerFactory.getLogger(AddressUtils.class);
// IP地址查询
public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp";
// 未知地址
public static final String UNKNOWN = "XX XX";
public static String getRealAddressByIP(... |
// 内网不查询
if (IpUtils.internalIp(ip))
{
return "内网IP";
}
if (RuoYiConfig.isAddressEnabled())
{
try
{
String rspStr = HttpUtils.sendGet(IP_URL, "ip=" + ip + "&json=true", Constants.GBK);
if (Str... | 132 | 263 | 395 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Md5Utils.java | Md5Utils | md5 | class Md5Utils
{
private static final Logger log = LoggerFactory.getLogger(Md5Utils.class);
private static byte[] md5(String s)
{<FILL_FUNCTION_BODY>}
private static final String toHex(byte hash[])
{
if (hash == null)
{
return null;
}
String... |
MessageDigest algorithm;
try
{
algorithm = MessageDigest.getInstance("MD5");
algorithm.reset();
algorithm.update(s.getBytes("UTF-8"));
byte[] messageDigest = algorithm.digest();
return messageDigest;
}
catch (... | 343 | 119 | 462 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java | SqlUtil | escapeOrderBySql | class SqlUtil
{
/**
* 定义常用的 sql关键字
*/
public static String SQL_REGEX = "and |extractvalue|updatexml|exec |insert |select |delete |update |drop |count |chr |mid |master |truncate |char |declare |or |+|user()";
/**
* 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序)
*/
public static String S... |
if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value))
{
throw new UtilException("参数不符合规范,不能进行查询");
}
if (StringUtils.length(value) > ORDER_BY_MAX_LENGTH)
{
throw new UtilException("参数已超过最大限制,不能进行查询");
}
return value;
... | 473 | 109 | 582 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/Seq.java | Seq | getSeq | class Seq
{
// 通用序列类型
public static final String commSeqType = "COMMON";
// 上传序列类型
public static final String uploadSeqType = "UPLOAD";
// 通用接口序列数
private static AtomicInteger commSeq = new AtomicInteger(1);
// 上传接口序列数
private static AtomicInteger uploadSeq = new AtomicInt... |
// 先取值再+1
int value = atomicInt.getAndIncrement();
// 如果更新后值>=10 的 (length)幂次方则重置为1
int maxSeq = (int) Math.pow(10, length);
if (atomicInt.get() >= maxSeq)
{
atomicInt.set(1);
}
// 转字符串,用0左补齐
return StringUtils.padl(value, ... | 609 | 140 | 749 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-common/src/main/java/com/ruoyi/common/xss/XssValidator.java | XssValidator | containsHtml | class XssValidator implements ConstraintValidator<Xss, String>
{
private static final String HTML_PATTERN = "<(\\S*?)[^>]*>.*?|<.*? />";
@Override
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext)
{
if (StringUtils.isBlank(value))
{
... |
StringBuilder sHtml = new StringBuilder();
Pattern pattern = Pattern.compile(HTML_PATTERN);
Matcher matcher = pattern.matcher(value);
while (matcher.find())
{
sHtml.append(matcher.group());
}
return pattern.matcher(sHtml).matches();
| 157 | 95 | 252 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java | DataScopeAspect | dataScopeFilter | class DataScopeAspect
{
/**
* 全部数据权限
*/
public static final String DATA_SCOPE_ALL = "1";
/**
* 自定数据权限
*/
public static final String DATA_SCOPE_CUSTOM = "2";
/**
* 部门数据权限
*/
public static final String DATA_SCOPE_DEPT = "3";
/**
* 部门及以下数据... |
StringBuilder sqlString = new StringBuilder();
List<String> conditions = new ArrayList<String>();
for (SysRole role : user.getRoles())
{
String dataScope = role.getDataScope();
if (!DATA_SCOPE_CUSTOM.equals(dataScope) && conditions.contains(dataScope))
... | 783 | 856 | 1,639 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java | DataSourceAspect | around | class DataSourceAspect
{
protected Logger logger = LoggerFactory.getLogger(getClass());
@Pointcut("@annotation(com.ruoyi.common.annotation.DataSource)"
+ "|| @within(com.ruoyi.common.annotation.DataSource)")
public void dsPointCut()
{
}
@Around("dsPointCut()")
publ... |
DataSource dataSource = getDataSource(point);
if (StringUtils.isNotNull(dataSource))
{
DynamicDataSourceContextHolder.setDataSourceType(dataSource.value().name());
}
try
{
return point.proceed();
}
finally
{
... | 286 | 128 | 414 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RateLimiterAspect.java | RateLimiterAspect | doBefore | class RateLimiterAspect
{
private static final Logger log = LoggerFactory.getLogger(RateLimiterAspect.class);
private RedisTemplate<Object, Object> redisTemplate;
private RedisScript<Long> limitScript;
@Autowired
public void setRedisTemplate1(RedisTemplate<Object, Object> redisTemplate)
... |
int time = rateLimiter.time();
int count = rateLimiter.count();
String combineKey = getCombineKey(rateLimiter, point);
List<Object> keys = Collections.singletonList(combineKey);
try
{
Long number = redisTemplate.execute(limitScript, keys, count, time... | 407 | 247 | 654 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java | CaptchaConfig | getKaptchaBeanMath | class CaptchaConfig
{
@Bean(name = "captchaProducer")
public DefaultKaptcha getKaptchaBean()
{
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
Properties properties = new Properties();
// 是否有边框 默认为true 我们可以自己设置yes,no
properties.setProperty(KAPTCHA_BORDER, "yes");
... |
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
Properties properties = new Properties();
// 是否有边框 默认为true 我们可以自己设置yes,no
properties.setProperty(KAPTCHA_BORDER, "yes");
// 边框颜色 默认为Color.BLACK
properties.setProperty(KAPTCHA_BORDER_COLOR, "105,179,90");
// 验证... | 617 | 762 | 1,379 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java | DruidConfig | dataSource | class DruidConfig
{
@Bean
@ConfigurationProperties("spring.datasource.druid.master")
public DataSource masterDataSource(DruidProperties druidProperties)
{
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
return druidProperties.dataSource(dataSource);
}
... |
Map<Object, Object> targetDataSources = new HashMap<>();
targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource);
setDataSource(targetDataSources, DataSourceType.SLAVE.name(), "slaveDataSource");
return new DynamicDataSource(masterDataSource, targetDataSources);
| 991 | 92 | 1,083 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java | FastJson2JsonRedisSerializer | deserialize | class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
{
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
static final Filter AUTO_TYPE_FILTER = JSONReader.autoTypeFilter(Constants.JSON_WHITELIST_STR);
private Class<T> clazz;
public FastJson2JsonRedisSerial... |
if (bytes == null || bytes.length <= 0)
{
return null;
}
String str = new String(bytes, DEFAULT_CHARSET);
return JSON.parseObject(str, clazz, AUTO_TYPE_FILTER);
| 267 | 74 | 341 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FilterConfig.java | FilterConfig | xssFilterRegistration | class FilterConfig
{
@Value("${xss.excludes}")
private String excludes;
@Value("${xss.urlPatterns}")
private String urlPatterns;
@SuppressWarnings({ "rawtypes", "unchecked" })
@Bean
@ConditionalOnProperty(value = "xss.enabled", havingValue = "true")
public FilterRegistration... |
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setDispatcherTypes(DispatcherType.REQUEST);
registration.setFilter(new XssFilter());
registration.addUrlPatterns(StringUtils.split(urlPatterns, ","));
registration.setName("xssFilter");
... | 269 | 158 | 427 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/config/I18nConfig.java | I18nConfig | localeChangeInterceptor | class I18nConfig implements WebMvcConfigurer
{
@Bean
public LocaleResolver localeResolver()
{
SessionLocaleResolver slr = new SessionLocaleResolver();
// 默认语言
slr.setDefaultLocale(Constants.DEFAULT_LOCALE);
return slr;
}
@Bean
public LocaleChangeInterceptor local... |
LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
// 参数名
lci.setParamName("lang");
return lci;
| 159 | 45 | 204 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java | KaptchaTextCreator | getText | class KaptchaTextCreator extends DefaultTextCreator
{
private static final String[] CNUMBERS = "0,1,2,3,4,5,6,7,8,9,10".split(",");
@Override
public String getText()
{<FILL_FUNCTION_BODY>}
} |
Integer result = 0;
Random random = new Random();
int x = random.nextInt(10);
int y = random.nextInt(10);
StringBuilder suChinese = new StringBuilder();
int randomoperands = random.nextInt(3);
if (randomoperands == 0)
{
result = x * y;
... | 84 | 429 | 513 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java | MyBatisConfig | setTypeAliasesPackage | class MyBatisConfig
{
@Autowired
private Environment env;
static final String DEFAULT_RESOURCE_PATTERN = "**/*.class";
public static String setTypeAliasesPackage(String typeAliasesPackage)
{<FILL_FUNCTION_BODY>}
public Resource[] resolveMapperLocations(String[] mapperLocations)
... |
ResourcePatternResolver resolver = (ResourcePatternResolver) new PathMatchingResourcePatternResolver();
MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver);
List<String> allResult = new ArrayList<String>();
try
{
for (String... | 522 | 532 | 1,054 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java | RedisConfig | redisTemplate | class RedisConfig extends CachingConfigurerSupport
{
@Bean
@SuppressWarnings(value = { "unchecked", "rawtypes" })
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory)
{<FILL_FUNCTION_BODY>}
@Bean
public DefaultRedisScript<Long> limitScript()
... |
RedisTemplate<Object, Object> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory);
FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class);
// 使用StringRedisSerializer来序列化和反序列化redis的key值
template.setKeySeria... | 401 | 182 | 583 | <methods>public void <init>() ,public org.springframework.cache.CacheManager cacheManager() ,public org.springframework.cache.interceptor.CacheResolver cacheResolver() ,public org.springframework.cache.interceptor.CacheErrorHandler errorHandler() ,public org.springframework.cache.interceptor.KeyGenerator keyGenerator()... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java | ResourcesConfig | corsFilter | class ResourcesConfig implements WebMvcConfigurer
{
@Autowired
private RepeatSubmitInterceptor repeatSubmitInterceptor;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
/** 本地文件上传路径 */
registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**... |
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
// 设置访问源地址
config.addAllowedOriginPattern("*");
// 设置访问源请求头
config.addAllowedHeader("*");
// 设置访问源请求方法
config.addAllowedMethod("*");
// 有效期 1800秒
... | 342 | 200 | 542 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java | SecurityConfig | configure | class SecurityConfig extends WebSecurityConfigurerAdapter
{
/**
* 自定义用户认证逻辑
*/
@Autowired
private UserDetailsService userDetailsService;
/**
* 认证失败处理类
*/
@Autowired
private AuthenticationEntryPointImpl unauthorizedHandler;
/**
* 退出处理类
*/
... |
// 注解标记允许匿名访问的url
ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry = httpSecurity.authorizeRequests();
permitAllUrl.getUrls().forEach(url -> registry.antMatchers(url).permitAll());
httpSecurity
// CSRF禁用,因为不使用session
... | 796 | 531 | 1,327 | <methods>public org.springframework.security.authentication.AuthenticationManager authenticationManagerBean() throws java.lang.Exception,public void configure(org.springframework.security.config.annotation.web.builders.WebSecurity) throws java.lang.Exception,public void init(org.springframework.security.config.annotati... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ServerConfig.java | ServerConfig | getDomain | class ServerConfig
{
/**
* 获取完整的请求路径,包括:域名,端口,上下文访问路径
*
* @return 服务地址
*/
public String getUrl()
{
HttpServletRequest request = ServletUtils.getRequest();
return getDomain(request);
}
public static String getDomain(HttpServletRequest request)
{... |
StringBuffer url = request.getRequestURL();
String contextPath = request.getServletContext().getContextPath();
return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(contextPath).toString();
| 131 | 66 | 197 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ThreadPoolConfig.java | ThreadPoolConfig | threadPoolTaskExecutor | class ThreadPoolConfig
{
// 核心线程池大小
private int corePoolSize = 50;
// 最大可创建的线程数
private int maxPoolSize = 200;
// 队列最大长度
private int queueCapacity = 1000;
// 线程池维护线程所允许的空闲时间
private int keepAliveSeconds = 300;
@Bean(name = "threadPoolTaskExecutor")
public Threa... |
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setMaxPoolSize(maxPoolSize);
executor.setCorePoolSize(corePoolSize);
executor.setQueueCapacity(queueCapacity);
executor.setKeepAliveSeconds(keepAliveSeconds);
// 线程池对拒绝任务(无线程可用)的处理策略
... | 344 | 135 | 479 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/DruidProperties.java | DruidProperties | dataSource | class DruidProperties
{
@Value("${spring.datasource.druid.initialSize}")
private int initialSize;
@Value("${spring.datasource.druid.minIdle}")
private int minIdle;
@Value("${spring.datasource.druid.maxActive}")
private int maxActive;
@Value("${spring.datasource.druid.maxWait}")... |
/** 配置初始化大小、最小、最大 */
datasource.setInitialSize(initialSize);
datasource.setMaxActive(maxActive);
datasource.setMinIdle(minIdle);
/** 配置获取连接等待超时的时间 */
datasource.setMaxWait(maxWait);
/** 配置驱动连接超时时间,检测数据库建立连接的超时时间,单位是毫秒 */
datasource.set... | 518 | 540 | 1,058 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/PermitAllUrlProperties.java | PermitAllUrlProperties | afterPropertiesSet | class PermitAllUrlProperties implements InitializingBean, ApplicationContextAware
{
private static final Pattern PATTERN = Pattern.compile("\\{(.*?)\\}");
private ApplicationContext applicationContext;
private List<String> urls = new ArrayList<>();
public String ASTERISK = "*";
@Overri... |
RequestMappingHandlerMapping mapping = applicationContext.getBean(RequestMappingHandlerMapping.class);
Map<RequestMappingInfo, HandlerMethod> map = mapping.getHandlerMethods();
map.keySet().forEach(info -> {
HandlerMethod handlerMethod = map.get(info);
// 获取方法上边... | 229 | 312 | 541 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java | RepeatSubmitInterceptor | preHandle | class RepeatSubmitInterceptor implements HandlerInterceptor
{
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
{<FILL_FUNCTION_BODY>}
/**
* 验证是否重复提交由子类实现具体的防重复提交的规则
*
* @param request 请求信息
* @para... |
if (handler instanceof HandlerMethod)
{
HandlerMethod handlerMethod = (HandlerMethod) handler;
Method method = handlerMethod.getMethod();
RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
if (annotation != null)
{
... | 166 | 185 | 351 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java | SameUrlDataInterceptor | isRepeatSubmit | class SameUrlDataInterceptor extends RepeatSubmitInterceptor
{
public final String REPEAT_PARAMS = "repeatParams";
public final String REPEAT_TIME = "repeatTime";
// 令牌自定义标识
@Value("${token.header}")
private String header;
@Autowired
private RedisCache redisCache;
@Suppr... |
String nowParams = "";
if (request instanceof RepeatedlyRequestWrapper)
{
RepeatedlyRequestWrapper repeatedlyRequest = (RepeatedlyRequestWrapper) request;
nowParams = HttpHelper.getBodyString(repeatedlyRequest);
}
// body参数为空,获取Parameter的数据
... | 411 | 547 | 958 | <methods>public non-sealed void <init>() ,public abstract boolean isRepeatSubmit(javax.servlet.http.HttpServletRequest, com.ruoyi.common.annotation.RepeatSubmit) ,public boolean preHandle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object) throws java.lang.Exception<variable... |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java | ShutdownManager | shutdownAsyncManager | class ShutdownManager
{
private static final Logger logger = LoggerFactory.getLogger("sys-user");
@PreDestroy
public void destroy()
{
shutdownAsyncManager();
}
/**
* 停止异步执行任务
*/
private void shutdownAsyncManager()
{<FILL_FUNCTION_BODY>}
} |
try
{
logger.info("====关闭后台任务任务线程池====");
AsyncManager.me().shutdown();
}
catch (Exception e)
{
logger.error(e.getMessage(), e);
}
| 108 | 76 | 184 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java | AsyncFactory | run | class AsyncFactory
{
private static final Logger sys_user_logger = LoggerFactory.getLogger("sys-user");
/**
* 记录登录信息
*
* @param username 用户名
* @param status 状态
* @param message 消息
* @param args 列表
* @return 任务task
*/
public static TimerTask recordLogini... |
String address = AddressUtils.getRealAddressByIP(ip);
StringBuilder s = new StringBuilder();
s.append(LogUtils.getBlock(ip));
s.append(address);
s.append(LogUtils.getBlock(username));
s.append(LogUtils.getBlock(status... | 411 | 429 | 840 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java | JwtAuthenticationTokenFilter | doFilterInternal | class JwtAuthenticationTokenFilter extends OncePerRequestFilter
{
@Autowired
private TokenService tokenService;
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
throws ServletException, IOException
{<FILL_FUNC... |
LoginUser loginUser = tokenService.getLoginUser(request);
if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication()))
{
tokenService.verifyToken(loginUser);
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePass... | 90 | 148 | 238 | <methods>public void <init>() ,public final void doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) throws javax.servlet.ServletException, java.io.IOException<variables>public static final java.lang.String ALREADY_FILTERED_SUFFIX |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java | AuthenticationEntryPointImpl | commence | class AuthenticationEntryPointImpl implements AuthenticationEntryPoint, Serializable
{
private static final long serialVersionUID = -8970718410437077606L;
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e)
throws IOException... |
int code = HttpStatus.UNAUTHORIZED;
String msg = StringUtils.format("请求访问:{},认证失败,无法访问系统资源", request.getRequestURI());
ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(code, msg)));
| 104 | 81 | 185 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java | LogoutSuccessHandlerImpl | onLogoutSuccess | class LogoutSuccessHandlerImpl implements LogoutSuccessHandler
{
@Autowired
private TokenService tokenService;
/**
* 退出处理
*
* @return
*/
@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
... |
LoginUser loginUser = tokenService.getLoginUser(request);
if (StringUtils.isNotNull(loginUser))
{
String userName = loginUser.getUsername();
// 删除用户缓存记录
tokenService.delLoginUser(loginUser.getToken());
// 记录用户退出日志
AsyncManager.... | 118 | 174 | 292 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java | GlobalExceptionHandler | handleRuntimeException | class GlobalExceptionHandler
{
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
/**
* 权限校验异常
*/
@ExceptionHandler(AccessDeniedException.class)
public AjaxResult handleAccessDeniedException(AccessDeniedException e, HttpServletRequest request)
... |
String requestURI = request.getRequestURI();
log.error("请求地址'{}',发生未知异常.", requestURI, e);
return AjaxResult.error(e.getMessage());
| 1,214 | 53 | 1,267 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java | PermissionService | hasRole | class PermissionService
{
/**
* 验证用户是否具备某权限
*
* @param permission 权限字符串
* @return 用户是否具备某权限
*/
public boolean hasPermi(String permission)
{
if (StringUtils.isEmpty(permission))
{
return false;
}
LoginUser loginUser = Securit... |
if (StringUtils.isEmpty(role))
{
return false;
}
LoginUser loginUser = SecurityUtils.getLoginUser();
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles()))
{
return false;
}
for (Sys... | 1,100 | 184 | 1,284 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java | SysLoginService | login | class SysLoginService
{
@Autowired
private TokenService tokenService;
@Resource
private AuthenticationManager authenticationManager;
@Autowired
private RedisCache redisCache;
@Autowired
private ISysUserService userService;
@Autowired
private ISysConfigServi... |
// 验证码校验
validateCaptcha(username, code, uuid);
// 登录前置校验
loginPreCheck(username, password);
// 用户验证
Authentication authentication = null;
try
{
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticat... | 1,198 | 422 | 1,620 | <no_super_class> |
yangzongzhuan_RuoYi-Vue | RuoYi-Vue/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPasswordService.java | SysPasswordService | validate | class SysPasswordService
{
@Autowired
private RedisCache redisCache;
@Value(value = "${user.password.maxRetryCount}")
private int maxRetryCount;
@Value(value = "${user.password.lockTime}")
private int lockTime;
/**
* 登录账户密码错误次数缓存键名
*
* @param username 用户名
... |
Authentication usernamePasswordAuthenticationToken = AuthenticationContextHolder.getContext();
String username = usernamePasswordAuthenticationToken.getName();
String password = usernamePasswordAuthenticationToken.getCredentials().toString();
Integer retryCount = redisCache.getCac... | 327 | 259 | 586 | <no_super_class> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.