<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>后端 &#8211; chang的个人博客</title>
	<atom:link href="https://www.qiqin-chang.cn/category/back/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.qiqin-chang.cn</link>
	<description></description>
	<lastBuildDate>Mon, 19 Jan 2026 23:45:57 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.qiqin-chang.cn/wp-content/uploads/2025/04/cropped-无背景-圆形-32x32.png</url>
	<title>后端 &#8211; chang的个人博客</title>
	<link>https://www.qiqin-chang.cn</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>功能演示</title>
		<link>https://www.qiqin-chang.cn/demonstration/</link>
					<comments>https://www.qiqin-chang.cn/demonstration/#respond</comments>
		
		<dc:creator><![CDATA[乐章]]></dc:creator>
		<pubDate>Mon, 19 Jan 2026 22:45:10 +0000</pubDate>
				<category><![CDATA[组件]]></category>
		<guid isPermaLink="false">https://www.qiqin-chang.cn/?p=622</guid>

					<description><![CDATA[SpringBoot3+Vue3： 登录模块： ### 登录功能： 注册功能： 记住密码： 找回密码： 确认账 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h1 class="wp-block-heading">SpringBoot3+Vue3：</h1>



<h2 class="wp-block-heading">登录模块：</h2>



<p><strong><em>### </em></strong><strong>登录功能：</strong></p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/4a30efb98a473b72c99eff3c0fcc66df-1024x576.png" alt="" class="wp-image-623" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/4a30efb98a473b72c99eff3c0fcc66df-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/4a30efb98a473b72c99eff3c0fcc66df-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/4a30efb98a473b72c99eff3c0fcc66df-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/4a30efb98a473b72c99eff3c0fcc66df-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/4a30efb98a473b72c99eff3c0fcc66df.png 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">注册功能：</h3>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/b1b6171bb5fbaa7f9c235c590277b089-1024x576.png" alt="" class="wp-image-624" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/b1b6171bb5fbaa7f9c235c590277b089-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/b1b6171bb5fbaa7f9c235c590277b089-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/b1b6171bb5fbaa7f9c235c590277b089-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/b1b6171bb5fbaa7f9c235c590277b089-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/b1b6171bb5fbaa7f9c235c590277b089.png 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">记住密码：</h3>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193824856-1024x576.png" alt="" class="wp-image-625" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193824856-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193824856-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193824856-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193824856-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193824856.png 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">找回密码：</h3>



<h4 class="wp-block-heading">确认账户：</h4>



<p>说明：第一次图片验证码用于人机验证</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193941851-1024x576.png" alt="" class="wp-image-626" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193941851-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193941851-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193941851-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193941851-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193941851.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h4 class="wp-block-heading">安全认证：</h4>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193955989-1024x576.png" alt="" class="wp-image-628" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193955989-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193955989-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193955989-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193955989-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193955989.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="905" height="234" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193948499.png" alt="" class="wp-image-627" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193948499.png 905w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193948499-300x78.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111193948499-768x199.png 768w" sizes="auto, (max-width: 905px) 100vw, 905px" /></figure>



<h4 class="wp-block-heading">重置密码：</h4>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194002945-1024x576.png" alt="" class="wp-image-630" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194002945-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194002945-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194002945-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194002945-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194002945.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h4 class="wp-block-heading">成功找回：</h4>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194009663-1024x576.png" alt="" class="wp-image-629" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194009663-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194009663-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194009663-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194009663-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194009663.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">个人中心：</h2>



<h3 class="wp-block-heading">个人信息：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201020115-1024x576.png" alt="" class="wp-image-647" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201020115-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201020115-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201020115-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201020115-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201020115.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">修改密码：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201055639-1024x576.png" alt="" class="wp-image-648" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201055639-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201055639-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201055639-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201055639-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201055639.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">信息模块：</h2>



<h3 class="wp-block-heading">数据统计：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195724560-1024x576.png" alt="" class="wp-image-649" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195724560-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195724560-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195724560-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195724560-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195724560.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">系统公告：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195542051-1024x576.png" alt="" class="wp-image-650" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195542051-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195542051-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195542051-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195542051-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195542051.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195503616-1-1024x576.png" alt="" class="wp-image-652" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195503616-1-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195503616-1-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195503616-1-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195503616-1-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195503616-1.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">系统日志：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195630042-1024x576.png" alt="" class="wp-image-653" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195630042-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195630042-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195630042-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195630042-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195630042.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">文章模块：</h2>



<h3 class="wp-block-heading">文章分类：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194418811-1024x576.png" alt="" class="wp-image-656" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194418811-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194418811-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194418811-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194418811-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194418811.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">文章信息：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194500169-1024x576.png" alt="" class="wp-image-657" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194500169-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194500169-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194500169-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194500169-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194500169.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">查看文章：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194549777-1024x576.png" alt="" class="wp-image-658" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194549777-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194549777-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194549777-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194549777-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194549777.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">编辑文章：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194612247-1024x576.png" alt="" class="wp-image-659" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194612247-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194612247-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194612247-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194612247-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194612247.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">文章前台：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194628198-1024x576.png" alt="" class="wp-image-631" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194628198-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194628198-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194628198-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194628198-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194628198.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194654277-1024x576.png" alt="" class="wp-image-632" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194654277-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194654277-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194654277-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194654277-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194654277.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">阅读文章：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194703342-1024x576.png" alt="" class="wp-image-633" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194703342-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194703342-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194703342-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194703342-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194703342.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">文章目录：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194710974-1024x576.png" alt="" class="wp-image-634" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194710974-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194710974-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194710974-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194710974-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111194710974.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">音乐模块：</h2>



<h3 class="wp-block-heading">音乐管理：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195933398-1024x576.png" alt="" class="wp-image-645" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195933398-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195933398-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195933398-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195933398-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111195933398.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085430266-1024x576.png" alt="" class="wp-image-646" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085430266-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085430266-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085430266-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085430266-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085430266.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">前台界面：</h3>



<p>说明：基础播放按键+旋转唱片+歌词跳动</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111200143166-1024x576.png" alt="" class="wp-image-635" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111200143166-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111200143166-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111200143166-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111200143166-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111200143166.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">播放列表：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111200216294-1024x576.png" alt="" class="wp-image-636" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111200216294-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111200216294-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111200216294-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111200216294-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111200216294.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">图片模块：</h2>



<h3 class="wp-block-heading">展示页面：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260120055523456-1024x576.png" alt="" class="wp-image-637" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260120055523456-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260120055523456-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260120055523456-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260120055523456-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260120055523456.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">轮播图：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260120055611196-1024x576.png" alt="" class="wp-image-638" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260120055611196-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260120055611196-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260120055611196-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260120055611196-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260120055611196.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">用户模块：</h2>



<h3 class="wp-block-heading">用户管理：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201335699-1024x576.png" alt="" class="wp-image-644" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201335699-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201335699-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201335699-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201335699-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201335699.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">发送邮件：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201411354-1024x576.png" alt="" class="wp-image-643" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201411354-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201411354-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201411354-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201411354-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201411354.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">导入导出：</h3>



<p>说明：导入 点击导入选择文件就可以导入信息 导出 点击导出就能生成Excel文件</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085903310-1024x576.png" alt="" class="wp-image-639" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085903310-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085903310-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085903310-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085903310-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085903310.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="556" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085951997-1024x556.png" alt="" class="wp-image-640" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085951997-1024x556.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085951997-300x163.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085951997-768x417.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085951997-1536x834.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117085951997.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h1 class="wp-block-heading">+SpringSecurity：</h1>



<p>说明：本项目为个人SpringSecurity脚手架-权限管理系统</p>



<p>记住密码：本次项目中使用了cookie代替了session存储密码，并使用RSA非对称加密算法做了存储加密</p>



<p>账号登录：会使用pinia依次保存token，动态路由（由权限管理12级目录分配，为菜单管理的目录，菜单），动态权限（由权限管理3级目录分配，为菜单管理的按钮的权限标识），和个人信息；</p>



<p>安全退出：会清除登录时存储的四种信息，并清除Redis中的会话链token</p>



<p>会话个数控制：设置单一账号登录个数，登录设备数量超过预设数量，最早的设备会退出登录，通过Redis会话链实现</p>



<p>会话频率控制：使用Redis实现，目前设置同一用户每0.3秒才可请求一次，否则显示请求频率过快，不过可以使用Sentinel实现不再讨论</p>



<p>标签：通过路由守卫监听浏览器路由变化添加标签，首页被锁定添加（pinia实现）不能删除（路由守卫过滤）</p>



<p>数据库设计：数据库使用RBAC设计，用户-角色-权限分离</p>



<p>基础配置：</p>



<p>异常处理：设置全局异常处理器和自定义异常处理器，权限不足异常-由于自定义异常无法监听到Security中过滤器，所以要单独设置</p>



<p>JWT过滤器：白名单放行，检测token存在，token过期，token无效</p>



<p>JWT工具包：token生成 信息-用户名，id；加密-签名；过期判断-签发时间，过期时间；唯一性-uuid（保证每次签发的token都不同）</p>



<p>token解析 token存在判断（此时为静默处理） 验签 判断过期</p>



<p>跨域配置：CorsConfig自定义跨域配置</p>



<p>Redis序列化器：RedisConfig</p>



<p>WebConfig：图片存储路径映射</p>



<p>缓存管理：SpringCache</p>



<p>连接池：druid</p>



<p>security配置：</p>



<p>WebSecurityConfig额外：</p>



<p>实现跨域处理（这个是Security的跨域配置） 开启授权保护 关闭csrf攻击防御 限流过滤器（由token代替）JWT过滤器 登录配置</p>



<p>以下均通过WebSecurityConfig加入Security过滤链</p>



<p>密码加密：使用BCryptPasswordEncoder</p>



<p>用户信息管理：判断密码正确性，判断是否为封禁用户，封装用户权限</p>



<p>登录成功处理器：生成并返回token，进行用户Redis中token链的判断</p>



<p>登录失败处理器：返回失败信息</p>



<p>注销处理器：清除Redis中的token</p>



<p>以下已经由token代替：</p>



<p>拒绝访问处理器：由于权限不足产生，被全局异常处理器代替</p>



<p>认证异常处理器：未检测出认证信息，由于使用token代替认证信息，但token为无状态信息，此阶段无法被识别，故舍弃</p>



<p>会话处理器：可以控制会话个数和会话频率但token为无状态所以不会产生会话</p>



<p>配置：</p>



<p>环境：dev开发环境配置；preprod预生产环境配置</p>



<p>dockerfile：配置了dockerfile，并配置了一键部署</p>



<h2 class="wp-block-heading">后台设计：</h2>



<p>说明：动态路由+动态菜单+动态标签页（固定首页）+面包屑导航+导航收缩按键+头像下拉栏+安全退出</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202102885-1024x576.png" alt="" class="wp-image-655" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202102885-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202102885-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202102885-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202102885-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202102885.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201859397-1024x576.png" alt="" class="wp-image-654" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201859397-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201859397-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201859397-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201859397-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111201859397.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">权限模块：</h2>



<h3 class="wp-block-heading">用户管理：</h3>



<h4 class="wp-block-heading">管理界面：</h4>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202452858-1024x576.png" alt="" class="wp-image-664" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202452858-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202452858-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202452858-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202452858-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202452858.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h4 class="wp-block-heading">分配角色：</h4>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202718703-1024x576.png" alt="" class="wp-image-665" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202718703-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202718703-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202718703-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202718703-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202718703.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">权限管理：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202517576-1024x576.png" alt="" class="wp-image-663" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202517576-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202517576-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202517576-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202517576-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202517576.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111203359290-1024x576.png" alt="" class="wp-image-662" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111203359290-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111203359290-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111203359290-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111203359290-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111203359290.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">菜单管理：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202533694-1024x576.png" alt="" class="wp-image-660" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202533694-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202533694-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202533694-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202533694-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111202533694.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111203503780-1024x576.png" alt="" class="wp-image-661" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111203503780-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111203503780-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111203503780-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111203503780-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260111203503780.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">个人中心：</h2>



<h3 class="wp-block-heading">基本资料：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117090936466-1024x576.png" alt="" class="wp-image-641" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117090936466-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117090936466-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117090936466-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117090936466-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117090936466.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">修改密码：</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117091004531-1024x576.png" alt="" class="wp-image-642" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117091004531-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117091004531-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117091004531-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117091004531-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2026/01/image-20260117091004531.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://www.qiqin-chang.cn/demonstration/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>MyBatis-持久层框架</title>
		<link>https://www.qiqin-chang.cn/mybatis-%e6%8c%81%e4%b9%85%e5%b1%82%e6%a1%86%e6%9e%b6%ef%bc%9a/</link>
					<comments>https://www.qiqin-chang.cn/mybatis-%e6%8c%81%e4%b9%85%e5%b1%82%e6%a1%86%e6%9e%b6%ef%bc%9a/#respond</comments>
		
		<dc:creator><![CDATA[乐章]]></dc:creator>
		<pubDate>Tue, 02 Sep 2025 13:47:51 +0000</pubDate>
				<category><![CDATA[ORM]]></category>
		<category><![CDATA[后端]]></category>
		<guid isPermaLink="false">http://www.qiqin-chang.cn/?p=559</guid>

					<description><![CDATA[官方网站：https://mybatis.org/mybatis-3/zh_CN/index.html 依赖： [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">官方网站：<a href="https://mybatis.org/mybatis-3/zh_CN/index.html">https://mybatis.org/mybatis-3/zh_CN/index.html</a></h2>



<h2 class="wp-block-heading">依赖：</h2>



<pre class="wp-block-code"><code>&lt;!-- MyBatis 持久层框架 --&gt;<br>&lt;dependency&gt;<br> &nbsp; &nbsp;&lt;groupId&gt;org.mybatis.spring.boot&lt;/groupId&gt;<br> &nbsp; &nbsp;&lt;artifactId&gt;mybatis-spring-boot-starter&lt;/artifactId&gt;<br> &nbsp; &nbsp;&lt;version&gt;3.0.5&lt;/version&gt;<br>&lt;/dependency&gt;</code></pre>



<h2 class="wp-block-heading">配置：</h2>



<pre class="wp-block-code"><code>## MyBatis配置与xml映射<br>mybatis:<br> &nbsp;## 映射xml<br>  mapper-locations: classpath:mapper/*.xml <br>  configuration:<br> &nbsp; &nbsp;## 日志配置<br> &nbsp;  log-impl: org.apache.ibatis.logging.stdout.StdOutImpl<br> &nbsp; &nbsp;## 映射格式转换<br> &nbsp;  map-underscore-to-camel-case: true</code></pre>



<h2 class="wp-block-heading">自动映射：</h2>



<p>Java：驼峰命名：departmentId</p>



<p>数据库：下划线：department_id</p>



<h2 class="wp-block-heading">mapper包扫描：</h2>



<p>启动类注解：</p>



<pre class="wp-block-code"><code>@MapperScan("com.chang.mapper")</code></pre>



<h2 class="wp-block-heading">XML基础模版：</h2>



<pre class="wp-block-code"><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;<br>&lt;!DOCTYPE mapper<br> &nbsp; &nbsp; &nbsp; &nbsp;PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"<br> &nbsp; &nbsp; &nbsp; &nbsp;"https://mybatis.org/dtd/mybatis-3-mapper.dtd"&gt;<br>&lt;mapper namespace="对应mapper接口引用"&gt;<br> &nbsp; &nbsp;<br>&lt;/mapper&gt;</code></pre>



<h3 class="wp-block-heading">XML格式：</h3>



<pre class="wp-block-code"><code>&lt;select id="selectAll" resultType="com.chang.entity.Employee"&gt; &lt;!--id对应方法名 resultType：结果类型 对应实体类引用--&gt;<br> &nbsp;  select * from employee<br> &nbsp; &nbsp;&lt;where&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;if test="name!=null"&gt;name like concat('%',#{name},'%')&lt;/if&gt;<br> &nbsp; &nbsp;&lt;/where&gt;<br>&lt;/select&gt;<br>​<br>&lt;insert id="insert" parameterType="com.chang.entity.Employee"&gt; &lt;!--parameterType：参数类型--&gt;<br> &nbsp;  insert into `employee` (name,sex,no,age,description,department_id) &lt;!--下划线命名法--&gt;<br> &nbsp;  values (#{name},#{sex},#{no},#{age},#{description},#{departmentId}) &lt;!--驼峰命名--&gt;<br>&lt;/insert&gt;</code></pre>



<h3 class="wp-block-heading">注解查询：</h3>



<pre class="wp-block-code"><code>@Select("select * from employee where id = #{id}")<br>Employee selectById(Integer id);</code></pre>



<h2 class="wp-block-heading">代码模版：</h2>



<h3 class="wp-block-heading">Mapper:</h3>



<pre class="wp-block-code"><code>package com.chang.mapper;<br>​<br>public interface EmployeeMapper {<br>}</code></pre>



<h3 class="wp-block-heading">Service:</h3>



<pre class="wp-block-code"><code>package com.chang.service;<br>​<br>import org.springframework.stereotype.Service;<br>​<br>@Service<br>public class EmployeeService {<br>}</code></pre>



<h2 class="wp-block-heading">分页插件-分页查询：</h2>



<h3 class="wp-block-heading">依赖：</h3>



<pre class="wp-block-code"><code>&lt;!--PageHelper 分页插件--&gt;<br>&lt;dependency&gt;<br> &nbsp; &nbsp;&lt;groupId&gt;com.github.pagehelper&lt;/groupId&gt;<br> &nbsp; &nbsp;&lt;artifactId&gt;pagehelper-spring-boot-starter&lt;/artifactId&gt;<br> &nbsp; &nbsp;&lt;version&gt;1.4.6&lt;/version&gt;<br> &nbsp; &nbsp;&lt;exclusions&gt;<br> &nbsp; &nbsp; &nbsp; &lt;exclusion&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;groupId&gt;org.mybatis&lt;/groupId&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;artifactId&gt;mybatis&lt;/artifactId&gt;<br> &nbsp; &nbsp; &nbsp; &lt;/exclusion&gt;<br> &nbsp; &nbsp;&lt;/exclusions&gt;<br>&lt;/dependency&gt;</code></pre>



<h3 class="wp-block-heading">代码：</h3>



<h4 class="wp-block-heading">controller：</h4>



<pre class="wp-block-code"><code>/**<br> * 分页查询数据<br> * pageNum: 当前页码<br> * pageSize: 每页的个数<br> */<br>@GetMapping("/selectPage")<br>public Result selectPage(@RequestParam(defaultValue = "1") Integer pageNum,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @RequestParam(defaultValue = "10") Integer pageSize){<br> &nbsp; &nbsp;PageInfo&lt;Employee&gt; pageInfo = employeeService.selectPage(pageNum, pageSize);<br> &nbsp; &nbsp;return Result.success(pageInfo);<br>}</code></pre>



<h4 class="wp-block-heading">service：</h4>



<pre class="wp-block-code"><code>@Override<br>public PageInfo&lt;Employee&gt; selectPage(Integer pageNum, Integer pageSize) {<br> &nbsp; &nbsp;PageHelper.startPage(pageNum, pageSize);<br> &nbsp; &nbsp;List&lt;Employee&gt; list = employeeMapper.selectAll();<br> &nbsp; &nbsp;return PageInfo.of(list) ;<br>}</code></pre>



<h2 class="wp-block-heading">CRUD：</h2>



<h3 class="wp-block-heading">Controller层：</h3>



<pre class="wp-block-code"><code>package com.chang.controller;<br>​<br>import com.chang.common.Result;<br>import com.chang.entity.Employee;<br>import com.chang.service.EmployeeService;<br>import com.github.pagehelper.PageInfo;<br>import org.springframework.beans.factory.annotation.Autowired;<br>import org.springframework.web.bind.annotation.*;<br>​<br>import java.util.List;<br>​<br>@RestController<br>@RequestMapping("/employee")<br>public class EmployeeController {<br>​<br> &nbsp; &nbsp;@Autowired<br> &nbsp; &nbsp;private EmployeeService employeeService;<br>​<br> &nbsp; &nbsp;/**<br> &nbsp; &nbsp; * 查询单个数据<br> &nbsp; &nbsp; */<br> &nbsp; &nbsp;@GetMapping("/selectById/{id}")<br> &nbsp; &nbsp;public Result selectById(@PathVariable Integer id){<br> &nbsp; &nbsp; &nbsp; &nbsp;Employee employee = employeeService.selectById(id);<br> &nbsp; &nbsp; &nbsp; &nbsp;return Result.success(employee);<br> &nbsp;  }<br>​<br> &nbsp; &nbsp;/**<br> &nbsp; &nbsp; * 查询所有的数据<br> &nbsp; &nbsp; */<br> &nbsp; &nbsp;@GetMapping("/selectAll")<br> &nbsp; &nbsp;public Result selectAll(){<br> &nbsp; &nbsp; &nbsp; &nbsp;List&lt;Employee&gt; list = employeeService.selectAll();<br> &nbsp; &nbsp; &nbsp; &nbsp;return Result.success(list);<br> &nbsp;  }<br>​<br> &nbsp; &nbsp;/**<br> &nbsp; &nbsp; * 分页查询数据<br> &nbsp; &nbsp; * pageNum: 当前页码<br> &nbsp; &nbsp; * pageSize: 每页的个数<br> &nbsp; &nbsp; */<br> &nbsp; &nbsp;@GetMapping("/selectPage")<br> &nbsp; &nbsp;public Result selectPage(@RequestParam(defaultValue = "1") Integer pageNum,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @RequestParam(defaultValue = "10") Integer pageSize){<br> &nbsp; &nbsp; &nbsp; &nbsp;PageInfo&lt;Employee&gt; pageInfo = employeeService.selectPage(pageNum, pageSize);<br> &nbsp; &nbsp; &nbsp; &nbsp;return Result.success(pageInfo);<br> &nbsp;  }<br>​<br> &nbsp; &nbsp;/**<br> &nbsp; &nbsp; * 新增数据<br> &nbsp; &nbsp; */<br> &nbsp; &nbsp;@PostMapping("/add")<br> &nbsp; &nbsp;public Result add(@RequestBody Employee employee){<br> &nbsp; &nbsp; &nbsp; &nbsp;employeeService.add(employee);<br> &nbsp; &nbsp; &nbsp; &nbsp;return Result.success();<br> &nbsp;  }<br>​<br> &nbsp; &nbsp;/**<br> &nbsp; &nbsp; * 跟新数据<br> &nbsp; &nbsp; */<br> &nbsp; &nbsp;@PutMapping("/update")<br> &nbsp; &nbsp;public Result update(@RequestBody Employee employee){<br> &nbsp; &nbsp; &nbsp; &nbsp;employeeService.update(employee);<br> &nbsp; &nbsp; &nbsp; &nbsp;return Result.success();<br> &nbsp;  }<br>​<br> &nbsp; &nbsp;/**<br> &nbsp; &nbsp; * 删除单个数据<br> &nbsp; &nbsp; */<br> &nbsp; &nbsp;@DeleteMapping("/deleteById/{id}")<br> &nbsp; &nbsp;public Result update(@PathVariable Integer id){<br> &nbsp; &nbsp; &nbsp; &nbsp;employeeService.deleteById(id);<br> &nbsp; &nbsp; &nbsp; &nbsp;return Result.success();<br> &nbsp;  }<br>}</code></pre>



<h3 class="wp-block-heading">ServiceImpl接口：</h3>



<pre class="wp-block-code"><code>package com.chang.service.impl;<br>​<br>import com.chang.entity.Employee;<br>import com.github.pagehelper.PageInfo;<br>​<br>import java.util.List;<br>​<br>public interface EmployeeServiceImpl {<br>​<br> &nbsp; &nbsp;Employee selectById(Integer id);<br>​<br> &nbsp; &nbsp;List&lt;Employee&gt; selectAll();<br>​<br> &nbsp; &nbsp;PageInfo&lt;Employee&gt; selectPage(Integer pageNum, Integer pageSize);<br>​<br> &nbsp; &nbsp;void add(Employee employee);<br>​<br> &nbsp; &nbsp;void update(Employee employee);<br>​<br> &nbsp; &nbsp;void deleteById(Integer id);<br>}</code></pre>



<h3 class="wp-block-heading">Service层：</h3>



<pre class="wp-block-code"><code>package com.chang.service;<br>​<br>import com.chang.entity.Employee;<br>import com.chang.mapper.EmployeeMapper;<br>import com.chang.service.impl.EmployeeServiceImpl;<br>import com.github.pagehelper.PageHelper;<br>import com.github.pagehelper.PageInfo;<br>import org.springframework.beans.factory.annotation.Autowired;<br>import org.springframework.stereotype.Service;<br>​<br>import java.util.List;<br>​<br>@Service<br>public class EmployeeService implements EmployeeServiceImpl {<br>​<br> &nbsp; &nbsp;@Autowired<br> &nbsp; &nbsp;private EmployeeMapper employeeMapper;<br>​<br> &nbsp; &nbsp;@Override<br> &nbsp; &nbsp;public Employee selectById(Integer id) {<br> &nbsp; &nbsp; &nbsp; &nbsp;return employeeMapper.selectById(id);<br> &nbsp;  }<br>​<br> &nbsp; &nbsp;@Override<br> &nbsp; &nbsp;public List&lt;Employee&gt; selectAll() {<br> &nbsp; &nbsp; &nbsp; &nbsp;//额外业务操作<br> &nbsp; &nbsp; &nbsp; &nbsp;return employeeMapper.selectAll();<br> &nbsp;  }<br>​<br> &nbsp; &nbsp;@Override<br> &nbsp; &nbsp;public PageInfo&lt;Employee&gt; selectPage(Integer pageNum, Integer pageSize) {<br> &nbsp; &nbsp; &nbsp; &nbsp;PageHelper.startPage(pageNum, pageSize);<br> &nbsp; &nbsp; &nbsp; &nbsp;List&lt;Employee&gt; list = employeeMapper.selectAll();<br> &nbsp; &nbsp; &nbsp; &nbsp;return PageInfo.of(list) ;<br> &nbsp;  }<br>​<br> &nbsp; &nbsp;@Override<br> &nbsp; &nbsp;public void add(Employee employee) {<br> &nbsp; &nbsp; &nbsp; &nbsp;employeeMapper.insert(employee);<br> &nbsp;  }<br>​<br> &nbsp; &nbsp;@Override<br> &nbsp; &nbsp;public void update(Employee employee) {<br> &nbsp; &nbsp; &nbsp; &nbsp;employeeMapper.updateById(employee);<br> &nbsp;  }<br>​<br> &nbsp; &nbsp;@Override<br> &nbsp; &nbsp;public void deleteById(Integer id) {<br> &nbsp; &nbsp; &nbsp; &nbsp;employeeMapper.deleteById(id);<br> &nbsp;  }<br>​<br>}</code></pre>



<h3 class="wp-block-heading">Mapper层：</h3>



<pre class="wp-block-code"><code>package com.chang.mapper;<br>​<br>import com.chang.entity.Employee;<br>import org.apache.ibatis.annotations.Delete;<br>import org.apache.ibatis.annotations.Select;<br>​<br>import java.util.List;<br>​<br>public interface EmployeeMapper {<br>​<br> &nbsp; &nbsp;List&lt;Employee&gt; selectAll();<br>​<br> &nbsp; &nbsp;@Select("select * from `employee` where id = #{id}")<br> &nbsp; &nbsp;Employee selectById(Integer id);<br>​<br> &nbsp; &nbsp;void insert(Employee employee);<br>​<br> &nbsp; &nbsp;void updateById(Employee employee);<br>​<br> &nbsp; &nbsp;@Delete("delete from `employee` where id = #{id}")<br> &nbsp; &nbsp;void deleteById(Integer id);<br>}</code></pre>



<h3 class="wp-block-heading">XML文件：</h3>



<pre class="wp-block-code"><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;<br>&lt;!DOCTYPE mapper<br> &nbsp; &nbsp; &nbsp; &nbsp;PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"<br> &nbsp; &nbsp; &nbsp; &nbsp;"https://mybatis.org/dtd/mybatis-3-mapper.dtd"&gt;<br>&lt;mapper namespace="com.chang.mapper.EmployeeMapper"&gt;<br>​<br> &nbsp; &nbsp;&lt;select id="selectAll" resultType="com.chang.entity.Employee"&gt;<br> &nbsp; &nbsp; &nbsp;  select * from employee<br> &nbsp; &nbsp;&lt;/select&gt;<br>​<br> &nbsp; &nbsp;&lt;insert id="insert" parameterType="com.chang.entity.Employee"&gt;<br> &nbsp; &nbsp; &nbsp;  insert into `employee` (name,sex,no,age,description,department_id)<br> &nbsp; &nbsp; &nbsp;  values (#{name},#{sex},#{no},#{age},#{description},#{departmentId})<br> &nbsp; &nbsp;&lt;/insert&gt;<br>​<br> &nbsp; &nbsp;&lt;update id="updateById" parameterType="com.chang.entity.Employee"&gt;<br> &nbsp; &nbsp; &nbsp;  update `employee` set name = #{name},sex = #{sex},no=#{no},age=#{age},<br> &nbsp; &nbsp; &nbsp;  description=#{description},department_id=#{departmentId}<br> &nbsp; &nbsp; &nbsp;  where id=#{id}<br> &nbsp; &nbsp;&lt;/update&gt;<br>​<br>&lt;/mapper&gt;</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.qiqin-chang.cn/mybatis-%e6%8c%81%e4%b9%85%e5%b1%82%e6%a1%86%e6%9e%b6%ef%bc%9a/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Git-远程仓库</title>
		<link>https://www.qiqin-chang.cn/git-%e8%bf%9c%e7%a8%8b%e4%bb%93%e5%ba%93/</link>
					<comments>https://www.qiqin-chang.cn/git-%e8%bf%9c%e7%a8%8b%e4%bb%93%e5%ba%93/#respond</comments>
		
		<dc:creator><![CDATA[乐章]]></dc:creator>
		<pubDate>Thu, 10 Apr 2025 05:10:51 +0000</pubDate>
				<category><![CDATA[后端]]></category>
		<category><![CDATA[组件]]></category>
		<guid isPermaLink="false">http://8.153.197.211/?p=170</guid>

					<description><![CDATA[下载安装： 官方网站：https://git-scm.com 下载地址：https://git-scm.com [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h1 class="wp-block-heading">下载安装：</h1>



<p>官方网站：<a href="https://git-scm.com/">https://git-scm.com</a></p>



<p>下载地址：<a href="https://git-scm.com/download">https://git-scm.com/download</a></p>



<h1 class="wp-block-heading">本地克隆：</h1>



<pre class="wp-block-preformatted">git clone 项目克隆地址</pre>



<p>IDEA中Git克隆项目：</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="975" height="203" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/Git-1.png" alt="" class="wp-image-172" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/Git-1.png 975w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/Git-1-300x62.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/Git-1-768x160.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></figure>
</div>


<p></p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="993" height="313" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/Git-2.png" alt="" class="wp-image-173" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/Git-2.png 993w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/Git-2-300x95.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/Git-2-768x242.png 768w" sizes="auto, (max-width: 993px) 100vw, 993px" /></figure>
</div>


<h1 class="wp-block-heading">推送：</h1>



<pre class="wp-block-preformatted">在导航栏点击VCS-&gt;创建Git仓库-&gt;选择项目根目录<br>​<br>在GitHub上创建仓库-&gt;复制仓库SSH路径-&gt;在idea中点击提交键输入要存入的Git仓库地址</pre>



<p><a href="#top">返回顶部</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.qiqin-chang.cn/git-%e8%bf%9c%e7%a8%8b%e4%bb%93%e5%ba%93/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Maven-依赖管理</title>
		<link>https://www.qiqin-chang.cn/maven-%e4%be%9d%e8%b5%96%e7%ae%a1%e7%90%86/</link>
					<comments>https://www.qiqin-chang.cn/maven-%e4%be%9d%e8%b5%96%e7%ae%a1%e7%90%86/#respond</comments>
		
		<dc:creator><![CDATA[乐章]]></dc:creator>
		<pubDate>Thu, 10 Apr 2025 05:09:27 +0000</pubDate>
				<category><![CDATA[后端]]></category>
		<category><![CDATA[组件]]></category>
		<guid isPermaLink="false">http://8.153.197.211/?p=165</guid>

					<description><![CDATA[Maven下载安装： 官网：https://maven.apache.org 下载地址：https://mav [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Maven下载安装：</p>



<p>官网：<a href="https://maven.apache.org/">https://maven.apache.org</a></p>



<p>下载地址：<a href="https://maven.apache.org/download.cgi">https://maven.apache.org/download.cgi</a></p>



<p>安装方式：解压安装</p>



<p>Maven配置：</p>



<p>修改Maven安装目录-&gt;conf-&gt;settings.xml文件：</p>



<p>配置本地仓库：</p>



<pre class="wp-block-code"><code lang="xml" class="language-xml">  &lt;!--本地仓库地址-->
  &lt;localRepository>D:/maven/jarku&lt;/localRepository></code></pre>



<p>配置远程仓库：</p>



<pre class="wp-block-code"><code lang="xml" class="language-xml">&lt;!--远程仓库地址-->
&lt;mirror>
    &lt;id>aliyunmaven&lt;/id>
    &lt;mirrorOf>*&lt;/mirrorOf>
    &lt;name>阿里云公共仓库&lt;/name>
    &lt;url>https://maven.aliyun.com/repository/public&lt;/url>
&lt;/mirror></code></pre>



<p>在Maven同级目录下创建本地仓库文件夹：jarku</p>



<p>IDEA中Maven配置：</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="751" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/Maven-01-1024x751.png" alt="" class="wp-image-166" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/Maven-01-1024x751.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/Maven-01-300x220.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/Maven-01-768x563.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/Maven-01.png 1229w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>IDEA中编码配置：</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="751" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/编码设置-1024x751.png" alt="" class="wp-image-167" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/编码设置-1024x751.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/编码设置-300x220.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/编码设置-768x563.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/编码设置.png 1229w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p><a href="#top">返回顶部</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.qiqin-chang.cn/maven-%e4%be%9d%e8%b5%96%e7%ae%a1%e7%90%86/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>阿里云OSS-对象存储</title>
		<link>https://www.qiqin-chang.cn/%e9%98%bf%e9%87%8c%e4%ba%91oss-%e5%af%b9%e8%b1%a1%e5%ad%98%e5%82%a8/</link>
					<comments>https://www.qiqin-chang.cn/%e9%98%bf%e9%87%8c%e4%ba%91oss-%e5%af%b9%e8%b1%a1%e5%ad%98%e5%82%a8/#respond</comments>
		
		<dc:creator><![CDATA[乐章]]></dc:creator>
		<pubDate>Thu, 10 Apr 2025 04:31:29 +0000</pubDate>
				<category><![CDATA[后端]]></category>
		<category><![CDATA[组件]]></category>
		<guid isPermaLink="false">http://8.153.197.211/?p=153</guid>

					<description><![CDATA[基本配置： 依赖： Java 9及以上的版本，则需要添加以下JAXB相关依赖： 配置： 配置类： 参数类： 工 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h1 class="wp-block-heading">基本配置：</h1>



<p>依赖：</p>



<pre class="wp-block-code"><code>&lt;dependency>
    &lt;groupId>com.aliyun.oss&lt;/groupId>
    &lt;artifactId>aliyun-sdk-oss&lt;/artifactId>
    &lt;version>3.17.4&lt;/version>
&lt;/dependency></code></pre>



<p>Java 9及以上的版本，则需要添加以下JAXB相关依赖：</p>



<pre class="wp-block-code"><code>&lt;dependency>
    &lt;groupId>javax.xml.bind&lt;/groupId>
    &lt;artifactId>jaxb-api&lt;/artifactId>
    &lt;version>2.3.1&lt;/version>
&lt;/dependency>
&lt;dependency>
    &lt;groupId>javax.activation&lt;/groupId>
    &lt;artifactId>activation&lt;/artifactId>
    &lt;version>1.1.1&lt;/version>
&lt;/dependency>
&lt;!-- no more than 2.3.3-->
&lt;dependency>
    &lt;groupId>org.glassfish.jaxb&lt;/groupId>
    &lt;artifactId>jaxb-runtime&lt;/artifactId>
    &lt;version>2.3.3&lt;/version>
&lt;/dependency></code></pre>



<p>配置：</p>



<pre class="wp-block-code"><code>chang:
    alioss:
        endpoint: ${chang.alioss.endpoint}
        access-key-id: ${chang.alioss.access-key-id}
        access-key-secret: ${chang.alioss.access-key-secret}
        bucket-name: ${chang.alioss.bucket-name}</code></pre>



<p>配置类：</p>



<pre class="wp-block-code"><code>/**
 * 配置类，用于创建AliOssUtil对象
 */
@Configuration
@Slf4j
public class OssConfiguration {
​
    @Bean
    @ConditionalOnMissingBean
    public AliOssUtil aliOssUtil(AliOssProperties aliOssProperties) {
        log.info("开始创建阿里云文件上传工具类对象：{}",aliOssProperties);
        return new AliOssUtil(
                aliOssProperties.getEndpoint(),
                aliOssProperties.getAccessKeyId(),
                aliOssProperties.getAccessKeySecret(),
                aliOssProperties.getBucketName());
    }
}</code></pre>



<p>参数类：</p>



<pre class="wp-block-code"><code>@Component
@ConfigurationProperties(prefix = "chang.alioss")
@Data
public class AliOssProperties {
​
    private String endpoint;
    private String accessKeyId;
    private String accessKeySecret;
    private String bucketName;
​
}</code></pre>



<p>工具类：</p>



<pre class="wp-block-code"><code>@Data
@AllArgsConstructor
@Slf4j
public class AliOssUtil {
​
    private String endpoint;
    private String accessKeyId;
    private String accessKeySecret;
    private String bucketName;
​
    /**
     * 文件上传
     *
     * @param bytes
     * @param objectName
     * @return
     */
    public String upload(byte&#91;] bytes, String objectName) {
​
        // 创建OSSClient实例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
​
        try {
            // 创建PutObject请求。
            ossClient.putObject(bucketName, objectName, new ByteArrayInputStream(bytes));
        } catch (OSSException oe) {
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
​
        //文件访问路径规则 https://BucketName.Endpoint/ObjectName
        StringBuilder stringBuilder = new StringBuilder("https://");
        stringBuilder
                .append(bucketName)
                .append(".")
                .append(endpoint)
                .append("/")
                .append(objectName);
​
        log.info("文件上传到:{}", stringBuilder.toString());
​
        return stringBuilder.toString();
    }
}</code></pre>



<h1 class="wp-block-heading">工具操作：</h1>



<h2 class="wp-block-heading">账号准备：</h2>



<p>注册阿里云账户（注册完成后需要实名认证）</p>



<p><a href="https://account.aliyun.com/login/login.htm?oauth_callback=https%3A%2F%2Fwww.aliyun.com%2F">https://account.aliyun.com/login/login.htm?oauth_callback=https%3A%2F%2Fwww.aliyun.com%2F</a></p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-1-1024x576.png" alt="" class="wp-image-154" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-1-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-1-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-1-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-1-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-1.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>注册完账号之后，就可以登录阿里云</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-2-1024x576.png" alt="" class="wp-image-155" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-2-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-2-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-2-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-2-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-2.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<h2 class="wp-block-heading">开通OSS云服务：</h2>



<p>通过控制台找到对象存储OSS服务：</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-3-1024x576.png" alt="" class="wp-image-156" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-3-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-3-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-3-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-3-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-3.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>选择要开通的服务：</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-4-1024x576.png" alt="" class="wp-image-157" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-4-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-4-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-4-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-4-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-4.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>如果是第一次访问，需开通对象存储服务OSS ：</p>



<p>开通OSS服务之后，就可以进入到阿里云对象存储的控制台:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-5-1024x576.png" alt="" class="wp-image-158" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-5-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-5-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-5-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-5-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-5.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>点击左侧的 &#8220;Bucket列表&#8221;，创建一个Bucket</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-6-1024x576.png" alt="" class="wp-image-159" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-6-1024x576.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-6-300x169.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-6-768x432.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-6-1536x864.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-6.png 1920w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>输入Bucket的相关信息</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="940" height="879" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-7.png" alt="" class="wp-image-160" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-7.png 940w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-7-300x281.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-7-768x718.png 768w" sizes="auto, (max-width: 940px) 100vw, 940px" /></figure>
</div>


<p>其他的信息，配置项使用默认的即可。</p>



<h2 class="wp-block-heading">配置AccessKey:</h2>



<p>创建AccessKey:</p>



<p>点击 &#8220;AccessKey管理&#8221;，进入到管理页面。</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="596" height="698" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-8.png" alt="" class="wp-image-161" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-8.png 596w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-8-256x300.png 256w" sizes="auto, (max-width: 596px) 100vw, 596px" /></figure>
</div>


<p>点击 &#8220;创建AccessKey&#8221;。</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="195" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-9-1024x195.png" alt="" class="wp-image-162" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-9-1024x195.png 1024w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-9-300x57.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-9-768x147.png 768w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-9-1536x293.png 1536w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-9.png 1656w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>

<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="804" height="483" src="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-10.png" alt="" class="wp-image-163" srcset="https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-10.png 804w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-10-300x180.png 300w, https://www.qiqin-chang.cn/wp-content/uploads/2025/04/阿里云OSS-10-768x461.png 768w" sizes="auto, (max-width: 804px) 100vw, 804px" /></figure>
</div>


<p>配置AccessKey:</p>



<p>以<strong>管理员身份</strong>打开CMD命令行，执行如下命令，配置系统的环境变量。</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">set OSS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
set OSS_ACCESS_KEY_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</code></pre>



<p><strong>注意：将上述的ACCESS_KEY_ID 与 ACCESS_KEY_SECRET 的值一定要替换成自己的 。</strong></p>



<p>执行如下命令，让更改生效。</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">setx OSS_ACCESS_KEY_ID "%OSS_ACCESS_KEY_ID%"
setx OSS_ACCESS_KEY_SECRET "%OSS_ACCESS_KEY_SECRET%"</code></pre>



<p>执行如下命令，验证环境变量是否生效。</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash">echo %OSS_ACCESS_KEY_ID%
echo %OSS_ACCESS_KEY_SECRET%</code></pre>



<p><a href="#top">返回顶部</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.qiqin-chang.cn/%e9%98%bf%e9%87%8c%e4%ba%91oss-%e5%af%b9%e8%b1%a1%e5%ad%98%e5%82%a8/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>WebSocket-全双工通信协议</title>
		<link>https://www.qiqin-chang.cn/websocket-%e5%85%a8%e5%8f%8c%e5%b7%a5%e9%80%9a%e4%bf%a1%e5%8d%8f%e8%ae%ae/</link>
					<comments>https://www.qiqin-chang.cn/websocket-%e5%85%a8%e5%8f%8c%e5%b7%a5%e9%80%9a%e4%bf%a1%e5%8d%8f%e8%ae%ae/#respond</comments>
		
		<dc:creator><![CDATA[乐章]]></dc:creator>
		<pubDate>Wed, 09 Apr 2025 12:30:19 +0000</pubDate>
				<category><![CDATA[后端]]></category>
		<category><![CDATA[插件]]></category>
		<guid isPermaLink="false">http://8.153.197.211/?p=70</guid>

					<description><![CDATA[依赖： 配置类： websocket服务类： 返回顶部]]></description>
										<content:encoded><![CDATA[
<p>依赖：</p>



<pre class="wp-block-code"><code lang="xml" class="language-xml">&lt;dependency>
    &lt;groupId>org.springframework.boot&lt;/groupId>
    &lt;artifactId>spring-boot-starter-websocket&lt;/artifactId>
&lt;/dependency></code></pre>



<p>配置类：</p>



<pre class="wp-block-code"><code lang="java" class="language-java">/**
 * WebSocket配置类，用于注册WebSocket的Bean
 */
@Configuration
public class WebSocketConfiguration {
    @Bean
    public ServerEndpointExporter serverEndpointExporter() {
        return new ServerEndpointExporter();
    }
}</code></pre>



<p>websocket服务类：</p>



<pre class="wp-block-code"><code lang="java" class="language-java">/**
 * WebSocket服务
 */
@Component
@ServerEndpoint("/ws/{sid}")
public class WebSocketServer {
​
    //存放会话对象
    private static Map&lt;String, Session> sessionMap = new HashMap();
​
    /**
     * 连接建立成功调用的方法
     */
    @OnOpen
    public void onOpen(Session session, @PathParam("sid") String sid) {
        System.out.println("客户端：" + sid + "建立连接");
        sessionMap.put(sid, session);
    }
​
    /**
     * 收到客户端消息后调用的方法
     *
     * @param message 客户端发送过来的消息
     */
    @OnMessage
    public void onMessage(String message, @PathParam("sid") String sid) {
        System.out.println("收到来自客户端：" + sid + "的信息:" + message);
    }
​
    /**
     * 连接关闭调用的方法
     *
     * @param sid
     */
    @OnClose
    public void onClose(@PathParam("sid") String sid) {
        System.out.println("连接断开:" + sid);
        sessionMap.remove(sid);
    }
​
    /**
     * 群发
     *
     * @param message
     */
    public void sendToAllClient(String message) {
        Collection&lt;Session> sessions = sessionMap.values();
        System.out.println("发送");
        for (Session session : sessions) {
            try {
                //服务器向客户端发送消息
                session.getBasicRemote().sendText(message);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
​
}</code></pre>



<p><a href="#top">返回顶部</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.qiqin-chang.cn/websocket-%e5%85%a8%e5%8f%8c%e5%b7%a5%e9%80%9a%e4%bf%a1%e5%8d%8f%e8%ae%ae/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SpringTask-定时任务</title>
		<link>https://www.qiqin-chang.cn/springtask-%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1/</link>
					<comments>https://www.qiqin-chang.cn/springtask-%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1/#respond</comments>
		
		<dc:creator><![CDATA[乐章]]></dc:creator>
		<pubDate>Wed, 09 Apr 2025 12:29:21 +0000</pubDate>
				<category><![CDATA[后端]]></category>
		<category><![CDATA[插件]]></category>
		<guid isPermaLink="false">http://8.153.197.211/?p=68</guid>

					<description><![CDATA[使用步骤： 与ServiceImpl层相似: 返回顶部]]></description>
										<content:encoded><![CDATA[
<p>使用步骤：</p>



<ul class="wp-block-list">
<li>导入maven坐标：spring-context(已存在)</li>



<li>启动类添加注解：@EnableScheduling //开启任务调度</li>



<li>自定义定时任务类</li>
</ul>



<p>与ServiceImpl层相似:</p>



<pre class="wp-block-code"><code lang="java" class="language-java">/**
 * 定时任务 
 */
@Scheduled(cron = "0/5 * * * * ?") //每隔5秒触发一次
public void execute() {
    log.info("定时任务开始执行：{}",new Date());
}</code></pre>



<p><a href="#top">返回顶部</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.qiqin-chang.cn/springtask-%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>JWT-令牌加密</title>
		<link>https://www.qiqin-chang.cn/jwt-%e4%bb%a4%e7%89%8c%e5%8a%a0%e5%af%86/</link>
					<comments>https://www.qiqin-chang.cn/jwt-%e4%bb%a4%e7%89%8c%e5%8a%a0%e5%af%86/#respond</comments>
		
		<dc:creator><![CDATA[乐章]]></dc:creator>
		<pubDate>Wed, 09 Apr 2025 12:28:17 +0000</pubDate>
				<category><![CDATA[后端]]></category>
		<category><![CDATA[插件]]></category>
		<guid isPermaLink="false">http://8.153.197.211/?p=66</guid>

					<description><![CDATA[依赖： 工具包： 旧： 生成Token 获取用户信息： Service层login方法中： 生成token并返 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">依赖：</h2>



<pre class="wp-block-code"><code>&lt;!--JWT 令牌加密--&gt;<br>&lt;dependency&gt;<br> &nbsp; &nbsp;&lt;groupId&gt;com.auth0&lt;/groupId&gt;<br> &nbsp; &nbsp;&lt;artifactId&gt;java-jwt&lt;/artifactId&gt;<br> &nbsp; &nbsp;&lt;version&gt;4.3.0&lt;/version&gt;<br>&lt;/dependency&gt;</code></pre>



<h2 class="wp-block-heading">工具包：</h2>



<h3 class="wp-block-heading">旧：</h3>



<p>生成Token 获取用户信息：</p>



<pre class="wp-block-code"><code>package com.chang.utils;
​
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.chang.entity.Account;
import com.chang.service.impl.AdminServiceImpl;
import com.chang.service.impl.EmployeeServiceImpl;
import jakarta.annotation.PostConstruct;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
​
import java.util.Date;
​
@Component
public class TokenUtils {
​
    @Autowired
    AdminServiceImpl adminService;
    @Autowired
    EmployeeServiceImpl employeeService;
​
    static AdminServiceImpl staticAdminService;
    static EmployeeServiceImpl staticEmployeeService;
​
    //springboot工程启动后会加载这段代码
    @PostConstruct
    public void init(){
        staticAdminService = adminService;
        staticEmployeeService = employeeService;
    }
​
​
    /**
     * 生成token
     */
    public static String createToken(String data,String sign) {
        return JWT.create().withAudience(data) //将userId-role 保存到token里面，作为载荷
                .withExpiresAt(DateUtil.offsetDay(new Date(),1)) //1天后token过期
                .sign(Algorithm.HMAC256(sign)); //秘钥签名 以password 作为token的秘钥，HMAC256算法加密
    }
​
    /**
     * 获取当前登录用户信息
     */
    public static Account getCurrentUser() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        String token  = request.getHeader("token");
        if (StrUtil.isBlank(token)){
            token = request.getParameter("Token");
        }
        if (StrUtil.isBlank(token)){
            return null;
        }
        //拿到token的载荷数据
        String audience = JWT.decode(token).getAudience().get(0);
        String&#91;] split = audience.split("-");
        String userId = split&#91;0];
        String role = split&#91;1];
        //根据token解析出来的userId去对应的表查询用户信息
        if ("ADMIN".equals(role)){
            return staticAdminService.selectById(Integer.valueOf(userId));
        } else if ("EMP".equals(role)) {
            return staticEmployeeService.selectById(Integer.valueOf(userId));
        }
​
        return null;
    }
}
​</code></pre>



<p>Service层login方法中：</p>



<p>生成token并返回给前端：</p>



<pre class="wp-block-code"><code>String token = TokenUtils.createToken(dbAdmin.getId() + "-" + "ADMIN", dbAdmin.getPassword());<br>dbAdmin.setToken(token);</code></pre>



<p>获取当前用户信息：</p>



<pre class="wp-block-code"><code>Account currentUser = TokenUtils.getCurrentUser();</code></pre>



<h3 class="wp-block-heading">新：</h3>



<pre class="wp-block-code"><code>package com.chang.utils;
​
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.chang.entity.Account;
import com.chang.service.impl.AdminServiceImpl;
import com.chang.service.impl.EmployeeServiceImpl;
import com.chang.service.impl.UserServiceImpl;
import jakarta.annotation.PostConstruct;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
​
import java.util.Date;
​
@Component
public class JWTUtils {
​
    private static final String sign = "chang_2025";
​
    @Autowired
    AdminServiceImpl adminService;
    @Autowired
    EmployeeServiceImpl employeeService;
    @Autowired
    UserServiceImpl userService;
​
    static AdminServiceImpl staticAdminService;
    static EmployeeServiceImpl staticEmployeeService;
    static UserServiceImpl staticUserService;
​
    //springboot工程启动后会加载这段代码
    @PostConstruct
    public void init(){
        staticAdminService = adminService;
        staticEmployeeService = employeeService;
        staticUserService = userService;
    }
​
    /**
     * 生成 Token
     */
    public static String createToken(Integer id, String role) {
        return JWT.create()
                .withClaim("id", id)
                .withClaim("role", role)               // 角色
                .withExpiresAt(DateUtil.offsetDay(new Date(), 1)) // 1天后过期
                .sign(Algorithm.HMAC256(sign));
    }
​
    /**
     * 获取用户信息
     * @return
     */
    public static Account getCurrentUser() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        String token = request.getHeader("Token");
        if (StrUtil.isBlank(token)) {
            token = request.getParameter("Token");
        }
        if (StrUtil.isBlank(token)) {
            return null; //只能进行静默处理
        }
​
        try {
            // 1. 验签
            DecodedJWT decodedJWT = JWT.require(Algorithm.HMAC256(sign)).build().verify(token);
​
            // 2. 解析 payload
            Integer userId = decodedJWT.getClaim("id").asInt();
            String role = decodedJWT.getClaim("role").asString();
​
            // 根据角色查对应表
            if ("ADMIN".equals(role)) {
                return staticAdminService.selectById(userId); // 假设 username 是主键
            } else if ("EMP".equals(role)) {
                return staticEmployeeService.selectById(userId);
            } else if ("USER".equals(role)) {
                return staticUserService.selectById(userId);
            }
        } catch (Exception e) {
            return null;
        }
​
​
        return null;
    }
​
}</code></pre>



<h2 class="wp-block-heading">拦截器：</h2>



<h3 class="wp-block-heading">注册拦截器：</h3>



<pre class="wp-block-code"><code>package com.chang.config;
​
import com.chang.interceptor.JWTInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
​
@Configuration
public class WebConfig implements WebMvcConfigurer {
​
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor()).addPathPatterns("/**").excludePathPatterns("/login","/register");
    }
    
    @Bean
    public JWTInterceptor jwtInterceptor() {
        return new JWTInterceptor();
    }
}</code></pre>



<h3 class="wp-block-heading">实现拦截器：</h3>



<h4 class="wp-block-heading">旧：</h4>



<pre class="wp-block-code"><code>package com.chang.interceptor;
​
import cn.hutool.core.util.StrUtil;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.chang.entity.Account;
import com.chang.exception.CustomException;
import com.chang.service.AdminService;
import com.chang.service.EmployeeService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
​
@Component
public class JWTInterceptor implements HandlerInterceptor {
    
    @Autowired
    AdminService adminService;
    @Autowired
    EmployeeService employeeService;
​
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        //1.从请求头中获取token
        String token = request.getHeader("Token");
        if (StrUtil.isEmpty(token)){
            //如果没拿到，从参数里再拿一次
            token = request.getParameter("Token");
        }
        //2.认证token
        if (StrUtil.isBlank(token)){
            throw new CustomException("401","您无权限操作");
        }
​
        Account account = null;
        try{
            //拿到token的载荷数据
            String audience = JWT.decode(token).getAudience().get(0);
            String&#91;] split = audience.split("-");
            String userId = split&#91;0];
            String role = split&#91;1];
            //根据token解析出来的userId去对应的表查询用户信息
            if ("ADMIN".equals(role)){
                account = adminService.selectById(Integer.valueOf(userId));
            } else if ("EMP".equals(role)) {
                account = employeeService.selectById(Integer.valueOf(userId));
            }
        }catch (Exception e){
            throw new CustomException("401","您无权限操作");
        }
        if (account == null){
            throw new CustomException("401","您无权限操作");
        }
​
        //验证签名
        try {
            JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(account.getPassword())).build();
            jwtVerifier.verify(token);
        }catch (Exception e){
            throw new CustomException("401","您无权限操作");
        }
        
        return true;
    }
}</code></pre>



<h4 class="wp-block-heading">新：</h4>



<pre class="wp-block-code"><code>package com.chang.interceptor;
​
import cn.hutool.core.util.StrUtil;
import com.chang.entity.Account;
import com.chang.exception.CustomException;
import com.chang.utils.TokenUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
​
@Component
public class JWTInterceptor implements HandlerInterceptor {
​
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        //1.从请求头中获取token
        String token = request.getHeader("Token");
        if (StrUtil.isEmpty(token)){
            //如果没拿到，从参数里再拿一次
            token = request.getParameter("Token");
        }
​
        //2.认证token
        if (StrUtil.isBlank(token)){
            throw new CustomException("401", "未检测到登录凭证，请先登录");
        }
​
        Account account = TokenUtils.getCurrentUser();
        if (account == null) {
            throw new CustomException("401", "Token无效或已过期，请重新登录");
        }
​
        return true;
    }
}</code></pre>



<h2 class="wp-block-heading">前端：</h2>



<h3 class="wp-block-heading">设置拦截器：</h3>



<p>utils包：</p>



<p>request.js:</p>



<p>添加请求头 处理错误信息：</p>



<pre class="wp-block-code"><code>import axios from 'axios';<br>import {ElMessage} from 'element-plus';<br>import router from "@/router/index.js";<br>​<br>const request = axios.create({<br> &nbsp; &nbsp;baseURL:'http://localhost:9090',<br> &nbsp; &nbsp;timeout:30000, //后台接口超时时间<br>})<br>​<br>//request 拦截器<br>//可以自动请求发送前对请求做的一些处理<br>request.interceptors.request.use(<br> &nbsp; &nbsp;config =&gt; {<br> &nbsp; &nbsp; &nbsp; &nbsp;config.headers&#91;'Content-Type'] = 'application/json;charset=utf-8';<br> &nbsp; &nbsp; &nbsp; &nbsp;let user = JSON.parse(localStorage.getItem('chang-user')||'{}');<br> &nbsp; &nbsp; &nbsp; &nbsp;config.headers&#91;'token'] = user.token<br> &nbsp; &nbsp; &nbsp; &nbsp;return config;<br> &nbsp;  },<br> &nbsp; &nbsp;error =&gt; {<br> &nbsp; &nbsp; &nbsp; &nbsp;return Promise.reject(error);<br> &nbsp;  }<br>)<br>​<br>//response 拦截器<br>//可以在接口响应后统一处理结果<br>request.interceptors.response.use(<br> &nbsp; &nbsp;response =&gt; {<br> &nbsp; &nbsp; &nbsp; &nbsp;let res = response.data;<br> &nbsp; &nbsp; &nbsp; &nbsp;//兼容服务端返回的字符串数据<br> &nbsp; &nbsp; &nbsp; &nbsp;if (typeof res === 'string') {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;res = res ? JSON.parse(res) : res;<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp;if (res.code === '401') {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ElMessage.error(res.msg);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;router.push('/login');<br> &nbsp; &nbsp; &nbsp;  }else{<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return res;<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp;return res;<br> &nbsp;  },<br> &nbsp; &nbsp;error =&gt; {<br> &nbsp; &nbsp; &nbsp; &nbsp;if (error.response.status === 404) {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ElMessage.error('未找到请求接口')<br> &nbsp; &nbsp; &nbsp;  }else if (error.response.status === 500) {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ElMessage.error('系统异常，请查看后端控制台报错')<br> &nbsp; &nbsp; &nbsp;  }else {<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;console.error(error.message);<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp; &nbsp; &nbsp;return Promise.reject(error);<br> &nbsp;  }<br>)<br>​<br>export default request;</code></pre>



<h3 class="wp-block-heading">拼接Token令牌：</h3>



<p>eg：更改导出数据代码:</p>



<pre class="wp-block-code"><code>user:JSON.parse(localStorage.getItem('chang-user')||'{}'),
​
//导出数据
const exportData=()=&gt;{
 &nbsp;let url = &nbsp;`http://localhost:9090/employee/export`
 &nbsp;+ `?Token=${data.user.token}`;
 &nbsp;//导出数据 是通过流的形式下载 excel &nbsp; 打开流的连接，浏览器会自动帮我们下载文件
 &nbsp;window.open(url);
}</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.qiqin-chang.cn/jwt-%e4%bb%a4%e7%89%8c%e5%8a%a0%e5%af%86/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Lombok-构建工具</title>
		<link>https://www.qiqin-chang.cn/lombok-%e6%9e%84%e5%bb%ba%e5%b7%a5%e5%85%b7/</link>
					<comments>https://www.qiqin-chang.cn/lombok-%e6%9e%84%e5%bb%ba%e5%b7%a5%e5%85%b7/#respond</comments>
		
		<dc:creator><![CDATA[乐章]]></dc:creator>
		<pubDate>Wed, 09 Apr 2025 12:25:21 +0000</pubDate>
				<category><![CDATA[后端]]></category>
		<category><![CDATA[插件]]></category>
		<guid isPermaLink="false">http://8.153.197.211/?p=64</guid>

					<description><![CDATA[依赖： 使用方法： 注解 添加位置 说明 @Setter: 注解在类/字段 生成setter方法 @Gette [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>依赖：</p>



<pre class="wp-block-code"><code lang="xml" class="language-xml">&lt;dependency>
    &lt;groupId>org.projectlombok&lt;/groupId>
    &lt;artifactId>lombok&lt;/artifactId>
&lt;/dependency></code></pre>



<p>使用方法：</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>注解</th><th>添加位置</th><th>说明</th></tr></thead><tbody><tr><td>@Setter:</td><td>注解在类/字段</td><td>生成setter方法</td></tr><tr><td>@Getter:</td><td>注解在类/字段</td><td>生成getter方法</td></tr><tr><td>@ToString:</td><td>注解在类</td><td>生成toString方法</td></tr><tr><td>@EqualsAndHashCode:</td><td>注解在类</td><td>生成hashCode和equals方法</td></tr><tr><td>@NoArgsConstructor:</td><td>注解在类</td><td>生成无参构造方法</td></tr><tr><td>@RequireArgsConstructor:</td><td>注解在类</td><td>为需要特殊处理的字段生成构造方法（如final和被@NonNull注解的字段）</td></tr><tr><td>@Data:</td><td>注解在类</td><td>生成setter、getter、equals、canEqual、hashCode、toString方法。(final属性，不会生成setter方法)</td></tr><tr><td>@Slf4j:</td><td>注解在类</td><td>生成log日志</td></tr><tr><td>@Builder：</td><td>注解在类</td><td>链式构造Java类对象</td></tr></tbody></table></figure>



<p><a href="#top">返回顶部</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.qiqin-chang.cn/lombok-%e6%9e%84%e5%bb%ba%e5%b7%a5%e5%85%b7/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Swagger-接口文档</title>
		<link>https://www.qiqin-chang.cn/swagger-%e6%8e%a5%e5%8f%a3%e6%96%87%e6%a1%a3/</link>
					<comments>https://www.qiqin-chang.cn/swagger-%e6%8e%a5%e5%8f%a3%e6%96%87%e6%a1%a3/#respond</comments>
		
		<dc:creator><![CDATA[乐章]]></dc:creator>
		<pubDate>Wed, 09 Apr 2025 12:24:24 +0000</pubDate>
				<category><![CDATA[后端]]></category>
		<category><![CDATA[插件]]></category>
		<guid isPermaLink="false">http://8.153.197.211/?p=62</guid>

					<description><![CDATA[依赖： 常用注解： 注解 说明 @Api 用在Controller类上 @ApiOperation 用在Con [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>依赖：</p>



<pre class="wp-block-code"><code lang="xml" class="language-xml">&lt;dependency>
    &lt;groupId>com.github.xiaoymin&lt;/groupId>
    &lt;artifactId>knife4j-spring-boot-starter&lt;/artifactId>
&lt;/dependency></code></pre>



<p>常用注解：</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>注解</th><th>说明</th></tr></thead><tbody><tr><td>@Api</td><td>用在Controller类上</td></tr><tr><td>@ApiOperation</td><td>用在Controller方法上</td></tr><tr><td>@ApiModel</td><td>用在pojo类上</td></tr><tr><td>@ApiModelProperty</td><td>用在pojo属性上</td></tr></tbody></table></figure>



<p>使用方法：</p>



<pre class="wp-block-code"><code lang="java" class="language-java">/**
 * 配置类，注册web层相关组件
 */
@Configuration
@Slf4j
public class WebMvcConfiguration extends WebMvcConfigurationSupport {

    /**
 	* 通过knife4j生成接口文档
 	* @return
 	*/
	@Bean
	public Docket docket() {
    	ApiInfo apiInfo = new ApiInfoBuilder()
            	.title("标题")
            	.version("2.0")
        	    .description("描述")
    	        .build();
   	 	Docket docket = new Docket(DocumentationType.SWAGGER_2)
        	    .apiInfo(apiInfo)
    	        .select()
	            //指定生成接口需要扫描的包
	            .apis(RequestHandlerSelectors.basePackage("com.sky.controller"))
            	.paths(PathSelectors.any())
        	    .build();
    	return docket;
	}

	/**
 	* 设置静态资源映射
 	* @param registry
 	*/
	protected void addResourceHandlers(ResourceHandlerRegistry registry) {
    	registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/");
    	registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
	}
}</code></pre>



<p><a href="#top">返回顶部</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.qiqin-chang.cn/swagger-%e6%8e%a5%e5%8f%a3%e6%96%87%e6%a1%a3/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
