/* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.category.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springblade.common.node.TreeIntegerNode; import org.springblade.common.utils.NodeTreeUtil; import org.springblade.modules.category.dto.CategoryDTO; import org.springblade.modules.category.entity.CategoryEntity; import org.springblade.modules.category.excel.CategoryExcel; import org.springblade.modules.category.vo.CategoryVO; import org.springblade.modules.category.mapper.CategoryMapper; import org.springblade.modules.category.service.ICategoryService; import org.springblade.core.mp.base.BaseServiceImpl; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.metadata.IPage; import java.util.List; import java.util.Map; /** * 天地图poi 分类表 服务实现类 * * @author BladeX * @since 2023-10-28 */ @Service public class CategoryServiceImpl extends ServiceImpl implements ICategoryService { @Override public IPage selectCategoryPage(IPage page, CategoryVO category) { return page.setRecords(baseMapper.selectCategoryPage(page, category)); } /** * 天地图poi 分类获取 */ @Override public Object getCategory(CategoryVO category) { return baseMapper.getCategory(category); } /** * 查询场所标签 * @param categoryDTO * @return */ @Override public List selectCategoryLabelList(CategoryDTO categoryDTO) { return this.baseMapper.selectCategoryList(categoryDTO); } @Override public List tree(CategoryVO category) { Map labelTreeList = baseMapper.getTreeList(category); List nodeTree = NodeTreeUtil.getNodeTree(labelTreeList); nodeTree.forEach(node -> recursion(node)); return nodeTree; } private void recursion(TreeIntegerNode node) { if (node.getChildren() != null && node.getChildren().size() > 0) { node.getChildren().forEach(node2 -> recursion(node2)); } else { node.setChildren(null); } } /** * 标签导入 * @param data * @param isCovered */ @Override public void importCategory(List data, Boolean isCovered) { for (CategoryExcel categoryExcel : data) { // 查询是否已存在 QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq("category_no",categoryExcel.getCategoryNo()).eq("is_deleted",0); CategoryEntity one = getOne(wrapper); if (null==one){ // 新增 CategoryEntity categoryEntity = new CategoryEntity(); categoryEntity.setCategoryNo(categoryExcel.getCategoryNo()); categoryEntity.setCategoryName(categoryExcel.getCategoryName()); categoryEntity.setLevel(categoryExcel.getLevel()); categoryEntity.setIsDeleted(0); categoryEntity.setParentNo(categoryExcel.getCategoryNo().substring(0,4)); categoryEntity.setDescription(categoryExcel.getDescription()); categoryEntity.setRemark(categoryExcel.getRemark()); // 新增 save(categoryEntity); } } } }