java框架树结构实现(带层级、编码、排序)

news2024/10/3 13:28:55

1、需求

实现一个影像资料库的功能,用树结构对资料进行分类

2、数据结构

通过id、pid表示父子关系

通过code表示层级关系

通过layer表示层级

通过sort进行排序

3、实体类

package org.jeecg.modules.image.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.system.base.entity.BaseSearchDTO;
import org.jeecg.common.system.base.support.Condition;
import org.jeecg.common.system.base.support.Match;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.data.annotation.Transient;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Description: 影像资料分类
 * @Author: jeecg-boot
 * @Date: 2024-05-28
 * @Version: V1.0
 */
@Data
@TableName("img_classification")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "img_classification对象", description = "影像资料分类")
public class ImgClassification extends BaseSearchDTO {

    /**
     * 主键
     */
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键")
    private String id;
    /**
     * 创建人
     */
    @ApiModelProperty(value = "创建人")
    private String createBy;
    /**
     * 创建日期
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建日期")
    private Date createTime;
    /**
     * 更新人
     */
    @ApiModelProperty(value = "更新人")
    private String updateBy;
    /**
     * 更新日期
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "更新日期")
    private Date updateTime;
    /**
     * 所属部门
     */
    @ApiModelProperty(value = "所属部门")
    private String sysOrgCode;
    /**
     * 父id
     */
    @Excel(name = "父id", width = 15)
    @ApiModelProperty(value = "父id")
    private String pid;
    /**
     * 分类编码
     */
    @Excel(name = "分类编码", width = 15)
    @ApiModelProperty(value = "分类编码")
    @Condition(match = Match.LLIKE)
    private String code;
    /**
     * 分类名称
     */
    @Excel(name = "分类名称", width = 15)
    @ApiModelProperty(value = "分类名称")
    @Condition(match = Match.LIKE)
    private String name;
    /**
     * 层级
     */
    @Excel(name = "层级", width = 15)
    @ApiModelProperty(value = "层级")
    private Integer layer;
    /**
     * 排序
     */
    @Excel(name = "排序", width = 15)
    @ApiModelProperty(value = "排序")
    private Integer sort;
    /**
     * 是否有子节点
     */
    @Excel(name = "是否有子节点", width = 15)
    @ApiModelProperty(value = "是否有子节点")
    private Boolean hasChildren;

    不在库里

    /**
     * 父级名称
     */
    @TableField(exist = false)
    @ApiModelProperty(value = "父级名称")
    private String parentName;

    /**
     * 子集
     */
    @Transient
    @TableField(exist = false)
    @ApiModelProperty(value = "子集")
    private List<ImgClassification> children = new ArrayList<>();


}

4、控制器

package org.jeecg.modules.image.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.base.service.BaseService;
import org.jeecg.modules.image.entity.ImgClassification;
import org.jeecg.modules.image.service.IImgClassificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Description: 影像资料分类
 * @Author: jeecg-boot
 * @Date: 2024-05-28
 * @Version: V1.0
 */
@Api(tags = "1.0.1.0 影像资料分类")
@RestController
@RequestMapping("/image/imgClassification")
@Slf4j
public class ImgClassificationController extends JeecgController<ImgClassification, IImgClassificationService> {
    @Autowired
    private IImgClassificationService imgClassificationService;
    @Autowired
    private BaseService<ImgClassification> baseService;

//    /**
//     * 分页列表查询
//     *
//     * @param imgClassification
//     * @param pageNo
//     * @param pageSize
//     * @param req
//     * @return
//     */
//    //@AutoLog(value = "影像资料分类-分页列表查询")
//    @ApiOperation(value = "影像资料分类-分页列表查询", notes = "影像资料分类-分页列表查询")
//    @GetMapping(value = "/list")
//    public Result<IPage<ImgClassification>> queryPageList(ImgClassification imgClassification,
//                                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
//                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
//                                                          HttpServletRequest req) {
//        QueryWrapper<ImgClassification> queryWrapper = QueryGenerator.initQueryWrapper(imgClassification, req.getParameterMap());
//        Page<ImgClassification> page = new Page<ImgClassification>(pageNo, pageSize);
//        IPage<ImgClassification> pageList = imgClassificationService.page(page, queryWrapper);
//        return Result.OK(pageList);
//    }

    /**
     * 分页列表查询
     *
     * @param imgClassification
     * @return
     */
    //@AutoLog(value = "影像资料分类-分页列表查询")
    @ApiOperation(value = "影像资料分类-分页列表查询", notes = "影像资料分类-分页列表查询")
    @GetMapping(value = "/list")
    public Result<IPage<ImgClassification>> queryPageList(ImgClassification imgClassification) {
        IPage<ImgClassification> pageList = baseService.selectPageByDTO(imgClassification);
        return Result.OK(pageList);
    }

    /**
     * 列表查询
     *
     * @param imgClassification
     * @return
     */
    @ApiOperation(value = "影像资料分类-列表查询", notes = "影像资料分类-列表查询")
    @GetMapping(value = "/listAll")
    public Result<List<ImgClassification>> listAll(ImgClassification imgClassification) {
        List<ImgClassification> list = baseService.selectlistByDto(imgClassification);
        return Result.OK(list);
    }

    /**
     * 添加
     *
     * @param imgClassification
     * @return
     */
    @AutoLog(value = "影像资料分类-添加")
    @ApiOperation(value = "影像资料分类-添加", notes = "影像资料分类-添加")
    //@RequiresPermissions("image:img_classification:add")
    @PostMapping(value = "/add")
    public Result<String> add(@RequestBody ImgClassification imgClassification) {
//        imgClassificationService.save(imgClassification);
        imgClassificationService.add(imgClassification);
        return Result.OK("添加成功!");
    }

    /**
     * 批量添加
     *
     * @param imgClassifications
     * @return
     */
    @AutoLog(value = "影像资料分类-批量添加")
    @ApiOperation(value = "影像资料分类-批量添加", notes = "影像资料分类-批量添加")
    @PostMapping(value = "/addBatch")
    public Result<String> addBatch(@RequestBody List<ImgClassification> imgClassifications) {
//        imgClassificationService.save(imgClassification);
        imgClassificationService.addBatch(imgClassifications);
        return Result.OK("添加成功!");
    }

    /**
     * 编辑
     *
     * @param imgClassification
     * @return
     */
    @AutoLog(value = "影像资料分类-编辑")
    @ApiOperation(value = "影像资料分类-编辑", notes = "影像资料分类-编辑")
    //@RequiresPermissions("image:img_classification:edit")
    @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
    public Result<String> edit(@RequestBody ImgClassification imgClassification) {
        imgClassificationService.updateById(imgClassification);
        return Result.OK("编辑成功!");
    }

    /**
     * 通过id删除
     *
     * @param id
     * @return
     */
    @AutoLog(value = "影像资料分类-通过id删除")
    @ApiOperation(value = "影像资料分类-通过id删除", notes = "影像资料分类-通过id删除")
    //@RequiresPermissions("image:img_classification:delete")
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
//        imgClassificationService.removeById(id);
        imgClassificationService.delete(id);
        return Result.OK("删除成功!");
    }

    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @AutoLog(value = "影像资料分类-批量删除")
    @ApiOperation(value = "影像资料分类-批量删除", notes = "影像资料分类-批量删除")
    //@RequiresPermissions("image:img_classification:deleteBatch")
    @DeleteMapping(value = "/deleteBatch")
    public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
//        this.imgClassificationService.removeByIds(Arrays.asList(ids.split(",")));
        imgClassificationService.deleteBatch(ids);
        return Result.OK("批量删除成功!");
    }

    /**
     * 通过id查询
     *
     * @param id
     * @return
     */
    //@AutoLog(value = "影像资料分类-通过id查询")
    @ApiOperation(value = "影像资料分类-通过id查询", notes = "影像资料分类-通过id查询")
    @GetMapping(value = "/queryById")
    public Result<ImgClassification> queryById(@RequestParam(name = "id", required = true) String id) {
//        ImgClassification imgClassification = imgClassificationService.getById(id);
        ImgClassification imgClassification = imgClassificationService.queryById(id);
        if (imgClassification == null) {
            return Result.error("未找到对应数据");
        }
        return Result.OK(imgClassification);
    }

    /**
     * 导出excel
     *
     * @param request
     * @param imgClassification
     */
    //@RequiresPermissions("image:img_classification:exportXls")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, ImgClassification imgClassification) {
        return super.exportXls(request, imgClassification, ImgClassification.class, "影像资料分类");
    }

    /**
     * 通过excel导入数据
     *
     * @param request
     * @param response
     * @return
     */
    //@RequiresPermissions("image:img_classification:importExcel")
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, ImgClassification.class);
    }


    /**
     * 获取树结构
     *
     * @param dto
     * @return
     */
    @PostMapping("/getTree")
    @ApiOperation(value = "获取树结构")
    public Result<?> getTree(@ApiParam(value = "查询条件")
                             @RequestBody ImgClassification dto) {
        List<ImgClassification> tree = imgClassificationService.getTree(dto);
        return Result.OK(tree);
    }

    /**
     * 设置innercode码
     */
    @ApiOperation(value = "设置innercode码", notes = "设置innercode码")
    @GetMapping(value = "/initCode")
    public Result<?> initCode() {
        imgClassificationService.initCode();
        return Result.OK("处理完成");
    }

}

5、service层

package org.jeecg.modules.image.service;

import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.image.entity.ImgClassification;

import java.util.List;

/**
 * @Description: 影像资料分类
 * @Author: jeecg-boot
 * @Date: 2024-05-28
 * @Version: V1.0
 */
public interface IImgClassificationService extends IService<ImgClassification> {

    List<ImgClassification> selectTree(ImgClassification dto);

    List<ImgClassification> getTree(ImgClassification dto);

    void initCode();

    void add(ImgClassification imgClassification);

    void delete(String id);

    void addBatch(List<ImgClassification> imgClassifications);

    void deleteBatch(String ids);

    ImgClassification queryById(String id);
}

package org.jeecg.modules.image.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.exception.BusinessException;
import org.jeecg.common.system.base.service.BaseService;
import org.jeecg.common.util.StringUtil;
import org.jeecg.modules.image.entity.ImgClassification;
import org.jeecg.modules.image.entity.ImgLibrary;
import org.jeecg.modules.image.mapper.ImgClassificationMapper;
import org.jeecg.modules.image.service.IImgClassificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @Description: 影像资料分类
 * @Author: jeecg-boot
 * @Date: 2024-05-28
 * @Version: V1.0
 */
@Service
public class ImgClassificationServiceImpl extends ServiceImpl<ImgClassificationMapper, ImgClassification> implements IImgClassificationService {

    @Resource
    ImgClassificationMapper mapper;
    @Autowired
    private BaseService<ImgClassification> baseService;
    @Autowired
    private BaseService<ImgLibrary> imgLibraryService;


    @Override
    public List<ImgClassification> selectTree(ImgClassification dto) {
        return mapper.selectTree(dto);
    }

    @Override
    public List<ImgClassification> getTree(ImgClassification dto) {
        List<ImgClassification> returndemo = this.selectTree(dto);
        List<ImgClassification> tree = Collections.synchronizedList(new ArrayList<>());
        String id = "1";
        if (StringUtil.isNotEmpty(dto.getId())) {
            id = dto.getId();
        }

        if (StringUtil.isNotEmpty(returndemo)) {
            String finalId = id;
            returndemo.parallelStream().forEach(x -> {
                if (finalId.equals(x.getId())) {
                    //现在做全局递归,之后更改
                    tree.add(findChildren(x, returndemo));
                }
            });
        }

        //根据日期进行升序排序
        for (ImgClassification e : tree) {
            e.setChildren(sort(e.getChildren()));
        }
        List<ImgClassification> treeAsce = sort(tree);
        return treeAsce;
    }


    private List<ImgClassification> sort(List<ImgClassification> source) {
        List<ImgClassification> treeAsce
                = source.stream().sorted(Comparator.comparing(ImgClassification::getSort))
                .collect(Collectors.toList());

        for (ImgClassification e : source) {
            if (e.getChildren().size() > 0) {
                e.setChildren(sort(e.getChildren()));
            }
        }
        return treeAsce;
    }

    /**
     * @param node  .
     * @param lists .
     * @return .
     */
    private static ImgClassification findChildren(ImgClassification node, List<ImgClassification> lists) {
        lists.parallelStream().forEach(y -> {
            if (node.getId().equals(y.getPid())) {
                if (node.getChildren() == null) {
                    node.setChildren(new ArrayList<ImgClassification>());
                }
                node.getChildren().add(findChildren(y, lists));
            }
        });
        return node;
    }

    @Override
    public void initCode() {
        ImgClassification dto = new ImgClassification();
        List<ImgClassification> treeList = getTree(dto);

        dealInnerCode(treeList, true);
    }

    @Override
    public void addBatch(List<ImgClassification> imgClassifications) {
        for (ImgClassification imgClassification : imgClassifications) {
            this.add(imgClassification);
        }
    }

    @Override
    public void add(ImgClassification imgClassification) {

        //更新父节点的hasChildren
        ImgClassification parent = this.queryById(imgClassification.getPid());
        if (StringUtil.isEmpty(parent)) {
            throw new BusinessException("未找到父节点");
        }
        parent.setHasChildren(true);
        this.updateById(parent);

        //更新本节点的层级、编码、排序
        imgClassification = this.reDoEntity(parent, imgClassification);
        //新增
        this.save(imgClassification);
    }

    /**
     * 获取分类的 层级layer、 编码code、 排序sort
     */
    private ImgClassification reDoEntity(ImgClassification parent, ImgClassification imgClassification) {
        String code = null;

        //当前父节点有几个子节点
        List<ImgClassification> childrenList = parent.getChildren();
        int lastNumber = 1;
        if (StringUtil.isEmpty(childrenList)) {
            // 列表为空或null,处理这种情况
            code = parent.getCode() + "-1";
        } else {
            //查询父节点下最新的一条记录
            ImgClassification latestItem = childrenList.get(0); // 假设第一个元素是最新的
            String latestCode = latestItem.getCode();
            // 按 "-" 分割字符串
            String[] parts = latestCode.split("-");

            // 检查是否至少有一个部分
            if (parts.length == 0) {
                System.out.println("没有分隔符,找不到数值");
            }
            // 找到最后一个编号,并转换为整数
            lastNumber = Integer.parseInt(parts[parts.length - 1]);

            // 将最后一个编号加1
            lastNumber++;

            // 将加1后的整数转换回字符串
            String lastNumberStr = String.valueOf(lastNumber);

            // 替换原来的最后一个编号,并用 "-" 重新连接所有编号
            // 如果只有一个部分,则不需要"-"
            StringBuilder newS = new StringBuilder();
            for (int i = 0; i < parts.length - 1; i++) {
                newS.append(parts[i]).append("-");
            }
            newS.append(lastNumberStr);
            code = newS.toString();
        }
        imgClassification.setCode(code);
        imgClassification.setLayer(parent.getLayer() + 1);
        if (StringUtil.isEmpty(imgClassification.getSort())) {
            imgClassification.setSort(lastNumber + 1);
        }
        //更新本节点的hasChildren
        imgClassification.setHasChildren(false);
        return imgClassification;
    }

    @Override
    public void deleteBatch(String ids) {
        List<String> idList = Arrays.asList(ids.split(","));
        if (StringUtil.isNotEmpty(idList)) {
            for (String id : idList) {
                this.delete(id);
            }
        }
    }

    @Override
    public ImgClassification queryById(String id) {
        ImgClassification imgClassification = this.getById(id);
        //获取子节点
        ImgClassification dto = new ImgClassification();
        dto.setPid(id);
        dto.setOrderby("create_time desc");
        List<ImgClassification> childrenList = baseService.selectlistByDto(dto);
        imgClassification.setChildren(childrenList);
        return imgClassification;
    }


    /**
     * 删除分类
     * 1.根节点不允许删除
     * 2.节点下挂了资料,不能删除
     * 3.更新父节点的hasChildren
     * 4.删除本节点
     *
     * @param id
     */
    @Override
    public void delete(String id) {

        ImgClassification imgClassification = this.getById(id);

        //根节点不允许删除
        if (id.equals("1")) {
            throw new BusinessException("根节点不允许删除。");
        }

        //判断分类下是否有资料,如果有,则不能删除
        if (hasData(imgClassification)) {
            throw new BusinessException(imgClassification.getName() + "分类下存在资料,不能删除。" + imgClassification.getCode() + ":" + imgClassification.getId());
        }

        //更新父节点的hasChildren
        if (imgClassification != null) {     //如果删除的是顶级节点,则父节点的hasChildren置为false
            ImgClassification parent = this.queryById(imgClassification.getPid());
            if (parent != null) {
                List<ImgClassification> childrenList = parent.getChildren();
                if (StringUtil.isNotEmpty(childrenList) && childrenList.size() == 1) {
                    parent.setHasChildren(false);
                    this.updateById(parent);
                }
            }
        }

        //删除本节点
        this.removeById(id);

    }

    private Boolean hasData(ImgClassification imgClassification) {
        ImgLibrary dto = new ImgLibrary();
        dto.setClsCode(imgClassification.getCode());
        List<ImgLibrary> imgLibraryList = imgLibraryService.selectlistByDto(dto);
        if (imgLibraryList != null && !imgLibraryList.isEmpty()) {
            return true;
        }
        return false;
    }

    public void dealInnerCode(List<ImgClassification> treeList, Boolean isTop) {

        for (int i = 0; i < treeList.size(); i++) {
            String thisId = treeList.get(i).getId();
            String pId = treeList.get(i).getPid();
            ImgClassification imgClassification = this.getById(thisId);
            if (isTop) {
                imgClassification.setCode("0");
            } else {
                imgClassification.setCode(getCodeById(pId) + (i + 1));
            }
            //更新
            this.updateById(imgClassification);
            List<ImgClassification> childrenList = treeList.get(i).getChildren();
            if (StringUtil.isNotEmpty(childrenList)) {
                dealInnerCode(childrenList, false);
            }
        }

    }

    public String getCodeById(String id) {
        ImgClassification imgClassification = this.getById(id);
        return imgClassification.getCode();
    }
}

6、dao层

package org.jeecg.modules.image.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.image.entity.ImgClassification;

import java.util.List;

/**
 * @Description: 影像资料分类
 * @Author: jeecg-boot
 * @Date: 2024-05-28
 * @Version: V1.0
 */
public interface ImgClassificationMapper extends BaseMapper<ImgClassification> {
    List<ImgClassification> selectTree(@Param("dto") ImgClassification dto);
}

7、xml层

<?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="org.jeecg.modules.image.mapper.ImgClassificationMapper">

    <!-- 树结构-查父节点的名字 -->
    <select id="selectTree"
            parameterType="Object"
            resultType="org.jeecg.modules.image.entity.ImgClassification">
        SELECT t1.name AS parent_name,
        t.*
        FROM IMG_CLASSIFICATION t
        LEFT JOIN IMG_CLASSIFICATION t1 ON t.pid = t1.id
        WHERE 1 = 1
        <if test="dto.name !=null and dto.name != ''">
            AND t.name like concat(concat('%',#{dto.name}),'%')
        </if>
        ORDER BY
        t1.CREATE_TIME,t.CREATE_TIME
    </select>

</mapper>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1793547.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

SQLAlchemy 模型中数据的错误表示

1. 问题背景 在使用 SQLAlchemy 0.6.0 版本&#xff08;也曾尝试使用 0.6.4 版本&#xff09;的 Pylons 应用程序中遇到了一个 SQLAlchemy ORM 问题。该问题出现在使用 psycopg2 作为数据库驱动程序、连接至 Postgresql 8.2 数据库的环境中。定义了一个 User 模型对象&#xf…

Java17 --- Mabbitmq之安装测试

目录 一、拉取运行镜像 1.1、拉取镜像环境 1.2、运行镜像 二、工作模式 2.1、消息的发送者 2.2、消息的接收者 2.3、生产队列模式 2.3.1、消息的发送者 2.3.2、消息的接收者 2.4、发布订阅模式 2.4.1、消息的发送者 2.4.2、消息的接收者 2.5、路由模式 2.5.…

记一次 .NET某工控视觉自动化系统 卡死分析

一&#xff1a;背景 1. 讲故事 今天分享的dump是训练营里一位学员的&#xff0c;从一个啥也不会到现在分析的有模有样&#xff0c;真的是看他成长起来的&#xff0c;调试技术学会了就是真真实实自己的&#xff0c;话不多说&#xff0c;上windbg说话。 二&#xff1a;WinDbg …

如何从官网下载 mysql 二进制安装包

一.下载二进行包 1. 官网网址: https://www.mysql.com/ 如图所示进入官网 2. 点击 DOWNLOADS ,进入如下图 在该页面找到 MySQL Community (GPL) Downloads 点进去 如上图页面&#xff0c;找到 MySQL Community Server 在点进去 下载 linux 通用版 点击最下面 Compressed …

你真的了解SQL语句的执行过程?

SQL查询语句的执行过程 连接器 连接器会对用户身份和访问权限进行校验。会先连接到数据库上&#xff0c;通过连接器跟客户端建立连接、获取权限、维持和管理连接。在建立连接之后&#xff0c;不会立即执行语句&#xff0c;而是将SQL语句同时传给分析器和缓存。 缓存 如果能在…

系统架构设计师【第14章】: 云原生架构设计理论与实践 (核心总结)

文章目录 14.1 云原生架构产生背景14.2 云原生架构内涵14.2.1 云原生架构定义14.2.2 云原生架构原则14.2.3 主要架构模式14.2.4 典型的云原生架构反模式 14.3 云原生架构相关技术14.3.1 容器技术14.3.2 云原生微服务14.3.3 无服务器技术14.3.4 服务网格 14.4 云原生…

linux动态调试 dev_dbg

动态调试使用方法 打开内核动态调试开关&#xff0c;make menuconfig选中CONFIG_DYNAMIC_DEBUG以及CONFIG_DEBUG_FS Linux启动后&#xff0c;使用命令行挂载上dbgfs 1. mkdir /mnt/dbg 2. mount -t debugfs none /mnt/dbg 1.控制某个文件所有dev_dbg()&#xff0c; echo -n &q…

Django里choices字段使用中文使用

如果想要将下面的表格里的内容数字换成对应的内容&#xff1a; 需要更改成这样&#xff1a; 下面是步骤&#xff1a; 在 python 里的 models.py 文件里&#xff0c;创建数据表的时候&#xff0c;用到了 choices class Example(models.Model):name models.CharField(verbose…

Ceph集群存储案例

Ceph是一种可靠的、可扩展的、统一的、分布式的存储系统。Ceph高度可靠、易于管理且免费。Ceph提供了非凡的可扩展性——数以千计的客户端访问PB到EB的数据。Ceph存储集群相互通信以动态复制和重新分配数据。目前众多云厂商都在使用Ceph&#xff0c;应用广泛。如&#xff1a;华…

SemanticKernel:添加插件

SemanticKernel介绍 Semantic Kernel是一个SDK&#xff0c;它将OpenAI、Azure OpenAI和Hugging Face等大型语言模型&#xff08;LLMs&#xff09;与C#、Python和Java等传统编程语言集成在一起。Semantic Kernel通过允许您定义插件来实现这一点&#xff0c;这些插件可以通过几行…

六、【源码】SQL执行器的定义和实现

源码地址&#xff1a;https://github.com/mybatis/mybatis-3/ 仓库地址&#xff1a;https://gitcode.net/qq_42665745/mybatis/-/tree/06-sql-executor SQL执行器的定义和实现 之前的Sql执行都是耦合在SqlSession里的&#xff0c;现在要对这部分进行解耦和重构&#xff0c;引…

CentOS 环境下 PostgreSQL 在线安装和源码安装详解

1、内容概述 昨天给大家简单的介绍了一下 PostgreSQL,并且在Windows系统上通过图形化界面的方式搭建好了环境&#xff0c;今天我们就来学习一下如何在Linux 系统上搭建 PostgreSQL环境&#xff0c;我会给大家介绍在线安装、离线源码安装以及Docker 安装三种方式。 2、在线安装…

Windows文件管理器导航窗口怎么删除第三方生成的无效导航【笔记】

Windows文件管理器导航窗口怎么删除第三方生成的无效导航【笔记】 导航窗口对应项目没有右击删除选项。 提示&#xff1a; 位置不可用 C:\Users\superman…不可用&#xff0c;如果该位置位于这台电脑上&#xff0c;请确保设备或驱动器连接&#xff0c;或者光盘已插入&#xf…

Elastic 8.14:用于简化分析的 Elasticsearch 查询语言 (ES|QL) 正式发布

作者&#xff1a;来自 Elastic Brian Bergholm 今天&#xff0c;我们很高兴地宣布 Elastic 8.14 正式发布。 什么是新的&#xff1f; 8.14 版本最重要的标题是 ES|QL 的正式发布(GA)&#xff0c;它是从头开始设计和专门构建的&#xff0c;可大大简化数据调查。在新的查询引擎的…

基于SSM+Jsp的高校二手交易平台

开发语言&#xff1a;Java框架&#xff1a;ssm技术&#xff1a;JSPJDK版本&#xff1a;JDK1.8服务器&#xff1a;tomcat7数据库&#xff1a;mysql 5.7&#xff08;一定要5.7版本&#xff09;数据库工具&#xff1a;Navicat11开发软件&#xff1a;eclipse/myeclipse/ideaMaven包…

css 理解了原理,绘制三角形就简单了

1.border-位置 注意&#xff1a;border-bottom/up/right/left 主要是以三角形的结构搭建而成&#xff0c;而border也是如此。而且从边框的外围开始计算像素尺寸。在理解了这一点之后&#xff0c;绘制三角形就简单多了。 1.transparent 注意&#xff1a;该属性主要是颜色透明…

LeetCode-2938. 区分黑球与白球【贪心 双指针 字符串】

LeetCode-2938. 区分黑球与白球【贪心 双指针 字符串】 题目描述&#xff1a;解题思路一&#xff1a;贪心解题思路二&#xff1a;一次遍历统计1的个数&#xff0c;找0后累加左边的1的个数解题思路三&#xff1a; 题目描述&#xff1a; 桌子上有 n 个球&#xff0c;每个球的颜色…

深圳比创达EMC|EMC电磁兼容性行业:技术前沿与市场挑战

在当今高度信息化的社会&#xff0c;电磁兼容性&#xff08;EMC&#xff09;技术已成为各行各业不可或缺的一部分。随着电子设备的日益增多和复杂化&#xff0c;电磁环境日益复杂&#xff0c;电磁兼容性行业面临着前所未有的挑战和机遇。 一、EMC电磁兼容性行业的技术基础 电…

0基础学习区块链技术——分叉

区块链是一种分布式存储技术。一谈到分布式服务&#xff0c;就会提及CAP原则。 CAP原则是以下三个单词的首字母&#xff1a; Consistency&#xff08;一致性&#xff09;&#xff1a;系统在执行某项操作后&#xff0c;仍然处于一致的状态。在分布式系统中&#xff0c;更新操作…

10分钟就会用的3D编辑器,帮你轻松实现Web3D交互自由!

近两年&#xff0c;AIGC技术可谓是在各行各业大放异彩&#xff0c;从AI绘画到AI写作&#xff0c;如今AI建模技术也悄然而至&#xff0c;只要输入文本就能直接AI生成3D模型。 △例&#xff1a;当输入“一个坐在睡莲上的蓝色箭毒蛙”这样的提示词时&#xff0c;对应的3D模型就会生…