优化树表性能,左树右表联动时,减少一次查询

This commit is contained in:
thinkgem
2025-03-31 09:42:28 +08:00
parent 029f6906e4
commit 38a56ab404
13 changed files with 144 additions and 79 deletions

View File

@@ -12,6 +12,7 @@ import com.jeesite.common.lang.StringUtils;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.test.entity.TestTree;
import com.jeesite.modules.test.service.TestTreeService;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@@ -41,7 +42,10 @@ public class TestTreeController extends BaseController {
* 获取数据
*/
@ModelAttribute
public TestTree get(String treeCode, boolean isNewRecord) {
public TestTree get(String treeCode, boolean isNewRecord, HttpServletRequest request) {
if (StringUtils.endsWith(request.getRequestURI(), "listData")) {
return new TestTree();
}
return testTreeService.get(treeCode, isNewRecord);
}
@@ -75,10 +79,9 @@ public class TestTreeController extends BaseController {
if (StringUtils.isBlank(testTree.getParentCode())) {
testTree.setParentCode(TestTree.ROOT_CODE);
}
if (StringUtils.isNotBlank(testTree.getTreeName())){
testTree.setParentCode(null);
}
if (StringUtils.isNotBlank(testTree.getRemarks())){
if (StringUtils.isNotBlank(testTree.getTreeCode())
|| StringUtils.isNotBlank(testTree.getTreeName())
|| StringUtils.isNotBlank(testTree.getRemarks())){
testTree.setParentCode(null);
}
List<TestTree> list = testTreeService.findList(testTree);
@@ -146,7 +149,7 @@ public class TestTreeController extends BaseController {
public String disable(TestTree testTree) {
TestTree where = new TestTree();
where.setStatus(TestTree.STATUS_NORMAL);
where.setParentCodes("," + testTree.getId() + ",");
where.setParentCodes_rightLike(testTree.getParentCodes() + testTree.getId() + ",");
long count = testTreeService.findCount(where);
if (count > 0) {
return renderResult(Global.FALSE, text("该数据包含未停用的子数据!"));