鸭脖娱乐app-治理系统模板开发详细教程

日期:2021-10-31 00:54:02 | 人气: 35230

本文摘要:序言继上一篇 一套治理系统基础模版详细梳理一下安装流程,功效说明,开发规范等。

鸭脖app大全

序言继上一篇 一套治理系统基础模版详细梳理一下安装流程,功效说明,开发规范等。后端项目结构?如何从零搭建情况开发?如何打包部署?接入开发及规范项目地址小结后端项目结构​ shop-server 依赖以下项目https://github.com/cuteJ/ot-server-parent (统一版本插件治理)https://github.com/cuteJ/ot-server-commons (公共基础类)https://github.com/cuteJ/ot-boot-starter (自界说Spring boot starter)https://github.com/cuteJ/ot-mybatis-generator (定制生成器)所依赖的项目安装包位置:https://maven.pkg.github.com/cuteJ/ot-server-parent依赖继续关系如下:项目依赖关系图如何从零搭建情况开发此小节为零基础搭建,履历开发人员可直接跳过!!!安装情况JDK1.8https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.htmlMavenhttps://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.zipGithttps://git-scm.com/downloadsIntellij ideahttps://www.jetbrains.com/idea/download/Mysqlhttps://downloads.mysql.com/archives/community/NodeJshttps://nodejs.org/en/download/git jdk maven 设置Git 设置git config --global user.name <your name>git config --global user.email <your_email@example.com>Git建议设置windowsgit config --global core.autocrlf truemacosgit config --global core.autocrlf input不必每次输入密码git config credential.helper storeJdk设置# 执行以下下令,显示版本信息,安装完毕。➜ ~ java -versionjava version "1.8.0_151"Java(TM) SE Runtime Environment (build 1.8.0_151-b12)Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)#如果提示找不到对应下令添加➜ ~ vim .bash_profileexport JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk版本/Contents/Homeexport PATH=$PATH:$M2_HOME/binMaven设置➜ ~ vim .bash_profileexport M2_HOME=/Users/lixingping/soft/apache-maven-3.5.2export PATH=$PATH:$M2_HOME/bin➜ ~ source .bash_profile➜ ~ mvn -vApache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T15:58:13+08:00)~/.m2 目录下添加settings.xml文件<?xml version="1.0" encoding="UTF-8"?><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"> <servers> <server> <id>github</id> <username>cuteJ</username> <password>30b172901cad280e75dd5aa519fa02ab1040d3db</password> </server> </servers> <mirrors> <mirror> <id>nexus</id> <mirrorOf>central</mirrorOf> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </mirror> </mirrors> <profiles> <profile> <id>github</id> <repositories> <repository> <id>github</id> <name>GitHub OWNER Apache Maven Packages</name> <url>https://maven.pkg.github.com/cuteJ/ot-server-parent</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> </profile> </profiles> <activeProfiles> <activeProfile>github</activeProfile> </activeProfiles></settings>运行项目下载项目git clone https://github.com/cuteJ/shop-server.git初始化数据库shop-server/install/sql---- db.sql // 建立数据库和用户---- data.sql // 项目表结构和初始化数据3. 安装maven依赖启动maven.pkg.github.com下载有点慢,请有心理准备4. 安装启动前端git clone https://github.com/cuteJ/shop-web-mgt.gitcd shop-web-mgtnpm install --registry=https://registry.npm.taobao.orgnpm run dev如何打包部署打包 shop-servercd shop-servermvn clean package// 将jar拷贝到服务器/data/cuteJ/servershop-server/shop-server-mgt/shop-server-mgt.jar添加启动剧本(shop-server/install/shell/execute.sh)剧本情况变量说明MYSQL_URL:127.0.0.1:3306 数据库地址MYSQL_USER:cuteJ_shop 数据库用户名MYSQL_PASSWORD:cuteJ_shop123 数据库密码SERVER_PORT:8300 应用启动端口SERVER_CONTEXT_PATH:/shop 应用上下文SERVER_SESSION_TIMEOUT:1800 治理后台Session超时时间(单元秒)SERVER_ERROR_MODE:always 服务异常响应形式:always: 返回全部的客栈信息(一般在debug,开发测试情况使用)never:返回友好提示APP_CORS_ORIGIN: http://localhost:9527 跨域设置,也可以在nginx 设置JWT_HEADER:Authorization Jwt C端API 认证设置JWT_EXPIRATION token失效时间(单元秒)#!/bin/bash -#export MYSQL_URL=127.0.0.1:3306#export MYSQL_USER=cuteJ_shop#export MYSQL_PASSWORD=cuteJ_shop123#export SERVER_PORT=8300#export SERVER_CONTEXT_PATH=/shop#export SERVER_SESSION_TIMEOUT=1800#export SERVER_ERROR_MODE=always#export APP_CORS_ORIGIN: http://localhost:9527#export JWT_HEADER=Authorization#export JWT_SECRET=abkfdsfooi0934#export JWT_EXPIRATION=86400# oss optional(aliyun|huawei)#export APP_OSS_KEY=xxx#export APP_OSS_SECRET=xxx#export APP_OSS_ENDPOINT=xxx#export APP_OSS_URL=xxx#export APP_OSS_BUCKET=xxxMS_HOME=/data/cuteJ/serverMS_JAR=shop-server-mgt.jar #APP_NAME=shop-server-mgt #JAVA_OPTS="-Dspring.profiles.active=prod -Xms1g -Xmx4g -XX:MaxMetaspaceSize=256m -XX:+UseG1GC";MS_PID=`ps fax|grep java|grep "${MS_JAR}"|awk '{print $1}'`export MS_PID;# Function: startstart() { pid=${MS_PID} if [ -n "${pid}" ]; then { echo "${APP_NAME} Service is already running (pid: ${pid})"; } else { # Start screener ms echo "Starting ${APP_NAME} service"; cd ${MS_HOME} nohup java ${JAVA_OPTS} -jar ./${MS_JAR} > /dev/null 2>&1 & } fi; # return 0;}# Function: stopstop() { pid=${MS_PID} if [ -n "${pid}" ]; then { echo -ne "Stopping service module"; kill -15 ${pid} sleep 5 pid=`ps fax|grep java|grep "${MS_JAR}"|awk '{print $1}'` if [ ${pid} ]; then { echo 'Kill Process!' kill -9 ${pid} } else { echo "${APP_NAME} stop success." } fi; } else { echo "${APP_NAME} service is not running"; } fi; #return 0;}# Main Codecase $1 in start) start; ;; stop) stop; ;; restart) stop; sleep 1; start; ;; status) pid=${MS_PID} if [ "${pid}" ]; then { echo "${APP_NAME} service is running with pid: ${pid}"; } else { echo "${APP_NAME} service is not running"; } fi; ;;esacexit 0;执行剧本sh execute.sh start // 启动应用sh execute.sh stop // 停止应用sh execute.sh status // 检察应用状态安装 nginx http://nginx.org//设置server { listen 80; server_name www.xxxx.com; proxy_set_header Host $host; proxy_set_header x-auth-token $http_x_auth_token; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Authorization $http_authorization; proxy_pass_header Authorization; location / { // shop-web-mgt 打包后 dist文件 root /www/shop-web-mgt; add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate"; index index.html index.htm; } location /shop/ { proxy_set_header Host $host; proxy_set_header Cookie $http_cookie; proxy_set_header Referer $http_referer; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass_header Server; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_pass http://127.0.0.1:8300/shop/; #expires 0; }}打包前端 shop-web-mgt// 设置接口地址shop-web-mgt/config/prod.env.jsnpm run build:prod// 拷贝 dist 目录下的文件到nginx下面接入开发及规范后端基础数据初始化目录 shop-server-mgt/main/src/java/com.onlythinking.shop.initDicsInitializer (常量初始化)ApisInitializer (常量初始化)MenusInitializer (菜单初始化)AdminInitializer (治理员初始化)GrantInitializer (治理员授权)DBMetaInitializer (数据库表结构数据)执行初始化mvn -Pdev spring-boot:runcurl http://127.0.0.1:8300/shop/api/insecure/re_initMybatis 生成实体Mapper目录 shop-server-apihttps://github.com/cuteJ/ot-mybatis-generator (可凭据自身项目情况定制生成器)mvn -Pgenerator clean installgeneratorConfig设置数据库 generatorConfig.xml添加表生成后的实体,mapper效果API文档的生成定制化内容可在以下目录shop-server-mgt/src/docs/asciidoc 添加adoc文件mvn -PapiDcos clean installSwagger UI生成后的Html文档生成的后的PDF文档响应异常处置惩罚// 项目统一响应式异常为com.onlythinking.commons.exception.RespondedException// errorCode用法:如Token失效,接口校验约束异常等。public static final int TOKEN_EXPIRED = 40000; // Token 逾期。

private final int errorCode;private String errorMsg;private Object[] msgArgs;国际化处置惩罚原则上除代码注释外项目内里不应该有中文国际化文件目录:shop-server-mgt/src/main/resources/i18n// 读取国际化信息 private final MessageSource messageSource;String message = messageSource.getMessage("mgt.entity.null", null)// 响应式异常提示国际化处置惩罚if (StringUtils.isBlank(msg)) { throw RespondedException.argumentInvalid("{mgt.entity.null}");}// 携带参数响应式异常提示国际化处置惩罚if (StringUtils.isBlank(msg)) { throw RespondedException.argumentInvalid("{mgt.entity.null}", 10);}接口URL规范因为‘shop-server-app’和'shop-server-mgt'合并为一个应用启动,为了利便权限控制添加了/app前缀作为区分| 凭据情况也可以拆分为两个应用)/{content-path}/api/app/ //(h5,小法式请求接口)/{content-path}/api/ //(治理后台接口)com.onlythinking.commons.config.annotation.@ApiRest //说明@Slf4j@RequiredArgsConstructor(onConstructor = @__(@Autowired))@Api(tags = "用户登录")@ApiRest(serviceId = "app", value = "/auth/{appNo}/{maType}")public class MaAuthController {// controller 的拼接路径为/${content-path}/api/${serviceId}/${value}权限的处置惩罚// H5,小法式请求接口接纳jwt 详细检察:shop-server-appcom.onlythinking.shop.app.core.security.JwtAuthorizationTokenFiltershop-server-mgt 治理端接纳Shiro框架// RequiresPermissions value 规则 (module:domain:action)@ApiOperation("系统角色添加")@RequiresPermissions(value = "sys:role:save")@PostMapping(value = "/role/save")public RespondedBody sysRoleSave(@RequestBody OtSysRole dto) {infraSystemService.saveOrUpdateSysRole(dto); return RespondedBody.successful();}定时任务的开发com.onlythinking.shop.mgt.system.jobs 建立任务package com.onlythinking.shop.mgt.system.jobs;/** * <p> The describe </p> * * @author Li Xingping */@Slf4j@DisallowConcurrentExecutionpublic class HelloWordJob implements Job { @Override public void execute(JobExecutionContext context) { String instanceId = context.getMergedJobDataMap().getString("instanceId"); log.info("Job [{}] running ", instanceId); log.info("Hello world"); if (new Random().nextInt(20) % 2 == 0) { throw RespondedException.argumentInvalid("执行任务参数错误"); } }}建立任务模版实例前端目录结构src -- 源码目录├── api -- API├── assets -- 图片资源文件├── components -- 通用组件├── directive -- vue指令├── filters -- 过滤器├── lang -- 国际化设置├── icons -- svg文件├── router -- 路由设置├── store -- vuex状态治理├── styles -- 全局css样式├── utils -- 工具类└── views -- 页面组件 ├── app -- 应用治理(小法式) ├── dashboard -- 首页 ├── errorPage -- 错误页面 ├── layout -- 结构页面 ├── login -- 登录页 ├── profile -- 小我私家设置 ├── svg-icons -- 图标 ├── system -- 系统治理 ├── components -- 页面级别组件 ├── sysApiListManager -- 接口列表 ├── sysAuthorityManager -- 接口权限 ├── sysDicManager -- 常量治理 ├── sysJobManager -- 定时任务 ├── sysJobRunLogManager -- 定时任务日志 ├── sysMenuManager -- 菜单治理 ├── sysMetadataManager -- 数据字典 ├── sysOptLogManager -- 操作日志 ├── sysRegionManager -- 地域治理 ├── sysRoleManager -- 角色治理 ├── sysUserManager -- 系统用户治理 ├── user -- C端用户治理 ├── userLoginManager -- C端用户列表常量值的处置惩罚常量值好比:性别,状态为了适配国际化和特殊字符处置惩罚制定一套映射表。添加常量值<template> <!--组件使用--> <sys-code v-if="cacheData.codes" :cache-options="cacheData['codes']" :type-code="'1000'" :selected.sync="ok" /> <!--过滤器使用--> <span v-if="cacheData.statusMap">{{ scope.row.status | statusFilter(cacheData.statusMap['1000'])}}</span></template>import SysCode from '@/components/SysCode' import {cacheData} from '@/utils/cache' export default { name: 'demo', components: { SysCode }, data() { return { cacheData: {}, } }, mounted() { cacheData(this.cacheData, '1000').then(() => { }) } }项目地址如有需要使用其它语言实现后端,可以参考下面API文档实现对应接口即可。Swagger在线文档 https://cutej.github.io/shop-server/index.html项目地址https://github.com/cuteJ/shop-server 后端https://github.com/cuteJ/shop-web-mgt 前端演示地址:因为项目托管在github上面且第一次加载文件较多,所有打开会比力慢http://shop-web-mgt.onlythinking.com小结​ 项目刚起步,由于小我私家能力精神有限,项目里的纰漏和不足接待大家指出和交流。

鸭脖娱乐app

开源不易,有了大家的支持和勉励才气更好的走下去。


本文关键词:鸭脖娱乐app,鸭脖app大全

本文来源:鸭脖娱乐app-www.kxdngs.com