Kennem's Blog
  • 🏠主页
  • 🔍搜索
  • 📚文章
  • ⏱时间轴
  • 🔖标签
  • 🗂️分类
  • 🙋🏻‍♂️关于
主页 » 📚文章

💻技术

苍穹外卖后端开发(Day5)

苍穹外卖后端开发(Day5) Redis Redis 是一个基于内存的key-value结构数据库的 基于内存存储,读写性能高 适合存储热点数据(热点商品,资讯,新闻) 企业应用广泛 Redis安装和使用 安装Redis ...

2024-10-15 · 3 分钟 · 1409 字 · updated: 2024-10-15 · ShowGuan

苍穹外卖后端开发(Day3)

苍穹外卖后端开发(Day3) 菜品管理 公共字段自动填充 对于创建时间、创建人id,修改时间,修改人id等字段 重复性代码进行统一编写 自定义注解AutoFill,用于标识需要进行公共字段自动填充的方法 package com.sky.annotation; /** * 自定义注解,用于标识某个方法需要进行功能字段自动填充处理。 * 这个注解可以应用于方法上,用于指示在特定的数据库操作时 * 需要自动填充某些功能字段。 */ @Target(ElementType.METHOD) // 指定注解可以用于方法 @Retention(RetentionPolicy.RUNTIME) // 指定注解在运行时可用 public @interface AutoFill { /** * 数据库操作类型:用于指示自动填充的操作类型。 * 可选值包括 UPDATE 和 INSERT。 * * @return 操作类型 */ OperationType value(); } 自定义切面类AutoFillAspect, 统一拦截加入了AutoFill注解的方法,通过反射为公共字段赋值。 package com.sky.aspect; /** * 自定义切面, 实现公共字段自动填充 */ @Aspect @Component @Slf4j public class AutoFillAspect { /** * 定义切入点,匹配com.sky.mapper包下的所有方法,并且方法上需有@AutoFill注解 */ @Pointcut("execution(* com.sky.mapper.*.*(..)) && @annotation(com.sky.annotation.AutoFill)") public void autoFillPointCut() { } /** * 前置通知,在目标方法执行前进行公共字段赋值 * * @param joinPoint 连接点,表示被拦截的方法调用 */ @Before("autoFillPointCut()") public void autoFill(JoinPoint joinPoint) { log.info("开始进行公共字段自动填充..."); // 获取当前被拦截方法的签名(方法信息) MethodSignature signature = (MethodSignature) joinPoint.getSignature(); // 从方法签名中获取@AutoFill注解 AutoFill autoFill = signature.getMethod().getAnnotation(AutoFill.class); // 获取操作类型(INSERT或UPDATE) OperationType operationType = autoFill.value(); // 获取目标方法的参数(假设第一个参数是实体对象) Object[] args = joinPoint.getArgs(); if (args == null || args.length == 0) { return; // 如果没有参数则直接返回 } // 获取实体对象(目标方法的第一个参数) Object entity = args[0]; // 获取当前时间和当前操作用户ID LocalDateTime now = LocalDateTime.now(); Long currentId = BaseContext.getCurrentId(); // 根据操作类型判断是INSERT还是UPDATE操作 if (operationType == OperationType.INSERT) { try { // 通过反射调用实体对象的set方法,赋值创建和更新时间、创建和更新用户 Method setCreateTime = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_CREATE_TIME, LocalDateTime.class); Method setCreateUser = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_CREATE_USER, Long.class); Method setUpdateTime = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_UPDATE_TIME, LocalDateTime.class); Method setUpdateUser = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_UPDATE_USER, Long.class); // 调用方法进行赋值 setCreateTime.invoke(entity, now); setCreateUser.invoke(entity, currentId); setUpdateTime.invoke(entity, now); setUpdateUser.invoke(entity, currentId); } catch (Exception e) { e.printStackTrace(); // 捕获异常并打印 } } else if (operationType == OperationType.UPDATE) { try { // 通过反射调用实体对象的set方法,赋值更新时间和更新用户 Method setUpdateTime = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_UPDATE_TIME, LocalDateTime.class); Method setUpdateUser = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_UPDATE_USER, Long.class); // 调用方法进行赋值 setUpdateTime.invoke(entity, now); setUpdateUser.invoke(entity, currentId); } catch (Exception e) { e.printStackTrace(); // 捕获异常并打印 } } } } 在Mapper的方法上加入AutoFill注解 ...

2024-10-14 · 5 分钟 · 2026 字 · updated: 2024-10-14 · ShowGuan

苍穹外卖后端开发(Day2)

苍穹外卖后端开发(Day2) 新增员工 管理端发出的请求, 统一使用/admin作为前缀 用户端发出的请求,统一使用/user作为前缀 代码开发 根据新增员工接口设计对应的DTO 注意 : 当前端提交的数据和实体类中对应的属性差别比较大时,建议使用DTO来封装数据 ...

2024-10-13 · 3 分钟 · 1241 字 · updated: 2024-10-13 · ShowGuan

Docker

Docker 快速构建、运行、管理应用的工具 Docker打印所有容器(包括关闭的) docker ps -a 正在运行的 docker ps 删除容器 docker rm <container_id> 启动已有的容器 docker start <容器ID或名称> 启动容器并进入其交互式终端 ...

2024-10-12 · 2 分钟 · 886 字 · updated: 2024-10-12 · ShowGuan

苍穹外卖后端开发(Day1)

苍穹外卖后端开发(Day1) 软件开发流程 需求分析 : 需求规格说明说、产品原型 设计 : UI设计、 数据库设计、接口设计 编码 : 项目代码、单元测试 测试 : 测试用例、测试报告 上线运维 : 软件环境安装、配置 ...

2024-10-12 · 4 分钟 · 1528 字 · updated: 2024-10-12 · ShowGuan

Prompt

Prompt 要求:字数尽可能多,内容需要全面,可以不按照我的标题来写,可以适当添加一些内容,但是内容一定一定要多,要专业 请根据以上内容以及你的数据库内容,撰写 : 数据处理与分析 海浪波谱仪采集的数据需要经过复杂的处理与分析,才能生成有用的波谱图。数据处理过程包括去噪、滤波、频谱分析等步骤。常用的频谱分析方法包括快速傅里叶变换(FFT)和小波变换等。通过对海浪频谱的分析,可以提取出海浪的主导频率、波高分布、能量谱等重要信息。 详细 我现在需要写实验报告,请缩写上部分内容,但是不要损失其表达的意思 文章生成 “我想写一篇科普文章,标题是:‘[在此处插入你的标题]’。你能帮我分析一下这个标题吗?它是否有吸引力,有没有可以改进的地方来增强其吸引力?” 文章生成: “在优化标题后,帮我生成一篇文章。文章的目标是向读者科普关于[插入主题]的知识。请确保内容易于普通读者理解,同时保持科学的准确性和趣味性。文章应包括以下部分:引言、定义、示例、现实应用以及结论。语气要保持信息性,但尽量亲切、易懂。” 朗读内容 先重复下面的内容,然后加一个简短的总结 Leetcode题目总结 下面我给出一个题目,代码实现,和对题目的总结和实现思路, 你需要的是学习我是如何总结的,如果你看懂了则回复我你懂了, 不用回复别的 """ 给你一个 n 个节点的树(也就是一个无环连通无向图),节点编号从 0 到 n - 1 ,且恰好有 n - 1 条边,每个节点有一个值。树的 根节点 为 0 号点。 给你一个整数数组 nums 和一个二维数组 edges 来表示这棵树。nums[i] 表示第 i 个点的值,edges[j] = [uj, vj] 表示节点 uj 和节点 vj 在树中有一条边。 当 gcd(x, y) == 1 ,我们称两个数 x 和 y 是 互质的 ,其中 gcd(x, y) 是 x 和 y 的 最大公约数 。 从节点 i 到 根 最短路径上的点都是节点 i 的祖先节点。一个节点 不是 它自己的祖先节点。 请你返回一个大小为 n 的数组 ans ,其中 ans[i]是离节点 i 最近的祖先节点且满足 nums[i] 和 nums[ans[i]] 是 互质的 ,如果不存在这样的祖先节点,ans[i] 为 -1 。 示例 1: 输入:nums = [2,3,3,2], edges = [[0,1],[1,2],[1,3]] 输出:[-1,0,0,1] 解释:上图中,每个节点的值在括号中表示。 - 节点 0 没有互质祖先。 - 节点 1 只有一个祖先节点 0 。它们的值是互质的(gcd(2,3) == 1)。 - 节点 2 有两个祖先节点,分别是节点 1 和节点 0 。节点 1 的值与它的值不是互质的(gcd(3,3) == 3)但节点 0 的值是互质的(gcd(2,3) == 1),所以节点 0 是最近的符合要求的祖先节点。 - 节点 3 有两个祖先节点,分别是节点 1 和节点 0 。它与节点 1 互质(gcd(3,2) == 1),所以节点 1 是离它最近的符合要求的祖先节点。 示例 2: 输入:nums = [5,6,10,2,3,6,15], edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]] 输出:[-1,0,-1,0,0,0,-1] 提示: nums.length == n 1 <= nums[i] <= 50 1 <= n <= 105 edges.length == n - 1 edges[j].length == 2 0 <= uj, vj < n uj != vj 代码实现: class Solution: def getCoprimes(self, nums: List[int], edges: List[List[int]]) -> List[int]: n = len(nums) g = [[]*n for _ in range(n)] ret = [-1]*n store = [[] for _ in range(51)] mem = [(-1, -1)]*(51) for i in range(1, 51): for j in range(1, 51): if gcd(i, j)==1: store[i].append(j) for u, v in edges: g[u].append(v) g[v].append(u) def dfs(u, last, level): ret[u] = max(mem[i] for i in store[nums[u]])[1] tmp = mem[nums[u]] mem[nums[u]] = (level, u) for son in g[u]: if son==last: continue dfs(son, u, level+1) mem[nums[u]] = tmp dfs(0, -1, 0) return ret """ 好的,你现在需要做的是 : 我给你其他题目,并给出已经AC的代码实现,你需要补充:1、题目大意 2、实现思路 如果你已经了解了我的需求,请回复我懂了

2024-09-30 · 3 分钟 · 1296 字 · updated: 2024-09-30 · ShowGuan

MIT6.S081(13)-Coordination (sleep&wakeup)

MIT6.S081(13)-Coordination (sleep&wakeup) plan Re-emphasize a few points about xv6 thread switching sequence coordination sleep & wakeup lost wakeup problem termination Why hold p->lock across swtch()? this is an important point and affects many situations in xv6 [diagram: P1, STACK1, swtch, STACK_SCHED] yield: acquire(&p->lock); p->state = RUNNABLE; swtch(); scheduler: swtch(); release(&p->lock); the main point of holding p->lock across swtch(): prevent another core’s scheduler from seeing p->state == RUNNABLE until after the original core has stopped executing the thread and after the original core has stopped using the thread’s stack ...

2024-09-29 · 12 分钟 · 5655 字 · updated: 2024-10-03 · ShowGuan

LeetCode周赛416(250922)

周赛250922 小号第一次AK, 题比较简单。 3295. 举报垃圾信息 题目大意 给定两个字符串数组 message 和 bannedWords,你需要判断 message 是否属于“垃圾信息”。如果 message 中至少有两个单词出现在 bannedWords 中,则该数组被视为垃圾信息,返回 true;否则返回 false。 ...

2024-09-24 · 4 分钟 · 1553 字 · updated: 2024-09-24 · ShowGuan

MIT6.S081(11)- Thread switching

MIT6.S081(11)- Thread switching Topic: more “under the hood” with xv6 Previously: system calls, interrupts, page tables, locks Today: process/thread switching Why support multiple tasks? Time-sharing: many users and/or many running programs. program structure: prime number sieve. parallel speedup on multi-core hardware. Threads are an abstraction to simplify programming when there are many tasks. thread = an independent serial execution – registers, pc, stack the threading system interleaves the execution of multiple threads ...

2024-09-21 · 7 分钟 · 3091 字 · updated: 2024-09-21 · ShowGuan

MIT6.S081(10)-Locking

MIT6.S081(10)-Locking Why talk about locking? apps want to use multi-core processors for parallel speed-up so kernel must deal with parallel system calls and thus parallel access to kernel data (buffer cache, processes, &c) locks help with correct sharing of data locks can limit parallel speedup What goes wrong if we don’t have locks Case study: delete acquire/release in kalloc.c Boot kernel works! Run usertests all tests pass! except we lose some pages Why do we lose pages? picture of shared-memory multiprocessor race between two cores calling kfree() BUMMER: we need locks for correctness but loose performance (kfree is serialized) ...

2024-09-19 · 3 分钟 · 1303 字 · updated: 2024-09-19 · ShowGuan

MIT6.S081(9)-Interrupts

MIT6.S081(9)-Interrupts 6.S081 2020 Lecture 9: Interrupts Interrupts hardware wants attention now! e.g., pkt arrived, clock interrupt software must set aside current work and respond on RISC-V use same trap mechanism as for syscalls and exceptions new issues/complications: asynchronous interrupts running process interrupt handler may not run in context of process who caused interrupt concurrency devices and process run in parallel programming devices device can be difficult to program Where do device interrupts come from? diagram: Fig 1 of SiFive board in FU540-C000-v1.0.pdf CPUs, CLINT, PLIC, devices Fig 3 has more detail for interrupts Section 8 and 9 of FU540-C000-v1.0.pdf UART (universal asynchrnonous receiver/transmitter) See Section 13 of FU540-C000-v1.0.pdf Although the QEMU version is slightly different Follows http://byterunner.com/16550.html the interrupt tells the kernel the device hardware wants attention the driver (in the kernel) knows how to tell the device to do things often the interrupt handler calls the relevant driver but other arrangements are possible (schedule a thread; poll) [diagram: top-half/bottom-half] ...

2024-09-18 · 3 分钟 · 1303 字 · updated: 2024-09-18 · ShowGuan

MIT6.S081(8)-Page faults

MIT6.S081(8)-Page faults plan: cool things you can do with vm Better performance/efficiency e.g., one zero-filled page e.g., copy-on-write fork New features e.g., memory-mapped files virtual memory: several views primary purpose: isolation each process has its own address space Virtual memory provides a level-of-indirection provides kernel with opportunity to do cool stuff already some examples: shared trampoline page guard page but more possible… Key idea: change page tables on page fault Page fault is a form of a trap (like a system call) Xv6 panics on page fault But you don’t have to panic! Instead: update page table instead of panic restart instruction (see userret() from traps lecture) Combination of page faults and updating page table is powerful! ...

2024-09-17 · 2 分钟 · 958 字 · updated: 2024-09-17 · ShowGuan

LeetCode周赛415(250915)

周赛250915 时隔多日再才重新开启周赛。这场DP居多。 T2-3290. 最高乘法得分 题目大意: 给定两个数组 a 和 b,数组 a 长度为 4,数组 b 长度至少为 4。需要从 b 中选择 4 个递增下标 i0 < i1 < i2 < i3,计算 a[0] * b[i0] + a[1] * b[i1] + a[2] * b[i2] + a[3] * b[i3],并返回最大得分。 ...

2024-09-17 · 2 分钟 · 997 字 · updated: 2024-09-17 · ShowGuan

MIT6.S081(7)-Q&A

MIT6.S081(7)-Q&A Plan: answering your questions Approach: walk through staff solutions start with pgtbl lab because it was the hardest your questions are at bottom of this file Pgtbl lab comments few lines of code, but difficult-to-debug bugs worst case: qemu/xv6 stops running “best” case: kernel panic hard to debug for staff too there are so many possible reasons why you discovered once we hadn’t seen yet likely to be the most challenging lab historically the first VM lab is hard this year too, even though we made a new lab to provide a gentler intro to VM Part 1 of pgtbl lab Explain vm output in terms of fig 3-4 ...

2024-09-12 · 6 分钟 · 2628 字 · updated: 2024-09-12 · ShowGuan

MIT6.S081(6)-System Call Entry/Exit

MIT6.S081(6)-System Call Entry/Exit Today: user -> kernel transition system calls, faults, interrupts enter the kernel in the same way important for isolation and performance lots of careful design and important detail What needs to happen when a program makes a system call, e.g. write()? [CPU | user/kernel diagram] CPU resources are set up for user execution (not kernel) 32 registers, sp, pc, privilege mode, satp, stvec, sepc, … what needs to happen? save 32 user registers and pc switch to supervisor mode switch to kernel page table switch to kernel stack jump to kernel C code high-level goals don’t let user code interfere with user->kernel transition e.g. don’t execute user code in supervisor mode! transparent to user code – resume without disturbing ...

2024-09-10 · 7 分钟 · 3445 字 · updated: 2024-09-10 · ShowGuan
« 上一页  下一页  »
© 2026 Kennem's Blog · Powered by Hugo & PaperMod
👤 Visitors: 👀 Views: