Commit f4639599 authored by 赵啸非's avatar 赵啸非

添加feign接口自动生成

parent 9d7603a0
......@@ -220,6 +220,7 @@ export default {
"genType",
"isGenExport",
"isShowControl",
"detailShow",
"genFeign",
], // 需要把number转化为string的表单字段name数组
};
......
......@@ -117,6 +117,28 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="detailShow">
<span slot="label"
>详细页面生成方式
<el-tooltip
content="生成vue详细页面"
placement="top"
>
<i class="el-icon-question"></i>
</el-tooltip>
</span>
<el-select v-model="info.detailShow">
<el-option label="独立页面" value="0" />
<el-option label="弹出窗口" value="1" />
<el-option label="抽屉" value="2" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item prop="packageName">
<span slot="label">
......
......@@ -555,7 +555,7 @@ export default {
open: false,
title: "代码预览",
data: {},
activeName: "entity.java",
activeName: "vo.java",
},
docForm: {},
appId: null,
......
package com.mortals.xhx.base.system.gentable.model;
/**
*
* Description:Gentable
* date: 2021-9-29 9:35:30
*/
public class GentableEntity extends GentableEntityExt{
* 代码生成业务实体对象
*
* @author zxfei
* @date 2022-07-04
*/
public class GentableEntity extends GentableEntityExt {
private static final long serialVersionUID = 1L;
/**
......@@ -72,6 +75,10 @@ public class GentableEntity extends GentableEntityExt{
* 生成feign接口,消费应用工程名称如(workflow-platform)
*/
private String feignAppName;
/**
* vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉)
*/
private Integer detailShow;
/**
* 是否生成对外api结构(0,否,1.是)
*/
......@@ -328,6 +335,20 @@ public class GentableEntity extends GentableEntityExt{
public void setFeignAppName(String feignAppName){
this.feignAppName = feignAppName;
}
/**
* 获取 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉)
* @return Integer
*/
public Integer getDetailShow(){
return detailShow;
}
/**
* 设置 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉)
* @param detailShow
*/
public void setDetailShow(Integer detailShow){
this.detailShow = detailShow;
}
/**
* 获取 是否生成对外api结构(0,否,1.是)
* @return Integer
......@@ -464,6 +485,7 @@ public class GentableEntity extends GentableEntityExt{
sb.append(",dividedTableType:").append(getDividedTableType());
sb.append(",genFeign:").append(getGenFeign());
sb.append(",feignAppName:").append(getFeignAppName());
sb.append(",detailShow:").append(getDetailShow());
sb.append(",genApi:").append(getGenApi());
sb.append(",isGenExport:").append(getIsGenExport());
sb.append(",isShowControl:").append(getIsShowControl());
......@@ -475,28 +497,53 @@ public class GentableEntity extends GentableEntityExt{
}
public void initAttrValue(){
this.tableName = "";
this.tableComment = "";
this.subTableName = null;
this.subTableFkName = null;
this.className = "";
this.tplCategory = "crud";
this.packageName = null;
this.moduleName = null;
this.businessName = null;
this.functionName = null;
this.functionAuthor = null;
this.cacheServiceType = null;
this.genType = 0;
this.dividedTableType = 0;
this.genFeign = 0;
this.feignAppName = "";
this.detailShow = 1;
this.genApi = null;
this.isGenExport = null;
this.isShowControl = 2;
this.isShowControl = null;
this.genPath = "/";
this.options = null;
this.remark = null;
this.appId = null;
}
}
\ No newline at end of file
package com.mortals.xhx.base.system.gentable.model;
import java.util.List;
import java.util.Date;
/**
*
* Description:Gentable
* date: 2021-9-28 10:10:15
*/
public class GentableQuery extends GentableEntity{
* 代码生成业务查询对象
*
* @author zxfei
* @date 2022-07-04
*/
public class GentableQuery extends GentableEntity {
/** 开始 ID,主键,自增长 */
private Long idStart;
......@@ -105,6 +104,18 @@ public class GentableQuery extends GentableEntity{
/** 生成feign接口,消费应用工程名称如(workflow-platform) */
private List<String> feignAppNameList;
/** 开始 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉) */
private Integer detailShowStart;
/** 结束 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉) */
private Integer detailShowEnd;
/** 增加 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉) */
private Integer detailShowIncrement;
/** vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉)列表 */
private List <Integer> detailShowList;
/** 开始 是否生成对外api结构(0,否,1.是) */
private Integer genApiStart;
......@@ -688,6 +699,70 @@ public class GentableQuery extends GentableEntity{
public void setFeignAppNameList(List<String> feignAppNameList){
this.feignAppNameList = feignAppNameList;
}
/**
* 获取 开始 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉)
* @return detailShowStart
*/
public Integer getDetailShowStart(){
return this.detailShowStart;
}
/**
* 设置 开始 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉)
* @param detailShowStart
*/
public void setDetailShowStart(Integer detailShowStart){
this.detailShowStart = detailShowStart;
}
/**
* 获取 结束 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉)
* @return $detailShowEnd
*/
public Integer getDetailShowEnd(){
return this.detailShowEnd;
}
/**
* 设置 结束 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉)
* @param detailShowEnd
*/
public void setDetailShowEnd(Integer detailShowEnd){
this.detailShowEnd = detailShowEnd;
}
/**
* 获取 增加 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉)
* @return detailShowIncrement
*/
public Integer getDetailShowIncrement(){
return this.detailShowIncrement;
}
/**
* 设置 增加 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉)
* @param detailShowIncrement
*/
public void setDetailShowIncrement(Integer detailShowIncrement){
this.detailShowIncrement = detailShowIncrement;
}
/**
* 获取 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉)
* @return detailShowList
*/
public List<Integer> getDetailShowList(){
return this.detailShowList;
}
/**
* 设置 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉)
* @param detailShowList
*/
public void setDetailShowList(List<Integer> detailShowList){
this.detailShowList = detailShowList;
}
/**
* 获取 开始 是否生成对外api结构(0,否,1.是)
* @return genApiStart
......@@ -1536,6 +1611,51 @@ public class GentableQuery extends GentableEntity{
return this;
}
/**
* 设置 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉)
* @param detailShow
*/
public GentableQuery detailShow(Integer detailShow){
setDetailShow(detailShow);
return this;
}
/**
* 设置 开始 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉)
* @param detailShowStart
*/
public GentableQuery detailShowStart(Integer detailShowStart){
this.detailShowStart = detailShowStart;
return this;
}
/**
* 设置 结束 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉)
* @param detailShowEnd
*/
public GentableQuery detailShowEnd(Integer detailShowEnd){
this.detailShowEnd = detailShowEnd;
return this;
}
/**
* 设置 增加 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉)
* @param detailShowIncrement
*/
public GentableQuery detailShowIncrement(Integer detailShowIncrement){
this.detailShowIncrement = detailShowIncrement;
return this;
}
/**
* 设置 vue生成详细页面方式(0,独立页面,1.弹出窗,2.抽屉)
* @param detailShowList
*/
public GentableQuery detailShowList(List<Integer> detailShowList){
this.detailShowList = detailShowList;
return this;
}
/**
* 设置 是否生成对外api结构(0,否,1.是)
* @param genApi
......@@ -1844,4 +1964,5 @@ public class GentableQuery extends GentableEntity{
public void setAndConditionList(List<GentableQuery> andConditionList){
this.andConditionList = andConditionList;
}
}
\ No newline at end of file
......@@ -12,7 +12,6 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.ParamDto;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.EntityUtil;
import com.mortals.xhx.base.system.gentable.dao.GentableDao;
import com.mortals.xhx.base.system.gentable.model.*;
......@@ -96,6 +95,7 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
table.setIsGenExport(0);
table.setGenFeign(0);
table.setIsShowControl(2);
table.setDetailShow(1);
table.setGenPath("/");
table.setTplCategory("crud");
table.setAppId(appId);
......@@ -171,6 +171,9 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
if (temp.contains("webForm.java.ftl")) {
continue;
}
// if (temp.contains("entity.java.ftl")||temp.contains("entityQuery.java.ftl")) {
// continue;
// }
}
if (gentableEntity.getIsShowControl() == 0) {
if (temp.contains("webBody.java.ftl")) {
......@@ -178,7 +181,21 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
}
}
if (temp.equals("menu.sql.ftl")||temp.equals("db.sql.ftl")||temp.equals("api.md.ftl")) {
if (gentableEntity.getDetailShow() == 0) {
if (temp.contains("VueDialogShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) {
continue;
}
} else if (gentableEntity.getDetailShow() == 1) {
if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) {
continue;
}
} else if (gentableEntity.getDetailShow() == 2) {
if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDialogShow.vue.ftl")) {
continue;
}
}
if (temp.equals("menu.sql.ftl") || temp.equals("db.sql.ftl") || temp.equals("api.md.ftl")) {
try {
List<GentableEntity> tableList = new ArrayList<>();
tableList.add(gentableEntity);
......@@ -353,6 +370,7 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
table.setGenFeign(0);
table.setIsGenExport(0);
table.setIsShowControl(2);
table.setDetailShow(1);
table.setGenPath("/");
table.setTplCategory("crud");
table.setCacheServiceType(CacheServiceTypeEnum.NORMAL_SERVICE.getValue());
......@@ -485,6 +503,11 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
if (temp.contains("web.java.ftl") || temp.contains("webForm.java.ftl")) {
continue;
}
// if (temp.contains("entity.java.ftl")||temp.contains("entityQuery.java.ftl")) {
// continue;
// }
} else {
if (temp.contains("webBody.java.ftl")) {
continue;
......@@ -497,6 +520,20 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
}
}
if (gentableEntity.getDetailShow() == 0) {
if (temp.contains("VueDialogShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) {
continue;
}
} else if (gentableEntity.getDetailShow() == 1) {
if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDrawerShow.vue.ftl")) {
continue;
}
} else if (gentableEntity.getDetailShow() == 2) {
if (temp.contains("webVueShow.vue.ftl") || temp.contains("VueDialogShow.vue.ftl")) {
continue;
}
}
if (temp.equals("menu.sql.ftl")) {
continue;
}
......
......@@ -65,9 +65,7 @@ public class GentableController extends BaseCRUDJsonMappingController<GentableSe
@Override
protected void doListBefore(HttpServletRequest request, HttpServletResponse response, GentableForm form, Map<String, Object> model, Context context) throws AppException {
form.getQuery().setOrderField("tableName");
super.doListBefore(request, response, form, model, context);
}
......@@ -85,15 +83,12 @@ public class GentableController extends BaseCRUDJsonMappingController<GentableSe
int code = VALUE_RESULT_SUCCESS;
try {
List<GentableEntity> list = this.service.selectDbTableList(form.getQuery());
model.put("result", list);
recordSysLog(request, busiDesc + " 【成功】");
} catch (Exception e) {
code = VALUE_RESULT_FAILURE;
this.doException(request, busiDesc, model, e);
}
ret.put(KEY_RESULT_CODE, code);
ret.put(KEY_RESULT_QUERY, form.getQuery());
ret.put(KEY_RESULT_DATA, model);
......
......@@ -90,6 +90,7 @@ public class FreeMarkerUtils {
templates.add("enum.java.ftl");
templates.add("entity.java.ftl");
templates.add("entityQuery.java.ftl");
// templates.add("entityAndQuery.java.ftl");
templates.add("dao.java.ftl");
templates.add("daoImpl.java.ftl");
templates.add("web.java.ftl");
......@@ -101,13 +102,14 @@ public class FreeMarkerUtils {
templates.add("db.sql.ftl");
templates.add("menu.sql.ftl");
templates.add("api.md.ftl");
templates.add("httpclient.test.ftl");
if (GenConstants.TPL_CRUD.equals(tplCategory)) {
templates.add("service.java.ftl");
templates.add("serviceImpl.java.ftl");
templates.add("webVueList.vue.ftl");
templates.add("VueDialogShow.vue.ftl");
// templates.add("webVueShow.vue.ftl");
templates.add("VueDrawerShow.vue.ftl");
templates.add("webVueShow.vue.ftl");
} else if (GenConstants.TPL_TREE.equals(tplCategory)) {
templates.add("entity-tree.java.ftl");
templates.add("service-tree.java.ftl");
......@@ -118,10 +120,12 @@ public class FreeMarkerUtils {
templates.add("service.java.ftl");
templates.add("serviceImpl.java.ftl");
templates.add("webVueList.vue.ftl");
//templates.add("webVueShow.vue.ftl");
templates.add("webVueShow.vue.ftl");
templates.add("VueDrawerShow.vue.ftl");
templates.add("VueDialogShow.vue.ftl");
}
//templates.add("webVueView.vue.ftl");
templates.add("webVueView.vue.ftl");
templates.add("httpclient.test.ftl");
return templates;
}
......@@ -415,7 +419,13 @@ public class FreeMarkerUtils {
fileName = StringUtils.format("{}/{}/model/vo/{}Vo.java", javaPath, businessName, className);
} else if (template.contains("entityQuery.java.ftl")) {
fileName = StringUtils.format("{}/{}/model/{}Query.java", javaPath, businessName, className);
} else if (template.contains("dao.java.ftl")) {
}
// else if (template.contains("entityAndQuery.java.ftl")) {
// fileName = StringUtils.format("{}/{}/model/{}Entity.java", javaPath, businessName, className);
// }
else if (template.contains("dao.java.ftl")) {
fileName = StringUtils.format("{}/{}/dao/{}Dao.java", javaPath, businessName, className);
} else if (template.contains("daoImpl.java.ftl")) {
fileName = StringUtils.format("{}/{}/dao/ibatis/{}DaoImpl.java", javaPath, businessName, className);
......@@ -441,7 +451,7 @@ public class FreeMarkerUtils {
fileName = StringUtils.format("{}/views/{}/list.vue", vuePath, businessNameExt);
}
/* else if (template.contains("webVueShow.vue.ftl")) {
else if (template.contains("webVueShow.vue.ftl")) {
String businessNameExt = getBusinessNameExt(genTable.getTableName());
businessNameExt = StringUtils.replace(businessNameExt, ".", "/");
fileName = StringUtils.format("{}/views/{}/show.vue", vuePath, businessNameExt);
......@@ -450,7 +460,7 @@ public class FreeMarkerUtils {
String businessNameExt = getBusinessNameExt(genTable.getTableName());
businessNameExt = StringUtils.replace(businessNameExt, ".", "/");
fileName = StringUtils.format("{}/views/{}/view.vue", vuePath, businessNameExt);
}*/
}
else if (template.contains("webVueTreeList.vue.ftl")) {
String businessNameExt = getBusinessNameExt(genTable.getTableName());
businessNameExt = StringUtils.replace(businessNameExt, ".", "/");
......@@ -463,7 +473,12 @@ public class FreeMarkerUtils {
String businessNameExt = getBusinessNameExt(genTable.getTableName());
businessNameExt = StringUtils.replace(businessNameExt, ".", "/");
fileName = StringUtils.format("{}/views/{}/dialogshow.vue", vuePath, businessNameExt);
} else if (template.contains("db.doc.ftl")) {
} else if (template.contains("VueDrawerShow.vue.ftl")) {
String businessNameExt = getBusinessNameExt(genTable.getTableName());
businessNameExt = StringUtils.replace(businessNameExt, ".", "/");
fileName = StringUtils.format("{}/views/{}/drawershow.vue", vuePath, businessNameExt);
}
else if (template.contains("db.doc.ftl")) {
fileName = StringUtils.format("doc/alldoc.docx");
} else if (template.contains("api.doc.ftl")) {
fileName = StringUtils.format("doc/api.md");
......
......@@ -360,8 +360,12 @@ dict|object|字典对象
:---|:---|:---|:-------
<#list table.columns as column>
<#if !column.isSuperColumn(column.javaField)>
<#if column.isRequired == 1>
${column.javaField}|${column.javaType}|是|${column.columnComment}
</#if>
<#else>
${column.javaField}|${column.javaType}|否|${column.columnComment}
</#if>
</#list>
**请求样例:**
......
......@@ -167,8 +167,8 @@ public class ${ClassName}Query extends ${ClassName}Entity {
}
</#if>
</#list>
<#list columns as column>
</#list>
<#list columns as column>
<#if column.javaType == "Long"||column.javaType == "Integer"||column.javaType == "BigDecimal">
/**
* 设置 ${column.columnComment}
......
......@@ -10,7 +10,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import ${packageName}.model.${ClassName}Entity;
import ${packageName}.model.${ClassName}Query;
import ${packageName}.service.${ClassName}Service;
<#if table.tplCategory=="tree">
import ${packageName}.model.${ClassName}TreeSelect;
......
......@@ -246,7 +246,7 @@
edit(row) {
this.reset()
this.query = { ${pkColumn.javaField}: row.${pkColumn.javaField} };
this.urls.currUrl =this.pageInfo.editUrl;;
this.urls.currUrl ="${RequestMapping}/edit";
this.getData();
this.pageInfo.type="edit"
this.title = "修改${functionName}";
......@@ -254,8 +254,7 @@
/** 新增 */
add(row) {
this.reset()
this.query = { ${pkColumn.javaField}: row.${pkColumn.javaField} };
this.urls.currUrl = this.pageInfo.addUrl;
this.urls.currUrl = "${RequestMapping}/add";
this.getData();
this.pageInfo.type="add"
this.title = "新增${functionName}";
......@@ -264,7 +263,7 @@
view(row) {
this.reset()
this.query = { ${pkColumn.javaField}: row.${pkColumn.javaField} };
this.urls.currUrl =this.pageInfo.viewUrl;;
this.urls.currUrl ="${RequestMapping}/view";
this.getData();
this.pageInfo.type="view"
this.title = "${functionName}详细";
......
......@@ -63,17 +63,38 @@
</div>
</el-dialog>
</#if>
<#if table.detailShow==1 >
<dialog-show ref="dialogform" @ok="getData" />
<#elseif table.detailShow==2>
<drawer-show ref="drawerform" @ok="getData" />
<#else>
<dialog-show ref="dialogform" @ok="getData" />
</#if>
</div>
</template>
<script>
/** 表单弹出框模式需引入 */
<#if table.detailShow==1 >
import dialogShow from "./dialogshow";
<#elseif table.detailShow==2>
import drawerShow from "./drawershow";
<#else >
import dialogShow from "./dialogshow";
</#if>
import table from "@/assets/mixins/table";
export default {
name: "${ClassName}",
components: {dialogShow },
name: "${ClassName}List",
components: {
<#if table.detailShow==1 >
dialogShow
<#elseif table.detailShow==2>
drawerShow
<#else >
dialogShow
</#if>},
mixins: [table],
created() {
},
......@@ -114,9 +135,10 @@
doExport() {
this.isExport = true;
this.$download("/${RequestMapping}/exportExcel", {
"idList": this.selection,
<#list columns as column>
<#if column.isQuery == 1 >
'query.${column.javaField}': this.$route.query['query.${column.javaField}']<#sep>,
'${column.javaField}': this.$route.query['${column.javaField}']<#sep>,
</#if>
</#list>
}, { type: "excel" }).then(() => this.isExport = false).catch(error => {
......@@ -144,7 +166,7 @@
);
},
</#if>
<#if table.detailShow==1 >
/** 重写新增方法 */
toAdd(row) {
this.$refs.dialogform.add(row);
......@@ -152,12 +174,38 @@
/** 重写编辑方法 */
toEdit(row) {
this.$refs.dialogform.edit(row);
},
/** 重写查看方法 */
// toView(row) {
// this.$refs.dialogform.view(row);
// },
toView(row) {
this.$refs.dialogform.view(row);
},
<#elseif table.detailShow==2>
/** 重写新增方法 */
toAdd(row) {
this.$refs.drawerform.add(row);
},
/** 重写编辑方法 */
toEdit(row) {
this.$refs.drawerform.edit(row);
},
/** 重写查看方法 */
toView(row) {
this.$refs.drawerform.view(row);
},
<#else>
/** 重写新增方法 */
toAdd(row) {
this.$refs.dialogform.add(row);
},
/** 重写编辑方法 */
toEdit(row) {
this.$refs.dialogform.edit(row);
},
/** 重写查看方法 */
toView(row) {
this.$refs.dialogform.view(row);
},
</#if>
},
data() {
......@@ -227,12 +275,13 @@
],
columns: [
{type: "selection", width: 60},
{type: "index",label: "序号",width: 50},
<#list columns as column>
<#assign comment=column.subComment(column.columnComment) />
<#if column.columnName != pkColumn.columnName && !column.isSuperColumn(column.javaField)&& column.isList==1>
<#if column.columnName != pkColumn.columnName && column.isList==1>
<#if column.javaType == "Long">
{label: "${comment}", prop: "${column.javaField}", formatter: this.formatterString},
{label: "${comment}", prop: "${column.javaField}", formatter: this.formatter},
</#if>
<#if column.javaType == "String">
{label: "${comment}", prop: "${column.javaField}"},
......
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