From 188dc1e55e3abbfb00397d67e2b4eed52cead356 Mon Sep 17 00:00:00 2001 From: ageerle <ageerle@163.com> Date: 星期一, 14 四月 2025 17:23:33 +0800 Subject: [PATCH] feat: mcp 测试版本 --- ruoyi-common/ruoyi-common-chat/src/main/java/org/ruoyi/common/chat/request/ChatRequest.java | 2 ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/SseServiceImpl.java | 62 +++++++++--- ruoyi-modules/ruoyi-chat/pom.xml | 6 - ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/util/SSEUtil.java | 3 ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/OllamaServiceImpl.java | 73 -------------- ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/ChatCostServiceImpl.java | 7 + ruoyi-modules/ruoyi-generator/src/main/java/org/ruoyi/generator/domain/GenTableColumn.java | 16 +- ruoyi-admin/src/main/resources/application.yml | 3 ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/listener/SSEEventSourceListener.java | 29 ++--- /dev/null | 3 ruoyi-modules-api/ruoyi-chat-api/pom.xml | 9 - ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/IChatCostService.java | 5 + ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/IChatService.java | 2 ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/OpenAIServiceImpl.java | 78 +++++++++++++++ 14 files changed, 169 insertions(+), 129 deletions(-) diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 84be163..d51ac50 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -322,6 +322,9 @@ spring: ai: + openai: + api-key: sk-xX + base-url: https://api.pandarobot.chat/ ollama: base-url: http://localhost:11434 mcp: diff --git a/ruoyi-common/ruoyi-common-chat/src/main/java/org/ruoyi/common/chat/request/ChatRequest.java b/ruoyi-common/ruoyi-common-chat/src/main/java/org/ruoyi/common/chat/request/ChatRequest.java index 97b8958..789f3de 100644 --- a/ruoyi-common/ruoyi-common-chat/src/main/java/org/ruoyi/common/chat/request/ChatRequest.java +++ b/ruoyi-common/ruoyi-common-chat/src/main/java/org/ruoyi/common/chat/request/ChatRequest.java @@ -49,7 +49,7 @@ /** * 鐢ㄦ埛id */ - private String userId; + private Long userId; /** * 搴旂敤ID diff --git a/ruoyi-modules-api/ruoyi-chat-api/pom.xml b/ruoyi-modules-api/ruoyi-chat-api/pom.xml index 33af693..e2ed34a 100644 --- a/ruoyi-modules-api/ruoyi-chat-api/pom.xml +++ b/ruoyi-modules-api/ruoyi-chat-api/pom.xml @@ -60,17 +60,12 @@ <!-- <dependency>--> <!-- <groupId>org.springframework.ai</groupId>--> -<!-- <artifactId>spring-ai-mcp</artifactId>--> -<!-- </dependency>--> - -<!-- <dependency>--> -<!-- <groupId>org.springframework.ai</groupId>--> -<!-- <artifactId>spring-ai-openai</artifactId>--> +<!-- <artifactId>spring-ai-ollama-spring-boot-starter</artifactId>--> <!-- </dependency>--> <dependency> <groupId>org.springframework.ai</groupId> - <artifactId>spring-ai-ollama-spring-boot-starter</artifactId> + <artifactId>spring-ai-openai-spring-boot-starter</artifactId> </dependency> </dependencies> diff --git a/ruoyi-modules/ruoyi-chat/pom.xml b/ruoyi-modules/ruoyi-chat/pom.xml index d8824b2..2a14fb1 100644 --- a/ruoyi-modules/ruoyi-chat/pom.xml +++ b/ruoyi-modules/ruoyi-chat/pom.xml @@ -113,12 +113,6 @@ <groupId>org.ruoyi</groupId> <artifactId>ruoyi-system-api</artifactId> </dependency> - <dependency> - <groupId>org.springframework.ai</groupId> - <artifactId>spring-ai-ollama</artifactId> - <version>1.0.0-M6</version> - <scope>compile</scope> - </dependency> </dependencies> diff --git a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/listener/SSEEventSourceListener.java b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/listener/SSEEventSourceListener.java index 83f2700..51d67cf 100644 --- a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/listener/SSEEventSourceListener.java +++ b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/listener/SSEEventSourceListener.java @@ -18,7 +18,7 @@ import org.ruoyi.common.core.utils.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; +import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; import java.util.Objects; @@ -34,13 +34,13 @@ public class SSEEventSourceListener extends EventSourceListener { @Autowired(required = false) - public SSEEventSourceListener(ResponseBodyEmitter emitter) { + public SSEEventSourceListener(SseEmitter emitter) { this.emitter = emitter; } - private ResponseBodyEmitter emitter; + private SseEmitter emitter; - private StringBuilder stringBuffer; + private StringBuilder stringBuffer = new StringBuilder(); private String modelName; @@ -61,7 +61,6 @@ @Override public void onEvent(@NotNull EventSource eventSource, String id, String type, String data) { try { - if ("[DONE]".equals(data)) { //鎴愬姛鍝嶅簲 emitter.complete(); @@ -72,25 +71,23 @@ chatCostService.deductToken(chatRequest); return; } - // 瑙f瀽杩斿洖鍐呭 + ObjectMapper mapper = new ObjectMapper(); ChatCompletionResponse completionResponse = mapper.readValue(data, ChatCompletionResponse.class); if(completionResponse == null || CollectionUtil.isEmpty(completionResponse.getChoices())){ return; } Object content = completionResponse.getChoices().get(0).getDelta().getContent(); - if(content == null){ - content = completionResponse.getChoices().get(0).getDelta().getReasoningContent(); - if(content == null) return; + + if(content != null ){ + if(StringUtils.isEmpty(modelName)){ + modelName = completionResponse.getModel(); + } + stringBuffer.append(content); + emitter.send(content); } - if(StringUtils.isEmpty(modelName)){ - modelName = completionResponse.getModel(); - } - stringBuffer.append(content); - emitter.send(data); } catch (Exception e) { - log.error("sse淇℃伅鎺ㄩ�佸け璐}鍐呭锛歿}",e.getMessage(),data); - eventSource.cancel(); + emitter.completeWithError(e); } } diff --git a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/IChatCostService.java b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/IChatCostService.java index 7d3bb3a..73c0c44 100644 --- a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/IChatCostService.java +++ b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/IChatCostService.java @@ -40,4 +40,9 @@ * 鍒ゆ柇鐢ㄦ埛鏄惁浠樿垂 */ void checkUserGrade(); + + /** + * 鑾峰彇鐧诲綍鐢ㄦ埛id + */ + Long getUserId(); } diff --git a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/IChatService.java b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/IChatService.java index 1fbadd4..649fce1 100644 --- a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/IChatService.java +++ b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/IChatService.java @@ -22,5 +22,5 @@ * 瀹㈡埛绔彂閫佹秷鎭埌鏈嶅姟绔� * @param chatRequest 璇锋眰瀵硅薄 */ - SseEmitter mcpChat(ChatRequest chatRequest,SseEmitter emitter); + void mcpChat(ChatRequest chatRequest,SseEmitter emitter); } diff --git a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/ChatCostServiceImpl.java b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/ChatCostServiceImpl.java index 272ebe5..7b7bb23 100644 --- a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/ChatCostServiceImpl.java +++ b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/ChatCostServiceImpl.java @@ -6,6 +6,7 @@ import org.ruoyi.chat.enums.BillingType; import org.ruoyi.chat.enums.UserGradeType; import org.ruoyi.chat.service.chat.IChatCostService; +import org.ruoyi.common.chat.config.LocalCache; import org.ruoyi.common.chat.request.ChatRequest; import org.ruoyi.common.chat.utils.TikTokensUtil; import org.ruoyi.common.core.domain.model.LoginUser; @@ -96,6 +97,12 @@ chatToken.setUserId(chatMessageBo.getUserId()); chatTokenService.editToken(chatToken); } + Object userId = LocalCache.CACHE.get("userId"); + if(userId!=null){ + chatMessageBo.setUserId((Long) userId); + }else { + chatMessageBo.setUserId(getUserId()); + } // 淇濆瓨娑堟伅璁板綍 chatMessageService.insertByBo(chatMessageBo); } diff --git a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/OllamaServiceImpl.java b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/OllamaServiceImpl.java index aace823..f06461b 100644 --- a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/OllamaServiceImpl.java +++ b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/OllamaServiceImpl.java @@ -7,24 +7,13 @@ import io.github.ollama4j.models.chat.OllamaChatRequestModel; import io.github.ollama4j.models.generate.OllamaStreamHandler; import lombok.extern.slf4j.Slf4j; -import org.ruoyi.chat.service.chat.IChatService; import org.ruoyi.chat.util.SSEUtil; import org.ruoyi.common.chat.entity.chat.Message; import org.ruoyi.common.chat.request.ChatRequest; import org.ruoyi.domain.vo.ChatModelVo; import org.ruoyi.service.IChatModelService; -import org.springframework.ai.chat.client.ChatClient; -import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor; -import org.springframework.ai.chat.memory.ChatMemory; -import org.springframework.ai.chat.memory.InMemoryChatMemory; -import org.springframework.ai.chat.messages.UserMessage; -import org.springframework.ai.ollama.api.OllamaModel; -import org.springframework.ai.ollama.api.OllamaOptions; -import org.springframework.ai.tool.ToolCallbackProvider; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; import org.springframework.stereotype.Service; - import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; import java.io.IOException; @@ -35,27 +24,11 @@ @Service @Slf4j -public class OllamaServiceImpl implements IChatService { +public class OllamaServiceImpl { - @Autowired - private IChatModelService chatModelService; + @Autowired + private IChatModelService chatModelService; - private final ChatClient chatClient; - - private final ChatMemory chatMemory = new InMemoryChatMemory(); - - public OllamaServiceImpl(ChatClient.Builder chatClientBuilder,ToolCallbackProvider tools) { - this.chatClient = chatClientBuilder - .defaultTools(tools) - .defaultOptions( - OllamaOptions.builder() - .model(OllamaModel.QWEN_2_5_7B) - .temperature(0.4) - .build()) - .build(); - } - - @Override public SseEmitter chat(ChatRequest chatRequest,SseEmitter emitter) { ChatModelVo chatModelVo = chatModelService.selectModelByName(chatRequest.getModel()); String host = chatModelVo.getApiHost(); @@ -100,44 +73,4 @@ return emitter; } - @Override - public SseEmitter mcpChat(ChatRequest chatRequest, SseEmitter emitter) { - List<Message> msgList = chatRequest.getMessages(); - // 娣诲姞璁板繂 - for (int i = 0; i < msgList.size(); i++) { - org.springframework.ai.chat.messages.Message springAiMessage = new UserMessage(msgList.get(i).getContent().toString()); - chatMemory.add(String.valueOf(i),springAiMessage); - } - var messageChatMemoryAdvisor = new MessageChatMemoryAdvisor(chatMemory, chatRequest.getUserId(), 10); - - this.chatClient.prompt(chatRequest.getPrompt()) - .advisors(messageChatMemoryAdvisor) - .stream() - .chatResponse() - .subscribe( - chatResponse -> { - try { - emitter.send(chatResponse, MediaType.APPLICATION_JSON); - } catch (IOException e) { - e.printStackTrace(); - } - }, - error -> { - try { - emitter.completeWithError(error); - } catch (Exception e) { - e.printStackTrace(); - } - }, - () -> { - try { - emitter.complete(); - } catch (Exception e) { - e.printStackTrace(); - } - } - ); - - return emitter; - } } diff --git a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/OpenAIServiceImpl.java b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/OpenAIServiceImpl.java new file mode 100644 index 0000000..f2d1211 --- /dev/null +++ b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/OpenAIServiceImpl.java @@ -0,0 +1,78 @@ +package org.ruoyi.chat.service.chat.impl; + +import lombok.extern.slf4j.Slf4j; +import org.ruoyi.chat.service.chat.IChatService; +import org.ruoyi.common.chat.entity.chat.Message; +import org.ruoyi.common.chat.request.ChatRequest; +import org.springframework.ai.chat.client.ChatClient; +import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor; +import org.springframework.ai.chat.memory.ChatMemory; +import org.springframework.ai.chat.memory.InMemoryChatMemory; +import org.springframework.ai.chat.messages.UserMessage; +import org.springframework.ai.openai.OpenAiChatOptions; +import org.springframework.ai.tool.ToolCallbackProvider; +import org.springframework.stereotype.Service; +import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; +import reactor.core.publisher.Flux; +import reactor.core.scheduler.Schedulers; + +import java.io.IOException; +import java.util.List; + + +@Service +@Slf4j +public class OpenAIServiceImpl implements IChatService { + + private final ChatClient chatClient; + + private final ChatMemory chatMemory = new InMemoryChatMemory(); + + + public OpenAIServiceImpl(ChatClient.Builder chatClientBuilder, ToolCallbackProvider tools) { + this.chatClient = chatClientBuilder + .defaultTools(tools) + .defaultOptions( + OpenAiChatOptions.builder() + .model("gpt-4o-mini") + .temperature(0.4) + .build()) + .build(); + } + + @Override + public SseEmitter chat(ChatRequest chatRequest,SseEmitter emitter) { + return emitter; + } + + @Override + public void mcpChat(ChatRequest chatRequest, SseEmitter emitter) { + List<Message> msgList = chatRequest.getMessages(); + // 娣诲姞璁板繂 + for (int i = 0; i < msgList.size(); i++) { + org.springframework.ai.chat.messages.Message springAiMessage = new UserMessage(msgList.get(i).getContent().toString()); + chatMemory.add(String.valueOf(i), springAiMessage); + } + var messageChatMemoryAdvisor = new MessageChatMemoryAdvisor(chatMemory, chatRequest.getUserId().toString(), 10); + + Flux<String> content = chatClient + .prompt(chatRequest.getPrompt()) + .advisors(messageChatMemoryAdvisor) + .stream().content(); + + content.publishOn(Schedulers.boundedElastic()) + .doOnNext(text -> { + try { + emitter.send(text); + } catch (IOException e) { + emitter.completeWithError(e); + } + }) + .doOnError(error -> { + log.error("Error in SSE stream: ", error); + emitter.completeWithError(error); + }) + .doOnComplete(emitter::complete) + .subscribe(); + } +} diff --git a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/SseServiceImpl.java b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/SseServiceImpl.java index c06fa44..4f5dcc5 100644 --- a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/SseServiceImpl.java +++ b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/service/chat/impl/SseServiceImpl.java @@ -11,11 +11,13 @@ import lombok.extern.slf4j.Slf4j; import okhttp3.*; +import org.ruoyi.chat.config.ChatConfig; +import org.ruoyi.chat.listener.SSEEventSourceListener; import org.ruoyi.chat.service.chat.IChatCostService; import org.ruoyi.chat.service.chat.IChatService; import org.ruoyi.chat.service.chat.ISseService; import org.ruoyi.chat.util.IpUtil; -import org.ruoyi.chat.util.SSEUtil; +import org.ruoyi.common.chat.config.LocalCache; import org.ruoyi.common.chat.request.ChatRequest; import org.ruoyi.common.chat.entity.Tts.TextToSpeech; import org.ruoyi.common.chat.entity.chat.ChatCompletion; @@ -33,7 +35,9 @@ import org.ruoyi.common.redis.utils.RedisUtils; +import org.ruoyi.domain.vo.ChatModelVo; import org.ruoyi.service.EmbeddingService; +import org.ruoyi.service.IChatModelService; import org.ruoyi.service.VectorStoreService; import org.springframework.core.io.InputStreamResource; import org.springframework.core.io.Resource; @@ -74,27 +78,35 @@ private final IChatService chatService; + private final IChatModelService chatModelService; private static final String requestIdTemplate = "company-%d"; private static final ObjectMapper mapper = new ObjectMapper(); + private final ChatConfig chatConfig; + @Override public SseEmitter sseChat(ChatRequest chatRequest, HttpServletRequest request) { - SseEmitter sseEmitter = new SseEmitter(0L); + SseEmitter sseEmitter = new SseEmitter(); try { // 鏋勫缓娑堟伅鍒楄〃澧炲姞鑱旂綉銆佺煡璇嗗簱绛夊唴瀹� buildChatMessageList(chatRequest); + if (!StpUtil.isLogin()) { + // 鏈櫥褰曠敤鎴烽檺鍒跺璇濇鏁� + checkUnauthenticatedUserChatLimit(request); + }else { + LocalCache.CACHE.put("userId", chatCostService.getUserId()); + + chatRequest.setUserId(chatCostService.getUserId()); + // 淇濆瓨娑堟伅璁板綍 骞舵墸闄よ垂鐢� + // chatCostService.deductToken(chatRequest); + } // 鏍规嵁妯″瀷鍚嶇О鍓嶇紑璋冪敤涓嶅悓鐨勫鐞嗛�昏緫 switchModelAndHandle(chatRequest,sseEmitter); - // 鏈櫥褰曠敤鎴烽檺鍒跺璇濇鏁� - checkUnauthenticatedUserChatLimit(request); - // 淇濆瓨娑堟伅璁板綍 骞舵墸闄よ垂鐢� - chatCostService.deductToken(chatRequest); } catch (Exception e) { - String message = e.getMessage(); - SSEUtil.sendErrorEvent(sseEmitter, message); - return sseEmitter; + log.error(e.getMessage(),e); + sseEmitter.completeWithError(e); } return sseEmitter; } @@ -106,8 +118,7 @@ * @throws ServiceException 濡傛灉褰撴棩鍏嶈垂娆℃暟宸茬敤瀹� */ public void checkUnauthenticatedUserChatLimit(HttpServletRequest request) throws ServiceException { - // 鏈櫥褰曠敤鎴烽檺鍒跺璇濇鏁� - if (!StpUtil.isLogin()) { + String clientIp = IpUtil.getClientIp(request); // 璁垮姣忓ぉ榛樿鍙兘瀵硅瘽5娆� int timeWindowInSeconds = 5; @@ -125,13 +136,14 @@ count++; RedisUtils.setCacheObject(redisKey, count); } - } + } /** * 鏍规嵁妯″瀷鍚嶇О鍓嶇紑璋冪敤涓嶅悓鐨勫鐞嗛�昏緫 */ private void switchModelAndHandle(ChatRequest chatRequest,SseEmitter emitter) { + SSEEventSourceListener openAIEventSourceListener = new SSEEventSourceListener(emitter); String model = chatRequest.getModel(); // 濡傛灉妯″瀷鍚嶇О浠llama寮�澶达紝鍒欒皟鐢╫llama涓儴缃茬殑鏈湴妯″瀷 if (model.startsWith("ollama-")) { @@ -142,8 +154,24 @@ } else { throw new IllegalArgumentException("Invalid ollama model name: " + chatRequest.getModel()); } - } else if (model.startsWith("gpt-4-gizmo")) { - chatRequest.setModel("gpt-4-gizmo"); + } else { + + if (model.startsWith("gpt-4-gizmo")) { + chatRequest.setModel("gpt-4-gizmo"); + } + ChatModelVo chatModelVo = chatModelService.selectModelByName(chatRequest.getModel()); + //openAiStreamClient = chatConfig.createOpenAiStreamClient(chatModelVo.getApiHost(), chatModelVo.getApiKey()); + + ChatCompletion completion = ChatCompletion + .builder() + .messages(chatRequest.getMessages()) + .model(chatRequest.getModel()) + .temperature(0.2) + .topP(1.0) + .stream(true) + .build(); + openAiStreamClient.streamChatCompletion(completion, openAIEventSourceListener); + } } @@ -151,9 +179,10 @@ * 鏋勫缓娑堟伅鍒楄〃 */ private void buildChatMessageList(ChatRequest chatRequest){ + ChatModelVo chatModelVo = chatModelService.selectModelByName(chatRequest.getModel()); // 鑾峰彇瀵硅瘽娑堟伅鍒楄〃 List<Message> messages = chatRequest.getMessages(); - String sysPrompt = chatRequest.getSysPrompt(); + String sysPrompt = chatModelVo.getSystemPrompt(); if(StringUtils.isEmpty(sysPrompt)){ sysPrompt ="浣犳槸涓�涓敱RuoYI-AI寮�鍙戠殑浜哄伐鏅鸿兘鍔╂墜锛屽悕瀛楀彨鐔婄尗鍔╂墜銆備綘鎿呴暱涓嫳鏂囧璇濓紝鑳藉鐞嗚В骞跺鐞嗗悇绉嶉棶棰橈紝鎻愪緵瀹夊叏銆佹湁甯姪銆佸噯纭殑鍥炵瓟銆�" + "褰撳墠鏃堕棿锛�"+ DateUtils.getDate(); @@ -162,8 +191,9 @@ Message sysMessage = Message.builder().content(sysPrompt).role(Message.Role.SYSTEM).build(); messages.add(0,sysMessage); + chatRequest.setSysPrompt(sysPrompt); // 鏌ヨ鍚戦噺搴撶浉鍏充俊鎭姞鍏ュ埌涓婁笅鏂� - if(chatRequest.getKid()!=null){ + if(StringUtils.isNotEmpty(chatRequest.getKid())){ List<Message> knMessages = new ArrayList<>(); String content = messages.get(messages.size() - 1).getContent().toString(); List<String> nearestList; diff --git a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/util/SSEUtil.java b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/util/SSEUtil.java index 21f183a..b429a6c 100644 --- a/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/util/SSEUtil.java +++ b/ruoyi-modules/ruoyi-chat/src/main/java/org/ruoyi/chat/util/SSEUtil.java @@ -1,6 +1,7 @@ package org.ruoyi.chat.util; import lombok.extern.slf4j.Slf4j; +import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; import java.io.IOException; @@ -19,7 +20,7 @@ * @param sseEmitter sse浜嬩欢瀵硅薄 * @param errorMessage 閿欒淇℃伅 */ - public static void sendErrorEvent(SseEmitter sseEmitter, String errorMessage) { + public static void sendErrorEvent(ResponseBodyEmitter sseEmitter, String errorMessage) { SseEmitter.SseEventBuilder event = SseEmitter.event() .name("error") .data(errorMessage); diff --git a/ruoyi-modules/ruoyi-demo/pom.xml b/ruoyi-modules/ruoyi-demo/pom.xml deleted file mode 100644 index 7aeb58c..0000000 --- a/ruoyi-modules/ruoyi-demo/pom.xml +++ /dev/null @@ -1,99 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-modules</artifactId> - <version>${revision}</version> - <relativePath>../pom.xml</relativePath> - </parent> - <modelVersion>4.0.0</modelVersion> - - <artifactId>ruoyi-demo</artifactId> - - <description> - demo妯″潡 - </description> - - <dependencies> - - <!-- 閫氱敤宸ュ叿--> - <dependency> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-common-core</artifactId> - </dependency> - - <dependency> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-common-doc</artifactId> - </dependency> - - <dependency> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-common-sms</artifactId> - </dependency> - - <dependency> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-common-mail</artifactId> - </dependency> - - <dependency> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-common-redis</artifactId> - </dependency> - - <dependency> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-common-idempotent</artifactId> - </dependency> - - <dependency> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-common-mybatis</artifactId> - </dependency> - - <dependency> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-common-log</artifactId> - </dependency> - - <dependency> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-common-excel</artifactId> - </dependency> - - <dependency> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-common-web</artifactId> - </dependency> - - <dependency> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-common-ratelimiter</artifactId> - </dependency> - - <dependency> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-common-translation</artifactId> - </dependency> - - <dependency> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-common-sensitive</artifactId> - </dependency> - - <dependency> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-common-encrypt</artifactId> - </dependency> - - <dependency> - <groupId>org.ruoyi</groupId> - <artifactId>ruoyi-common-tenant</artifactId> - </dependency> - - </dependencies> - -</project> diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/MailController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/MailController.java deleted file mode 100644 index 4603ae3..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/MailController.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.ruoyi.demo.controller; - -import lombok.RequiredArgsConstructor; -import org.ruoyi.common.core.domain.R; -import org.ruoyi.common.mail.utils.MailUtils; -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 java.io.File; - - -/** - * 閭欢鍙戦�佹渚� - * - * @author Michelle.Chung - */ -@Validated -@RequiredArgsConstructor -@RestController -@RequestMapping("/demo/mail") -public class MailController { - - /** - * 鍙戦�侀偖浠� - * - * @param to 鎺ユ敹浜� - * @param subject 鏍囬 - * @param text 鍐呭 - */ - @GetMapping("/sendSimpleMessage") - public R<Void> sendSimpleMessage(String to, String subject, String text) { - MailUtils.sendText(to, subject, text); - return R.ok(); - } - - /** - * 鍙戦�侀偖浠讹紙甯﹂檮浠讹級 - * - * @param to 鎺ユ敹浜� - * @param subject 鏍囬 - * @param text 鍐呭 - * @param filePath 闄勪欢璺緞 - */ - @GetMapping("/sendMessageWithAttachment") - public R<Void> sendMessageWithAttachment(String to, String subject, String text, String filePath) { - MailUtils.sendText(to, subject, text, new File(filePath)); - return R.ok(); - } - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/RedisCacheController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/RedisCacheController.java deleted file mode 100644 index bd9e083..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/RedisCacheController.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.ruoyi.demo.controller; - -import lombok.RequiredArgsConstructor; -import org.ruoyi.common.core.constant.CacheNames; -import org.ruoyi.common.core.domain.R; -import org.ruoyi.common.redis.utils.RedisUtils; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.CachePut; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.time.Duration; - -/** - * spring-cache 婕旂ず妗堜緥 - * - * @author Lion Li - */ -// 绫荤骇鍒� 缂撳瓨缁熶竴閰嶇疆 -//@CacheConfig(cacheNames = CacheNames.DEMO_CACHE) -@RequiredArgsConstructor -@RestController -@RequestMapping("/demo/cache") -public class RedisCacheController { - - /** - * 娴嬭瘯 @Cacheable - * <p> - * 琛ㄧず杩欎釜鏂规硶鏈変簡缂撳瓨鐨勫姛鑳�,鏂规硶鐨勮繑鍥炲�间細琚紦瀛樹笅鏉� - * 涓嬩竴娆¤皟鐢ㄨ鏂规硶鍓�,浼氬幓妫�鏌ユ槸鍚︾紦瀛樹腑宸茬粡鏈夊�� - * 濡傛灉鏈夊氨鐩存帴杩斿洖,涓嶈皟鐢ㄦ柟娉� - * 濡傛灉娌℃湁,灏辫皟鐢ㄦ柟娉�,鐒跺悗鎶婄粨鏋滅紦瀛樿捣鏉� - * 杩欎釜娉ㄨВ銆屼竴鑸敤鍦ㄦ煡璇㈡柟娉曚笂銆� - * <p> - * 閲嶇偣璇存槑: 缂撳瓨娉ㄨВ涓ヨ皑涓庡叾浠栫瓫閫夋暟鎹姛鑳戒竴璧蜂娇鐢� - * 渚嬪: 鏁版嵁鏉冮檺娉ㄨВ 浼氶�犳垚 缂撳瓨鍑荤┛ 涓� 鏁版嵁涓嶄竴鑷撮棶棰� - * <p> - * cacheNames 鍛藉悕瑙勫垯 鏌ョ湅 {@link CacheNames} 娉ㄩ噴 鏀寔澶氬弬鏁� - */ - @Cacheable(cacheNames = "demo:cache#60s#10m#20", key = "#key", condition = "#key != null") - @GetMapping("/test1") - public R<String> test1(String key, String value) { - return R.ok("鎿嶄綔鎴愬姛", value); - } - - /** - * 娴嬭瘯 @CachePut - * <p> - * 鍔犱簡@CachePut娉ㄨВ鐨勬柟娉�,浼氭妸鏂规硶鐨勮繑鍥炲�紁ut鍒扮紦瀛橀噷闈㈢紦瀛樿捣鏉�,渚涘叾瀹冨湴鏂逛娇鐢� - * 瀹冦�岄�氬父鐢ㄥ湪鏂板鎴栬�呭疄鏃舵洿鏂版柟娉曚笂銆� - * <p> - * cacheNames 鍛藉悕瑙勫垯 鏌ョ湅 {@link CacheNames} 娉ㄩ噴 鏀寔澶氬弬鏁� - */ - @CachePut(cacheNames = CacheNames.DEMO_CACHE, key = "#key", condition = "#key != null") - @GetMapping("/test2") - public R<String> test2(String key, String value) { - return R.ok("鎿嶄綔鎴愬姛", value); - } - - /** - * 娴嬭瘯 @CacheEvict - * <p> - * 浣跨敤浜咰acheEvict娉ㄨВ鐨勬柟娉�,浼氭竻绌烘寚瀹氱紦瀛� - * 銆屼竴鑸敤鍦ㄥ垹闄ょ殑鏂规硶涓娿�� - * <p> - * cacheNames 鍛藉悕瑙勫垯 鏌ョ湅 {@link CacheNames} 娉ㄩ噴 鏀寔澶氬弬鏁� - */ - @CacheEvict(cacheNames = CacheNames.DEMO_CACHE, key = "#key", condition = "#key != null") - @GetMapping("/test3") - public R<String> test3(String key, String value) { - return R.ok("鎿嶄綔鎴愬姛", value); - } - - /** - * 娴嬭瘯璁剧疆杩囨湡鏃堕棿 - * 鎵嬪姩璁剧疆杩囨湡鏃堕棿10绉� - * 11绉掑悗鑾峰彇 鍒ゆ柇鏄惁鐩哥瓑 - */ - @GetMapping("/test6") - public R<Boolean> test6(String key, String value) { - RedisUtils.setCacheObject(key, value); - boolean flag = RedisUtils.expire(key, Duration.ofSeconds(10)); - System.out.println("***********" + flag); - try { - Thread.sleep(11 * 1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - Object obj = RedisUtils.getCacheObject(key); - return R.ok(value.equals(obj)); - } - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/RedisLockController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/RedisLockController.java deleted file mode 100644 index 61154cf..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/RedisLockController.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.ruoyi.demo.controller; - -import com.baomidou.lock.LockInfo; -import com.baomidou.lock.LockTemplate; -import com.baomidou.lock.annotation.Lock4j; -import com.baomidou.lock.executor.RedissonLockExecutor; -import lombok.extern.slf4j.Slf4j; -import org.ruoyi.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; -import org.springframework.web.bind.annotation.RestController; - -import java.time.LocalTime; - - -/** - * 娴嬭瘯鍒嗗竷寮忛攣鐨勬牱渚� - * - * @author shenxinquan - */ -@Slf4j -@RestController -@RequestMapping("/demo/redisLock") -public class RedisLockController { - - @Autowired - private LockTemplate lockTemplate; - - /** - * 娴嬭瘯lock4j 娉ㄨВ - */ - @Lock4j(keys = {"#key"}) - @GetMapping("/testLock4j") - public R<String> testLock4j(String key, String value) { - System.out.println("start:" + key + ",time:" + LocalTime.now().toString()); - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - System.out.println("end :" + key + ",time:" + LocalTime.now().toString()); - return R.ok("鎿嶄綔鎴愬姛", value); - } - - /** - * 娴嬭瘯lock4j 宸ュ叿 - */ - @GetMapping("/testLock4jLockTemplate") - public R<String> testLock4jLockTemplate(String key, String value) { - final LockInfo lockInfo = lockTemplate.lock(key, 30000L, 5000L, RedissonLockExecutor.class); - if (null == lockInfo) { - throw new RuntimeException("涓氬姟澶勭悊涓�,璇风◢鍚庡啀璇�"); - } - // 鑾峰彇閿佹垚鍔燂紝澶勭悊涓氬姟 - try { - try { - Thread.sleep(8000); - } catch (InterruptedException e) { - // - } - System.out.println("鎵ц绠�鍗曟柟娉�1 , 褰撳墠绾跨▼:" + Thread.currentThread().getName()); - } finally { - //閲婃斁閿� - lockTemplate.releaseLock(lockInfo); - } - //缁撴潫 - return R.ok("鎿嶄綔鎴愬姛", value); - } - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/RedisPubSubController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/RedisPubSubController.java deleted file mode 100644 index be6e270..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/RedisPubSubController.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.ruoyi.demo.controller; - -import lombok.RequiredArgsConstructor; -import org.ruoyi.common.core.domain.R; -import org.ruoyi.common.redis.utils.RedisUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * Redis 鍙戝竷璁㈤槄 婕旂ず妗堜緥 - * - * @author Lion Li - */ -@RequiredArgsConstructor -@RestController -@RequestMapping("/demo/redis/pubsub") -public class RedisPubSubController { - - /** - * 鍙戝竷娑堟伅 - * - * @param key 閫氶亾Key - * @param value 鍙戦�佸唴瀹� - */ - @GetMapping("/pub") - public R<Void> pub(String key, String value) { - RedisUtils.publish(key, value, consumer -> { - System.out.println("鍙戝竷閫氶亾 => " + key + ", 鍙戦�佸�� => " + value); - }); - return R.ok("鎿嶄綔鎴愬姛"); - } - - /** - * 璁㈤槄娑堟伅 - * - * @param key 閫氶亾Key - */ - @GetMapping("/sub") - public R<Void> sub(String key) { - RedisUtils.subscribe(key, String.class, msg -> { - System.out.println("璁㈤槄閫氶亾 => " + key + ", 鎺ユ敹鍊� => " + msg); - }); - return R.ok("鎿嶄綔鎴愬姛"); - } - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/RedisRateLimiterController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/RedisRateLimiterController.java deleted file mode 100644 index 915dcaa..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/RedisRateLimiterController.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.ruoyi.demo.controller; - -import lombok.extern.slf4j.Slf4j; -import org.ruoyi.common.core.domain.R; -import org.ruoyi.common.ratelimiter.annotation.RateLimiter; -import org.ruoyi.common.ratelimiter.enums.LimitType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - - -/** - * 娴嬭瘯鍒嗗竷寮忛檺娴佹牱渚� - * - * @author Lion Li - */ -@Slf4j -@RestController -@RequestMapping("/demo/rateLimiter") -public class RedisRateLimiterController { - - /** - * 娴嬭瘯鍏ㄥ眬闄愭祦 - * 鍏ㄥ眬褰卞搷 - */ - @RateLimiter(count = 2, time = 10) - @GetMapping("/test") - public R<String> test(String value) { - return R.ok("鎿嶄綔鎴愬姛", value); - } - - /** - * 娴嬭瘯璇锋眰IP闄愭祦 - * 鍚屼竴IP璇锋眰鍙楀奖鍝� - */ - @RateLimiter(count = 2, time = 10, limitType = LimitType.IP) - @GetMapping("/testip") - public R<String> testip(String value) { - return R.ok("鎿嶄綔鎴愬姛", value); - } - - /** - * 娴嬭瘯闆嗙兢瀹炰緥闄愭祦 - * 鍚姩涓や釜鍚庣鏈嶅姟浜掍笉褰卞搷 - */ - @RateLimiter(count = 2, time = 10, limitType = LimitType.CLUSTER) - @GetMapping("/testcluster") - public R<String> testcluster(String value) { - return R.ok("鎿嶄綔鎴愬姛", value); - } - - /** - * 娴嬭瘯璇锋眰IP闄愭祦(key鍩轰簬鍙傛暟鑾峰彇) - * 鍚屼竴IP璇锋眰鍙楀奖鍝� - * - * 绠�鍗曞彉閲忚幏鍙� #鍙橀噺 澶嶆潅琛ㄨ揪寮� #{#鍙橀噺 != 1 ? 1 : 0} - */ - @RateLimiter(count = 2, time = 10, limitType = LimitType.IP, key = "#value") - @GetMapping("/testObj") - public R<String> testObj(String value) { - return R.ok("鎿嶄綔鎴愬姛", value); - } - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/SmsController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/SmsController.java deleted file mode 100644 index 9f11504..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/SmsController.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.ruoyi.demo.controller; - -import lombok.RequiredArgsConstructor; -import org.ruoyi.common.core.domain.R; -import org.ruoyi.common.core.utils.SpringUtils; -import org.ruoyi.common.sms.config.properties.SmsProperties; -import org.ruoyi.common.sms.core.SmsTemplate; -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 java.util.HashMap; -import java.util.Map; - -/** - * 鐭俊婕旂ず妗堜緥 - * 璇峰厛闃呰鏂囨。 鍚﹀垯鏃犳硶浣跨敤 - * - * @author Lion Li - * @version 4.2.0 - */ -@Validated -@RequiredArgsConstructor -@RestController -@RequestMapping("/demo/sms") -public class SmsController { - - private final SmsProperties smsProperties; -// private final SmsTemplate smsTemplate; // 鍙互浣跨敤spring娉ㄥ叆 -// private final AliyunSmsTemplate smsTemplate; // 涔熷彲浠ユ敞鍏ユ煇涓巶瀹剁殑妯℃澘宸ュ叿 - - /** - * 鍙戦�佺煭淇liyun - * - * @param phones 鐢佃瘽鍙� - * @param templateId 妯℃澘ID - */ - @GetMapping("/sendAliyun") - public R<Object> sendAliyun(String phones, String templateId) { - if (!smsProperties.getEnabled()) { - return R.fail("褰撳墠绯荤粺娌℃湁寮�鍚煭淇″姛鑳斤紒"); - } - if (!SpringUtils.containsBean("aliyunSmsTemplate")) { - return R.fail("闃块噷浜戜緷璧栨湭寮曞叆锛�"); - } - SmsTemplate smsTemplate = SpringUtils.getBean(SmsTemplate.class); - Map<String, String> map = new HashMap<>(1); - map.put("code", "1234"); - Object send = smsTemplate.send(phones, templateId, map); - return R.ok(send); - } - - /** - * 鍙戦�佺煭淇encent - * - * @param phones 鐢佃瘽鍙� - * @param templateId 妯℃澘ID - */ - @GetMapping("/sendTencent") - public R<Object> sendTencent(String phones, String templateId) { - if (!smsProperties.getEnabled()) { - return R.fail("褰撳墠绯荤粺娌℃湁寮�鍚煭淇″姛鑳斤紒"); - } - if (!SpringUtils.containsBean("tencentSmsTemplate")) { - return R.fail("鑵捐浜戜緷璧栨湭寮曞叆锛�"); - } - SmsTemplate smsTemplate = SpringUtils.getBean(SmsTemplate.class); - Map<String, String> map = new HashMap<>(1); -// map.put("2", "娴嬭瘯娴嬭瘯"); - map.put("1", "1234"); - Object send = smsTemplate.send(phones, templateId, map); - return R.ok(send); - } - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/Swagger3DemoController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/Swagger3DemoController.java deleted file mode 100644 index 9006837..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/Swagger3DemoController.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.ruoyi.demo.controller; - -import org.ruoyi.common.core.domain.R; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -/** - * swagger3 鐢ㄦ硶绀轰緥 - * - * @author Lion Li - */ -@RestController -@RequestMapping("/swagger/demo") -public class Swagger3DemoController { - - /** - * 涓婁紶璇锋眰 - * 蹇呴』浣跨敤 @RequestPart 娉ㄨВ鏍囨敞涓烘枃浠� - * - * @param file 鏂囦欢 - */ - @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public R<String> upload(@RequestPart("file") MultipartFile file) { - return R.ok("鎿嶄綔鎴愬姛", file.getOriginalFilename()); - } - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestBatchController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestBatchController.java deleted file mode 100644 index aba105c..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestBatchController.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.ruoyi.demo.controller; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import lombok.RequiredArgsConstructor; -import org.ruoyi.common.core.domain.R; -import org.ruoyi.common.web.core.BaseController; -import org.ruoyi.demo.domain.TestDemo; -import org.ruoyi.demo.mapper.TestDemoMapper; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.ArrayList; -import java.util.List; - -/** - * 娴嬭瘯鎵归噺鏂规硶 - * - * @author Lion Li - * @date 2021-05-30 - */ -@RequiredArgsConstructor -@RestController -@RequestMapping("/demo/batch") -public class TestBatchController extends BaseController { - - /** - * 涓轰簡渚夸簬娴嬭瘯 鐩存帴寮曞叆mapper - */ - private final TestDemoMapper testDemoMapper; - - /** - * 鏂板鎵归噺鏂规硶 鍙畬缇庢浛浠� saveBatch 绉掔骇鎻掑叆涓婁竾鏁版嵁 (瀵筸ysql璐熻嵎杈冨ぇ) - * <p> - * 3.5.0 鐗堟湰 澧炲姞 rewriteBatchedStatements=true 鎵瑰鐞嗗弬鏁� 浣� MP 鍘熺敓鎵瑰鐞嗗彲浠ヨ揪鍒板悓鏍风殑閫熷害 - */ - @PostMapping("/add") -// @DS("slave") - public R<Void> add() { - List<TestDemo> list = new ArrayList<>(); - for (int i = 0; i < 1000; i++) { - TestDemo testDemo = new TestDemo(); - testDemo.setOrderNum(-1); - testDemo.setTestKey("鎵归噺鏂板"); - testDemo.setValue("娴嬭瘯鏂板"); - list.add(testDemo); - } - return toAjax(testDemoMapper.insertBatch(list)); - } - - /** - * 鏂板鎴栨洿鏂� 鍙畬缇庢浛浠� saveOrUpdateBatch 楂樻�ц兘 - * <p> - * 3.5.0 鐗堟湰 澧炲姞 rewriteBatchedStatements=true 鎵瑰鐞嗗弬鏁� 浣� MP 鍘熺敓鎵瑰鐞嗗彲浠ヨ揪鍒板悓鏍风殑閫熷害 - */ - @PostMapping("/addOrUpdate") -// @DS("slave") - public R<Void> addOrUpdate() { - List<TestDemo> list = new ArrayList<>(); - for (int i = 0; i < 1000; i++) { - TestDemo testDemo = new TestDemo(); - testDemo.setOrderNum(-1); - testDemo.setTestKey("鎵归噺鏂板"); - testDemo.setValue("娴嬭瘯鏂板"); - list.add(testDemo); - } - testDemoMapper.insertBatch(list); - for (int i = 0; i < list.size(); i++) { - TestDemo testDemo = list.get(i); - testDemo.setTestKey("鎵归噺鏂板鎴栦慨鏀�"); - testDemo.setValue("鎵归噺鏂板鎴栦慨鏀�"); - if (i % 2 == 0) { - testDemo.setId(null); - } - } - return toAjax(testDemoMapper.insertOrUpdateBatch(list)); - } - - /** - * 鍒犻櫎鎵归噺鏂规硶 - */ - @DeleteMapping() -// @DS("slave") - public R<Void> remove() { - return toAjax(testDemoMapper.delete(new LambdaQueryWrapper<TestDemo>() - .eq(TestDemo::getOrderNum, -1L))); - } - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestDemoController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestDemoController.java deleted file mode 100644 index f20d720..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestDemoController.java +++ /dev/null @@ -1,147 +0,0 @@ -package org.ruoyi.demo.controller; - -import cn.dev33.satoken.annotation.SaCheckPermission; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import lombok.RequiredArgsConstructor; -import org.ruoyi.common.core.domain.R; -import org.ruoyi.common.core.utils.MapstructUtils; -import org.ruoyi.common.core.utils.ValidatorUtils; -import org.ruoyi.common.core.validate.AddGroup; -import org.ruoyi.common.core.validate.EditGroup; -import org.ruoyi.common.core.validate.QueryGroup; -import org.ruoyi.common.excel.core.ExcelResult; -import org.ruoyi.common.excel.utils.ExcelUtil; -import org.ruoyi.common.idempotent.annotation.RepeatSubmit; -import org.ruoyi.common.log.annotation.Log; -import org.ruoyi.common.log.enums.BusinessType; -import org.ruoyi.core.page.PageQuery; -import org.ruoyi.core.page.TableDataInfo; -import org.ruoyi.common.web.core.BaseController; -import org.ruoyi.demo.domain.TestDemo; -import org.ruoyi.demo.domain.bo.TestDemoBo; -import org.ruoyi.demo.domain.bo.TestDemoImportVo; -import org.ruoyi.demo.domain.vo.TestDemoVo; -import org.ruoyi.demo.service.ITestDemoService; -import org.springframework.http.MediaType; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; - -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.TimeUnit; - -/** - * 娴嬭瘯鍗曡〃Controller - * - * @author Lion Li - * @date 2021-07-26 - */ -@Validated -@RequiredArgsConstructor -@RestController -@RequestMapping("/demo/demo") -public class TestDemoController extends BaseController { - - private final ITestDemoService testDemoService; - - /** - * 鏌ヨ娴嬭瘯鍗曡〃鍒楄〃 - */ - @SaCheckPermission("demo:demo:list") - @GetMapping("/list") - public TableDataInfo<TestDemoVo> list(@Validated(QueryGroup.class) TestDemoBo bo, PageQuery pageQuery) { - return testDemoService.queryPageList(bo, pageQuery); - } - - /** - * 鑷畾涔夊垎椤垫煡璇� - */ - @SaCheckPermission("demo:demo:list") - @GetMapping("/page") - public TableDataInfo<TestDemoVo> page(@Validated(QueryGroup.class) TestDemoBo bo, PageQuery pageQuery) { - return testDemoService.customPageList(bo, pageQuery); - } - - /** - * 瀵煎叆鏁版嵁 - * - * @param file 瀵煎叆鏂囦欢 - */ - @Log(title = "娴嬭瘯鍗曡〃", businessType = BusinessType.IMPORT) - @SaCheckPermission("demo:demo:import") - @PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public R<Void> importData(@RequestPart("file") MultipartFile file) throws Exception { - ExcelResult<TestDemoImportVo> excelResult = ExcelUtil.importExcel(file.getInputStream(), TestDemoImportVo.class, true); - List<TestDemo> list = MapstructUtils.convert(excelResult.getList(), TestDemo.class); - testDemoService.saveBatch(list); - return R.ok(excelResult.getAnalysis()); - } - - /** - * 瀵煎嚭娴嬭瘯鍗曡〃鍒楄〃 - */ - @SaCheckPermission("demo:demo:export") - @Log(title = "娴嬭瘯鍗曡〃", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(@Validated TestDemoBo bo, HttpServletResponse response) { - List<TestDemoVo> list = testDemoService.queryList(bo); - // 娴嬭瘯闆姳id瀵煎嚭 -// for (TestDemoVo vo : list) { -// vo.setId(1234567891234567893L); -// } - ExcelUtil.exportExcel(list, "娴嬭瘯鍗曡〃", TestDemoVo.class, response); - } - - /** - * 鑾峰彇娴嬭瘯鍗曡〃璇︾粏淇℃伅 - * - * @param id 娴嬭瘯ID - */ - @SaCheckPermission("demo:demo:query") - @GetMapping("/{id}") - public R<TestDemoVo> getInfo(@NotNull(message = "涓婚敭涓嶈兘涓虹┖") - @PathVariable("id") Long id) { - return R.ok(testDemoService.queryById(id)); - } - - /** - * 鏂板娴嬭瘯鍗曡〃 - */ - @SaCheckPermission("demo:demo:add") - @Log(title = "娴嬭瘯鍗曡〃", businessType = BusinessType.INSERT) - @RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS, message = "{repeat.submit.message}") - @PostMapping() - public R<Void> add(@RequestBody TestDemoBo bo) { - // 浣跨敤鏍¢獙宸ュ叿瀵规爣 @Validated(AddGroup.class) 娉ㄨВ - // 鐢ㄤ簬鍦ㄩ潪 Controller 鐨勫湴鏂规牎楠屽璞� - ValidatorUtils.validate(bo, AddGroup.class); - return toAjax(testDemoService.insertByBo(bo)); - } - - /** - * 淇敼娴嬭瘯鍗曡〃 - */ - @SaCheckPermission("demo:demo:edit") - @Log(title = "娴嬭瘯鍗曡〃", businessType = BusinessType.UPDATE) - @RepeatSubmit - @PutMapping() - public R<Void> edit(@Validated(EditGroup.class) @RequestBody TestDemoBo bo) { - return toAjax(testDemoService.updateByBo(bo)); - } - - /** - * 鍒犻櫎娴嬭瘯鍗曡〃 - * - * @param ids 娴嬭瘯ID涓� - */ - @SaCheckPermission("demo:demo:remove") - @Log(title = "娴嬭瘯鍗曡〃", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public R<Void> remove(@NotEmpty(message = "涓婚敭涓嶈兘涓虹┖") - @PathVariable Long[] ids) { - return toAjax(testDemoService.deleteWithValidByIds(Arrays.asList(ids), true)); - } -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestEncryptController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestEncryptController.java deleted file mode 100644 index 9897ce1..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestEncryptController.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.ruoyi.demo.controller; - -import org.ruoyi.common.core.domain.R; -import org.ruoyi.demo.domain.TestDemoEncrypt; -import org.ruoyi.demo.mapper.TestDemoEncryptMapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -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 java.util.HashMap; -import java.util.Map; - - -/** - * 娴嬭瘯鏁版嵁搴撳姞瑙e瘑鍔熻兘 - * - * @author Lion Li - */ -@Validated -@RestController -@RequestMapping("/demo/encrypt") -public class TestEncryptController { - - @Autowired - private TestDemoEncryptMapper mapper; - @Value("${mybatis-encryptor.enable}") - private Boolean encryptEnable; - - /** - * 娴嬭瘯鏁版嵁搴撳姞瑙e瘑 - * - * @param key 娴嬭瘯key - * @param value 娴嬭瘯value - */ - @GetMapping() - public R<Map<String, TestDemoEncrypt>> test(String key, String value) { - if (!encryptEnable) { - throw new RuntimeException("鍔犲瘑鍔熻兘鏈紑鍚�!"); - } - Map<String, TestDemoEncrypt> map = new HashMap<>(2); - TestDemoEncrypt demo = new TestDemoEncrypt(); - demo.setTestKey(key); - demo.setValue(value); - mapper.insert(demo); - map.put("鍔犲瘑", demo); - TestDemoEncrypt testDemo = mapper.selectById(demo.getId()); - map.put("瑙e瘑", testDemo); - return R.ok(map); - } - - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestExcelController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestExcelController.java deleted file mode 100644 index 025c4b3..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestExcelController.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.ruoyi.demo.controller; - -import cn.hutool.core.collection.CollUtil; -import jakarta.servlet.http.HttpServletResponse; -import lombok.AllArgsConstructor; -import lombok.Data; -import org.ruoyi.common.excel.utils.ExcelUtil; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 娴嬭瘯Excel鍔熻兘 - * - * @author Lion Li - */ -@RestController -@RequestMapping("/demo/excel") -public class TestExcelController { - - /** - * 鍗曞垪琛ㄥ鏁版嵁 - */ - @GetMapping("/exportTemplateOne") - public void exportTemplateOne(HttpServletResponse response) { - Map<String, String> map = new HashMap<>(); - map.put("title", "鍗曞垪琛ㄥ鏁版嵁"); - map.put("test1", "鏁版嵁娴嬭瘯1"); - map.put("test2", "鏁版嵁娴嬭瘯2"); - map.put("test3", "鏁版嵁娴嬭瘯3"); - map.put("test4", "鏁版嵁娴嬭瘯4"); - map.put("testTest", "666"); - List<TestObj> list = new ArrayList<>(); - list.add(new TestObj("鍗曞垪琛ㄦ祴璇�1", "鍒楄〃娴嬭瘯1", "鍒楄〃娴嬭瘯2", "鍒楄〃娴嬭瘯3", "鍒楄〃娴嬭瘯4")); - list.add(new TestObj("鍗曞垪琛ㄦ祴璇�2", "鍒楄〃娴嬭瘯5", "鍒楄〃娴嬭瘯6", "鍒楄〃娴嬭瘯7", "鍒楄〃娴嬭瘯8")); - list.add(new TestObj("鍗曞垪琛ㄦ祴璇�3", "鍒楄〃娴嬭瘯9", "鍒楄〃娴嬭瘯10", "鍒楄〃娴嬭瘯11", "鍒楄〃娴嬭瘯12")); - ExcelUtil.exportTemplate(CollUtil.newArrayList(map, list), "鍗曞垪琛�.xlsx", "excel/鍗曞垪琛�.xlsx", response); - } - - /** - * 澶氬垪琛ㄥ鏁版嵁 - */ - @GetMapping("/exportTemplateMuliti") - public void exportTemplateMuliti(HttpServletResponse response) { - Map<String, String> map = new HashMap<>(); - map.put("title1", "鏍囬1"); - map.put("title2", "鏍囬2"); - map.put("title3", "鏍囬3"); - map.put("title4", "鏍囬4"); - map.put("author", "Lion Li"); - List<TestObj1> list1 = new ArrayList<>(); - list1.add(new TestObj1("list1娴嬭瘯1", "list1娴嬭瘯2", "list1娴嬭瘯3")); - list1.add(new TestObj1("list1娴嬭瘯4", "list1娴嬭瘯5", "list1娴嬭瘯6")); - list1.add(new TestObj1("list1娴嬭瘯7", "list1娴嬭瘯8", "list1娴嬭瘯9")); - List<TestObj1> list2 = new ArrayList<>(); - list2.add(new TestObj1("list2娴嬭瘯1", "list2娴嬭瘯2", "list2娴嬭瘯3")); - list2.add(new TestObj1("list2娴嬭瘯4", "list2娴嬭瘯5", "list2娴嬭瘯6")); - List<TestObj1> list3 = new ArrayList<>(); - list3.add(new TestObj1("list3娴嬭瘯1", "list3娴嬭瘯2", "list3娴嬭瘯3")); - List<TestObj1> list4 = new ArrayList<>(); - list4.add(new TestObj1("list4娴嬭瘯1", "list4娴嬭瘯2", "list4娴嬭瘯3")); - list4.add(new TestObj1("list4娴嬭瘯4", "list4娴嬭瘯5", "list4娴嬭瘯6")); - list4.add(new TestObj1("list4娴嬭瘯7", "list4娴嬭瘯8", "list4娴嬭瘯9")); - list4.add(new TestObj1("list4娴嬭瘯10", "list4娴嬭瘯11", "list4娴嬭瘯12")); - Map<String, Object> multiListMap = new HashMap<>(); - multiListMap.put("map", map); - multiListMap.put("data1", list1); - multiListMap.put("data2", list2); - multiListMap.put("data3", list3); - multiListMap.put("data4", list4); - ExcelUtil.exportTemplateMultiList(multiListMap, "澶氬垪琛�.xlsx", "excel/澶氬垪琛�.xlsx", response); - } - - @Data - @AllArgsConstructor - static class TestObj1 { - private String test1; - private String test2; - private String test3; - } - - @Data - @AllArgsConstructor - static class TestObj { - private String name; - private String list1; - private String list2; - private String list3; - private String list4; - } - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestI18nController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestI18nController.java deleted file mode 100644 index 704d9b3..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestI18nController.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.ruoyi.demo.controller; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import lombok.Data; -import org.ruoyi.common.core.domain.R; -import org.ruoyi.common.core.utils.MessageUtils; -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; - - -/** - * 娴嬭瘯鍥介檯鍖� - * - * @author Lion Li - */ -@Validated -@RestController -@RequestMapping("/demo/i18n") -public class TestI18nController { - - /** - * 閫氳繃code鑾峰彇鍥介檯鍖栧唴瀹� - * code涓� messages.properties 涓殑 key - * <p> - * 娴嬭瘯浣跨敤 user.register.success - * - * @param code 鍥介檯鍖朿ode - */ - @GetMapping() - public R<Void> get(String code) { - return R.ok(MessageUtils.message(code)); - } - - /** - * Validator 鏍¢獙鍥介檯鍖� - * 涓嶄紶鍊� 鍒嗗埆鏌ョ湅寮傚父杩斿洖 - * <p> - * 娴嬭瘯浣跨敤 not.null - */ - @GetMapping("/test1") - public R<Void> test1(@NotBlank(message = "{not.null}") String str) { - return R.ok(str); - } - - /** - * Bean 鏍¢獙鍥介檯鍖� - * 涓嶄紶鍊� 鍒嗗埆鏌ョ湅寮傚父杩斿洖 - * <p> - * 娴嬭瘯浣跨敤 not.null - */ - @GetMapping("/test2") - public R<TestI18nBo> test2(@Validated TestI18nBo bo) { - return R.ok(bo); - } - - @Data - public static class TestI18nBo { - - @NotBlank(message = "{not.null}") - private String name; - - @NotNull(message = "{not.null}") - @Range(min = 0, max = 100, message = "{length.not.valid}") - private Integer age; - } -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestSensitiveController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestSensitiveController.java deleted file mode 100644 index 4acf1f5..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestSensitiveController.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.ruoyi.demo.controller; - -import lombok.Data; -import org.ruoyi.common.core.domain.R; -import org.ruoyi.common.sensitive.annotation.Sensitive; -import org.ruoyi.common.sensitive.core.SensitiveService; -import org.ruoyi.common.sensitive.core.SensitiveStrategy; -import org.ruoyi.common.web.core.BaseController; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * 娴嬭瘯鏁版嵁鑴辨晱鎺у埗鍣� - * <p> - * 榛樿绠$悊鍛樹笉杩囨护 - * 闇�鑷鏍规嵁涓氬姟閲嶅啓瀹炵幇 - * - * @author Lion Li - * @version 3.6.0 - * @see SensitiveService - */ -@RestController -@RequestMapping("/demo/sensitive") -public class TestSensitiveController extends BaseController { - - /** - * 娴嬭瘯鏁版嵁鑴辨晱 - */ - @GetMapping("/test") - public R<TestSensitive> test() { - TestSensitive testSensitive = new TestSensitive(); - testSensitive.setIdCard("210397198608215431"); - testSensitive.setPhone("17640125371"); - testSensitive.setAddress("鍖椾含甯傛湞闃冲尯鏌愭煇鍥涘悎闄�1203瀹�"); - testSensitive.setEmail("17640125371@163.com"); - testSensitive.setBankCard("6226456952351452853"); - return R.ok(testSensitive); - } - - @Data - static class TestSensitive { - - /** - * 韬唤璇� - */ - @Sensitive(strategy = SensitiveStrategy.ID_CARD) - private String idCard; - - /** - * 鐢佃瘽 - */ - @Sensitive(strategy = SensitiveStrategy.PHONE) - private String phone; - - /** - * 鍦板潃 - */ - @Sensitive(strategy = SensitiveStrategy.ADDRESS) - private String address; - - /** - * 閭 - */ - @Sensitive(strategy = SensitiveStrategy.EMAIL) - private String email; - - /** - * 閾惰鍗� - */ - @Sensitive(strategy = SensitiveStrategy.BANK_CARD) - private String bankCard; - - } - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestTreeController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestTreeController.java deleted file mode 100644 index b8123c8..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/TestTreeController.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.ruoyi.demo.controller; - -import cn.dev33.satoken.annotation.SaCheckPermission; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import lombok.RequiredArgsConstructor; -import org.ruoyi.common.core.domain.R; -import org.ruoyi.common.core.validate.AddGroup; -import org.ruoyi.common.core.validate.EditGroup; -import org.ruoyi.common.core.validate.QueryGroup; -import org.ruoyi.common.excel.utils.ExcelUtil; -import org.ruoyi.common.idempotent.annotation.RepeatSubmit; -import org.ruoyi.common.log.annotation.Log; -import org.ruoyi.common.log.enums.BusinessType; -import org.ruoyi.common.web.core.BaseController; -import org.ruoyi.demo.domain.bo.TestTreeBo; -import org.ruoyi.demo.domain.vo.TestTreeVo; -import org.ruoyi.demo.service.ITestTreeService; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import java.util.Arrays; -import java.util.List; - -/** - * 娴嬭瘯鏍戣〃Controller - * - * @author Lion Li - * @date 2021-07-26 - */ -@Validated -@RequiredArgsConstructor -@RestController -@RequestMapping("/demo/tree") -public class TestTreeController extends BaseController { - - private final ITestTreeService testTreeService; - - /** - * 鏌ヨ娴嬭瘯鏍戣〃鍒楄〃 - */ - @SaCheckPermission("demo:tree:list") - @GetMapping("/list") - public R<List<TestTreeVo>> list(@Validated(QueryGroup.class) TestTreeBo bo) { - List<TestTreeVo> list = testTreeService.queryList(bo); - return R.ok(list); - } - - /** - * 瀵煎嚭娴嬭瘯鏍戣〃鍒楄〃 - */ - @SaCheckPermission("demo:tree:export") - @Log(title = "娴嬭瘯鏍戣〃", businessType = BusinessType.EXPORT) - @GetMapping("/export") - public void export(@Validated TestTreeBo bo, HttpServletResponse response) { - List<TestTreeVo> list = testTreeService.queryList(bo); - ExcelUtil.exportExcel(list, "娴嬭瘯鏍戣〃", TestTreeVo.class, response); - } - - /** - * 鑾峰彇娴嬭瘯鏍戣〃璇︾粏淇℃伅 - * - * @param id 娴嬭瘯鏍慖D - */ - @SaCheckPermission("demo:tree:query") - @GetMapping("/{id}") - public R<TestTreeVo> getInfo(@NotNull(message = "涓婚敭涓嶈兘涓虹┖") - @PathVariable("id") Long id) { - return R.ok(testTreeService.queryById(id)); - } - - /** - * 鏂板娴嬭瘯鏍戣〃 - */ - @SaCheckPermission("demo:tree:add") - @Log(title = "娴嬭瘯鏍戣〃", businessType = BusinessType.INSERT) - @RepeatSubmit - @PostMapping() - public R<Void> add(@Validated(AddGroup.class) @RequestBody TestTreeBo bo) { - return toAjax(testTreeService.insertByBo(bo)); - } - - /** - * 淇敼娴嬭瘯鏍戣〃 - */ - @SaCheckPermission("demo:tree:edit") - @Log(title = "娴嬭瘯鏍戣〃", businessType = BusinessType.UPDATE) - @RepeatSubmit - @PutMapping() - public R<Void> edit(@Validated(EditGroup.class) @RequestBody TestTreeBo bo) { - return toAjax(testTreeService.updateByBo(bo)); - } - - /** - * 鍒犻櫎娴嬭瘯鏍戣〃 - * - * @param ids 娴嬭瘯鏍慖D涓� - */ - @SaCheckPermission("demo:tree:remove") - @Log(title = "娴嬭瘯鏍戣〃", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public R<Void> remove(@NotEmpty(message = "涓婚敭涓嶈兘涓虹┖") - @PathVariable Long[] ids) { - return toAjax(testTreeService.deleteWithValidByIds(Arrays.asList(ids), true)); - } -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/queue/BoundedQueueController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/queue/BoundedQueueController.java deleted file mode 100644 index e70bb39..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/queue/BoundedQueueController.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.ruoyi.demo.controller.queue; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.ruoyi.common.core.domain.R; -import org.ruoyi.common.redis.utils.QueueUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * 鏈夌晫闃熷垪 婕旂ず妗堜緥 - * <p> - * 杞婚噺绾ч槦鍒� 閲嶉噺绾ф暟鎹噺 璇蜂娇鐢� MQ - * <p> - * 闆嗙兢娴嬭瘯閫氳繃 鍚屼竴涓暟鎹彧浼氳娑堣垂涓�娆� 鍋氬ソ浜嬪姟琛ュ伩 - * 闆嗙兢娴嬭瘯娴佺▼ 鍦ㄥ叾涓竴鍙板彂閫佹暟鎹� 涓ょ鍒嗗埆璋冪敤鑾峰彇鎺ュ彛 涓�娆¤幏鍙栦竴鏉� - * - * @author Lion Li - * @version 3.6.0 - */ -@Slf4j -@RequiredArgsConstructor -@RestController -@RequestMapping("/demo/queue/bounded") -public class BoundedQueueController { - - - /** - * 娣诲姞闃熷垪鏁版嵁 - * - * @param queueName 闃熷垪鍚� - * @param capacity 瀹归噺 - */ - @GetMapping("/add") - public R<Void> add(String queueName, int capacity) { - // 鐢ㄥ畬浜嗕竴瀹氳閿�姣� 鍚﹀垯浼氫竴鐩村瓨鍦� - boolean b = QueueUtils.destroyQueue(queueName); - log.info("閫氶亾: {} , 鍒犻櫎: {}", queueName, b); - // 鍒濆鍖栬缃竴娆″嵆鍙� - if (QueueUtils.trySetBoundedQueueCapacity(queueName, capacity)) { - log.info("閫氶亾: {} , 璁剧疆瀹归噺: {}", queueName, capacity); - } else { - log.info("閫氶亾: {} , 璁剧疆瀹归噺澶辫触", queueName); - return R.fail("鎿嶄綔澶辫触"); - } - for (int i = 0; i < 11; i++) { - String data = "data-" + i; - boolean flag = QueueUtils.addBoundedQueueObject(queueName, data); - if (flag == false) { - log.info("閫氶亾: {} , 鍙戦�佹暟鎹�: {} 澶辫触, 閫氶亾宸叉弧", queueName, data); - } else { - log.info("閫氶亾: {} , 鍙戦�佹暟鎹�: {}", queueName, data); - } - } - return R.ok("鎿嶄綔鎴愬姛"); - } - - /** - * 鍒犻櫎闃熷垪鏁版嵁 - * - * @param queueName 闃熷垪鍚� - */ - @GetMapping("/remove") - public R<Void> remove(String queueName) { - String data = "data-" + 5; - if (QueueUtils.removeQueueObject(queueName, data)) { - log.info("閫氶亾: {} , 鍒犻櫎鏁版嵁: {}", queueName, data); - } else { - return R.fail("鎿嶄綔澶辫触"); - } - return R.ok("鎿嶄綔鎴愬姛"); - } - - /** - * 鑾峰彇闃熷垪鏁版嵁 - * - * @param queueName 闃熷垪鍚� - */ - @GetMapping("/get") - public R<Void> get(String queueName) { - String data; - do { - data = QueueUtils.getQueueObject(queueName); - log.info("閫氶亾: {} , 鑾峰彇鏁版嵁: {}", queueName, data); - } while (data != null); - return R.ok("鎿嶄綔鎴愬姛"); - } - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/queue/DelayedQueueController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/queue/DelayedQueueController.java deleted file mode 100644 index 74d3e4d..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/queue/DelayedQueueController.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.ruoyi.demo.controller.queue; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.ruoyi.common.core.domain.R; -import org.ruoyi.common.redis.utils.QueueUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.concurrent.TimeUnit; - -/** - * 寤惰繜闃熷垪 婕旂ず妗堜緥 - * <p> - * 杞婚噺绾ч槦鍒� 閲嶉噺绾ф暟鎹噺 璇蜂娇鐢� MQ - * 渚嬪: 鍒涘缓璁㈠崟30鍒嗛挓鍚庤繃鏈熷鐞� - * <p> - * 闆嗙兢娴嬭瘯閫氳繃 鍚屼竴涓暟鎹彧浼氳娑堣垂涓�娆� 鍋氬ソ浜嬪姟琛ュ伩 - * 闆嗙兢娴嬭瘯娴佺▼ 涓ゅ彴闆嗙兢鍒嗗埆寮�鍚闃� 鍦ㄥ叾涓竴鍙板彂閫佹暟鎹� 瑙傚療鎺ユ敹娑堟伅鐨勮寰� - * - * @author Lion Li - * @version 3.6.0 - */ -@Slf4j -@RequiredArgsConstructor -@RestController -@RequestMapping("/demo/queue/delayed") -public class DelayedQueueController { - - /** - * 璁㈤槄闃熷垪 - * - * @param queueName 闃熷垪鍚� - */ - @GetMapping("/subscribe") - public R<Void> subscribe(String queueName) { - log.info("閫氶亾: {} 鐩戝惉涓�......", queueName); - // 椤圭洰鍒濆鍖栬缃竴娆″嵆鍙� - QueueUtils.subscribeBlockingQueue(queueName, (String orderNum) -> { - // 瑙傚療鎺ユ敹鏃堕棿 - log.info("閫氶亾: {}, 鏀跺埌鏁版嵁: {}", queueName, orderNum); - }); - return R.ok("鎿嶄綔鎴愬姛"); - } - - /** - * 娣诲姞闃熷垪鏁版嵁 - * - * @param queueName 闃熷垪鍚� - * @param orderNum 璁㈠崟鍙� - * @param time 寤惰繜鏃堕棿(绉�) - */ - @GetMapping("/add") - public R<Void> add(String queueName, String orderNum, Long time) { - QueueUtils.addDelayedQueueObject(queueName, orderNum, time, TimeUnit.SECONDS); - // 瑙傚療鍙戦�佹椂闂� - log.info("閫氶亾: {} , 鍙戦�佹暟鎹�: {}", queueName, orderNum); - return R.ok("鎿嶄綔鎴愬姛"); - } - - /** - * 鍒犻櫎闃熷垪鏁版嵁 - * - * @param queueName 闃熷垪鍚� - * @param orderNum 璁㈠崟鍙� - */ - @GetMapping("/remove") - public R<Void> remove(String queueName, String orderNum) { - if (QueueUtils.removeDelayedQueueObject(queueName, orderNum)) { - log.info("閫氶亾: {} , 鍒犻櫎鏁版嵁: {}", queueName, orderNum); - } else { - return R.fail("鎿嶄綔澶辫触"); - } - return R.ok("鎿嶄綔鎴愬姛"); - } - - /** - * 閿�姣侀槦鍒� - * - * @param queueName 闃熷垪鍚� - */ - @GetMapping("/destroy") - public R<Void> destroy(String queueName) { - // 鐢ㄥ畬浜嗕竴瀹氳閿�姣� 鍚﹀垯浼氫竴鐩村瓨鍦� - QueueUtils.destroyDelayedQueue(queueName); - return R.ok("鎿嶄綔鎴愬姛"); - } - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/queue/PriorityDemo.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/queue/PriorityDemo.java deleted file mode 100644 index bf1de73..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/queue/PriorityDemo.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.ruoyi.demo.controller.queue; - -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 瀹炰綋绫� 娉ㄦ剰涓嶅厑璁镐娇鐢ㄥ唴閮ㄧ被 鍚﹀垯浼氭壘涓嶅埌绫� - * - * @author Lion Li - * @version 3.6.0 - */ -@Data -@NoArgsConstructor -public class PriorityDemo implements Comparable<PriorityDemo> { - private String name; - private Integer orderNum; - - @Override - public int compareTo(PriorityDemo other) { - return Integer.compare(getOrderNum(), other.getOrderNum()); - } -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/queue/PriorityQueueController.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/queue/PriorityQueueController.java deleted file mode 100644 index e0dbaed..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/controller/queue/PriorityQueueController.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.ruoyi.demo.controller.queue; - -import cn.hutool.core.util.RandomUtil; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.ruoyi.common.core.domain.R; -import org.ruoyi.common.redis.utils.QueueUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * 浼樺厛闃熷垪 婕旂ず妗堜緥 - * <p> - * 杞婚噺绾ч槦鍒� 閲嶉噺绾ф暟鎹噺 璇蜂娇鐢� MQ - * <p> - * 闆嗙兢娴嬭瘯閫氳繃 鍚屼竴涓秷鎭彧浼氳娑堣垂涓�娆� 鍋氬ソ浜嬪姟琛ュ伩 - * 闆嗙兢娴嬭瘯娴佺▼ 鍦ㄥ叾涓竴鍙板彂閫佹暟鎹� 涓ょ鍒嗗埆璋冪敤鑾峰彇鎺ュ彛 涓�娆¤幏鍙栦竴鏉� - * - * @author Lion Li - * @version 3.6.0 - */ -@Slf4j -@RequiredArgsConstructor -@RestController -@RequestMapping("/demo/queue/priority") -public class PriorityQueueController { - - /** - * 娣诲姞闃熷垪鏁版嵁 - * - * @param queueName 闃熷垪鍚� - */ - @GetMapping("/add") - public R<Void> add(String queueName) { - // 鐢ㄥ畬浜嗕竴瀹氳閿�姣� 鍚﹀垯浼氫竴鐩村瓨鍦� - boolean b = QueueUtils.destroyQueue(queueName); - log.info("閫氶亾: {} , 鍒犻櫎: {}", queueName, b); - - for (int i = 0; i < 10; i++) { - int randomNum = RandomUtil.randomInt(10); - PriorityDemo data = new PriorityDemo(); - data.setName("data-" + i); - data.setOrderNum(randomNum); - if (QueueUtils.addPriorityQueueObject(queueName, data)) { - log.info("閫氶亾: {} , 鍙戦�佹暟鎹�: {}", queueName, data); - } else { - log.info("閫氶亾: {} , 鍙戦�佹暟鎹�: {}, 鍙戦�佸け璐�", queueName, data); - } - } - return R.ok("鎿嶄綔鎴愬姛"); - } - - /** - * 鍒犻櫎闃熷垪鏁版嵁 - * - * @param queueName 闃熷垪鍚� - * @param name 瀵硅薄鍚� - * @param orderNum 鎺掑簭鍙� - */ - @GetMapping("/remove") - public R<Void> remove(String queueName, String name, Integer orderNum) { - PriorityDemo data = new PriorityDemo(); - data.setName(name); - data.setOrderNum(orderNum); - if (QueueUtils.removeQueueObject(queueName, data)) { - log.info("閫氶亾: {} , 鍒犻櫎鏁版嵁: {}", queueName, data); - } else { - return R.fail("鎿嶄綔澶辫触"); - } - return R.ok("鎿嶄綔鎴愬姛"); - } - - /** - * 鑾峰彇闃熷垪鏁版嵁 - * - * @param queueName 闃熷垪鍚� - */ - @GetMapping("/get") - public R<Void> get(String queueName) { - PriorityDemo data; - do { - data = QueueUtils.getQueueObject(queueName); - log.info("閫氶亾: {} , 鑾峰彇鏁版嵁: {}", queueName, data); - } while (data != null); - return R.ok("鎿嶄綔鎴愬姛"); - } - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/TestDemo.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/TestDemo.java deleted file mode 100644 index 901eadc..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/TestDemo.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.ruoyi.demo.domain; - -import com.baomidou.mybatisplus.annotation.*; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.ruoyi.common.tenant.core.TenantEntity; - -import java.io.Serial; - -/** - * 娴嬭瘯鍗曡〃瀵硅薄 test_demo - * - * @author Lion Li - * @date 2021-07-26 - */ -@Data -@EqualsAndHashCode(callSuper = true) -@TableName("test_demo") -public class TestDemo extends TenantEntity { - - @Serial - private static final long serialVersionUID = 1L; - - /** - * 涓婚敭 - */ - @TableId(value = "id") - private Long id; - - /** - * 閮ㄩ棬id - */ - private Long deptId; - - /** - * 鐢ㄦ埛id - */ - private Long userId; - - /** - * 鎺掑簭鍙� - */ - @OrderBy(asc = false, sort = 1) - private Integer orderNum; - - /** - * key閿� - */ - private String testKey; - - /** - * 鍊� - */ - private String value; - - /** - * 鐗堟湰 - */ - @Version - private Long version; - - /** - * 鍒犻櫎鏍囧織 - */ - @TableLogic - private Long delFlag; - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/TestDemoEncrypt.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/TestDemoEncrypt.java deleted file mode 100644 index d8f7181..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/TestDemoEncrypt.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.ruoyi.demo.domain; - -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.ruoyi.common.encrypt.annotation.EncryptField; -import org.ruoyi.common.encrypt.enumd.AlgorithmType; - -@Data -@EqualsAndHashCode(callSuper = true) -@TableName("test_demo") -public class TestDemoEncrypt extends TestDemo { - - /** - * key閿� - */ - // @EncryptField(algorithm=AlgorithmType.SM2, privateKey = "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgZSlOvw8FBiH+aFJWLYZP/VRjg9wjfRarTkGBZd/T3N+gCgYIKoEcz1UBgi2hRANCAAR5DGuQwJqkxnbCsP+iPSDoHWIF4RwcR5EsSvT8QPxO1wRkR2IhCkzvRb32x2CUgJFdvoqVqfApFDPZzShqzBwX", publicKey = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEeQxrkMCapMZ2wrD/oj0g6B1iBeEcHEeRLEr0/ED8TtcEZEdiIQpM70W99sdglICRXb6KlanwKRQz2c0oaswcFw==") - @EncryptField(algorithm = AlgorithmType.RSA, privateKey = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBANBBEeueWlXlkkj2+WY5l+IWe42d8b5K28g+G/CFKC/yYAEHtqGlCsBOrb+YBkG9mPzmuYA/n9k0NFIc8E8yY5vZQaroyFBrTTWEzG9RY2f7Y3svVyybs6jpXSUs4xff8abo7wL1Y/wUaeatTViamxYnyTvdTmLm3d+JjRij68rxAgMBAAECgYAB0TnhXraSopwIVRfmboea1b0upl+BUdTJcmci412UjrKr5aE695ZLPkXbFXijVu7HJlyyv94NVUdaMACV7Ku/S2RuNB70M7YJm8rAjHFC3/i2ZeIM60h1Ziy4QKv0XM3pRATlDCDNhC1WUrtQCQSgU8kcp6eUUppruOqDzcY04QJBAPm9+sBP9CwDRgy3e5+V8aZtJkwDstb0lVVV/KY890cydVxiCwvX3fqVnxKMlb+x0YtH0sb9v+71xvK2lGobaRECQQDVePU6r/cCEfpc+nkWF6osAH1f8Mux3rYv2DoBGvaPzV2BGfsLed4neRfCwWNCKvGPCdW+L0xMJg8+RwaoBUPhAkAT5kViqXxFPYWJYd1h2+rDXhMdH3ZSlm6HvDBDdrwlWinr0Iwcx3iSjPV93uHXwm118aUj4fg3LDJMCKxOwBxhAkByrQXfvwOMYygBprRBf/j0plazoWFrbd6lGR0f1uI5IfNnFRPdeFw1DEINZ2Hw+6zEUF44SqRMC+4IYJNc02dBAkBCgy7RvfyV/A7N6kKXxTHauY0v6XwSSvpeKtRJkbIcRWOdIYvaHO9L7cklj3vIEdwjSUp9K4VTBYYlmAz1xh03", publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQQRHrnlpV5ZJI9vlmOZfiFnuNnfG+StvIPhvwhSgv8mABB7ahpQrATq2/mAZBvZj85rmAP5/ZNDRSHPBPMmOb2UGq6MhQa001hMxvUWNn+2N7L1csm7Oo6V0lLOMX3/Gm6O8C9WP8FGnmrU1YmpsWJ8k73U5i5t3fiY0Yo+vK8QIDAQAB") - private String testKey; - - /** - * 鍊� - */ - // @EncryptField // 浠�涔堜篃涓嶅啓璧伴粯璁ml閰嶇疆 - // @EncryptField(algorithm = AlgorithmType.SM4, password = "10rfylhtccpuyke5") - @EncryptField(algorithm = AlgorithmType.AES, password = "10rfylhtccpuyke5") - private String value; - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/TestTree.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/TestTree.java deleted file mode 100644 index 9b9b34c..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/TestTree.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.ruoyi.demo.domain; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableLogic; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.annotation.Version; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.ruoyi.common.tenant.core.TenantEntity; - -import java.io.Serial; - -/** - * 娴嬭瘯鏍戣〃瀵硅薄 test_tree - * - * @author Lion Li - * @date 2021-07-26 - */ -@Data -@EqualsAndHashCode(callSuper = true) -@TableName("test_tree") -public class TestTree extends TenantEntity { - - @Serial - private static final long serialVersionUID = 1L; - - /** - * 涓婚敭 - */ - @TableId(value = "id") - private Long id; - - /** - * 鐖禝D - */ - private Long parentId; - - /** - * 閮ㄩ棬id - */ - private Long deptId; - - /** - * 鐢ㄦ埛id - */ - private Long userId; - - /** - * 鏍戣妭鐐瑰悕 - */ - private String treeName; - - /** - * 鐗堟湰 - */ - @Version - private Long version; - - /** - * 鍒犻櫎鏍囧織 - */ - @TableLogic - private Long delFlag; - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/bo/TestDemoBo.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/bo/TestDemoBo.java deleted file mode 100644 index 630ca87..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/bo/TestDemoBo.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.ruoyi.demo.domain.bo; - -import io.github.linpeilie.annotations.AutoMapper; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.ruoyi.common.core.validate.AddGroup; -import org.ruoyi.common.core.validate.EditGroup; -import org.ruoyi.core.domain.BaseEntity; -import org.ruoyi.demo.domain.TestDemo; - -/** - * 娴嬭瘯鍗曡〃涓氬姟瀵硅薄 test_demo - * - * @author Lion Li - * @date 2021-07-26 - */ - -@Data -@EqualsAndHashCode(callSuper = true) -@AutoMapper(target = TestDemo.class, reverseConvertGenerate = false) -public class TestDemoBo extends BaseEntity { - - /** - * 涓婚敭 - */ - @NotNull(message = "涓婚敭涓嶈兘涓虹┖", groups = {EditGroup.class}) - private Long id; - - /** - * 閮ㄩ棬id - */ - @NotNull(message = "閮ㄩ棬id涓嶈兘涓虹┖", groups = {AddGroup.class, EditGroup.class}) - private Long deptId; - - /** - * 鐢ㄦ埛id - */ - @NotNull(message = "鐢ㄦ埛id涓嶈兘涓虹┖", groups = {AddGroup.class, EditGroup.class}) - private Long userId; - - /** - * 鎺掑簭鍙� - */ - @NotNull(message = "鎺掑簭鍙蜂笉鑳戒负绌�", groups = {AddGroup.class, EditGroup.class}) - private Integer orderNum; - - /** - * key閿� - */ - @NotBlank(message = "key閿笉鑳戒负绌�", groups = {AddGroup.class, EditGroup.class}) - private String testKey; - - /** - * 鍊� - */ - @NotBlank(message = "鍊间笉鑳戒负绌�", groups = {AddGroup.class, EditGroup.class}) - private String value; - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/bo/TestDemoImportVo.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/bo/TestDemoImportVo.java deleted file mode 100644 index 7685cb7..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/bo/TestDemoImportVo.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.ruoyi.demo.domain.bo; - -import com.alibaba.excel.annotation.ExcelProperty; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import lombok.Data; - -/** - * 娴嬭瘯鍗曡〃涓氬姟瀵硅薄 test_demo - * - * @author Lion Li - * @date 2021-07-26 - */ -@Data -public class TestDemoImportVo { - - /** - * 閮ㄩ棬id - */ - @NotNull(message = "閮ㄩ棬id涓嶈兘涓虹┖") - @ExcelProperty(value = "閮ㄩ棬id") - private Long deptId; - - /** - * 鐢ㄦ埛id - */ - @NotNull(message = "鐢ㄦ埛id涓嶈兘涓虹┖") - @ExcelProperty(value = "鐢ㄦ埛id") - private Long userId; - - /** - * 鎺掑簭鍙� - */ - @NotNull(message = "鎺掑簭鍙蜂笉鑳戒负绌�") - @ExcelProperty(value = "鎺掑簭鍙�") - private Long orderNum; - - /** - * key閿� - */ - @NotBlank(message = "key閿笉鑳戒负绌�") - @ExcelProperty(value = "key閿�") - private String testKey; - - /** - * 鍊� - */ - @NotBlank(message = "鍊间笉鑳戒负绌�") - @ExcelProperty(value = "鍊�") - private String value; - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/bo/TestTreeBo.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/bo/TestTreeBo.java deleted file mode 100644 index 29b2c7f..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/bo/TestTreeBo.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.ruoyi.demo.domain.bo; - -import io.github.linpeilie.annotations.AutoMapper; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.ruoyi.common.core.validate.AddGroup; -import org.ruoyi.common.core.validate.EditGroup; -import org.ruoyi.core.domain.BaseEntity; -import org.ruoyi.demo.domain.TestTree; - -/** - * 娴嬭瘯鏍戣〃涓氬姟瀵硅薄 test_tree - * - * @author Lion Li - * @date 2021-07-26 - */ - -@Data -@EqualsAndHashCode(callSuper = true) -@AutoMapper(target = TestTree.class, reverseConvertGenerate = false) -public class TestTreeBo extends BaseEntity { - - /** - * 涓婚敭 - */ - @NotNull(message = "涓婚敭涓嶈兘涓虹┖", groups = {EditGroup.class}) - private Long id; - - /** - * 鐖禝D - */ - private Long parentId; - - /** - * 閮ㄩ棬id - */ - @NotNull(message = "閮ㄩ棬id涓嶈兘涓虹┖", groups = {AddGroup.class, EditGroup.class}) - private Long deptId; - - /** - * 鐢ㄦ埛id - */ - @NotNull(message = "鐢ㄦ埛id涓嶈兘涓虹┖", groups = {AddGroup.class, EditGroup.class}) - private Long userId; - - /** - * 鏍戣妭鐐瑰悕 - */ - @NotBlank(message = "鏍戣妭鐐瑰悕涓嶈兘涓虹┖", groups = {AddGroup.class, EditGroup.class}) - private String treeName; - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/vo/TestDemoVo.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/vo/TestDemoVo.java deleted file mode 100644 index d7a7334..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/vo/TestDemoVo.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.ruoyi.demo.domain.vo; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.github.linpeilie.annotations.AutoMapper; -import lombok.Data; -import org.ruoyi.common.translation.annotation.Translation; -import org.ruoyi.common.translation.constant.TransConstant; -import org.ruoyi.demo.domain.TestDemo; - -import java.io.Serial; -import java.io.Serializable; -import java.util.Date; - - -/** - * 娴嬭瘯鍗曡〃瑙嗗浘瀵硅薄 test_demo - * - * @author Lion Li - * @date 2021-07-26 - */ -@Data -@ExcelIgnoreUnannotated -@AutoMapper(target = TestDemo.class) -public class TestDemoVo implements Serializable { - - @Serial - private static final long serialVersionUID = 1L; - - /** - * 涓婚敭 - */ - @ExcelProperty(value = "涓婚敭") - private Long id; - - /** - * 閮ㄩ棬id - */ - @ExcelProperty(value = "閮ㄩ棬id") - private Long deptId; - - /** - * 鐢ㄦ埛id - */ - @ExcelProperty(value = "鐢ㄦ埛id") - private Long userId; - - /** - * 鎺掑簭鍙� - */ - @ExcelProperty(value = "鎺掑簭鍙�") - private Integer orderNum; - - /** - * key閿� - */ - @ExcelProperty(value = "key閿�") - private String testKey; - - /** - * 鍊� - */ - @ExcelProperty(value = "鍊�") - private String value; - - /** - * 鍒涘缓鏃堕棿 - */ - @ExcelProperty(value = "鍒涘缓鏃堕棿") - private Date createTime; - - /** - * 鍒涘缓浜� - */ - @ExcelProperty(value = "鍒涘缓浜�") - private Long createBy; - - /** - * 鍒涘缓浜鸿处鍙� - */ - @Translation(type = TransConstant.USER_ID_TO_NAME, mapper = "createBy") - @ExcelProperty(value = "鍒涘缓浜鸿处鍙�") - private String createByName; - - /** - * 鏇存柊鏃堕棿 - */ - @ExcelProperty(value = "鏇存柊鏃堕棿") - private Date updateTime; - - /** - * 鏇存柊浜� - */ - @ExcelProperty(value = "鏇存柊浜�") - private Long updateBy; - - /** - * 鏇存柊浜鸿处鍙� - */ - @Translation(type = TransConstant.USER_ID_TO_NAME, mapper = "updateBy") - @ExcelProperty(value = "鏇存柊浜鸿处鍙�") - private String updateByName; - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/vo/TestTreeVo.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/vo/TestTreeVo.java deleted file mode 100644 index f9e3e1e..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/domain/vo/TestTreeVo.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.ruoyi.demo.domain.vo; - -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.github.linpeilie.annotations.AutoMapper; -import lombok.Data; -import org.ruoyi.demo.domain.TestTree; - -import java.io.Serial; -import java.io.Serializable; -import java.util.Date; - - -/** - * 娴嬭瘯鏍戣〃瑙嗗浘瀵硅薄 test_tree - * - * @author Lion Li - * @date 2021-07-26 - */ -@Data -@ExcelIgnoreUnannotated -@AutoMapper(target = TestTree.class) -public class TestTreeVo implements Serializable { - - @Serial - private static final long serialVersionUID = 1L; - - /** - * 涓婚敭 - */ - private Long id; - - /** - * 鐖秈d - */ - @ExcelProperty(value = "鐖秈d") - private Long parentId; - - /** - * 閮ㄩ棬id - */ - @ExcelProperty(value = "閮ㄩ棬id") - private Long deptId; - - /** - * 鐢ㄦ埛id - */ - @ExcelProperty(value = "鐢ㄦ埛id") - private Long userId; - - /** - * 鏍戣妭鐐瑰悕 - */ - @ExcelProperty(value = "鏍戣妭鐐瑰悕") - private String treeName; - - /** - * 鍒涘缓鏃堕棿 - */ - @ExcelProperty(value = "鍒涘缓鏃堕棿") - private Date createTime; - - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/mapper/TestDemoEncryptMapper.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/mapper/TestDemoEncryptMapper.java deleted file mode 100644 index bd752b1..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/mapper/TestDemoEncryptMapper.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.ruoyi.demo.mapper; - -import org.ruoyi.core.mapper.BaseMapperPlus; -import org.ruoyi.demo.domain.TestDemoEncrypt; - -/** - * 娴嬭瘯鍔犲瘑鍔熻兘 - * - * @author Lion Li - */ -public interface TestDemoEncryptMapper extends BaseMapperPlus<TestDemoEncrypt, TestDemoEncrypt> { - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/mapper/TestDemoMapper.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/mapper/TestDemoMapper.java deleted file mode 100644 index 7848335..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/mapper/TestDemoMapper.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.ruoyi.demo.mapper; - -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.ruoyi.annotation.DataColumn; -import org.ruoyi.annotation.DataPermission; -import org.ruoyi.core.mapper.BaseMapperPlus; -import org.ruoyi.demo.domain.TestDemo; -import org.ruoyi.demo.domain.vo.TestDemoVo; - -import java.util.Collection; -import java.util.List; - -/** - * 娴嬭瘯鍗曡〃Mapper鎺ュ彛 - * - * @author Lion Li - * @date 2021-07-26 - */ -public interface TestDemoMapper extends BaseMapperPlus<TestDemo, TestDemoVo> { - - @DataPermission({ - @DataColumn(key = "deptName", value = "dept_id"), - @DataColumn(key = "userName", value = "user_id") - }) - Page<TestDemoVo> customPageList(@Param("page") Page<TestDemo> page, @Param("ew") Wrapper<TestDemo> wrapper); - - @Override - @DataPermission({ - @DataColumn(key = "deptName", value = "dept_id"), - @DataColumn(key = "userName", value = "user_id") - }) - <P extends IPage<TestDemo>> P selectPage(P page, @Param(Constants.WRAPPER) Wrapper<TestDemo> queryWrapper); - - @Override - @DataPermission({ - @DataColumn(key = "deptName", value = "dept_id"), - @DataColumn(key = "userName", value = "user_id") - }) - List<TestDemo> selectList(@Param(Constants.WRAPPER) Wrapper<TestDemo> queryWrapper); - - @Override - @DataPermission({ - @DataColumn(key = "deptName", value = "dept_id"), - @DataColumn(key = "userName", value = "user_id") - }) - int updateById(@Param(Constants.ENTITY) TestDemo entity); - - @Override - @DataPermission({ - @DataColumn(key = "deptName", value = "dept_id"), - @DataColumn(key = "userName", value = "user_id") - }) - int deleteBatchIds(@Param(Constants.COLL) Collection<?> idList); -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/mapper/TestTreeMapper.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/mapper/TestTreeMapper.java deleted file mode 100644 index d8558f3..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/mapper/TestTreeMapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.ruoyi.demo.mapper; - -import org.ruoyi.annotation.DataColumn; -import org.ruoyi.annotation.DataPermission; -import org.ruoyi.core.mapper.BaseMapperPlus; -import org.ruoyi.demo.domain.TestTree; -import org.ruoyi.demo.domain.vo.TestTreeVo; - -/** - * 娴嬭瘯鏍戣〃Mapper鎺ュ彛 - * - * @author Lion Li - * @date 2021-07-26 - */ -@DataPermission({ - @DataColumn(key = "deptName", value = "dept_id"), - @DataColumn(key = "userName", value = "user_id") -}) -public interface TestTreeMapper extends BaseMapperPlus<TestTree, TestTreeVo> { - -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/service/ITestDemoService.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/service/ITestDemoService.java deleted file mode 100644 index b30132c..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/service/ITestDemoService.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.ruoyi.demo.service; - -import org.ruoyi.core.page.PageQuery; -import org.ruoyi.core.page.TableDataInfo; -import org.ruoyi.demo.domain.TestDemo; -import org.ruoyi.demo.domain.bo.TestDemoBo; -import org.ruoyi.demo.domain.vo.TestDemoVo; - -import java.util.Collection; -import java.util.List; - -/** - * 娴嬭瘯鍗曡〃Service鎺ュ彛 - * - * @author Lion Li - * @date 2021-07-26 - */ -public interface ITestDemoService { - - /** - * 鏌ヨ鍗曚釜 - * - * @return - */ - TestDemoVo queryById(Long id); - - /** - * 鏌ヨ鍒楄〃 - */ - TableDataInfo<TestDemoVo> queryPageList(TestDemoBo bo, PageQuery pageQuery); - - /** - * 鑷畾涔夊垎椤垫煡璇� - */ - TableDataInfo<TestDemoVo> customPageList(TestDemoBo bo, PageQuery pageQuery); - - /** - * 鏌ヨ鍒楄〃 - */ - List<TestDemoVo> queryList(TestDemoBo bo); - - /** - * 鏍规嵁鏂板涓氬姟瀵硅薄鎻掑叆娴嬭瘯鍗曡〃 - * - * @param bo 娴嬭瘯鍗曡〃鏂板涓氬姟瀵硅薄 - * @return - */ - Boolean insertByBo(TestDemoBo bo); - - /** - * 鏍规嵁缂栬緫涓氬姟瀵硅薄淇敼娴嬭瘯鍗曡〃 - * - * @param bo 娴嬭瘯鍗曡〃缂栬緫涓氬姟瀵硅薄 - * @return - */ - Boolean updateByBo(TestDemoBo bo); - - /** - * 鏍¢獙骞跺垹闄ゆ暟鎹� - * - * @param ids 涓婚敭闆嗗悎 - * @param isValid 鏄惁鏍¢獙,true-鍒犻櫎鍓嶆牎楠�,false-涓嶆牎楠� - * @return - */ - Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); - - /** - * 鎵归噺淇濆瓨 - */ - Boolean saveBatch(List<TestDemo> list); -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/service/ITestTreeService.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/service/ITestTreeService.java deleted file mode 100644 index 6336fc1..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/service/ITestTreeService.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.ruoyi.demo.service; - -import org.ruoyi.demo.domain.bo.TestTreeBo; -import org.ruoyi.demo.domain.vo.TestTreeVo; - -import java.util.Collection; -import java.util.List; - -/** - * 娴嬭瘯鏍戣〃Service鎺ュ彛 - * - * @author Lion Li - * @date 2021-07-26 - */ -public interface ITestTreeService { - /** - * 鏌ヨ鍗曚釜 - * - * @return - */ - TestTreeVo queryById(Long id); - - /** - * 鏌ヨ鍒楄〃 - */ - List<TestTreeVo> queryList(TestTreeBo bo); - - /** - * 鏍规嵁鏂板涓氬姟瀵硅薄鎻掑叆娴嬭瘯鏍戣〃 - * - * @param bo 娴嬭瘯鏍戣〃鏂板涓氬姟瀵硅薄 - * @return - */ - Boolean insertByBo(TestTreeBo bo); - - /** - * 鏍规嵁缂栬緫涓氬姟瀵硅薄淇敼娴嬭瘯鏍戣〃 - * - * @param bo 娴嬭瘯鏍戣〃缂栬緫涓氬姟瀵硅薄 - * @return - */ - Boolean updateByBo(TestTreeBo bo); - - /** - * 鏍¢獙骞跺垹闄ゆ暟鎹� - * - * @param ids 涓婚敭闆嗗悎 - * @param isValid 鏄惁鏍¢獙,true-鍒犻櫎鍓嶆牎楠�,false-涓嶆牎楠� - * @return - */ - Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/service/impl/TestDemoServiceImpl.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/service/impl/TestDemoServiceImpl.java deleted file mode 100644 index dc2e6b6..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/service/impl/TestDemoServiceImpl.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.ruoyi.demo.service.impl; - -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.ruoyi.common.core.utils.MapstructUtils; -import org.ruoyi.common.core.utils.StringUtils; -import org.ruoyi.core.page.PageQuery; -import org.ruoyi.core.page.TableDataInfo; -import org.ruoyi.demo.domain.TestDemo; -import org.ruoyi.demo.domain.bo.TestDemoBo; -import org.ruoyi.demo.domain.vo.TestDemoVo; -import org.ruoyi.demo.mapper.TestDemoMapper; -import org.ruoyi.demo.service.ITestDemoService; -import org.springframework.stereotype.Service; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 娴嬭瘯鍗曡〃Service涓氬姟灞傚鐞� - * - * @author Lion Li - * @date 2021-07-26 - */ -@RequiredArgsConstructor -@Service -public class TestDemoServiceImpl implements ITestDemoService { - - private final TestDemoMapper baseMapper; - - @Override - public TestDemoVo queryById(Long id) { - return baseMapper.selectVoById(id); - } - - @Override - public TableDataInfo<TestDemoVo> queryPageList(TestDemoBo bo, PageQuery pageQuery) { - LambdaQueryWrapper<TestDemo> lqw = buildQueryWrapper(bo); - Page<TestDemoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); - return TableDataInfo.build(result); - } - - /** - * 鑷畾涔夊垎椤垫煡璇� - */ - @Override - public TableDataInfo<TestDemoVo> customPageList(TestDemoBo bo, PageQuery pageQuery) { - LambdaQueryWrapper<TestDemo> lqw = buildQueryWrapper(bo); - Page<TestDemoVo> result = baseMapper.customPageList(pageQuery.build(), lqw); - return TableDataInfo.build(result); - } - - @Override - public List<TestDemoVo> queryList(TestDemoBo bo) { - return baseMapper.selectVoList(buildQueryWrapper(bo)); - } - - private LambdaQueryWrapper<TestDemo> buildQueryWrapper(TestDemoBo bo) { - Map<String, Object> params = bo.getParams(); - LambdaQueryWrapper<TestDemo> lqw = Wrappers.lambdaQuery(); - lqw.like(StringUtils.isNotBlank(bo.getTestKey()), TestDemo::getTestKey, bo.getTestKey()); - lqw.eq(StringUtils.isNotBlank(bo.getValue()), TestDemo::getValue, bo.getValue()); - lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null, - TestDemo::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime")); - return lqw; - } - - @Override - public Boolean insertByBo(TestDemoBo bo) { - TestDemo add = MapstructUtils.convert(bo, TestDemo.class); - validEntityBeforeSave(add); - boolean flag = baseMapper.insert(add) > 0; - if (flag) { - bo.setId(add.getId()); - } - return flag; - } - - @Override - public Boolean updateByBo(TestDemoBo bo) { - TestDemo update = MapstructUtils.convert(bo, TestDemo.class); - validEntityBeforeSave(update); - return baseMapper.updateById(update) > 0; - } - - /** - * 淇濆瓨鍓嶇殑鏁版嵁鏍¢獙 - * - * @param entity 瀹炰綋绫绘暟鎹� - */ - private void validEntityBeforeSave(TestDemo entity) { - //TODO 鍋氫竴浜涙暟鎹牎楠�,濡傚敮涓�绾︽潫 - } - - @Override - public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { - if (isValid) { - //TODO 鍋氫竴浜涗笟鍔′笂鐨勬牎楠�,鍒ゆ柇鏄惁闇�瑕佹牎楠� - } - return baseMapper.deleteBatchIds(ids) > 0; - } - - @Override - public Boolean saveBatch(List<TestDemo> list) { - return baseMapper.insertBatch(list); - } -} diff --git a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/service/impl/TestTreeServiceImpl.java b/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/service/impl/TestTreeServiceImpl.java deleted file mode 100644 index 07ee214..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/java/org/ruoyi/demo/service/impl/TestTreeServiceImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.ruoyi.demo.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import lombok.RequiredArgsConstructor; -import org.ruoyi.common.core.utils.MapstructUtils; -import org.ruoyi.common.core.utils.StringUtils; -import org.ruoyi.demo.domain.TestTree; -import org.ruoyi.demo.domain.bo.TestTreeBo; -import org.ruoyi.demo.domain.vo.TestTreeVo; -import org.ruoyi.demo.mapper.TestTreeMapper; -import org.ruoyi.demo.service.ITestTreeService; -import org.springframework.stereotype.Service; - -import java.util.Collection; -import java.util.List; -import java.util.Map; - -/** - * 娴嬭瘯鏍戣〃Service涓氬姟灞傚鐞� - * - * @author Lion Li - * @date 2021-07-26 - */ -// @DS("slave") // 鍒囨崲浠庡簱鏌ヨ -@RequiredArgsConstructor -@Service -public class TestTreeServiceImpl implements ITestTreeService { - - private final TestTreeMapper baseMapper; - - @Override - public TestTreeVo queryById(Long id) { - return baseMapper.selectVoById(id); - } - - // @DS("slave") // 鍒囨崲浠庡簱鏌ヨ - @Override - public List<TestTreeVo> queryList(TestTreeBo bo) { - LambdaQueryWrapper<TestTree> lqw = buildQueryWrapper(bo); - return baseMapper.selectVoList(lqw); - } - - private LambdaQueryWrapper<TestTree> buildQueryWrapper(TestTreeBo bo) { - Map<String, Object> params = bo.getParams(); - LambdaQueryWrapper<TestTree> lqw = Wrappers.lambdaQuery(); - lqw.like(StringUtils.isNotBlank(bo.getTreeName()), TestTree::getTreeName, bo.getTreeName()); - lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null, - TestTree::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime")); - return lqw; - } - - @Override - public Boolean insertByBo(TestTreeBo bo) { - TestTree add = MapstructUtils.convert(bo, TestTree.class); - validEntityBeforeSave(add); - boolean flag = baseMapper.insert(add) > 0; - if (flag) { - bo.setId(add.getId()); - } - return flag; - } - - @Override - public Boolean updateByBo(TestTreeBo bo) { - TestTree update = MapstructUtils.convert(bo, TestTree.class); - validEntityBeforeSave(update); - return baseMapper.updateById(update) > 0; - } - - /** - * 淇濆瓨鍓嶇殑鏁版嵁鏍¢獙 - * - * @param entity 瀹炰綋绫绘暟鎹� - */ - private void validEntityBeforeSave(TestTree entity) { - //TODO 鍋氫竴浜涙暟鎹牎楠�,濡傚敮涓�绾︽潫 - } - - @Override - public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { - if (isValid) { - //TODO 鍋氫竴浜涗笟鍔′笂鐨勬牎楠�,鍒ゆ柇鏄惁闇�瑕佹牎楠� - } - return baseMapper.deleteBatchIds(ids) > 0; - } -} diff --git "a/ruoyi-modules/ruoyi-demo/src/main/resources/excel/\345\215\225\345\210\227\350\241\250.xlsx" "b/ruoyi-modules/ruoyi-demo/src/main/resources/excel/\345\215\225\345\210\227\350\241\250.xlsx" deleted file mode 100644 index 0f7347d..0000000 --- "a/ruoyi-modules/ruoyi-demo/src/main/resources/excel/\345\215\225\345\210\227\350\241\250.xlsx" +++ /dev/null Binary files differ diff --git "a/ruoyi-modules/ruoyi-demo/src/main/resources/excel/\345\244\232\345\210\227\350\241\250.xlsx" "b/ruoyi-modules/ruoyi-demo/src/main/resources/excel/\345\244\232\345\210\227\350\241\250.xlsx" deleted file mode 100644 index c7d11dc..0000000 --- "a/ruoyi-modules/ruoyi-demo/src/main/resources/excel/\345\244\232\345\210\227\350\241\250.xlsx" +++ /dev/null Binary files differ diff --git a/ruoyi-modules/ruoyi-demo/src/main/resources/mapper/demo/TestDemoMapper.xml b/ruoyi-modules/ruoyi-demo/src/main/resources/mapper/demo/TestDemoMapper.xml deleted file mode 100644 index 6d00b20..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/resources/mapper/demo/TestDemoMapper.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!DOCTYPE mapper -PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" -"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="org.ruoyi.demo.mapper.TestDemoMapper"> - - <select id="customPageList" resultType="org.ruoyi.demo.domain.vo.TestDemoVo"> - SELECT * FROM test_demo ${ew.customSqlSegment} - </select> - -</mapper> diff --git a/ruoyi-modules/ruoyi-demo/src/main/resources/mapper/demo/TestTreeMapper.xml b/ruoyi-modules/ruoyi-demo/src/main/resources/mapper/demo/TestTreeMapper.xml deleted file mode 100644 index 46b0e36..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/resources/mapper/demo/TestTreeMapper.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!DOCTYPE mapper -PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" -"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="org.ruoyi.demo.mapper.TestTreeMapper"> - -</mapper> diff --git a/ruoyi-modules/ruoyi-demo/src/main/resources/mapper/package-info.md b/ruoyi-modules/ruoyi-demo/src/main/resources/mapper/package-info.md deleted file mode 100644 index c938b1e..0000000 --- a/ruoyi-modules/ruoyi-demo/src/main/resources/mapper/package-info.md +++ /dev/null @@ -1,3 +0,0 @@ -java鍖呬娇鐢� `.` 鍒嗗壊 resource 鐩綍浣跨敤 `/` 鍒嗗壊 -<br> -姝ゆ枃浠剁洰鐨� 闃叉鏂囦欢澶圭矘杩炴壘涓嶅埌 `xml` 鏂囦欢 \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-generator/src/main/java/org/ruoyi/generator/domain/GenTableColumn.java b/ruoyi-modules/ruoyi-generator/src/main/java/org/ruoyi/generator/domain/GenTableColumn.java index c88836f..e96dec6 100644 --- a/ruoyi-modules/ruoyi-generator/src/main/java/org/ruoyi/generator/domain/GenTableColumn.java +++ b/ruoyi-modules/ruoyi-generator/src/main/java/org/ruoyi/generator/domain/GenTableColumn.java @@ -41,7 +41,7 @@ /** * 鍒楁弿杩� */ - @TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) + @TableField(updateStrategy = FieldStrategy.ALWAYS, jdbcType = JdbcType.VARCHAR) private String columnComment; /** @@ -63,43 +63,43 @@ /** * 鏄惁涓婚敭锛�1鏄級 */ - @TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) + @TableField(updateStrategy = FieldStrategy.ALWAYS, jdbcType = JdbcType.VARCHAR) private String isPk; /** * 鏄惁鑷锛�1鏄級 */ - @TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) + @TableField(updateStrategy = FieldStrategy.ALWAYS, jdbcType = JdbcType.VARCHAR) private String isIncrement; /** * 鏄惁蹇呭~锛�1鏄級 */ - @TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) + @TableField(updateStrategy = FieldStrategy.ALWAYS, jdbcType = JdbcType.VARCHAR) private String isRequired; /** * 鏄惁涓烘彃鍏ュ瓧娈碉紙1鏄級 */ - @TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) + @TableField(updateStrategy = FieldStrategy.ALWAYS, jdbcType = JdbcType.VARCHAR) private String isInsert; /** * 鏄惁缂栬緫瀛楁锛�1鏄級 */ - @TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) + @TableField(updateStrategy = FieldStrategy.ALWAYS, jdbcType = JdbcType.VARCHAR) private String isEdit; /** * 鏄惁鍒楄〃瀛楁锛�1鏄級 */ - @TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) + @TableField(updateStrategy = FieldStrategy.ALWAYS, jdbcType = JdbcType.VARCHAR) private String isList; /** * 鏄惁鏌ヨ瀛楁锛�1鏄級 */ - @TableField(updateStrategy = FieldStrategy.IGNORED, jdbcType = JdbcType.VARCHAR) + @TableField(updateStrategy = FieldStrategy.ALWAYS, jdbcType = JdbcType.VARCHAR) private String isQuery; /** -- Gitblit v1.9.3