parent
7bffb3fd73
commit
f580b86af3
File diff suppressed because one or more lines are too long
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package org.opsli.modulars.generator.template.wrapper;
|
||||
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.opsli.api.base.warpper.ApiWrapper;
|
||||
import org.opsli.common.annotation.validator.Validator;
|
||||
import org.opsli.common.annotation.validator.ValidatorLenMax;
|
||||
import org.opsli.common.enums.ValidatorType;
|
||||
import org.opsli.plugins.excel.annotation.ExcelInfo;
|
||||
|
||||
/**
|
||||
* 代码模板 Model
|
||||
*
|
||||
* @author 周鹏程
|
||||
* @date 2021-05-27 14:33:49
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class GenTemplateCopyModel extends ApiWrapper {
|
||||
|
||||
|
||||
/** 模板名称 */
|
||||
@ApiModelProperty(value = "模板名称")
|
||||
@ExcelProperty(value = "模板名称", order = 1)
|
||||
@ExcelInfo
|
||||
@Validator({
|
||||
ValidatorType.IS_GENERAL_WITH_CHINESE,
|
||||
ValidatorType.IS_NOT_NULL
|
||||
})
|
||||
@ValidatorLenMax(100)
|
||||
private String tempName;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.plugins.generator.enums;
|
||||
|
||||
/**
|
||||
* 代码类型
|
||||
*
|
||||
* @author Mybatis-plus
|
||||
* @date 2020-09-22 11:17
|
||||
*/
|
||||
public enum CodeType {
|
||||
|
||||
/** 代码类型 */
|
||||
BACKEND("0", "后端"),
|
||||
FRONTEND("1", "前端"),
|
||||
;
|
||||
|
||||
private final String type;
|
||||
private final String desc;
|
||||
|
||||
public static CodeType getCodeType(String type) {
|
||||
CodeType[] var = values();
|
||||
for (CodeType codeType : var) {
|
||||
if (codeType.type.equalsIgnoreCase(type)) {
|
||||
return codeType;
|
||||
}
|
||||
}
|
||||
return BACKEND;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return this.desc;
|
||||
}
|
||||
|
||||
// ================
|
||||
|
||||
CodeType(final String type, final String desc) {
|
||||
this.type = type;
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package org.opsli.plugins.generator.factory;
|
||||
|
||||
|
||||
/**
|
||||
* 代码生成器工厂
|
||||
*
|
||||
* @author Parker
|
||||
* @date 2021年6月1日19:10:36
|
||||
*/
|
||||
public final class GeneratorFactory {
|
||||
|
||||
public static String getJavaHeadAnnotation(){
|
||||
return "/**\n"+
|
||||
" * Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com\n"+
|
||||
" * <p>\n"+
|
||||
" * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n"+
|
||||
" * use this file except in compliance with the License. You may obtain a copy of\n"+
|
||||
" * the License at\n"+
|
||||
" * <p>\n"+
|
||||
" * http://www.apache.org/licenses/LICENSE-2.0\n"+
|
||||
" * <p>\n"+
|
||||
" * Unless required by applicable law or agreed to in writing, software\n"+
|
||||
" * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n"+
|
||||
" * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n"+
|
||||
" * License for the specific language governing permissions and limitations under\n"+
|
||||
" * the License.\n"+
|
||||
" */\n";
|
||||
}
|
||||
|
||||
|
||||
// ========================
|
||||
|
||||
public GeneratorFactory(){}
|
||||
}
|
@ -1,334 +0,0 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.plugins.generator.strategy.create.backend;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.jfinal.kit.Kv;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.opsli.common.utils.WrapperUtil;
|
||||
import org.opsli.common.utils.ZipUtils;
|
||||
import org.opsli.plugins.generator.strategy.create.CodeBuilder;
|
||||
import org.opsli.plugins.generator.utils.EnjoyUtil;
|
||||
import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Java代码构建器
|
||||
*
|
||||
* @author parker
|
||||
* @date 2020-09-13 19:36
|
||||
*/
|
||||
public enum JavaCodeBuilder {
|
||||
|
||||
/** 实例对象 */
|
||||
INSTANCE;
|
||||
|
||||
/**
|
||||
* 生成Entity
|
||||
* @param builderModelTmp Build 模型
|
||||
* @param dataStr 数据字符串
|
||||
* @return Map
|
||||
*/
|
||||
public Map<String,String> createEntity(GenBuilderModel builderModelTmp, String dataStr){
|
||||
GenBuilderModel builderModel =
|
||||
WrapperUtil.transformInstance(builderModelTmp, GenBuilderModel.class, true);
|
||||
|
||||
String codeStr = EnjoyUtil.render("/backend/entity/TemplateEntity.html",
|
||||
this.createKv(builderModel)
|
||||
);
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.BACKEND_PATH)
|
||||
.append("/").append(builderModel.getPackageName().replaceAll("\\.","/"))
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append("entity").append("/");
|
||||
if(StringUtils.isNotBlank(builderModel.getSubModuleName())){
|
||||
path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.BACKEND_PATH)
|
||||
.append("/").append(builderModel.getPackageName().replaceAll("\\.","/"))
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append(builderModel.getSubModuleName())
|
||||
.append("/").append("entity").append("/");
|
||||
}
|
||||
Map<String,String> entityMap = new HashMap<>();
|
||||
entityMap.put(ZipUtils.FILE_PATH, path.toString());
|
||||
entityMap.put(ZipUtils.FILE_NAME,
|
||||
builderModel.getModel().getTableHumpName()+".java");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成Mapper
|
||||
* @param builderModelTmp Build 模型
|
||||
* @param dataStr 数据字符串
|
||||
* @return Map
|
||||
*/
|
||||
public Map<String,String> createMapper(GenBuilderModel builderModelTmp, String dataStr){
|
||||
GenBuilderModel builderModel =
|
||||
WrapperUtil.transformInstance(builderModelTmp, GenBuilderModel.class, true);
|
||||
String codeStr = EnjoyUtil.render("/backend/mapper/TemplateMapper.html",
|
||||
this.createKv(builderModel)
|
||||
);
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.BACKEND_PATH)
|
||||
.append("/").append(builderModel.getPackageName().replaceAll("\\.","/"))
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append("mapper").append("/");
|
||||
if(StringUtils.isNotBlank(builderModel.getSubModuleName())){
|
||||
path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.BACKEND_PATH)
|
||||
.append("/").append(builderModel.getPackageName().replaceAll("\\.","/"))
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append(builderModel.getSubModuleName())
|
||||
.append("/").append("mapper").append("/");
|
||||
}
|
||||
Map<String,String> entityMap = new HashMap<>();
|
||||
entityMap.put(ZipUtils.FILE_PATH, path.toString());
|
||||
entityMap.put(ZipUtils.FILE_NAME,
|
||||
builderModel.getModel().getTableHumpName()+"Mapper.java");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成MapperXML
|
||||
* @param builderModelTmp Build 模型
|
||||
* @param dataStr 数据字符串
|
||||
* @return Map
|
||||
*/
|
||||
public Map<String,String> createMapperXML(GenBuilderModel builderModelTmp, String dataStr){
|
||||
GenBuilderModel builderModel =
|
||||
WrapperUtil.transformInstance(builderModelTmp, GenBuilderModel.class, true);
|
||||
String codeStr = EnjoyUtil.render("/backend/mapper/xml/TemplateMapperXML.html",
|
||||
this.createKv(builderModel)
|
||||
);
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.BACKEND_PATH)
|
||||
.append("/").append(builderModel.getPackageName().replaceAll("\\.","/"))
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append("mapper")
|
||||
.append("/").append("xml").append("/");
|
||||
if(StringUtils.isNotBlank(builderModel.getSubModuleName())){
|
||||
path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.BACKEND_PATH)
|
||||
.append("/").append(builderModel.getPackageName().replaceAll("\\.","/"))
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append(builderModel.getSubModuleName())
|
||||
.append("/").append("mapper")
|
||||
.append("/").append("xml").append("/");
|
||||
}
|
||||
Map<String,String> entityMap = new HashMap<>();
|
||||
entityMap.put(ZipUtils.FILE_PATH, path.toString());
|
||||
entityMap.put(ZipUtils.FILE_NAME,
|
||||
builderModel.getModel().getTableHumpName()+"Mapper.xml");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成Service
|
||||
* @param builderModelTmp Build 模型
|
||||
* @param dataStr 数据字符串
|
||||
* @return Map
|
||||
*/
|
||||
public Map<String,String> createService(GenBuilderModel builderModelTmp, String dataStr){
|
||||
GenBuilderModel builderModel =
|
||||
WrapperUtil.transformInstance(builderModelTmp, GenBuilderModel.class, true);
|
||||
String codeStr = EnjoyUtil.render("/backend/service/TemplateService.html",
|
||||
this.createKv(builderModel)
|
||||
);
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.BACKEND_PATH)
|
||||
.append("/").append(builderModel.getPackageName().replaceAll("\\.","/"))
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append("service").append("/");
|
||||
if(StringUtils.isNotBlank(builderModel.getSubModuleName())){
|
||||
path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.BACKEND_PATH)
|
||||
.append("/").append(builderModel.getPackageName().replaceAll("\\.","/"))
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append(builderModel.getSubModuleName())
|
||||
.append("/").append("service").append("/");
|
||||
}
|
||||
Map<String,String> entityMap = new HashMap<>();
|
||||
entityMap.put(ZipUtils.FILE_PATH, path.toString());
|
||||
entityMap.put(ZipUtils.FILE_NAME,
|
||||
"I"+builderModel.getModel().getTableHumpName()+"Service.java");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成 Service Impl
|
||||
* @param builderModelTmp Build 模型
|
||||
* @param dataStr 数据字符串
|
||||
* @return Map
|
||||
*/
|
||||
public Map<String,String> createServiceImpl(GenBuilderModel builderModelTmp, String dataStr){
|
||||
GenBuilderModel builderModel =
|
||||
WrapperUtil.transformInstance(builderModelTmp, GenBuilderModel.class, true);
|
||||
String codeStr = EnjoyUtil.render("/backend/service/impl/TemplateServiceImpl.html",
|
||||
this.createKv(builderModel)
|
||||
);
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.BACKEND_PATH)
|
||||
.append("/").append(builderModel.getPackageName().replaceAll("\\.","/"))
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append("service")
|
||||
.append("/").append("impl").append("/");
|
||||
if(StringUtils.isNotBlank(builderModel.getSubModuleName())){
|
||||
path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.BACKEND_PATH)
|
||||
.append("/").append(builderModel.getPackageName().replaceAll("\\.","/"))
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append(builderModel.getSubModuleName())
|
||||
.append("/").append("service")
|
||||
.append("/").append("impl").append("/");
|
||||
}
|
||||
Map<String,String> entityMap = new HashMap<>();
|
||||
entityMap.put(ZipUtils.FILE_PATH, path.toString());
|
||||
entityMap.put(ZipUtils.FILE_NAME,
|
||||
builderModel.getModel().getTableHumpName()+"ServiceImpl.java");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 Web
|
||||
* @param builderModelTmp Build 模型
|
||||
* @param dataStr 数据字符串
|
||||
* @return Map
|
||||
*/
|
||||
public Map<String,String> createWeb(GenBuilderModel builderModelTmp, String dataStr){
|
||||
GenBuilderModel builderModel =
|
||||
WrapperUtil.transformInstance(builderModelTmp, GenBuilderModel.class, true);
|
||||
String codeStr = EnjoyUtil.render("/backend/web/TemplateRestController.html",
|
||||
this.createKv(builderModel)
|
||||
);
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.BACKEND_PATH)
|
||||
.append("/").append(builderModel.getPackageName().replaceAll("\\.","/"))
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append("web").append("/");
|
||||
if(StringUtils.isNotBlank(builderModel.getSubModuleName())){
|
||||
path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.BACKEND_PATH)
|
||||
.append("/").append(builderModel.getPackageName().replaceAll("\\.","/"))
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append(builderModel.getSubModuleName())
|
||||
.append("/").append("web").append("/");
|
||||
}
|
||||
Map<String,String> entityMap = new HashMap<>();
|
||||
entityMap.put(ZipUtils.FILE_PATH, path.toString());
|
||||
entityMap.put(ZipUtils.FILE_NAME,
|
||||
builderModel.getModel().getTableHumpName()+"RestController.java");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成Model
|
||||
* @param builderModelTmp Build 模型
|
||||
* @param dataStr 数据字符串
|
||||
* @return Map
|
||||
*/
|
||||
public Map<String,String> createModel(GenBuilderModel builderModelTmp, String dataStr){
|
||||
GenBuilderModel builderModel =
|
||||
WrapperUtil.transformInstance(builderModelTmp, GenBuilderModel.class, true);
|
||||
|
||||
String codeStr = EnjoyUtil.render("/backend/model/TemplateModel.html",
|
||||
this.createKv(builderModel)
|
||||
);
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.BACKEND_PATH)
|
||||
.append("/").append(CodeBuilder.API_PATH.replaceAll("\\.","/"))
|
||||
.append("/").append("wrapper")
|
||||
.append("/").append(builderModel.getModuleName()).append("/");
|
||||
if(StringUtils.isNotBlank(builderModel.getSubModuleName())){
|
||||
path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.BACKEND_PATH)
|
||||
.append("/").append(CodeBuilder.API_PATH.replaceAll("\\.","/"))
|
||||
.append("/").append("wrapper")
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append(builderModel.getSubModuleName()).append("/");
|
||||
}
|
||||
Map<String,String> entityMap = new HashMap<>();
|
||||
entityMap.put(ZipUtils.FILE_PATH, path.toString());
|
||||
entityMap.put(ZipUtils.FILE_NAME,
|
||||
builderModel.getModel().getTableHumpName()+"Model.java");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成RestApi
|
||||
* @param builderModelTmp Build 模型
|
||||
* @param dataStr 数据字符串
|
||||
* @return Map
|
||||
*/
|
||||
public Map<String,String> createRestApi(GenBuilderModel builderModelTmp, String dataStr){
|
||||
GenBuilderModel builderModel =
|
||||
WrapperUtil.transformInstance(builderModelTmp, GenBuilderModel.class, true);
|
||||
String codeStr = EnjoyUtil.render("/backend/api/TemplateRestApi.html",
|
||||
this.createKv(builderModel)
|
||||
);
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.BACKEND_PATH)
|
||||
.append("/").append(CodeBuilder.API_PATH.replaceAll("\\.","/"))
|
||||
.append("/").append("web")
|
||||
.append("/").append(builderModel.getModuleName()).append("/");
|
||||
if(StringUtils.isNotBlank(builderModel.getSubModuleName())){
|
||||
path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.BACKEND_PATH)
|
||||
.append("/").append(CodeBuilder.API_PATH.replaceAll("\\.","/"))
|
||||
.append("/").append("web")
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append(builderModel.getSubModuleName()).append("/");
|
||||
}
|
||||
Map<String,String> entityMap = new HashMap<>();
|
||||
entityMap.put(ZipUtils.FILE_PATH, path.toString());
|
||||
entityMap.put(ZipUtils.FILE_NAME,
|
||||
builderModel.getModel().getTableHumpName()+"RestApi.java");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 Kv
|
||||
* @param builderModel Build 模型
|
||||
* @return Kv
|
||||
*/
|
||||
private Kv createKv(GenBuilderModel builderModel){
|
||||
return Kv.by("data", builderModel)
|
||||
.set("currTime", DateUtil.now())
|
||||
.set("apiPath", CodeBuilder.API_PATH);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,201 +0,0 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.plugins.generator.strategy.create.foreend;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.jfinal.kit.Kv;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.opsli.common.utils.Props;
|
||||
import org.opsli.common.utils.WrapperUtil;
|
||||
import org.opsli.common.utils.ZipUtils;
|
||||
import org.opsli.plugins.generator.strategy.create.CodeBuilder;
|
||||
import org.opsli.plugins.generator.utils.EnjoyUtil;
|
||||
import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Vue代码构建器
|
||||
*
|
||||
* @author parker
|
||||
* @date 2020-09-13 19:36
|
||||
*/
|
||||
public enum VueCodeBuilder {
|
||||
|
||||
/** 实例对象 */
|
||||
INSTANCE;
|
||||
|
||||
/** 验证方法前缀 */
|
||||
private static final String VALIDATE_PREFIX = "validate_";
|
||||
/** 虚拟根路径 */
|
||||
private static final String BASE_API_PATH;
|
||||
static {
|
||||
Props props = new Props("application.yaml");
|
||||
BASE_API_PATH = props.getStr("server.servlet.api.path.global-prefix","/api/v1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 Index
|
||||
* @param builderModelTmp Build 模型
|
||||
* @param dataStr 数据字符串
|
||||
* @return Map
|
||||
*/
|
||||
public Map<String,String> createIndex(GenBuilderModel builderModelTmp, String dataStr){
|
||||
GenBuilderModel builderModel =
|
||||
WrapperUtil.transformInstance(builderModelTmp, GenBuilderModel.class, true);
|
||||
|
||||
String codeStr = EnjoyUtil.render("/foreend/index/TemplateIndex.html",
|
||||
this.createKv(builderModel)
|
||||
);
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.FOREEND_PATH)
|
||||
.append("/").append("vue")
|
||||
.append("/").append("views").append("/").append("modules")
|
||||
.append("/").append(builderModel.getModuleName()).append("/");
|
||||
if(StringUtils.isNotBlank(builderModel.getSubModuleName())){
|
||||
path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.FOREEND_PATH)
|
||||
.append("/").append("vue")
|
||||
.append("/").append("views").append("/").append("modules")
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append(builderModel.getSubModuleName()).append("/");
|
||||
}
|
||||
Map<String,String> entityMap = new HashMap<>();
|
||||
entityMap.put(ZipUtils.FILE_PATH, path.toString());
|
||||
entityMap.put(ZipUtils.FILE_NAME, "index.vue");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成 Edit
|
||||
* @param builderModelTmp Build 模型
|
||||
* @param dataStr 数据字符串
|
||||
* @return Map
|
||||
*/
|
||||
public Map<String,String> createEdit(GenBuilderModel builderModelTmp, String dataStr){
|
||||
GenBuilderModel builderModel =
|
||||
WrapperUtil.transformInstance(builderModelTmp, GenBuilderModel.class, true);
|
||||
|
||||
String codeStr = EnjoyUtil.render("/foreend/components/TemplateEdit.html",
|
||||
this.createKv(builderModel));
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.FOREEND_PATH)
|
||||
.append("/").append("vue")
|
||||
.append("/").append("views").append("/").append("modules")
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append("components").append("/");
|
||||
if(StringUtils.isNotBlank(builderModel.getSubModuleName())){
|
||||
path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.FOREEND_PATH)
|
||||
.append("/").append("vue")
|
||||
.append("/").append("views").append("/").append("modules")
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append(builderModel.getSubModuleName())
|
||||
.append("/").append("components").append("/");
|
||||
}
|
||||
Map<String,String> entityMap = new HashMap<>();
|
||||
entityMap.put(ZipUtils.FILE_PATH, path.toString());
|
||||
entityMap.put(ZipUtils.FILE_NAME, builderModel.getModel().getTableHumpName()+"ManagementEdit.vue");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成 Import
|
||||
* @param builderModelTmp Build 模型
|
||||
* @param dataStr 数据字符串
|
||||
* @return Map
|
||||
*/
|
||||
public Map<String,String> createImport(GenBuilderModel builderModelTmp, String dataStr){
|
||||
GenBuilderModel builderModel =
|
||||
WrapperUtil.transformInstance(builderModelTmp, GenBuilderModel.class, true);
|
||||
|
||||
String codeStr = EnjoyUtil.render("/foreend/components/TemplateImport.html",
|
||||
this.createKv(builderModel)
|
||||
);
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.FOREEND_PATH)
|
||||
.append("/").append("vue")
|
||||
.append("/").append("views").append("/").append("modules")
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append("components").append("/");
|
||||
if(StringUtils.isNotBlank(builderModel.getSubModuleName())){
|
||||
path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.FOREEND_PATH)
|
||||
.append("/").append("vue")
|
||||
.append("/").append("views").append("/").append("modules")
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append(builderModel.getSubModuleName())
|
||||
.append("/").append("components").append("/");
|
||||
}
|
||||
Map<String,String> entityMap = new HashMap<>();
|
||||
entityMap.put(ZipUtils.FILE_PATH, path.toString());
|
||||
entityMap.put(ZipUtils.FILE_NAME, builderModel.getModel().getTableHumpName()+"ManagementImport.vue");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 Api
|
||||
* @param builderModelTmp Build 模型
|
||||
* @param dataStr 数据字符串
|
||||
* @return Map
|
||||
*/
|
||||
public Map<String,String> createApi(GenBuilderModel builderModelTmp, String dataStr){
|
||||
GenBuilderModel builderModel =
|
||||
WrapperUtil.transformInstance(builderModelTmp, GenBuilderModel.class, true);
|
||||
|
||||
String codeStr = EnjoyUtil.render("/foreend/api/TemplateApi.html",
|
||||
this.createKv(builderModel)
|
||||
.set("apiPath", BASE_API_PATH)
|
||||
);
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.FOREEND_PATH)
|
||||
.append("/").append("vue").append("/").append("api")
|
||||
.append("/").append(builderModel.getModuleName()).append("/");
|
||||
if(StringUtils.isNotBlank(builderModel.getSubModuleName())){
|
||||
path = new StringBuilder();
|
||||
path.append(CodeBuilder.BASE_PATH).append(dataStr).append(CodeBuilder.FOREEND_PATH)
|
||||
.append("/").append("vue").append("/").append("api")
|
||||
.append("/").append(builderModel.getModuleName())
|
||||
.append("/").append(builderModel.getSubModuleName()).append("/");
|
||||
}
|
||||
Map<String,String> entityMap = new HashMap<>();
|
||||
entityMap.put(ZipUtils.FILE_PATH, path.toString());
|
||||
entityMap.put(ZipUtils.FILE_NAME, builderModel.getModel().getTableHumpName()+"Management.js");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 Kv
|
||||
* @param builderModel Build 模型
|
||||
* @return Kv
|
||||
*/
|
||||
private Kv createKv(GenBuilderModel builderModel){
|
||||
return Kv.by("data", builderModel)
|
||||
.set("currTime", DateUtil.now());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package org.opsli.plugins.generator.strategy.create.readme;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.jfinal.kit.Kv;
|
||||
import org.opsli.common.utils.WrapperUtil;
|
||||
import org.opsli.common.utils.ZipUtils;
|
||||
import org.opsli.plugins.generator.strategy.create.CodeBuilder;
|
||||
import org.opsli.plugins.generator.utils.EnjoyUtil;
|
||||
import org.opsli.modulars.generator.logs.wrapper.GenBuilderModel;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ReadMe 构建器
|
||||
*
|
||||
* @author parker
|
||||
* @date 2020-09-13 19:36
|
||||
*/
|
||||
public enum ReadMeBuilder {
|
||||
|
||||
/** 实例对象 */
|
||||
INSTANCE;
|
||||
|
||||
/**
|
||||
* 生成 ReadMe
|
||||
* @param builderModelTmp Build 模型
|
||||
* @param dataStr 数据字符串
|
||||
* @return Map
|
||||
*/
|
||||
public Map<String,String> createReadMe(GenBuilderModel builderModelTmp, String dataStr){
|
||||
GenBuilderModel builderModel =
|
||||
WrapperUtil.transformInstance(builderModelTmp, GenBuilderModel.class, true);
|
||||
|
||||
String codeStr = EnjoyUtil.render("/readme/TemplateReadMe.html",
|
||||
this.createKv(builderModel)
|
||||
);
|
||||
|
||||
Map<String,String> entityMap = new HashMap<>();
|
||||
entityMap.put(ZipUtils.FILE_PATH, CodeBuilder.BASE_PATH + dataStr + "/");
|
||||
entityMap.put(ZipUtils.FILE_NAME, "README.md");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 Kv
|
||||
* @param builderModel Build 模型
|
||||
* @return Kv
|
||||
*/
|
||||
private Kv createKv(GenBuilderModel builderModel){
|
||||
return Kv.by("data", builderModel)
|
||||
.set("currTime", DateUtil.now());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
package #(data.packageName+"."+data.moduleName+"."+data.subModuleName).entity;
|
||||
#else
|
||||
package #(data.packageName+"."+data.moduleName).entity;
|
||||
#end
|
||||
|
||||
#for(pkg : data.model.entityPkgList)
|
||||
import #(pkg);
|
||||
#end
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.opsli.core.base.entity.BaseEntity;
|
||||
|
||||
/**
|
||||
* #(data.codeTitle) Entity
|
||||
*
|
||||
* @author #(data.authorName)
|
||||
* @date #(currTime)
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class #(data.model.tableHumpName) extends BaseEntity {
|
||||
|
||||
|
||||
#for(column : data.model.columnList)
|
||||
### 不等于 删除字段 和 不等于 租户字段放入上边
|
||||
#if(column.fieldHumpName != "deleted" && column.fieldHumpName != "tenantId")
|
||||
/** #(column.fieldComments) */
|
||||
#if(!column.izNotNull)
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
#end
|
||||
private #(column.javaType) #(column.fieldHumpName);
|
||||
|
||||
#end
|
||||
#end
|
||||
|
||||
// ========================================
|
||||
|
||||
### 专门处理 删除字段 和 租户字段
|
||||
#for(column : data.model.columnList)
|
||||
#if(column.fieldHumpName == "deleted")
|
||||
/** 逻辑删除字段 */
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
#else if(column.fieldHumpName == "tenantId")
|
||||
/** 多租户字段 */
|
||||
private String tenantId;
|
||||
#end
|
||||
|
||||
#end
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
package #(data.packageName+"."+data.moduleName+"."+data.subModuleName).mapper;
|
||||
#else
|
||||
package #(data.packageName+"."+data.moduleName).mapper;
|
||||
#end
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
import #(data.packageName+"."+data.moduleName+"."+data.subModuleName).entity.#(data.model.tableHumpName);
|
||||
#else
|
||||
import #(data.packageName+"."+data.moduleName).entity.#(data.model.tableHumpName);
|
||||
#end
|
||||
|
||||
/**
|
||||
* #(data.codeTitle) Mapper
|
||||
*
|
||||
* @author #(data.authorName)
|
||||
* @date #(currTime)
|
||||
*/
|
||||
@Mapper
|
||||
public interface #(data.model.tableHumpName)Mapper extends BaseMapper<#(data.model.tableHumpName)> {
|
||||
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
<mapper namespace="#(data.packageName+'.'+data.moduleName+'.'+data.subModuleName).mapper.#(data.model.tableHumpName)Mapper">
|
||||
#else
|
||||
<mapper namespace="#(data.packageName+'.'+data.moduleName).mapper.#(data.model.tableHumpName)Mapper">
|
||||
#end
|
||||
|
||||
|
||||
</mapper>
|
@ -1,89 +0,0 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
package #(apiPath).wrapper.#(data.moduleName+"."+data.subModuleName);
|
||||
#else
|
||||
package #(apiPath).wrapper.#(data.moduleName);
|
||||
#end
|
||||
|
||||
#for(pkg : data.model.entityPkgList)
|
||||
import #(pkg);
|
||||
#end
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import #(apiPath).base.warpper.ApiWrapper;
|
||||
import org.opsli.common.annotation.validator.Validator;
|
||||
import org.opsli.common.annotation.validator.ValidatorLenMax;
|
||||
import org.opsli.common.annotation.validator.ValidatorLenMin;
|
||||
import org.opsli.common.enums.ValidatorType;
|
||||
import org.opsli.plugins.excel.annotation.ExcelInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* #(data.codeTitle) Model
|
||||
*
|
||||
* @author #(data.authorName)
|
||||
* @date #(currTime)
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class #(data.model.tableHumpName)Model extends ApiWrapper {
|
||||
|
||||
#for(column : data.model.columnList)
|
||||
### 不等于 删除字段 和 不等于 租户字段放入上边
|
||||
#if(column.fieldHumpName != "deleted" && column.fieldHumpName != "tenantId")
|
||||
/** #(column.fieldComments) */
|
||||
@ApiModelProperty(value = "#(column.fieldComments)")
|
||||
@ExcelProperty(value = "#(column.fieldComments)", order = #(column.sort))
|
||||
#if(column.dictTypeCode != null && column.dictTypeCode != "")
|
||||
@ExcelInfo( dictType = "#(column.dictTypeCode)" )
|
||||
#else
|
||||
@ExcelInfo
|
||||
#end
|
||||
#if(column.validateTypeAndCommaList != null && column.validateTypeAndCommaList.size() > 0)
|
||||
@Validator({
|
||||
#for(typeAndComma : column.validateTypeAndCommaList)
|
||||
ValidatorType.#(typeAndComma)
|
||||
#end
|
||||
})
|
||||
#end
|
||||
#if(column.fieldLength != null && column.fieldLength > 0)
|
||||
#if(column.fieldPrecision != null && column.fieldPrecision > 0)
|
||||
@ValidatorLenMax(#(column.fieldLength+column.fieldPrecision))
|
||||
#else
|
||||
@ValidatorLenMax(#(column.fieldLength))
|
||||
#end
|
||||
#end
|
||||
### 日期处理
|
||||
#if(column.javaType == "Date")
|
||||
#if(column.showType == "4")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
#else
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
#end
|
||||
#end
|
||||
private #(column.javaType) #(column.fieldHumpName);
|
||||
|
||||
#end
|
||||
#end
|
||||
|
||||
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
package #(data.packageName+"."+data.moduleName+"."+data.subModuleName).service;
|
||||
#else
|
||||
package #(data.packageName+"."+data.moduleName).service;
|
||||
#end
|
||||
|
||||
import org.opsli.core.base.service.interfaces.CrudServiceInterface;
|
||||
|
||||
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
import #(data.packageName+"."+data.moduleName+"."+data.subModuleName).entity.#(data.model.tableHumpName);
|
||||
import #(apiPath).wrapper.#(data.moduleName+"."+data.subModuleName).#(data.model.tableHumpName)Model;
|
||||
#else
|
||||
import #(data.packageName+"."+data.moduleName).entity.#(data.model.tableHumpName);
|
||||
import #(apiPath).wrapper.#(data.moduleName).#(data.model.tableHumpName)Model;
|
||||
#end
|
||||
|
||||
/**
|
||||
* #(data.codeTitle) Service
|
||||
*
|
||||
* @author #(data.authorName)
|
||||
* @date #(currTime)
|
||||
*/
|
||||
public interface I#(data.model.tableHumpName)Service extends CrudServiceInterface<#(data.model.tableHumpName), #(data.model.tableHumpName)Model> {
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/**
|
||||
* Copyright 2020 OPSLI 快速开发平台 https://www.opsli.com
|
||||
* <p>
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
package #(data.packageName+"."+data.moduleName+"."+data.subModuleName).service.impl;
|
||||
#else
|
||||
package #(data.packageName+"."+data.moduleName).service.impl;
|
||||
#end
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.opsli.core.base.service.impl.CrudServiceImpl;
|
||||
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
import #(data.packageName+"."+data.moduleName+"."+data.subModuleName).entity.#(data.model.tableHumpName);
|
||||
import #(apiPath).wrapper.#(data.moduleName+"."+data.subModuleName).#(data.model.tableHumpName)Model;
|
||||
import #(data.packageName+"."+data.moduleName+"."+data.subModuleName).service.I#(data.model.tableHumpName)Service;
|
||||
import #(data.packageName+"."+data.moduleName+"."+data.subModuleName).mapper.#(data.model.tableHumpName)Mapper;
|
||||
#else
|
||||
import #(data.packageName+"."+data.moduleName).entity.#(data.model.tableHumpName);
|
||||
import #(apiPath).wrapper.#(data.moduleName).#(data.model.tableHumpName)Model;
|
||||
import #(data.packageName+"."+data.moduleName).service.I#(data.model.tableHumpName)Service;
|
||||
import #(data.packageName+"."+data.moduleName).mapper.#(data.model.tableHumpName)Mapper;
|
||||
#end
|
||||
|
||||
|
||||
/**
|
||||
* #(data.codeTitle) Service Impl
|
||||
*
|
||||
* @author #(data.authorName)
|
||||
* @date #(currTime)
|
||||
*/
|
||||
@Service
|
||||
public class #(data.model.tableHumpName)ServiceImpl extends CrudServiceImpl<#(data.model.tableHumpName)Mapper, #(data.model.tableHumpName), #(data.model.tableHumpName)Model>
|
||||
implements I#(data.model.tableHumpName)Service {
|
||||
|
||||
@Autowired(required = false)
|
||||
private #(data.model.tableHumpName)Mapper mapper;
|
||||
|
||||
}
|
@ -1,118 +0,0 @@
|
||||
import request from "@/utils/request";
|
||||
import {downloadFileByData} from "@/utils/download";
|
||||
|
||||
export function getList(data) {
|
||||
return request({
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
url: "#(apiPath)/#(data.moduleName)/#(data.subModuleName)/findPage",
|
||||
#else
|
||||
url: "#(apiPath)/#(data.moduleName)/findPage",
|
||||
#end
|
||||
method: "get",
|
||||
params: data,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export function doInsert(data) {
|
||||
return request({
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
url: "#(apiPath)/#(data.moduleName)/#(data.subModuleName)/insert",
|
||||
#else
|
||||
url: "#(apiPath)/#(data.moduleName)/insert",
|
||||
#end
|
||||
method: "post",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
export function doUpdate(data) {
|
||||
return request({
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
url: "#(apiPath)/#(data.moduleName)/#(data.subModuleName)/update",
|
||||
#else
|
||||
url: "#(apiPath)/#(data.moduleName)/update",
|
||||
#end
|
||||
method: "post",
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
export function doDelete(data) {
|
||||
return request({
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
url: "#(apiPath)/#(data.moduleName)/#(data.subModuleName)/del",
|
||||
#else
|
||||
url: "#(apiPath)/#(data.moduleName)/del",
|
||||
#end
|
||||
method: "post",
|
||||
params: data,
|
||||
});
|
||||
}
|
||||
|
||||
export function doDeleteAll(data) {
|
||||
return request({
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
url: "#(apiPath)/#(data.moduleName)/#(data.subModuleName)/delAll",
|
||||
#else
|
||||
url: "#(apiPath)/#(data.moduleName)/delAll",
|
||||
#end
|
||||
method: "post",
|
||||
params: data,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出Excel 目前只支持一层参数传递
|
||||
* @param data
|
||||
* @returns file
|
||||
*/
|
||||
export function doExportExcel(data) {
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
let requestURL = "#(apiPath)/#(data.moduleName)/#(data.subModuleName)/exportExcel";
|
||||
#else
|
||||
let requestURL = "#(apiPath)/#(data.moduleName)/exportExcel";
|
||||
#end
|
||||
// 下载文件
|
||||
downloadFileByData(requestURL, data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下载模版
|
||||
* @returns file
|
||||
*/
|
||||
export function doDownloadTemplate() {
|
||||
let data = {};
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
let requestURL = "#(apiPath)/#(data.moduleName)/#(data.subModuleName)/importExcel/template";
|
||||
#else
|
||||
let requestURL = "#(apiPath)/#(data.moduleName)/importExcel/template";
|
||||
#end
|
||||
// 下载文件
|
||||
downloadFileByData(requestURL, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入Excel
|
||||
* @returns file
|
||||
*/
|
||||
export function doImportExcel(data) {
|
||||
return request({
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
url: "#(apiPath)/#(data.moduleName)/#(data.subModuleName)/importExcel",
|
||||
#else
|
||||
url: "#(apiPath)/#(data.moduleName)/importExcel",
|
||||
#end
|
||||
method: "post",
|
||||
// 最长超时时间 3 分钟
|
||||
timeout: 180000,
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
},
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,187 +0,0 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="title"
|
||||
:visible.sync="dialogFormVisible"
|
||||
:close-on-click-modal="false"
|
||||
width="800px"
|
||||
@close="close"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="105px">
|
||||
<el-row :gutter="10" >
|
||||
#for(column : data.model.formList)
|
||||
### 文本框
|
||||
#if(column.showType == "0")
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
|
||||
<el-form-item label="#(column.fieldComments)" prop="#(column.fieldHumpName)">
|
||||
<el-input v-model="form.#(column.fieldHumpName)" autocomplete="off"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
### 文本域
|
||||
#else if(column.showType == "1")
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
|
||||
<el-form-item label="#(column.fieldComments)" prop="#(column.fieldHumpName)">
|
||||
<el-input type="textarea" v-model="form.#(column.fieldHumpName)" autocomplete="off"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
### 字典
|
||||
#else if(column.showType == "2")
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
|
||||
<el-form-item label="#(column.fieldComments)" prop="#(column.fieldHumpName)">
|
||||
<el-select v-model="form.#(column.fieldHumpName)" clearable
|
||||
placeholder="请选择" style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in dict.#(column.dictTypeCode)"
|
||||
:key="item.dictValue"
|
||||
:label="item.dictName"
|
||||
:value="item.dictValue"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
### 日期时间
|
||||
#else if(column.showType == "3")
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
|
||||
<el-form-item label="#(column.fieldComments)" prop="#(column.fieldHumpName)">
|
||||
<el-date-picker
|
||||
v-model="form.#(column.fieldHumpName)"
|
||||
type="datetime"
|
||||
placeholder="选择#(column.fieldComments)"
|
||||
style="width: 100%"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
### 日期
|
||||
#else if(column.showType == "4")
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
|
||||
<el-form-item label="#(column.fieldComments)" prop="#(column.fieldHumpName)">
|
||||
<el-date-picker
|
||||
v-model="form.#(column.fieldHumpName)"
|
||||
type="date"
|
||||
placeholder="选择#(column.fieldComments)"
|
||||
style="width: 100%"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
#end
|
||||
|
||||
#end
|
||||
</el-row>
|
||||
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="close">取 消</el-button>
|
||||
<el-button type="primary" @click="save">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
import { doInsert, doUpdate } from "@/api/#(data.moduleName)/#(data.subModuleName)/#(data.model.tableHumpName)Management";
|
||||
#else
|
||||
import { doInsert, doUpdate } from "@/api/#(data.moduleName)/#(data.model.tableHumpName)Management";
|
||||
#end
|
||||
import { isNull } from "@/utils/validate";
|
||||
import { formateDate } from "@/utils/format";
|
||||
import { validatorRule } from "@/utils/validateRlue";
|
||||
|
||||
export default {
|
||||
name: "#(data.model.tableHumpName)ManagementEdit",
|
||||
data() {
|
||||
|
||||
return {
|
||||
form: {
|
||||
// 设置默认值
|
||||
version: 0
|
||||
},
|
||||
dict: {},
|
||||
rules: {
|
||||
#for(columnList : data.model.formList)
|
||||
#for(column : columnList)
|
||||
#if(column.validateTypeList != null && column.validateTypeList.size() > 0)
|
||||
#(column.fieldHumpName): [
|
||||
#for(typeNotComma : column.validateTypeList)
|
||||
#if(typeNotComma == "IS_NOT_NULL")
|
||||
{ required: true, trigger: "blur", message: "#(column.fieldComments)非空" },
|
||||
#end
|
||||
#end
|
||||
#for(typeNotComma : column.validateTypeList)
|
||||
#if(typeNotComma != "IS_NOT_NULL")
|
||||
{ required: false, trigger: "blur", validator: validatorRule.#(typeNotComma) },
|
||||
#end
|
||||
#end
|
||||
],
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
},
|
||||
title: "",
|
||||
dialogFormVisible: false,
|
||||
};
|
||||
},
|
||||
created() {
|
||||
|
||||
},
|
||||
mounted() {
|
||||
// 加载字典值
|
||||
#for(column : data.model.columnList)
|
||||
#if(column.dictTypeCode != null && column.dictTypeCode != "")
|
||||
this.dict.#(column.dictTypeCode) = this.$getDictList("#(column.dictTypeCode)");
|
||||
#end
|
||||
#end
|
||||
},
|
||||
methods: {
|
||||
showEdit(row) {
|
||||
if (!row) {
|
||||
this.title = "添加";
|
||||
} else {
|
||||
this.title = "编辑";
|
||||
this.form = Object.assign({}, row);
|
||||
}
|
||||
this.dialogFormVisible = true;
|
||||
},
|
||||
close() {
|
||||
this.dialogFormVisible = false;
|
||||
this.$refs["form"].resetFields();
|
||||
this.form = this.$options.data().form;
|
||||
},
|
||||
save() {
|
||||
this.$refs["form"].validate(async (valid) => {
|
||||
if (valid) {
|
||||
// 处理数据
|
||||
this.handlerFormData(this.form);
|
||||
|
||||
// 修改
|
||||
if (!isNull(this.form.id)) {
|
||||
const { success, msg } = await doUpdate(this.form);
|
||||
if(success){
|
||||
this.$baseMessage(msg, "success");
|
||||
}
|
||||
} else {
|
||||
const { success, msg } = await doInsert(this.form);
|
||||
if(success){
|
||||
this.$baseMessage(msg, "success");
|
||||
}
|
||||
}
|
||||
|
||||
await this.$emit("fetchData");
|
||||
this.close();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
// 处理 form数据
|
||||
handlerFormData(formData){
|
||||
if(!isNull(formData)){
|
||||
for(let key in formData){
|
||||
// 对于时间类进行处理
|
||||
if("[object Date]" === Object.prototype.toString.call(formData[key])){
|
||||
formData[key] = formateDate(formData[key], 'yyyy-MM-dd hh:mm:ss');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
@ -1,543 +0,0 @@
|
||||
<template>
|
||||
<div class="tenantManagement-container">
|
||||
|
||||
<el-collapse-transition>
|
||||
<div class="more-query" v-show="this.moreQueryFlag">
|
||||
<!-- 更多查找 -->
|
||||
<vab-query-form>
|
||||
<vab-query-form-left-panel :span="24">
|
||||
<el-form :inline="true" :model="queryForm" @submit.native.prevent>
|
||||
#for(column : data.model.moreQueryList)
|
||||
|
||||
### 字典
|
||||
#if(column.showType == "2")
|
||||
<el-form-item>
|
||||
<el-select v-model="queryForm.#(column.fieldHumpName+'_'+column.queryType)" placeholder="请选择#(column.fieldComments)" clearable style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in dict.#(column.dictTypeCode)"
|
||||
:key="item.dictValue"
|
||||
:label="item.dictName"
|
||||
:value="item.dictValue"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#else if(column.showType == "3")
|
||||
### 时间
|
||||
<el-form-item>
|
||||
<el-date-picker
|
||||
v-model="#(column.fieldHumpName)DatePicker"
|
||||
type="datetimerange"
|
||||
:picker-options="pickerOptions"
|
||||
range-separator="至"
|
||||
start-placeholder="开始#(column.fieldComments)"
|
||||
end-placeholder="结束#(column.fieldComments)"
|
||||
align="right">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
#else if(column.showType == "4")
|
||||
### 日期
|
||||
<el-form-item>
|
||||
<el-date-picker
|
||||
v-model="#(column.fieldHumpName)DatePicker"
|
||||
type="daterange"
|
||||
align="right"
|
||||
range-separator="至"
|
||||
start-placeholder="开始#(column.fieldComments)"
|
||||
end-placeholder="结束#(column.fieldComments)"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
#else
|
||||
#if(column.queryType == "EQ" || column.queryType == "LIKE")
|
||||
<el-form-item>
|
||||
<el-input
|
||||
v-model.trim="queryForm.#(column.fieldHumpName)_#(column.queryType)"
|
||||
placeholder="请输入#(column.fieldComments)"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
#else if(column.queryType == "RANGE")
|
||||
<el-col :span="12" >
|
||||
<el-form-item style="text-align: center">
|
||||
<el-input
|
||||
v-model.trim="queryForm.#(column.fieldHumpName)_BEGIN"
|
||||
placeholder="#(column.fieldComments)开始"
|
||||
clearable
|
||||
style="float: left;width: calc(50% - 6px)"
|
||||
/>
|
||||
<div style="float:left;width: 12px">-</div>
|
||||
<el-input
|
||||
v-model.trim="queryForm.#(column.fieldHumpName)_END"
|
||||
placeholder="#(column.fieldComments)结束"
|
||||
clearable
|
||||
style="float: right;width: calc(50% - 6px)"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
|
||||
|
||||
</el-form>
|
||||
</vab-query-form-left-panel>
|
||||
|
||||
</vab-query-form>
|
||||
<el-divider></el-divider>
|
||||
</div>
|
||||
</el-collapse-transition>
|
||||
|
||||
<!-- 主要操作 -->
|
||||
<vab-query-form>
|
||||
<vab-query-form-left-panel :span="10">
|
||||
<el-button
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
v-if="$perms('#(data.moduleName.toLowerCase())_#(data.subModuleName.toLowerCase())_insert')"
|
||||
#else
|
||||
v-if="$perms('#(data.moduleName.toLowerCase())_insert')"
|
||||
#end
|
||||
icon="el-icon-plus"
|
||||
type="primary"
|
||||
@click="handleInsert"
|
||||
> 添加 </el-button>
|
||||
|
||||
<el-button
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
v-if="$perms('#(data.moduleName.toLowerCase())_#(data.subModuleName.toLowerCase())_import')"
|
||||
#else
|
||||
v-if="$perms('#(data.moduleName.toLowerCase())_import')"
|
||||
#end
|
||||
icon="el-icon-upload2"
|
||||
type="warning"
|
||||
@click="handleImportExcel"
|
||||
> 导入 </el-button>
|
||||
|
||||
<el-button
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
v-if="$perms('#(data.moduleName.toLowerCase())_#(data.subModuleName.toLowerCase())_export')"
|
||||
#else
|
||||
v-if="$perms('#(data.moduleName.toLowerCase())_export')"
|
||||
#end
|
||||
icon="el-icon-download"
|
||||
type="warning"
|
||||
@click="handleExportExcel"
|
||||
> 导出 </el-button>
|
||||
|
||||
<el-button
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
v-if="$perms('#(data.moduleName.toLowerCase())_#(data.subModuleName.toLowerCase())_delete')"
|
||||
#else
|
||||
v-if="$perms('#(data.moduleName.toLowerCase())_delete')"
|
||||
#end
|
||||
:disabled="!selectRows.length > 0"
|
||||
icon="el-icon-delete"
|
||||
type="danger"
|
||||
@click="handleDelete"
|
||||
> 批量删除 </el-button>
|
||||
|
||||
</vab-query-form-left-panel>
|
||||
<vab-query-form-right-panel :span="14">
|
||||
<el-form :inline="true" :model="queryForm" @submit.native.prevent>
|
||||
### 代码生成器 简要只展示2个
|
||||
#for(column : data.model.briefQueryList)
|
||||
|
||||
### 字典
|
||||
#if(column.showType == "2")
|
||||
<el-form-item>
|
||||
<el-select v-model="queryForm.#(column.fieldHumpName+'_'+column.queryType)" placeholder="请选择#(column.fieldComments)" clearable style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in dict.#(column.dictTypeCode)"
|
||||
:key="item.dictValue"
|
||||
:label="item.dictName"
|
||||
:value="item.dictValue"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#else if(column.showType == "3")
|
||||
### 时间
|
||||
<el-form-item>
|
||||
<el-date-picker
|
||||
v-model="#(column.fieldHumpName)DatePicker"
|
||||
type="datetimerange"
|
||||
:picker-options="pickerOptions"
|
||||
range-separator="至"
|
||||
start-placeholder="开始#(column.fieldComments)"
|
||||
end-placeholder="结束#(column.fieldComments)"
|
||||
align="right">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
#else if(column.showType == "4")
|
||||
### 日期
|
||||
<el-form-item>
|
||||
<el-date-picker
|
||||
v-model="#(column.fieldHumpName)DatePicker"
|
||||
type="daterange"
|
||||
align="right"
|
||||
range-separator="至"
|
||||
start-placeholder="开始#(column.fieldComments)"
|
||||
end-placeholder="结束#(column.fieldComments)"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
#else
|
||||
#if(column.queryType == "EQ" || column.queryType == "LIKE")
|
||||
<el-form-item>
|
||||
<el-input
|
||||
v-model.trim="queryForm.#(column.fieldHumpName)_#(column.queryType)"
|
||||
placeholder="请输入#(column.fieldComments)"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
#else if(column.queryType == "RANGE")
|
||||
<el-col :span="12" >
|
||||
<el-form-item style="text-align: center">
|
||||
<el-input
|
||||
v-model.trim="queryForm.#(column.fieldHumpName)_BEGIN"
|
||||
placeholder="#(column.fieldComments)开始"
|
||||
clearable
|
||||
style="float: left;width: calc(50% - 6px)"
|
||||
/>
|
||||
<div style="float:left;width: 12px">-</div>
|
||||
<el-input
|
||||
v-model.trim="queryForm.#(column.fieldHumpName)_END"
|
||||
placeholder="#(column.fieldComments)结束"
|
||||
clearable
|
||||
style="float: right;width: calc(50% - 6px)"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
|
||||
<el-form-item>
|
||||
<el-button icon="el-icon-search" type="primary" @click="queryData">
|
||||
查询
|
||||
</el-button>
|
||||
|
||||
#if(data.model.moreQueryList != null && data.model.moreQueryList.size() > 0)
|
||||
<el-button icon="el-icon-search" @click="moreQuery">
|
||||
更多
|
||||
</el-button>
|
||||
#end
|
||||
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</vab-query-form-right-panel>
|
||||
</vab-query-form>
|
||||
|
||||
<el-table
|
||||
v-loading="listLoading"
|
||||
:data="list"
|
||||
:element-loading-text="elementLoadingText"
|
||||
@selection-change="setSelectRows"
|
||||
>
|
||||
<el-table-column show-overflow-tooltip type="selection"></el-table-column>
|
||||
|
||||
<el-table-column show-overflow-tooltip label="序号" width="95">
|
||||
<template slot-scope="scope">
|
||||
{{(queryForm.pageNo - 1) * queryForm.pageSize + scope.$index + 1}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
#for(column : data.model.columnList)
|
||||
### 字典
|
||||
#if(column.showType == "2" && column.izShowList == "1")
|
||||
<el-table-column
|
||||
show-overflow-tooltip
|
||||
prop="#(column.fieldHumpName)"
|
||||
label="#(column.fieldComments)"
|
||||
>
|
||||
|
||||
<template slot-scope="scope">
|
||||
<span>
|
||||
{{ $getDictNameByValue('#(column.dictTypeCode)', scope.row.#(column.fieldHumpName)) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
</el-table-column>
|
||||
|
||||
#else
|
||||
#if(column.izShowList == "1")
|
||||
<el-table-column
|
||||
show-overflow-tooltip
|
||||
prop="#(column.fieldHumpName)"
|
||||
label="#(column.fieldComments)"
|
||||
></el-table-column>
|
||||
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
|
||||
<el-table-column
|
||||
show-overflow-tooltip
|
||||
label="操作"
|
||||
width="200"
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
v-if="$perms('#(data.moduleName.toLowerCase())_#(data.subModuleName.toLowerCase())_update') || $perms('#(data.moduleName.toLowerCase())_#(data.subModuleName.toLowerCase())_delete')"
|
||||
#else
|
||||
v-if="$perms('#(data.moduleName.toLowerCase())_update') || $perms('#(data.moduleName.toLowerCase())_delete')"
|
||||
#end
|
||||
>
|
||||
<template v-slot="scope">
|
||||
<el-button
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
v-if="$perms('#(data.moduleName.toLowerCase())_#(data.subModuleName.toLowerCase())_update')"
|
||||
#else
|
||||
v-if="$perms('#(data.moduleName.toLowerCase())_update')"
|
||||
#end
|
||||
type="text"
|
||||
@click="handleUpdate(scope.row)"
|
||||
> 编辑 </el-button>
|
||||
<el-button
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
v-if="$perms('#(data.moduleName.toLowerCase())_#(data.subModuleName.toLowerCase())_delete')"
|
||||
#else
|
||||
v-if="$perms('#(data.moduleName.toLowerCase())_delete')"
|
||||
#end
|
||||
type="text"
|
||||
@click="handleDelete(scope.row)"
|
||||
> 删除 </el-button>
|
||||
</template>
|
||||
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
background
|
||||
:current-page="queryForm.pageNo"
|
||||
:page-size="queryForm.pageSize"
|
||||
:layout="layout"
|
||||
:total="total"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
></el-pagination>
|
||||
|
||||
<edit ref="edit" @fetchData="fetchData"></edit>
|
||||
<import ref="import" @fetchData="fetchData" ></import>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
import { getList, doDelete, doDeleteAll, doExportExcel } from "@/api/#(data.moduleName)/#(data.subModuleName)/#(data.model.tableHumpName)Management";
|
||||
#else
|
||||
import { getList, doDelete, doDeleteAll, doExportExcel } from "@/api/#(data.moduleName)/#(data.model.tableHumpName)Management";
|
||||
#end
|
||||
import Edit from "./components/#(data.model.tableHumpName)ManagementEdit";
|
||||
import Import from "./components/#(data.model.tableHumpName)ManagementImport";
|
||||
|
||||
import { vueButtonClickBan } from "@/utils";
|
||||
import { isNotNull } from "@/utils/valiargs";
|
||||
import { formateDate } from "@/utils/format";
|
||||
|
||||
export default {
|
||||
name: "#(data.model.tableHumpName)Management",
|
||||
components: { Edit, Import },
|
||||
data() {
|
||||
return {
|
||||
list: null,
|
||||
listLoading: true,
|
||||
layout: "total, prev, pager, next, sizes, jumper",
|
||||
total: 0,
|
||||
selectRows: "",
|
||||
elementLoadingText: "正在加载...",
|
||||
moreQueryFlag: false,
|
||||
queryForm: {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
### 代码生成器 简要2个
|
||||
#for(column : data.model.briefQueryList)
|
||||
### 字典
|
||||
#if(column.showType == "2")
|
||||
#(column.fieldHumpName)_EQ: "",
|
||||
#else if(column.showType == "3" || column.showType == "4")
|
||||
### 日期
|
||||
#(column.fieldHumpName)_BEGIN: "",
|
||||
#(column.fieldHumpName)_END: "",
|
||||
#else
|
||||
#if(column.queryType == "EQ" || column.queryType == "LIKE")
|
||||
#(column.fieldHumpName)_#(column.queryType): "",
|
||||
#else if(column.queryType == "RANGE")
|
||||
#(column.fieldHumpName)_BEGIN: "",
|
||||
#(column.fieldHumpName)_END: "",
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
### 代码生成器 更多
|
||||
#for(column : data.model.moreQueryList)
|
||||
### 字典
|
||||
#if(column.showType == "2")
|
||||
#(column.fieldHumpName)_EQ: "",
|
||||
#else if(column.showType == "3" || column.showType == "4")
|
||||
### 日期
|
||||
#(column.fieldHumpName)_BEGIN: "",
|
||||
#(column.fieldHumpName)_END: "",
|
||||
#else
|
||||
#if(column.queryType == "EQ" || column.queryType == "LIKE")
|
||||
#(column.fieldHumpName)_#(column.queryType): "",
|
||||
#else if(column.queryType == "RANGE")
|
||||
#(column.fieldHumpName)_BEGIN: "",
|
||||
#(column.fieldHumpName)_END: "",
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
},
|
||||
### 代码生成器 简要2个
|
||||
#for(column : data.model.briefQueryList)
|
||||
### 日期
|
||||
#if(column.showType == "3" || column.showType == "4")
|
||||
#(column.fieldHumpName)DatePicker: [],
|
||||
#end
|
||||
#end
|
||||
### 代码生成器 更多
|
||||
#for(column : data.model.moreQueryList)
|
||||
### 日期
|
||||
#if(column.showType == "3" || column.showType == "4")
|
||||
#(column.fieldHumpName)DatePicker: [],
|
||||
#end
|
||||
#end
|
||||
dict:{},
|
||||
pickerOptions: {
|
||||
shortcuts: [{
|
||||
text: '最近一周',
|
||||
onClick(picker) {
|
||||
const end = new Date();
|
||||
const start = new Date();
|
||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
|
||||
picker.$emit('pick', [start, end]);
|
||||
}
|
||||
}, {
|
||||
text: '最近一个月',
|
||||
onClick(picker) {
|
||||
const end = new Date();
|
||||
const start = new Date();
|
||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
|
||||
picker.$emit('pick', [start, end]);
|
||||
}
|
||||
}, {
|
||||
text: '最近三个月',
|
||||
onClick(picker) {
|
||||
const end = new Date();
|
||||
const start = new Date();
|
||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
|
||||
picker.$emit('pick', [start, end]);
|
||||
}
|
||||
}]
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.fetchData();
|
||||
},
|
||||
mounted() {
|
||||
#for(column : data.model.columnList)
|
||||
#if(column.dictTypeCode != null && column.dictTypeCode != "")
|
||||
this.dict.#(column.dictTypeCode) = this.$getDictList("#(column.dictTypeCode)");
|
||||
#end
|
||||
#end
|
||||
},
|
||||
methods: {
|
||||
setSelectRows(val) {
|
||||
this.selectRows = val;
|
||||
},
|
||||
handleInsert(row) {
|
||||
this.$refs["edit"].showEdit();
|
||||
},
|
||||
handleUpdate(row) {
|
||||
if (row.id) {
|
||||
this.$refs["edit"].showEdit(row);
|
||||
}
|
||||
},
|
||||
handleDelete(row) {
|
||||
if (row.id) {
|
||||
this.$baseConfirm("你确定要删除当前项吗", null, async () => {
|
||||
const { msg } = await doDelete({ id: row.id });
|
||||
this.$baseMessage(msg, "success");
|
||||
await this.fetchData();
|
||||
});
|
||||
} else {
|
||||
if (this.selectRows.length > 0) {
|
||||
const ids = this.selectRows.map((item) => item.id).join();
|
||||
this.$baseConfirm("你确定要删除选中项吗", null, async () => {
|
||||
const { msg } = await doDeleteAll({ ids });
|
||||
this.$baseMessage(msg, "success");
|
||||
await this.fetchData();
|
||||
});
|
||||
} else {
|
||||
this.$baseMessage("未选中任何行", "error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
// 导出excel
|
||||
handleExportExcel(el){
|
||||
// 导出按钮防抖处理 默认限制为10秒
|
||||
vueButtonClickBan(el, 10);
|
||||
|
||||
// 执行导出
|
||||
doExportExcel(this.queryForm);
|
||||
},
|
||||
// 导入excel
|
||||
handleImportExcel(){
|
||||
this.$refs["import"].show();
|
||||
},
|
||||
|
||||
|
||||
handleSizeChange(val) {
|
||||
this.queryForm.pageSize = val;
|
||||
this.fetchData();
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.queryForm.pageNo = val;
|
||||
this.fetchData();
|
||||
},
|
||||
moreQuery(){
|
||||
this.moreQueryFlag = !this.moreQueryFlag;
|
||||
},
|
||||
queryData() {
|
||||
### 代码生成器 简要2个
|
||||
#for(column : data.model.briefQueryList)
|
||||
### 日期
|
||||
#if(column.showType == "3" || column.showType == "4")
|
||||
if(isNotNull(this.#(column.fieldHumpName)DatePicker) && this.#(column.fieldHumpName)DatePicker.length === 2){
|
||||
this.queryForm.#(column.fieldHumpName)_BEGIN =
|
||||
this.#(column.fieldHumpName)DatePicker.length === 0 ? "" : formateDate(this.#(column.fieldHumpName)DatePicker[0], 'yyyy-MM-dd hh:mm:ss');
|
||||
this.queryForm.#(column.fieldHumpName)_END =
|
||||
this.#(column.fieldHumpName)DatePicker.length === 0 ? "" : formateDate(this.#(column.fieldHumpName)DatePicker[1], 'yyyy-MM-dd hh:mm:ss');
|
||||
}else{
|
||||
this.queryForm.#(column.fieldHumpName)_BEGIN = "";
|
||||
this.queryForm.#(column.fieldHumpName)_END = "";
|
||||
} #end
|
||||
#end
|
||||
### 代码生成器 更多
|
||||
#for(column : data.model.moreQueryList)
|
||||
### 日期
|
||||
#if(column.showType == "3" || column.showType == "4")
|
||||
if(isNotNull(this.#(column.fieldHumpName)DatePicker) && this.#(column.fieldHumpName)DatePicker.length === 2){
|
||||
this.queryForm.#(column.fieldHumpName)_BEGIN =
|
||||
this.#(column.fieldHumpName)DatePicker.length === 0 ? "" : formateDate(this.#(column.fieldHumpName)DatePicker[0], 'yyyy-MM-dd hh:mm:ss');
|
||||
this.queryForm.#(column.fieldHumpName)_END =
|
||||
this.#(column.fieldHumpName)DatePicker.length === 0 ? "" : formateDate(this.#(column.fieldHumpName)DatePicker[1], 'yyyy-MM-dd hh:mm:ss');
|
||||
}else{
|
||||
this.queryForm.#(column.fieldHumpName)_BEGIN = "";
|
||||
this.queryForm.#(column.fieldHumpName)_END = "";
|
||||
}
|
||||
#end
|
||||
#end
|
||||
|
||||
this.queryForm.pageNo = 1;
|
||||
this.fetchData();
|
||||
},
|
||||
async fetchData() {
|
||||
this.listLoading = true;
|
||||
const { data } = await getList(this.queryForm);
|
||||
if(isNotNull(data)){
|
||||
this.list = data.rows;
|
||||
this.total = data.total;
|
||||
setTimeout(() => {
|
||||
this.listLoading = false;
|
||||
}, 300);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
Loading…
Reference in new issue