| | |
| | | import com.ycl.system.domain.group.Update; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | |
| | | public abstract class AbsForm { |
| | | |
| | | @ApiModelProperty(value = "id,修改必传", required = false) |
| | | @NotBlank(message = "请选择数据", groups = {Update.class}) |
| | | @NotNull(message = "请选择数据", groups = {Update.class}) |
| | | private Integer id; |
| | | |
| | | } |
| | |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 基础响应 |
| | |
| | | private Integer id; |
| | | |
| | | /** |
| | | * 值 |
| | | * 展示内容 |
| | | */ |
| | | private String value; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ycl.platform.base; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 级联选择数据格式 |
| | | * |
| | | * @author:xp |
| | | * @date:2024/4/28 14:37 |
| | | */ |
| | | @Data |
| | | public class Cascader { |
| | | |
| | | /** |
| | | * 选中 |
| | | */ |
| | | private Long value; |
| | | |
| | | /** |
| | | * 显示 |
| | | */ |
| | | private String label; |
| | | |
| | | private Long parentId; |
| | | |
| | | private List<Cascader> Children; |
| | | |
| | | } |
| | |
| | | |
| | | @ApiModelProperty("运维单位") |
| | | @TableField(value = "unit_id", updateStrategy = FieldStrategy.IGNORED) |
| | | private Integer unitId; |
| | | private Long unitId; |
| | | |
| | | @ApiModelProperty("运维状态") |
| | | @TableField("status") |
| | |
| | | @ApiModelProperty("备注") |
| | | @TableField("remark") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty("运维类型") |
| | | @TableField("category") |
| | | private Short category; |
| | | |
| | | @ApiModelProperty("上报部门") |
| | | @TableField("dept_id") |
| | | private Long deptId; |
| | | |
| | | @TableField("point_detail") |
| | | private String pointDetail; |
| | | @TableField("point_tag") |
| | | private String pointTag; |
| | | |
| | | |
| | | } |
| | |
| | | import com.ycl.system.domain.group.Add; |
| | | import com.ycl.platform.base.AbsForm; |
| | | import com.ycl.platform.domain.entity.YwPoint; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import org.springframework.beans.BeanUtils; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 运维点位表单 |
| | |
| | | @ApiModelProperty("运维单位") |
| | | private Integer unitId; |
| | | |
| | | // @NotBlank(message = "运维状态不能为空", groups = {Add.class, Update.class}) |
| | | @NotNull(message = "监管部门不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("监管部门") |
| | | private Long deptId; |
| | | |
| | | @NotEmpty(message = "点位标签不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("点位标签") |
| | | private List<String> pointTag; |
| | | |
| | | @ApiModelProperty("运维状态") |
| | | private String status; |
| | | |
| | | @ApiModelProperty("备注") |
| | | private String remark; |
| | | |
| | | private String pointDetail; |
| | | |
| | | // @NotBlank(message = "备注不能为空", groups = {Add.class, Update.class}) |
| | | // @ApiModelProperty("备注") |
| | | // private String remark; |
| | | @ApiModelProperty("类型") |
| | | private Short category; |
| | | |
| | | public static YwPoint getEntityByForm(@NonNull YwPointForm form, YwPoint entity) { |
| | | if(entity == null) { |
| | |
| | | package com.ycl.platform.domain.vo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.ycl.platform.base.AbsVo; |
| | | import com.ycl.platform.domain.entity.YwPoint; |
| | | |
| | |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import org.springframework.beans.BeanUtils; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.experimental.Accessors; |
| | | |
| | |
| | | private LocalDateTime endTime; |
| | | |
| | | /** 运维单位 */ |
| | | private Integer unitId; |
| | | private Long unitId; |
| | | private String unitName; |
| | | |
| | | /** 运维状态 */ |
| | |
| | | |
| | | private Short category; |
| | | |
| | | /** 监管部门 */ |
| | | private Long deptId; |
| | | private List<Long> deptIds; |
| | | private String deptName; |
| | | private String pointDetail; |
| | | |
| | | /** 点位标签 */ |
| | | private String [] pointTags; |
| | | private String pointTagString; |
| | | |
| | | public static YwPointVO getVoByEntity(@NonNull YwPoint entity, YwPointVO vo) { |
| | | if(vo == null) { |
| | |
| | | package com.ycl.platform.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ycl.platform.base.BaseSelect; |
| | | import com.ycl.platform.domain.entity.YwPoint; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ycl.platform.domain.query.YwPointQuery; |
| | | import com.ycl.platform.domain.vo.YwPointVO; |
| | | import com.ycl.platform.domain.form.YwPointForm; |
| | | import java.util.List; |
| | |
| | | * @return |
| | | */ |
| | | List<BaseSelect> selectData(@Param("keyword") String keyword, @Param("unitId") Integer unitId); |
| | | |
| | | IPage page(IPage<YwPointVO> page, @Param("query") YwPointQuery query); |
| | | } |
| | |
| | | import java.util.List; |
| | | |
| | | import com.ycl.system.entity.SysUser; |
| | | import com.ycl.system.mapper.SysDeptMapper; |
| | | import com.ycl.system.service.ISysDeptService; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | @RequiredArgsConstructor |
| | | public class YwPointServiceImpl extends ServiceImpl<YwPointMapper, YwPoint> implements YwPointService { |
| | | |
| | | private final YwPointMapper ywPointMapper; |
| | | private final ISysDeptService deptService; |
| | | private final SysDeptMapper sysDeptMapper; |
| | | private final YwUnitService unitService; |
| | | private final YwUnitMapper ywUnitMapper; |
| | | private final RegionMapper regionMapper; |
| | | private final YwPeopleMapper ywPeopleMapper; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public Result update(YwPointForm form) { |
| | | |
| | | YwPoint entity = baseMapper.selectById(form.getId()); |
| | | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | | if (baseMapper.updateById(entity) > 0) { |
| | | return Result.ok("修改成功"); |
| | | } |
| | | return Result.error("修改失败"); |
| | | entity.setPointTag(form.getPointTag().stream().collect(Collectors.joining(","))); |
| | | baseMapper.updateById(entity); |
| | | return Result.ok("修改成功"); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public Result page(YwPointQuery query) { |
| | | |
| | | IPage<YwPoint> page = new LambdaQueryChainWrapper<>(baseMapper) |
| | | .like(StringUtils.hasText(query.getPointName()), YwPoint::getPointName, query.getPointName()) |
| | | .orderByDesc(YwPoint::getCreateTime) |
| | | .page(PageUtil.getPage(query, YwPoint.class)); |
| | | |
| | | List<YwPointVO> vos = page.getRecords().stream() |
| | | .map( |
| | | entity -> YwPointVO.getVoByEntity(entity, null) |
| | | .setDeptName(deptService.selectDeptById(entity.getDeptId()).getDeptName()) |
| | | .setUnitName(unitService.getById(entity.getUnitId()).getUnitName()) |
| | | ) |
| | | .collect(Collectors.toList()); |
| | | |
| | | return Result.ok().data(vos).total(page.getTotal()); |
| | | IPage<YwPointVO> page = PageUtil.getPage(query, YwPointVO.class); |
| | | baseMapper.page(page, query); |
| | | page.getRecords().stream().forEach(point -> { |
| | | if (StringUtils.hasText(point.getPointTagString())) { |
| | | point.setPointTags(point.getPointTagString().split(",")); |
| | | } |
| | | }); |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public Result detail(String id) { |
| | | |
| | | YwPoint entity = baseMapper.selectById(id); |
| | | Assert.notNull(entity, "记录不存在"); |
| | | YwPointVO vo = YwPointVO.getVoByEntity(entity, null); |
| | | if (StringUtils.hasText(entity.getPointTag())) { |
| | | vo.setPointTags(entity.getPointTag().split(",")); |
| | | } |
| | | if (Objects.nonNull(entity.getDeptId())) { |
| | | vo.setDeptIds(sysDeptMapper.selectParents(entity.getDeptId())); |
| | | } |
| | | return Result.ok().data(vo); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 部门信息 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | |
| | | public Result pullList() { |
| | | return deptService.pullList(); |
| | | } |
| | | |
| | | @GetMapping("/cascader") |
| | | @ApiOperation(value = "部门级联选择数据", notes = "部门级联选择数据") |
| | | public Result cascader() { |
| | | return deptService.cascader(); |
| | | } |
| | | } |
| | |
| | | package com.ycl.system.mapper; |
| | | |
| | | import com.ycl.platform.base.Cascader; |
| | | import com.ycl.system.entity.SysDept; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | |
| | | |
| | | /** |
| | | * 部门管理 数据层 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Mapper |
| | |
| | | { |
| | | /** |
| | | * 查询部门管理数据 |
| | | * |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 部门信息集合 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据角色ID查询部门树信息 |
| | | * |
| | | * |
| | | * @param roleId 角色ID |
| | | * @param deptCheckStrictly 部门树选择项是否关联显示 |
| | | * @return 选中部门列表 |
| | |
| | | |
| | | /** |
| | | * 根据部门ID查询信息 |
| | | * |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 部门信息 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据ID查询所有子部门 |
| | | * |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 部门列表 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据ID查询所有子部门(正常状态) |
| | | * |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 子部门数 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 是否存在子节点 |
| | | * |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询部门是否存在用户 |
| | | * |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 校验部门名称是否唯一 |
| | | * |
| | | * |
| | | * @param deptName 部门名称 |
| | | * @param parentId 父部门ID |
| | | * @return 结果 |
| | |
| | | |
| | | /** |
| | | * 新增部门信息 |
| | | * |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 修改部门信息 |
| | | * |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 修改所在部门正常状态 |
| | | * |
| | | * |
| | | * @param deptIds 部门ID组 |
| | | */ |
| | | public void updateDeptStatusNormal(Long[] deptIds); |
| | | |
| | | /** |
| | | * 修改子元素关系 |
| | | * |
| | | * |
| | | * @param depts 子元素 |
| | | * @return 结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 删除部门管理信息 |
| | | * |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteDeptById(Long deptId); |
| | | |
| | | /** |
| | | * 级联数据 |
| | | * |
| | | * @return |
| | | */ |
| | | List<Cascader> cascader(); |
| | | |
| | | /** |
| | | * 查询自己的父类部门ID |
| | | * |
| | | * @param deptId |
| | | * @return |
| | | */ |
| | | List<Long> selectParents(@Param("id") Long deptId); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 部门管理 服务层 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysDeptService |
| | | { |
| | | /** |
| | | * 查询部门管理数据 |
| | | * |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 部门信息集合 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询部门树结构信息 |
| | | * |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 部门树信息集合 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 构建前端所需要树结构 |
| | | * |
| | | * |
| | | * @param depts 部门列表 |
| | | * @return 树结构列表 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 构建前端所需要下拉树结构 |
| | | * |
| | | * |
| | | * @param depts 部门列表 |
| | | * @return 下拉树结构列表 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据角色ID查询部门树信息 |
| | | * |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 选中部门列表 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据部门ID查询信息 |
| | | * |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 部门信息 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据ID查询所有子部门(正常状态) |
| | | * |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 子部门数 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 是否存在部门子节点 |
| | | * |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询部门是否存在用户 |
| | | * |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 结果 true 存在 false 不存在 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 校验部门名称是否唯一 |
| | | * |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 校验部门是否有数据权限 |
| | | * |
| | | * |
| | | * @param deptId 部门id |
| | | */ |
| | | public void checkDeptDataScope(Long deptId); |
| | | |
| | | /** |
| | | * 新增保存部门信息 |
| | | * |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 修改保存部门信息 |
| | | * |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 删除部门管理信息 |
| | | * |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 结果 |
| | | */ |
| | |
| | | * @return |
| | | */ |
| | | Result pullList(); |
| | | |
| | | /** |
| | | * 部门级联数据 |
| | | * |
| | | * @return |
| | | */ |
| | | Result cascader(); |
| | | } |
| | |
| | | import annotation.DataScope; |
| | | import com.ycl.exception.ServiceException; |
| | | import com.ycl.platform.base.BaseSelect; |
| | | import com.ycl.platform.base.Cascader; |
| | | import com.ycl.system.Result; |
| | | import com.ycl.system.domain.TreeSelect; |
| | | import com.ycl.system.entity.SysDept; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import utils.text.Convert; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 部门管理 服务实现 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | |
| | | |
| | | /** |
| | | * 查询部门管理数据 |
| | | * |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 部门信息集合 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询部门树结构信息 |
| | | * |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 部门树信息集合 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 构建前端所需要树结构 |
| | | * |
| | | * |
| | | * @param depts 部门列表 |
| | | * @return 树结构列表 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 构建前端所需要下拉树结构 |
| | | * |
| | | * |
| | | * @param depts 部门列表 |
| | | * @return 下拉树结构列表 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据角色ID查询部门树信息 |
| | | * |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 选中部门列表 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据部门ID查询信息 |
| | | * |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 部门信息 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据ID查询所有子部门(正常状态) |
| | | * |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 子部门数 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 是否存在子节点 |
| | | * |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询部门是否存在用户 |
| | | * |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 结果 true 存在 false 不存在 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 校验部门名称是否唯一 |
| | | * |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 校验部门是否有数据权限 |
| | | * |
| | | * |
| | | * @param deptId 部门id |
| | | */ |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 新增保存部门信息 |
| | | * |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 修改保存部门信息 |
| | | * |
| | | * |
| | | * @param dept 部门信息 |
| | | * @return 结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 修改该部门的父级部门状态 |
| | | * |
| | | * |
| | | * @param dept 当前部门 |
| | | */ |
| | | private void updateParentDeptStatusNormal(SysDept dept) |
| | |
| | | |
| | | /** |
| | | * 修改子元素关系 |
| | | * |
| | | * |
| | | * @param deptId 被修改的部门ID |
| | | * @param newAncestors 新的父ID集合 |
| | | * @param oldAncestors 旧的父ID集合 |
| | |
| | | |
| | | /** |
| | | * 删除部门管理信息 |
| | | * |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 结果 |
| | | */ |
| | |
| | | return Result.ok().data(vos); |
| | | } |
| | | |
| | | @Override |
| | | public Result cascader() { |
| | | List<Cascader> data = deptMapper.cascader(); |
| | | return Result.ok().data(this.buildTree(data)); |
| | | } |
| | | |
| | | public List<Cascader> buildTree(List<Cascader> cascaders) { |
| | | // 创建一个映射,以parentId为键,对应的子节点列表为值 |
| | | Map<Long, List<Cascader>> map = new HashMap<>(); |
| | | for (Cascader cascader : cascaders) { |
| | | Long parentId = cascader.getParentId(); |
| | | map.computeIfAbsent(parentId, k -> new ArrayList<>()).add(cascader); |
| | | } |
| | | |
| | | // 递归函数,用于构建树 |
| | | List<Cascader> tree = new ArrayList<>(); |
| | | for (Cascader cascader : cascaders) { |
| | | if (cascader.getParentId().equals(0L)) { // 根节点 |
| | | tree.add(setChildren(cascader, map)); |
| | | } |
| | | } |
| | | |
| | | // 更新原始列表为树形结构 |
| | | cascaders.clear(); |
| | | cascaders.addAll(tree); |
| | | return cascaders; |
| | | } |
| | | |
| | | private Cascader setChildren(Cascader cascader, Map<Long, List<Cascader>> map) { |
| | | List<Cascader> children = map.getOrDefault(cascader.getValue(), new ArrayList<>()); |
| | | for (Cascader child : children) { |
| | | setChildren(child, map); // 递归设置子节点的子节点 |
| | | } |
| | | cascader.setChildren(children); |
| | | return cascader; |
| | | } |
| | | |
| | | /** |
| | | * 递归列表 |
| | | */ |
| | |
| | | <result property="updateBy" column="update_by" /> |
| | | <result property="updateTime" column="update_time" /> |
| | | </resultMap> |
| | | |
| | | |
| | | <sql id="selectDeptVo"> |
| | | select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time,d.area |
| | | from sys_dept d |
| | | </sql> |
| | | |
| | | |
| | | <select id="selectDeptList" parameterType="com.ycl.system.entity.SysDept" resultMap="SysDeptResult"> |
| | | <include refid="selectDeptVo"/> |
| | | where d.del_flag = '0' |
| | |
| | | ${params.dataScope} |
| | | order by d.parent_id, d.order_num |
| | | </select> |
| | | |
| | | |
| | | <select id="selectDeptListByRoleId" resultType="Long"> |
| | | select d.dept_id |
| | | from sys_dept d |
| | |
| | | </if> |
| | | order by d.parent_id, d.order_num |
| | | </select> |
| | | |
| | | |
| | | <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult"> |
| | | select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,d.area, |
| | | (select dept_name from sys_dept where dept_id = d.parent_id) parent_name |
| | | from sys_dept d |
| | | where d.dept_id = #{deptId} |
| | | </select> |
| | | |
| | | |
| | | <select id="checkDeptExistUser" parameterType="Long" resultType="int"> |
| | | select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0' |
| | | </select> |
| | | |
| | | |
| | | <select id="hasChildByDeptId" parameterType="Long" resultType="int"> |
| | | select count(1) from sys_dept |
| | | where del_flag = '0' and parent_id = #{deptId} limit 1 |
| | | </select> |
| | | |
| | | |
| | | <select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult"> |
| | | select * from sys_dept where find_in_set(#{deptId}, ancestors) |
| | | </select> |
| | | |
| | | |
| | | <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int"> |
| | | select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors) |
| | | </select> |
| | | |
| | | |
| | | <select id="checkDeptNameUnique" resultMap="SysDeptResult"> |
| | | <include refid="selectDeptVo"/> |
| | | where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1 |
| | | </select> |
| | | |
| | | |
| | | <insert id="insertDept" parameterType="com.ycl.system.entity.SysDept"> |
| | | insert into sys_dept( |
| | | <if test="deptId != null and deptId != 0">dept_id,</if> |
| | |
| | | sysdate() |
| | | ) |
| | | </insert> |
| | | |
| | | |
| | | <update id="updateDept" parameterType="com.ycl.system.entity.SysDept"> |
| | | update sys_dept |
| | | <set> |
| | |
| | | </set> |
| | | where dept_id = #{deptId} |
| | | </update> |
| | | |
| | | |
| | | <update id="updateDeptChildren" parameterType="java.util.List"> |
| | | update sys_dept set ancestors = |
| | | <foreach collection="depts" item="item" index="index" |
| | |
| | | #{item.deptId} |
| | | </foreach> |
| | | </update> |
| | | |
| | | |
| | | <update id="updateDeptStatusNormal" parameterType="Long"> |
| | | update sys_dept set status = '0' where dept_id in |
| | | update sys_dept set status = '0' where dept_id in |
| | | <foreach collection="array" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | </update> |
| | | |
| | | |
| | | <delete id="deleteDeptById" parameterType="Long"> |
| | | update sys_dept set del_flag = '2' where dept_id = #{deptId} |
| | | </delete> |
| | | |
| | | </mapper> |
| | | <select id="cascader" resultType="com.ycl.platform.base.Cascader"> |
| | | SELECT dept_id as value, dept_name as label, parent_id as parentId FROM sys_dept WHERE status = '0' AND del_flag = '0' |
| | | </select> |
| | | |
| | | <select id="selectParents" resultType="long"> |
| | | WITH RECURSIVE temp_table AS ( |
| | | SELECT |
| | | dept_id, dept_name, parent_id, 0 as level FROM sys_dept WHERE dept_id = 101 |
| | | UNION ALL |
| | | SELECT |
| | | sd.dept_id, sd.dept_name, sd.parent_id, tb.level+1 FROM sys_dept sd INNER JOIN temp_table tb ON sd.dept_id = tb.parent_id |
| | | ) |
| | | SELECT |
| | | dept_id |
| | | FROM |
| | | temp_table |
| | | ORDER BY |
| | | level DESC |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <result column="start_time" property="startTime" /> |
| | | <result column="end_time" property="endTime" /> |
| | | <result column="unit_id" property="unitId" /> |
| | | <result column="unit_name" property="unitName" /> |
| | | <result column="status" property="status" /> |
| | | <result column="dept_id" property="deptId" /> |
| | | <result column="dept_name" property="deptName" /> |
| | | <result column="remark" property="remark" /> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="update_time" property="updateTime" /> |
| | | <result column="category" property="category" /> |
| | | <result column="point_tag" property="pointTagString" /> |
| | | </resultMap> |
| | | |
| | | <select id="selectData" resultType="com.ycl.platform.base.BaseSelect"> |
| | | |
| | | </select> |
| | | |
| | | <select id="page" resultMap="BaseResultMap"> |
| | | SELECT |
| | | typ.id, |
| | | typ.point_name, |
| | | typ.point_tag, |
| | | typ.start_time, |
| | | typ.end_time, |
| | | typ.unit_id, |
| | | tyu.unit_name, |
| | | typ.status, |
| | | typ.dept_id, |
| | | sd.dept_name, |
| | | typ.remark, |
| | | typ.create_time, |
| | | typ.update_time, |
| | | typ.point_tag, |
| | | typ.category |
| | | FROM |
| | | t_yw_point typ |
| | | LEFT JOIN t_yw_unit tyu ON typ.unit_id = tyu.id AND tyu.deleted = 0 |
| | | LEFT JOIN sys_dept sd ON typ.dept_id = sd.dept_id AND sd.del_flag = 0 |
| | | <where> |
| | | <if test="query.pointName != null and query.pointName != ''"> |
| | | AND typ.point_name like concat('%', #{query.pointName}, '%') |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | </mapper> |