【8.3.0】【rule】更新pids计算的工具

master
stylefeng 2024-08-30 14:21:43 +08:00
parent fef2ce23b7
commit ae760ae09a
4 changed files with 121 additions and 0 deletions

View File

@ -0,0 +1,45 @@
package cn.stylefeng.roses.kernel.rule.pidset;
import cn.stylefeng.roses.kernel.rule.constants.SymbolConstant;
import cn.stylefeng.roses.kernel.rule.constants.TreeConstants;
import cn.stylefeng.roses.kernel.rule.pidset.callback.PidGetterService;
import cn.stylefeng.roses.kernel.rule.pidset.callback.PidSettable;
import cn.stylefeng.roses.kernel.rule.pidset.pojo.ParentIdInfoPojo;
/**
* pidpids
*
* @author fengshuonan
* @since 2024/8/30 13:45
*/
public class CalcParentIdListUtil {
/**
* pIds
* <p>
* pidpids [-1],
* <p>
* pidpidspids + [pid] + ,
*
* @author fengshuonan
* @since 2024/8/30 13:45
*/
public static void fillParentIds(PidSettable pidSettable, PidGetterService pidGetterService) {
// 如果父级是-1则代表顶级节点
if (TreeConstants.DEFAULT_PARENT_ID.equals(pidSettable.getParentId())) {
pidSettable.setParentIdListString(SymbolConstant.LEFT_SQUARE_BRACKETS + TreeConstants.DEFAULT_PARENT_ID + SymbolConstant.RIGHT_SQUARE_BRACKETS + SymbolConstant.COMMA);
}
// 如果不是顶级节点则查询到父级的id集合再拼接上级id即可
else {
// 获取父级的节点信息
ParentIdInfoPojo pointNodePidInfo = pidGetterService.getPointNodePidInfo(pidSettable.getParentId());
// 设置本节点的父ids为 (上一个节点的pids + (上级节点的id) )
pidSettable.setParentIdListString(pointNodePidInfo.getParentIdListString() + SymbolConstant.LEFT_SQUARE_BRACKETS + pointNodePidInfo.getId() + SymbolConstant.RIGHT_SQUARE_BRACKETS + SymbolConstant.COMMA);
}
}
}

View File

@ -0,0 +1,21 @@
package cn.stylefeng.roses.kernel.rule.pidset.callback;
import cn.stylefeng.roses.kernel.rule.pidset.pojo.ParentIdInfoPojo;
/**
* itempids
*
* @author fengshuonan
* @since 2024/8/30 13:50
*/
public interface PidGetterService {
/**
* pids
*
* @author fengshuonan
* @since 2024/8/30 13:50
*/
ParentIdInfoPojo getPointNodePidInfo(Long itemId);
}

View File

@ -0,0 +1,27 @@
package cn.stylefeng.roses.kernel.rule.pidset.callback;
/**
* pid string
*
* @author fengshuonan
* @since 2024/8/30 13:46
*/
public interface PidSettable {
/**
* id
*
* @author fengshuonan
* @since 2024/8/30 13:51
*/
Long getParentId();
/**
* pid string
*
* @author fengshuonan
* @since 2024/8/30 13:47
*/
void setParentIdListString(String parentIdListString);
}

View File

@ -0,0 +1,28 @@
package cn.stylefeng.roses.kernel.rule.pidset.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* id
*
* @author fengshuonan
* @since 2024/8/30 13:54
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ParentIdInfoPojo {
/**
* id
*/
private Long id;
/**
* id
*/
private String parentIdListString;
}