📝 升级文档.
This commit is contained in:
@@ -62,10 +62,6 @@ public class CustomFileFilter {
|
||||
if (!table.isEnableCache()) {
|
||||
files.removeIf(file -> isServerCacheFile(file.getTemplatePath()));
|
||||
}
|
||||
// 不生成导出文件
|
||||
if (!table.isEnableExport()) {
|
||||
files.removeIf(file -> isExportFile(file.getTemplatePath()));
|
||||
}
|
||||
// 不生成操作日志文件
|
||||
if (!table.isEnableOperatorLog()) {
|
||||
files.removeIf(file -> isOperatorLogFile(file.getTemplatePath()));
|
||||
|
||||
@@ -73,16 +73,6 @@ public class ServerTemplate extends Template {
|
||||
return this;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 生成导出
|
||||
// *
|
||||
// * @return this
|
||||
// */
|
||||
// public ServerTemplate enableExport() {
|
||||
// table.enableExport = true;
|
||||
// return this;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 不生成单元测试
|
||||
*
|
||||
|
||||
@@ -43,11 +43,6 @@ public class Table {
|
||||
*/
|
||||
protected boolean enableUnitTest;
|
||||
|
||||
/**
|
||||
* 是否生成导出
|
||||
*/
|
||||
protected boolean enableExport;
|
||||
|
||||
/**
|
||||
* 是否可缓存
|
||||
*/
|
||||
|
||||
@@ -68,19 +68,5 @@ Authorization: {{token}}
|
||||
${httpComment} ${apiComment.batchDelete}
|
||||
DELETE {{baseUrl}}/${package.ModuleName}/${typeHyphen}/batch-delete?idList=1,2,3
|
||||
Authorization: {{token}}
|
||||
#if($meta.enableExport)
|
||||
|
||||
|
||||
${httpComment} ${apiComment.export}
|
||||
POST {{baseUrl}}/${package.ModuleName}/${typeHyphen}/export
|
||||
Content-Type: application/json
|
||||
Authorization: {{token}}
|
||||
|
||||
{
|
||||
#foreach($field in ${table.fields})
|
||||
"${field.propertyName}": ""#if($foreach.hasNext),#end
|
||||
#end
|
||||
}
|
||||
#end
|
||||
|
||||
${httpComment}
|
||||
|
||||
@@ -141,19 +141,6 @@ public class ${table.controllerName} {
|
||||
public Integer batchDelete${type}(@RequestParam("idList") List<Long> idList) {
|
||||
return ${typeLower}Service.delete${type}ByIdList(idList);
|
||||
}
|
||||
#if($meta.enableExport)
|
||||
|
||||
#if($meta.enableOperatorLog)
|
||||
@OperatorLog(${type}OperatorType.EXPORT)
|
||||
#end
|
||||
@PostMapping("/export")
|
||||
@Operation(summary = "${apiComment.export}")
|
||||
@PreAuthorize("@ss.hasPermission('${package.ModuleName}:${typeHyphen}:export')")
|
||||
public void export${type}(@Validated @RequestBody ${type}QueryRequest request,
|
||||
HttpServletResponse response) throws IOException {
|
||||
${typeLower}Service.export${type}(request, response);
|
||||
}
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,6 @@ public interface ${type}Convert {
|
||||
${type}DO to(${type}QueryRequest request);
|
||||
|
||||
${type}VO to(${type}DO domain);
|
||||
#if($meta.enableExport)
|
||||
|
||||
${type}Export toExport(${type}DO domain);
|
||||
#end
|
||||
|
||||
List<${type}VO> to(List<${type}DO> list);
|
||||
|
||||
|
||||
@@ -21,10 +21,6 @@ public class ${type}OperatorType extends InitializingOperatorTypes {
|
||||
public static final String UPDATE = "${typeHyphen}:update";
|
||||
|
||||
public static final String DELETE = "${typeHyphen}:delete";
|
||||
#if($meta.enableExport)
|
||||
|
||||
public static final String EXPORT = "${typeHyphen}:export";
|
||||
#end
|
||||
|
||||
@Override
|
||||
public OperatorType[] types() {
|
||||
@@ -32,9 +28,6 @@ public class ${type}OperatorType extends InitializingOperatorTypes {
|
||||
new OperatorType(L, CREATE, "创建$!{table.comment}"),
|
||||
new OperatorType(M, UPDATE, "更新$!{table.comment}"),
|
||||
new OperatorType(H, DELETE, "删除$!{table.comment}"),
|
||||
#if($meta.enableExport)
|
||||
new OperatorType(M, EXPORT, "导出$!{table.comment}"),
|
||||
#end
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -5,13 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
#if($meta.enableExport)
|
||||
import com.orion.office.excel.writer.exporting.ExcelExport;
|
||||
#end
|
||||
import com.orion.visor.framework.common.constant.ErrorMessage;
|
||||
#if($meta.enableExport)
|
||||
import com.orion.visor.framework.common.utils.FileNames;
|
||||
#end
|
||||
import com.orion.visor.framework.common.utils.Valid;
|
||||
#if($meta.enableCache)
|
||||
import com.orion.visor.framework.redis.core.utils.RedisMaps;
|
||||
@@ -23,18 +17,11 @@ import ${pkg}.*;
|
||||
import ${package.Entity}.${entity};
|
||||
import ${package.Mapper}.${table.mapperName};
|
||||
import ${package.Service}.${table.serviceName};
|
||||
#if($meta.enableExport)
|
||||
import com.orion.web.servlet.web.Servlets;
|
||||
#end
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
#if($meta.enableExport)
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
#end
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -54,6 +41,7 @@ public class ${table.serviceImplName} implements ${table.serviceName} {
|
||||
private ${type}DAO ${typeLower}DAO;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long create${type}(${type}CreateRequest request) {
|
||||
log.info("${type}Service-create${type} request: {}", JSON.toJSONString(request));
|
||||
// 转换
|
||||
@@ -72,6 +60,7 @@ public class ${table.serviceImplName} implements ${table.serviceName} {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer update${type}ById(${type}UpdateRequest request) {
|
||||
Long id = Valid.notNull(request.getId(), ErrorMessage.ID_MISSING);
|
||||
log.info("${type}Service-update${type}ById id: {}, request: {}", id, JSON.toJSONString(request));
|
||||
@@ -93,6 +82,7 @@ public class ${table.serviceImplName} implements ${table.serviceName} {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer update${type}(${type}QueryRequest query, ${type}UpdateRequest update) {
|
||||
log.info("${type}Service.update${type} query: {}, update: {}", JSON.toJSONString(query), JSON.toJSONString(update));
|
||||
// 条件
|
||||
@@ -179,6 +169,7 @@ public class ${table.serviceImplName} implements ${table.serviceName} {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer delete${type}ById(Long id) {
|
||||
log.info("${type}Service-delete${type}ById id: {}", id);
|
||||
// 检查数据是否存在
|
||||
@@ -195,6 +186,7 @@ public class ${table.serviceImplName} implements ${table.serviceName} {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer delete${type}ByIdList(List<Long> idList) {
|
||||
log.info("${type}Service-delete${type}ByIdList idList: {}", idList);
|
||||
int effect = ${typeLower}DAO.deleteBatchIds(idList);
|
||||
@@ -207,6 +199,7 @@ public class ${table.serviceImplName} implements ${table.serviceName} {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer delete${type}(${type}QueryRequest request) {
|
||||
log.info("${type}Service.delete${type} request: {}", JSON.toJSONString(request));
|
||||
// 条件
|
||||
@@ -220,26 +213,6 @@ public class ${table.serviceImplName} implements ${table.serviceName} {
|
||||
#end
|
||||
return effect;
|
||||
}
|
||||
#if($meta.enableExport)
|
||||
|
||||
@Override
|
||||
public void export${type}(${type}QueryRequest request, HttpServletResponse response) throws IOException {
|
||||
log.info("${type}Service.export${type} request: {}", JSON.toJSONString(request));
|
||||
// 条件
|
||||
LambdaQueryWrapper<${type}DO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
List<${type}Export> rows = ${typeLower}DAO.of(wrapper).list(${type}Convert.MAPPER::toExport);
|
||||
log.info("${type}Service.export${type} size: {}", rows.size());
|
||||
// 导出
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ExcelExport.create(${type}Export.class)
|
||||
.addRows(rows)
|
||||
.write(out)
|
||||
.close();
|
||||
// 传输
|
||||
Servlets.transfer(response, out.toByteArray(), FileNames.exportName(${type}Export.TITLE));
|
||||
}
|
||||
#end
|
||||
|
||||
/**
|
||||
* 检查对象是否存在
|
||||
|
||||
@@ -115,16 +115,5 @@ public interface ${table.serviceName} {
|
||||
* @return effect
|
||||
*/
|
||||
Integer delete${type}(${type}QueryRequest request);
|
||||
#if($meta.enableExport)
|
||||
|
||||
/**
|
||||
* ${apiComment.export}
|
||||
*
|
||||
* @param request request
|
||||
* @param response response
|
||||
* @throws IOException IOException
|
||||
*/
|
||||
void export${type}(${type}QueryRequest request, HttpServletResponse response) throws IOException;
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
@@ -14,12 +14,7 @@ VALUES
|
||||
(@MODULE_KEY_ID, 'operatorLogModule', '${package.ModuleName}:${typeHyphen}', '$!{table.comment}', '{}', @MODULE_KEY_MAX_SORT + 10, now(), now(), '1', '1', 0),
|
||||
(@TYPE_KEY_ID, 'operatorLogType', '${typeHyphen}:create', '创建$!{table.comment}', '{}', 10, now(), now(), '1', '1', 0),
|
||||
(@TYPE_KEY_ID, 'operatorLogType', '${typeHyphen}:update', '更新$!{table.comment}', '{}', 20, now(), now(), '1', '1', 0),
|
||||
#if($meta.enableExport)
|
||||
(@TYPE_KEY_ID, 'operatorLogType', '${typeHyphen}:delete', '删除$!{table.comment}', '{}', 30, now(), now(), '1', '1', 0),
|
||||
(@TYPE_KEY_ID, 'operatorLogType', '${typeHyphen}:export', '导出$!{table.comment}', '{}', 40, now(), now(), '1', '1', 0);
|
||||
#else
|
||||
(@TYPE_KEY_ID, 'operatorLogType', '${typeHyphen}:delete', '删除$!{table.comment}', '{}', 30, now(), now(), '1', '1', 0);
|
||||
#end
|
||||
#end
|
||||
|
||||
#if($dictMap.entrySet().size() > 0)
|
||||
|
||||
@@ -133,12 +133,4 @@ export function batchDelete${vue.featureEntity}(idList: Array<number>) {
|
||||
}
|
||||
});
|
||||
}
|
||||
#if($meta.enableExport)
|
||||
|
||||
/**
|
||||
* $apiComment.export
|
||||
*/
|
||||
export function export${vue.featureEntity}(request: ${vue.featureEntity}QueryRequest) {
|
||||
return axios.post('/${package.ModuleName}/${typeHyphen}/export', request);
|
||||
}
|
||||
#end
|
||||
|
||||
Reference in New Issue
Block a user