7 changed files with 608 additions and 0 deletions
@ -0,0 +1,118 @@ |
|||||
|
package org.dromara.platform.controller; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import jakarta.servlet.http.HttpServletResponse; |
||||
|
import jakarta.validation.constraints.*; |
||||
|
import cn.dev33.satoken.annotation.SaCheckPermission; |
||||
|
import org.dromara.platform.domain.ProjectCategoryPoint; |
||||
|
import org.dromara.platform.domain.ServiceCatalogCategory; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.dromara.common.idempotent.annotation.RepeatSubmit; |
||||
|
import org.dromara.common.log.annotation.Log; |
||||
|
import org.dromara.common.web.core.BaseController; |
||||
|
import org.dromara.common.mybatis.core.page.PageQuery; |
||||
|
import org.dromara.common.core.domain.R; |
||||
|
import org.dromara.common.core.validate.AddGroup; |
||||
|
import org.dromara.common.core.validate.EditGroup; |
||||
|
import org.dromara.common.log.enums.BusinessType; |
||||
|
import org.dromara.common.excel.utils.ExcelUtil; |
||||
|
import org.dromara.platform.domain.vo.ProjectCategoryPointVo; |
||||
|
import org.dromara.platform.domain.bo.ProjectCategoryPointBo; |
||||
|
import org.dromara.platform.service.IProjectCategoryPointService; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
|
||||
|
/** |
||||
|
* 项目目录-点位 |
||||
|
* |
||||
|
* @author gejunhao |
||||
|
* @date 2025-03-10 |
||||
|
*/ |
||||
|
@Validated |
||||
|
@RequiredArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("/platform/projectCategoryPoint") |
||||
|
public class ProjectCategoryPointController extends BaseController { |
||||
|
|
||||
|
private final IProjectCategoryPointService projectCategoryPointService; |
||||
|
|
||||
|
/** |
||||
|
* 查询项目目录-点位列表 |
||||
|
*/ |
||||
|
@SaCheckPermission("platform:projectCategoryPoint:list") |
||||
|
@GetMapping("/list") |
||||
|
public TableDataInfo<ProjectCategoryPointVo> list(ProjectCategoryPointBo bo, PageQuery pageQuery) { |
||||
|
return projectCategoryPointService.queryPageList(bo, pageQuery); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 导出项目目录-点位列表 |
||||
|
*/ |
||||
|
@SaCheckPermission("platform:projectCategoryPoint:export") |
||||
|
@Log(title = "项目目录-点位", businessType = BusinessType.EXPORT) |
||||
|
@PostMapping("/export") |
||||
|
public void export(ProjectCategoryPointBo bo, HttpServletResponse response) { |
||||
|
List<ProjectCategoryPointVo> list = projectCategoryPointService.queryList(bo); |
||||
|
ExcelUtil.exportExcel(list, "项目目录-点位", ProjectCategoryPointVo.class, response); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取项目目录-点位详细信息 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
*/ |
||||
|
@SaCheckPermission("platform:projectCategoryPoint:query") |
||||
|
@GetMapping("/{id}") |
||||
|
public R<ProjectCategoryPointVo> getInfo(@NotNull(message = "主键不能为空") |
||||
|
@PathVariable String id) { |
||||
|
return R.ok(projectCategoryPointService.queryById(id)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增项目目录-点位 |
||||
|
*/ |
||||
|
@SaCheckPermission("platform:projectCategoryPoint:add") |
||||
|
@Log(title = "项目目录-点位", businessType = BusinessType.INSERT) |
||||
|
@RepeatSubmit() |
||||
|
@PostMapping() |
||||
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody ProjectCategoryPointBo bo) { |
||||
|
return toAjax(projectCategoryPointService.insertByBo(bo)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改项目目录-点位 |
||||
|
*/ |
||||
|
@SaCheckPermission("platform:projectCategoryPoint:edit") |
||||
|
@Log(title = "项目目录-点位", businessType = BusinessType.UPDATE) |
||||
|
@RepeatSubmit() |
||||
|
@PutMapping() |
||||
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ProjectCategoryPointBo bo) { |
||||
|
return toAjax(projectCategoryPointService.updateByBo(bo)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除项目目录-点位 |
||||
|
* |
||||
|
* @param ids 主键串 |
||||
|
*/ |
||||
|
@SaCheckPermission("platform:projectCategoryPoint:remove") |
||||
|
@Log(title = "项目目录-点位", businessType = BusinessType.DELETE) |
||||
|
@DeleteMapping("/{ids}") |
||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
||||
|
@PathVariable String[] ids) { |
||||
|
return toAjax(projectCategoryPointService.deleteWithValidByIds(List.of(ids), true)); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 获取服务目录- (父+子) |
||||
|
* |
||||
|
*/ |
||||
|
@SaCheckPermission("platform:projectCategoryPoint:queryAll") |
||||
|
@GetMapping("/queryAll") |
||||
|
public R<List<ProjectCategoryPoint>> queryAll() { |
||||
|
return R.ok(projectCategoryPointService.queryAll()); |
||||
|
} |
||||
|
} |
@ -0,0 +1,76 @@ |
|||||
|
package org.dromara.platform.domain; |
||||
|
|
||||
|
import org.dromara.common.tenant.core.TenantEntity; |
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 项目目录-点位对象 project_category_point |
||||
|
* |
||||
|
* @author gejunhao |
||||
|
* @date 2025-03-10 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@TableName("project_category_point") |
||||
|
public class ProjectCategoryPoint extends TenantEntity { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
|
||||
|
@TableField(exist = false) |
||||
|
List<ProjectCategoryPoint> children; |
||||
|
/** |
||||
|
* 目录ID,唯一标识每个目录条目 |
||||
|
*/ |
||||
|
@TableId(value = "id") |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 项目id |
||||
|
*/ |
||||
|
private String projectId; |
||||
|
|
||||
|
/** |
||||
|
* 目录名称,表示目录的名字 |
||||
|
*/ |
||||
|
private String projectName; |
||||
|
|
||||
|
/** |
||||
|
* 编号,用于额外标识或排序目的 |
||||
|
*/ |
||||
|
private String code; |
||||
|
|
||||
|
/** |
||||
|
* 是否为子目录,true表示是子目录,false则不是 |
||||
|
*/ |
||||
|
private Long isChildren; |
||||
|
|
||||
|
/** |
||||
|
* 上级目录id,指向父目录的id,如果没有父目录则为空 |
||||
|
*/ |
||||
|
private String ownerId; |
||||
|
|
||||
|
/** |
||||
|
* 上级目录名称,冗余存储父目录的名称以便查询优化 |
||||
|
*/ |
||||
|
private String ownerName; |
||||
|
|
||||
|
/** |
||||
|
* 当前状态 |
||||
|
*/ |
||||
|
private Long status; |
||||
|
|
||||
|
/** |
||||
|
* 删除标志(0代表存在 2代表删除) |
||||
|
*/ |
||||
|
@TableLogic |
||||
|
private String delFlag; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,72 @@ |
|||||
|
package org.dromara.platform.domain.bo; |
||||
|
|
||||
|
import org.dromara.platform.domain.ProjectCategoryPoint; |
||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity; |
||||
|
import org.dromara.common.core.validate.AddGroup; |
||||
|
import org.dromara.common.core.validate.EditGroup; |
||||
|
import io.github.linpeilie.annotations.AutoMapper; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
import jakarta.validation.constraints.*; |
||||
|
|
||||
|
/** |
||||
|
* 项目目录-点位业务对象 project_category_point |
||||
|
* |
||||
|
* @author gejunhao |
||||
|
* @date 2025-03-10 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@AutoMapper(target = ProjectCategoryPoint.class, reverseConvertGenerate = false) |
||||
|
public class ProjectCategoryPointBo extends BaseEntity { |
||||
|
|
||||
|
/** |
||||
|
* 目录ID,唯一标识每个目录条目 |
||||
|
*/ |
||||
|
@NotBlank(message = "目录ID,唯一标识每个目录条目不能为空", groups = { EditGroup.class }) |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 项目id |
||||
|
*/ |
||||
|
@NotBlank(message = "项目id不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private String projectId; |
||||
|
|
||||
|
/** |
||||
|
* 目录名称,表示目录的名字 |
||||
|
*/ |
||||
|
@NotBlank(message = "目录名称,表示目录的名字不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private String projectName; |
||||
|
|
||||
|
/** |
||||
|
* 编号,用于额外标识或排序目的 |
||||
|
*/ |
||||
|
@NotBlank(message = "编号,用于额外标识或排序目的不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private String code; |
||||
|
|
||||
|
/** |
||||
|
* 是否为子目录,true表示是子目录,false则不是 |
||||
|
*/ |
||||
|
@NotNull(message = "是否为子目录,true表示是子目录,false则不是不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private Long isChildren; |
||||
|
|
||||
|
/** |
||||
|
* 上级目录id,指向父目录的id,如果没有父目录则为空 |
||||
|
*/ |
||||
|
@NotBlank(message = "上级目录id,指向父目录的id,如果没有父目录则为空不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private String ownerId; |
||||
|
|
||||
|
/** |
||||
|
* 上级目录名称,冗余存储父目录的名称以便查询优化 |
||||
|
*/ |
||||
|
@NotBlank(message = "上级目录名称,冗余存储父目录的名称以便查询优化不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private String ownerName; |
||||
|
|
||||
|
/** |
||||
|
* 当前状态 |
||||
|
*/ |
||||
|
@NotNull(message = "当前状态不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private Long status; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,80 @@ |
|||||
|
package org.dromara.platform.domain.vo; |
||||
|
|
||||
|
import org.dromara.platform.domain.ProjectCategoryPoint; |
||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
||||
|
import com.alibaba.excel.annotation.ExcelProperty; |
||||
|
import org.dromara.common.excel.annotation.ExcelDictFormat; |
||||
|
import org.dromara.common.excel.convert.ExcelDictConvert; |
||||
|
import io.github.linpeilie.annotations.AutoMapper; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 项目目录-点位视图对象 project_category_point |
||||
|
* |
||||
|
* @author gejunhao |
||||
|
* @date 2025-03-10 |
||||
|
*/ |
||||
|
@Data |
||||
|
@ExcelIgnoreUnannotated |
||||
|
@AutoMapper(target = ProjectCategoryPoint.class) |
||||
|
public class ProjectCategoryPointVo implements Serializable { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 目录ID,唯一标识每个目录条目 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "目录ID,唯一标识每个目录条目") |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 项目id |
||||
|
*/ |
||||
|
@ExcelProperty(value = "项目id") |
||||
|
private String projectId; |
||||
|
|
||||
|
/** |
||||
|
* 目录名称,表示目录的名字 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "目录名称,表示目录的名字") |
||||
|
private String projectName; |
||||
|
|
||||
|
/** |
||||
|
* 编号,用于额外标识或排序目的 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "编号,用于额外标识或排序目的") |
||||
|
private String code; |
||||
|
|
||||
|
/** |
||||
|
* 是否为子目录,true表示是子目录,false则不是 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "是否为子目录,true表示是子目录,false则不是") |
||||
|
private Long isChildren; |
||||
|
|
||||
|
/** |
||||
|
* 上级目录id,指向父目录的id,如果没有父目录则为空 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "上级目录id,指向父目录的id,如果没有父目录则为空") |
||||
|
private String ownerId; |
||||
|
|
||||
|
/** |
||||
|
* 上级目录名称,冗余存储父目录的名称以便查询优化 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "上级目录名称,冗余存储父目录的名称以便查询优化") |
||||
|
private String ownerName; |
||||
|
|
||||
|
/** |
||||
|
* 当前状态 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "当前状态") |
||||
|
private Long status; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package org.dromara.platform.mapper; |
||||
|
|
||||
|
import org.dromara.platform.domain.ProjectCategoryPoint; |
||||
|
import org.dromara.platform.domain.vo.ProjectCategoryPointVo; |
||||
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
||||
|
|
||||
|
/** |
||||
|
* 项目目录-点位Mapper接口 |
||||
|
* |
||||
|
* @author gejunhao |
||||
|
* @date 2025-03-10 |
||||
|
*/ |
||||
|
public interface ProjectCategoryPointMapper extends BaseMapperPlus<ProjectCategoryPoint, ProjectCategoryPointVo> { |
||||
|
|
||||
|
} |
@ -0,0 +1,72 @@ |
|||||
|
package org.dromara.platform.service; |
||||
|
|
||||
|
import org.dromara.platform.domain.ProjectCategoryPoint; |
||||
|
import org.dromara.platform.domain.ServiceCatalogCategory; |
||||
|
import org.dromara.platform.domain.vo.ProjectCategoryPointVo; |
||||
|
import org.dromara.platform.domain.bo.ProjectCategoryPointBo; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
import org.dromara.common.mybatis.core.page.PageQuery; |
||||
|
|
||||
|
import java.util.Collection; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 项目目录-点位Service接口 |
||||
|
* |
||||
|
* @author gejunhao |
||||
|
* @date 2025-03-10 |
||||
|
*/ |
||||
|
public interface IProjectCategoryPointService { |
||||
|
|
||||
|
/** |
||||
|
* 查询项目目录-点位 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
* @return 项目目录-点位 |
||||
|
*/ |
||||
|
ProjectCategoryPointVo queryById(String id); |
||||
|
|
||||
|
/** |
||||
|
* 分页查询项目目录-点位列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @param pageQuery 分页参数 |
||||
|
* @return 项目目录-点位分页列表 |
||||
|
*/ |
||||
|
TableDataInfo<ProjectCategoryPointVo> queryPageList(ProjectCategoryPointBo bo, PageQuery pageQuery); |
||||
|
|
||||
|
/** |
||||
|
* 查询符合条件的项目目录-点位列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @return 项目目录-点位列表 |
||||
|
*/ |
||||
|
List<ProjectCategoryPointVo> queryList(ProjectCategoryPointBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 新增项目目录-点位 |
||||
|
* |
||||
|
* @param bo 项目目录-点位 |
||||
|
* @return 是否新增成功 |
||||
|
*/ |
||||
|
Boolean insertByBo(ProjectCategoryPointBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 修改项目目录-点位 |
||||
|
* |
||||
|
* @param bo 项目目录-点位 |
||||
|
* @return 是否修改成功 |
||||
|
*/ |
||||
|
Boolean updateByBo(ProjectCategoryPointBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 校验并批量删除项目目录-点位信息 |
||||
|
* |
||||
|
* @param ids 待删除的主键集合 |
||||
|
* @param isValid 是否进行有效性校验 |
||||
|
* @return 是否删除成功 |
||||
|
*/ |
||||
|
Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid); |
||||
|
|
||||
|
List<ProjectCategoryPoint> queryAll(); |
||||
|
} |
@ -0,0 +1,175 @@ |
|||||
|
package org.dromara.platform.service.impl; |
||||
|
|
||||
|
import org.dromara.common.core.utils.MapstructUtils; |
||||
|
import org.dromara.common.core.utils.StringUtils; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
import org.dromara.common.mybatis.core.page.PageQuery; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import org.dromara.platform.domain.ServiceCatalogCategory; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.dromara.platform.domain.bo.ProjectCategoryPointBo; |
||||
|
import org.dromara.platform.domain.vo.ProjectCategoryPointVo; |
||||
|
import org.dromara.platform.domain.ProjectCategoryPoint; |
||||
|
import org.dromara.platform.mapper.ProjectCategoryPointMapper; |
||||
|
import org.dromara.platform.service.IProjectCategoryPointService; |
||||
|
|
||||
|
import java.util.*; |
||||
|
|
||||
|
/** |
||||
|
* 项目目录-点位Service业务层处理 |
||||
|
* |
||||
|
* @author gejunhao |
||||
|
* @date 2025-03-10 |
||||
|
*/ |
||||
|
@RequiredArgsConstructor |
||||
|
@Service |
||||
|
public class ProjectCategoryPointServiceImpl implements IProjectCategoryPointService { |
||||
|
|
||||
|
private final ProjectCategoryPointMapper baseMapper; |
||||
|
|
||||
|
/** |
||||
|
* 查询项目目录-点位 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
* @return 项目目录-点位 |
||||
|
*/ |
||||
|
@Override |
||||
|
public ProjectCategoryPointVo queryById(String id){ |
||||
|
return baseMapper.selectVoById(id); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 分页查询项目目录-点位列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @param pageQuery 分页参数 |
||||
|
* @return 项目目录-点位分页列表 |
||||
|
*/ |
||||
|
@Override |
||||
|
public TableDataInfo<ProjectCategoryPointVo> queryPageList(ProjectCategoryPointBo bo, PageQuery pageQuery) { |
||||
|
LambdaQueryWrapper<ProjectCategoryPoint> lqw = buildQueryWrapper(bo); |
||||
|
Page<ProjectCategoryPointVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
||||
|
return TableDataInfo.build(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 查询符合条件的项目目录-点位列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @return 项目目录-点位列表 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<ProjectCategoryPointVo> queryList(ProjectCategoryPointBo bo) { |
||||
|
LambdaQueryWrapper<ProjectCategoryPoint> lqw = buildQueryWrapper(bo); |
||||
|
return baseMapper.selectVoList(lqw); |
||||
|
} |
||||
|
|
||||
|
private LambdaQueryWrapper<ProjectCategoryPoint> buildQueryWrapper(ProjectCategoryPointBo bo) { |
||||
|
Map<String, Object> params = bo.getParams(); |
||||
|
LambdaQueryWrapper<ProjectCategoryPoint> lqw = Wrappers.lambdaQuery(); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getProjectId()), ProjectCategoryPoint::getProjectId, bo.getProjectId()); |
||||
|
lqw.like(StringUtils.isNotBlank(bo.getProjectName()), ProjectCategoryPoint::getProjectName, bo.getProjectName()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getCode()), ProjectCategoryPoint::getCode, bo.getCode()); |
||||
|
lqw.eq(bo.getIsChildren() != null, ProjectCategoryPoint::getIsChildren, bo.getIsChildren()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getOwnerId()), ProjectCategoryPoint::getOwnerId, bo.getOwnerId()); |
||||
|
lqw.like(StringUtils.isNotBlank(bo.getOwnerName()), ProjectCategoryPoint::getOwnerName, bo.getOwnerName()); |
||||
|
lqw.eq(bo.getStatus() != null, ProjectCategoryPoint::getStatus, bo.getStatus()); |
||||
|
return lqw; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增项目目录-点位 |
||||
|
* |
||||
|
* @param bo 项目目录-点位 |
||||
|
* @return 是否新增成功 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean insertByBo(ProjectCategoryPointBo bo) { |
||||
|
ProjectCategoryPoint add = MapstructUtils.convert(bo, ProjectCategoryPoint.class); |
||||
|
validEntityBeforeSave(add); |
||||
|
boolean flag = baseMapper.insert(add) > 0; |
||||
|
if (flag) { |
||||
|
bo.setId(add.getId()); |
||||
|
} |
||||
|
return flag; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改项目目录-点位 |
||||
|
* |
||||
|
* @param bo 项目目录-点位 |
||||
|
* @return 是否修改成功 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean updateByBo(ProjectCategoryPointBo bo) { |
||||
|
ProjectCategoryPoint update = MapstructUtils.convert(bo, ProjectCategoryPoint.class); |
||||
|
validEntityBeforeSave(update); |
||||
|
return baseMapper.updateById(update) > 0; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 保存前的数据校验 |
||||
|
*/ |
||||
|
private void validEntityBeforeSave(ProjectCategoryPoint entity){ |
||||
|
//TODO 做一些数据校验,如唯一约束
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 校验并批量删除项目目录-点位信息 |
||||
|
* |
||||
|
* @param ids 待删除的主键集合 |
||||
|
* @param isValid 是否进行有效性校验 |
||||
|
* @return 是否删除成功 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) { |
||||
|
if(isValid){ |
||||
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
|
} |
||||
|
return baseMapper.deleteByIds(ids) > 0; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<ProjectCategoryPoint> queryAll() { |
||||
|
LambdaQueryWrapper<ProjectCategoryPoint> qw = new LambdaQueryWrapper<>(); |
||||
|
qw.eq(ProjectCategoryPoint::getIsChildren, false); |
||||
|
|
||||
|
// 查询所有父级目录
|
||||
|
List<ProjectCategoryPoint> projectCategories = baseMapper.selectList(qw); |
||||
|
if (projectCategories == null) { |
||||
|
projectCategories = new ArrayList<>(); |
||||
|
} |
||||
|
|
||||
|
LambdaQueryWrapper<ProjectCategoryPoint> subQw = new LambdaQueryWrapper<>(); |
||||
|
subQw.eq(ProjectCategoryPoint::getIsChildren, true); |
||||
|
List<ProjectCategoryPoint> subList = baseMapper.selectList(subQw); |
||||
|
if (subList == null) { |
||||
|
subList = new ArrayList<>(); |
||||
|
} |
||||
|
|
||||
|
// 创建一个 Map 来快速查找子目录
|
||||
|
Map<String, List<ProjectCategoryPoint>> subCategoryMap = new HashMap<>(); |
||||
|
for (ProjectCategoryPoint subCategory : subList) { |
||||
|
String ownerId = subCategory.getOwnerId(); |
||||
|
if (ownerId != null) { // 判空检查
|
||||
|
subCategoryMap.computeIfAbsent(ownerId, k -> new ArrayList<>()).add(subCategory); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 遍历父级目录,并填充子目录
|
||||
|
for (ProjectCategoryPoint category : projectCategories) { |
||||
|
String parentId = category.getProjectId(); |
||||
|
if (subCategoryMap.containsKey(parentId)) { // 判空检查
|
||||
|
category.setChildren(subCategoryMap.get(parentId)); |
||||
|
} else { |
||||
|
// 如果没有子目录,则设置一个空列表
|
||||
|
category.setChildren(new ArrayList<>()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return projectCategories; |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue