Commit 44b84151 by yuwei

项目初始化

parent 31ce94c0
...@@ -171,7 +171,7 @@ public class WordUtil { ...@@ -171,7 +171,7 @@ public class WordUtil {
* @param doc word文件流 * @param doc word文件流
* @param watermarkText 水印内容 * @param watermarkText 水印内容
*/ */
private static void insertWatermarkText(Document doc, String watermarkText) throws Exception { public void insertWatermarkText(Document doc, String watermarkText) throws Exception {
Shape watermark = new Shape(doc, ShapeType.TEXT_PLAIN_TEXT); Shape watermark = new Shape(doc, ShapeType.TEXT_PLAIN_TEXT);
watermark.setName("WaterMark"); watermark.setName("WaterMark");
watermark.getTextPath().setText(watermarkText); watermark.getTextPath().setText(watermarkText);
...@@ -195,7 +195,7 @@ public class WordUtil { ...@@ -195,7 +195,7 @@ public class WordUtil {
} }
} }
private static void insertWatermarkIntoHeader(Paragraph watermarkPara, Section sect, int headerType) throws Exception { private void insertWatermarkIntoHeader(Paragraph watermarkPara, Section sect, int headerType) throws Exception {
HeaderFooter header = sect.getHeadersFooters().getByHeaderFooterType(headerType); HeaderFooter header = sect.getHeadersFooters().getByHeaderFooterType(headerType);
if (header == null) { if (header == null) {
header = new HeaderFooter(sect.getDocument(), headerType); header = new HeaderFooter(sect.getDocument(), headerType);
......
...@@ -4,6 +4,8 @@ import cn.datax.commo.office.word.WordUtil; ...@@ -4,6 +4,8 @@ import cn.datax.commo.office.word.WordUtil;
import cn.datax.common.core.DataConstant; import cn.datax.common.core.DataConstant;
import cn.datax.common.exception.DataException; import cn.datax.common.exception.DataException;
import cn.datax.common.rabbitmq.config.RabbitMqConstant; import cn.datax.common.rabbitmq.config.RabbitMqConstant;
import cn.datax.common.utils.MD5Util;
import cn.datax.common.utils.SecurityUtil;
import cn.datax.common.utils.ThrowableUtil; import cn.datax.common.utils.ThrowableUtil;
import cn.datax.service.data.market.api.dto.*; import cn.datax.service.data.market.api.dto.*;
import cn.datax.service.data.market.api.entity.DataApiEntity; import cn.datax.service.data.market.api.entity.DataApiEntity;
...@@ -253,11 +255,14 @@ public class DataApiServiceImpl extends BaseServiceImpl<DataApiDao, DataApiEntit ...@@ -253,11 +255,14 @@ public class DataApiServiceImpl extends BaseServiceImpl<DataApiDao, DataApiEntit
DataApiEntity dataApiEntity = super.getById(id); DataApiEntity dataApiEntity = super.getById(id);
// 合并模版 // 合并模版
ClassPathResource classPathResource = new ClassPathResource("templates/api_1.0.0.docx"); ClassPathResource classPathResource = new ClassPathResource("templates/api_1.0.0.docx");
InputStream inputStream =classPathResource.getInputStream(); InputStream inputStream = classPathResource.getInputStream();
Document doc = WordUtil.getInstance().getDocument(inputStream); Document doc = WordUtil.getInstance().getDocument(inputStream);
// 提供字段 // 提供字段
String[] fieldNames = new String[] {"apiName", "apiVersion", "reqMethod", "resType", "apiUrl", "remark"}; MD5Util mt = MD5Util.getInstance();
Object[] fieldValues = new Object[] {dataApiEntity.getApiName(), dataApiEntity.getApiVersion(), dataApiEntity.getReqMethod(), dataApiEntity.getResType(), "/services/"+dataApiEntity.getApiVersion()+dataApiEntity.getApiUrl(), dataApiEntity.getRemark()}; String apiKey = mt.encode(id);
String secretkey = mt.encode(SecurityUtil.getUserId());
String[] fieldNames = new String[] {"apiName", "apiVersion", "reqMethod", "resType", "apiUrl", "remark", "apiKey", "secretkey"};
Object[] fieldValues = new Object[] {dataApiEntity.getApiName(), dataApiEntity.getApiVersion(), dataApiEntity.getReqMethod(), dataApiEntity.getResType(), "/services/"+dataApiEntity.getApiVersion()+dataApiEntity.getApiUrl(), dataApiEntity.getRemark(), apiKey, secretkey};
MailMerge mailMerge = doc.getMailMerge(); MailMerge mailMerge = doc.getMailMerge();
mailMerge.execute(fieldNames, fieldValues); mailMerge.execute(fieldNames, fieldValues);
// 请求参数 TableStart:ReqParamList TableEnd:ReqParamList // 请求参数 TableStart:ReqParamList TableEnd:ReqParamList
...@@ -296,6 +301,7 @@ public class DataApiServiceImpl extends BaseServiceImpl<DataApiDao, DataApiEntit ...@@ -296,6 +301,7 @@ public class DataApiServiceImpl extends BaseServiceImpl<DataApiDao, DataApiEntit
resParamTable.getRows().add(row); resParamTable.getRows().add(row);
} }
mailMerge.executeWithRegions(resParamTable); mailMerge.executeWithRegions(resParamTable);
WordUtil.getInstance().insertWatermarkText(doc, SecurityUtil.getUserName());
return doc; return doc;
} }
} }
...@@ -9,6 +9,7 @@ import cn.datax.common.database.constants.DbQueryProperty; ...@@ -9,6 +9,7 @@ import cn.datax.common.database.constants.DbQueryProperty;
import cn.datax.common.database.core.DbColumn; import cn.datax.common.database.core.DbColumn;
import cn.datax.common.database.core.DbTable; import cn.datax.common.database.core.DbTable;
import cn.datax.common.exception.DataException; import cn.datax.common.exception.DataException;
import cn.datax.common.utils.SecurityUtil;
import cn.datax.service.data.metadata.api.dto.DbSchema; import cn.datax.service.data.metadata.api.dto.DbSchema;
import cn.datax.service.data.metadata.api.dto.MetadataSourceDto; import cn.datax.service.data.metadata.api.dto.MetadataSourceDto;
import cn.datax.service.data.metadata.api.entity.MetadataColumnEntity; import cn.datax.service.data.metadata.api.entity.MetadataColumnEntity;
...@@ -219,7 +220,7 @@ public class MetadataSourceServiceImpl extends BaseServiceImpl<MetadataSourceDao ...@@ -219,7 +220,7 @@ public class MetadataSourceServiceImpl extends BaseServiceImpl<MetadataSourceDao
dataSet.getRelations().add(dataRelation); dataSet.getRelations().add(dataRelation);
// 合并模版 // 合并模版
ClassPathResource classPathResource = new ClassPathResource("templates/metadata_1.0.0.doc"); ClassPathResource classPathResource = new ClassPathResource("templates/metadata_1.0.0.doc");
InputStream inputStream =classPathResource.getInputStream(); InputStream inputStream = classPathResource.getInputStream();
Document doc = WordUtil.getInstance().getDocument(inputStream); Document doc = WordUtil.getInstance().getDocument(inputStream);
// 提供数据源 // 提供数据源
String[] fieldNames = new String[] {"database"}; String[] fieldNames = new String[] {"database"};
...@@ -227,6 +228,7 @@ public class MetadataSourceServiceImpl extends BaseServiceImpl<MetadataSourceDao ...@@ -227,6 +228,7 @@ public class MetadataSourceServiceImpl extends BaseServiceImpl<MetadataSourceDao
MailMerge mailMerge = doc.getMailMerge(); MailMerge mailMerge = doc.getMailMerge();
mailMerge.execute(fieldNames, fieldValues); mailMerge.execute(fieldNames, fieldValues);
mailMerge.executeWithRegions(dataSet); mailMerge.executeWithRegions(dataSet);
WordUtil.getInstance().insertWatermarkText(doc, SecurityUtil.getUserName());
return doc; return doc;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment