Commit 1b2faeeb authored by June's avatar June

v3

parent bd88cfc2
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<dependency> <dependency>
<groupId>com.jiankangyouyi.cloud</groupId> <groupId>com.jiankangyouyi.cloud</groupId>
<artifactId>health-cloud-motor-plan-api</artifactId> <artifactId>health-cloud-motor-plan-api</artifactId>
<version>2.2-TK-SNAPSHOT</version> <version>2.2.1-TK-SNAPSHOT</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
......
...@@ -62,7 +62,7 @@ public class AssessmentAccessTokenDO implements Serializable { ...@@ -62,7 +62,7 @@ public class AssessmentAccessTokenDO implements Serializable {
private String appId; private String appId;
/** /**
* 业务类型,见《开放平台业务类型设计.xlsx》 * 业务类型
*/ */
private String bizType; private String bizType;
......
...@@ -52,7 +52,7 @@ public class AssessmentCallbackConfigDO implements Serializable { ...@@ -52,7 +52,7 @@ public class AssessmentCallbackConfigDO implements Serializable {
private String appId; private String appId;
/** /**
* 业务类型,见《开放平台业务类型设计.xlsx》 * 业务类型
*/ */
private String bizType; private String bizType;
......
...@@ -61,7 +61,7 @@ public class AssessmentConfigDO { ...@@ -61,7 +61,7 @@ public class AssessmentConfigDO {
private String configName; private String configName;
/** /**
* 业务类型,见《开放平台业务类型设计.xlsx》 * 业务类型
*/ */
private String bizType; private String bizType;
......
...@@ -26,7 +26,7 @@ public class AssessmentInfoDO extends BaseMongoEntity { ...@@ -26,7 +26,7 @@ public class AssessmentInfoDO extends BaseMongoEntity {
/** /**
* 业务类型,见《开放平台业务类型设计.xlsx》 * 业务类型
*/ */
@Indexed(unique = true) @Indexed(unique = true)
private String bizType; private String bizType;
......
...@@ -48,7 +48,7 @@ public class AssessmentQuestionBackDO extends BaseMongoEntity { ...@@ -48,7 +48,7 @@ public class AssessmentQuestionBackDO extends BaseMongoEntity {
private String configId; private String configId;
/** /**
* 业务类型,见《开放平台业务类型设计.xlsx》 * 业务类型
*/ */
private String bizType; private String bizType;
......
...@@ -61,7 +61,7 @@ public class AssessmentReportDO extends BaseMongoEntity { ...@@ -61,7 +61,7 @@ public class AssessmentReportDO extends BaseMongoEntity {
private String tokenId; private String tokenId;
/** /**
* 业务类型,见《开放平台业务类型设计.xlsx》 * 业务类型
*/ */
private String bizType; private String bizType;
......
...@@ -31,7 +31,7 @@ public class EffectReport implements Serializable { ...@@ -31,7 +31,7 @@ public class EffectReport implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 业务类型,见《开放平台业务类型设计.xlsx》 * 业务类型
*/ */
private String bizType; private String bizType;
......
...@@ -75,7 +75,7 @@ public class LifeStyleReportDO implements Serializable { ...@@ -75,7 +75,7 @@ public class LifeStyleReportDO implements Serializable {
private String reportId; private String reportId;
/** /**
* 业务类型,见《开放平台业务类型设计.xlsx》 * 业务类型
*/ */
private String bizType; private String bizType;
......
...@@ -79,7 +79,7 @@ public class LifeStyleReportSchemeDO implements Serializable { ...@@ -79,7 +79,7 @@ public class LifeStyleReportSchemeDO implements Serializable {
private String schemeId; private String schemeId;
/** /**
* 业务类型,见《开放平台业务类型设计.xlsx》 * 业务类型
*/ */
private String bizType; private String bizType;
......
...@@ -70,7 +70,7 @@ public class LifeStyleReportSchemeDetailDO implements Serializable { ...@@ -70,7 +70,7 @@ public class LifeStyleReportSchemeDetailDO implements Serializable {
private String createDate; private String createDate;
/** /**
* 业务类型,见《开放平台业务类型设计.xlsx》 * 业务类型
*/ */
private String bizType; private String bizType;
......
...@@ -88,7 +88,7 @@ public class LifeStyleReportSchemeStageDO implements Serializable { ...@@ -88,7 +88,7 @@ public class LifeStyleReportSchemeStageDO implements Serializable {
private String schemeStageId; private String schemeStageId;
/** /**
* 业务类型,见《开放平台业务类型设计.xlsx》 * 业务类型
*/ */
private String bizType; private String bizType;
......
...@@ -16,13 +16,14 @@ ...@@ -16,13 +16,14 @@
package com.jiankangyouyi.cloud.basedata.model.entity.mongo; package com.jiankangyouyi.cloud.basedata.model.entity.mongo;
import lombok.*; import lombok.AllArgsConstructor;
import lombok.Data;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Document;
/** /**
* developer app information * 开发者应用信息
* *
* @author wangyalei * @author wangyalei
*/ */
......
...@@ -5,6 +5,7 @@ import com.june.entitytodbdoc.utils.FileUtils; ...@@ -5,6 +5,7 @@ import com.june.entitytodbdoc.utils.FileUtils;
import com.june.entitytodbdoc.utils.GetClassCommentUtils; import com.june.entitytodbdoc.utils.GetClassCommentUtils;
import com.june.entitytodbdoc.utils.MarkdownUtils; import com.june.entitytodbdoc.utils.MarkdownUtils;
import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
...@@ -18,10 +19,10 @@ import java.util.stream.Collectors; ...@@ -18,10 +19,10 @@ import java.util.stream.Collectors;
public class Starter { public class Starter {
public static void main(String[] args) { public static void main(String[] args) {
String beanFilePath = // String beanFilePath =
"D:\\work\\idea\\june\\entity-to-db-doc\\entity-to-db-doc\\src\\main\\java\\com\\jiankangyouyi\\cloud\\basedata"; // "D:\\work\\idea\\june\\entity-to-db-doc\\entity-to-db-doc\\src\\main\\java\\com\\jiankangyouyi\\cloud";
List<String> javaFilePaths = FileUtils.findJavaFilePaths(beanFilePath); // List<String> javaFilePaths = FileUtils.findJavaFilePaths(beanFilePath);
// List<String> javaFilePaths = Arrays.asList("D:\\work\\idea\\june\\entity-to-db-doc\\entity-to-db-doc\\src\\main\\java\\com\\june\\entitytodbdoc\\entity\\mongo\\food\\FoodProcessDO.java"); List<String> javaFilePaths = Arrays.asList("D:\\work\\idea\\june\\entity-to-db-doc\\entity-to-db-doc\\src\\main\\java\\com\\jiankangyouyi\\cloud\\motorplan\\model\\entity\\mongo\\ExerciseCoursePlanDO.java");
// 获取所有的 markdown 内容 // 获取所有的 markdown 内容
List<String> resultContentList = javaFilePaths List<String> resultContentList = javaFilePaths
.parallelStream().map(GetClassCommentUtils::execute) .parallelStream().map(GetClassCommentUtils::execute)
......
...@@ -29,12 +29,18 @@ public class ClassUtils { ...@@ -29,12 +29,18 @@ public class ClassUtils {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
}
try {
ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType();
Type[] typeArguments = parameterizedType.getActualTypeArguments();
Class<?> type = (Class<?>) typeArguments[0];
return type.getName();
} catch (Exception e) {
e.printStackTrace();
System.out.printf("获取泛型报错:%s-%s", fullClassName, field);
return null;
} }
ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType();
Type[] typeArguments = parameterizedType.getActualTypeArguments();
Class<?> type = (Class<?>) typeArguments[0];
return type.getName();
} }
public static void main(String[] args) { public static void main(String[] args) {
......
...@@ -27,7 +27,7 @@ public class FileUtils { ...@@ -27,7 +27,7 @@ public class FileUtils {
} }
for (File file : files) { for (File file : files) {
String absolutePath = file.getAbsolutePath(); String absolutePath = file.getAbsolutePath();
if (file.isFile() && absolutePath.toLowerCase().endsWith("do.java") && absolutePath.contains("jiankangyouyi")) { if (file.isFile() && absolutePath.endsWith(".java") && absolutePath.contains("jiankangyouyi")) {
javaFilePaths.add(absolutePath); javaFilePaths.add(absolutePath);
} else if (file.isDirectory()) { } else if (file.isDirectory()) {
javaFilePaths.addAll(findJavaFilePaths(absolutePath)); javaFilePaths.addAll(findJavaFilePaths(absolutePath));
......
...@@ -9,6 +9,7 @@ import com.sun.tools.javadoc.Main; ...@@ -9,6 +9,7 @@ import com.sun.tools.javadoc.Main;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.util.*; import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -74,7 +75,15 @@ public class GetClassCommentUtils { ...@@ -74,7 +75,15 @@ public class GetClassCommentUtils {
private static ClassDoc getInnerClassDoc(String beanFilePath) { private static ClassDoc getInnerClassDoc(String beanFilePath) {
if (!beanFilePath.contains("$")) { if (!beanFilePath.contains("$")) {
return getClassDoc(beanFilePath); // 判斷文件是否存在
if (!new File(beanFilePath).exists()) {
// 替换掉 最后 一个 \ 为 $
int lastIndex = beanFilePath.lastIndexOf("\\");
beanFilePath = beanFilePath.substring(0, lastIndex) + "$" + beanFilePath.substring(lastIndex + 1);
return getInnerClassDoc(beanFilePath);
}
ClassDoc classDoc = getClassDoc(beanFilePath);
return classDoc;
} }
Matcher matcher = PATTERN.matcher(beanFilePath); Matcher matcher = PATTERN.matcher(beanFilePath);
if (!matcher.matches()) { if (!matcher.matches()) {
...@@ -110,9 +119,15 @@ public class GetClassCommentUtils { ...@@ -110,9 +119,15 @@ public class GetClassCommentUtils {
if (field.isTransient() || field.isFinal()) { if (field.isTransient() || field.isFinal()) {
continue; continue;
} }
DocumentInfoDTO.FieldInfoDTO fieldInfoDTO = new DocumentInfoDTO.FieldInfoDTO(field.name(), field.type().typeName(), getRealFieldComment(field.commentText())); DocumentInfoDTO.FieldInfoDTO fieldInfoDTO = new DocumentInfoDTO.FieldInfoDTO(field.name(), field.type().typeName(), getFirstLineComment(field.commentText()));
// 判断是否是自己创建的类型 // 判断是否是自己创建的类型
String fieldClassFullName = field.type().qualifiedTypeName(); String fieldClassFullName = field.type().qualifiedTypeName();
String fieldClassTypeName = field.type().typeName();
// 说明是子类
if (fieldClassTypeName.contains(".") && !fieldClassFullName.contains("$")) {
int lastIndex = fieldClassFullName.lastIndexOf(".");
fieldClassFullName = fieldClassFullName.substring(0, lastIndex) + "$" + fieldClassFullName.substring(lastIndex + 1);
}
if (fieldClassFullName.endsWith("ArticleOptionInfo")) { if (fieldClassFullName.endsWith("ArticleOptionInfo")) {
fieldInfoDTO.setChildrenFieldList(getArticleOptionInfoFieldInfo()); fieldInfoDTO.setChildrenFieldList(getArticleOptionInfoFieldInfo());
} else if (isSelfClass(fieldClassFullName)) { } else if (isSelfClass(fieldClassFullName)) {
...@@ -147,7 +162,7 @@ public class GetClassCommentUtils { ...@@ -147,7 +162,7 @@ public class GetClassCommentUtils {
* @param fieldClassFullName 类全名 * @param fieldClassFullName 类全名
* @return 是否是Collection的子类 * @return 是否是Collection的子类
*/ */
private static boolean isCollection(String fieldClassFullName){ private static boolean isCollection(String fieldClassFullName) {
try { try {
return Collection.class.isAssignableFrom(Class.forName(fieldClassFullName)); return Collection.class.isAssignableFrom(Class.forName(fieldClassFullName));
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
...@@ -156,11 +171,11 @@ public class GetClassCommentUtils { ...@@ -156,11 +171,11 @@ public class GetClassCommentUtils {
} }
private static String getRealFieldComment(String comment){ private static String getFirstLineComment(String comment) {
if(!(comment.contains("@") && comment.contains("\n"))){ if (!comment.contains("\n")) {
return comment.replace("\n",""); return comment.replace("\n", "");
} }
return comment.substring(0,comment.indexOf("\n")); return comment.substring(0, comment.indexOf("\n"));
} }
/** /**
...@@ -248,6 +263,9 @@ public class GetClassCommentUtils { ...@@ -248,6 +263,9 @@ public class GetClassCommentUtils {
); );
private static DocumentInfoDTO getDocumentMainInfo(ClassDoc classDoc) { private static DocumentInfoDTO getDocumentMainInfo(ClassDoc classDoc) {
if (Objects.isNull(classDoc)) {
return null;
}
AnnotationDesc[] annotations = classDoc.annotations(); AnnotationDesc[] annotations = classDoc.annotations();
// 注释为空 return // 注释为空 return
if (ArrayUtils.isEmpty(annotations)) { if (ArrayUtils.isEmpty(annotations)) {
...@@ -257,7 +275,7 @@ public class GetClassCommentUtils { ...@@ -257,7 +275,7 @@ public class GetClassCommentUtils {
.filter(ann -> DOCUMENT_AND_NAME.contains(ann.annotationType().qualifiedTypeName())) .filter(ann -> DOCUMENT_AND_NAME.contains(ann.annotationType().qualifiedTypeName()))
.map(ann -> ann.elementValues()[0].value().toString().replaceAll("\"", "")) .map(ann -> ann.elementValues()[0].value().toString().replaceAll("\"", ""))
.findFirst(); .findFirst();
return documentNameOptional.map(s -> new DocumentInfoDTO(s, classDoc.commentText())).orElse(null); return documentNameOptional.map(s -> new DocumentInfoDTO(s, getFirstLineComment(classDoc.commentText()))).orElse(null);
} }
} }
\ No newline at end of file
...@@ -21,6 +21,11 @@ public class JarPathAndPackageMapping { ...@@ -21,6 +21,11 @@ public class JarPathAndPackageMapping {
static { static {
mappingJar("com.jiankangyouyi.cloud.basedata.api", "health-cloud-base-data-api-2.2-TK-SNAPSHOT-sources"); mappingJar("com.jiankangyouyi.cloud.basedata.api", "health-cloud-base-data-api-2.2-TK-SNAPSHOT-sources");
mappingJar("com.jiankangyouyi.cloud.assessment.api", "health-cloud-assessment-api-1.1-TK-SNAPSHOT-sources");
mappingJar("com.jiankangyouyi.cloud.data.center.api", "health-cloud-data-center-api-2.2.1.1-TK-SNAPSHOT-sources");
mappingJar("com.jiankangyouyi.cloud.food_match.api", "food-match-api-2.2.2-TK-SNAPSHOT-sources");
mappingJar("com.jiankangyouyi.cloud.motorplan.api", "health-cloud-motor-plan-api-2.2.1-TK-SNAPSHOT-sources");
mappingJar("com.jiankangyouyi.cloud.iot.api", "health-cloud-iot-data-api-1.0-TK-SNAPSHOT-sources");
} }
private static void mappingJar(String packageName, String path) { private static void mappingJar(String packageName, String path) {
......
...@@ -63,16 +63,29 @@ public class MarkdownUtils { ...@@ -63,16 +63,29 @@ public class MarkdownUtils {
} }
} }
private static List<String> CAN_NOT_IN_TITLE_NAMES = Arrays.asList(
",可以为空"
);
private static String getTitleName(String titleName) {
for (String canNotInTitleName : CAN_NOT_IN_TITLE_NAMES) {
if (titleName.contains(canNotInTitleName)) {
titleName = titleName.replace(canNotInTitleName, "");
}
}
return titleName;
}
/** /**
* 获取一个字段的内容 * 获取一个字段的内容
* *
* @param field 字段 * @param field 字段
* @return {@link String} * @return {@link String}
*/ */
public static String getOneFieldContent(DocumentInfoDTO.FieldInfoDTO field){ public static String getOneFieldContent(DocumentInfoDTO.FieldInfoDTO field) {
return CollectionUtils.isEmpty(field.getChildrenFieldList()) return CollectionUtils.isEmpty(field.getChildrenFieldList())
? String.format("|%s|%s|%s|",field.getFieldName(),field.getFieldType(),field.getDescribe()) ? String.format("|%s|%s|%s|", field.getFieldName(), field.getFieldType(), field.getDescribe())
: String.format("|%s|[%s](#%s)|[%s](#%s)|",field.getFieldName(),field.getFieldType(),field.getFiledId(),field.getDescribe(),field.getFiledId()); : String.format("|%s|[%s](#%s)|[%s](#%s)|", field.getFieldName(), field.getFieldType(), field.getFiledId(), field.getDescribe(), field.getFiledId());
} }
...@@ -125,7 +138,7 @@ public class MarkdownUtils { ...@@ -125,7 +138,7 @@ public class MarkdownUtils {
return Arrays.asList( return Arrays.asList(
getIndexDiv(field.getFiledId()), getIndexDiv(field.getFiledId()),
"", "",
String.format("%s %s (%s)", titleLevelStr, fieldDescribe, field.getFieldName()) String.format("%s %s (%s)", titleLevelStr, getTitleName(fieldDescribe), field.getFieldName())
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment