Commit bcd6200d by 陶光胜

Merge branch 'developer' of…

Merge branch 'developer' of http://115.159.76.241/base_platform_enterprise/gic-enterprise-base into developer
parents 9994ee5a 023869ff
...@@ -86,7 +86,7 @@ public class AuthInterceptor extends HandlerInterceptorAdapter { ...@@ -86,7 +86,7 @@ public class AuthInterceptor extends HandlerInterceptorAdapter {
if (ignoreUriAfterLoginMap.containsKey(uri)) { if (ignoreUriAfterLoginMap.containsKey(uri)) {
return true; return true;
} }
//增删改,即操作项类型的操作,需要 获取操作模块,一级、二级的ID和名称 //接口调用,操作项类型的操作,需要 获取操作模块,一级、二级的ID和名称
if (isOperationItemRequest) { if (isOperationItemRequest) {
List<MenuInfo> menuInfoList = userDetail.getMenuInfoList(); List<MenuInfo> menuInfoList = userDetail.getMenuInfoList();
Map<String, MenuInfo> moduleUrlMap = userDetail.getModuleUrlMap(); Map<String, MenuInfo> moduleUrlMap = userDetail.getModuleUrlMap();
...@@ -113,22 +113,31 @@ public class AuthInterceptor extends HandlerInterceptorAdapter { ...@@ -113,22 +113,31 @@ public class AuthInterceptor extends HandlerInterceptorAdapter {
String secondLevelMenuName = "无"; String secondLevelMenuName = "无";
int firstLevelMenuId; int firstLevelMenuId;
String firstLevelMenuName; String firstLevelMenuName;
//用于下载文件,跳转到频道页的地址
String secondLevelUrl = "https://four.gicdev.com";
//如果是第二级的 //如果是第二级的
if (menuInfo.getLevel().intValue() == 2) { if (menuInfo.getLevel().intValue() == 2) {
secondLevelMenuId = tempMap.get(temp.toString()).getMenuId(); MenuInfo secondMenuInfo = tempMap.get(temp.toString());
secondLevelMenuName = tempMap.get(temp.toString()).getMenuName(); secondLevelMenuId = secondMenuInfo.getMenuId();
secondLevelMenuName = secondMenuInfo.getMenuName();
secondLevelUrl = secondLevelUrl + secondMenuInfo.getProjectUrlForWeb() + secondMenuInfo.getMenuUrl();
//获取第一层级的页面 //获取第一层级的页面
temp = getOperationModule(tempMap.get(temp.toString()).getMenuId(), tempMap); temp = getOperationModule(secondMenuInfo.getMenuId(), tempMap);
firstLevelMenuId = tempMap.get(temp.toString()).getMenuId(); firstLevelMenuId = tempMap.get(temp.toString()).getMenuId();
firstLevelMenuName = tempMap.get(temp.toString()).getMenuName(); firstLevelMenuName = tempMap.get(temp.toString()).getMenuName();
} else { } else {
//第一级 //第一级
firstLevelMenuId = tempMap.get(temp.toString()).getMenuId(); MenuInfo firstMenuInfo = tempMap.get(temp.toString());
firstLevelMenuName = tempMap.get(temp.toString()).getMenuName(); firstLevelMenuId = firstMenuInfo.getMenuId();
secondLevelMenuId = firstMenuInfo.getMenuId();
firstLevelMenuName = firstMenuInfo.getMenuName();
secondLevelUrl = secondLevelUrl + firstMenuInfo.getProjectUrlForWeb() + firstMenuInfo.getMenuUrl();
} }
log.info("一级页面的ID和名称:{},{}", firstLevelMenuId, firstLevelMenuName); log.info("一级页面的ID和名称:{},{}", firstLevelMenuId, firstLevelMenuName);
log.info("二级页面的ID和名称:{},{}", secondLevelMenuId, secondLevelMenuName); log.info("二级页面的ID和名称:{},{}", secondLevelMenuId, secondLevelMenuName);
log.info("二级页面的地址:{}", secondLevelUrl);
request.setAttribute("moduleMenuId", secondLevelMenuId); request.setAttribute("moduleMenuId", secondLevelMenuId);
request.setAttribute("moduleMenuUrl", secondLevelUrl);
request.setAttribute("moduleMenuName", firstLevelMenuName + "-" + secondLevelMenuName); request.setAttribute("moduleMenuName", firstLevelMenuName + "-" + secondLevelMenuName);
} }
} }
......
package com.gic.enterprise.jsonSeralizer;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
public abstract class AbstractJsonSerializer extends JsonSerializer<String> {
protected abstract String serializerData(String value);
@Override
public void serialize(String o, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
if(o != null){
String result = this.serializerData(o);
jsonGenerator.writeString(result);
}
}
}
package com.gic.enterprise.jsonSeralizer;
import com.gic.enterprise.utils.UserDetail;
import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.lang3.StringUtils;
import org.redisson.api.RBucket;
import org.redisson.api.RedissonClient;
public class EncryptJsonSerializer extends AbstractJsonSerializer {
@Override
protected String serializerData(String text){
if (StringUtils.isEmpty(text)) {
return text;
}
if (ensureRiskMode()) {
// 风险模式
return text;
} else {
// 安全模式
return encrypt(text);
}
}
private boolean ensureRiskMode() {
UserDetail userDetail = UserDetailUtils.getUserDetail();
String redisKey = "enterprise:riskMode:" + userDetail.getEnterpriseId() + ":" + userDetail.getUserId();
RedissonClient redisClient = RedisUtil.getRedisClient();
RBucket<Object> bucket = redisClient.getBucket(redisKey);
return bucket.get() != null;
}
private String encrypt(String data) {
if (StringUtils.isBlank(data)) {
return data;
}
//手机号或者会员卡号 第5-8位用*代替
int length = data.length();
if (length > 8) {
return data.substring(0, 4) + "****" + data.substring(8);
} else if (length > 4) {
return data.substring(0, 4) + "****";
} else {
return "****";
}
}
}
...@@ -71,6 +71,7 @@ public class DataDownloadUtils { ...@@ -71,6 +71,7 @@ public class DataDownloadUtils {

 */ 
 */
public static Integer createDownloadReport(DownloadReport dto) { public static Integer createDownloadReport(DownloadReport dto) {
DownloadReportDTO record = EntityUtil.changeEntityNew(DownloadReportDTO.class, dto); DownloadReportDTO record = EntityUtil.changeEntityNew(DownloadReportDTO.class, dto);
LOGGER.info("服务对象是否为空:{}", dataDownloadUtils.downloadReportApiService == null);
ServiceResponse<Integer> result = dataDownloadUtils.downloadReportApiService.saveDownloadReport(record); ServiceResponse<Integer> result = dataDownloadUtils.downloadReportApiService.saveDownloadReport(record);
if (result.isSuccess()) { if (result.isSuccess()) {
return result.getResult(); return result.getResult();
......
package com.gic.download.utils; package com.gic.download.utils;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.text.SimpleDateFormat;
import java.util.Collection; import java.util.*;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -12,6 +10,7 @@ import com.gic.download.constants.ExcelExtensionEnum; ...@@ -12,6 +10,7 @@ import com.gic.download.constants.ExcelExtensionEnum;
import com.gic.thirdparty.BucketNameEnum; import com.gic.thirdparty.BucketNameEnum;
import com.gic.thirdparty.FileOperateUtils; import com.gic.thirdparty.FileOperateUtils;
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.PropertyUtilsBean;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
...@@ -22,6 +21,7 @@ import org.apache.logging.log4j.Logger; ...@@ -22,6 +21,7 @@ import org.apache.logging.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class DownloadUtils { public class DownloadUtils {
private static final Logger LOGGER = LogManager.getLogger(DownloadUtils.class); private static final Logger LOGGER = LogManager.getLogger(DownloadUtils.class);
...@@ -51,9 +51,31 @@ public class DownloadUtils { ...@@ -51,9 +51,31 @@ public class DownloadUtils {
* @date 2017年3月16日 上午11:45:45 * @date 2017年3月16日 上午11:45:45
*/ */
protected String convertProperty(T bean, String propertyName, Object property) { protected String convertProperty(T bean, String propertyName, Object property) {
try {
Class clazz = getPropertyType(bean, propertyName);
if (Date.class.equals(clazz)) {
//如果是日期类型
SimpleDateFormat format = new SimpleDateFormat("E MMM dd hh:mm:ss z yyyy", Locale.US);
SimpleDateFormat resultFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return resultFormat.format(format.parse(property.toString()));
}
} catch (Exception e) {
LOGGER.info("bean:" + bean + ",Property:" + propertyName + e.getMessage(), e);
return null;
}
return property == null ? "" : property.toString(); return property == null ? "" : property.toString();
} }
protected Class getPropertyType(T bean, String propertyName) {
try {
return new PropertyUtilsBean().getPropertyType(bean, propertyName);
} catch (Throwable e) {
LOGGER.info("bean:" + bean + ",Property:" + propertyName + e.getMessage(), e);
return null;
}
}
/** /**
* 分页下载属性赋值 * 分页下载属性赋值
* @param bean * @param bean
...@@ -114,6 +136,10 @@ public class DownloadUtils { ...@@ -114,6 +136,10 @@ public class DownloadUtils {
DataDownloadUtils.mkDir(new File(tempPath)); DataDownloadUtils.mkDir(new File(tempPath));
File file = new File(tempPath); File file = new File(tempPath);
//初始化数据 //初始化数据
if (fileName.length() < 3) {
//如果长度太短
fileName = fileName + "__";
}
tempFile = File.createTempFile(fileName, ExcelExtensionEnum.getExtensionByCode(excelExtensionCode), file); tempFile = File.createTempFile(fileName, ExcelExtensionEnum.getExtensionByCode(excelExtensionCode), file);
final OutputStream out = new FileOutputStream(tempFile); final OutputStream out = new FileOutputStream(tempFile);
try { try {
...@@ -122,7 +148,12 @@ public class DownloadUtils { ...@@ -122,7 +148,12 @@ public class DownloadUtils {
String extension = ExcelExtensionEnum.getExtensionByCode(excelExtensionCode); String extension = ExcelExtensionEnum.getExtensionByCode(excelExtensionCode);
// 如果是excel的后缀 // 如果是excel的后缀
if (ExcelExtensionEnum.EXCEL_2003.getExtension().equalsIgnoreCase(extension) || ExcelExtensionEnum.EXCEL_2007.getExtension().equalsIgnoreCase(extension)) { if (ExcelExtensionEnum.EXCEL_2003.getExtension().equalsIgnoreCase(extension) || ExcelExtensionEnum.EXCEL_2007.getExtension().equalsIgnoreCase(extension)) {
Workbook workbook = new HSSFWorkbook(); Workbook workbook;
if (ExcelExtensionEnum.EXCEL_2003.getExtension().equalsIgnoreCase(extension)) {
workbook = new HSSFWorkbook();
} else {
workbook = new XSSFWorkbook();
}
Sheet sheet = workbook.createSheet("sheet1"); Sheet sheet = workbook.createSheet("sheet1");
final List<Collection<String>> rows = new ArrayList<>(); final List<Collection<String>> rows = new ArrayList<>();
writer = new Writer() { writer = new Writer() {
......
...@@ -66,4 +66,45 @@ public class LogUtils { ...@@ -66,4 +66,45 @@ public class LogUtils {
} }
}); });
} }
/**
* 添加日志
* @Title: createLog

* @Description:

 * @author guojuxing
* @param content 操作内容
* @param operationObject
 操作对象
* @return void


 */
public static void createLog(String content, String operationObject, String username, Integer enterpriseId, String enterpriseName) {
UserDetail userDetail = UserDetailUtils.getUserDetail();
SystemSetLogDTO logDTO = new SystemSetLogDTO();
//操作时间
logDTO.setCreateTime(new Date());
//操作人
// logDTO.setUserId(Long.valueOf(userDetail.getUserInfo().getUserId()));
logDTO.setUserName(username);
//操作内容
logDTO.setContent(content);
//操作模块
// String moduleMenuName = (String) RequestContext.getContext().getRequest().getAttribute("moduleMenuName");
// Integer moduleMenuId = (Integer) RequestContext.getContext().getRequest().getAttribute("moduleMenuId");
// if (moduleMenuId != null) {
// logDTO.setRelationId(Long.valueOf(moduleMenuId));
// } else {
// LOGGER.info("操作模块数据有误");
// }
//操作对象
//账号(手机号)?
logDTO.setEnterpriesId(Long.valueOf(enterpriseId));
logDTO.setEnterpriseName(enterpriseName);
ExecutorPoolSingleton.getInstance().executeTask(new Runnable() {
@Override
public void run() {
LOGGER.info("添加日志了,恭喜发财。{}", JSON.toJSONString(logDTO));
logApiService.saveSystemSetLog(logDTO);
}
});
}
} }
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