Skip to content

Commit

Permalink
github
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangshibin committed Jun 16, 2019
1 parent 1d607ce commit 8ac22ec
Show file tree
Hide file tree
Showing 90 changed files with 1,732 additions and 343 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ temp_output/
*.db
.DS_Store
code_output/
tableModel/
tableModel/
molicode_repos/
5 changes: 5 additions & 0 deletions molicode-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@
<artifactId>maven-invoker</artifactId>
</dependency>

<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
</dependency>

<dependency>
<groupId>com.google.googlejavaformat</groupId>
<artifactId>google-java-format</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.shareyi.molicode.common.vo.code

import com.shareyi.molicode.sdk.dto.ExtAttrDto
import com.shareyi.molicode.common.utils.PubUtils
import com.shareyi.molicode.common.vo.git.GitRepoVo
import com.shareyi.molicode.common.vo.maven.MavenResourceVo
import com.shareyi.molicode.sdk.dto.ExtAttrDto
import org.apache.commons.lang3.StringUtils

/**
Expand Down Expand Up @@ -70,10 +71,6 @@ class AutoCodeParams extends ExtAttrDto {
*/
String frontContent;

/**
* 是否直接输出到前台
*/
String outputFrontType;
/**
* 和页面会话ID,日志输出使用
*/
Expand Down Expand Up @@ -103,7 +100,16 @@ class AutoCodeParams extends ExtAttrDto {
/**
* json配置信息
*/
Map<String,Object> jsonConfig
Map<String, Object> jsonConfig
/**
* git仓库的配置
*/
GitRepoVo gitRepoInfo

/**
* 输出路径
*/
String outputType;

/**
* 是否包含该模板ID
Expand Down Expand Up @@ -245,6 +251,7 @@ class AutoCodeParams extends ExtAttrDto {
this.jsonConfig = jsonConfig
}


@Override
String toString() {
return "AutoCodeParams{" +
Expand All @@ -260,7 +267,6 @@ class AutoCodeParams extends ExtAttrDto {
", dataModelType='" + dataModelType + '\'' +
", resourceType='" + resourceType + '\'' +
", frontContent='" + frontContent + '\'' +
", outputFrontType='" + outputFrontType + '\'' +
", sid='" + sid + '\'' +
", mavenResourceVo=" + mavenResourceVo +
", loadTemplateContent=" + loadTemplateContent +
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.shareyi.molicode.common.vo.git;

/**
* git仓库相关配置
*
* @author zhangshibin
* @date 2019/6/14
*/
class GitRepoVo {
/**
* 远程地址
*/
String gitUrl;

/**
* 分支名称
*/
String branchName;
/**
* 用户名
*/
String userName;
/**
* 密码
*/
String password;

/**
* 加密密码
*/
String encryptPassword;

/**
* 模板相对路径
*/
String templateRelativePath;

@Override
String toString() {
return "GitRepoVo{" +
"gitUrl='" + gitUrl + '\'' +
", branchName='" + branchName + '\'' +
", userName='" + userName + '\'' +
", password='" + password + '\'' +
", encryptPassword='" + encryptPassword + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.shareyi.molicode.common.vo.page

import com.shareyi.molicode.common.vo.git.GitRepoVo

/**
* 替换参数
* @author david
* @since 2018/9/2
*/
class ReplaceParams {
class ReplaceParams extends GitRepoVo {

/**
* 原路径
Expand Down Expand Up @@ -35,4 +37,9 @@ class ReplaceParams {
* 文件目录转换表达式
*/
String dirReplaceExp;

/**
* 模板类型
*/
String templateType;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.shareyi.molicode.common.enums;

/**
* 输出方式枚举
*
* @author zhangshibin
* @date 2019/6/16
*/
public enum OutputTypeEnum implements EnumCode<String> {

LOCAL_DIR("1", "本地文件"),
ZIP_FILE("2", "zip文件"),
FRONT_CONSOLE("3", "前台");

String code, desc;

OutputTypeEnum(String code, String desc) {
this.code = code;
this.desc = desc;
}

@Override
public String getCode() {
return code;
}

@Override
public String getDesc() {
return desc;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.shareyi.molicode.common.enums;

/**
* 仓库类型
*
* @author zhangshibin
* @date 2019/6/10
*/
public enum RepoTypeEnum implements EnumCode<String> {

SAMPLE_PROJECT("sampleProject", "示例工程"),
TEMPLATE("template", "模板仓库");

private String code;
private String desc;

RepoTypeEnum(String code, String desc) {
this.code = code;
this.desc = desc;
}

@Override
public String getCode() {
return code;
}

@Override
public String getDesc() {
return desc;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
public enum TemplateTypeEnum implements EnumCode<String> {

LOCAL("local", "本地"),
MAVEN("maven", "maven");
MAVEN("maven", "maven"),
GIT("git", "git");

private final String code;
private final String desc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void setUrl(final String url) {
LOGGER.info("set swing browser url={}", url);
final StringBuilder stringBuilder=new StringBuilder();
stringBuilder.append("<html><h1>说明</h1> 本窗口仅仅提供文件选择器功能!");
stringBuilder.append("<p>服务已经启动,请用浏览器打开地址访问:</p>");
stringBuilder.append("<p>服务已经启动,请用chrome或者Firefox(低版本IE无法正常运行)浏览器打开地址访问:</p>");
stringBuilder.append("<a href=\"");
stringBuilder.append(url).append("\">");
stringBuilder.append(url).append("</a>");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package com.shareyi.molicode.common.utils;

import com.shareyi.molicode.common.valid.Validate;

import java.util.concurrent.TimeUnit;

/**
* 用时监控表
*
* @author zhangshibin
* @date 2019/6/15
*/
public class CostWatch {

/**
* 起始时间
*/
private Long startTime;
/**
* 结束时间
*/
private Long stopTime;

public Long getStartTime() {
return startTime;
}

public void setStartTime(Long startTime) {
this.startTime = startTime;
}

public Long getStopTime() {
return stopTime;
}

public void setStopTime(Long stopTime) {
this.stopTime = stopTime;
}

/**
* 创建一个已经启动的表
*
* @return
*/
public static CostWatch createStarted() {
CostWatch costWatch = new CostWatch();
costWatch.start();
return costWatch;
}

/**
* 启动
*/
public void start() {
this.startTime = System.currentTimeMillis();
}

public void stop() {
this.stopTime = System.currentTimeMillis();
}

/**
* 获取耗时
*
* @param timeUnit
* @return
*/
public long getCost(TimeUnit timeUnit) {
long cost = getCost();
switch (timeUnit) {
case DAYS:
return cost / (24 * 3600 * 1000);
case HOURS:
return cost / (3600 * 1000);
case MINUTES:
return cost / (60 * 1000);
case SECONDS:
return cost / (1 * 1000);
case MILLISECONDS:
return cost;
default:
Validate.assertTrue(false, "不支持的类型");
}
return 0;
}

/**
* 获取耗时 毫秒
*
* @return
*/
private long getCost() {
return stopTime - startTime;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.shareyi.molicode.common.utils;

import com.google.common.collect.Lists;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

Expand Down Expand Up @@ -103,11 +104,24 @@ public static String getTimeBasedStr() {
}


/**
* 执行md5
*
* @param str
* @return
*/
public static String md5(String str) {
return DigestUtils.md5Hex(str);
}


public static void main(String[] args) {
System.out.println(compareVersion("1.0.0", "1.0.1"));
System.out.println(compareVersion("1.0.a", "1.0.1"));
System.out.println(compareVersion("1.0.2", "1.0.1"));
System.out.println(compareVersion("1.0.1", "1.0.1"));
System.out.println(getTimeBasedStr());

System.out.println(md5("hahaha"));
}
}
Loading

0 comments on commit 8ac22ec

Please sign in to comment.