Selaa lähdekoodia

Merge branch 'master' of https://git.coding.net/Charsen/property-docs

李爱光 6 vuotta sitten
vanhempi
commit
771e819fa2

+ 246 - 0
规范/Java后端/Java后端开发手册.md

@@ -0,0 +1,246 @@
+# Java后端开发手册
+
+### 技术栈介绍
+
+| 模块         | 主键                                                         |
+| ------------ | ------------------------------------------------------------ |
+| 核心框架     | spring boot 2.1.2.RELEASE                                    |
+| 安全框架     | spring security 2.1.2.RELEASE                                |
+| 注册中心     | eureka                                                       |
+| 网关         | spring cloud gateway                                         |
+| 服务监控     | spring boot admin                                            |
+| 请求链追踪   | zipkin-server 2.12.0                                         |
+| 服务间调用   | feign 10.1.0                                                 |
+| http框架     | okhttp3                                                      |
+| 表单校验     | hibernate-validator 6.0.14.Final                             |
+| 数据库连接池 | druid 1.1.10                                                 |
+| 持久层       | mybatis 3.4.6                                                |
+| 缓存框架     | spring-data-redis 2.1.4.RELEASE、lettuce 5.1.3.RELEASE       |
+| 日志管理     | logback 1.2.3、slf4j 1.7.25                                  |
+| 定时任务     | quartz 2.3.0                                                 |
+| 工作流引擎   | flowable 6.4.1                                               |
+| 消息队列     | rocketMQ                                                     |
+| 性能测试框架 | contiperf 2.3.4                                              |
+| 验证码       | kaptcha 2.3.2                                                |
+| 配置文件加密 | jasypt 2.1.1                                                 |
+| 工具类       | lombok 1.18.2、joda-time 2.10.1、easyexcel 1.1.2-beta5、commons-lang3 3.3.2、pinyin4j 2.5.1、pagehelper 5.1.8、swagger 2.9.2 |
+
+### 基础环境
+
+操作系统:Ubuntu 18.04.1 LTS
+
+代码仓库:Git 2.17.1
+
+发版构建工具:Jenkins ver. 2.150.1、JDK 1.8.0_191、Maven 3.6.0
+
+接口文档管理:YApi 1.4.3、Swagger 2.9.2
+
+Maven私服:Nexus 3.15.2-01
+
+### 代码生成器介绍
+
+项目:wisdom-generator
+
+使用spring boot + velocity模板引擎实现,根据已设计好的表结构,完成dao、service、controller三层代码自动生成,并同时生成swagger文档以及基础的表单校验
+
+### 项目工程介绍
+
+##### 框架
+
+* wisdom-common (共通包,共通配置、工具类、通用bean) http://139.159.196.162:3000/WisdomCity-JAVA/wisdom-common.git
+* wisdom-ds (动态数据源)http://139.159.196.162:3000/WisdomCity-JAVA/wisdom-ds.git
+* wisdom-monitor (spring cloud服务监控)http://139.159.196.162:3000/WisdomCity-JAVA/wisdom-monitor.git
+* wisdom-track (服务调用链追踪)http://139.159.196.162:3000/WisdomCity-JAVA/wisdom-track.git
+* wisdom-gateway (服务网关)http://139.159.196.162:3000/WisdomCity-JAVA/wisdom-gateway.git
+* wisdom-center (服务注册中心)http://139.159.196.162:3000/WisdomCity-JAVA/wisdom-center.git
+* wisdom-parent (父pom,管理依赖包版本)http://139.159.196.162:3000/WisdomCity-JAVA/wisdom-parent.git
+
+##### 业务
+
+* wisdom-asset (资产管理系统)http://139.159.196.162:3000/WisdomCity-JAVA/wisdom-asset.git
+* wisdom-bill (账单管理系统)http://139.159.196.162:3000/WisdomCity-JAVA/wisdom-bill.git
+* wisdom-platform (平台系统)http://139.159.196.162:3000/WisdomCity-JAVA/wisdom-platform.git
+* wisdom-serve (物业服务系统)http://139.159.196.162:3000/WisdomCity-JAVA/wisdom-serve.git
+* wisdom-payment (支付网关)http://139.159.196.162:3000/WisdomCity-JAVA/wisdom-payment.git
+* wisdom-auth (授权中心)http://139.159.196.162:3000/WisdomCity-JAVA/wisdom-auth.git
+* wisdom-flow (工作流模块)http://139.159.196.162:3000/WisdomCity-JAVA/wisdom-flow.git
+* wisdom-push (推送系统)http://139.159.196.162:3000/WisdomCity-JAVA/wisdom-push.git
+* wisdom-file (文件系统)http://139.159.196.162:3000/WisdomCity-JAVA/wisdom-file.git
+
+### 开发步骤
+
+1. 原型评估
+
+2. 接口设计及接口文档编写
+
+3. 数据库表设计
+
+4. 代码生成
+
+5. 代码编写完善
+
+6. 功能发版
+
+7. 与前端联调
+
+8. 交付测试,bug跟踪
+
+   
+
+### 项目工程基础配置
+
+##### maven私服配置
+
+```xml
+<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
+  <localRepository>D:/usr/bin/Java/apache-maven-3.5.2/maven-dependcies</localRepository>
+  <pluginGroups>
+  </pluginGroups>
+  <proxies>
+  </proxies>
+  <servers>
+    <!-- 智慧城私服 -->
+	<server>
+      <id>wisdom</id>
+      <username>admin</username>
+      <password>WisdomCity@2019</password>
+    </server>
+  </servers>
+  <mirrors>
+	<!-- 智慧城私服 -->
+	<mirror>
+        <id>wisdom</id>
+        <mirrorOf>central</mirrorOf>
+        <url>http://139.159.210.228:8081/repository/maven-public/</url>
+    </mirror>
+	<!-- 智慧城私服 -->
+	<mirror>
+        <id>spring</id>
+        <mirrorOf>spring-milestones</mirrorOf>
+        <url>http://139.159.210.228:8081/repository/spring-milestones/</url>
+    </mirror>
+  </mirrors>
+  <profiles>
+	<profile>
+     <id>wisdom</id>
+     <repositories>
+       <repository>
+         <id>central</id>
+         <url>http://central</url>
+         <releases>
+           <enabled>true</enabled>
+         </releases>
+         <snapshots>
+           <enabled>true</enabled>
+		   <updatePolicy>always</updatePolicy>
+           <checksumPolicy>warn</checksumPolicy>
+         </snapshots>
+       </repository>
+     </repositories>
+     <pluginRepositories>
+       <pluginRepository>
+         <id>central</id>
+         <url>http://central</url>
+         <releases>
+           <enabled>true</enabled>
+         </releases>
+         <snapshots>
+           <enabled>true</enabled>
+		   <updatePolicy>always</updatePolicy>
+           <checksumPolicy>warn</checksumPolicy>
+         </snapshots>
+       </pluginRepository>
+     </pluginRepositories>
+   </profile>
+   <profile>
+      <id>spring-milestones</id>
+      <repositories>
+        <repository>
+          <id>spring-milestones</id>
+          <url>https://spring</url>
+          <releases>
+            <enabled>true</enabled>
+          </releases>
+          <snapshots>
+            <enabled>false</enabled>
+          </snapshots>
+        </repository>
+      </repositories>
+      <pluginRepositories>
+        <pluginRepository>
+          <id>spring-milestones</id>
+          <url>https://spring</url>
+          <releases>
+            <enabled>true</enabled>
+          </releases>
+          <snapshots>
+            <enabled>false</enabled>
+          </snapshots>
+        </pluginRepository>
+      </pluginRepositories>
+    </profile>
+  </profiles>
+  <activeProfiles>
+    <activeProfile>wisdom</activeProfile>
+    <activeProfile>spring-milestones</activeProfile>
+  </activeProfiles>
+</settings>
+```
+
+##### pom配置
+
+```xml
+   <parent>
+        <groupId>com.wisdom</groupId>
+        <artifactId>wisdom-cloud-parent</artifactId>
+        <version>1.0.0-SNAPSHOT</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+
+
+	<build>
+        <finalName>wisdom-xxx</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+```
+
+##### SwaggerConfig
+
+```java
+@Configuration
+@EnableSwagger2
+public class SwaggerConfig {
+    @Bean
+    public Docket createRestApi() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(apiInfo())
+                .select()
+                .apis(RequestHandlerSelectors.basePackage("com.wisdom.xxx.web"))
+                .paths(PathSelectors.any())
+                .build();
+    }
+
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+                .title("xxx系统")
+                .description("xxx系统")
+                .termsOfServiceUrl("http://wuye.huiguanjia.cn")
+                .version("1.0")
+                .build();
+    }
+}
+```
+
+##### 开发约定
+
+详见:[Java开发约定]:http://doc.huiguanjia.cn/markdown/content/router?filePath=/tmp/docs/develop/规范/Java后端/Java后端开发规范.md&code=null
+
+
+

+ 33 - 0
规范/运维/Linux环境部署规划.md

@@ -0,0 +1,33 @@
+# Linux环境部署规划
+
+### 系统版本
+
+* Ubuntu 18.04.1 LTS
+* JDK8
+* Maven 3.6.0
+* Git 2.17.1
+* Jenkins 2.150.1
+* YApi 1.4.3
+* Nexus 3.15.2-01
+
+### 系统用户
+
+* root 用户
+* ftp用户(仅能访问限定的目录)
+* dev用户(用于启动各种应用)
+* jenkins用户(仅用于发版)
+
+### 目录划分
+
+| 目录               | 功能描述                                |
+| ------------------ | --------------------------------------- |
+| /data/ftp          | FTP共享目录                             |
+| /data/log          | 应用日志                                |
+| /data/publish/java | Java后端应用发布路径(Jenkins用户授权) |
+| /data/publish/web  | 前端应用发布路径(Jenkins用户授权)     |
+| /data/soft         | 应用存放日志                            |
+| /data/bin          | 应用安装路径                            |
+| /data/back         | 备份文件路径                            |
+| /data/file         | 数据文件路径                            |
+
+![网络拓扑](image/网络拓扑.jpg)

BIN
规范/运维/image/网络拓扑.jpg


+ 261 - 0
规范/运维/堡垒机搭建.md

@@ -0,0 +1,261 @@
+# 堡垒机Jumpserver搭建
+
+### 系统环境
+
+* Ubuntu 18.04.2 LTS
+
+### 安装步骤
+
+##### 准备 Python3 和 Python 虚拟环境
+
+1. 安装依赖包
+
+   ```shell
+   $ apt-get update && apt-get -y upgrade
+   $ apt-get -y install wget gcc libffi-dev git libmysqlclient-dev
+   
+   # 修改字符集, 否则可能报 input/output error的问题, 因为日志里打印了中文
+   $ apt-get -y install language-pack-zh-hans
+   $ export LC_ALL=zh_CN.UTF-8
+   $ echo 'LANG="zh_CN.UTF-8"' > /etc/default/locale
+   ```
+
+2. 安装 Python3.6
+
+   ```shell
+   $ add-apt-repository ppa:jonathonf/python-3.6 -y
+   $ apt-get update
+   $ apt-get -y install python3.6 python3.6-dev python3.6-venv
+   # 查看python版本,如果存在多版本python则将系统默认python版本切换为python3.6
+   $ python --version
+   # 如果版本不是Python 3.6,则
+   $ echo alias python=python3 >> ~/.bashrc
+   $ source ~/.bashrc
+   # 再次检查python版本
+   $ python --version
+   ```
+
+3. 建立 Python 虚拟环境
+
+   ```shell
+   $ cd /opt
+   $ python3.6 -m venv py3
+   $ source /opt/py3/bin/activate
+   
+   # 看到下面的提示符代表成功, 以后运行 Jumpserver 都要先运行以上 source 命令, 以下所有命令均在该虚拟环境中运行
+   (py3) [root@localhost py3]
+   ```
+
+### 安装Jumpserver (以下所有命令都在python虚拟环境中执行)
+
+1. 下载或 Clone 项目
+
+   ```shell
+   $ cd /opt/
+   $ git clone https://github.com/jumpserver/jumpserver.git
+   ```
+
+2. 安装依赖包
+
+   ```shell
+   $ cd /opt/jumpserver/requirements
+   $ apt-get -y install $(cat deb_requirements.txt)  # 如果没有任何报错请继续
+   ```
+
+3. 安装 Python 库依赖
+
+   ```shell
+   $ pip install --upgrade pip setuptools
+   $ pip install -r requirements.txt
+   
+   # 如果下载速度很慢, 可以换国内源
+   $ pip install --upgrade pip setuptools -i https://mirrors.aliyun.com/pypi/simple/
+   $ pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
+   ```
+
+4. 安装 Redis, Jumpserver 使用 Redis 做 cache 和 celery broke
+
+   ```shell
+   $ apt-get -y install redis-server
+   ```
+
+5. 安装 MySQL
+
+   ```shell
+   $ apt-get -y install mysql-server  # 安装过程中注意输入数据库 root账户 的密码
+   ```
+
+6. 创建数据库 Jumpserver 并授权
+
+   ```shell
+   $ DB_PASSWORD=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 24`  # 生成随机数据库密码
+   $ echo -e "\033[31m 你的数据库密码是 $DB_PASSWORD \033[0m"
+   $ mysql -uroot -p -e "create database jumpserver default charset 'utf8'; grant all on jumpserver.* to 'jumpserver'@'127.0.0.1' identified by '$DB_PASSWORD'; flush privileges;"
+   ```
+
+7. 修改 Jumpserver 配置文件
+
+   ```shell
+   $ cd /opt/jumpserver
+   $ cp config_example.yml config.yml
+   
+   $ SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50`  # 生成随机SECRET_KEY
+   $ echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc
+   $ BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`  # 生成随机BOOTSTRAP_TOKEN
+   $ echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc
+   
+   $ sed -i "s/SECRET_KEY:/SECRET_KEY: $SECRET_KEY/g" /opt/jumpserver/config.yml
+   $ sed -i "s/BOOTSTRAP_TOKEN:/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/jumpserver/config.yml
+   $ sed -i "s/# DEBUG: true/DEBUG: false/g" /opt/jumpserver/config.yml
+   $ sed -i "s/# LOG_LEVEL: DEBUG/LOG_LEVEL: ERROR/g" /opt/jumpserver/config.yml
+   $ sed -i "s/# SESSION_EXPIRE_AT_BROWSER_CLOSE: false/SESSION_EXPIRE_AT_BROWSER_CLOSE: true/g" /opt/jumpserver/config.yml
+   $ sed -i "s/DB_PASSWORD: /DB_PASSWORD: $DB_PASSWORD/g" /opt/jumpserver/config.yml
+   
+   $ echo -e "\033[31m 你的SECRET_KEY是 $SECRET_KEY \033[0m"
+   $ echo -e "\033[31m 你的BOOTSTRAP_TOKEN是 $BOOTSTRAP_TOKEN \033[0m"
+   ```
+
+8. 运行 Jumpserver
+
+   ```shell
+   $ cd /opt/jumpserver
+   $ ./jms start all -d  # 后台运行使用 -d 参数./jms start all -d
+   # 运行不报错, 请继续往下操作安装 SSH Server 和 WebSocket Server: Coco
+   ```
+
+### 安装 SSH Server 和 WebSocket Server: Coco
+
+1. 下载或 Clone 项目
+
+   ```shell
+   $ cd /opt
+   $ source /opt/py3/bin/activate
+   $ git clone https://github.com/jumpserver/coco.git && cd coco && git checkout master
+   ```
+
+2. 安装依赖
+
+   ```shell
+   $ cd /opt/coco/requirements
+   $ pip install -r requirements.txt
+   
+   # 如果下载速度很慢, 可以换国内源
+   $ pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
+   ```
+
+3. 查看配置文件并运行
+
+   ```shell
+   $ cd /opt/coco
+   $ cp config_example.yml config.yml
+   $ vi config.yml
+   # 修改BOOTSTRAP_TOKEN为/opt/jumpserver/config.yml的BOOTSTRAP_TOKEN
+   $ ./cocod start -d  # 后台运行使用 -d 参数./cocod start -d
+   ```
+
+### 安装 Web Terminal 前端: Luna
+
+1. 下载解压Luna
+
+   ```shell
+   $ cd /opt/
+   $ wget https://github.com/jumpserver/luna/releases/download/1.4.9/luna.tar.gz
+   
+   # 如果网络有问题导致下载无法完成可以使用下面地址
+   $ wget https://demo.jumpserver.org/download/luna/1.4.9/luna.tar.gz
+   
+   $ tar xf luna.tar.gz
+   $ chown -R root:root luna
+   ```
+
+### 配置 Nginx 整合各组件
+
+1. 安装 Nginx
+
+   ```shell
+   $ apt-get -y install nginx
+   $ rm -rf /etc/nginx/site-enabled/default
+   ```
+
+2. 创建配置文件 /etc/nginx/site-enabled/jumpserver.conf
+
+   ```shell
+   $ vim /etc/nginx/site-enabled/jumpserver.conf
+   # 文件内容
+   server {
+       listen 80;
+       server_name _;
+   
+       client_max_body_size 100m;  # 录像及文件上传大小限制
+   
+       location /luna/ {
+           try_files $uri / /index.html;
+           alias /opt/luna/;  # luna 路径, 如果修改安装目录, 此处需要修改
+       }
+   
+       location /media/ {
+           add_header Content-Encoding gzip;
+           root /opt/jumpserver/data/;  # 录像位置, 如果修改安装目录, 此处需要修改
+       }
+   
+       location /static/ {
+           root /opt/jumpserver/data/;  # 静态资源, 如果修改安装目录, 此处需要修改
+       }
+   
+       location /socket.io/ {
+           proxy_pass       http://localhost:5000/socket.io/; # 如果coco安装在别的服务器, 请填写它的ip
+           proxy_buffering off;
+           proxy_http_version 1.1;
+           proxy_set_header Upgrade $http_upgrade;
+           proxy_set_header Connection "upgrade";
+           proxy_set_header X-Real-IP $remote_addr;
+           proxy_set_header Host $host;
+           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+           access_log off;
+       }
+   
+       location /coco/ {
+           proxy_pass       http://localhost:5000/coco/;
+           proxy_set_header X-Real-IP $remote_addr;
+           proxy_set_header Host $host;
+           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+           access_log off;
+       }
+   
+       location /guacamole/ {
+           proxy_pass       http://localhost:8081/;  # 如果guacamole安装在别的服务器, 请填写它的ip
+           proxy_buffering off;
+           proxy_http_version 1.1;
+           proxy_set_header Upgrade $http_upgrade;
+           proxy_set_header Connection $http_connection;
+           access_log off;
+           proxy_set_header X-Real-IP $remote_addr;
+           proxy_set_header Host $host;
+           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+       }
+   
+       location / {
+           proxy_pass http://localhost:8080;
+           proxy_set_header X-Real-IP $remote_addr;
+           proxy_set_header Host $host;
+           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+       }
+   }
+   ```
+
+3. 重启Nginx
+
+   ```shell
+   $ nginx -t  # 如果没有报错请继续
+   $ nginx -s reload
+   ```
+
+### 开始使用Jumpserver
+
+服务全部启动后, 访问http://localhost
+
+账号:admin
+
+密码:admin
+
+完结!

+ 0 - 0
部署环境/Jenkins部署.md → 规范/运维/部署环境/Jenkins部署.md


+ 0 - 0
部署环境/Ubuntu环境配置.md → 规范/运维/部署环境/Ubuntu环境配置.md


+ 0 - 0
部署环境/jdk部署.md → 规范/运维/部署环境/jdk部署.md


+ 0 - 0
部署环境/maven私服部署.md → 规范/运维/部署环境/maven私服部署.md


+ 0 - 0
部署环境/maven部署.md → 规范/运维/部署环境/maven部署.md


+ 0 - 0
部署环境/mongo部署.md → 规范/运维/部署环境/mongo部署.md


+ 0 - 0
部署环境/mysql部署.md → 规范/运维/部署环境/mysql部署.md


+ 34 - 0
部署环境/nginx部署.md → 规范/运维/部署环境/nginx部署.md

@@ -113,6 +113,40 @@ server {
 }
 ```
 
+### vhost/admin.conf
+
+```
+server {
+    listen 3000;
+    server_name 127.0.0.1;
+ 
+    root   html;
+    index  index.html index.htm index.php;
+ 
+
+    location / {
+        root /root/web/wisdom-web/public/;
+	index index.html;
+	try_files $uri $uri/ /index.html;
+
+        #Proxy Settings
+        proxy_redirect     off;
+        proxy_set_header   Host             $host;
+        proxy_set_header   X-Real-IP        $remote_addr;
+        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
+        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
+        proxy_max_temp_file_size 0;
+        proxy_connect_timeout      300;
+        proxy_send_timeout         300;
+        proxy_read_timeout         300;
+        proxy_buffer_size          4k;
+        proxy_buffers              4 32k;
+        proxy_busy_buffers_size    64k;
+        proxy_temp_file_write_size 64k;
+   }
+}
+```
+
 ### vhost/wechat_nginx.conf
 
 ```

+ 0 - 0
部署环境/redis部署.md → 规范/运维/部署环境/redis部署.md


+ 0 - 0
部署环境/yapi部署.md → 规范/运维/部署环境/yapi部署.md