From f7d045b0a8355b0ababd480c8aa195ff6d42bdfd Mon Sep 17 00:00:00 2001 From: k94314517 <8417338+k94314517@user.noreply.gitee.com> Date: 星期三, 16 四月 2025 11:19:01 +0800 Subject: [PATCH] 工单业务 --- server/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java | 31 ++++++++++++++++++++++++++++--- 1 files changed, 28 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java b/server/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java index 4edd8cb..aa0f18f 100644 --- a/server/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java +++ b/server/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java @@ -123,6 +123,9 @@ if( category.getId() == null){ throw new BusinessException(ResponseStatus.BAD_REQUEST); } + if(Constants.equalsInteger(category.getId(),category.getParentId())){ + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝鐖剁骇涓嶈兘璁剧疆涓鸿嚜韬紒"); + } category.setType(null);//绫诲瀷涓嶆敮鎸佷慨鏀� Category model = categoryMapper.selectById(category.getId()); if(model ==null || Constants.equalsInteger(model.getIsdeleted(),Constants.ONE)) { @@ -136,6 +139,8 @@ .eq(Category::getIsdeleted,Constants.ZERO)) >0){ throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "瀵逛笉璧凤紝鍚嶇О涓嶈兘閲嶅~"); }*/ + String oldIdPath = model.getIdPath(); + String oldNamePath = model.getNamePath(); LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); category.setIdPath(category.getId()+"/");//鍚嶇О璺緞 category.setNamePath(category.getName());//鍚嶇О璺緞 @@ -150,7 +155,25 @@ } category.setEditDate(new Date()); category.setEditor(user.getId()); - categoryMapper.updateById(category); + categoryMapper.update(null,new UpdateWrapper<Category>().lambda() + .eq(Category::getId,category.getId()) + .set(Category::getEditDate,category.getEditDate()) + .set(Category::getEditor,category.getEditor()) + .set(Category::getName,category.getName()) + .set(Category::getParentId,category.getParentId()) + .set(Category::getSortnum,category.getSortnum()) + .set(Category::getRemark,category.getRemark()) + .set(Category::getNamePath,category.getNamePath()) + .set(Category::getIdPath,category.getId()) + ); + //淇敼鍏ㄩ儴涓嬬骇鐨勭紪鐮佸拰鍚嶇О璺緞 + categoryMapper.update(null,new UpdateWrapper<Category>().lambda() + .likeRight(Category::getIdPath,oldIdPath) + .set(Category::getEditDate,category.getEditDate()) + .set(Category::getEditor,category.getEditor()) + .setSql("id_path=replace(id_path,'"+oldIdPath+"','"+category.getIdParentPath()+"')") + .setSql("name_path=replace(name_path,'"+oldNamePath+"/','"+category.getName()+"/')") + ); } @Override @@ -268,10 +291,11 @@ @Override - public List<CategoryVO> getCategoryVOTree(String categoryType){ + public List<CategoryVO> getCategoryVOTree(String categoryType,Integer categoryId){ List<Category> categoryList = categoryMapper.selectList(new QueryWrapper<Category>().lambda() .eq(Category::getIsdeleted, Constants.ZERO) .in(Objects.nonNull(categoryType),Category::getType,categoryType.split(",")) + .apply(Objects.nonNull(categoryId)," find_in_set("+categoryId+", REPLACE(ID_PATH,'/',',') ) ") .orderByAsc(Category::getSortnum,Category::getId) ); List<CategoryVO> categoryVOList = new ArrayList<>(); @@ -291,10 +315,11 @@ @Override - public List<CategoryVO> getCategoryVOList(Integer categoryType){ + public List<CategoryVO> getCategoryVOList(Integer categoryType,Integer isRoot){ List<Category> categoryList = categoryMapper.selectList(new QueryWrapper<Category>().lambda() .eq(Category::getIsdeleted, Constants.ZERO) .eq(Objects.nonNull(categoryType),Category::getType,categoryType) + .isNull(Constants.equalsInteger(isRoot,Constants.ONE),Category::getParentId) .orderByAsc(Category::getSortnum,Category::getId) ); List<CategoryVO> categoryVOList = new ArrayList<>(); -- Gitblit v1.9.3