新增空项目下载

This commit is contained in:
wenc000 2020-03-17 22:20:53 +08:00
parent 6631d57c55
commit 11c4cd4020
19 changed files with 1290 additions and 28 deletions

View File

@ -3,15 +3,19 @@ package com.cm.common.plugin.controller.apis.dynamic.config;
import com.cm.common.annotation.CheckRequestBodyAnnotation;
import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.exception.ParamsException;
import com.cm.common.exception.SearchException;
import com.cm.common.plugin.pojo.dtos.dynamic.config.DynamicConfigTableDTO;
import com.cm.common.plugin.pojo.vos.dynamic.config.DynamicConfigTableVO;
import com.cm.common.plugin.pojo.vos.dynamic.config.EmptyProjectVO;
import com.cm.common.plugin.service.dynamic.config.IDynamicConfigTableService;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultList;
import com.cm.common.utils.RegexUtil;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -137,4 +141,51 @@ public class DynamicConfigTableController extends AbstractController {
dynamicConfigTableService.getStaticCode(id, basePackage, context, response);
}
@ApiOperation(value = "下载空项目", notes = "下载空项目接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "systemUrl", value = "系统地址", paramType = "form"),
@ApiImplicitParam(name = "systemPort", value = "系统端口", paramType = "form", dataType = "Integer"),
@ApiImplicitParam(name = "systemName", value = "系统名", paramType = "form", dataType = "String"),
@ApiImplicitParam(name = "systemSummary", value = "系统说明", paramType = "form", dataType = "String"),
@ApiImplicitParam(name = "oauthServerUrl", value = "认证地址", paramType = "form", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("getemptyproject")
public void saveEmptyProject(@RequestParam("systemUrl") String systemUrl,
@RequestParam("systemPort") Integer systemPort,
@RequestParam("systemName") String systemName,
@RequestParam("systemSummary") String systemSummary,
@RequestParam("oauthServerUrl") String oauthServerUrl,
HttpServletResponse response) throws Exception {
if (StringUtils.isBlank(systemUrl) || !RegexUtil.isUrl(systemUrl)) {
throw new ParamsException("系统地址格式不正确");
}
if (systemPort == null || systemPort <= 0 || systemPort > 65535) {
throw new ParamsException("系统端口不在范围");
}
if (StringUtils.isBlank(systemName) || !RegexUtil.isLetter(systemName)) {
throw new ParamsException("系统名必须全部为字母");
}
if (StringUtils.isBlank(systemSummary)) {
throw new ParamsException("系统说明必须全部为字母");
}
if (StringUtils.isBlank(oauthServerUrl) || !RegexUtil.isUrl(oauthServerUrl)) {
throw new ParamsException("认证地址格式不正确");
}
EmptyProjectVO emptyProjectVO = new EmptyProjectVO();
emptyProjectVO.setSystemUrl(systemUrl);
emptyProjectVO.setSystemPort(systemPort.toString());
emptyProjectVO.setSystemName(systemName);
emptyProjectVO.setSystemSummary(systemSummary);
emptyProjectVO.setOauthServerUrl(oauthServerUrl);
dynamicConfigTableService.getEmptyProject(emptyProjectVO, response);
}
@ApiOperation(value = "下载空项目", notes = "下载空项目接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("getassetszip")
public void getAssetsZip(HttpServletResponse response) {
dynamicConfigTableService.getAssetsZip(response);
}
}

View File

@ -59,4 +59,11 @@ public class DynamicConfigTableRouteController {
return mv;
}
@ApiOperation(value = "生成空项目页面", notes = "生成空项目页面接口")
@GetMapping("getgeneratoremptyproject")
public ModelAndView getGeneratorEmptyProject() {
ModelAndView mv = new ModelAndView("dynamic/config/get-generator-empty-project");
return mv;
}
}

View File

@ -0,0 +1,117 @@
package com.cm.common.plugin.pojo.vos.dynamic.config;
import com.cm.common.annotation.CheckEmptyAnnotation;
import com.cm.common.annotation.CheckNumberAnnotation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: EmptyProjectVO
* @Description: 空项目
* @Author: WangGeng
* @Date: 2020/3/16 10:45 下午
* @Version: 1.0
**/
@ApiModel
public class EmptyProjectVO {
@ApiModelProperty(name = "systemUrl", value = "系统地址")
@CheckEmptyAnnotation(name = "系统地址", verifyType = "url")
private String systemUrl;
@ApiModelProperty(name = "systemPort", value = "系统端口")
@CheckEmptyAnnotation(name = "系统端口", verifyType = "number")
private String systemPort;
@ApiModelProperty(name = "systemName", value = "系统名")
@CheckEmptyAnnotation(name = "系统名", verifyType = "letter")
private String systemName;
@ApiModelProperty(name = "systemSummary", value = "系统说明")
@CheckEmptyAnnotation(name = "系统说明")
private String systemSummary;
@ApiModelProperty(name = "oauthServerUrl", value = "认证地址")
@CheckEmptyAnnotation(name = "认证地址", verifyType = "url")
private String oauthServerUrl;
@ApiModelProperty(name = "clientId", value = "认证用户名")
private String clientId;
@ApiModelProperty(name = "clientSecret", value = "认证密码")
private String clientSecret;
public String getSystemUrl() {
return systemUrl == null ? "" : systemUrl.trim();
}
public void setSystemUrl(String systemUrl) {
this.systemUrl = systemUrl;
}
public String getSystemPort() {
return systemPort;
}
public void setSystemPort(String systemPort) {
this.systemPort = systemPort;
}
public String getSystemName() {
return systemName == null ? "" : systemName.trim();
}
public void setSystemName(String systemName) {
this.systemName = systemName;
}
public String getSystemSummary() {
return systemSummary == null ? "" : systemSummary.trim();
}
public void setSystemSummary(String systemSummary) {
this.systemSummary = systemSummary;
}
public String getOauthServerUrl() {
return oauthServerUrl == null ? "" : oauthServerUrl.trim();
}
public void setOauthServerUrl(String oauthServerUrl) {
this.oauthServerUrl = oauthServerUrl;
}
public String getClientId() {
return clientId == null ? "客户端认证用户名" : clientId.trim();
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getClientSecret() {
return clientSecret == null ? "客户端认证密码" : clientSecret.trim();
}
public void setClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("{");
sb.append("\"systemUrl\":")
.append("\"").append(systemUrl).append("\"");
sb.append(",\"systemPort\":")
.append(systemPort);
sb.append(",\"systemName\":")
.append("\"").append(systemName).append("\"");
sb.append(",\"systemSummary\":")
.append("\"").append(systemSummary).append("\"");
sb.append(",\"oauthServerUrl\":")
.append("\"").append(oauthServerUrl).append("\"");
sb.append(",\"clientId\":")
.append("\"").append(clientId).append("\"");
sb.append(",\"clientSecret\":")
.append("\"").append(clientSecret).append("\"");
sb.append('}');
return sb.toString();
}
}

View File

@ -5,6 +5,7 @@ import com.cm.common.exception.SearchException;
import com.cm.common.exception.UpdateException;
import com.cm.common.plugin.pojo.dtos.dynamic.config.DynamicConfigTableDTO;
import com.cm.common.plugin.pojo.vos.dynamic.config.DynamicConfigTableVO;
import com.cm.common.plugin.pojo.vos.dynamic.config.EmptyProjectVO;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultList;
@ -110,4 +111,20 @@ public interface IDynamicConfigTableService {
* @throws SearchException
*/
void getStaticCode(String id, String basePackage, String context, HttpServletResponse response) throws Exception;
/**
* 下载空项目
*
* @param emptyProjectVO
* @param response
* @throws Exception
*/
void getEmptyProject(EmptyProjectVO emptyProjectVO, HttpServletResponse response) throws Exception;
/**
* 下载静态资源包
*
* @param response
*/
void getAssetsZip(HttpServletResponse response);
}

View File

@ -15,6 +15,7 @@ import com.cm.common.plugin.pojo.dtos.dynamic.config.form.DynamicConfigFormDTO;
import com.cm.common.plugin.pojo.vos.dynamic.DynamicFormFieldVO;
import com.cm.common.plugin.pojo.vos.dynamic.DynamicFormVO;
import com.cm.common.plugin.pojo.vos.dynamic.config.DynamicConfigTableVO;
import com.cm.common.plugin.pojo.vos.dynamic.config.EmptyProjectVO;
import com.cm.common.plugin.service.dynamic.IDynamicFormService;
import com.cm.common.plugin.service.dynamic.IDynamicTableService;
import com.cm.common.plugin.service.dynamic.config.IDynamicConfigTableService;
@ -27,9 +28,11 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
@ -219,7 +222,7 @@ public class DynamicConfigTableServiceImpl extends AbstractService implements ID
fieldList.add(field);
}
String baseCodeFolder = String.format("%s/gencodes/%s/%s", fileProperties.getUploadPath(), dynamicConfigTableDTO.getTableName().toLowerCase(), String.valueOf(System.currentTimeMillis()));
String templatePath = String.format("codetemplate/%s", "default");
String templatePath = "codetemplate/default";
try {
generatorDefaultCode(templateMap, baseCodeFolder, templatePath);
@ -232,6 +235,254 @@ public class DynamicConfigTableServiceImpl extends AbstractService implements ID
}
}
@Override
public void getEmptyProject(EmptyProjectVO emptyProjectVO, HttpServletResponse response) throws Exception {
Map<String, Object> params = HashMapUtil.beanToMap(emptyProjectVO);
params.put("lowerSystemName", emptyProjectVO.getSystemName().toLowerCase());
params.put("firstUpperSystemName", WStringUtil.firstToUpper(emptyProjectVO.getSystemName()));
params.put("gmtCreate", DateUtil.getDay());
String baseCodeFolder = String.format("%s/emptyproject/%s/system-%s", fileProperties.getUploadPath(), String.valueOf(System.currentTimeMillis()), params.get("lowerSystemName").toString());
String templatePath = String.format("codetemplate/base");
try {
dynamicEmptyProject(params, baseCodeFolder, templatePath, response);
String zipCodeFile = baseCodeFolder + ".zip";
ZipUtil.zip(baseCodeFolder, zipCodeFile);
RequestUtil.downLoad(response, zipCodeFile);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new SearchException("生成代码失败");
}
}
@Override
public void getAssetsZip(HttpServletResponse response) {
response.setCharacterEncoding(ISystemConstant.CHARSET_UTF8);
response.setHeader("Content-Disposition", "attachment;filename=assets.zip");
response.setContentType("application/octet-stream");
ClassPathResource classPathResource = new ClassPathResource("assets.zip");
InputStream inputStream = null;
try {
inputStream = classPathResource.getInputStream();
IOUtils.copy(inputStream, response.getOutputStream());
response.flushBuffer();
} catch (IOException e) {
LOG.error(e.getMessage(), e);
} finally {
IOUtils.closeQuietly(inputStream);
}
}
/**
* 生成空项目
*
* @param params
* @param response
*/
private void dynamicEmptyProject(Map<String, Object> params, String baseCodeFolder, String templatePath, HttpServletResponse response) throws IOException {
freeMarkerConfigurer.getConfiguration().setClassForTemplateLoading(DynamicConfigTableServiceImpl.class, "/templates");
LOG.debug("生成pom.xml");
generatorEmptyProjectPomXML(params, baseCodeFolder, templatePath);
LOG.debug("生成banner.txt");
generatorEmptyProjectBannerTxt(params, baseCodeFolder, templatePath);
LOG.debug("生成application.yml");
generatorEmptyProjectApplicationYml(params, baseCodeFolder, templatePath);
LOG.debug("生成Application.java");
generatorEmptyProjectApplicationJava(params, baseCodeFolder, templatePath);
LOG.debug("生成AuthClientSecurityConfig.java");
generatorEmptyProjectAuthClientSecurityConfigJava(params, baseCodeFolder, templatePath);
LOG.debug("生成index.html");
generatorEmptyProjectIndexHtml(params, baseCodeFolder, templatePath);
LOG.debug("生成index.html");
generatorEmptyProjectDefaultHtml(params, baseCodeFolder, templatePath);
LOG.debug("生成403.html");
generatorEmptyProject403Html(params, baseCodeFolder, templatePath);
LOG.debug("生成404.html");
generatorEmptyProject404Html(params, baseCodeFolder, templatePath);
LOG.debug("生成500.html");
generatorEmptyProject500Html(params, baseCodeFolder, templatePath);
LOG.debug("生成mybatis-config.xml");
generatorEmptyProjectMybatisConfigXml(params, baseCodeFolder, templatePath);
}
/**
* 生成空项目pom.xml
*
* @param params
* @param baseCodeFolder
* @param templatePath
* @throws IOException
*/
private void generatorEmptyProjectPomXML(Map<String, Object> params, String baseCodeFolder, String templatePath) throws IOException {
String codePath = baseCodeFolder;
FolderUtil.createFolder(codePath);
Template template = freeMarkerConfigurer.getConfiguration().getTemplate(String.format("%s/pom.ftl", templatePath));
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(String.format("%s/pom.xml", codePath)), ISystemConstant.CHARSET_UTF8));
generatorCode(params, writer, template);
}
/**
* 生成空项目banner.txt
*
* @param params
* @param baseCodeFolder
* @param templatePath
* @throws IOException
*/
private void generatorEmptyProjectBannerTxt(Map<String, Object> params, String baseCodeFolder, String templatePath) throws IOException {
String codePath = String.format("%s/src/main/resources", baseCodeFolder);
FolderUtil.createFolder(codePath);
Template template = freeMarkerConfigurer.getConfiguration().getTemplate(String.format("%s/banner.ftl", templatePath));
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(String.format("%s/banner.txt", codePath)), ISystemConstant.CHARSET_UTF8));
generatorCode(params, writer, template);
}
/**
* 生成空项目application.yml
*
* @param params
* @param baseCodeFolder
* @param templatePath
* @throws IOException
*/
private void generatorEmptyProjectApplicationYml(Map<String, Object> params, String baseCodeFolder, String templatePath) throws IOException {
String codePath = String.format("%s/src/main/resources", baseCodeFolder);
FolderUtil.createFolder(codePath);
Template template = freeMarkerConfigurer.getConfiguration().getTemplate(String.format("%s/application.ftl", templatePath));
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(String.format("%s/application.yml", codePath)), ISystemConstant.CHARSET_UTF8));
generatorCode(params, writer, template);
}
/**
* 生成空项目Application.java
*
* @param params
* @param baseCodeFolder
* @param templatePath
* @throws IOException
*/
private void generatorEmptyProjectApplicationJava(Map<String, Object> params, String baseCodeFolder, String templatePath) throws IOException {
String codePath = String.format("%s/src/main/java/com/cm/%s", baseCodeFolder, params.get("lowerSystemName").toString());
FolderUtil.createFolder(codePath);
Template template = freeMarkerConfigurer.getConfiguration().getTemplate(String.format("%s/src/Application.ftl", templatePath));
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(String.format("%s/%sApplication.java", codePath, params.get("firstUpperSystemName").toString())), ISystemConstant.CHARSET_UTF8));
generatorCode(params, writer, template);
}
/**
* 生成空项目AuthClientSecurityConfig.java
*
* @param params
* @param baseCodeFolder
* @param templatePath
* @throws IOException
*/
private void generatorEmptyProjectAuthClientSecurityConfigJava(Map<String, Object> params, String baseCodeFolder, String templatePath) throws IOException {
String codePath = String.format("%s/src/main/java/com/cm/%s/config", baseCodeFolder, params.get("lowerSystemName").toString());
FolderUtil.createFolder(codePath);
Template template = freeMarkerConfigurer.getConfiguration().getTemplate(String.format("%s/src/AuthClientSecurityConfig.ftl", templatePath));
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(String.format("%s/AuthClientSecurityConfig.java", codePath)), ISystemConstant.CHARSET_UTF8));
generatorCode(params, writer, template);
}
/**
* 生成空项目index.html
*
* @param params
* @param baseCodeFolder
* @param templatePath
* @throws IOException
*/
private void generatorEmptyProjectIndexHtml(Map<String, Object> params, String baseCodeFolder, String templatePath) throws IOException {
String codePath = String.format("%s/src/main/resources/templates", baseCodeFolder);
FolderUtil.createFolder(codePath);
Template template = freeMarkerConfigurer.getConfiguration().getTemplate(String.format("%s/route/index.ftl", templatePath));
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(String.format("%s/index.html", codePath)), ISystemConstant.CHARSET_UTF8));
generatorCode(params, writer, template);
}
/**
* 生成空项目default.html
*
* @param params
* @param baseCodeFolder
* @param templatePath
* @throws IOException
*/
private void generatorEmptyProjectDefaultHtml(Map<String, Object> params, String baseCodeFolder, String templatePath) throws IOException {
String codePath = String.format("%s/src/main/resources/static", baseCodeFolder);
FolderUtil.createFolder(codePath);
Template template = freeMarkerConfigurer.getConfiguration().getTemplate(String.format("%s/route/default.ftl", templatePath));
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(String.format("%s/default.html", codePath)), ISystemConstant.CHARSET_UTF8));
generatorCode(params, writer, template);
}
/**
* 生成空项目403.html
*
* @param params
* @param baseCodeFolder
* @param templatePath
* @throws IOException
*/
private void generatorEmptyProject403Html(Map<String, Object> params, String baseCodeFolder, String templatePath) throws IOException {
String codePath = String.format("%s/src/main/resources/static/error", baseCodeFolder);
FolderUtil.createFolder(codePath);
Template template = freeMarkerConfigurer.getConfiguration().getTemplate(String.format("%s/error/403.ftl", templatePath));
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(String.format("%s/403.html", codePath)), ISystemConstant.CHARSET_UTF8));
generatorCode(params, writer, template);
}
/**
* 生成空项目404.html
*
* @param params
* @param baseCodeFolder
* @param templatePath
* @throws IOException
*/
private void generatorEmptyProject404Html(Map<String, Object> params, String baseCodeFolder, String templatePath) throws IOException {
String codePath = String.format("%s/src/main/resources/static/error", baseCodeFolder);
FolderUtil.createFolder(codePath);
Template template = freeMarkerConfigurer.getConfiguration().getTemplate(String.format("%s/error/404.ftl", templatePath));
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(String.format("%s/404.html", codePath)), ISystemConstant.CHARSET_UTF8));
generatorCode(params, writer, template);
}
/**
* 生成空项目500.html
*
* @param params
* @param baseCodeFolder
* @param templatePath
* @throws IOException
*/
private void generatorEmptyProject500Html(Map<String, Object> params, String baseCodeFolder, String templatePath) throws IOException {
String codePath = String.format("%s/src/main/resources/static/error", baseCodeFolder);
FolderUtil.createFolder(codePath);
Template template = freeMarkerConfigurer.getConfiguration().getTemplate(String.format("%s/error/500.ftl", templatePath));
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(String.format("%s/500.html", codePath)), ISystemConstant.CHARSET_UTF8));
generatorCode(params, writer, template);
}
/**
* 生成空项目mybatis-config.xml
*
* @param params
* @param baseCodeFolder
* @param templatePath
* @throws IOException
*/
private void generatorEmptyProjectMybatisConfigXml(Map<String, Object> params, String baseCodeFolder, String templatePath) throws IOException {
String codePath = String.format("%s/src/main/resources/mybatis", baseCodeFolder);
FolderUtil.createFolder(codePath);
Template template = freeMarkerConfigurer.getConfiguration().getTemplate(String.format("%s/mapper/mybatis-config.ftl", templatePath));
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(String.format("%s/mybatis-config.xml", codePath)), ISystemConstant.CHARSET_UTF8));
generatorCode(params, writer, template);
}
/**
* 动态表单转hashMap
*

View File

@ -0,0 +1,121 @@
server:
port: ${systemPort}
url: ${systemUrl}:${systemPort}/${lowerSystemName}
title: ${lowerSystemName}
servlet:
context-path: /${lowerSystemName}
spring:
thymeleaf:
prefix: classpath:/templates/
suffix: .html
mode: HTML5
encoding: UTF-8
cache: false
main:
allow-bean-definition-overriding: true
servlet:
multipart:
max-file-size: 1GB
max-request-size: 1GB
datasource:
druid:
url: jdbc:mysql://127.0.0.1:3306/db_cloud_${lowerSystemName}?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false
db-type: mysql
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
initial-size: 2
min-idle: 2
max-active: 5
max-wait: 60000
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 10
filter:
commons-log:
connection-logger-name: stat,wall,log4j
stat:
log-slow-sql: true
slow-sql-millis: 2000
connection-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
use-global-data-source-stat: true
# 数据库
mybatis:
config-location: classpath:mybatis/mybatis-config.xml
mapper-locations: classpath*:mybatis/mapper/**/*.xml
# 文档
swagger:
title: 接口文档
description: ${systemSummary}接口文档
service-url: https://baidu.com/
version: 1.0
swagger-base-package: com.cm
# 文件
file:
uploadPath: /Users/wenc/Desktop/filetest
imageTypes: png,jpg,jpeg,gif,blob
videoTypes: mp4,rmvb
audioTypes: mp3,wmv
fileTypes: doc,docx,xls,xlsx,ppt,pptx,txt,zip,rar,apk,pdf
maxFileCount: 6
# 安全
security:
oauth2:
oauth-server: ${oauthServerUrl}
oauth-logout: ${r"${security.oauth2.oauth-server}/logout?redirect_uri=${server.url}"}
client:
client-id: ${clientId}
client-secret: ${clientSecret}
user-authorization-uri: ${r"${security.oauth2.oauth-server}/oauth/authorize"}
access-token-uri: ${r"${security.oauth2.oauth-server}/oauth/token"}
grant-type: authorization_code
resource:
jwt:
key-uri: ${r"${security.oauth2.oauth-server}/oauth/token_key"}
token-info-uri: ${r"${security.oauth2.oauth-server}/oauth/check_token"}
user-info-uri: ${r"${security.oauth2.oauth-server}/user"}
authorization:
check-token-access: ${r"${security.oauth2.oauth-server}/oauth/token_key"}
api-path:
user-center: ${r"${security.oauth2.oauth-server}"}
# 访问控制
access-control:
pass-paths:
- /index.html
- /logout.html
- /default.html
- /assets/**
- /route/file/downloadfile/**
save-paths:
- /**/save*/**
- /**/add*/**
delete-paths:
- /**/delete*/**
- /**/remove*/**
update-paths:
- /**/update*/**
- /**/edit*/**
query-paths:
- /**/get*/**
- /**/query*/**
- /**/find*/**
- /**/list*/**
- /**/count*/**
# 日志
logging:
level:
root: error
com.cm: debug

View File

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<base href="/${lowerSystemName}/">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, appversion-scalable=0">
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid">
<div class="layadmin-tips">
<i class="layui-icon" face>&#xe664;</i>
<div class="layui-text">
权限不足
<h1>
<span class="layui-anim layui-anim-loop layui-anim-rotate">4</span>
<span class="layui-anim layui-anim-loop layui-anim-rotate">0</span>
<span class="layui-anim layui-anim-loop layui-anim-rotate">3</span>
</h1>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<base href="/${lowerSystemName}/">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, appversion-scalable=0">
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid">
<div class="layadmin-tips">
<i class="layui-icon" face>&#xe664;</i>
<div class="layui-text">
无法访问
<h1>
<span class="layui-anim layui-anim-loop layui-anim-rotate">4</span>
<span class="layui-anim layui-anim-loop layui-anim-rotate">0</span>
<span class="layui-anim layui-anim-loop layui-anim-rotate">4</span>
</h1>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<base href="/${lowerSystemName}/">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, appversion-scalable=0">
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid">
<div class="layadmin-tips">
<i class="layui-icon" face>&#xe664;</i>
<div class="layui-text">
系统错误
<h1>
<span class="layui-anim layui-anim-loop layui-anim-rotate">4</span>
<span class="layui-anim layui-anim-loop layui-anim-rotate">0</span>
<span class="layui-anim layui-anim-loop layui-anim-rotate">5</span>
</h1>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<typeAliases>
<typeAlias type="java.util.Map" alias="map"/>
<typeAlias type="java.util.List" alias="list"/>
</typeAliases>
<plugins>
<plugin interceptor="com.github.pagehelper.PageInterceptor"></plugin>
</plugins>
</configuration>

View File

@ -0,0 +1,109 @@
<?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>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath/>
</parent>
<groupId>com.cm</groupId>
<artifactId>system-${systemName}</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>system-${systemName}</name>
<description>${systemSummary}</description>
<properties>
<java.version>1.8</java.version>
<durid.version>1.0.31</durid.version>
<spring-boot.version>2.1.2.RELEASE</spring-boot.version>
<spring-mybatis.version>1.3.2</spring-mybatis.version>
<spring-jdbc.version>5.1.4.RELEASE</spring-jdbc.version>
<mysql.version>5.1.47</mysql.version>
<freemarker.version>2.3.28</freemarker.version>
<druid.version>1.1.9</druid.version>
<cm-cloud.version>1.0.1-SNAPSHOT</cm-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${r"${spring-boot.version}"}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>${r"${spring-boot.version}"}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>${r"${spring-boot.version}"}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
<version>${r"${spring-boot.version}"}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${r"${mysql.version}"}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${r"${spring-jdbc.version}"}</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${r"${spring-mybatis.version}"}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${r"${druid.version}"}</version>
</dependency>
<dependency>
<groupId>com.cm</groupId>
<artifactId>cloud-common-plugin-oauth</artifactId>
<version>${r"${cm-cloud.version}"}</version>
</dependency>
<dependency>
<groupId>com.cm</groupId>
<artifactId>cloud-common-plugin-dynamic</artifactId>
<version>${r"${cm-cloud.version}"}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${r"${spring-boot.version}"}</version>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<base href="/${lowerSystemName}/">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div id="LAY-app" class="layui-fluid">
<div class="layui-row layui-col-space15"></div>
</div>
</div>
<script type="text/javascript" src="assets/js/vue.min.js"></script>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'animate-numbers'], function() {
var $ = layui.$;
new Vue({
el: '#LAY-app',
data: {},
methods: {},
mounted: function() {
var self = this;
}
})
});
</script>
</body>
</html>

View File

@ -0,0 +1,236 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<base href="/${lowerSystemName}/">
<title th:text="${r"${title}"}"></title>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="icon" type="image/ico" href="assets/favicon.ico"/>
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body class="layui-layout-body">
<div id="LAY_app">
<div class="layui-layout layui-layout-admin">
<div class="layui-header">
<!-- 头部区域 -->
<ul class="layui-nav layui-layout-left">
<li class="layui-nav-item layadmin-flexible" lay-unselect>
<a href="javascript:void(0);" layadmin-event="flexible" title="侧边伸缩">
<i class="layui-icon layui-icon-shrink-right" id="LAY_app_flexible"></i>
</a>
</li>
<li class="layui-nav-item layui-hide-xs" lay-unselect>
<a href="javascript:void(0);" target="_blank" title="前台">
<i class="layui-icon layui-icon-website"></i>
</a>
</li>
<li class="layui-nav-item" lay-unselect>
<a href="javascript:void(0);" layadmin-event="refresh" title="刷新">
<i class="layui-icon layui-icon-refresh-3"></i>
</a>
</li>
</ul>
<ul class="layui-nav layui-layout-right" lay-filter="layadmin-layout-right">
<li class="layui-nav-item layui-hide-xs" lay-unselect>
<a href="javascript:void(0);" layadmin-event="theme">
<i class="layui-icon layui-icon-theme"></i>
</a>
</li>
<li class="layui-nav-item layui-hide-xs" lay-unselect>
<a href="javascript:void(0);" layadmin-event="note">
<i class="layui-icon layui-icon-note"></i>
</a>
</li>
<li class="layui-nav-item layui-hide-xs" lay-unselect>
<a href="javascript:void(0);" layadmin-event="fullscreen">
<i class="layui-icon layui-icon-screen-full"></i>
</a>
</li>
<li class="layui-nav-item" lay-unselect>
<a href="javascript:void(0);">
<cite th:text="${r"${userUsername}"}"></cite>
</a>
<dl class="layui-nav-child">
<dd><a id="LAY-changePassword" lay-href="javascript:void(0);">修改密码</a></dd>
<hr>
<dd id="LAY-logout" style="text-align: center;"><a href="javascript:void(0);">退出</a></dd>
</dl>
</li>
<li class="layui-nav-item layui-hide-xs" lay-unselect>
<a href="javascript:void(0);" layadmin-event="about"><i class="layui-icon layui-icon-more-vertical"></i></a>
</li>
<li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-unselect>
<a href="javascript:void(0);" layadmin-event="more"><i class="layui-icon layui-icon-more-vertical"></i></a>
</li>
</ul>
</div>
<!-- 侧边菜单 -->
<div class="layui-side layui-side-menu">
<div class="layui-side-scroll" id="menuBox"></div>
</div>
<!-- 页面标签 -->
<div class="layadmin-pagetabs" id="LAY_app_tabs">
<div class="layui-icon layadmin-tabs-control layui-icon-prev" layadmin-event="leftPage"></div>
<div class="layui-icon layadmin-tabs-control layui-icon-next" layadmin-event="rightPage"></div>
<div class="layui-icon layadmin-tabs-control layui-icon-down">
<ul class="layui-nav layadmin-tabs-select" lay-filter="layadmin-pagetabs-nav">
<li class="layui-nav-item" lay-unselect>
<a href="javascript:void(0);"></a>
<dl class="layui-nav-child layui-anim-fadein">
<dd layadmin-event="closeThisTabs"><a href="javascript:void(0);">关闭当前标签页</a></dd>
<dd layadmin-event="closeOtherTabs"><a href="javascript:void(0);">关闭其它标签页</a></dd>
<dd layadmin-event="closeAllTabs"><a href="javascript:void(0);">关闭全部标签页</a></dd>
</dl>
</li>
</ul>
</div>
<div class="layui-tab" lay-unauto lay-allowClose="true" lay-filter="layadmin-layout-tabs">
<ul class="layui-tab-title" id="LAY_app_tabsheader">
<li lay-id="default.html" lay-attr="default.html" class="layui-this"><i class="layui-icon layui-icon-home"></i></li>
</ul>
</div>
</div>
<!-- 主体内容 -->
<div class="layui-body" id="LAY_app_body">
<div class="layadmin-tabsbody-item layui-show">
<iframe id="defaultIFrame" frameborder="0" class="layadmin-iframe"></iframe>
</div>
</div>
<!-- 辅助元素,一般用于移动设备下遮罩 -->
<div class="layadmin-body-shade" layadmin-event="shade"></div>
</div>
</div>
<script id="menuTemplate" type="text/html">
<div class="layui-logo">
<span th:text="${r"${title}"}"></span>
</div>
<ul class="layui-nav layui-nav-tree" lay-shrink="all" id="LAY-system-side-menu" lay-filter="layadmin-system-side-menu">
{{# for(var i = 0, menu1; menu1 = d[i++];) { }}
<li data-name="component" class="layui-nav-item">
{{# if(menu1.subMenus.length > 0) { }}
<a href="javascript:void(0);" lay-tips="{{menu1.menuName}}" lay-direction="2">
<span class="layui-icon">
<i class="{{menu1.menuIcon}}"></i>
</span>
<cite>{{menu1.menuName}}</cite>
</a>
{{# } else { }}
<a href="javascript:void(0);" lay-tips="{{menu1.menuName}}" lay-href="{{menu1.routePrefix}}{{menu1.menuUrl}}" lay-open-type="{{menu1.openType}}" lay-direction="2">
<span class="layui-icon">
<i class="{{menu1.menuIcon}}"></i>
</span>
<cite>{{menu1.menuName}}</cite>
</a>
{{# } }}
{{# if(menu1.subMenus.length > 0) { }}
<dl class="layui-nav-child">
{{# for(var j = 0, menu2; menu2 = menu1.subMenus[j++];) { }}
<dd data-name="grid">
{{# if(menu2.subMenus.length > 0) { }}
<a href="javascript:void(0);">
<span class="layui-icon">
<i class="{{menu2.menuIcon}}"></i>
</span>
<cite>{{menu2.menuName}}</cite>
</a>
{{# } else { }}
<a href="javascript:void(0);" lay-href="{{menu2.routePrefix}}{{menu2.menuUrl}}" lay-open-type="{{menu2.openType}}">
<span class="layui-icon">
<i class="{{menu2.menuIcon}}"></i>
</span>
<cite>{{menu2.menuName}}</cite>
</a>
{{# } }}
{{# if(menu2.subMenus.length > 0) { }}
<dl class="layui-nav-child">
{{# for(var k = 0, menu3; menu3 = menu2.subMenus[k++];) { }}
<dd data-name="list">
<a href="javascript:void(0)" lay-href="{{menu3.routePrefix}}{{menu3.menuUrl}}" lay-open-type="{{menu3.openType}}">{{menu3.menuName}}</a>
</dd>
{{# } }}
</dl>
{{# } }}
</dd>
{{# } }}
</dl>
{{# } }}
</li>
{{# } }}
</ul>
</script>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'laytpl', 'restajax', 'datamessage', 'dialog'], function() {
var $ = layui.$;
var layer = layui.layer;
var laytpl = layui.laytpl;
window.dialog = layui.dialog;
window.restAjax = layui.restajax;
window.dataMessage = layui.datamessage;
// 初始化菜单
function initMenus() {
restAjax.get(restAjax.path('api/menu/listmenuofmine', []), {}, null, function(code, data) {
laytpl(document.getElementById('menuTemplate').innerHTML).render(data, function(html){
document.getElementById('menuBox').innerHTML = html;
});
layui.element.init();
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
initMenus();
function changePassword() {
top.dialog.open({
url: top.restAjax.path('route/user/updatepassword', []),
title: '修改密码',
width: '400px',
height: '290px',
onClose: function() {}
});
}
function checkPasswordStatus() {
top.restAjax.get(top.restAjax.path('api/user/getpasswordstatus', []), {}, null, function(code, data) {
if(data.data == 'change') {
changePassword();
} else if(data.data == 'remind') {
layer.open({
auto: ['100px', '80px'],
offset: 'rb'
});
}
}, function(code, data) {
top.dialog.message(data.msg);
});
}
checkPasswordStatus();
$('#LAY-changePassword').on('click', function() {
changePassword()
});
$('#defaultIFrame').attr('src', 'default.html');
$('#LAY-logout').on('click', function() {
top.dialog.confirm('确认退出?', function() {
window.location.href = 'logout';
});
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,24 @@
package com.cm.${lowerSystemName};
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* ${systemSummary}
*
* @author WenG
*/
@EnableSwagger2
@SpringBootApplication
@ComponentScan("com.cm")
@MapperScan({"com.cm.**.dao"})
public class ${firstUpperSystemName}Application {
public static void main(String[] args) {
SpringApplication.run(${firstUpperSystemName}Application.class, args);
}
}

View File

@ -0,0 +1,83 @@
package com.cm.${lowerSystemName}.config;
import com.cm.common.config.properties.OauthProperties;
import com.cm.common.plugin.converter.ClientUserAccessTokenConverter;
import com.cm.common.plugin.utils.RestTemplateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.oauth2.provider.token.DefaultTokenServices;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
/**
* @ClassName: AuthClientSecurityConfig
* @Description: ${systemSummary}认证配置
* @Author: WenG
* @Date: ${gmtCreate}
**/
@EnableWebSecurity
@EnableOAuth2Sso
public class AuthClientSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private OauthProperties authServer;
@Autowired
private RestTemplateUtil restTemplateUtil;
@Autowired
private OauthProperties oauthProperties;
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.formLogin()
.defaultSuccessUrl("/authorize", true)
.and()
.logout().logoutSuccessUrl(authServer.getOauthLogout())
.and()
.authorizeRequests().antMatchers("/app/**", "/route/file/**", "/assets/**").permitAll()
.and()
.authorizeRequests()
.anyRequest()
.access("@clientRbacService.hasPermission(request, authentication)")
.and()
.headers().frameOptions().sameOrigin()
.and()
.cors()
.and()
.csrf().disable();
}
@Bean
@Primary
public DefaultTokenServices defaultTokenServices() {
DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
defaultTokenServices.setTokenStore(jwtTokenStore());
return defaultTokenServices;
}
@Bean
public JwtTokenStore jwtTokenStore() {
return new JwtTokenStore(jwtAccessTokenConverter());
}
@Bean
public JwtAccessTokenConverter jwtAccessTokenConverter() {
JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
jwtAccessTokenConverter.setAccessTokenConverter(new ClientUserAccessTokenConverter(this.oauthProperties, this.restTemplateUtil));
jwtAccessTokenConverter.setSigningKey("cmxx");
return jwtAccessTokenConverter;
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}

View File

@ -0,0 +1,111 @@
<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#httpServletRequest.getScheme() + '://' + #httpServletRequest.getServerName() + ':' + #request.getServerPort() + #request.getContextPath() + '/'} ">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein" style="padding: 0px;">
<div class="layui-card">
<div class="layui-card-body" style="padding: 15px;">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<div class="layui-form-item">
<label class="layui-form-label">系统地址 *</label>
<div class="layui-input-block">
<input type="text" name="systemUrl" lay-verify="url" placeholder="请输入系统地址如http://192.169.1.1" class="layui-input" value="http://192.168.1.1">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">系统端口 *</label>
<div class="layui-input-block">
<input type="number" name="systemPort" lay-verify="number" placeholder="请输入系统端口8080" class="layui-input" value="8080">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">系统名 *</label>
<div class="layui-input-block">
<input type="text" name="systemName" lay-verify="letter" placeholder="请输入系统名usercenter" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">系统说明 *</label>
<div class="layui-input-block">
<input type="text" name="systemSummary" lay-verify="require" placeholder="请输入系统说明" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">认证地址 *</label>
<div class="layui-input-block">
<input type="text" name="oauthServerUrl" lay-verify="url" placeholder="请输入认证地址如http://192.168.0.106:7001/usercenter" class="layui-input" value="http://192.168.0.106:7001/usercenter">
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">确定生成</button>
<button type="button" class="layui-btn layui-btn-primary close">关闭</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<input type="hidden" id="id" th:value="${id}">
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laydate'], function(){
var $ = layui.$;
var form = layui.form;
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
// 初始化
function initData() {}
initData();
// 提交表单
form.on('submit(submitForm)', function(data) {
var formData = data.field;
var formStr = '';
for (var name in formData) {
if (formStr.length == 0) {
formStr += name + '=' + encodeURI(formData[name]);
} else {
formStr += '&' + name + '=' + encodeURI(formData[name]);
}
}
top.dialog.confirm('确定下载吗?', function(index) {
top.dialog.close(index);
top.window.open(top.restAjax.path('api/dynamicconfigtable/getemptyproject?{formStr}', [formStr]))
closeBox();
});
return false;
});
form.verify({
letter: function(value, item) {
if(!/[a-zA-Z]+/g.test(value)){
return '必须是字母';
}
}
});
$('.close').on('click', function() {
closeBox();
});
});
</script>
</body>
</html>

View File

@ -21,15 +21,15 @@
<div class="layui-inline">
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
</div>
<div class="layui-inline">
<input type="text" id="startTime" class="layui-input search-item" placeholder="开始时间" readonly>
</div>
<div class="layui-inline">
<input type="text" id="endTime" class="layui-input search-item" placeholder="结束时间" readonly>
</div>
<button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索
</button>
<button type="button" id="emptyProject" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-cloud-download"></i> 基础项目
</button>
<button type="button" id="staticAssets" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-cloud-download"></i> 静态资源
</button>
</div>
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
<!-- 表头按钮组 -->
@ -67,13 +67,14 @@
var windowWidth = $(window).width();
var windowHeight = $(window).height();
var resizeTimeout = null;
var tableUrl = top.restAjax.path('api/dynamicconfigtable/listpagetable', []);
// 初始化表格
function initTable() {
table.render({
elem: '#dataTable',
id: 'dataTable',
url: top.restAjax.path('api/dynamicconfigtable/listpagetable', []),
url: tableUrl,
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 90,
limit: 20,
@ -125,27 +126,13 @@
// 重载表格
function reloadTable() {
table.reload('dataTable', {
url: top.restAjax.path('api/dynamicconfigtable/listpagetable', []),
url: tableUrl,
where: {
keywords: $('#keywords').val(),
startTime: $('#startTime').val(),
endTime: $('#endTime').val()
keywords: $('#keywords').val()
},
height: $win.height() - 90,
});
}
// 初始化日期
function initDate() {
// 日期选择
laydate.render({
elem: '#startTime',
format: 'yyyy-MM-dd'
});
laydate.render({
elem: '#endTime',
format: 'yyyy-MM-dd'
});
}
// 删除
function removeData(ids) {
top.dialog.msg(top.dataMessage.delete, {
@ -170,7 +157,6 @@
});
}
initTable();
initDate();
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);
@ -182,6 +168,17 @@
$(document).on('click', '#search', function() {
reloadTable();
});
$(document).on('click', '#emptyProject', function() {
top.dialog.open({
url: top.restAjax.path('route/dynamicconfigtable/getgeneratoremptyproject', []),
title: '生成空项目',
width: '400px',
height: '400px'
});
});
$(document).on('click', '#staticAssets', function() {
top.window.open(top.restAjax.path('api/dynamicconfigtable/getassetszip', []))
});
// 事件 - 增删改
table.on('toolbar(dataTable)', function(obj) {
var layEvent = obj.event;