【删除】 删除文件
This commit is contained in:
@@ -1,81 +0,0 @@
|
||||
package pc.exam.pp.module.judgement.controller.admin.Wps;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import pc.exam.pp.framework.common.enums.CommonStatusEnum;
|
||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||
import pc.exam.pp.framework.common.util.object.BeanUtils;
|
||||
import pc.exam.pp.module.judgement.controller.admin.Wps.vo.*;
|
||||
import pc.exam.pp.module.judgement.dal.dataobject.wpspptx.WpsPptxLinkDO;
|
||||
import pc.exam.pp.module.judgement.dal.dataobject.wpsword.WpsWordLinkDO;
|
||||
import pc.exam.pp.module.judgement.service.wps_pptx.WpsPptxLinkService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static pc.exam.pp.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - wps_pptx")
|
||||
@RestController
|
||||
@RequestMapping("/wps/pptx")
|
||||
@Validated
|
||||
public class PptxController {
|
||||
|
||||
@Resource
|
||||
private WpsPptxLinkService wpsPptxLinkService;
|
||||
|
||||
@PostMapping("create")
|
||||
@Operation(summary = "创建wps_pptx")
|
||||
public CommonResult<Long> createPptx(@Valid @RequestBody PptxSaveReqVO createReqVO) {
|
||||
Long pptxId = wpsPptxLinkService.createPptx(createReqVO);
|
||||
return success(pptxId);
|
||||
}
|
||||
|
||||
@PutMapping("update")
|
||||
@Operation(summary = "更新wps_pptx")
|
||||
public CommonResult<Boolean> updatePptx(@Valid @RequestBody PptxSaveReqVO updateReqVO) {
|
||||
wpsPptxLinkService.updatePptx(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("delete")
|
||||
@Operation(summary = "删除wps_pptx")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
public CommonResult<Boolean> deletePptx(@RequestParam("id") Long id) {
|
||||
wpsPptxLinkService.deletePptx(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获取wps_pptx列表")
|
||||
public CommonResult<List<PptxRespVO>> getPptxList(PptxListReqVO reqVO) {
|
||||
List<WpsPptxLinkDO> list = wpsPptxLinkService.getPptxList(reqVO);
|
||||
return success(BeanUtils.toBean(list, PptxRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/list-all-simple", "/simple-list"})
|
||||
@Operation(summary = "获取wps_pptx精简信息列表", description = "只包含被开启的wps_pptx,主要用于前端的下拉选项")
|
||||
public CommonResult<List<PptxSimpleRespVO>> getSimplePptxList() {
|
||||
List<WpsPptxLinkDO> list = wpsPptxLinkService.getPptxList(
|
||||
new PptxListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
||||
return success(BeanUtils.toBean(list, PptxSimpleRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得wps_pptx信息")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
public CommonResult<PptxRespVO> getPptx(@RequestParam("id") Long id) {
|
||||
WpsPptxLinkDO pptx = wpsPptxLinkService.getPptx(id);
|
||||
return success(BeanUtils.toBean(pptx, PptxRespVO.class));
|
||||
}
|
||||
@GetMapping("/listInfo")
|
||||
@Operation(summary = "获取wps_pptx列表")
|
||||
public CommonResult<List<PptxRespVO>> getPptxListInfo(PptxListReqVO reqVO) {
|
||||
List<WpsPptxLinkDO> list = wpsPptxLinkService.getPptxListInfo(reqVO);
|
||||
return success(BeanUtils.toBean(list, PptxRespVO.class));
|
||||
}
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
package pc.exam.pp.module.judgement.controller.admin.Wps.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - WpsWord对应关系 Request VO")
|
||||
@Data
|
||||
public class PptxListReqVO {
|
||||
|
||||
@Schema(description = "节点名称模糊匹配", example = "芋道")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
|
||||
private Integer status;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
private Integer belongTo;
|
||||
private String nodeFunction;
|
||||
private Integer isboo;
|
||||
private Integer titleType;
|
||||
private String unit;
|
||||
private String page;
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
package pc.exam.pp.module.judgement.controller.admin.Wps.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 节点信息 Response VO")
|
||||
@Data
|
||||
public class PptxRespVO {
|
||||
|
||||
@Schema(description = "节点编号", example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "节点名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "父节点 ID", example = "1024")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "节点方法")
|
||||
private String nodeFunction;
|
||||
|
||||
@Schema(description = "转中文")
|
||||
private String toChinese;
|
||||
|
||||
@Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
|
||||
private LocalDateTime createTime;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private Integer type;
|
||||
private Integer belongTo;
|
||||
private Integer isboo;
|
||||
private Integer titleType;
|
||||
private String unit;
|
||||
private String page;
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
package pc.exam.pp.module.judgement.controller.admin.Wps.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import pc.exam.pp.framework.common.enums.CommonStatusEnum;
|
||||
import pc.exam.pp.framework.common.validation.InEnum;
|
||||
|
||||
@Schema(description = "管理后台 - 节点创建/修改 Request VO")
|
||||
@Data
|
||||
public class PptxSaveReqVO {
|
||||
|
||||
@Schema(description = "节点编号", example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "节点名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
@NotBlank(message = "节点名称不能为空")
|
||||
private String name;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private Integer type;
|
||||
private Integer belongTo;
|
||||
private Integer isboo;
|
||||
private Integer titleType;
|
||||
private String unit;
|
||||
private String page;
|
||||
|
||||
@Schema(description = "父节点 ID", example = "1024")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "节点方法")
|
||||
private String nodeFunction;
|
||||
|
||||
@Schema(description = "转中文")
|
||||
private String toChinese;
|
||||
|
||||
@Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
package pc.exam.pp.module.judgement.controller.admin.Wps.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Schema(description = "管理后台 - 节点精简信息 Response VO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PptxSimpleRespVO {
|
||||
|
||||
@Schema(description = "节点编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "节点名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "父节点 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long parentId;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private Integer type;
|
||||
private Integer belongTo;
|
||||
private Integer isboo;
|
||||
private Integer titleType;
|
||||
private String unit;
|
||||
private String page;
|
||||
}
|
@@ -1,72 +0,0 @@
|
||||
package pc.exam.pp.module.judgement.dal.dataobject.wpspptx;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import pc.exam.pp.framework.common.enums.CommonStatusEnum;
|
||||
import pc.exam.pp.framework.tenant.core.db.TenantBaseDO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* wps pptx关系对应表
|
||||
*
|
||||
* @author REN
|
||||
*/
|
||||
@TableName("wps_pptx_link")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WpsPptxLinkDO extends TenantBaseDO {
|
||||
|
||||
public static final Long PARENT_ID_ROOT = 0L;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 父部门ID
|
||||
*
|
||||
* 关联 {@link #id}
|
||||
*/
|
||||
private Long parentId;
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 节点功能
|
||||
*/
|
||||
private String nodeFunction;
|
||||
/**
|
||||
* 中文描述
|
||||
*/
|
||||
private String toChinese;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 枚举 {@link CommonStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private Integer type;
|
||||
private String belongTo;
|
||||
private Integer isboo;
|
||||
private Integer titleType;
|
||||
private String unit;
|
||||
private String page;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<WpsPptxLinkDO> children = new ArrayList<>();
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
package pc.exam.pp.module.judgement.dal.mysql.wpspptx;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import pc.exam.pp.module.judgement.controller.admin.Wps.vo.PptxListReqVO;
|
||||
import pc.exam.pp.module.judgement.dal.dataobject.wpspptx.WpsPptxLinkDO;
|
||||
import pc.exam.pp.module.judgement.dal.dataobject.wpsword.WpsWordLinkDO;
|
||||
import pc.exam.pp.module.judgement.utils.tree.vo.TreeVO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface WpsPptxLinkMapper extends BaseMapperX<WpsPptxLinkDO> {
|
||||
|
||||
default List<WpsPptxLinkDO> selectList(PptxListReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<WpsPptxLinkDO>()
|
||||
.likeIfPresent(WpsPptxLinkDO::getName, reqVO.getName())
|
||||
.eq(reqVO.getBelongTo() != null, WpsPptxLinkDO::getBelongTo, reqVO.getBelongTo())
|
||||
.eqIfPresent(WpsPptxLinkDO::getStatus, reqVO.getStatus()));
|
||||
}
|
||||
|
||||
default WpsPptxLinkDO selectByParentIdAndName(Long parentId, String name) {
|
||||
return selectOne(WpsPptxLinkDO::getParentId, parentId, WpsPptxLinkDO::getName, name);
|
||||
}
|
||||
default WpsPptxLinkDO selectByNodeFunction(String nodeFunction) {
|
||||
LambdaQueryWrapper<WpsPptxLinkDO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.like(WpsPptxLinkDO::getNodeFunction, nodeFunction);
|
||||
return selectOne(wrapper);
|
||||
}
|
||||
|
||||
default List<WpsPptxLinkDO> selectInfoList(Long id) {
|
||||
return selectList(new LambdaQueryWrapperX<WpsPptxLinkDO>()
|
||||
.eqIfPresent(WpsPptxLinkDO::getParentId, id));
|
||||
}
|
||||
default Long selectCountByParentId(Long parentId) {
|
||||
return selectCount(WpsPptxLinkDO::getParentId, parentId);
|
||||
}
|
||||
|
||||
default List<WpsPptxLinkDO> selectListByParentId(Collection<Long> parentIds) {
|
||||
return selectList(WpsPptxLinkDO::getParentId, parentIds);
|
||||
}
|
||||
|
||||
List<TreeVO> selectTreeListByNodeFunction();
|
||||
|
||||
}
|
@@ -1,113 +0,0 @@
|
||||
package pc.exam.pp.module.judgement.service.wps_pptx;
|
||||
|
||||
import pc.exam.pp.framework.common.util.collection.CollectionUtils;
|
||||
import pc.exam.pp.module.judgement.controller.admin.Wps.vo.PptxListReqVO;
|
||||
import pc.exam.pp.module.judgement.controller.admin.Wps.vo.PptxSaveReqVO;
|
||||
import pc.exam.pp.module.judgement.dal.dataobject.wpspptx.WpsPptxLinkDO;
|
||||
import pc.exam.pp.module.judgement.utils.tree.vo.TreeVO;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 节点 Service 接口
|
||||
*
|
||||
* @author 朋辰
|
||||
*/
|
||||
public interface WpsPptxLinkService {
|
||||
|
||||
/**
|
||||
* 创建节点
|
||||
*
|
||||
* @param createReqVO 节点信息
|
||||
* @return 节点编号
|
||||
*/
|
||||
Long createPptx(PptxSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新节点
|
||||
*
|
||||
* @param updateReqVO 节点信息
|
||||
*/
|
||||
void updatePptx(PptxSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除节点
|
||||
*
|
||||
* @param id 节点编号
|
||||
*/
|
||||
void deletePptx(Long id);
|
||||
|
||||
/**
|
||||
* 获得节点信息
|
||||
*
|
||||
* @param id 节点编号
|
||||
* @return 节点信息
|
||||
*/
|
||||
WpsPptxLinkDO getPptx(Long id);
|
||||
|
||||
/**
|
||||
* 获得节点信息数组
|
||||
*
|
||||
* @param ids 节点编号数组
|
||||
* @return 节点信息数组
|
||||
*/
|
||||
List<WpsPptxLinkDO> getPptxList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 筛选节点列表
|
||||
*
|
||||
* @param reqVO 筛选条件请求 VO
|
||||
* @return 节点列表
|
||||
*/
|
||||
List<WpsPptxLinkDO> getPptxList(PptxListReqVO reqVO);
|
||||
List<WpsPptxLinkDO> getPptxListInfo(PptxListReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 获得指定编号的节点 Map
|
||||
*
|
||||
* @param ids 节点编号数组
|
||||
* @return 节点 Map
|
||||
*/
|
||||
default Map<Long, WpsPptxLinkDO> getPptxMap(Collection<Long> ids) {
|
||||
List<WpsPptxLinkDO> list = getPptxList(ids);
|
||||
return CollectionUtils.convertMap(list, WpsPptxLinkDO::getId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得指定节点的所有子节点
|
||||
*
|
||||
* @param id 节点编号
|
||||
* @return 子节点列表
|
||||
*/
|
||||
default List<WpsPptxLinkDO> getChildPptxList(Long id) {
|
||||
return getChildPptxList(Collections.singleton(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得指定节点的所有子节点
|
||||
*
|
||||
* @param ids 节点编号数组
|
||||
* @return 子节点列表
|
||||
*/
|
||||
List<WpsPptxLinkDO> getChildPptxList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得所有子节点,从缓存中
|
||||
*
|
||||
* @param id 父节点编号
|
||||
* @return 子节点列表
|
||||
*/
|
||||
Set<Long> getChildPptxIdListFromCache(Long id);
|
||||
|
||||
/**
|
||||
* 校验节点们是否有效。如下情况,视为无效:
|
||||
* 1. 节点编号不存在
|
||||
* 2. 节点被禁用
|
||||
*
|
||||
* @param ids 角色编号数组
|
||||
*/
|
||||
void validatePptxList(Collection<Long> ids);
|
||||
|
||||
List<TreeVO> getPptxTreeList();
|
||||
|
||||
}
|
@@ -1,250 +0,0 @@
|
||||
package pc.exam.pp.module.judgement.service.wps_pptx;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import pc.exam.pp.framework.common.enums.CommonStatusEnum;
|
||||
import pc.exam.pp.framework.common.util.object.BeanUtils;
|
||||
import pc.exam.pp.framework.datapermission.core.annotation.DataPermission;
|
||||
import pc.exam.pp.framework.tenant.core.aop.TenantIgnore;
|
||||
import pc.exam.pp.module.judgement.controller.admin.Wps.vo.PptxListReqVO;
|
||||
import pc.exam.pp.module.judgement.controller.admin.Wps.vo.PptxSaveReqVO;
|
||||
import pc.exam.pp.module.judgement.dal.dataobject.wpspptx.WpsPptxLinkDO;
|
||||
import pc.exam.pp.module.judgement.dal.dataobject.wpsword.WpsWordLinkDO;
|
||||
import pc.exam.pp.module.judgement.dal.mysql.wpspptx.WpsPptxLinkMapper;
|
||||
import pc.exam.pp.module.judgement.utils.tree.vo.TreeVO;
|
||||
import pc.exam.pp.module.system.dal.redis.RedisKeyConstants;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static pc.exam.pp.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static pc.exam.pp.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static pc.exam.pp.module.system.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 节点 Service 实现类
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class WpsPptxLinkServiceImpl implements WpsPptxLinkService {
|
||||
|
||||
@Resource
|
||||
private WpsPptxLinkMapper wpsPptxLinkMapper;
|
||||
|
||||
@Override
|
||||
@CacheEvict(cacheNames = RedisKeyConstants.WPS_PPTX_CHILDREN_ID_LIST,
|
||||
allEntries = true) // allEntries 清空所有缓存,因为操作一个节点,涉及到多个缓存
|
||||
public Long createPptx(PptxSaveReqVO createReqVO) {
|
||||
if (createReqVO.getParentId() == null) {
|
||||
createReqVO.setParentId(WpsPptxLinkDO.PARENT_ID_ROOT);
|
||||
}
|
||||
// 校验父节点的有效性
|
||||
validateParentPptx(null, createReqVO.getParentId());
|
||||
// 校验节点名的唯一性
|
||||
validatePptxNameUnique(null, createReqVO.getParentId(), createReqVO.getName());
|
||||
|
||||
// 插入节点
|
||||
WpsPptxLinkDO wpsPptxLinkDO = BeanUtils.toBean(createReqVO, WpsPptxLinkDO.class);
|
||||
wpsPptxLinkMapper.insert(wpsPptxLinkDO);
|
||||
return wpsPptxLinkDO.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(cacheNames = RedisKeyConstants.WPS_PPTX_CHILDREN_ID_LIST,
|
||||
allEntries = true) // allEntries 清空所有缓存,因为操作一个节点,涉及到多个缓存
|
||||
public void updatePptx(PptxSaveReqVO updateReqVO) {
|
||||
if (updateReqVO.getParentId() == null) {
|
||||
updateReqVO.setParentId(WpsPptxLinkDO.PARENT_ID_ROOT);
|
||||
}
|
||||
// 校验自己存在
|
||||
validatePptxExists(updateReqVO.getId());
|
||||
// 校验父节点的有效性
|
||||
validateParentPptx(updateReqVO.getId(), updateReqVO.getParentId());
|
||||
// 校验节点名的唯一性
|
||||
validatePptxNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName());
|
||||
|
||||
// 更新节点
|
||||
WpsPptxLinkDO updateObj = BeanUtils.toBean(updateReqVO, WpsPptxLinkDO.class);
|
||||
wpsPptxLinkMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(cacheNames = RedisKeyConstants.WPS_PPTX_CHILDREN_ID_LIST,
|
||||
allEntries = true) // allEntries 清空所有缓存,因为操作一个节点,涉及到多个缓存
|
||||
public void deletePptx(Long id) {
|
||||
// 校验是否存在
|
||||
validatePptxExists(id);
|
||||
// 校验是否有子节点
|
||||
if (wpsPptxLinkMapper.selectCountByParentId(id) > 0) {
|
||||
throw exception(WORD_NOT_FOUND);
|
||||
}
|
||||
// 删除节点
|
||||
wpsPptxLinkMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void validatePptxExists(Long id) {
|
||||
if (id == null) {
|
||||
return;
|
||||
}
|
||||
WpsPptxLinkDO wpsPptxLinkDO = wpsPptxLinkMapper.selectById(id);
|
||||
if (wpsPptxLinkDO == null) {
|
||||
throw exception(PPTX_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void validateParentPptx(Long id, Long parentId) {
|
||||
if (parentId == null || WpsPptxLinkDO.PARENT_ID_ROOT.equals(parentId)) {
|
||||
return;
|
||||
}
|
||||
// 1. 不能设置自己为父节点
|
||||
if (Objects.equals(id, parentId)) {
|
||||
throw exception(PPTX_PARENT_ERROR);
|
||||
}
|
||||
// 2. 父节点不存在
|
||||
WpsPptxLinkDO parentPptx = wpsPptxLinkMapper.selectById(parentId);
|
||||
if (parentPptx == null) {
|
||||
throw exception(PPTX_PARENT_NOT_EXITS);
|
||||
}
|
||||
// 3. 递归校验父节点,如果父节点是自己的子节点,则报错,避免形成环路
|
||||
// id 为空,说明新增,不需要考虑环路
|
||||
if (id == null) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < Short.MAX_VALUE; i++) {
|
||||
// 3.1 校验环路
|
||||
parentId = parentPptx.getParentId();
|
||||
if (Objects.equals(id, parentId)) {
|
||||
throw exception(PPTX_PARENT_IS_CHILD);
|
||||
}
|
||||
// 3.2 继续递归下一级父节点
|
||||
if (parentId == null || WpsPptxLinkDO.PARENT_ID_ROOT.equals(parentId)) {
|
||||
break;
|
||||
}
|
||||
parentPptx = wpsPptxLinkMapper.selectById(parentId);
|
||||
if (parentPptx == null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void validatePptxNameUnique(Long id, Long parentId, String name) {
|
||||
WpsPptxLinkDO wpsPptxLinkDO = wpsPptxLinkMapper.selectByParentIdAndName(parentId, name);
|
||||
if (wpsPptxLinkDO == null) {
|
||||
return;
|
||||
}
|
||||
// 如果 id 为空,说明不用比较是否为相同 id 的节点
|
||||
if (id == null) {
|
||||
throw exception(PPTX_NAME_DUPLICATE);
|
||||
}
|
||||
if (ObjectUtil.notEqual(wpsPptxLinkDO.getId(), id)) {
|
||||
throw exception(PPTX_NAME_DUPLICATE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WpsPptxLinkDO getPptx(Long id) {
|
||||
return wpsPptxLinkMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WpsPptxLinkDO> getPptxList(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return wpsPptxLinkMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WpsPptxLinkDO> getPptxList(PptxListReqVO reqVO) {
|
||||
List<WpsPptxLinkDO> list = wpsPptxLinkMapper.selectList(reqVO);
|
||||
list.sort(Comparator.comparing(WpsPptxLinkDO::getSort));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WpsPptxLinkDO> getPptxListInfo(PptxListReqVO reqVO) {
|
||||
String nodeFunction = reqVO.getNodeFunction().split("\\[")[0];
|
||||
List<WpsPptxLinkDO> pptxList = new ArrayList<>();
|
||||
WpsPptxLinkDO data = wpsPptxLinkMapper.selectByNodeFunction(nodeFunction);
|
||||
if (data == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<WpsPptxLinkDO> wpsPptxLinkDOS = wpsPptxLinkMapper.selectInfoList(data.getId());
|
||||
// 在依次判断是否还有子数据
|
||||
for (WpsPptxLinkDO wpsPptxLinkDO : wpsPptxLinkDOS) {
|
||||
pptxList.add(wpsPptxLinkDO);
|
||||
List<WpsPptxLinkDO> datas = wpsPptxLinkMapper.selectInfoList(wpsPptxLinkDO.getId());
|
||||
if (datas != null) {
|
||||
for (WpsPptxLinkDO wpsPptxLinkDO1 : datas) {
|
||||
pptxList.add(wpsPptxLinkDO1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return pptxList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WpsPptxLinkDO> getChildPptxList(Collection<Long> ids) {
|
||||
List<WpsPptxLinkDO> children = new LinkedList<>();
|
||||
// 遍历每一层
|
||||
Collection<Long> parentIds = ids;
|
||||
// 使用 Short.MAX_VALUE 避免 bug 场景下,存在死循环
|
||||
for (int i = 0; i < Short.MAX_VALUE; i++) {
|
||||
// 查询当前层,所有的子节点
|
||||
List<WpsPptxLinkDO> pptxs = wpsPptxLinkMapper.selectListByParentId(parentIds);
|
||||
// 1. 如果没有子节点,则结束遍历
|
||||
if (CollUtil.isEmpty(pptxs)) {
|
||||
break;
|
||||
}
|
||||
// 2. 如果有子节点,继续遍历
|
||||
children.addAll(pptxs);
|
||||
parentIds = convertSet(pptxs, WpsPptxLinkDO::getId);
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DataPermission(enable = false) // 禁用数据权限,避免建立不正确的缓存
|
||||
@Cacheable(cacheNames = RedisKeyConstants.WPS_PPTX_CHILDREN_ID_LIST, key = "#id")
|
||||
public Set<Long> getChildPptxIdListFromCache(Long id) {
|
||||
List<WpsPptxLinkDO> children = getChildPptxList(id);
|
||||
return convertSet(children, WpsPptxLinkDO::getId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validatePptxList(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
// 获得科室信息
|
||||
Map<Long, WpsPptxLinkDO> PptxMap = getPptxMap(ids);
|
||||
// 校验
|
||||
ids.forEach(id -> {
|
||||
WpsPptxLinkDO Pptx = PptxMap.get(id);
|
||||
if (Pptx == null) {
|
||||
throw exception(PPTX_NOT_FOUND);
|
||||
}
|
||||
if (!CommonStatusEnum.ENABLE.getStatus().equals(Pptx.getStatus())) {
|
||||
throw exception(PPTX_NOT_ENABLE, Pptx.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@TenantIgnore
|
||||
public List<TreeVO> getPptxTreeList() {
|
||||
return wpsPptxLinkMapper.selectTreeListByNodeFunction();
|
||||
}
|
||||
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="pc.exam.pp.module.judgement.dal.mysql.wpspptx.WpsPptxLinkMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
<resultMap id="NodeResultMap" type="pc.exam.pp.module.judgement.utils.tree.vo.TreeVO">
|
||||
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="parentId" column="parent_id" jdbcType="BIGINT"/>
|
||||
<result property="nodeFunction" column="node_function" jdbcType="VARCHAR"/>
|
||||
<result property="toChinese" column="to_chinese" jdbcType="VARCHAR"/>
|
||||
<result property="type" column="type" jdbcType="TINYINT"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="selectTreeListByNodeFunction" resultMap="NodeResultMap">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
wps_pptx_link
|
||||
</select>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user