diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml new file mode 100644 index 0000000..9f28fb8 --- /dev/null +++ b/.onedev-buildspec.yml @@ -0,0 +1,156 @@ +version: 18 +jobs: +- name: maven ci + steps: + - !CheckoutStep + name: checkout + cloneCredential: !DefaultCredential {} + withLfs: false + withSubmodules: false + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !CommandStep + name: detect build version + runInContainer: true + image: '@script:builtin:maven:determine-docker-image@' + interpreter: !DefaultInterpreter + commands: + - echo "Detecting project version (may require some time while downloading maven + dependencies)..." + - echo $(mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version + -q -DforceStdout) > buildVersion + useTTY: false + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !SetBuildVersionStep + name: set build version + buildVersion: '@file:buildVersion@' + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !CommandStep + name: run unit tests + runInContainer: true + image: '@script:builtin:maven:determine-docker-image@' + interpreter: !DefaultInterpreter + commands: + - mvn clean test -P dev + useTTY: false + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + triggers: + - !BranchUpdateTrigger {} + retryCondition: never + maxRetries: 3 + retryDelay: 30 + cpuRequirement: 250 + memoryRequirement: 256 + caches: + - key: maven-cache + path: /root/.m2/repository + timeout: 3600 +- name: package + steps: + - !CheckoutStep + name: Checkout Code + cloneCredential: !DefaultCredential {} + withLfs: false + withSubmodules: false + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !CommandStep + name: delete build version + runInContainer: true + image: '@script:builtin:maven:determine-docker-image@' + interpreter: !DefaultInterpreter + commands: + - echo "Detecting project version (may require some time while downloading maven + dependencies)..." + - echo $(mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version + -q -DforceStdout) > buildVersion + useTTY: false + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !SetBuildVersionStep + name: Set Build Version + buildVersion: '@file:buildVersion@' + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !CommandStep + name: run maven package + runInContainer: true + image: '@script:builtin:maven:determine-docker-image@' + interpreter: !DefaultInterpreter + commands: + - mvn package + useTTY: false + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !PublishArtifactStep + name: Publish Artifacts + artifacts: '**' + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + jobExecutor: internal + retryCondition: never + maxRetries: 3 + retryDelay: 30 + cpuRequirement: 250 + memoryRequirement: 256 + caches: + - key: maven-cache + path: /root/.m2/repository + timeout: 3600 +- name: Build Docker Image + steps: + - !SetBuildVersionStep + name: Set Build Version + buildVersion: '@file:buildVersion@' + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !BuildImageStep + name: Build Docker Image + tags: rymcu/forest:@build_version@ + publish: false + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + jobDependencies: + - jobName: package + requireSuccessful: true + artifacts: '**' + retryCondition: never + maxRetries: 3 + retryDelay: 30 + cpuRequirement: 250 + memoryRequirement: 256 + timeout: 3600 +- name: Pull from Github + steps: + - !PullRepository + name: Pull from GitHub + remoteUrl: https://github.com/ronger-x/forest + syncToChildProject: false + passwordSecret: access_token + refs: refs/heads/* refs/tags/* + withLfs: false + force: false + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + triggers: + - !ScheduleTrigger + cronExpression: 0 0 1 * * ? + retryCondition: never + maxRetries: 3 + retryDelay: 30 + cpuRequirement: 250 + memoryRequirement: 256 + timeout: 3600 +- name: Push to GitHub + steps: + - !PushRepository + name: Push to GitHub + remoteUrl: https://github.com/ronger-x/forest + passwordSecret: access_token + withLfs: false + force: false + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + triggers: + - !BranchUpdateTrigger + branches: master + projects: forest + - !TagCreateTrigger + branches: master + projects: forest + retryCondition: never + maxRetries: 3 + retryDelay: 30 + cpuRequirement: 250 + memoryRequirement: 256 + timeout: 3600 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a6b09c3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM rymcu/java-container:1.0.0 + +MAINTAINER rymcu.com + +COPY target/forest.war /usr/local/tomcat/webapps/ + +ENV JAVA_HOME=/usr/lib/jvm/jdk1.8.0_202 + +ENV PATH=$JAVA_HOME/bin:$PATH + +CMD ["/usr/local/tomcat/bin/catalina.sh", "run"] + +EXPOSE 8080 \ No newline at end of file diff --git a/forest.iml b/forest.iml new file mode 100644 index 0000000..1dc6832 --- /dev/null +++ b/forest.iml @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 78ce411..2183932 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,11 @@ + + org.yaml + snakeyaml + 1.33 + org.springframework.boot spring-boot-starter-mail @@ -103,13 +108,13 @@ com.github.pagehelper pagehelper - 5.3.1 + 5.3.2 com.alibaba fastjson - 2.0.12 + 2.0.14 @@ -158,7 +163,7 @@ com.alibaba druid-spring-boot-starter - 1.2.11 + 1.2.13-SNSAPSHOT org.apache.logging.log4j @@ -170,7 +175,7 @@ org.apache.logging.log4j log4j-to-slf4j - 2.18.0 + 2.19.0 org.apache.logging.log4j @@ -181,7 +186,7 @@ org.apache.logging.log4j log4j-api - 2.18.0 + 2.19.0 org.springframework.boot @@ -201,11 +206,6 @@ jodd-http 6.3.0 - - com.thoughtworks.xstream - xstream - 1.4.19 - com.github.jedis-lock jedis-lock @@ -241,12 +241,12 @@ cn.hutool hutool-core - 5.8.5 + 5.8.8 cn.hutool hutool-http - 5.8.5 + 5.8.8 @@ -272,15 +272,98 @@ **/**/*.xml + + + src/main/resources + false + + **/** + + + + + + src/main/resources + true + config + + application.yml + application-${profileActive}.yml + banner.txt + logback.xml + *.properties + + org.springframework.boot spring-boot-maven-plugin 2.3.5.RELEASE + + true + + + + org.apache.maven.plugins + maven-resources-plugin + + + woff + woff2 + eot + ttf + svg + + forest - + + + + + dev + + dev + + + false + + + + prod + + prod + + + true + + + + + + public + aliyun nexus + https://maven.aliyun.com/nexus/content/groups/public/ + + true + + + + + + + public + aliyun nexus + https://maven.aliyun.com/nexus/content/groups/public/ + + true + + + false + + + diff --git a/src/main/java/com/rymcu/forest/lucene/api/LuceneSearchController.java b/src/main/java/com/rymcu/forest/lucene/api/LuceneSearchController.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/api/UserDicController.java b/src/main/java/com/rymcu/forest/lucene/api/UserDicController.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/cfg/Configuration.java b/src/main/java/com/rymcu/forest/lucene/cfg/Configuration.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/cfg/DefaultConfig.java b/src/main/java/com/rymcu/forest/lucene/cfg/DefaultConfig.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/core/AnalyzeContext.java b/src/main/java/com/rymcu/forest/lucene/core/AnalyzeContext.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/core/CJKSegmenter.java b/src/main/java/com/rymcu/forest/lucene/core/CJKSegmenter.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/core/CN_QuantifierSegmenter.java b/src/main/java/com/rymcu/forest/lucene/core/CN_QuantifierSegmenter.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/core/CharacterUtil.java b/src/main/java/com/rymcu/forest/lucene/core/CharacterUtil.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/core/IKArbitrator.java b/src/main/java/com/rymcu/forest/lucene/core/IKArbitrator.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/core/IKSegmenter.java b/src/main/java/com/rymcu/forest/lucene/core/IKSegmenter.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/core/ISegmenter.java b/src/main/java/com/rymcu/forest/lucene/core/ISegmenter.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/core/LetterSegmenter.java b/src/main/java/com/rymcu/forest/lucene/core/LetterSegmenter.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/core/Lexeme.java b/src/main/java/com/rymcu/forest/lucene/core/Lexeme.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/core/LexemePath.java b/src/main/java/com/rymcu/forest/lucene/core/LexemePath.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/core/QuickSortSet.java b/src/main/java/com/rymcu/forest/lucene/core/QuickSortSet.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/dic/DictSegment.java b/src/main/java/com/rymcu/forest/lucene/dic/DictSegment.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/dic/Dictionary.java b/src/main/java/com/rymcu/forest/lucene/dic/Dictionary.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/dic/Hit.java b/src/main/java/com/rymcu/forest/lucene/dic/Hit.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/lucene/IKAnalyzer.java b/src/main/java/com/rymcu/forest/lucene/lucene/IKAnalyzer.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/lucene/IKTokenizer.java b/src/main/java/com/rymcu/forest/lucene/lucene/IKTokenizer.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/mapper/ArticleLuceneMapper.java b/src/main/java/com/rymcu/forest/lucene/mapper/ArticleLuceneMapper.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/lucene/mapper/UserDicMapper.java b/src/main/java/com/rymcu/forest/lucene/mapper/UserDicMapper.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/rymcu/forest/service/impl/UserServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/UserServiceImpl.java index ed17d78..e6855cd 100644 --- a/src/main/java/com/rymcu/forest/service/impl/UserServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/UserServiceImpl.java @@ -122,7 +122,7 @@ public class UserServiceImpl extends AbstractService implements UserServic userMapper.updateLastOnlineTimeByEmail(user.getEmail()); TokenUser tokenUser = new TokenUser(); BeanCopierUtil.copy(user, tokenUser); - tokenUser.setToken(tokenManager.createToken(account)); + tokenUser.setToken(tokenManager.createToken(user.getEmail())); tokenUser.setWeights(userMapper.selectRoleWeightsByUser(user.getIdUser())); // 保存登录日志 loginRecordService.saveLoginRecord(tokenUser.getIdUser()); diff --git a/src/main/java/mapper/lucene/ArticleLuceneMapper.xml b/src/main/java/mapper/lucene/ArticleLuceneMapper.xml old mode 100755 new mode 100644 diff --git a/src/main/java/mapper/lucene/UserDicMapper.xml b/src/main/java/mapper/lucene/UserDicMapper.xml old mode 100755 new mode 100644 diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml new file mode 100644 index 0000000..7174d95 --- /dev/null +++ b/src/main/resources/application-dev.yml @@ -0,0 +1,100 @@ +publicKey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANbY1W9TXU+OdseRBVw5/eq1rs5UVQZie5ydEPYIurRzF4oBORu/+Sjqt+c5mHulleuiD4Yov+0e/CXODg4FYu8CAwEAAQ== +spring: + thymeleaf: + prefix: classpath:/templates/ + suffix: .html + mode: HTML + encoding: UTF-8 + servlet: + content-type: text/html + cache: false + redis: + host: 192.168.31.200 + port: 6379 + password: d9d2j9w2 + database: 1 + timeout: 3000 + jedis: + pool: + max-active: 8 + max-wait: 1 + max-idle: 500 + min-idle: 0 + datasource: + druid: + url: jdbc:mysql://192.168.31.200:3306/forest?characterEncoding=UTF-8&autoReconnect=true&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true + username: root + password: Ldh1NrsXJntz5nTXeO0nPh+8s1FMe+JHCfXy2Zj3egqqjegN+mNe+53ZmduUlVdE4ZqKuUho7T9yftc6AYYKog== + driver-class-name: com.mysql.cj.jdbc.Driver + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + time-between-eviction-runs-millis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + min-evictable-idle-time-millis: 30000 + validation-query: SELECT 1 FROM DUAL + test-while-idle: true + test-on-borrow: false + test-on-return: false + connection-properties: config.decrypt=true;config.decrypt.key=${publickey} + filters: config,stat + max-pool-prepared-statement-per-connection-size: 100 + stat-view-servlet: + enabled: true + allow: + login-username: admin + login-password: rymcu.Test1 + filter: + stat: + log-slow-sql: true + resources: + add-mappings: true + mail: + host: smtp.ym.163.com + port: 465 + username: service@rymcu.com + password: 4W3tCXdyk0Gm +wx: + open: + componentAppId: wx9c4a7dfb3238d5f6 + componentSecret: e32a6f75ab6b746ec3ae38a39a79ba22 + componentToken: rymcu + componentAesKey: NWIwMDQyZjU0YWI2NGFlZThkOWZhZTg3NTg4NzQwN2E + mp: + configs: + - appId: wxf085386aa07c0857 + secret: aabd075d2851764714fd14a0d0b1b8b4 + token: rymcu + aesKey: lvn3mMSnFOvbnIJVNhHQqjWb9swe66L1xIcerJSs0fm + - appId: wxa49093339a5a822b + secret: 29e9390e6d58d57a2b2a2350dbee8754 + token: qwert + aesKey: + miniapp: + configs: + - appid: wxb4fff78a6b878cf7 + secret: c8735d0ccc8497b8509dc2762246cb37 + token: #微信小程序消息服务器配置的token + aesKey: #微信小程序消息服务器配置的EncodingAESKey + msgDataFormat: JSON +env: dev +logging: + file: + path: /logs/vertical + level: debug +server: + port: 8099 + servlet: + context-path: /forest + max-http-header-size: 1048576 +version: 1.0 +resource: + domain: http://test.rymcu.com + file-path: http://test.rymcu.com + pic-path: /opt/nebula/static +baidu: + data: + site: https://rymcu.com + token: 9cdKR6bVCJzxDEJS + ai: + appId: 22891829 + appKey: HKxdO8ioaUmltZh0eaOVMsmW + secretKey: GXOtl3XtiIkVA3CPsc3c29Pqa4V290Yr \ No newline at end of file diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml new file mode 100644 index 0000000..508296d --- /dev/null +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,109 @@ +publicKey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMJp8DiJzkOxlpcx0RdLcXRV0gMnKVZfERC/t0JD324baxCW8MYpTQBvcJS3foW4w5IQlnjRdJwg2VF3gvqkPpECAwEAAQ== +spring: + thymeleaf: + prefix: classpath:/templates/ + suffix: .html + mode: HTML + encoding: UTF-8 + servlet: + content-type: text/html + cache: false + redis: + host: 127.0.0.1 + port: 6379 + password: d9d2j9w2 + database: 1 + timeout: 3000 + jedis: + pool: + max-active: 8 + max-wait: 1 + max-idle: 500 + min-idle: 0 + datasource: + druid: + url: jdbc:mysql://101.132.182.12:3306/forest?characterEncoding=UTF-8&autoReconnect=true&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true + username: root + password: SFCUIZVG/y3IZ+dPcx1Jk2WnAaqU5zkV4iqqOtRKFLOpA5FHiNXW+cXuvKGEJeL6sC9uPo+qR7ljB2R4xG0DGQ== + driver-class-name: com.mysql.cj.jdbc.Driver + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 30000 + validation-query: SELECT 1 FROM DUAL + test-while-idle: true + test-on-borrow: false + test-on-return: false + connection-properties: config.decrypt=true;config.decrypt.key=${publickey} + filters: config,stat + max-pool-prepared-statement-per-connection-size: 100 + stat-view-servlet: + enabled: true + allow: + login-username: admin + login-password: rymcu.Test1 + filter: + stat: + log-slow-sql: true + resources: + add-mappings: true + mail: + host: smtp.ym.163.com + port: 465 + username: service@rymcu.com + password: Aa12345678 + servlet: + multipart: + max-file-size: 10MB + max-request-size: 20MB +wx: + open: + componentAppId: wx9c4a7dfb3238d5f6 + componentSecret: e32a6f75ab6b746ec3ae38a39a79ba22 + componentToken: rymcu + componentAesKey: NWIwMDQyZjU0YWI2NGFlZThkOWZhZTg3NTg4NzQwN2E + mp: + configs: + - appId: wx1082362f11561645 + secret: f15ffc794c0b3fb6c2bc1207bd553365 + token: rymcu + aesKey: lvn3mMSnFOvbnIJVNhHQqjWb9swe66L1xIcerJSs0fm + - appId: wxa49093339a5a822b + secret: 29e9390e6d58d57a2b2a2350dbee8754 + token: qwert + aesKey: + miniapp: + configs: + - appid: wxb4fff78a6b878cf7 + secret: c8735d0ccc8497b8509dc2762246cb37 + token: #微信小程序消息服务器配置的token + aesKey: #微信小程序消息服务器配置的EncodingAESKey + msgDataFormat: JSON +env: prod +logging: + file: + path: /logs/forest + level: + com: + rymcu: info +server: + port: 8099 + servlet: + context-path: /forest + compression: + enabled: true + mime-types: application/json,application/xml,text/html,text/xml,text/plain + min-response-size: 1024 + max-http-header-size: 1048576 +version: 1.0 +resource: + domain: https://rymcu.com + file-path: https://static.rymcu.com + pic-path: /usr/local/src/nebula/static +baidu: + data: + site: https://rymcu.com + token: 9cdKR6bVCJzxDEJS + ai: + appId: 22891829 + appKey: HKxdO8ioaUmltZh0eaOVMsmW + secretKey: GXOtl3XtiIkVA3CPsc3c29Pqa4V290Yr +reserved-words: \u7cfb\u7edf\u516c\u544a\u002c\u516c\u544a \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 1f0ad51..99c9014 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,6 +1,9 @@ +--- spring: profiles: - active: dev + active: '@profileActive@' +--- +spring: thymeleaf: prefix: classpath:/templates/ suffix: .html diff --git a/src/main/resources/lucene/ext.dic b/src/main/resources/lucene/ext.dic old mode 100755 new mode 100644 diff --git a/src/main/resources/lucene/main2012.dic b/src/main/resources/lucene/main2012.dic old mode 100755 new mode 100644 diff --git a/src/main/resources/lucene/quantifier.dic b/src/main/resources/lucene/quantifier.dic old mode 100755 new mode 100644 diff --git a/src/main/resources/lucene/sensitive.dic b/src/main/resources/lucene/sensitive.dic old mode 100755 new mode 100644 diff --git a/src/main/resources/lucene/stopword.dic b/src/main/resources/lucene/stopword.dic old mode 100755 new mode 100644 diff --git a/src/main/resources/lucene/web.dic b/src/main/resources/lucene/web.dic old mode 100755 new mode 100644 diff --git a/src/main/resources/static/forest.sql b/src/main/resources/static/forest.sql index fbde953..0c1cd23 100644 --- a/src/main/resources/static/forest.sql +++ b/src/main/resources/static/forest.sql @@ -388,3 +388,193 @@ create table forest_login_record constraint forest_login_record_id_uindex unique (id) ) comment '登录记录表' collate = utf8mb4_unicode_ci; + +create table forest_product +( + id int auto_increment comment '主键' + primary key, + product_title varchar(100) null comment '产品名', + product_price int default 0 null comment '单价(单位:分)', + product_img_url varchar(100) null comment '产品主图', + product_description varchar(200) null comment '产品描述', + weights tinyint default 50 null comment '权重,数值越小权限越大;0:无权限', + created_time datetime null comment '创建时间', + updated_time datetime null comment '更新时间', + constraint forest_product_id_uindex + unique (id) +) + comment '产品表'; + +create table forest_product_content +( + id_product int null comment '产品表主键', + product_content text null comment '产品详情原文', + product_content_html text null comment '产品详情 Html', + created_time datetime null comment '创建时间', + updated_time datetime null comment '更新时间' +) + comment '产品详情表'; + +INSERT INTO forest.forest_product (id, product_title, product_price, product_img_url, product_description, weights, created_time, updated_time) VALUES (1, 'Nebula Pi', 2000000, 'https://static.rymcu.com/article/1648960741563.jpg', '产品描述', 20, '2022-06-13 22:35:33', '2022-06-13 22:35:33'); + +INSERT INTO forest.forest_product_content (id_product, product_content, product_content_html, created_time, + updated_time) +VALUES (1, '![nebula pi](https://static.rymcu.com/article/1640531590770) + +Nebula-Pi 开发板平台 + +## 1.1主板结构及布局 + +![](https://static.rymcu.com/article/1640531590844) + +图1.1 Nebula-Pi 单片机开发平台 + +## 1.2主板元件说明 + +从图1.1可以看出, Nebula-Pi 开发板平台资源丰富,不仅涵盖了 51 单片机所有内部资源,还扩展了大量的外设,单片机的各项功能均可以在平台上得到验证。我们以顺时针的顺序从**①**到**⑳**,分别介绍主要模块的功能。 + +| 序号 | 元器件 | 功能介绍 | +| --- | --- | --- | +| 1 | 迷你 USB 接口 | 给开发板供电,以及计算机与开发板通信 | +| 2 | 单片机跳线帽 | 开发板上有两块独立的 51 单片机,可以通过这个跳线进行切换,选择你需要使用的单片机。 | +| 3 | 电源开关 | 开发板电源开关 | +| 4 | 51 单片机 STC89C52RC | 这套教程的主角, 51 单片机,选用 STC 公司的 STC89C52RC 型号进行讲解 | +| 5 | 液晶显示器跳线帽 | 液晶显示器的跳线,可以选择 OLED 或者 LCD | +| 6 | 主板复位按钮 | 复位按钮,相当于电脑的重启按键 | +| 7 | 数字温度传感器 | 温度传感器,可以测量环境温度 | +| 8 | 红外接收头 | 接收红外遥控信号专用 | +| 9 | 液晶显示器接口 | 预留的液晶显示器 1602/12864 等的接口 | +| 10 | 数码管 | 4 位数码管,可以同时显示 4 个数字等 | +| 11 | 蜂鸣器 | 相当于开发板的小喇叭,可以发出"滴滴"等声音 | +| 12 | 光敏&热敏电阻 | 两种类型的电阻,分别可以用来测量光强度和温度 | +| 13 | 步进电机接口 | 预留给电机的接口 | +| 14 | 8 个 LED 灯 | 8 个 LED 小灯,可实现指示灯,流水灯等效果 | +| 15 | 增强型 51 单片机 STC12 | 开发板上的另外一块 51 单片机,比主角功能更强大,第一块用来学习,这一块用来做项目,学习、实践两不误 | +| 16 | 2.4G 无线模块接口 | 为 2.4G 无线通信模块预留的接口,无线通信距离可以达到 1-2Km,大大扩展了开发板的功能 | +| 17 | 3 个独立按键 | 3 个按键,可以当做开发板的输入设备,相当于迷你版键盘 | +| 18 | 继电器接口 | 开发板上集成了继电器,这个接口预留给用户接线用的,可以用来控制 220V 设备的开关。因此,可以通过开发板來控制各种类型的家用电器 | +| 19 | 电源端子 | 预留了 5V 和 3.3V 的电源端子,可以用来给其他设备供电 | +| 20 | WiFi 模块接口 | WiFi 模块接口,接上 WiFi 模块,开发板可以轻松上网冲浪 | + +表 1-1 主板元器件说明 + +', '

nebula pi

+

Nebula-Pi 开发板平台

+

1.1 主板结构及布局

+

+

图 1.1 Nebula-Pi 单片机开发平台

+

1.2 主板元件说明

+

从图 1.1 可以看出, Nebula-Pi 开发板平台资源丰富,不仅涵盖了 51 单片机所有内部资源,还扩展了大量的外设,单片机的各项功能均可以在平台上得到验证。我们以顺时针的顺序从 ,分别介绍主要模块的功能。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
序号元器件功能介绍
1迷你 USB 接口给开发板供电,以及计算机与开发板通信
2单片机跳线帽开发板上有两块独立的 51 单片机,可以通过这个跳线进行切换,选择你需要使用的单片机。
3电源开关开发板电源开关
451 单片机 STC89C52RC这套教程的主角, 51 单片机,选用 STC 公司的 STC89C52RC 型号进行讲解
5液晶显示器跳线帽液晶显示器的跳线,可以选择 OLED 或者 LCD
6主板复位按钮复位按钮,相当于电脑的重启按键
7数字温度传感器温度传感器,可以测量环境温度
8红外接收头接收红外遥控信号专用
9液晶显示器接口预留的液晶显示器 1602/12864 等的接口
10数码管4 位数码管,可以同时显示 4 个数字等
11蜂鸣器相当于开发板的小喇叭,可以发出"滴滴"等声音
12光敏&热敏电阻两种类型的电阻,分别可以用来测量光强度和温度
13步进电机接口预留给电机的接口
148 个 LED 灯8 个 LED 小灯,可实现指示灯,流水灯等效果
15增强型 51 单片机 STC12开发板上的另外一块 51 单片机,比主角功能更强大,第一块用来学习,这一块用来做项目,学习、实践两不误
162.4G 无线模块接口为 2.4G 无线通信模块预留的接口,无线通信距离可以达到 1-2Km,大大扩展了开发板的功能
173 个独立按键3 个按键,可以当做开发板的输入设备,相当于迷你版键盘
18继电器接口开发板上集成了继电器,这个接口预留给用户接线用的,可以用来控制 220V 设备的开关。因此,可以通过开发板來控制各种类型的家用电器
19电源端子预留了 5V 和 3.3V 的电源端子,可以用来给其他设备供电
20WiFi 模块接口WiFi 模块接口,接上 WiFi 模块,开发板可以轻松上网冲浪
+

表 1-1 主板元器件说明

+', '2022-06-13 22:35:34', '2022-06-13 22:35:34'); \ No newline at end of file