feat(商城): 代码优化

master
wayn 10 months ago
parent 919df9c16a
commit 9137d6fed9

@ -99,7 +99,7 @@ git clone git@github.com:wayn111/waynboot-mall.git
# 2. 导入项目依赖
将 waynboot-mall 目录用 idea 打开,导入 maven 依赖
# 3. 安装 Mysql8.0+、Redis3.0+、RabbitMQ3.0+含延迟消息插件、ElasticSearch7.0+(含分词、拼英插件)到本地
# 3. 安装 Jdk17、Mysql8.0+、Redis3.0+、RabbitMQ3.0+含延迟消息插件、ElasticSearch7.0+(含分词、拼英插件)到本地
# 4. 导入 sql 文件
在项目根目录下,找到 `wayn_shop_*.sql` 文件,新建 mysql 数据库 wayn_shop导入其中
@ -150,42 +150,15 @@ h5商城api:
所以如有咨询大量问题,请先付出金钱成本😜。
# 演示截图
<table>
<tr>
<td>商城首页<img src="https://files.mdnice.com/user/40549/914d6ec3-7456-49fc-bda5-24256bdec9ee.png"/></td>
<td>更多商品<img src="https://files.mdnice.com/user/40549/dc5160be-77ed-4082-99d0-94dc529f4093.png"/></td>
</tr>
<tr>
<td>商城搜索<img src="https://files.mdnice.com/user/40549/f9a80d94-3e99-477d-a7e5-deb7269092ec.png"/></td>
<td>金刚位跳转<img src="https://files.mdnice.com/user/40549/a7f61d46-24e2-4197-8684-f741cb584bf9.png"/></td>
</tr>
<tr>
<td>商品详情<img src="https://files.mdnice.com/user/40549/d6da447b-cc18-4175-a879-482a14ba7892.png"/></td>
<td>商品分类<img src="https://files.mdnice.com/user/40549/b0b57fee-87c8-49e1-b870-afcf98408bde.png"/></td>
</tr>
<tr>
<td>商品sku选择<img src="https://files.mdnice.com/user/40549/2ea549b3-842c-4949-ba97-56c954206b0e.png"/></td>
<td>购物车查看<img src="https://files.mdnice.com/user/40549/0e5e0317-5caf-41d9-9171-831bc13decda.png"/></td>
</tr>
<tr>
<td>确认下单<img src="https://files.mdnice.com/user/40549/aa089cc8-301f-4b39-9caa-9eff9d5bb407.png"/></td>
<td>选择支付方式<img src="https://files.mdnice.com/user/40549/38aed1a1-7bfc-422c-a080-a919af91c306.png"/></td>
</tr>
<tr>
<td>下单成功<img src="https://files.mdnice.com/user/40549/f1e6bd71-8f70-442d-852d-803937b9d703.png"/></td>
<td>订单列表<img src="https://files.mdnice.com/user/40549/6c171780-2c94-48cf-bfe8-b4369745a567.png"/></td>
</tr>
<tr>
<td>商品评论<img src="https://files.mdnice.com/user/40549/590615c0-1167-44e9-9b8f-0fc7e11db654.png"/></td>
<td>我的页面<img src="https://files.mdnice.com/user/40549/fc26c2d0-6e71-4e76-aeff-8886f15be092.png"/></td>
</tr>
<tr>
<td>登录<img src="https://files.mdnice.com/user/40549/57bb81a0-92af-4db4-93c8-e83d87cc1a73.png"/></td>
<td>注册<img src="https://files.mdnice.com/user/40549/09c7c705-5839-4364-b908-e4231d31a8cc.png"/></td>
</tr>
</table>
# 演示gif
## 前台演示
![mall.gif](images%2Fmall.gif)
## 后台演示
![admin.gif](images%2Fadmin.gif)
# 文件目录

@ -3578,15 +3578,16 @@ INSERT INTO `sys_user_role` VALUES (110, 3346);
DROP TABLE IF EXISTS `tool_email_config`;
CREATE TABLE `tool_email_config` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`from_user` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '收件人',
`host` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '邮件服务器SMTP地址',
`pass` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '密码',
`port` int DEFAULT NULL COMMENT '端口',
`ssl_port` int DEFAULT NULL COMMENT 'ssl端口',
`user` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '发件者用户名',
`del_flag` tinyint(1) NOT NULL DEFAULT '0' COMMENT '逻辑删除 0存在 1删除',
`from_user` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '收件人',
`host` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '邮件服务器SMTP地址',
`pass` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '密码',
`port` int NULL DEFAULT NULL COMMENT '端口',
`ssl_port` int NULL DEFAULT NULL COMMENT 'ssl端口',
`user` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '发件者用户名',
`ssl_enable` tinyint(1) NOT NULL COMMENT '是否启用 ssl port 0不启用 1启用',
`del_flag` tinyint(1) NOT NULL DEFAULT 0 COMMENT '逻辑删除 0存在 1删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='邮箱配置';
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '邮箱配置' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of tool_email_config

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 MiB

@ -40,7 +40,7 @@ public class EmailController {
sendMailVO.setSubject(subject);
sendMailVO.setContent(content);
sendMailVO.setTos(Collections.singletonList(tos));
MailUtil.sendMail(emailConfig, sendMailVO, false, true);
MailUtil.sendMail(emailConfig, sendMailVO, false);
return R.success();
}
}

@ -46,7 +46,7 @@ public class EmailConfigController {
if (!mailConfigService.checkMailConfig(emailConfig)) {
return R.error(ReturnCodeEnum.TOOL_EMAIL_ERROR);
}
MailUtil.sendMail(emailConfig, mailVO, false, true);
MailUtil.sendMail(emailConfig, mailVO, false);
return R.success();
}
}

@ -44,7 +44,10 @@ public class EmailConfig implements Serializable {
*
*/
private String user;
/**
* ssl port 0 1
*/
private Integer sslEnable;
/**
* 01
*/

@ -1,6 +1,7 @@
package com.wayn.common.core.domain.vo;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.io.Serial;
@ -26,9 +27,10 @@ public class EmailConfigVO implements Serializable {
/**
* SMTP
*/
@NotBlank(message = "邮件服务器SMTP端口不能为空")
@NotNull(message = "邮件服务器SMTP端口不能为空")
private Integer port;
@NotNull(message = "邮件服务器SMTP SSL端口不能为空")
private Integer sslPort;
@NotBlank(message = "邮箱密钥不能为空")
@ -49,4 +51,9 @@ public class EmailConfigVO implements Serializable {
* 01
*/
private Integer delFlag;
/**
* ssl port 0 1
*/
private Integer sslEnable;
}

@ -15,6 +15,7 @@ import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.List;
import java.util.Objects;
import java.util.Properties;
/**
@ -23,7 +24,7 @@ import java.util.Properties;
@Slf4j
public class MailUtil {
public static void sendMail(EmailConfig emailConfig, SendMailVO mailVO, boolean isHtml, boolean ssl) {
public static void sendMail(EmailConfig emailConfig, SendMailVO mailVO, boolean isHtml) {
if (emailConfig == null) {
log.warn("emailConfig is null");
return;
@ -42,7 +43,7 @@ public class MailUtil {
Properties properties = System.getProperties();
properties.setProperty("mail.smtp.port", String.valueOf(emailConfig.getPort()));
// SSL加密
if (ssl) {
if (Objects.equals(emailConfig.getSslEnable(), 1)) {
MailSSLSocketFactory sf = new MailSSLSocketFactory();
sf.setTrustAllHosts(true);
properties.put("mail.smtp.ssl.enable", "true");

@ -176,7 +176,7 @@ public class LoginController {
sendMailVO.setSubject("mall商城注册通知");
sendMailVO.setContent("邮箱验证码:" + verCode);
sendMailVO.setTos(Collections.singletonList(registryObj.getEmail()));
MailUtil.sendMail(emailConfig, sendMailVO, false, true);
MailUtil.sendMail(emailConfig, sendMailVO, false);
});
return R.success().add("emailKey", key);
}

@ -109,7 +109,7 @@ public class UserController {
sendMailVO.setSubject("mall商城重置密码通知");
sendMailVO.setContent("邮箱验证码:" + verCode);
sendMailVO.setTos(Collections.singletonList(registryObj.getEmail()));
MailUtil.sendMail(emailConfig, sendMailVO, false, true);
MailUtil.sendMail(emailConfig, sendMailVO, false);
return R.success().add("key", key);
}

@ -36,7 +36,7 @@ public class EmailController {
sendMailVO.setSubject(subject);
sendMailVO.setContent(content);
sendMailVO.setTos(List.of(tos));
MailUtil.sendMail(emailConfig, sendMailVO, false, true);
MailUtil.sendMail(emailConfig, sendMailVO, false);
return R.success();
}
}

Loading…
Cancel
Save