update 格式化全部代码
This commit is contained in:
+9
-9
@@ -1,8 +1,8 @@
|
||||
package org.dromara.demo.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.mail.core.MailBuilder;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -26,9 +26,9 @@ public class MailSendController {
|
||||
/**
|
||||
* 发送邮件
|
||||
*
|
||||
* @param to 接收人
|
||||
* @param to 接收人
|
||||
* @param subject 标题
|
||||
* @param text 内容
|
||||
* @param text 内容
|
||||
*/
|
||||
@GetMapping("/sendSimpleMessage")
|
||||
public R<Void> sendSimpleMessage(String to, String subject, String text) {
|
||||
@@ -39,9 +39,9 @@ public class MailSendController {
|
||||
/**
|
||||
* 发送邮件(带附件)
|
||||
*
|
||||
* @param to 接收人
|
||||
* @param subject 标题
|
||||
* @param text 内容
|
||||
* @param to 接收人
|
||||
* @param subject 标题
|
||||
* @param text 内容
|
||||
*/
|
||||
@GetMapping("/sendMessageWithAttachment")
|
||||
public R<Void> sendMessageWithAttachment(String to, String subject, String text) {
|
||||
@@ -53,9 +53,9 @@ public class MailSendController {
|
||||
/**
|
||||
* 发送邮件(多附件)
|
||||
*
|
||||
* @param to 接收人
|
||||
* @param subject 标题
|
||||
* @param text 内容
|
||||
* @param to 接收人
|
||||
* @param subject 标题
|
||||
* @param text 内容
|
||||
*/
|
||||
@GetMapping("/sendMessageWithAttachments")
|
||||
public R<Void> sendMessageWithAttachments(String to, String subject, String text) {
|
||||
|
||||
+1
-1
@@ -1,10 +1,10 @@
|
||||
package org.dromara.demo.controller;
|
||||
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
|
||||
+1
-1
@@ -5,8 +5,8 @@ import com.baomidou.lock.LockInfo;
|
||||
import com.baomidou.lock.LockTemplate;
|
||||
import com.baomidou.lock.annotation.Lock4j;
|
||||
import com.baomidou.lock.executor.RedissonLockExecutor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package org.dromara.demo.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -20,7 +20,7 @@ public class RedisPubSubController {
|
||||
/**
|
||||
* 发布消息
|
||||
*
|
||||
* @param key 通道Key
|
||||
* @param key 通道Key
|
||||
* @param value 发送内容
|
||||
*/
|
||||
@GetMapping("/pub")
|
||||
|
||||
+2
-2
@@ -61,7 +61,7 @@ public class SmsController {
|
||||
* @param phone 手机号
|
||||
*/
|
||||
@GetMapping("/addBlacklist")
|
||||
public R<Object> addBlacklist(String phone){
|
||||
public R<Object> addBlacklist(String phone) {
|
||||
SmsBlend smsBlend = SmsFactory.getSmsBlend("config1");
|
||||
smsBlend.joinInBlacklist(phone);
|
||||
return R.ok();
|
||||
@@ -73,7 +73,7 @@ public class SmsController {
|
||||
* @param phone 手机号
|
||||
*/
|
||||
@GetMapping("/removeBlacklist")
|
||||
public R<Object> removeBlacklist(String phone){
|
||||
public R<Object> removeBlacklist(String phone) {
|
||||
SmsBlend smsBlend = SmsFactory.getSmsBlend("config1");
|
||||
smsBlend.removeFromBlacklist(phone);
|
||||
return R.ok();
|
||||
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package org.dromara.demo.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.demo.domain.TestDemo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.demo.mapper.TestDemoMapper;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
+7
-7
@@ -2,33 +2,33 @@ package org.dromara.demo.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.PageResult;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.utils.ValidatorUtils;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.core.validate.QueryGroup;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.excel.core.ExcelResult;
|
||||
import org.dromara.common.excel.utils.ExcelBuilder;
|
||||
import org.dromara.common.redis.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.PageResult;
|
||||
import org.dromara.common.redis.annotation.RepeatSubmit;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.demo.domain.TestDemo;
|
||||
import org.dromara.demo.domain.bo.TestDemoBo;
|
||||
import org.dromara.demo.domain.vo.TestDemoImportVo;
|
||||
import org.dromara.demo.domain.vo.TestDemoVo;
|
||||
import org.dromara.demo.service.ITestDemoService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
+3
-4
@@ -1,17 +1,16 @@
|
||||
package org.dromara.demo.controller;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.utils.MessageUtils;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
|
||||
/**
|
||||
* 测试国际化
|
||||
|
||||
+1
-1
@@ -1,10 +1,10 @@
|
||||
package org.dromara.demo.controller;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.sensitive.annotation.Sensitive;
|
||||
import org.dromara.common.sensitive.core.SensitiveStrategy;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
+15
-15
@@ -1,24 +1,24 @@
|
||||
package org.dromara.demo.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.excel.utils.ExcelBuilder;
|
||||
import org.dromara.common.redis.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.demo.domain.bo.TestTreeBo;
|
||||
import org.dromara.demo.domain.vo.TestTreeVo;
|
||||
import org.dromara.demo.service.ITestTreeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.excel.utils.ExcelBuilder;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.redis.annotation.RepeatSubmit;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.demo.domain.bo.TestTreeBo;
|
||||
import org.dromara.demo.domain.vo.TestTreeVo;
|
||||
import org.dromara.demo.service.ITestTreeService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.dromara.demo.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package org.dromara.demo.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import org.dromara.common.encrypt.annotation.EncryptField;
|
||||
import org.dromara.common.encrypt.enums.AlgorithmType;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.encrypt.annotation.EncryptField;
|
||||
import org.dromara.common.encrypt.enums.AlgorithmType;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
||||
+1
-2
@@ -1,10 +1,9 @@
|
||||
package org.dromara.demo.domain.vo;
|
||||
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.apache.fesod.sheet.annotation.ExcelProperty;
|
||||
import org.dromara.demo.domain.TestDemo;
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.dromara.demo.domain.vo;
|
||||
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.apache.fesod.sheet.annotation.ExcelIgnoreUnannotated;
|
||||
import org.apache.fesod.sheet.annotation.ExcelProperty;
|
||||
import org.apache.fesod.sheet.annotation.format.DateTimeFormat;
|
||||
@@ -8,8 +10,6 @@ import org.dromara.common.excel.annotation.ExcelRequired;
|
||||
import org.dromara.common.translation.annotation.Translation;
|
||||
import org.dromara.common.translation.constant.TransConstant;
|
||||
import org.dromara.demo.domain.TestDemo;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
-1
@@ -2,7 +2,6 @@ package org.dromara.demo.mapper;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.dromara.demo.domain.ShardingOrderItem;
|
||||
|
||||
|
||||
-1
@@ -2,7 +2,6 @@ package org.dromara.demo.mapper;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.dromara.demo.domain.ShardingOrder;
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.common.mybatis.annotation.DataColumn;
|
||||
import org.dromara.common.mybatis.annotation.DataPermission;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.demo.domain.TestDemo;
|
||||
import org.dromara.demo.domain.vo.TestDemoVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
|
||||
+5
-5
@@ -1,9 +1,9 @@
|
||||
package org.dromara.demo.mcp;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.mcp.core.McpClientTemplate;
|
||||
import org.dromara.common.mcp.core.McpResourceReadResult;
|
||||
import org.dromara.common.mcp.core.McpToolCallResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class McpDemoClientService {
|
||||
/**
|
||||
* 调用外部 MCP 工具接收数据。
|
||||
*
|
||||
* @param toolName 工具名称
|
||||
* @param toolName 工具名称
|
||||
* @param arguments 工具参数
|
||||
* @return 工具返回内容
|
||||
*/
|
||||
@@ -65,7 +65,7 @@ public class McpDemoClientService {
|
||||
* <p>
|
||||
* MCP 返回数据不建议直接入库,应先转换成业务 BO/DTO,再进入业务 Service。
|
||||
*
|
||||
* @param toolName 工具名称
|
||||
* @param toolName 工具名称
|
||||
* @param arguments 工具参数
|
||||
* @return 处理结果
|
||||
*/
|
||||
@@ -85,8 +85,8 @@ public class McpDemoClientService {
|
||||
* MCP 数据处理结果。
|
||||
*
|
||||
* @param sourceType 数据来源类型
|
||||
* @param handled 是否已处理
|
||||
* @param data MCP 原始返回数据
|
||||
* @param handled 是否已处理
|
||||
* @param data MCP 原始返回数据
|
||||
*/
|
||||
public record McpDemoHandleResult(
|
||||
String sourceType,
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package org.dromara.demo.service;
|
||||
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.PageResult;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.demo.domain.TestDemo;
|
||||
import org.dromara.demo.domain.bo.TestDemoBo;
|
||||
import org.dromara.demo.domain.vo.TestDemoVo;
|
||||
|
||||
+29
-29
@@ -211,35 +211,6 @@ public class ExportExcelServiceImpl implements IExportExcelService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟的数据库省市县
|
||||
*/
|
||||
@Data
|
||||
private static class DemoCityData {
|
||||
/**
|
||||
* 数据库id字段
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 数据库pid字段
|
||||
*/
|
||||
private Integer pid;
|
||||
/**
|
||||
* 数据库name字段
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* MyBatisPlus连带查询父数据
|
||||
*/
|
||||
private DemoCityData pData;
|
||||
|
||||
public DemoCityData(Integer id, Integer pid, String name) {
|
||||
this.id = id;
|
||||
this.pid = pid;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customExport(HttpServletResponse response) {
|
||||
ExcelBuilder.writer(ExportDemoVo.class).sheetName("自定义导出").toResponse(response, wrapper -> {
|
||||
@@ -291,4 +262,33 @@ public class ExportExcelServiceImpl implements IExportExcelService {
|
||||
// wrapper.write(excelDataList2, sheet2);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟的数据库省市县
|
||||
*/
|
||||
@Data
|
||||
private static class DemoCityData {
|
||||
/**
|
||||
* 数据库id字段
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 数据库pid字段
|
||||
*/
|
||||
private Integer pid;
|
||||
/**
|
||||
* 数据库name字段
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* MyBatisPlus连带查询父数据
|
||||
*/
|
||||
private DemoCityData pData;
|
||||
|
||||
public DemoCityData(Integer id, Integer pid, String name) {
|
||||
this.id = id;
|
||||
this.pid = pid;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -4,16 +4,16 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.PageResult;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.PageResult;
|
||||
import org.dromara.demo.domain.TestDemo;
|
||||
import org.dromara.demo.domain.bo.TestDemoBo;
|
||||
import org.dromara.demo.domain.vo.TestDemoVo;
|
||||
import org.dromara.demo.mapper.TestDemoMapper;
|
||||
import org.dromara.demo.service.ITestDemoService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
+1
-1
@@ -3,13 +3,13 @@ package org.dromara.demo.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.demo.domain.TestTree;
|
||||
import org.dromara.demo.domain.bo.TestTreeBo;
|
||||
import org.dromara.demo.domain.vo.TestTreeVo;
|
||||
import org.dromara.demo.mapper.TestTreeMapper;
|
||||
import org.dromara.demo.service.ITestTreeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -80,7 +80,7 @@ easy-es:
|
||||
# 兼容模式
|
||||
compatible: true
|
||||
# es连接地址+端口 格式必须为ip:port,如果是集群则可用逗号隔开
|
||||
address : localhost:9200
|
||||
address: localhost:9200
|
||||
# 默认为http
|
||||
schema: http
|
||||
# 注意ES建议使用账号认证 不使用会报警告日志
|
||||
|
||||
@@ -18,6 +18,16 @@ public class DemoUnitTest {
|
||||
@Value("${spring.application.name}")
|
||||
private String appName;
|
||||
|
||||
@BeforeAll
|
||||
public static void testBeforeAll() {
|
||||
System.out.println("@BeforeAll ==================");
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void testAfterAll() {
|
||||
System.out.println("@AfterAll ==================");
|
||||
}
|
||||
|
||||
@DisplayName("测试 @SpringBootTest @Test @DisplayName 注解")
|
||||
@Test
|
||||
public void testTest() {
|
||||
@@ -39,18 +49,12 @@ public class DemoUnitTest {
|
||||
System.out.println(appName);
|
||||
}
|
||||
|
||||
|
||||
@DisplayName("测试 @RepeatedTest 注解")
|
||||
@RepeatedTest(3)
|
||||
public void testRepeatedTest() {
|
||||
System.out.println(666);
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
public static void testBeforeAll() {
|
||||
System.out.println("@BeforeAll ==================");
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void testBeforeEach() {
|
||||
System.out.println("@BeforeEach ==================");
|
||||
@@ -61,9 +65,4 @@ public class DemoUnitTest {
|
||||
System.out.println("@AfterEach ==================");
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void testAfterAll() {
|
||||
System.out.println("@AfterAll ==================");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,14 @@ import java.util.stream.Stream;
|
||||
@DisplayName("带参数单元测试案例")
|
||||
public class ParamUnitTest {
|
||||
|
||||
public static Stream<String> getParam() {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("t1");
|
||||
list.add("t2");
|
||||
list.add("t3");
|
||||
return list.stream();
|
||||
}
|
||||
|
||||
@DisplayName("测试 @ValueSource 注解")
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"t1", "t2", "t3"})
|
||||
@@ -50,14 +58,6 @@ public class ParamUnitTest {
|
||||
System.out.println(str);
|
||||
}
|
||||
|
||||
public static Stream<String> getParam() {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("t1");
|
||||
list.add("t2");
|
||||
list.add("t3");
|
||||
return list.stream();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void testBeforeEach() {
|
||||
System.out.println("@BeforeEach ==================");
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.dromara.demo;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import org.dromara.demo.domain.ShardingOrder;
|
||||
import org.dromara.demo.mapper.ShardingOrderMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -27,19 +26,19 @@ class TOrderTest {
|
||||
page.setCurrent(3L);
|
||||
QueryWrapper<ShardingOrder> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByAsc("order_id");
|
||||
torderMapper.selectPage(page,queryWrapper);
|
||||
torderMapper.selectPage(page, queryWrapper);
|
||||
System.out.println(page.getTotal());
|
||||
for(ShardingOrder order : page.getRecords()){
|
||||
System.out.print(order.getTotalMoney()+" ");
|
||||
for (ShardingOrder order : page.getRecords()) {
|
||||
System.out.print(order.getTotalMoney() + " ");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void insert() {
|
||||
for(Long i = 1L; i <= 100L; i++){
|
||||
for (Long i = 1L; i <= 100L; i++) {
|
||||
ShardingOrder torder = new ShardingOrder();
|
||||
torder.setUserId(i);
|
||||
torder.setTotalMoney(100 + Integer.parseInt(i+""));
|
||||
torder.setTotalMoney(100 + Integer.parseInt(i + ""));
|
||||
torderMapper.insert(torder);
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -6,6 +6,7 @@ import org.springframework.boot.context.metrics.buffering.BufferingApplicationSt
|
||||
|
||||
/**
|
||||
* SpringBoot-MQ 案例项目
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@SpringBootApplication
|
||||
|
||||
+1
@@ -10,6 +10,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Rabbit回调
|
||||
*
|
||||
* @author JC
|
||||
*/
|
||||
|
||||
|
||||
+14
-14
@@ -20,7 +20,7 @@ public class RabbitConfig {
|
||||
/**
|
||||
* 创建交换机
|
||||
* ExchangeBuilder有四种交换机模式
|
||||
* Direct Exchange:直连交换机,根据Routing Key(路由键)进行投递到不同队列。
|
||||
* Direct Exchange:直连交换机,根据Routing Key(路由键)进行投递到不同队列。
|
||||
* Fanout Exchange:扇形交换机,采用广播模式,根据绑定的交换机,路由到与之对应的所有队列。
|
||||
* Topic Exchange:主题交换机,对路由键进行模式匹配后进行投递,符号#表示一个或多个词,*表示一个词。
|
||||
* Header Exchange:头交换机,不处理路由键。而是根据发送的消息内容中的headers属性进行匹配。
|
||||
@@ -31,24 +31,24 @@ public class RabbitConfig {
|
||||
return new TopicExchange(EXCHANGE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建队列
|
||||
* durable 队列是否持久化 队列调用此方法就是持久化 可查看方法的源码
|
||||
* deliveryMode 消息是否持久化(1 不持久化,2 持久化)
|
||||
**/
|
||||
/**
|
||||
* 创建队列
|
||||
* durable 队列是否持久化 队列调用此方法就是持久化 可查看方法的源码
|
||||
* deliveryMode 消息是否持久化(1 不持久化,2 持久化)
|
||||
**/
|
||||
@Bean
|
||||
public Queue queue() {
|
||||
return new Queue(QUEUE_NAME, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定交换机和队列
|
||||
* bing 方法参数可以是队列和交换机
|
||||
* to 方法参数必须是交换机
|
||||
* with 方法参数是路由Key 这里是以rabbit.开头
|
||||
* noargs 就是不要参数的意思
|
||||
* 这个方法的意思是把rabbit开头的消息 和 上面的队列 和 上面的交换机绑定
|
||||
**/
|
||||
/**
|
||||
* 绑定交换机和队列
|
||||
* bing 方法参数可以是队列和交换机
|
||||
* to 方法参数必须是交换机
|
||||
* with 方法参数是路由Key 这里是以rabbit.开头
|
||||
* noargs 就是不要参数的意思
|
||||
* 这个方法的意思是把rabbit开头的消息 和 上面的队列 和 上面的交换机绑定
|
||||
**/
|
||||
@Bean
|
||||
public Binding binding(Queue queue, TopicExchange exchange) {
|
||||
return BindingBuilder.bind(queue).to(exchange).with(ROUTING_KEY);
|
||||
|
||||
+5
-5
@@ -20,15 +20,15 @@ public class RabbitConsumer {
|
||||
*/
|
||||
@RabbitListener(queues = RabbitConfig.QUEUE_NAME)
|
||||
public void listenQueue(Message message) {
|
||||
log.info("【消费者】Start consuming data:{}",new String(message.getBody()));
|
||||
log.info("【消费者】Start consuming data:{}", new String(message.getBody()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理延迟队列消息
|
||||
*/
|
||||
@RabbitListener(queues = RabbitTtlQueueConfig.DELAY_QUEUE_NAME)
|
||||
public void receiveDelayMessage(String message){
|
||||
log.info("【消费者】Received delayed message:{}",message);
|
||||
public void receiveDelayMessage(String message) {
|
||||
log.info("【消费者】Received delayed message:{}", message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,7 @@ public class RabbitConsumer {
|
||||
* 它会被自动转发到死信队列中,以便后续的特殊处理或重新尝试。
|
||||
*/
|
||||
@RabbitListener(queues = RabbitTtlQueueConfig.DEAD_LETTER_QUEUE)
|
||||
public void receiveDeadMessage(String message){
|
||||
log.info("【消费者】Received dead message:{}",message);
|
||||
public void receiveDeadMessage(String message) {
|
||||
log.info("【消费者】Received dead message:{}", message);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -12,11 +12,11 @@ import org.springframework.stereotype.Component;
|
||||
@Slf4j
|
||||
@Component
|
||||
@RocketMQMessageListener(topic = "transaction-topic", consumerGroup = "transaction-group")
|
||||
public class TransactionRocketConsumer implements RocketMQListener<String> {
|
||||
public class TransactionRocketConsumer implements RocketMQListener<String> {
|
||||
|
||||
@Override
|
||||
public void onMessage(String message) {
|
||||
log.info("【消费者】===>接收事务消息:{}",message);
|
||||
log.info("【消费者】===>接收事务消息:{}", message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -47,7 +47,7 @@ public class PushMessageController {
|
||||
* 需要手动创建相关的Topic和group
|
||||
*/
|
||||
@GetMapping("/rocket/send")
|
||||
public void rocketSend(){
|
||||
public void rocketSend() {
|
||||
normalRocketProducer.sendMessage();
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class PushMessageController {
|
||||
* rocketmq 事务消息
|
||||
*/
|
||||
@GetMapping("/rocket/transaction")
|
||||
public void rocketTransaction(){
|
||||
public void rocketTransaction() {
|
||||
transactionRocketProducer.sendTransactionMessage();
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class PushMessageController {
|
||||
* kafka 发送消息
|
||||
*/
|
||||
@GetMapping("/kafka/send")
|
||||
public void kafkaSend(){
|
||||
public void kafkaSend() {
|
||||
normalKafkaProducer.sendKafkaMsg();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user