Browse Source

钉钉发送消息

夏文涛 1 year ago
parent
commit
5570ecf3ed

+ 13 - 0
.idea/libraries/Maven__cn_snowheart_spring_boot_dingtalk_robot_starter_1_0_3_RELEASE.xml

@@ -0,0 +1,13 @@
+<component name="libraryTable">
+  <library name="Maven: cn.snowheart:spring-boot-dingtalk-robot-starter:1.0.3.RELEASE">
+    <CLASSES>
+      <root url="jar://$MAVEN_REPOSITORY$/cn/snowheart/spring-boot-dingtalk-robot-starter/1.0.3.RELEASE/spring-boot-dingtalk-robot-starter-1.0.3.RELEASE.jar!/" />
+    </CLASSES>
+    <JAVADOC>
+      <root url="jar://$MAVEN_REPOSITORY$/cn/snowheart/spring-boot-dingtalk-robot-starter/1.0.3.RELEASE/spring-boot-dingtalk-robot-starter-1.0.3.RELEASE-javadoc.jar!/" />
+    </JAVADOC>
+    <SOURCES>
+      <root url="jar://$MAVEN_REPOSITORY$/cn/snowheart/spring-boot-dingtalk-robot-starter/1.0.3.RELEASE/spring-boot-dingtalk-robot-starter-1.0.3.RELEASE-sources.jar!/" />
+    </SOURCES>
+  </library>
+</component>

+ 1 - 1
.idea/misc.xml

@@ -445,7 +445,7 @@
       </profile-state>
     </entry>
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/classes" />
   </component>
 </project>

+ 422 - 10
.idea/workspace.xml

@@ -1,5 +1,119 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
+  <component name="ChangeListManager">
+    <list default="true" id="af419770-cc4a-43bc-b95f-05e68869e008" name="Default Changelist" comment="">
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/template/api/DingTalkControllerAPI.java" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/main/java/com/template/controller/DingTalkController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/api/LoginControllerAPI.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/api/LoginControllerAPI.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/common/utils/TimeExchange.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/common/utils/TimeExchange.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/controller/ExcelController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/controller/ExcelController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/resources/application-dev.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application-dev.yml" afterDir="false" />
+    </list>
+    <ignored path="$PROJECT_DIR$/classes/" />
+    <ignored path="$PROJECT_DIR$/target/" />
+    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
+    <option name="SHOW_DIALOG" value="false" />
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
+    <option name="LAST_RESOLUTION" value="IGNORE" />
+  </component>
+  <component name="DefaultGradleProjectSettings">
+    <option name="testRunner" value="GRADLE" />
+    <option name="delegatedBuild" value="true" />
+  </component>
+  <component name="FileEditorManager">
+    <leaf>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/template/controller/ExcelController.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="240">
+              <caret line="18" column="52" selection-start-line="18" selection-start-column="52" selection-end-line="18" selection-end-column="52" />
+              <folding>
+                <element signature="imports" expanded="true" />
+              </folding>
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/template/controller/LoginController.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="414">
+              <caret line="33" column="4" selection-start-line="33" selection-start-column="4" selection-end-line="33" selection-end-column="82" />
+              <folding>
+                <element signature="imports" expanded="true" />
+              </folding>
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="true">
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/template/api/DingTalkControllerAPI.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="253">
+              <caret line="11" selection-start-line="11" selection-end-line="11" />
+              <folding>
+                <element signature="imports" expanded="true" />
+              </folding>
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/pom.xml">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="1160">
+              <caret line="240" column="21" selection-start-line="240" selection-start-column="21" selection-end-line="240" selection-end-column="21" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/template/api/LoginControllerAPI.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="378">
+              <caret line="18" column="4" selection-start-line="18" selection-start-column="4" selection-end-line="18" selection-end-column="73" />
+              <folding>
+                <element signature="imports" expanded="true" />
+              </folding>
+            </state>
+          </provider>
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/src/main/java/com/template/api/ExcelControllerAPI.java">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="230">
+              <caret line="14" column="14" selection-start-line="14" selection-start-column="14" selection-end-line="14" selection-end-column="14" />
+            </state>
+          </provider>
+        </entry>
+      </file>
+    </leaf>
+  </component>
+  <component name="FileTemplateManagerImpl">
+    <option name="RECENT_TEMPLATES">
+      <list>
+        <option value="Class" />
+      </list>
+    </option>
+  </component>
+  <component name="Git.Settings">
+    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
+  </component>
+  <component name="IdeDocumentHistory">
+    <option name="CHANGED_PATHS">
+      <list>
+        <option value="$PROJECT_DIR$/src/main/java/com/template/api/LoginControllerAPI.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/template/controller/ExcelController.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/template/api/ExcelControllerAPI.java" />
+        <option value="$PROJECT_DIR$/src/main/java/com/template/api/DingTalkControllerAPI.java" />
+        <option value="$PROJECT_DIR$/pom.xml" />
+        <option value="$PROJECT_DIR$/src/main/java/com/template/controller/DingTalkController.java" />
+      </list>
+    </option>
+  </component>
   <component name="MavenImportPreferences">
     <option name="generalSettings">
       <MavenGeneralSettings>
@@ -9,30 +123,317 @@
       </MavenGeneralSettings>
     </option>
   </component>
-  <component name="ProjectFrameBounds" extendedState="1">
+  <component name="MavenProjectNavigator">
+    <treeState>
+      <expand>
+        <path>
+          <item name="" type="16c1761:MavenProjectsStructure$RootNode" />
+          <item name="mybatis_plus" type="9519ce18:MavenProjectsStructure$ProjectNode" />
+        </path>
+        <path>
+          <item name="" type="16c1761:MavenProjectsStructure$RootNode" />
+          <item name="mybatis_plus" type="9519ce18:MavenProjectsStructure$ProjectNode" />
+          <item name="Lifecycle" type="58874e2:MavenProjectsStructure$LifecycleNode" />
+        </path>
+      </expand>
+      <select />
+    </treeState>
+  </component>
+  <component name="MavenRunner">
+    <option name="skipTests" value="true" />
+  </component>
+  <component name="ProjectFrameBounds">
     <option name="x" value="-7" />
     <option name="width" value="974" />
     <option name="height" value="1039" />
   </component>
+  <component name="ProjectView">
+    <navigator proportions="" version="1">
+      <foldersAlwaysOnTop value="true" />
+    </navigator>
+    <panes>
+      <pane id="ProjectPane">
+        <subPane>
+          <expand>
+            <path>
+              <item name="mybatis_plus" type="b2602c69:ProjectViewProjectNode" />
+              <item name="Back-endDevelopmentFramework" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="mybatis_plus" type="b2602c69:ProjectViewProjectNode" />
+              <item name="Back-endDevelopmentFramework" type="462c0819:PsiDirectoryNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="mybatis_plus" type="b2602c69:ProjectViewProjectNode" />
+              <item name="Back-endDevelopmentFramework" type="462c0819:PsiDirectoryNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+              <item name="main" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="mybatis_plus" type="b2602c69:ProjectViewProjectNode" />
+              <item name="Back-endDevelopmentFramework" type="462c0819:PsiDirectoryNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+              <item name="main" type="462c0819:PsiDirectoryNode" />
+              <item name="java" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="mybatis_plus" type="b2602c69:ProjectViewProjectNode" />
+              <item name="Back-endDevelopmentFramework" type="462c0819:PsiDirectoryNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+              <item name="main" type="462c0819:PsiDirectoryNode" />
+              <item name="java" type="462c0819:PsiDirectoryNode" />
+              <item name="template" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="mybatis_plus" type="b2602c69:ProjectViewProjectNode" />
+              <item name="Back-endDevelopmentFramework" type="462c0819:PsiDirectoryNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+              <item name="main" type="462c0819:PsiDirectoryNode" />
+              <item name="java" type="462c0819:PsiDirectoryNode" />
+              <item name="template" type="462c0819:PsiDirectoryNode" />
+              <item name="api" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="mybatis_plus" type="b2602c69:ProjectViewProjectNode" />
+              <item name="Back-endDevelopmentFramework" type="462c0819:PsiDirectoryNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+              <item name="main" type="462c0819:PsiDirectoryNode" />
+              <item name="java" type="462c0819:PsiDirectoryNode" />
+              <item name="template" type="462c0819:PsiDirectoryNode" />
+              <item name="controller" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="mybatis_plus" type="b2602c69:ProjectViewProjectNode" />
+              <item name="Back-endDevelopmentFramework" type="462c0819:PsiDirectoryNode" />
+              <item name="src" type="462c0819:PsiDirectoryNode" />
+              <item name="main" type="462c0819:PsiDirectoryNode" />
+              <item name="resources" type="462c0819:PsiDirectoryNode" />
+            </path>
+          </expand>
+          <select />
+        </subPane>
+      </pane>
+      <pane id="Scope" />
+      <pane id="PackagesPane" />
+    </panes>
+  </component>
   <component name="PropertiesComponent">
     <property name="WebServerToolWindowFactoryState" value="false" />
     <property name="aspect.path.notification.shown" value="true" />
-    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
+    <property name="last_opened_file_path" value="$PROJECT_DIR$/../../外卖服务/dev-feat" />
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
+    <property name="project.structure.last.edited" value="Project" />
+    <property name="project.structure.proportion" value="0.0" />
+    <property name="project.structure.side.proportion" value="0.0" />
     <property name="settings.editor.selected.configurable" value="MavenSettings" />
   </component>
-  <component name="RunManager">
-    <configuration name="MybatisPlusApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
-      <module name="mybatis_plus" />
-      <option name="SPRING_BOOT_MAIN_CLASS" value="com.template.MybatisPlusApplication" />
-      <method v="2">
-        <option name="Make" enabled="true" />
-      </method>
-    </configuration>
+  <component name="RebelAgentSelection">
+    <selection>jr</selection>
+  </component>
+  <component name="RecentsManager">
+    <key name="CopyClassDialog.RECENTS_KEY">
+      <recent name="com.template.api" />
+    </key>
+  </component>
+  <component name="RunDashboard">
+    <option name="ruleStates">
+      <list>
+        <RuleState>
+          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
+        </RuleState>
+        <RuleState>
+          <option name="name" value="StatusDashboardGroupingRule" />
+        </RuleState>
+      </list>
+    </option>
+  </component>
+  <component name="SvnConfiguration">
+    <configuration />
+  </component>
+  <component name="TaskManager">
+    <task active="true" id="Default" summary="Default task">
+      <changelist id="af419770-cc4a-43bc-b95f-05e68869e008" name="Default Changelist" comment="" />
+      <created>1728973976319</created>
+      <option name="number" value="Default" />
+      <option name="presentableId" value="Default" />
+      <updated>1728973976319</updated>
+      <workItem from="1728973977437" duration="3740000" />
+    </task>
+    <servers />
+  </component>
+  <component name="TimeTrackingManager">
+    <option name="totallyTimeSpent" value="3740000" />
+  </component>
+  <component name="ToolWindowManager">
+    <frame x="-7" y="0" width="974" height="1039" extended-state="0" />
+    <layout>
+      <window_info id="JRebel" side_tool="true" />
+      <window_info id="Image Layers" />
+      <window_info id="Capture Tool" />
+      <window_info id="UI Designer" />
+      <window_info id="Favorites" side_tool="true" />
+      <window_info id="Designer" />
+      <window_info id="Web" side_tool="true" />
+      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.4157549" />
+      <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
+      <window_info anchor="bottom" id="Spring" />
+      <window_info anchor="bottom" id="Event Log" side_tool="true" />
+      <window_info anchor="bottom" id="Terminal" />
+      <window_info anchor="bottom" id="Docker" />
+      <window_info anchor="bottom" id="Java Enterprise" />
+      <window_info anchor="bottom" id="Database Changes" />
+      <window_info anchor="bottom" id="Version Control" />
+      <window_info anchor="bottom" id="JRebel Executor" />
+      <window_info anchor="bottom" id="JRebel Console" side_tool="true" />
+      <window_info anchor="bottom" id="Message" order="0" />
+      <window_info anchor="bottom" id="Find" order="1" />
+      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.3325967" />
+      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
+      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
+      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
+      <window_info anchor="bottom" id="TODO" order="6" />
+      <window_info anchor="right" id="Maven" visible="true" weight="0.32932165" />
+      <window_info anchor="right" id="Palette" />
+      <window_info anchor="right" id="Capture Analysis" />
+      <window_info anchor="right" id="Database" />
+      <window_info anchor="right" id="Palette&#9;" />
+      <window_info anchor="right" id="Theme Preview" />
+      <window_info anchor="right" id="JRebel Setup Guide" side_tool="true" />
+      <window_info anchor="right" id="Bean Validation" />
+      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
+      <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
+      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
+    </layout>
+  </component>
+  <component name="TypeScriptGeneratedFilesManager">
+    <option name="version" value="1" />
+  </component>
+  <component name="editorHistoryManager">
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/template/api/ExcelControllerAPI.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="230">
+          <caret line="14" column="14" selection-start-line="14" selection-start-column="14" selection-end-line="14" selection-end-column="14" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/template/api/LoginControllerAPI.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="378">
+          <caret line="18" column="4" selection-start-line="18" selection-start-column="4" selection-end-line="18" selection-end-column="73" />
+          <folding>
+            <element signature="imports" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/pom.xml">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="1160">
+          <caret line="240" column="21" selection-start-line="240" selection-start-column="21" selection-end-line="240" selection-end-column="21" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/template/controller/LoginController.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="414">
+          <caret line="33" column="4" selection-start-line="33" selection-start-column="4" selection-end-line="33" selection-end-column="82" />
+          <folding>
+            <element signature="imports" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/template/controller/ExcelController.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="240">
+          <caret line="18" column="52" selection-start-line="18" selection-start-column="52" selection-end-line="18" selection-end-column="52" />
+          <folding>
+            <element signature="imports" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/template/controller/DingTalkController.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="318">
+          <caret line="61" column="5" lean-forward="true" selection-start-line="61" selection-start-column="5" selection-end-line="61" selection-end-column="5" />
+          <folding>
+            <element signature="imports" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/src/main/java/com/template/api/DingTalkControllerAPI.java">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="253">
+          <caret line="11" selection-start-line="11" selection-end-line="11" />
+          <folding>
+            <element signature="imports" expanded="true" />
+          </folding>
+        </state>
+      </provider>
+    </entry>
   </component>
   <component name="masterDetails">
     <states>
+      <state key="ArtifactsStructureConfigurable.UI">
+        <settings>
+          <artifact-editor />
+          <splitter-proportions>
+            <option name="proportions">
+              <list>
+                <option value="0.2" />
+              </list>
+            </option>
+          </splitter-proportions>
+        </settings>
+      </state>
+      <state key="FacetStructureConfigurable.UI">
+        <settings>
+          <splitter-proportions>
+            <option name="proportions">
+              <list>
+                <option value="0.2" />
+              </list>
+            </option>
+          </splitter-proportions>
+        </settings>
+      </state>
+      <state key="GlobalLibrariesConfigurable.UI">
+        <settings>
+          <splitter-proportions>
+            <option name="proportions">
+              <list>
+                <option value="0.2" />
+              </list>
+            </option>
+          </splitter-proportions>
+        </settings>
+      </state>
+      <state key="JdkListConfigurable.UI">
+        <settings>
+          <splitter-proportions>
+            <option name="proportions">
+              <list>
+                <option value="0.2" />
+              </list>
+            </option>
+          </splitter-proportions>
+        </settings>
+      </state>
+      <state key="ModuleStructureConfigurable.UI">
+        <settings>
+          <splitter-proportions>
+            <option name="proportions">
+              <list>
+                <option value="0.2" />
+              </list>
+            </option>
+          </splitter-proportions>
+        </settings>
+      </state>
       <state key="ProjectJDKs.UI">
         <settings>
           <last-edited>1.8</last-edited>
@@ -45,6 +446,17 @@
           </splitter-proportions>
         </settings>
       </state>
+      <state key="ProjectLibrariesConfigurable.UI">
+        <settings>
+          <splitter-proportions>
+            <option name="proportions">
+              <list>
+                <option value="0.2" />
+              </list>
+            </option>
+          </splitter-proportions>
+        </settings>
+      </state>
     </states>
   </component>
 </project>

+ 1 - 0
mybatis_plus.iml

@@ -197,5 +197,6 @@
     <orderEntry type="library" name="Maven: org.glassfish.jaxb:txw2:2.3.3" level="project" />
     <orderEntry type="library" name="Maven: com.sun.istack:istack-commons-runtime:3.0.11" level="project" />
     <orderEntry type="library" scope="RUNTIME" name="Maven: com.sun.activation:jakarta.activation:1.2.2" level="project" />
+    <orderEntry type="library" name="Maven: cn.snowheart:spring-boot-dingtalk-robot-starter:1.0.3.RELEASE" level="project" />
   </component>
 </module>

+ 6 - 0
pom.xml

@@ -233,6 +233,12 @@
             <artifactId>easyexcel</artifactId>
             <version>2.2.11</version>
         </dependency>
+        <!--钉钉机器人-->
+        <dependency>
+            <groupId>cn.snowheart</groupId>
+            <artifactId>spring-boot-dingtalk-robot-starter</artifactId>
+            <version>1.0.3.RELEASE</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 26 - 0
src/main/java/com/template/api/DingTalkControllerAPI.java

@@ -0,0 +1,26 @@
+package com.template.api;
+
+import com.template.model.result.CommonResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@Api(tags = {"DingTalkControllerAPI"}, value = "钉钉发送消息")
+@RequestMapping("/api/dingTalk")
+public interface DingTalkControllerAPI {
+
+    @GetMapping("/sendTextMsg")
+    @ApiOperation(value = "测试发送文本消息", notes = "测试发送文本消息", httpMethod = "GET")
+    CommonResult sendMessage();
+
+    @GetMapping("/sendFeedCardMessage")
+    @ApiOperation(value = "测试发送消息", notes = "测试发送消息", httpMethod = "GET")
+    CommonResult sendFeedCardMessage();
+
+    @GetMapping("/sendActionCardMessage")
+    @ApiOperation(value = "测试发送卡片消息", notes = "测试发送卡片消息", httpMethod = "GET")
+    CommonResult sendActionCardMessage();
+
+
+}

+ 0 - 1
src/main/java/com/template/api/LoginControllerAPI.java

@@ -9,7 +9,6 @@ import org.springframework.validation.BindingResult;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
-import javax.validation.Valid;
 
 
 @RequestMapping("/api/login")

+ 101 - 75
src/main/java/com/template/common/utils/TimeExchange.java

@@ -24,13 +24,11 @@ import java.util.*;
 public class TimeExchange {
 
     /**
-     * String(yyyy-MM-dd HH:mm:ss) 转 Date
-     *
-     * @param time
+     * 字符串转时间
+     * @param time 时间字符串
+     * @param formatDate 时间格式
      * @return
-     * @throws ParseException
      */
-    // String date = "2010/05/04 12:34:23";
     public static Date StringToDate(String time, String formatDate) {
 
         Date date = new Date();
@@ -46,23 +44,28 @@ public class TimeExchange {
     }
 
     /**
-     * Date转为String(yyyy-MM-dd HH:mm:ss)
-     *
-     * @param time
+     * Date转为String
+     * @param time      时间
+     * @param FormatStr 自定义时间格式
      * @return
      */
-    public static String DateToString(Date time) {
+    public static String DateToString(Date time, String FormatStr) {
         String dateStr = "";
-        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:sss");
+        DateFormat dateFormat = new SimpleDateFormat(FormatStr);
         try {
             dateStr = dateFormat.format(time);
-            System.out.println(dateStr);
         } catch (Exception e) {
             e.printStackTrace();
         }
         return dateStr;
     }
 
+
+    /**
+     * 时间转中文的年月日格式
+     * @param time
+     * @return
+     */
     public static String chineseDateTime(Date time) {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分");
         String dateStringParse = null;
@@ -77,8 +80,7 @@ public class TimeExchange {
     }
 
     /**
-     * String(yyyy-MM-dd HH:mm:ss)转10位时间戳
-     *
+     * String转时间戳
      * @param time
      * @return
      */
@@ -98,6 +100,7 @@ public class TimeExchange {
     }
 
     /**
+     * 时间戳转String
      * 10位int型的时间戳转换为String(yyyy-MM-dd HH:mm:ss)
      *
      * @param time
@@ -162,7 +165,12 @@ public class TimeExchange {
         return (int) ((ts.getTime()) / 1000);
     }
 
-    // 当前时间减1小时
+    /**
+     * 时间减小时数
+     * @param time
+     * @param hour
+     * @return
+     */
     public static String TimeDesH(Date time, int hour) {
         Calendar nowTime2 = Calendar.getInstance();
         nowTime2.setTime(time);
@@ -171,16 +179,12 @@ public class TimeExchange {
         return simpleDateFormat.format(nowTime2.getTime());
     }
 
-
-    // 当前时间加5分钟
-    public static String TimeRangeI(String time) throws ParseException {
-        // 当前时间+5分钟
-        Date endTime = DateUtils.addMinutes(StringToDate(time, "yyyy-MM-dd HH:mm:ss"), 300);
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        return simpleDateFormat.format(endTime);
-    }
-
-    // 当前时间加X秒
+    /**
+     * 时间加秒数
+     * @param time
+     * @param s
+     * @return
+     */
     public static String TimeRangeSrcond(String time, int s) {
         Calendar nowTime2 = Calendar.getInstance();
         nowTime2.setTime(StringToDate(time, "yyyy-MM-dd HH:mm:ss"));
@@ -189,7 +193,12 @@ public class TimeExchange {
         return simpleDateFormat.format(nowTime2.getTime());
     }
 
-    // 当前时间加X分钟
+    /**
+     * 时间加分钟数
+     * @param time
+     * @param m
+     * @return
+     */
     public static String TimeRangeMinute(String time, int m) {
         Calendar nowTime2 = Calendar.getInstance();
         nowTime2.setTime(StringToDate(time, "yyyy-MM-dd HH:mm:ss"));
@@ -198,16 +207,10 @@ public class TimeExchange {
         return simpleDateFormat.format(nowTime2.getTime());
     }
 
-    // 当前时间减5分钟
-    public static String TimeRangeD(String time) throws ParseException {
-        Calendar nowTime2 = Calendar.getInstance();
-        nowTime2.setTime(StringToDate(time, "yyyy-MM-dd HH:mm:ss"));
-        nowTime2.add(Calendar.MINUTE, -300);//5分钟前的时间
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        return simpleDateFormat.format(nowTime2.getTime());
-    }
-
-    // 获取当天开始时间
+    /**
+     * 获取当天开始时间
+     * @return
+     */
     public static String getStartDate() {
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(new Date());
@@ -219,7 +222,10 @@ public class TimeExchange {
         return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime());
     }
 
-    // 获取当天结束时间
+    /**
+     * 获取当天结束时间
+     * @return
+     */
     public static String getEndDate() {
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(new Date());
@@ -231,83 +237,113 @@ public class TimeExchange {
         return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime());
     }
 
-    // 获取当前日期
+    /**
+     * 获取当天的年月日
+     * @return
+     */
     public static String getDate() {
         SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd");
         return sp.format(new Date());
     }
 
-    // 获取当前日期的年月
+    /**
+     * 获取当天的年月
+     * @return
+     */
     public static String getDateMonth() {
         SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-");
         return sp.format(new Date());
     }
 
-    // 获取前天
-    public static String getQianDay() throws ParseException {
-        Calendar nowTime2 = Calendar.getInstance();
-        nowTime2.setTime(StringToDate(getTime(), "yyyy-MM-dd HH:mm:ss"));
-        nowTime2.add(Calendar.DATE, -5);//5分钟前的时间
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        return simpleDateFormat.format(nowTime2.getTime());
-    }
-
-    // 获取当前时间
+    /**
+     * 获取当前时间的年月日小时分钟秒
+     * @return
+     */
     public static String getTime() {
         SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         return sp.format(new Date());
     }
 
+    /**
+     * 获取当前时间的小时分钟
+     * @return
+     */
     public static String getOnlyMM() {
         SimpleDateFormat sp = new SimpleDateFormat("HH:mm");
         return sp.format(new Date());
     }
 
-    public static String getOnlyDesMM() throws ParseException {
-        Calendar nowTime2 = Calendar.getInstance();
-        nowTime2.setTime(StringToDate(getTime(), "yyyy-MM-dd HH:mm:ss"));
-        nowTime2.add(Calendar.MINUTE, -5);//5分钟前的时间
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
-        return simpleDateFormat.format(nowTime2.getTime());
-    }
-
+    /**
+     * 获取当前时间的年份
+     * @return
+     */
     public static String getYear() {
         SimpleDateFormat sp = new SimpleDateFormat("yyyy");
         return sp.format(new Date());
     }
 
+    /**
+     * 获取当前时间的年月
+     * @return
+     */
     public static String getMonth() {
         SimpleDateFormat sp = new SimpleDateFormat("yyyy-MM");
         return sp.format(new Date());
     }
 
+    /**
+     * 获取当前时间的月份
+     * @return
+     */
     public static String getNowMonth() {
         SimpleDateFormat sp = new SimpleDateFormat("MM");
         return sp.format(new Date());
     }
 
-    // 获取当前时间
+    /**
+     * 获取当前时间的小时分钟秒
+     * @return
+     */
     public static String getOnlyTime() {
         SimpleDateFormat sp = new SimpleDateFormat("HH:mm:ss");
         return sp.format(new Date());
     }
 
-
+    /**
+     * 获取指定时间的年份
+     * @param dateNow
+     * @return
+     */
     public static String getYear(Date dateNow) {
         SimpleDateFormat sp = new SimpleDateFormat("yyyy");
         return sp.format(dateNow);
     }
 
+    /**
+     * 获取指定时间的月份
+     * @param dateNow
+     * @return
+     */
     public static String getMonth(Date dateNow) {
         SimpleDateFormat sp = new SimpleDateFormat("MM");
         return sp.format(new Date());
     }
 
+    /**
+     * 获取指定时间的天
+     * @param dateNow
+     * @return
+     */
     public static String getDay(Date dateNow) {
         SimpleDateFormat sp = new SimpleDateFormat("dd");
         return sp.format(new Date());
     }
 
+    /**
+     * 获取指定时间的小时分钟秒
+     * @param dateNow
+     * @return
+     */
     public static String getTime(Date dateNow) {
         SimpleDateFormat sp = new SimpleDateFormat("HH:mm:ss");
         return sp.format(new Date());
@@ -342,6 +378,12 @@ public class TimeExchange {
         return hours + minutes;
     }
 
+    /**
+     * 计算两个日期的时间差
+     * @param time1
+     * @param time2
+     * @return
+     */
     public static double getOnlyTimeDifference(String time1, String time2) {
         SimpleDateFormat timeformat = new SimpleDateFormat("HH:mm:ss");
         long t1 = 0L;
@@ -421,23 +463,7 @@ public class TimeExchange {
         return date;
     }
 
-    /**
-     * Date转为String
-     *
-     * @param time      时间
-     * @param FormatStr 自定义时间格式
-     * @return
-     */
-    public static String DateToString(Date time, String FormatStr) {
-        String dateStr = "";
-        DateFormat dateFormat = new SimpleDateFormat(FormatStr);
-        try {
-            dateStr = dateFormat.format(time);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return dateStr;
-    }
+
 
     /**
      * 日期路径 即年/月/日 如2018/08/08

+ 78 - 0
src/main/java/com/template/controller/DingTalkController.java

@@ -0,0 +1,78 @@
+package com.template.controller;
+
+import cn.snowheart.dingtalk.robot.starter.client.DingTalkRobotClient;
+import cn.snowheart.dingtalk.robot.starter.entity.ActionCardMessage;
+import cn.snowheart.dingtalk.robot.starter.entity.DingTalkResponse;
+import cn.snowheart.dingtalk.robot.starter.entity.FeedCardMessageItem;
+import cn.snowheart.dingtalk.robot.starter.entity.TextMessage;
+import cn.snowheart.dingtalk.robot.starter.type.ButtonOrientationType;
+import cn.snowheart.dingtalk.robot.starter.type.HideAvatarType;
+import com.template.annotation.PassToken;
+import com.template.api.DingTalkControllerAPI;
+import com.template.model.result.CommonResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+
+/**
+ * @Author: binguo
+ * @Date: 2024/10/15 星期二 14:39
+ * @Description: com.template.controller
+ * @Version: 1.0
+ */
+@RestController
+public class DingTalkController implements DingTalkControllerAPI {
+    @Autowired
+    private DingTalkRobotClient dingTalkRobotClient;
+
+    private static Logger logger = LoggerFactory.getLogger(DingTalkController.class);
+
+    @Override
+    @PassToken
+    public CommonResult sendMessage() {
+        String content ="这是一条消息";
+        String[] arr= {"13572294996"};
+        Boolean isAll=false;
+        TextMessage textMessage=new TextMessage();
+        textMessage.setContent(content);
+        textMessage.setIsAtAll(isAll);
+        textMessage.setAtMobiles(arr);
+        logger.info("Message:"+textMessage.toMessageMap().toString());
+        DingTalkResponse response = dingTalkRobotClient.sendMessage(textMessage);
+        logger.info(response.toString());
+        return CommonResult.ok(response);
+    }
+
+    @Override
+    @PassToken
+    public CommonResult sendFeedCardMessage() {
+        ArrayList<FeedCardMessageItem> items = new ArrayList<>();
+        FeedCardMessageItem messageItem=new FeedCardMessageItem();
+        messageItem.setMessageURL("http://mp.weixin.qq.com/s/CPUaB60pue0Zf3fUL9xqvw");
+        messageItem.setTitle("标题");
+        messageItem.setPicURL("https://mmbiz.qpic.cn/mmbiz_jpg/YriaiaJPb26VND0Q0hSBOoyVkr9cXQrFjWI7hOzax1IxIibqanXYD4W8nyeYX5iaicjgiaqia7ly94iawOsGwehbKGwGsA/640");
+        items.add(messageItem);
+        logger.info("Message:"+items);
+        DingTalkResponse response = dingTalkRobotClient.sendFeedCardMessage(items);
+        logger.info(response.toString());
+        return CommonResult.ok(response);
+    }
+
+    @Override
+    @PassToken
+    public CommonResult sendActionCardMessage() {
+        ActionCardMessage actionCardMessage=new ActionCardMessage();
+        actionCardMessage.setTitle("标题");
+        actionCardMessage.setText("![screenshot](@lADOpwk3K80C0M0FoA)**Apple Store** 的设计正从原来满满的科技感走向生活化,而其生活化的走向其实可以追溯到 20 年前苹果一个建立咖啡馆的计划");
+        actionCardMessage.setBtnOrientation(ButtonOrientationType.HORIZONTAL);
+        actionCardMessage.setButtonView(true);
+        actionCardMessage.setHideAvatar(HideAvatarType.HIDE);
+        logger.info("Message:"+actionCardMessage);
+        DingTalkResponse response = dingTalkRobotClient.sendActionCardMessage(actionCardMessage);
+        logger.info(response.toString());
+        return CommonResult.ok(response);
+    }
+}

+ 1 - 0
src/main/java/com/template/controller/ExcelController.java

@@ -2,6 +2,7 @@ package com.template.controller;
 
 import com.template.annotation.PassToken;
 import com.template.api.ExcelControllerAPI;
+import com.template.api.LoginControllerAPI;
 import com.template.model.pojo.SystemUser;
 import com.template.services.SystemUserService;
 import org.apache.poi.ss.usermodel.DataFormatter;

+ 1 - 0
src/main/resources/application-dev.yml

@@ -10,6 +10,7 @@ spring:
     multipart:
       max-file-size: 100MB
       max-request-size: 150MB
+#mybatis多数据源配置https://blog.51cto.com/u_16213568/11273627
   datasource:
     username: root
     password: root