Compare commits
3 Commits
76cd8ddb6c
...
a06007728f
| Author | SHA1 | Date |
|---|---|---|
|
|
a06007728f | |
|
|
a256618d5d | |
|
|
8db4f0c8f7 |
|
|
@ -0,0 +1,136 @@
|
|||
package com.ruoyi.common.core.utils.trees;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 树形菜单生成工具类
|
||||
* @param <T>
|
||||
*/
|
||||
public class Tree <T>{
|
||||
|
||||
/**
|
||||
* 扁平化的树形结构
|
||||
*/
|
||||
protected List<TreeNode> flatTrees = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 所有根节点
|
||||
*/
|
||||
public List<TreeNode> rootTrees = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Id key标识
|
||||
*/
|
||||
protected String idFlag;
|
||||
|
||||
/**
|
||||
* pid key标识
|
||||
*/
|
||||
protected String pidFlag;
|
||||
|
||||
/**
|
||||
* name key标识
|
||||
*/
|
||||
protected String nameFlag;
|
||||
|
||||
/**
|
||||
* 使用默认属性名
|
||||
*/
|
||||
public Tree() {
|
||||
this("MenuId", "ParentId", "MenuName");
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义修改属性名
|
||||
* @param idFlag
|
||||
* @param pidFlag
|
||||
* @param nameFlag
|
||||
*/
|
||||
public Tree(String idFlag, String pidFlag, String nameFlag) {
|
||||
this.idFlag = idFlag;
|
||||
this.pidFlag = pidFlag;
|
||||
this.nameFlag = nameFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成树形菜单
|
||||
* @return
|
||||
*/
|
||||
public List<TreeNode> generateTrees(List<T> anyTrees) throws Exception {
|
||||
|
||||
// 处理给定的树形结构
|
||||
screenTrees(anyTrees);
|
||||
|
||||
// 找到父节点下面所有子节点 - 递归
|
||||
generateRecursionTrees();
|
||||
|
||||
return rootTrees;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从任意扁平树结构中生成待处理的扁平化的树形结构 以及 根节点
|
||||
* @param anyTrees
|
||||
* @return
|
||||
*/
|
||||
protected void screenTrees(List<T> anyTrees) throws Exception {
|
||||
for (T anyTree: anyTrees) {
|
||||
TreeNode treeNode = new TreeNode();
|
||||
|
||||
try {
|
||||
treeNode.id = (Long) anyTree.getClass().getMethod("get" + idFlag).invoke(anyTree);
|
||||
treeNode.pid = (Long) anyTree.getClass().getMethod("get" + pidFlag).invoke(anyTree);
|
||||
treeNode.label = (String) anyTree.getClass().getMethod("get" + nameFlag).invoke(anyTree);
|
||||
} catch (Exception e) {
|
||||
throw new Exception(e.getMessage());
|
||||
}
|
||||
|
||||
// 提取root节点和子节点
|
||||
if (treeNode.pid == 0L) {
|
||||
this.rootTrees.add(treeNode);
|
||||
} else {
|
||||
this.flatTrees.add(treeNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用递归方式生成树形结构
|
||||
*/
|
||||
protected void generateRecursionTrees() {
|
||||
for (TreeNode rootTreeNode : rootTrees) {
|
||||
recursionFunction(rootTreeNode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归函数
|
||||
* @param rootTreeNode
|
||||
*/
|
||||
protected void recursionFunction(TreeNode rootTreeNode) {
|
||||
|
||||
List<TreeNode> usedTreeNode = new ArrayList<>();
|
||||
|
||||
for(TreeNode treeNode : flatTrees) {
|
||||
if (treeNode.pid == rootTreeNode.id) {
|
||||
rootTreeNode.children.add(treeNode);
|
||||
// 标记使用过的node
|
||||
usedTreeNode.add(treeNode);
|
||||
}
|
||||
}
|
||||
|
||||
// 删除标记的node
|
||||
flatTrees.removeAll(usedTreeNode);
|
||||
|
||||
// 终止条件
|
||||
if (usedTreeNode.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 递归
|
||||
for (TreeNode treeNode: usedTreeNode) {
|
||||
recursionFunction(treeNode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.ruoyi.common.core.utils.trees;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Tree node
|
||||
*/
|
||||
public class TreeNode {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
public Long id;
|
||||
|
||||
/**
|
||||
* parentId
|
||||
*/
|
||||
public Long pid;
|
||||
|
||||
/**
|
||||
* Node name
|
||||
*/
|
||||
public String label;
|
||||
|
||||
/**
|
||||
* Child nodes
|
||||
*/
|
||||
public List<TreeNode> children = new ArrayList<>();
|
||||
}
|
||||
|
|
@ -343,25 +343,25 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
|
|||
final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36);
|
||||
// time_low
|
||||
builder.append(digits(mostSigBits >> 32, 8));
|
||||
if (false == isSimple)
|
||||
if (!isSimple)
|
||||
{
|
||||
builder.append('-');
|
||||
}
|
||||
// time_mid
|
||||
builder.append(digits(mostSigBits >> 16, 4));
|
||||
if (false == isSimple)
|
||||
if (!isSimple)
|
||||
{
|
||||
builder.append('-');
|
||||
}
|
||||
// time_high_and_version
|
||||
builder.append(digits(mostSigBits, 4));
|
||||
if (false == isSimple)
|
||||
if (!isSimple)
|
||||
{
|
||||
builder.append('-');
|
||||
}
|
||||
// variant_and_sequence
|
||||
builder.append(digits(leastSigBits >> 48, 4));
|
||||
if (false == isSimple)
|
||||
if (!isSimple)
|
||||
{
|
||||
builder.append('-');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,17 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ruoyi.common.core.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.common.core.utils.PageUtils;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.core.utils.sql.SqlUtil;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.web.page.PageDomain;
|
||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.web.page.TableSupport;
|
||||
|
||||
/**
|
||||
* web层通用数据处理
|
||||
|
|
@ -48,6 +53,19 @@ public class BaseController
|
|||
PageUtils.startPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置请求排序数据
|
||||
*/
|
||||
protected void startOrderBy()
|
||||
{
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
|
||||
{
|
||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||
PageHelper.orderBy(orderBy);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理分页的线程变量
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -56,16 +56,8 @@ public class PreAuthorizeAspect
|
|||
// 注解鉴权
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
checkMethodAnnotation(signature.getMethod());
|
||||
try
|
||||
{
|
||||
// 执行原有逻辑
|
||||
Object obj = joinPoint.proceed();
|
||||
return obj;
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
// 执行原有逻辑
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public class GenController extends BaseController
|
|||
}
|
||||
|
||||
/**
|
||||
* 修改代码生成业务
|
||||
* 获取代码生成信息
|
||||
*/
|
||||
@RequiresPermissions("tool:gen:query")
|
||||
@GetMapping(value = "/{tableId}")
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ public class SysJobController extends BaseController
|
|||
@RequiresPermissions("monitor:job:remove")
|
||||
@Log(title = "定时任务", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{jobIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException
|
||||
public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException
|
||||
{
|
||||
jobService.deleteJobByIds(jobIds);
|
||||
return success();
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.ruoyi.job.util;
|
|||
import java.util.Date;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.ruoyi.common.core.constant.ScheduleConstants;
|
||||
|
|
@ -30,7 +29,7 @@ public abstract class AbstractQuartzJob implements Job
|
|||
private static ThreadLocal<Date> threadLocal = new ThreadLocal<>();
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException
|
||||
public void execute(JobExecutionContext context)
|
||||
{
|
||||
SysJob sysJob = new SysJob();
|
||||
BeanUtils.copyBeanProp(sysJob, context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES));
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
insert into sys_user(
|
||||
<if test="userId != null and userId != 0">user_id,</if>
|
||||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||
<if test="userName != null and userName != ''">user_name,</if>
|
||||
<if test="nickName != null and nickName != ''">nick_name,</if>
|
||||
<if test="email != null and email != ''">email,</if>
|
||||
<if test="avatar != null and avatar != ''">avatar,</if>
|
||||
|
|
@ -177,7 +178,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
update sys_user
|
||||
<set>
|
||||
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
||||
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
||||
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
||||
<if test="email != null ">email = #{email},</if>
|
||||
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
|
||||
|
|
|
|||
Loading…
Reference in New Issue