Преглед изворни кода

feat: 跑通广播模式RPC过程调用

seamew пре 2 година
комит
7f1774d2a8
26 измењених фајлова са 974 додато и 0 уклоњено
  1. 47 0
      .gitignore
  2. 8 0
      .idea/.gitignore
  3. 12 0
      .idea/dataSources.xml
  4. 12 0
      .idea/encodings.xml
  5. 8 0
      .idea/inspectionProfiles/Project_Default.xml
  6. 25 0
      .idea/misc.xml
  7. 124 0
      .idea/uiDesigner.xml
  8. 6 0
      .idea/vcs.xml
  9. 37 0
      lottery-common/pom.xml
  10. 35 0
      lottery-common/src/main/java/com/seamew/lottery/common/Constants.java
  11. 36 0
      lottery-common/src/main/java/com/seamew/lottery/common/Result.java
  12. 45 0
      lottery-infrastructure/pom.xml
  13. 20 0
      lottery-infrastructure/src/main/java/com/seamew/lottery/infrastructure/dao/IActivityDao.java
  14. 56 0
      lottery-infrastructure/src/main/java/com/seamew/lottery/infrastructure/po/Activity.java
  15. 126 0
      lottery-interfaces/pom.xml
  16. 21 0
      lottery-interfaces/src/main/java/com/seamew/lottery/LotteryApplication.java
  17. 44 0
      lottery-interfaces/src/main/java/com/seamew/lottery/interfaces/ActivityBooth.java
  18. 28 0
      lottery-interfaces/src/main/resources/application.yaml
  19. 21 0
      lottery-interfaces/src/main/resources/mybatis/mapper/Activity_Mapper.xml
  20. 45 0
      lottery-interfaces/src/test/java/com/seamew/lottery/test/ApiTest.java
  21. 46 0
      lottery-rpc/pom.xml
  22. 15 0
      lottery-rpc/src/main/java/com/seamew/lottery/rpc/IActivityBooth.java
  23. 45 0
      lottery-rpc/src/main/java/com/seamew/lottery/rpc/dto/ActivityDto.java
  24. 21 0
      lottery-rpc/src/main/java/com/seamew/lottery/rpc/req/ActivityReq.java
  25. 26 0
      lottery-rpc/src/main/java/com/seamew/lottery/rpc/res/ActivityRes.java
  26. 65 0
      pom.xml

+ 47 - 0
.gitignore

@@ -0,0 +1,47 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
+
+### 默认 ###
+/Lottery.iml
+/lottery-application/lottery-application.iml
+/lottery-common/lottery-common.iml
+/lottery-domain/lottery-domain.iml
+/lottery-infrastructure/lottery-infrastructure.iml
+/lottery-interfaces/lottery-interfaces.iml
+/lottery-rpc/lottery-rpc.iml

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml

+ 12 - 0
.idea/dataSources.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="DataSourceManagerImpl" format="xml" multifile-model="true">
+    <data-source source="LOCAL" name="百度云" uuid="2c5b79fc-ee73-4688-a460-eb0ca3da0bbc">
+      <driver-ref>mysql.8</driver-ref>
+      <synchronize>true</synchronize>
+      <jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
+      <jdbc-url>jdbc:mysql://180.76.231.231:6033</jdbc-url>
+      <working-dir>$ProjectFileDir$</working-dir>
+    </data-source>
+  </component>
+</project>

+ 12 - 0
.idea/encodings.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
+    <file url="file://$PROJECT_DIR$/lottery-common/src/main/java" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/lottery-infrastructure/src/main/java" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/lottery-interfaces/src/main/java" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/lottery-rpc/src/main/java" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
+    <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
+    <file url="PROJECT" charset="UTF-8" />
+  </component>
+</project>

+ 8 - 0
.idea/inspectionProfiles/Project_Default.xml

@@ -0,0 +1,8 @@
+<component name="InspectionProjectProfileManager">
+  <profile version="1.0">
+    <option name="myName" value="Project Default" />
+    <inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
+      <option name="ADDITIONAL_TAGS" value="Author:,Title:,CreateTime:,Description:,Version:" />
+    </inspection_tool>
+  </profile>
+</component>

+ 25 - 0
.idea/misc.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="AnalysisProjectProfileManager">
+    <option name="PROJECT_PROFILE" />
+    <option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
+    <list size="0" />
+  </component>
+  <component name="ExternalStorageConfigurationManager" enabled="true" />
+  <component name="FrameworkDetectionExcludesConfiguration">
+    <file type="web" url="file://$PROJECT_DIR$/lottery-interfaces" />
+  </component>
+  <component name="MavenProjectsManager">
+    <option name="originalFiles">
+      <list>
+        <option value="$PROJECT_DIR$/pom.xml" />
+      </list>
+    </option>
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/out" />
+  </component>
+  <component name="SuppressionsComponent">
+    <option name="suppComments" value="[]" />
+  </component>
+</project>

+ 124 - 0
.idea/uiDesigner.xml

@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Palette2">
+    <group name="Swing">
+      <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
+      </item>
+      <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
+        <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
+        <initial-values>
+          <property name="text" value="Button" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="RadioButton" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="CheckBox" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="Label" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
+          <preferred-size width="-1" height="20" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
+      </item>
+    </group>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

+ 37 - 0
lottery-common/pom.xml

@@ -0,0 +1,37 @@
+<?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">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.seamew</groupId>
+        <artifactId>Lottery</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>lottery-common</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <build>
+        <finalName>lottery-common</finalName>
+        <plugins>
+            <!-- 编译plugin -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>${jdk.version}</source>
+                    <target>${jdk.version}</target>
+                    <compilerVersion>1.8</compilerVersion>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+
+</project>

+ 35 - 0
lottery-common/src/main/java/com/seamew/lottery/common/Constants.java

@@ -0,0 +1,35 @@
+package com.seamew.lottery.common;
+
+/**
+ * @Author: seamew
+ * @Title: Constants
+ * @CreateTime: 2023年02月07日 11:24:00
+ * @Description: 枚举信息定义
+ * @Version: 1.0
+ */
+public class Constants {
+    public enum ResponseCode {
+        SUCCESS("0000", "成功"),
+        UN_ERROR("0001","未知失败"),
+        ILLEGAL_PARAMETER("0002","非法参数"),
+        INDEX_DUP("0003","主键冲突");
+
+        private String code;
+        private String info;
+
+        ResponseCode(String code, String info) {
+            this.code = code;
+            this.info = info;
+        }
+
+        public String getCode() {
+            return code;
+        }
+
+        public String getInfo() {
+            return info;
+        }
+
+    }
+
+}

+ 36 - 0
lottery-common/src/main/java/com/seamew/lottery/common/Result.java

@@ -0,0 +1,36 @@
+package com.seamew.lottery.common;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @Author: seamew
+ * @Title: Result
+ * @CreateTime: 2023年02月07日 11:23:00
+ * @Description: 统一返回对象中,Code码、Info描述
+ * @Version: 1.0
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class Result implements Serializable {
+    private static final long serialVersionUID = -3826891916021780628L;
+    private String code;
+    private String info;
+
+    public static Result buildResult(String code, String info) {
+        return new Result(code, info);
+    }
+
+    public static Result buildSuccessResult() {
+        return new Result(Constants.ResponseCode.SUCCESS.getCode(), Constants.ResponseCode.SUCCESS.getInfo());
+    }
+
+    public static Result buildErrorResult() {
+        return new Result(Constants.ResponseCode.UN_ERROR.getCode(), Constants.ResponseCode.UN_ERROR.getInfo());
+    }
+
+}

+ 45 - 0
lottery-infrastructure/pom.xml

@@ -0,0 +1,45 @@
+<?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">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.seamew</groupId>
+        <artifactId>Lottery</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>lottery-infrastructure</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+            <version>2.2.2</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <finalName>lottery-infrastructure</finalName>
+        <plugins>
+            <!-- 编译plugin -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>${jdk.version}</source>
+                    <target>${jdk.version}</target>
+                    <compilerVersion>1.8</compilerVersion>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+
+</project>

+ 20 - 0
lottery-infrastructure/src/main/java/com/seamew/lottery/infrastructure/dao/IActivityDao.java

@@ -0,0 +1,20 @@
+package com.seamew.lottery.infrastructure.dao;
+
+import com.seamew.lottery.infrastructure.po.Activity;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @Author: seamew
+ * @Title: IActivityDao
+ * @CreateTime: 2023年02月07日 13:54:00
+ * @Description:
+ * @Version: 1.0
+ */
+@Mapper
+public interface IActivityDao {
+
+    void insert(Activity req);
+
+    Activity queryActivityById(Long activityId);
+
+}

+ 56 - 0
lottery-infrastructure/src/main/java/com/seamew/lottery/infrastructure/po/Activity.java

@@ -0,0 +1,56 @@
+package com.seamew.lottery.infrastructure.po;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+/**
+ * @Author: seamew
+ * @Title: Activity
+ * @CreateTime: 2023年02月07日 13:55:00
+ * @Description:
+ * @Version: 1.0
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class Activity {
+    // 自增ID
+    private Long id;
+
+    // 活动ID
+    private Long activityId;
+
+    // 活动名称
+    private String activityName;
+
+    // 活动描述
+    private String activityDesc;
+
+    // 开始时间
+    private Date beginDateTime;
+
+    // 结束时间
+    private Date endDateTime;
+
+    // 库存
+    private Integer stockCount;
+
+    // 每人可参与次数
+    private Integer takeCount;
+
+    // 活动状态:编辑、提审、撤审、通过、运行、拒绝、关闭、开启
+    private Integer state;
+
+    // 创建人
+    private String creator;
+
+    // 创建时间
+    private Date createTime;
+
+    // 修改时间
+    private Date updateTime;
+
+}

+ 126 - 0
lottery-interfaces/pom.xml

@@ -0,0 +1,126 @@
+<?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">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.seamew</groupId>
+        <artifactId>Lottery</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>lottery-interfaces</artifactId>
+
+    <packaging>war</packaging>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+            <version>2.2.2</version>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo</artifactId>
+            <version>2.7.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-spring-boot-starter</artifactId>
+            <version>2.7.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-framework</artifactId>
+            <version>2.8.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.curator</groupId>
+            <artifactId>curator-recipes</artifactId>
+            <version>2.8.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>2.0.23</version>
+        </dependency>
+
+
+        <dependency>
+            <groupId>com.seamew</groupId>
+            <artifactId>lottery-infrastructure</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.seamew</groupId>
+            <artifactId>lottery-rpc</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
+
+    <build>
+        <finalName>Lottery</finalName>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>**/**</include>
+                </includes>
+            </resource>
+        </resources>
+        <testResources>
+            <testResource>
+                <directory>src/test/resources</directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>**/**</include>
+                </includes>
+            </testResource>
+        </testResources>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>8</source>
+                    <target>8</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 21 - 0
lottery-interfaces/src/main/java/com/seamew/lottery/LotteryApplication.java

@@ -0,0 +1,21 @@
+package com.seamew.lottery;
+
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
+import org.springframework.beans.factory.annotation.Configurable;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+/**
+ * @Author: seamew
+ * @Title: LotteryApplication
+ * @CreateTime: 2023年02月07日 14:18:00
+ * @Description:
+ * @Version: 1.0
+ */
+@SpringBootApplication
+@Configurable
+@EnableDubbo
+public class LotteryApplication {
+    public static void main(String[] args) {
+        SpringApplication.run(LotteryApplication.class, args);
+    }
+}

+ 44 - 0
lottery-interfaces/src/main/java/com/seamew/lottery/interfaces/ActivityBooth.java

@@ -0,0 +1,44 @@
+package com.seamew.lottery.interfaces;
+
+import com.seamew.lottery.common.Constants;
+import com.seamew.lottery.common.Result;
+import com.seamew.lottery.infrastructure.dao.IActivityDao;
+import com.seamew.lottery.infrastructure.po.Activity;
+import com.seamew.lottery.rpc.IActivityBooth;
+import com.seamew.lottery.rpc.dto.ActivityDto;
+import com.seamew.lottery.rpc.req.ActivityReq;
+import com.seamew.lottery.rpc.res.ActivityRes;
+import org.apache.dubbo.config.annotation.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.annotation.Resource;
+
+/**
+ * @Author: seamew
+ * @Title: ActivityBooth
+ * @CreateTime: 2023年02月07日 13:48:00
+ * @Description: 活动展台
+ * @Version: 1.0
+ */
+@Service
+public class ActivityBooth implements IActivityBooth {
+
+    @Autowired
+    private IActivityDao activityDao;
+
+    @Override
+    public ActivityRes queryActivityById(ActivityReq req) {
+        Activity activity = activityDao.queryActivityById(req.getActivityId());
+
+        ActivityDto activityDto = new ActivityDto();
+        activityDto.setActivityId(activity.getActivityId());
+        activityDto.setActivityName(activity.getActivityName());
+        activityDto.setActivityDesc(activity.getActivityDesc());
+        activityDto.setBeginDateTime(activity.getBeginDateTime());
+        activityDto.setEndDateTime(activity.getEndDateTime());
+        activityDto.setStockCount(activity.getStockCount());
+        activityDto.setTakeCount(activity.getTakeCount());
+
+        return new ActivityRes(new Result(Constants.ResponseCode.SUCCESS.getCode(), Constants.ResponseCode.SUCCESS.getInfo()), activityDto);
+    }
+}

+ 28 - 0
lottery-interfaces/src/main/resources/application.yaml

@@ -0,0 +1,28 @@
+server:
+  port: 8080
+
+spring:
+  datasource:
+    username: root
+    password: MKcloud123
+    url: jdbc:mysql://180.76.231.231:6033/lottery?useUnicode=true&characterEncoding=UTF-8
+    driver-class-name: com.mysql.cj.jdbc.Driver
+
+mybatis:
+  mapper-locations: classpath:/mybatis/mapper/*.xml
+  configuration:
+    map-underscore-to-camel-case: true
+
+dubbo:
+  application:
+    name: Lottery
+    version: 1.0.0
+  registry:
+    address: zookeeper://180.76.231.231:2181
+  protocol:
+    name: dubbo
+    port: 20880
+  scan:
+    base-packages: com.seamew.lottery.rpc
+
+

+ 21 - 0
lottery-interfaces/src/main/resources/mybatis/mapper/Activity_Mapper.xml

@@ -0,0 +1,21 @@
+<?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="com.seamew.lottery.infrastructure.dao.IActivityDao">
+
+    <insert id="insert" parameterType="com.seamew.lottery.infrastructure.po.Activity">
+        INSERT INTO activity
+        (activity_id, activity_name, activity_desc, begin_date_time, end_date_time,
+         stock_count, take_count, state, creator, create_time, update_time)
+        VALUES (#{activityId}, #{activityName}, #{activityDesc}, #{beginDateTime}, #{endDateTime},
+                #{stockCount}, #{takeCount}, #{state}, #{creator}, now(), now())
+    </insert>
+
+    <select id="queryActivityById" parameterType="java.lang.Long" resultType="com.seamew.lottery.infrastructure.po.Activity">
+        SELECT activity_id, activity_name, activity_desc, begin_date_time, end_date_time,
+               stock_count, take_count, state, creator, create_time, update_time
+        FROM activity
+        WHERE activity_id = #{activityId}
+    </select>
+
+
+</mapper>

+ 45 - 0
lottery-interfaces/src/test/java/com/seamew/lottery/test/ApiTest.java

@@ -0,0 +1,45 @@
+package com.seamew.lottery.test;
+
+import com.seamew.lottery.infrastructure.dao.IActivityDao;
+import com.seamew.lottery.infrastructure.po.Activity;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.Date;
+
+/**
+ * @Author: seamew
+ * @Title: ApiTest
+ * @CreateTime: 2023年02月07日 17:23:00
+ * @Description:
+ * @Version: 1.0
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class ApiTest {
+    @Autowired
+    IActivityDao activityDao;
+    @Test
+    public void context() {
+        Activity activity = new Activity();
+        activity.setActivityId(100002l);
+        activity.setActivityName("测试活动");
+        activity.setActivityDesc("仅用于插入数据测试");
+        activity.setBeginDateTime(new Date());
+        activity.setEndDateTime(new Date());
+        activity.setStockCount(10);
+        activity.setTakeCount(10);
+        activity.setState(0);
+        activity.setCreator("admin");
+
+        activityDao.insert(activity);
+        //
+        // Activity activity = activityDao.queryActivityById(100002l);
+        // System.out.println(activity);
+    }
+}
+
+

+ 46 - 0
lottery-rpc/pom.xml

@@ -0,0 +1,46 @@
+<?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">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.seamew</groupId>
+        <artifactId>Lottery</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>lottery-rpc</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.seamew</groupId>
+            <artifactId>lottery-common</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
+
+    <build>
+        <finalName>lottery-rpc</finalName>
+        <plugins>
+            <!-- 编译plugin -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>${jdk.version}</source>
+                    <target>${jdk.version}</target>
+                    <compilerVersion>1.8</compilerVersion>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+
+</project>

+ 15 - 0
lottery-rpc/src/main/java/com/seamew/lottery/rpc/IActivityBooth.java

@@ -0,0 +1,15 @@
+package com.seamew.lottery.rpc;
+
+import com.seamew.lottery.rpc.req.ActivityReq;
+import com.seamew.lottery.rpc.res.ActivityRes;
+
+/**
+ * @Author: seamew
+ * @Title: IActivityBooth
+ * @CreateTime: 2023年02月07日 11:17:00
+ * @Description:
+ * @Version: 1.0
+ */
+public interface IActivityBooth {
+    ActivityRes queryActivityById(ActivityReq req);
+}

+ 45 - 0
lottery-rpc/src/main/java/com/seamew/lottery/rpc/dto/ActivityDto.java

@@ -0,0 +1,45 @@
+package com.seamew.lottery.rpc.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @Author: seamew
+ * @Title: ActivityDto
+ * @CreateTime: 2023年02月07日 11:18:00
+ * @Description:
+ * @Version: 1.0
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class ActivityDto implements Serializable {
+    // 活动ID
+    private Long activityId;
+
+    // 活动名称
+    private String activityName;
+
+    // 活动描述
+    private String activityDesc;
+
+    // 开始时间
+    private Date beginDateTime;
+
+    // 结束时间
+    private Date endDateTime;
+
+    // 库存
+    private Integer stockCount;
+
+    // 每人可参与次数
+    private Integer takeCount;
+
+    // 活动状态:编辑、提审、撤审、通过、运行、拒绝、关闭、开启
+    private Integer state;
+
+}

+ 21 - 0
lottery-rpc/src/main/java/com/seamew/lottery/rpc/req/ActivityReq.java

@@ -0,0 +1,21 @@
+package com.seamew.lottery.rpc.req;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @Author: seamew
+ * @Title: ActivityReq
+ * @CreateTime: 2023年02月07日 11:21:00
+ * @Description:
+ * @Version: 1.0
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class ActivityReq implements Serializable {
+    private Long activityId;
+}

+ 26 - 0
lottery-rpc/src/main/java/com/seamew/lottery/rpc/res/ActivityRes.java

@@ -0,0 +1,26 @@
+package com.seamew.lottery.rpc.res;
+
+import com.seamew.lottery.common.Result;
+import com.seamew.lottery.rpc.dto.ActivityDto;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @Author: seamew
+ * @Title: ActivityRes
+ * @CreateTime: 2023年02月07日 11:18:00
+ * @Description:
+ * @Version: 1.0
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class ActivityRes implements Serializable {
+    private Result result;
+    private ActivityDto activity;
+
+
+}

+ 65 - 0
pom.xml

@@ -0,0 +1,65 @@
+<?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">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.seamew</groupId>
+    <artifactId>Lottery</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+    <modules>
+        <module>lottery-rpc</module>
+        <module>lottery-interfaces</module>
+        <module>lottery-common</module>
+        <module>lottery-infrastructure</module>
+    </modules>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <!-- Base -->
+        <jdk.version>1.8</jdk.version>
+        <sourceEncoding>UTF-8</sourceEncoding>
+    </properties>
+
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.3.5.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <dependencies>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <skipTests>true</skipTests>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>8</source>
+                    <target>8</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+
+
+
+
+
+</project>