栏目删除更改id类型

This commit is contained in:
xierz 2020-10-31 10:21:42 +08:00
parent 8db9504a60
commit 2f2f9ddf3c
4 changed files with 10 additions and 9 deletions

View File

@ -182,7 +182,7 @@ public class CategoryAction extends BaseAction {
@RequiresPermissions("cms:category:del")
public ResultData delete(@RequestBody List<CategoryEntity> categorys, HttpServletResponse response, HttpServletRequest request) {
for(int i = 0;i<categorys.size();i++){
categoryBiz.delete(Integer.parseInt(categorys.get(i).getId()));
categoryBiz.delete(categorys.get(i).getId());
}
return ResultData.build().success();
}

View File

@ -33,5 +33,5 @@ public interface ICategoryBiz extends IBaseBiz<CategoryEntity> {
*/
void update(CategoryEntity entity);
void delete(int categoryId);
void delete(String categoryId);
}

View File

@ -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<ICategoryDao, CategoryEntity> 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<CategoryEntity> childrenList = categoryDao.queryChildren(category);
int[] ids = new int[childrenList.size()];
List<String> 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()]));
}
}

View File

@ -41,5 +41,5 @@ public interface IContentDao extends IBaseDao<ContentEntity> {
* 分类编号删除文章
* @param ids
*/
void deleteEntityByCategoryIds(@Param("ids") int[] ids);
void deleteEntityByCategoryIds(@Param("ids") String[] ids);
}