parent
f05582e655
commit
fd93c0cec9
@ -0,0 +1,10 @@
|
||||
package org.opsli.api;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.api
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-11-21 15:15
|
||||
* @Description: 标示文件 请勿删除
|
||||
*/
|
||||
public interface ApiFlag { }
|
@ -0,0 +1,91 @@
|
||||
/**
|
||||
* 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.api.wrapper.gentest.user;
|
||||
|
||||
import java.util.Date;
|
||||
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.validation.ValidationArgs;
|
||||
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
|
||||
import org.opsli.common.enums.ValiArgsType;
|
||||
import org.opsli.plugins.excel.annotation.ExcelInfo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.api.wrapper.gentest.user
|
||||
* @Author: 周鹏程
|
||||
* @CreateTime: 2020-11-22 12:12:05
|
||||
* @Description: 某系统用户
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class TestUserModel extends ApiWrapper {
|
||||
|
||||
/** 名称 */
|
||||
@ApiModelProperty(value = "名称")
|
||||
@ExcelProperty(value = "名称", order = 1)
|
||||
@ExcelInfo
|
||||
// 验证器
|
||||
@ValidationArgs({ValiArgsType.IS_GENERAL_WITH_CHINESE})
|
||||
@ValidationArgsLenMax(50)
|
||||
private String name;
|
||||
|
||||
/** 金钱 */
|
||||
@ApiModelProperty(value = "金钱")
|
||||
@ExcelProperty(value = "金钱", order = 2)
|
||||
@ExcelInfo
|
||||
// 验证器
|
||||
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_MONEY})
|
||||
@ValidationArgsLenMax(8)
|
||||
private Double money;
|
||||
|
||||
/** 年龄 */
|
||||
@ApiModelProperty(value = "年龄")
|
||||
@ExcelProperty(value = "年龄", order = 3)
|
||||
@ExcelInfo
|
||||
// 验证器
|
||||
@ValidationArgs({ValiArgsType.IS_NOT_NULL, ValiArgsType.IS_NUMBER})
|
||||
@ValidationArgsLenMax(5)
|
||||
private Integer age;
|
||||
|
||||
/** 生日 */
|
||||
@ApiModelProperty(value = "生日")
|
||||
@ExcelProperty(value = "生日", order = 4)
|
||||
@ExcelInfo
|
||||
// 验证器
|
||||
@ValidationArgs({ValiArgsType.IS_NOT_NULL, })
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date birth;
|
||||
|
||||
/** 是否启用 */
|
||||
@ApiModelProperty(value = "是否启用")
|
||||
@ExcelProperty(value = "是否启用", order = 5)
|
||||
@ExcelInfo( dictType = "no_yes" )
|
||||
// 验证器
|
||||
@ValidationArgs({ValiArgsType.IS_NOT_NULL, })
|
||||
@ValidationArgsLenMax(1)
|
||||
private Character izUsable;
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package org.opsli.common.utils;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* @author Parker
|
||||
* @date 2020-01-07
|
||||
* <p>
|
||||
* 文件流转压缩包工具类
|
||||
*/
|
||||
public class ZipUtils {
|
||||
/**
|
||||
* 缓存区大小
|
||||
*/
|
||||
private static final int BUFFER_SIZE = 2 * 1024;
|
||||
|
||||
public static final String FILE_PATH = "path";
|
||||
public static final String FILE_NAME = "name";
|
||||
public static final String FILE_DATA = "data";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 压缩核心方法
|
||||
*/
|
||||
private static void compress(ZipOutputStream zos, String path, String name, String data) throws Exception {
|
||||
byte[] buf = new byte[BUFFER_SIZE];
|
||||
zos.putNextEntry(new ZipEntry(path + name));
|
||||
int len;
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8));
|
||||
while ((len = in.read(buf)) != -1) {
|
||||
zos.write(buf, 0, len);
|
||||
}
|
||||
zos.closeEntry();
|
||||
in.close();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 文本直接转zip压缩成文件
|
||||
*
|
||||
* @param list -> map -> path 路径; name 文件名; data 具体文本内容;
|
||||
* @param out 传入输出流
|
||||
* @throws RuntimeException 抛出异常
|
||||
*/
|
||||
public static void toZip(List<Map<String, String>> list, OutputStream out) throws RuntimeException {
|
||||
ZipOutputStream zos = null;
|
||||
try {
|
||||
zos = new ZipOutputStream(out, StandardCharsets.UTF_8);
|
||||
for (Map<String, String> map : list) {
|
||||
String path = map.get("path");
|
||||
String name = map.get("name");
|
||||
String data = map.get("data");
|
||||
compress(zos, path, name, data);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("zip error from ZipUtils", e);
|
||||
} finally {
|
||||
if (zos != null) {
|
||||
try {
|
||||
zos.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
List<Map<String, String>> list = new ArrayList<>();
|
||||
OutputStream outputStream = new FileOutputStream(new File("/Users/system/Documents/脚本/opsli/test.zip"));
|
||||
Map<String,String> m1 = new HashMap(){{put("path","/f1/f2/f3/");put("name","1.txt");put("data","abcdefg");}};
|
||||
Map<String,String> m2 = new HashMap(){{put("path","/f1/f2/f3/f4/");put("name","2.txt");put("data","abcdefg");}};
|
||||
Map<String,String> m3 = new HashMap(){{put("path","");put("name","3.txt");put("data","abcdefg");}};
|
||||
|
||||
list.add(m1);
|
||||
list.add(m2);
|
||||
list.add(m3);
|
||||
toZip(list, outputStream);
|
||||
if (outputStream != null) {
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,159 @@
|
||||
/**
|
||||
* 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.core.creater.strategy.create;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import com.jfinal.kit.Kv;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.opsli.api.ApiFlag;
|
||||
import org.opsli.common.enums.DictType;
|
||||
import org.opsli.common.enums.ValiArgsType;
|
||||
import org.opsli.common.utils.HumpUtil;
|
||||
import org.opsli.common.utils.Props;
|
||||
import org.opsli.common.utils.ZipUtils;
|
||||
import org.opsli.core.creater.strategy.create.backend.JavaCodeBuilder;
|
||||
import org.opsli.core.creater.strategy.create.foreend.VueCodeBuilder;
|
||||
import org.opsli.core.creater.strategy.create.readme.ReadMeBuilder;
|
||||
import org.opsli.core.creater.utils.EnjoyUtil;
|
||||
import org.opsli.modulars.creater.column.wrapper.CreaterTableColumnModel;
|
||||
import org.opsli.modulars.creater.createrlogs.wrapper.CreaterBuilderModel;
|
||||
import org.opsli.modulars.creater.table.wrapper.CreaterTableAndColumnModel;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.core.creater.strategy.create.backend
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-11-20 17:30
|
||||
* @Description: Java代码构建器
|
||||
*/
|
||||
public enum CodeBuilder {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
/** 排除字段 */
|
||||
private static final List<String> EXCLUDE_FIELDS;
|
||||
|
||||
public static final String API_PATH;
|
||||
public static final String FILE_NAME = "OPSLI-CodeCreate";
|
||||
public static final String BASE_PATH = "/代码生成-";
|
||||
public static final String BACKEND_PATH = "/后端";
|
||||
public static final String FOREEND_PATH = "/前端";
|
||||
|
||||
|
||||
static {
|
||||
Props props = new Props("creater.yaml");
|
||||
EXCLUDE_FIELDS = props.getList("opsli.exclude-fields");
|
||||
API_PATH = ApiFlag.class.getPackage().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建
|
||||
*/
|
||||
public void build(CreaterBuilderModel builderModel, HttpServletResponse response){
|
||||
if(builderModel == null) return;
|
||||
|
||||
String dataStr = DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss");
|
||||
|
||||
CreaterTableAndColumnModel model = builderModel.getModel();
|
||||
|
||||
|
||||
// 数据库表名转驼峰
|
||||
model.setTableName(
|
||||
HumpUtil.captureName(
|
||||
HumpUtil.underlineToHump(
|
||||
model.getTableName()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
List<CreaterTableColumnModel> columnList = model.getColumnList();
|
||||
//遍历排除字段
|
||||
columnList.removeIf(tmp -> EXCLUDE_FIELDS.contains(tmp.getFieldName()));
|
||||
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
OutputStream out = this.getOutputStream(response, dataStr);
|
||||
try {
|
||||
if(out != null){
|
||||
List<Map<String, String>> fileList = new ArrayList<>();
|
||||
// 处理后端代码 ====================
|
||||
// entity
|
||||
fileList.add(JavaCodeBuilder.INSTANCE.createEntity(builderModel, dataStr));
|
||||
// mapper
|
||||
fileList.add(JavaCodeBuilder.INSTANCE.createMapper(builderModel, dataStr));
|
||||
// mapper xml
|
||||
fileList.add(JavaCodeBuilder.INSTANCE.createMapperXML(builderModel, dataStr));
|
||||
// service
|
||||
fileList.add(JavaCodeBuilder.INSTANCE.createService(builderModel, dataStr));
|
||||
// service impl
|
||||
fileList.add(JavaCodeBuilder.INSTANCE.createServiceImpl(builderModel, dataStr));
|
||||
// web
|
||||
fileList.add(JavaCodeBuilder.INSTANCE.createWeb(builderModel, dataStr));
|
||||
// model
|
||||
fileList.add(JavaCodeBuilder.INSTANCE.createModel(builderModel, dataStr));
|
||||
// api
|
||||
fileList.add(JavaCodeBuilder.INSTANCE.createRestApi(builderModel, dataStr));
|
||||
|
||||
// 处理前端代码 ====================
|
||||
// index
|
||||
fileList.add(VueCodeBuilder.INSTANCE.createIndex(builderModel, dataStr));
|
||||
// edit
|
||||
fileList.add(VueCodeBuilder.INSTANCE.createEdit(builderModel, dataStr));
|
||||
// 前api
|
||||
fileList.add(VueCodeBuilder.INSTANCE.createApi(builderModel, dataStr));
|
||||
|
||||
// 处理 ReadMe
|
||||
fileList.add(ReadMeBuilder.INSTANCE.createReadMe(builderModel, dataStr));
|
||||
|
||||
// 生成zip文件
|
||||
ZipUtils.toZip(fileList, baos);
|
||||
|
||||
// 输出流文件
|
||||
IoUtil.write(out,true, baos.toByteArray());
|
||||
}
|
||||
}catch (Exception ignored){}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出文件时为Writer生成OutputStream
|
||||
*/
|
||||
private OutputStream getOutputStream(HttpServletResponse response, String dataStr){
|
||||
//创建本地文件
|
||||
try {
|
||||
String fileName = FILE_NAME +"-"+ dataStr+".zip";
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
|
||||
return response.getOutputStream();
|
||||
} catch (IOException ignored) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(ValiArgsType.IS_NOT_NULL.toString());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,379 @@
|
||||
/**
|
||||
* 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.core.creater.strategy.create.backend;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.jfinal.kit.Kv;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.opsli.common.enums.DictType;
|
||||
import org.opsli.common.enums.ValiArgsType;
|
||||
import org.opsli.common.utils.HumpUtil;
|
||||
import org.opsli.common.utils.WrapperUtil;
|
||||
import org.opsli.common.utils.ZipUtils;
|
||||
import org.opsli.core.creater.strategy.create.CodeBuilder;
|
||||
import org.opsli.core.creater.utils.EnjoyUtil;
|
||||
import org.opsli.modulars.creater.column.wrapper.CreaterTableColumnModel;
|
||||
import org.opsli.modulars.creater.createrlogs.wrapper.CreaterBuilderModel;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.core.creater.strategy.create.backend
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-11-20 17:30
|
||||
* @Description: Java代码构建器
|
||||
*/
|
||||
public enum JavaCodeBuilder {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
/**
|
||||
* 生成Entity
|
||||
* @param builderModelTmp
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> createEntity(CreaterBuilderModel builderModelTmp, String dataStr){
|
||||
CreaterBuilderModel builderModel =
|
||||
WrapperUtil.cloneTransformInstance(builderModelTmp, CreaterBuilderModel.class);
|
||||
List<CreaterTableColumnModel> columnList = builderModel.getModel().getColumnList();
|
||||
// 处理数据
|
||||
for (CreaterTableColumnModel columnModel : columnList) {
|
||||
// 数据库字段名转驼峰
|
||||
columnModel.setFieldName(
|
||||
HumpUtil.underlineToHump(
|
||||
columnModel.getFieldName()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
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().getTableName()+".java");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成Mapper
|
||||
* @param builderModelTmp
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> createMapper(CreaterBuilderModel builderModelTmp, String dataStr){
|
||||
CreaterBuilderModel builderModel =
|
||||
WrapperUtil.cloneTransformInstance(builderModelTmp, CreaterBuilderModel.class);
|
||||
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().getTableName()+"Mapper.java");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成MapperXML
|
||||
* @param builderModelTmp
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> createMapperXML(CreaterBuilderModel builderModelTmp, String dataStr){
|
||||
CreaterBuilderModel builderModel =
|
||||
WrapperUtil.cloneTransformInstance(builderModelTmp, CreaterBuilderModel.class);
|
||||
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().getTableName()+"Mapper.xml");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成Service
|
||||
* @param builderModelTmp
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> createService(CreaterBuilderModel builderModelTmp, String dataStr){
|
||||
CreaterBuilderModel builderModel =
|
||||
WrapperUtil.cloneTransformInstance(builderModelTmp, CreaterBuilderModel.class);
|
||||
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().getTableName()+"Service.java");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成 Service Impl
|
||||
* @param builderModelTmp
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> createServiceImpl(CreaterBuilderModel builderModelTmp, String dataStr){
|
||||
CreaterBuilderModel builderModel =
|
||||
WrapperUtil.cloneTransformInstance(builderModelTmp, CreaterBuilderModel.class);
|
||||
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().getTableName()+"ServiceImpl.java");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 Web
|
||||
* @param builderModelTmp
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> createWeb(CreaterBuilderModel builderModelTmp, String dataStr){
|
||||
CreaterBuilderModel builderModel =
|
||||
WrapperUtil.cloneTransformInstance(builderModelTmp, CreaterBuilderModel.class);
|
||||
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().getTableName()+"RestController.java");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成Model
|
||||
* @param builderModelTmp
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> createModel(CreaterBuilderModel builderModelTmp, String dataStr){
|
||||
CreaterBuilderModel builderModel =
|
||||
WrapperUtil.cloneTransformInstance(builderModelTmp, CreaterBuilderModel.class);
|
||||
// 处理数据
|
||||
List<CreaterTableColumnModel> columnList = builderModel.getModel().getColumnList();
|
||||
for (CreaterTableColumnModel columnModel : columnList) {
|
||||
// 数据库字段名转驼峰
|
||||
columnModel.setFieldName(
|
||||
HumpUtil.underlineToHump(
|
||||
columnModel.getFieldName()
|
||||
)
|
||||
);
|
||||
|
||||
// 处理验证器
|
||||
String validateType = columnModel.getValidateType();
|
||||
if(StringUtils.isNotBlank(validateType)){
|
||||
String[] validateTypes = validateType.split(",");
|
||||
StringBuilder stb = new StringBuilder();
|
||||
boolean izNotNull = false;
|
||||
// 如果非空 则开启非空验证
|
||||
if(DictType.NO_YES_YES.getCode().equals(columnModel.getIzNotNull())){
|
||||
izNotNull = true;
|
||||
stb.append("ValiArgsType.").append(ValiArgsType.IS_NOT_NULL);
|
||||
}
|
||||
|
||||
for (int i = 0; i < validateTypes.length; i++) {
|
||||
String type = validateTypes[i];
|
||||
if(izNotNull){
|
||||
stb.append(", ");
|
||||
izNotNull = false;
|
||||
}
|
||||
if(!ValiArgsType.IS_NOT_NULL.equals(ValiArgsType.valueOf(type))){
|
||||
stb.append("ValiArgsType.").append(type);
|
||||
}
|
||||
if(i < validateTypes.length -1 ){
|
||||
stb.append(", ");
|
||||
}
|
||||
}
|
||||
columnModel.setValidateType(stb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
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().getTableName()+"Model.java");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成RestApi
|
||||
* @param builderModelTmp
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> createRestApi(CreaterBuilderModel builderModelTmp, String dataStr){
|
||||
CreaterBuilderModel builderModel =
|
||||
WrapperUtil.cloneTransformInstance(builderModelTmp, CreaterBuilderModel.class);
|
||||
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().getTableName()+"RestApi.java");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 Kv
|
||||
* @param builderModel
|
||||
* @return
|
||||
*/
|
||||
private Kv createKv(CreaterBuilderModel builderModel){
|
||||
return Kv.by("data", builderModel)
|
||||
.set("currTime", DateUtil.now())
|
||||
.set("apiPath", CodeBuilder.API_PATH);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,279 @@
|
||||
/**
|
||||
* 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.core.creater.strategy.create.foreend;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.jfinal.kit.Kv;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.opsli.common.enums.DictType;
|
||||
import org.opsli.common.enums.ValiArgsType;
|
||||
import org.opsli.common.utils.HumpUtil;
|
||||
import org.opsli.common.utils.Props;
|
||||
import org.opsli.common.utils.WrapperUtil;
|
||||
import org.opsli.common.utils.ZipUtils;
|
||||
import org.opsli.core.creater.strategy.create.CodeBuilder;
|
||||
import org.opsli.core.creater.utils.EnjoyUtil;
|
||||
import org.opsli.modulars.creater.column.wrapper.CreaterTableColumnModel;
|
||||
import org.opsli.modulars.creater.createrlogs.wrapper.CreaterBuilderModel;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.core.creater.strategy.create.backend
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-11-20 17:30
|
||||
* @Description: Vue代码构建器
|
||||
*/
|
||||
public enum VueCodeBuilder {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
/** 虚拟根路径 */
|
||||
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
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> createIndex(CreaterBuilderModel builderModelTmp, String dataStr){
|
||||
CreaterBuilderModel builderModel =
|
||||
WrapperUtil.cloneTransformInstance(builderModelTmp, CreaterBuilderModel.class);
|
||||
List<CreaterTableColumnModel> columnList = builderModel.getModel().getColumnList();
|
||||
// 处理数据
|
||||
for (CreaterTableColumnModel columnModel : columnList) {
|
||||
// 数据库字段名转驼峰
|
||||
columnModel.setFieldName(
|
||||
HumpUtil.underlineToHump(
|
||||
columnModel.getFieldName()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
List<CreaterTableColumnModel> queryList = new ArrayList<>(2);
|
||||
// 简单检索
|
||||
List<CreaterTableColumnModel> briefQueryList = new ArrayList<>(2);
|
||||
// 更多检索
|
||||
List<CreaterTableColumnModel> moreQueryList = new ArrayList<>();
|
||||
for (int i = 0; i < columnList.size(); i++) {
|
||||
if(StringUtils.isNotBlank(columnList.get(i).getQueryType()) &&
|
||||
columnList.get(i).getIzShowList().equals(DictType.NO_YES_YES.getCode())
|
||||
){
|
||||
queryList.add(columnList.get(i));
|
||||
}
|
||||
}
|
||||
// 筛选数据
|
||||
for (int i = 0; i < queryList.size(); i++) {
|
||||
if(i < 2){
|
||||
briefQueryList.add(queryList.get(i));
|
||||
}else{
|
||||
moreQueryList.add(queryList.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String codeStr = EnjoyUtil.render("/foreend/index/TemplateIndex.html",
|
||||
this.createKv(builderModel)
|
||||
.set("briefQueryList", briefQueryList)
|
||||
.set("moreQueryList", moreQueryList)
|
||||
);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成 Index
|
||||
* @param builderModelTmp
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> createEdit(CreaterBuilderModel builderModelTmp, String dataStr){
|
||||
CreaterBuilderModel builderModel =
|
||||
WrapperUtil.cloneTransformInstance(builderModelTmp, CreaterBuilderModel.class);
|
||||
List<CreaterTableColumnModel> columnList = builderModel.getModel().getColumnList();
|
||||
List<List<CreaterTableColumnModel>> formList = new ArrayList<>();
|
||||
Map<String,List<String>> valiDict = new HashMap<>();
|
||||
Set<String> validataTypes = new HashSet<>();
|
||||
// 处理验证数据
|
||||
for (CreaterTableColumnModel columnModel : columnList) {
|
||||
// 数据库字段名转驼峰
|
||||
columnModel.setFieldName(
|
||||
HumpUtil.underlineToHump(
|
||||
columnModel.getFieldName()
|
||||
)
|
||||
);
|
||||
|
||||
// 处理验证器
|
||||
String validateType = columnModel.getValidateType();
|
||||
if(StringUtils.isNotBlank(validateType)){
|
||||
String[] validateTypes = validateType.split(",");
|
||||
Set<String> validateTypeSet = new HashSet<>(Arrays.asList(validateTypes));
|
||||
// 如果非空 则开启非空验证
|
||||
if(DictType.NO_YES_YES.getCode().equals(columnModel.getIzNotNull())){
|
||||
validateTypeSet.add(ValiArgsType.IS_NOT_NULL.toString());
|
||||
}
|
||||
|
||||
List<String> validateTypeList = new ArrayList<>(validateTypes.length);
|
||||
for (String vali : validateTypeSet) {
|
||||
validateTypeList.add(
|
||||
HumpUtil.underlineToHump(
|
||||
vali.toLowerCase()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
validataTypes.addAll(validateTypeList);
|
||||
valiDict.put(columnModel.getFieldName(), validateTypeList);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理数据
|
||||
if(columnList.size() == 1){
|
||||
if(columnList.get(0).getIzShowForm().equals(DictType.NO_YES_YES.getCode()) &&
|
||||
StringUtils.isNotBlank(columnList.get(0).getShowType())
|
||||
){
|
||||
List<CreaterTableColumnModel> formTmpList = new ArrayList<>();
|
||||
formTmpList.add(columnList.get(0));
|
||||
formList.add(formTmpList);
|
||||
}
|
||||
}else{
|
||||
for (int i = 0; i < columnList.size(); i+=2) {
|
||||
List<CreaterTableColumnModel> formTmpList = new ArrayList<>();
|
||||
if(columnList.get(i).getIzShowForm().equals(DictType.NO_YES_YES.getCode()) &&
|
||||
StringUtils.isNotBlank(columnList.get(i).getShowType())
|
||||
){
|
||||
formTmpList.add(columnList.get(i));
|
||||
if(i+1 < columnList.size()){
|
||||
formTmpList.add(columnList.get(i+1));
|
||||
}
|
||||
formList.add(formTmpList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder validataTypeStb = new StringBuilder();
|
||||
for (String validataType : validataTypes) {
|
||||
validataTypeStb.append(validataType);
|
||||
validataTypeStb.append(", ");
|
||||
}
|
||||
|
||||
String codeStr = EnjoyUtil.render("/foreend/components/TemplateEdit.html",
|
||||
this.createKv(builderModel)
|
||||
.set("formList", formList)
|
||||
.set("valiDict", valiDict)
|
||||
.set("validataTypes", validataTypeStb.toString())
|
||||
);
|
||||
|
||||
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().getTableName()+"ManagementEdit.vue");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 Api
|
||||
* @param builderModelTmp
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> createApi(CreaterBuilderModel builderModelTmp, String dataStr){
|
||||
CreaterBuilderModel builderModel =
|
||||
WrapperUtil.cloneTransformInstance(builderModelTmp, CreaterBuilderModel.class);
|
||||
List<CreaterTableColumnModel> columnList = builderModel.getModel().getColumnList();
|
||||
// 处理数据
|
||||
for (CreaterTableColumnModel columnModel : columnList) {
|
||||
// 数据库字段名转驼峰
|
||||
columnModel.setFieldName(
|
||||
HumpUtil.underlineToHump(
|
||||
columnModel.getFieldName()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
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().getTableName()+"Management.js");
|
||||
entityMap.put(ZipUtils.FILE_DATA, codeStr);
|
||||
return entityMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 Kv
|
||||
* @param builderModel
|
||||
* @return
|
||||
*/
|
||||
private Kv createKv(CreaterBuilderModel builderModel){
|
||||
return Kv.by("data", builderModel)
|
||||
.set("currTime", DateUtil.now());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/**
|
||||
* 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.core.creater.strategy.create.readme;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.jfinal.kit.Kv;
|
||||
import org.opsli.common.utils.HumpUtil;
|
||||
import org.opsli.common.utils.Props;
|
||||
import org.opsli.common.utils.WrapperUtil;
|
||||
import org.opsli.common.utils.ZipUtils;
|
||||
import org.opsli.core.creater.strategy.create.CodeBuilder;
|
||||
import org.opsli.core.creater.utils.EnjoyUtil;
|
||||
import org.opsli.modulars.creater.column.wrapper.CreaterTableColumnModel;
|
||||
import org.opsli.modulars.creater.createrlogs.wrapper.CreaterBuilderModel;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.core.creater.strategy.create.backend
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-11-20 17:30
|
||||
* @Description: ReadMe 构建器
|
||||
*/
|
||||
public enum ReadMeBuilder {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
/**
|
||||
* 生成 ReadMe
|
||||
* @param builderModelTmp
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> createReadMe(CreaterBuilderModel builderModelTmp, String dataStr){
|
||||
CreaterBuilderModel builderModel =
|
||||
WrapperUtil.cloneTransformInstance(builderModelTmp, CreaterBuilderModel.class);
|
||||
|
||||
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
|
||||
* @return
|
||||
*/
|
||||
private Kv createKv(CreaterBuilderModel builderModel){
|
||||
return Kv.by("data", builderModel)
|
||||
.set("currTime", DateUtil.now());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package org.opsli.core.creater.utils;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import com.jfinal.kit.Kv;
|
||||
import com.jfinal.template.Engine;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/***
|
||||
* jfinal魔板引擎
|
||||
* @author dufuzhong
|
||||
*/
|
||||
@Slf4j
|
||||
public final class EnjoyUtil {
|
||||
|
||||
private static final String BASE_PATH = "/tpl";
|
||||
|
||||
/**
|
||||
* 根据具体魔板生成文件
|
||||
* @param templateFileName 模板文件名称
|
||||
* @param kv 渲染参数
|
||||
* @return
|
||||
*/
|
||||
public static String render(String templateFileName, Kv kv) {
|
||||
|
||||
//ClassPathResource resource = new ClassPathResource(templateFileName);
|
||||
// (InputStream inputStream = resource.getInputStream())
|
||||
String str = "";
|
||||
ClassPathResource resource = new ClassPathResource(BASE_PATH + templateFileName);
|
||||
try (InputStream inputStream = resource.getInputStream()){
|
||||
String readTpl = IoUtil.read(inputStream, StandardCharsets.UTF_8);
|
||||
|
||||
str = Engine.use()
|
||||
// 开启预热模式
|
||||
.setDevMode(true)
|
||||
.getTemplateByString(readTpl)
|
||||
.renderToString(kv);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("load config file {} error", templateFileName, e);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private EnjoyUtil(){}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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.creater.createrlogs.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.opsli.modulars.creater.createrlogs.entity.CreaterLogs;
|
||||
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-09-17 13:01
|
||||
* @Description: 代码生成器 - 生成日志 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface CreaterLogsMapper extends BaseMapper<CreaterLogs> {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
<?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">
|
||||
<mapper namespace="org.opsli.modulars.creater.createrlogs.mapper.CreaterLogsMapper">
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,57 @@
|
||||
/**
|
||||
* 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.creater.createrlogs.service;
|
||||
|
||||
import org.opsli.core.base.service.interfaces.CrudServiceInterface;
|
||||
import org.opsli.modulars.creater.createrlogs.entity.CreaterLogs;
|
||||
import org.opsli.modulars.creater.createrlogs.wrapper.CreaterLogsModel;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-09-17 13:07
|
||||
* @Description: 代码生成器 - 表 接口
|
||||
*/
|
||||
public interface ICreateLogsService extends CrudServiceInterface<CreaterLogs, CreaterLogsModel> {
|
||||
|
||||
/**
|
||||
* 根据表Id 删除
|
||||
* @param tableId
|
||||
*/
|
||||
void delByTableId(String tableId);
|
||||
|
||||
/**
|
||||
* 根据表Id 批量删除
|
||||
* @param tableIds
|
||||
*/
|
||||
void delByTableIds(String[] tableIds);
|
||||
|
||||
/**
|
||||
* 根据表Id 查询
|
||||
* @param tableId
|
||||
*/
|
||||
CreaterLogsModel getByTableId(String tableId);
|
||||
|
||||
/**
|
||||
* 代码生成
|
||||
* @param model
|
||||
*/
|
||||
void create(CreaterLogsModel model, HttpServletResponse response);
|
||||
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
/**
|
||||
* 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.creater.createrlogs.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.opsli.common.utils.WrapperUtil;
|
||||
import org.opsli.core.base.service.impl.CrudServiceImpl;
|
||||
import org.opsli.core.creater.exception.CreaterException;
|
||||
import org.opsli.core.creater.msg.CreaterMsg;
|
||||
import org.opsli.core.creater.strategy.create.CodeBuilder;
|
||||
import org.opsli.core.persistence.querybuilder.GenQueryBuilder;
|
||||
import org.opsli.core.persistence.querybuilder.QueryBuilder;
|
||||
import org.opsli.modulars.creater.column.service.ITableColumnService;
|
||||
import org.opsli.modulars.creater.column.wrapper.CreaterTableColumnModel;
|
||||
import org.opsli.modulars.creater.createrlogs.entity.CreaterLogs;
|
||||
import org.opsli.modulars.creater.createrlogs.mapper.CreaterLogsMapper;
|
||||
import org.opsli.modulars.creater.createrlogs.service.ICreateLogsService;
|
||||
import org.opsli.modulars.creater.createrlogs.wrapper.CreaterBuilderModel;
|
||||
import org.opsli.modulars.creater.createrlogs.wrapper.CreaterLogsModel;
|
||||
import org.opsli.modulars.creater.table.service.ITableService;
|
||||
import org.opsli.modulars.creater.table.wrapper.CreaterTableAndColumnModel;
|
||||
import org.opsli.modulars.creater.table.wrapper.CreaterTableModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-09-16 17:34
|
||||
* @Description: 代码生成器 - 表 接口实现类
|
||||
*/
|
||||
@Service
|
||||
public class CreateLogsServiceImpl extends CrudServiceImpl<CreaterLogsMapper, CreaterLogs, CreaterLogsModel>
|
||||
implements ICreateLogsService {
|
||||
|
||||
@Autowired(required = false)
|
||||
private CreaterLogsMapper mapper;
|
||||
@Autowired
|
||||
private ITableService iTableService;
|
||||
@Autowired
|
||||
private ITableColumnService iTableColumnService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delByTableId(String tableId) {
|
||||
QueryBuilder<CreaterLogs> queryBuilder =
|
||||
new GenQueryBuilder<>();
|
||||
QueryWrapper<CreaterLogs> wrapper = queryBuilder.build();
|
||||
wrapper.eq("table_id", tableId);
|
||||
super.remove(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delByTableIds(String[] tableIds) {
|
||||
if(tableIds != null){
|
||||
for (String tableId : tableIds) {
|
||||
QueryBuilder<CreaterLogs> queryBuilder =
|
||||
new GenQueryBuilder<>();
|
||||
QueryWrapper<CreaterLogs> wrapper = queryBuilder.build();
|
||||
wrapper.eq("table_id", tableId);
|
||||
super.remove(wrapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreaterLogsModel getByTableId(String tableId) {
|
||||
QueryBuilder<CreaterLogs> queryBuilder =
|
||||
new GenQueryBuilder<>();
|
||||
QueryWrapper<CreaterLogs> wrapper = queryBuilder.build();
|
||||
wrapper.eq("table_id", tableId);
|
||||
return super.transformT2M(
|
||||
this.getOne(wrapper)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(CreaterLogsModel model, HttpServletResponse response) {
|
||||
if(model == null){
|
||||
// 生成失败,数据为空
|
||||
throw new CreaterException(CreaterMsg.EXCEPTION_CREATE_NULL);
|
||||
}
|
||||
model.setVersion(null);
|
||||
CreaterLogsModel saveModel = this.save(model);
|
||||
if(saveModel != null){
|
||||
CreaterTableModel createrTableModel = iTableService.get(saveModel.getTableId());
|
||||
if(createrTableModel == null){
|
||||
// 生成失败,暂无表数据
|
||||
throw new CreaterException(CreaterMsg.EXCEPTION_CREATE_TABLE_NULL);
|
||||
}
|
||||
|
||||
CreaterTableAndColumnModel currTableModel = WrapperUtil.transformInstance(
|
||||
createrTableModel, CreaterTableAndColumnModel.class
|
||||
);
|
||||
List<CreaterTableColumnModel> columnModelList = iTableColumnService.
|
||||
getByTableId(currTableModel.getId());
|
||||
if(columnModelList == null || columnModelList.isEmpty()){
|
||||
// 生成失败,暂无表字段
|
||||
throw new CreaterException(CreaterMsg.EXCEPTION_CREATE_FIELD_NULL);
|
||||
}
|
||||
|
||||
|
||||
// 赋值表字段
|
||||
currTableModel.setColumnList(columnModelList);
|
||||
|
||||
// 生成代码
|
||||
CreaterBuilderModel builderModel = WrapperUtil.transformInstance(
|
||||
saveModel, CreaterBuilderModel.class
|
||||
);
|
||||
builderModel.setModel(currTableModel);
|
||||
|
||||
// 生成代码
|
||||
CodeBuilder.INSTANCE.build(builderModel, response);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,90 @@
|
||||
/**
|
||||
* 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.creater.createrlogs.web;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.opsli.api.base.result.ResultVo;
|
||||
import org.opsli.common.annotation.ApiRestController;
|
||||
import org.opsli.common.annotation.EnableLog;
|
||||
import org.opsli.common.exception.ServiceException;
|
||||
import org.opsli.common.utils.WrapperUtil;
|
||||
import org.opsli.core.base.concroller.BaseRestController;
|
||||
import org.opsli.core.creater.exception.CreaterException;
|
||||
import org.opsli.core.creater.msg.CreaterMsg;
|
||||
import org.opsli.core.creater.strategy.sync.util.SQLSyncUtil;
|
||||
import org.opsli.core.msg.CoreMsg;
|
||||
import org.opsli.core.persistence.Page;
|
||||
import org.opsli.core.persistence.querybuilder.QueryBuilder;
|
||||
import org.opsli.core.persistence.querybuilder.WebQueryBuilder;
|
||||
import org.opsli.modulars.creater.column.service.ITableColumnService;
|
||||
import org.opsli.modulars.creater.column.wrapper.CreaterTableColumnModel;
|
||||
import org.opsli.modulars.creater.createrlogs.api.CreaterLogsApi;
|
||||
import org.opsli.modulars.creater.createrlogs.entity.CreaterLogs;
|
||||
import org.opsli.modulars.creater.createrlogs.service.ICreateLogsService;
|
||||
import org.opsli.modulars.creater.createrlogs.wrapper.CreaterLogsModel;
|
||||
import org.opsli.modulars.creater.importable.ImportTableUtil;
|
||||
import org.opsli.modulars.creater.table.api.TableApi;
|
||||
import org.opsli.modulars.creater.table.entity.CreaterTable;
|
||||
import org.opsli.modulars.creater.table.service.ITableService;
|
||||
import org.opsli.modulars.creater.table.wrapper.CreaterTableAndColumnModel;
|
||||
import org.opsli.modulars.creater.table.wrapper.CreaterTableModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-09-13 17:40
|
||||
* @Description: 代码生成器 - 表
|
||||
*/
|
||||
@Slf4j
|
||||
@ApiRestController("/creater/logs")
|
||||
public class CreaterLogsRestController extends BaseRestController<CreaterLogs, CreaterLogsModel, ICreateLogsService>
|
||||
implements CreaterLogsApi {
|
||||
|
||||
@ApiOperation(value = "获得当前表生成记录", notes = "获得当前表生成记录")
|
||||
@RequiresPermissions("deve_creater_select")
|
||||
@Override
|
||||
public ResultVo<CreaterLogsModel> getByTableId(String tableId) {
|
||||
CreaterLogsModel byTableId = IService.getByTableId(tableId);
|
||||
return ResultVo.success(byTableId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 代码生成 修改
|
||||
* @param model 模型
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "代码生成", notes = "代码生成")
|
||||
@RequiresPermissions("deve_creater_create")
|
||||
@EnableLog
|
||||
@Override
|
||||
public void create(CreaterLogsModel model, HttpServletResponse response) {
|
||||
// 演示模式 不允许操作
|
||||
// super.demoError();
|
||||
|
||||
// 调用生成方法
|
||||
IService.create(model, response);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* 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.creater.createrlogs.wrapper;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.opsli.api.base.warpper.ApiWrapper;
|
||||
import org.opsli.common.annotation.validation.ValidationArgs;
|
||||
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
|
||||
import org.opsli.common.enums.ValiArgsType;
|
||||
import org.opsli.modulars.creater.table.wrapper.CreaterTableAndColumnModel;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.modulars.creater.createrlogs.wrapper
|
||||
* @Author: Parker
|
||||
* @CreateTime: 2020-09-16 17:33
|
||||
* @Description: 代码生成器 - 生成日志+代码模型
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class CreaterBuilderModel extends ApiWrapper {
|
||||
|
||||
|
||||
/** 归属表ID */
|
||||
private String tableId;
|
||||
|
||||
/** 包名 */
|
||||
private String packageName;
|
||||
|
||||
/** 模块名 */
|
||||
private String moduleName;
|
||||
|
||||
/** 子模块名 */
|
||||
private String subModuleName;
|
||||
|
||||
/** 代码标题 */
|
||||
private String codeTitle;
|
||||
|
||||
/** 代码标题简介 */
|
||||
private String codeTitleBrief;
|
||||
|
||||
/** 作者名 */
|
||||
private String authorName;
|
||||
|
||||
/** 代码模型 */
|
||||
private CreaterTableAndColumnModel model;
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
import java.util.Date;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
* @BelongsPackage: #(data.packageName+"."+data.moduleName+"."+data.subModuleName).entity
|
||||
#else
|
||||
* @BelongsPackage: #(data.packageName+"."+data.moduleName).entity
|
||||
#end
|
||||
* @Author: #(data.authorName)
|
||||
* @CreateTime: #(currTime)
|
||||
* @Description: #(data.codeTitle)
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class #(data.model.tableName) extends BaseEntity {
|
||||
|
||||
|
||||
#for(column : data.model.columnList)
|
||||
### 不等于 删除字段 和 不等于 租户字段放入上边
|
||||
#if(column.fieldName != "deleted" && column.fieldName != "tenantId")
|
||||
/** #(column.fieldComments) */
|
||||
#if(!column.izNotNull)
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
#end
|
||||
private #(column.javaType) #(column.fieldName);
|
||||
|
||||
#end
|
||||
#end
|
||||
|
||||
// ========================================
|
||||
|
||||
### 专门处理 删除字段 和 租户字段
|
||||
#for(column : data.model.columnList)
|
||||
#if(column.fieldName == "deleted")
|
||||
/** 逻辑删除字段 */
|
||||
private Integer deleted;
|
||||
#else if(column.fieldName == "tenantId")
|
||||
/** 多租户字段 */
|
||||
private String tenantId;
|
||||
#end
|
||||
|
||||
#end
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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.tableName);
|
||||
#else
|
||||
import #(data.packageName+"."+data.moduleName).entity.#(data.model.tableName);
|
||||
#end
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
* @BelongsPackage: #(data.packageName+"."+data.moduleName+"."+data.subModuleName).mapper
|
||||
#else
|
||||
* @BelongsPackage: #(data.packageName+"."+data.moduleName).mapper
|
||||
#end
|
||||
* @Author: #(data.authorName)
|
||||
* @CreateTime: #(currTime)
|
||||
* @Description: #(data.codeTitle) Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface #(data.model.tableName)Mapper extends BaseMapper<#(data.model.tableName)> {
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?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.tableName)Mapper">
|
||||
#else
|
||||
<mapper namespace="#(data.packageName+'.'+data.moduleName).mapper.#(data.model.tableName)Mapper">
|
||||
#end
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
import java.util.Date;
|
||||
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.validation.ValidationArgs;
|
||||
import org.opsli.common.annotation.validation.ValidationArgsLenMax;
|
||||
import org.opsli.common.enums.ValiArgsType;
|
||||
import org.opsli.plugins.excel.annotation.ExcelInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
* @BelongsPackage: #(apiPath).wrapper.#(data.moduleName+"."+data.subModuleName)
|
||||
#else
|
||||
* @BelongsPackage: #(apiPath).wrapper.#(data.moduleName)
|
||||
#end
|
||||
* @Author: #(data.authorName)
|
||||
* @CreateTime: #(currTime)
|
||||
* @Description: #(data.codeTitle)
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class #(data.model.tableName)Model extends ApiWrapper {
|
||||
|
||||
#for(column : data.model.columnList)
|
||||
### 不等于 删除字段 和 不等于 租户字段放入上边
|
||||
#if(column.fieldName != "deleted" && column.fieldName != "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.validateType != null && column.validateType != "")
|
||||
@ValidationArgs({#(column.validateType)})
|
||||
#end
|
||||
#if(column.fieldLength != null && column.fieldLength > 0)
|
||||
#if(column.fieldPrecision != null && column.fieldPrecision > 0)
|
||||
@ValidationArgsLenMax(#(column.fieldLength+column.fieldPrecision))
|
||||
#else
|
||||
@ValidationArgsLenMax(#(column.fieldLength))
|
||||
#end
|
||||
#end
|
||||
#if(column.javaType == "Date")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
#end
|
||||
private #(column.javaType) #(column.fieldName);
|
||||
|
||||
#end
|
||||
#end
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* 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.tableName);
|
||||
import #(apiPath).wrapper.#(data.moduleName+"."+data.subModuleName).#(data.model.tableName)Model;
|
||||
#else
|
||||
import #(data.packageName+"."+data.moduleName).entity.#(data.model.tableName);
|
||||
import #(apiPath).wrapper.#(data.moduleName).#(data.model.tableName)Model;
|
||||
#end
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
* @BelongsPackage: #(data.packageName+"."+data.moduleName+"."+data.subModuleName).service
|
||||
#else
|
||||
* @BelongsPackage: #(data.packageName+"."+data.moduleName).service
|
||||
#end
|
||||
* @Author: #(data.authorName)
|
||||
* @CreateTime: #(currTime)
|
||||
* @Description: #(data.codeTitle) Service
|
||||
*/
|
||||
public interface I#(data.model.tableName)Service extends CrudServiceInterface<#(data.model.tableName), #(data.model.tableName)Model> {
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* 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.tableName);
|
||||
import #(apiPath).wrapper.#(data.moduleName+"."+data.subModuleName).#(data.model.tableName)Model;
|
||||
import #(data.packageName+"."+data.moduleName+"."+data.subModuleName).service.I#(data.model.tableName)Service;
|
||||
import #(data.packageName+"."+data.moduleName+"."+data.subModuleName).mapper.#(data.model.tableName)Mapper;
|
||||
#else
|
||||
import #(data.packageName+"."+data.moduleName).entity.#(data.model.tableName);
|
||||
import #(apiPath).wrapper.#(data.moduleName).#(data.model.tableName)Model;
|
||||
import #(data.packageName+"."+data.moduleName).service.I#(data.model.tableName)Service;
|
||||
import #(data.packageName+"."+data.moduleName).mapper.#(data.model.tableName)Mapper;
|
||||
#end
|
||||
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
* @BelongsPackage: #(data.packageName+"."+data.moduleName+"."+data.subModuleName).service.impl
|
||||
#else
|
||||
* @BelongsPackage: #(data.packageName+"."+data.moduleName).service.impl
|
||||
#end
|
||||
* @Author: #(data.authorName)
|
||||
* @CreateTime: #(currTime)
|
||||
* @Description: #(data.codeTitle) Service Impl
|
||||
*/
|
||||
@Service
|
||||
public class #(data.model.tableName)ServiceImpl extends CrudServiceImpl<#(data.model.tableName)Mapper, #(data.model.tableName), #(data.model.tableName)Model>
|
||||
implements I#(data.model.tableName)Service {
|
||||
|
||||
@Autowired(required = false)
|
||||
private #(data.model.tableName)Mapper mapper;
|
||||
|
||||
}
|
@ -0,0 +1,242 @@
|
||||
/**
|
||||
* 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).web;
|
||||
#else
|
||||
package #(data.packageName+"."+data.moduleName).web;
|
||||
#end
|
||||
|
||||
import org.opsli.core.base.service.interfaces.CrudServiceInterface;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import #(apiPath).base.result.ResultVo;
|
||||
import org.opsli.common.annotation.ApiRestController;
|
||||
import org.opsli.common.annotation.EnableLog;
|
||||
import org.opsli.core.base.concroller.BaseRestController;
|
||||
import org.opsli.core.persistence.Page;
|
||||
import org.opsli.core.persistence.querybuilder.QueryBuilder;
|
||||
import org.opsli.core.persistence.querybuilder.WebQueryBuilder;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
import #(data.packageName+"."+data.moduleName+"."+data.subModuleName).entity.#(data.model.tableName);
|
||||
import #(apiPath).wrapper.#(data.moduleName+"."+data.subModuleName).#(data.model.tableName)Model;
|
||||
import #(data.packageName+"."+data.moduleName+"."+data.subModuleName).service.I#(data.model.tableName)Service;
|
||||
import #(apiPath).web.#(data.moduleName+"."+data.subModuleName).#(data.model.tableName)RestApi;
|
||||
#else
|
||||
import #(data.packageName+"."+data.moduleName).entity.#(data.model.tableName);
|
||||
import #(apiPath).wrapper.#(data.moduleName).#(data.model.tableName)Model;
|
||||
import #(data.packageName+"."+data.moduleName).service.I#(data.model.tableName)Service;
|
||||
import #(apiPath).web.#(data.moduleName).#(data.model.tableName)RestApi;
|
||||
#end
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
* @BelongsPackage: #(data.packageName+"."+data.moduleName+"."+data.subModuleName).web
|
||||
#else
|
||||
* @BelongsPackage: #(data.packageName+"."+data.moduleName).web
|
||||
#end
|
||||
* @Author: #(data.authorName)
|
||||
* @CreateTime: #(currTime)
|
||||
* @Description: #(data.codeTitle) Controller
|
||||
*/
|
||||
@Slf4j
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
@ApiRestController("/#(data.moduleName)/#(data.subModuleName)")
|
||||
#else
|
||||
@ApiRestController("/#(data.moduleName)")
|
||||
#end
|
||||
public class #(data.model.tableName)RestController extends BaseRestController<#(data.model.tableName), #(data.model.tableName)Model, I#(data.model.tableName)Service>
|
||||
implements #(data.model.tableName)RestApi {
|
||||
|
||||
|
||||
/**
|
||||
* #(data.codeTitleBrief) 查一条
|
||||
* @param model 模型
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "获得单条#(data.codeTitleBrief)", notes = "获得单条#(data.codeTitleBrief) - ID")
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_#(data.subModuleName.toLowerCase())_select")
|
||||
#else
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_select")
|
||||
#end
|
||||
@Override
|
||||
public ResultVo<#(data.model.tableName)Model> get(#(data.model.tableName)Model model) {
|
||||
// 如果系统内部调用 则直接查数据库
|
||||
if(model != null && model.getIzApi() != null && model.getIzApi()){
|
||||
model = IService.get(model);
|
||||
}
|
||||
return ResultVo.success(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* #(data.codeTitleBrief) 查询分页
|
||||
* @param pageNo 当前页
|
||||
* @param pageSize 每页条数
|
||||
* @param request request
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "获得分页数据", notes = "获得分页数据 - 查询构造器")
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_#(data.subModuleName.toLowerCase())_select")
|
||||
#else
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_select")
|
||||
#end
|
||||
@Override
|
||||
public ResultVo<?> findPage(Integer pageNo, Integer pageSize, HttpServletRequest request) {
|
||||
|
||||
QueryBuilder<#(data.model.tableName)> queryBuilder = new WebQueryBuilder<>(#(data.model.tableName).class, request.getParameterMap());
|
||||
Page<#(data.model.tableName), #(data.model.tableName)Model> page = new Page<>(pageNo, pageSize);
|
||||
page.setQueryWrapper(queryBuilder.build());
|
||||
page = IService.findPage(page);
|
||||
|
||||
return ResultVo.success(page.getBootstrapData());
|
||||
}
|
||||
|
||||
/**
|
||||
* #(data.codeTitleBrief) 新增
|
||||
* @param model 模型
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "新增#(data.codeTitleBrief)数据", notes = "新增#(data.codeTitleBrief)数据")
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_#(data.subModuleName.toLowerCase())_insert")
|
||||
#else
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_insert")
|
||||
#end
|
||||
@EnableLog
|
||||
@Override
|
||||
public ResultVo<?> insert(#(data.model.tableName)Model model) {
|
||||
// 调用新增方法
|
||||
IService.insert(model);
|
||||
return ResultVo.success("新增#(data.codeTitleBrief)成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* #(data.codeTitleBrief) 修改
|
||||
* @param model 模型
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "修改#(data.codeTitleBrief)数据", notes = "修改#(data.codeTitleBrief)数据")
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_#(data.subModuleName.toLowerCase())_update")
|
||||
#else
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_update")
|
||||
#end
|
||||
@EnableLog
|
||||
@Override
|
||||
public ResultVo<?> update(#(data.model.tableName)Model model) {
|
||||
// 调用修改方法
|
||||
IService.update(model);
|
||||
return ResultVo.success("修改#(data.codeTitleBrief)成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* #(data.codeTitleBrief) 删除
|
||||
* @param id ID
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "删除#(data.codeTitleBrief)数据", notes = "删除#(data.codeTitleBrief)数据")
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_#(data.subModuleName.toLowerCase())_update")
|
||||
#else
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_update")
|
||||
#end
|
||||
@EnableLog
|
||||
@Override
|
||||
public ResultVo<?> del(String id){
|
||||
IService.delete(id);
|
||||
return ResultVo.success("删除#(data.codeTitleBrief)成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* #(data.codeTitleBrief) 批量删除
|
||||
* @param ids ID 数组
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "批量删除#(data.codeTitleBrief)数据", notes = "批量删除#(data.codeTitleBrief)数据")
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_#(data.subModuleName.toLowerCase())_update")
|
||||
#else
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_update")
|
||||
#end
|
||||
@EnableLog
|
||||
@Override
|
||||
public ResultVo<?> delAll(String[] ids){
|
||||
IService.deleteAll(ids);
|
||||
return ResultVo.success("批量删除#(data.codeTitleBrief)成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* #(data.codeTitleBrief) Excel 导出
|
||||
* @param request request
|
||||
* @param response response
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "导出Excel", notes = "导出Excel")
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_#(data.subModuleName.toLowerCase())_export")
|
||||
#else
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_export")
|
||||
#end
|
||||
@EnableLog
|
||||
@Override
|
||||
public ResultVo<?> exportExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
QueryBuilder<#(data.model.tableName)> queryBuilder = new WebQueryBuilder<>(#(data.model.tableName).class, request.getParameterMap());
|
||||
return super.excelExport(RoleApi.TITLE, queryBuilder.build(), response);
|
||||
}
|
||||
|
||||
/**
|
||||
* #(data.codeTitleBrief) Excel 导入
|
||||
* @param request 文件流 request
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "导入Excel", notes = "导入Excel")
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_#(data.subModuleName.toLowerCase())_import")
|
||||
#else
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_import")
|
||||
#end
|
||||
@EnableLog
|
||||
@Override
|
||||
public ResultVo<?> excelImport(MultipartHttpServletRequest request) {
|
||||
return super.excelImport(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* #(data.codeTitleBrief) Excel 下载导入模版
|
||||
* @param response response
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "导出Excel模版", notes = "导出Excel模版")
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_#(data.subModuleName.toLowerCase())_import")
|
||||
#else
|
||||
@RequiresPermissions("#(data.moduleName.toLowerCase())_import")
|
||||
#end
|
||||
@Override
|
||||
public ResultVo<?> importTemplate(HttpServletResponse response) {
|
||||
return super.importTemplate(RoleApi.TITLE, response);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
import request from "@/utils/request";
|
||||
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
@ -0,0 +1,195 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="title"
|
||||
:visible.sync="dialogFormVisible"
|
||||
width="800px"
|
||||
@close="close"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="105px">
|
||||
#for(columnList : formList)
|
||||
#if(columnList != null && columnList.size() > 0)
|
||||
<el-row>
|
||||
#for(column : columnList)
|
||||
### 文本框
|
||||
#if(column.showType == "0")
|
||||
<el-col :span="12">
|
||||
<el-form-item label="#(column.fieldComments)" prop="#(column.fieldName)">
|
||||
<el-input v-model="form.#(column.fieldName)" autocomplete="off"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
### 文本域
|
||||
#else if(column.showType == "1")
|
||||
<el-col :span="12">
|
||||
<el-form-item label="#(column.fieldComments)" prop="#(column.fieldName)">
|
||||
<el-input type="textarea" v-model="form.#(column.fieldName)" autocomplete="off"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
### 字典
|
||||
#else if(column.showType == "2")
|
||||
<el-col :span="12">
|
||||
<el-form-item label="#(column.fieldComments)" prop="#(column.fieldName)">
|
||||
<el-select v-model="form.#(column.fieldName)" 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 :span="12">
|
||||
<el-form-item label="#(column.fieldComments)" prop="#(column.fieldName)">
|
||||
<el-date-picker
|
||||
v-model="form.#(column.fieldName)"
|
||||
type="datetime"
|
||||
placeholder="选择#(column.fieldComments)时间"
|
||||
style="width: 100%"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
#end
|
||||
#end
|
||||
</el-row>
|
||||
#end
|
||||
#end
|
||||
|
||||
</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.tableName)Management";
|
||||
#else
|
||||
import { doInsert, doUpdate } from "@/api/#(data.moduleName)/#(data.model.tableName)Management";
|
||||
#end
|
||||
import { formateDate } from "@/utils/format";
|
||||
import { isNull } from "@/utils/validate";
|
||||
import { #(validataTypes) getMsg} from "@/utils/valiargs";
|
||||
|
||||
export default {
|
||||
name: "#(data.model.tableName)ManagementEdit",
|
||||
data() {
|
||||
|
||||
#for(columnList : formList)
|
||||
#for(column : columnList)
|
||||
#for(vali : valiDict[column.fieldName])
|
||||
#if(vali != "isNotNull")
|
||||
const validate_#(column.fieldName+'_'+vali) = (rule, value, callback) => {
|
||||
if (!#(vali)(value)) {
|
||||
callback(new Error(getMsg('#(vali)')));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
|
||||
return {
|
||||
form: {
|
||||
// 设置默认值
|
||||
version: 0
|
||||
},
|
||||
dict: {},
|
||||
rules: {
|
||||
#for(columnList : formList)
|
||||
#for(column : columnList)
|
||||
#if(valiDict[column.fieldName] != null && valiDict[column.fieldName].size() > 0)
|
||||
#(column.fieldName): [
|
||||
#for(vali : valiDict[column.fieldName])
|
||||
#if(vali == "isNotNull")
|
||||
{ required: true, trigger: "blur", message: "#(column.fieldComments)非空" },
|
||||
#end
|
||||
#end
|
||||
#for(vali : valiDict[column.fieldName])
|
||||
#if(vali != "isNotNull")
|
||||
{ required: false, trigger: "blur", validator: validate_#(column.fieldName+'_'+vali) },
|
||||
#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;
|
||||
this.$emit("fetchData");
|
||||
},
|
||||
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>
|
@ -0,0 +1,479 @@
|
||||
<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 : moreQueryList)
|
||||
|
||||
### 字典
|
||||
#if(column.showType == "2")
|
||||
<el-form-item>
|
||||
<el-select v-model="queryForm.#(column.fieldName+'_'+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.fieldName)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.queryType == "EQ" || column.queryType == "LIKE")
|
||||
<el-form-item>
|
||||
<el-input
|
||||
v-model.trim="queryForm.#(column.fieldName)_#(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.fieldName)_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.fieldName)_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())_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 : briefQueryList)
|
||||
|
||||
### 字典
|
||||
#if(column.showType == "2")
|
||||
<el-form-item>
|
||||
<el-select v-model="queryForm.#(column.fieldName+'_'+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.fieldName)DatePicker"
|
||||
type="datetimerange"
|
||||
:picker-options="pickerOptions"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
align="right">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
#else
|
||||
#if(column.queryType == "EQ" || column.queryType == "LIKE")
|
||||
<el-form-item>
|
||||
<el-input
|
||||
v-model.trim="queryForm.#(column.fieldName)_#(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.fieldName)_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.fieldName)_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(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.fieldName)"
|
||||
label="#(column.fieldComments)"
|
||||
>
|
||||
|
||||
<template slot-scope="scope">
|
||||
<span>
|
||||
{{ $getDictNameByValue('#(column.dictTypeCode)', scope.row.#(column.fieldName)) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
</el-table-column>
|
||||
|
||||
#else
|
||||
#if(column.izShowList == "1")
|
||||
<el-table-column
|
||||
show-overflow-tooltip
|
||||
prop="#(column.fieldName)"
|
||||
label="#(column.fieldComments)"
|
||||
></el-table-column>
|
||||
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
|
||||
<el-table-column
|
||||
show-overflow-tooltip
|
||||
fixed="right"
|
||||
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>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
#if(data.subModuleName != null && data.subModuleName != "")
|
||||
import { getList, doDelete, doDeleteAll } from "@/api/#(data.moduleName)/#(data.subModuleName)/#(data.model.tableName)Management";
|
||||
#else
|
||||
import { getList, doDelete, doDeleteAll } from "@/api/#(data.moduleName)/#(data.model.tableName)Management";
|
||||
#end
|
||||
import Edit from "./components/#(data.model.tableName)ManagementEdit";
|
||||
import { isNotNull } from "@/utils/valiargs";
|
||||
import { formateDate } from "@/utils/format";
|
||||
|
||||
export default {
|
||||
name: "#(data.model.tableName)Management",
|
||||
components: { Edit },
|
||||
data() {
|
||||
return {
|
||||
list: null,
|
||||
listLoading: true,
|
||||
layout: "total, sizes, prev, pager, next, jumper",
|
||||
total: 0,
|
||||
selectRows: "",
|
||||
elementLoadingText: "正在加载...",
|
||||
moreQueryFlag: false,
|
||||
queryForm: {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
### 代码生成器 简要2个
|
||||
#for(column : briefQueryList)
|
||||
### 字典
|
||||
#if(column.showType == "2")
|
||||
#(column.fieldName)_EQ: "",
|
||||
#else if(column.showType == "3")
|
||||
### 日期
|
||||
#(column.fieldName)_BEGIN: "",
|
||||
#(column.fieldName)_END: "",
|
||||
#else
|
||||
#if(column.queryType == "EQ" || column.queryType == "LIKE")
|
||||
#(column.fieldName)_#(column.queryType): "",
|
||||
#else if(column.queryType == "RANGE")
|
||||
#(column.fieldName)_BEGIN: "",
|
||||
#(column.fieldName)_END: "",
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
### 代码生成器 更多
|
||||
#for(column : moreQueryList)
|
||||
### 字典
|
||||
#if(column.showType == "2")
|
||||
#(column.fieldName)_EQ: "",
|
||||
#else if(column.showType == "3")
|
||||
### 日期
|
||||
#(column.fieldName)_BEGIN: "",
|
||||
#(column.fieldName)_END: "",
|
||||
#else
|
||||
#if(column.queryType == "EQ" || column.queryType == "LIKE")
|
||||
#(column.fieldName)_#(column.queryType): "",
|
||||
#else if(column.queryType == "RANGE")
|
||||
#(column.fieldName)_BEGIN: "",
|
||||
#(column.fieldName)_END: "",
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
},
|
||||
### 代码生成器 简要2个
|
||||
#for(column : briefQueryList)
|
||||
### 日期
|
||||
#if(column.showType == "3")
|
||||
#(column.fieldName)DatePicker: [],
|
||||
#end
|
||||
#end
|
||||
### 代码生成器 更多
|
||||
#for(column : moreQueryList)
|
||||
### 日期
|
||||
#if(column.showType == "3")
|
||||
#(column.fieldName)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;
|
||||
}
|
||||
}
|
||||
},
|
||||
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 : briefQueryList)
|
||||
### 日期
|
||||
#if(column.showType == "3")
|
||||
if(isNotNull(this.#(column.fieldName)DatePicker) && this.#(column.fieldName)DatePicker.length === 2){
|
||||
this.queryForm.#(column.fieldName)_BEGIN =
|
||||
this.#(column.fieldName)DatePicker.length === 0 ? "" : formateDate(this.#(column.fieldName)DatePicker[0], 'yyyy-MM-dd hh:mm:ss');
|
||||
this.queryForm.#(column.fieldName)_END =
|
||||
this.#(column.fieldName)DatePicker.length === 0 ? "" : formateDate(this.#(column.fieldName)DatePicker[1], 'yyyy-MM-dd hh:mm:ss');
|
||||
}else{
|
||||
this.queryForm.#(column.fieldName)_BEGIN = "";
|
||||
this.queryForm.#(column.fieldName)_END = "";
|
||||
} #end
|
||||
#end
|
||||
### 代码生成器 更多
|
||||
#for(column : moreQueryList)
|
||||
### 日期
|
||||
#if(column.showType == "3")
|
||||
if(isNotNull(this.#(column.fieldName)DatePicker) && this.#(column.fieldName)DatePicker.length === 2){
|
||||
this.queryForm.#(column.fieldName)_BEGIN =
|
||||
this.#(column.fieldName)DatePicker.length === 0 ? "" : formateDate(this.#(column.fieldName)DatePicker[0], 'yyyy-MM-dd hh:mm:ss');
|
||||
this.queryForm.#(column.fieldName)_END =
|
||||
this.#(column.fieldName)DatePicker.length === 0 ? "" : formateDate(this.#(column.fieldName)DatePicker[1], 'yyyy-MM-dd hh:mm:ss');
|
||||
}else{
|
||||
this.queryForm.#(column.fieldName)_BEGIN = "";
|
||||
this.queryForm.#(column.fieldName)_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>
|
@ -0,0 +1,68 @@
|
||||
/**
|
||||
* 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.gentest.user.entity;
|
||||
|
||||
import java.util.Date;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.modulars.gentest.user.entity
|
||||
* @Author: 周鹏程
|
||||
* @CreateTime: 2020-11-22 12:12:05
|
||||
* @Description: 某系统用户
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class TestUser extends BaseEntity {
|
||||
|
||||
|
||||
/** 名称 */
|
||||
private String name;
|
||||
|
||||
/** 金钱 */
|
||||
private Double money;
|
||||
|
||||
/** 年龄 */
|
||||
private Integer age;
|
||||
|
||||
/** 生日 */
|
||||
private Date birth;
|
||||
|
||||
/** 是否启用 */
|
||||
private Character izUsable;
|
||||
|
||||
|
||||
// ========================================
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** 多租户字段 */
|
||||
private String tenantId;
|
||||
|
||||
/** 逻辑删除字段 */
|
||||
private Integer deleted;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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.gentest.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.opsli.modulars.gentest.user.entity.TestUser;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.modulars.gentest.user.mapper
|
||||
* @Author: 周鹏程
|
||||
* @CreateTime: 2020-11-22 12:12:05
|
||||
* @Description: 某系统用户 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface TestUserMapper extends BaseMapper<TestUser> {
|
||||
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
<?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">
|
||||
<mapper namespace="org.opsli.modulars.gentest.user.mapper.TestUserMapper">
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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.gentest.user.service;
|
||||
|
||||
import org.opsli.core.base.service.interfaces.CrudServiceInterface;
|
||||
|
||||
|
||||
import org.opsli.modulars.gentest.user.entity.TestUser;
|
||||
import org.opsli.api.wrapper.gentest.user.TestUserModel;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.modulars.gentest.user.service
|
||||
* @Author: 周鹏程
|
||||
* @CreateTime: 2020-11-22 12:12:05
|
||||
* @Description: 某系统用户 Service
|
||||
*/
|
||||
public interface ITestUserService extends CrudServiceInterface<TestUser, TestUserModel> {
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* 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.gentest.user.service.impl;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
import org.opsli.modulars.gentest.user.entity.TestUser;
|
||||
import org.opsli.api.wrapper.gentest.user.TestUserModel;
|
||||
import org.opsli.modulars.gentest.user.service.ITestUserService;
|
||||
import org.opsli.modulars.gentest.user.mapper.TestUserMapper;
|
||||
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.modulars.gentest.user.service.impl
|
||||
* @Author: 周鹏程
|
||||
* @CreateTime: 2020-11-22 12:12:05
|
||||
* @Description: 某系统用户 Service Impl
|
||||
*/
|
||||
@Service
|
||||
public class TestUserServiceImpl extends CrudServiceImpl<TestUserMapper, TestUser, TestUserModel>
|
||||
implements ITestUserService {
|
||||
|
||||
@Autowired(required = false)
|
||||
private TestUserMapper mapper;
|
||||
|
||||
}
|
@ -0,0 +1,188 @@
|
||||
/**
|
||||
* 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.gentest.user.web;
|
||||
|
||||
import org.opsli.api.web.system.role.RoleApi;
|
||||
import org.opsli.core.base.service.interfaces.CrudServiceInterface;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.opsli.api.base.result.ResultVo;
|
||||
import org.opsli.common.annotation.ApiRestController;
|
||||
import org.opsli.common.annotation.EnableLog;
|
||||
import org.opsli.core.base.concroller.BaseRestController;
|
||||
import org.opsli.core.persistence.Page;
|
||||
import org.opsli.core.persistence.querybuilder.QueryBuilder;
|
||||
import org.opsli.core.persistence.querybuilder.WebQueryBuilder;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.opsli.modulars.gentest.user.entity.TestUser;
|
||||
import org.opsli.api.wrapper.gentest.user.TestUserModel;
|
||||
import org.opsli.modulars.gentest.user.service.ITestUserService;
|
||||
import org.opsli.api.web.gentest.user.TestUserRestApi;
|
||||
|
||||
/**
|
||||
* @BelongsProject: opsli-boot
|
||||
* @BelongsPackage: org.opsli.modulars.gentest.user.web
|
||||
* @Author: 周鹏程
|
||||
* @CreateTime: 2020-11-22 12:12:05
|
||||
* @Description: 某系统用户 Controller
|
||||
*/
|
||||
@Slf4j
|
||||
@ApiRestController("/gentest/user")
|
||||
public class TestUserRestController extends BaseRestController<TestUser, TestUserModel, ITestUserService>
|
||||
implements TestUserRestApi {
|
||||
|
||||
|
||||
/**
|
||||
* 用户 查一条
|
||||
* @param model 模型
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "获得单条用户", notes = "获得单条用户 - ID")
|
||||
@RequiresPermissions("gentest_user_select")
|
||||
@Override
|
||||
public ResultVo<TestUserModel> get(TestUserModel model) {
|
||||
// 如果系统内部调用 则直接查数据库
|
||||
if(model != null && model.getIzApi() != null && model.getIzApi()){
|
||||
model = IService.get(model);
|
||||
}
|
||||
return ResultVo.success(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户 查询分页
|
||||
* @param pageNo 当前页
|
||||
* @param pageSize 每页条数
|
||||
* @param request request
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "获得分页数据", notes = "获得分页数据 - 查询构造器")
|
||||
@RequiresPermissions("gentest_user_select")
|
||||
@Override
|
||||
public ResultVo<?> findPage(Integer pageNo, Integer pageSize, HttpServletRequest request) {
|
||||
|
||||
QueryBuilder<TestUser> queryBuilder = new WebQueryBuilder<>(TestUser.class, request.getParameterMap());
|
||||
Page<TestUser, TestUserModel> page = new Page<>(pageNo, pageSize);
|
||||
page.setQueryWrapper(queryBuilder.build());
|
||||
page = IService.findPage(page);
|
||||
|
||||
return ResultVo.success(page.getBootstrapData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户 新增
|
||||
* @param model 模型
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "新增用户数据", notes = "新增用户数据")
|
||||
@RequiresPermissions("gentest_user_insert")
|
||||
@EnableLog
|
||||
@Override
|
||||
public ResultVo<?> insert(TestUserModel model) {
|
||||
// 调用新增方法
|
||||
IService.insert(model);
|
||||
return ResultVo.success("新增用户成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户 修改
|
||||
* @param model 模型
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "修改用户数据", notes = "修改用户数据")
|
||||
@RequiresPermissions("gentest_user_update")
|
||||
@EnableLog
|
||||
@Override
|
||||
public ResultVo<?> update(TestUserModel model) {
|
||||
// 调用修改方法
|
||||
IService.update(model);
|
||||
return ResultVo.success("修改用户成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户 删除
|
||||
* @param id ID
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "删除用户数据", notes = "删除用户数据")
|
||||
@RequiresPermissions("gentest_user_update")
|
||||
@EnableLog
|
||||
@Override
|
||||
public ResultVo<?> del(String id){
|
||||
IService.delete(id);
|
||||
return ResultVo.success("删除用户成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户 批量删除
|
||||
* @param ids ID 数组
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "批量删除用户数据", notes = "批量删除用户数据")
|
||||
@RequiresPermissions("gentest_user_update")
|
||||
@EnableLog
|
||||
@Override
|
||||
public ResultVo<?> delAll(String[] ids){
|
||||
IService.deleteAll(ids);
|
||||
return ResultVo.success("批量删除用户成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户 Excel 导出
|
||||
* @param request request
|
||||
* @param response response
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "导出Excel", notes = "导出Excel")
|
||||
@RequiresPermissions("gentest_user_export")
|
||||
@EnableLog
|
||||
@Override
|
||||
public ResultVo<?> exportExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
QueryBuilder<TestUser> queryBuilder = new WebQueryBuilder<>(TestUser.class, request.getParameterMap());
|
||||
return super.excelExport(RoleApi.TITLE, queryBuilder.build(), response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户 Excel 导入
|
||||
* @param request 文件流 request
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "导入Excel", notes = "导入Excel")
|
||||
@RequiresPermissions("gentest_user_import")
|
||||
@EnableLog
|
||||
@Override
|
||||
public ResultVo<?> excelImport(MultipartHttpServletRequest request) {
|
||||
return super.excelImport(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户 Excel 下载导入模版
|
||||
* @param response response
|
||||
* @return ResultVo
|
||||
*/
|
||||
@ApiOperation(value = "导出Excel模版", notes = "导出Excel模版")
|
||||
@RequiresPermissions("gentest_user_import")
|
||||
@Override
|
||||
public ResultVo<?> importTemplate(HttpServletResponse response) {
|
||||
return super.importTemplate(RoleApi.TITLE, response);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue