From 2f2f9ddf3cfc4e205fa42c3548eed0224979e9bf Mon Sep 17 00:00:00 2001 From: xierz Date: Sat, 31 Oct 2020 10:21:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=8F=E7=9B=AE=E5=88=A0=E9=99=A4=E6=9B=B4?= =?UTF-8?q?=E6=94=B9id=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../net/mingsoft/cms/action/CategoryAction.java | 2 +- .../java/net/mingsoft/cms/biz/ICategoryBiz.java | 2 +- .../net/mingsoft/cms/biz/impl/CategoryBizImpl.java | 13 +++++++------ src/main/java/net/mingsoft/cms/dao/IContentDao.java | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/mingsoft/cms/action/CategoryAction.java b/src/main/java/net/mingsoft/cms/action/CategoryAction.java index 43e5addd..cce498d4 100644 --- a/src/main/java/net/mingsoft/cms/action/CategoryAction.java +++ b/src/main/java/net/mingsoft/cms/action/CategoryAction.java @@ -182,7 +182,7 @@ public class CategoryAction extends BaseAction { @RequiresPermissions("cms:category:del") public ResultData delete(@RequestBody List categorys, HttpServletResponse response, HttpServletRequest request) { for(int i = 0;i { */ void update(CategoryEntity entity); - void delete(int categoryId); + void delete(String categoryId); } diff --git a/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java b/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java index 9f0d8852..a9658150 100644 --- a/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java +++ b/src/main/java/net/mingsoft/cms/biz/impl/CategoryBizImpl.java @@ -37,6 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.List; /** @@ -163,21 +164,21 @@ public class CategoryBizImpl extends BaseBizImpl i } @Override - public void delete(int categoryId) { + public void delete(String categoryId) { // TODO Auto-generated method stub - CategoryEntity category = (CategoryEntity) categoryDao.getEntity(categoryId); + CategoryEntity category = (CategoryEntity) categoryDao.selectById(categoryId); //删除父类 if(category != null){ category.setCategoryParentId(null); List childrenList = categoryDao.queryChildren(category); - int[] ids = new int[childrenList.size()]; + List ids = new ArrayList<>(); for(int i = 0; i < childrenList.size(); i++){ //删除子类 - ids[i] = Integer.parseInt(childrenList.get(i).getId()); + ids.add(childrenList.get(i).getId()); } - categoryDao.delete(ids); + categoryDao.deleteBatchIds(ids); // 删除文章 - contentDao.deleteEntityByCategoryIds(ids); + contentDao.deleteEntityByCategoryIds(ids.toArray(new String[ids.size()])); } } diff --git a/src/main/java/net/mingsoft/cms/dao/IContentDao.java b/src/main/java/net/mingsoft/cms/dao/IContentDao.java index f82e909f..2578771e 100644 --- a/src/main/java/net/mingsoft/cms/dao/IContentDao.java +++ b/src/main/java/net/mingsoft/cms/dao/IContentDao.java @@ -41,5 +41,5 @@ public interface IContentDao extends IBaseDao { * 分类编号删除文章 * @param ids */ - void deleteEntityByCategoryIds(@Param("ids") int[] ids); + void deleteEntityByCategoryIds(@Param("ids") String[] ids); } \ No newline at end of file