Commit 534f3593 by hulei

rename package

parent 73359377
package com.brilliance.isc.encry;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import org.jasypt.encryption.StringEncryptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/*
对密码进行加密和解密类
*/
@Component
@Path("/encrypt")
public class EncryptTest{
@Autowired
public StringEncryptor stringEncryptor;
@GET
@Path("/test")
public void test(){
//加密
// System.out.println(stringEncryptor.encrypt("48@01"));
// //解密
// System.out.println(stringEncryptor.decrypt("uVvi6YLLfQeD4h0glpAt8+4yRKv66EM5"));
}
}
package com.ec.resteasy.providers.exceptionmapper;
import com.brilliance.isc.exception.RestBizException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import java.io.UnsupportedEncodingException;
import java.util.Base64;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* RESTEasy全局异常封装类,返回json格式异常信息;
* 服务器端异常默认500
*
*/
@Provider
@Component
public class RestExceptionMapper implements ExceptionMapper<Exception> {
private Logger logger = LoggerFactory.getLogger(this.getClass());
private static final int NOT_ACCEPTABLE_CODE = 406;
private static final int NOT_ALLOWED_CODE = 405;
private static final int NOT_FOUND_CODE = 404;
private static final int NOT_AUTHORIZED_CODE = 401;
private static final int BAD_REQUEST_CODE = 400;
private static final int SERVER_ERROR_CODE = 500;
private static final int BUFFER_SIZE = 1024;
private static final String EXCEPTION_CALLBACK_SERIVCE_ID = "restExceptionCallbackSerivce";
private int responseStatus = SERVER_ERROR_CODE;
private String responseMessage = null;
@Context
HttpServletRequest request;
@Context
HttpServletResponse response;
boolean first = true;
public RestExceptionMapper(){
logger.info("--RestExceptionMapper()--");
}
//原构造方法加载改为第一次发生异常是初始化 by yuyong 20220218
public void init() {
if (first) {
// Configuration configuration = ConfigurationManager.getInstance().getConfiguration("ec");
// String status = configuration.getValue("http.response.error.status");
// if (StringUtils.isNotBlank(status)) {
// try {
// responseStatus = Integer.valueOf(status);
// } catch (NumberFormatException e) {
// logger.error(e);
// }
// }
// responseMessage = configuration.getValue("http.response.error.message");
// if (StringUtils.isBlank(responseMessage)) {
// responseMessage = "访问出错,请联系管理员!";
// }
first = false;
responseStatus = 200;
responseMessage = "访问出错,请联系管理员!";
}
}
/**
* 将异常信息封装为JSON格式
*/
@Override
public Response toResponse(Exception e) {
init();
logger.error("发生业务异常{}",e);
if (e instanceof BadRequestException) { // 400
return Response.status(BAD_REQUEST_CODE).type(MediaType.APPLICATION_JSON).build();
} else if (e instanceof NotAuthorizedException) { // 401
return Response.status(NOT_AUTHORIZED_CODE).type(MediaType.APPLICATION_JSON).build();
} else if (e instanceof NotFoundException) { // 404
return Response.status(NOT_FOUND_CODE).type(MediaType.APPLICATION_JSON).build();
} else if (e instanceof NotAllowedException) { // 405
return Response.status(NOT_ALLOWED_CODE).type(MediaType.APPLICATION_JSON).build();
} else if (e instanceof NotAcceptableException) { // 406
return Response.status(NOT_ACCEPTABLE_CODE).type(MediaType.APPLICATION_JSON).build();
}
// else if (e instanceof DefaultOptionsMethodException){//跨域请求时,需要允许options请求
// return ((DefaultOptionsMethodException) e).getResponse();
// }
else {
return handle(e);
}
}
/**
* 提供系统异常处理扩展接口 add by yxch
* @param e
* @return
*/
public Response handle(Exception e){
// Map<String, ISystemExceptionHandler> systemExceptionHandlerMap = SpringWebApp.appContext.getBeansOfType(ISystemExceptionHandler.class);
// if(!ObjectUtils.isEmpty(systemExceptionHandlerMap)){
// try {
// for (Entry<String, ISystemExceptionHandler> entry : systemExceptionHandlerMap.entrySet()) {
// ISystemExceptionHandler systemExceptionHandler = entry.getValue();
// if(logger.isDebugEnabled()){
// logger.debug("调用系统级异常处理类:【"+systemExceptionHandler+"】");
// }
// return (Response)systemExceptionHandler.handle(e);
// }
// } catch (Exception ee) {
// logger.error("调用系统级异常处理类异常",ee);
// if(logger.isDebugEnabled()){
// logger.debug("进行默认系统级异常处理");
// }
// return coreSystemExceptionHandler(ee);
// }
// }
return coreSystemExceptionHandler(e);
}
public Response coreSystemExceptionHandler(Exception e){
//新增异常处理接口,返回自定义异常信息 by yuyong 20220411
// IRestExceptionCallbackSerivce callbackService =
// (IRestExceptionCallbackSerivce)SpringWebApp.instance.getBean(EXCEPTION_CALLBACK_SERIVCE_ID);
// if (callbackService != null) {
// return callbackService.handlerException(e);
// }
//-----------end
if(checkEdspFlag()) {
return handlerEdspHeader(buildErrorMsg(e));
}
return Response.status(responseStatus).entity(buildErrorMsg(e)).header("nonEncrypt4Response", "true").type(MediaType.APPLICATION_JSON).build();
}
//添加了响应头 errorcode,errorMsg
public Response handlerEdspHeader(RestErrorMsg errmsg) {
String edspbase64="";
try {
edspbase64 = Base64.getEncoder().encodeToString(errmsg.getErrorMsg().toString().getBytes("utf-8"));
} catch (UnsupportedEncodingException e1) {
logger.error("base64加密异常!",e1);
}
if(edspbase64.length()>BUFFER_SIZE){
edspbase64 = "";
}
return Response.status(responseStatus).entity(errmsg).header("nonEncrypt4Response", "true")
.header("errorcode", errmsg.getErrorCode()).header("errorMsg",edspbase64)
.type(MediaType.APPLICATION_JSON).build();
}
public boolean checkEdspFlag() {
// Configuration configuration = ConfigurationManager.getInstance().getConfiguration("edsp");
// boolean edsp = configuration != null && Boolean.valueOf(configuration.getValue("edspFlag"));
// return edsp;
return false;
}
/**
* 拼返回的JSON串并记录日志
*
* @param e
* @return
*/
private RestErrorMsg buildErrorMsg(Exception e) {
String errorCode = null;
String errorMsg = null;
if (e instanceof RestBizException) {
errorCode = ((RestBizException) e).getCode();
errorMsg = ((RestBizException) e).getMessage();
if (errorMsg == null) {
logger.error("系统处理异常!", e);
errorMsg = responseMessage;
}
}
else {
// 未预期的异常打印日志
logger.error("系统处理异常!", e);
//尝试返回更明确的信息 by yuyong 20180821
errorCode = "ERR9999";
errorMsg = e.getMessage();
if (errorMsg == null && e.getCause() != null) {
errorMsg = e.getCause().getMessage();
}
if (errorMsg == null) {
errorMsg = responseMessage;
}
}
String traceid=response.getHeader("trace_id");
logger.info("traceid is{}",traceid);
errorMsg= String.format("%s|追踪流水号:[%s]",errorMsg,traceid);
// errorMsg = handlerMessage(errorMsg);
return new RestErrorMsg(errorCode, errorMsg);
}
private String handlerMessage(String errorMsg) {
String regex = "([a-z]+\\.){2,}";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(errorMsg);
boolean isMatch = m.find();
if (isMatch) {
//qc114080 20201125
int start = errorMsg.indexOf("RestBizException:");
if (start != -1) {
errorMsg = errorMsg.substring(start + 17);
int end = errorMsg.indexOf("[");
if (end != -1) {
errorMsg = errorMsg.substring(0, end);
}
}else{
errorMsg = responseMessage;
}
}
//主要用于url异常时,不展示脚本标签,可能后续还需要添加其他的 by yuyong 20200513
errorMsg = errorMsg.replaceAll("script", "");
// 异常信息去掉ip显示 by jfy 20220609
int index = errorMsg.indexOf("http://");
if(index != -1){
String errMsg = errorMsg;
errMsg = errMsg.substring(index+7,errorMsg.length());
String[] split = errMsg.split("/");
if(split != null && split.length > 1){
errMsg = "http://" + split[0];
}
errorMsg = errorMsg.replaceAll(errMsg, "");
}
return errorMsg;
}
private class RestErrorMsg {
private String errorCode;
private String errorMsg;
public RestErrorMsg(String errorCode, String errorMsg) {
this.errorCode = errorCode;
this.errorMsg = errorMsg;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
}
}
server: server:
port: 28090 port: 38096
--- ---
database_type: oracle database_type: oracle
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<Configuration status="OFF"> <Configuration status="OFF">
<Properties> <Properties>
<!--应用名称--> <!--应用名称-->
<Property name="APP_NAME" value="${sys:appName:-isc-funds}"/> <Property name="APP_NAME" value="${sys:appName:-ISC-FUNDS}"/>
<!--POD名称--> <!--POD名称-->
<Property name="POD_NAME" value="${sys:MY_POD_NAME:-default}"/> <Property name="POD_NAME" value="${sys:MY_POD_NAME:-default}"/>
<!-- 日志级别 --> <!-- 日志级别 -->
......
package com.brilliance.isc.common.exception;
import com.brilliance.isc.constant.ErrorCode;
import com.brilliance.isc.exception.RestBizException;
public class FundsServiceException extends RestBizException {
public FundsServiceException(String errorMsg) {
super(ErrorCode.REMIT_SERVER_ERROR, errorMsg);
}
}
package com.brilliance.isc.basesel.ftdsel.resource; package com.brilliance.isc.funds.basesel.ftdsel.resource;
import com.brilliance.isc.basesel.ftdsel.service.FtdselService; import com.brilliance.isc.funds.basesel.ftdsel.service.FtdselService;
import com.brilliance.isc.funds.vo.FtdVo; import com.brilliance.isc.funds.vo.FtdVo;
import com.brilliance.isc.vo.ResponseSet; import com.brilliance.isc.vo.ResponseSet;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
......
package com.brilliance.isc.basesel.ftdsel.service; package com.brilliance.isc.funds.basesel.ftdsel.service;
import com.brilliance.isc.funds.bo.Ftd; import com.brilliance.isc.funds.bo.Ftd;
import com.brilliance.isc.funds.vo.FtdVo; import com.brilliance.isc.funds.vo.FtdVo;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
......
package com.brilliance.isc.basesel.ftdsel.service.impl; package com.brilliance.isc.funds.basesel.ftdsel.service.impl;
import com.brilliance.isc.basesel.ftdsel.service.FtdselService; import com.brilliance.isc.funds.basesel.ftdsel.service.FtdselService;
import com.brilliance.isc.funds.bo.Ftd; import com.brilliance.isc.funds.bo.Ftd;
import com.brilliance.isc.funds.vo.FtdVo; import com.brilliance.isc.funds.vo.FtdVo;
import com.brilliance.isc.mda.dao.FtdselMapper; import com.brilliance.isc.funds.mapper.FtdselMapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
......
package com.brilliance.isc.basesel.fxdsel.resource; package com.brilliance.isc.funds.basesel.fxdsel.resource;
import com.brilliance.isc.basesel.fxdsel.service.FxdselService; import com.brilliance.isc.funds.basesel.fxdsel.service.FxdselService;
import com.brilliance.isc.vo.ResponseSet; import com.brilliance.isc.vo.ResponseSet;
import com.brilliance.isc.funds.vo.FxdVo; import com.brilliance.isc.funds.vo.FxdVo;
......
package com.brilliance.isc.basesel.fxdsel.service; package com.brilliance.isc.funds.basesel.fxdsel.service;
import com.brilliance.isc.funds.bo.Fxd; import com.brilliance.isc.funds.bo.Fxd;
import com.brilliance.isc.funds.vo.FxdVo; import com.brilliance.isc.funds.vo.FxdVo;
......
package com.brilliance.isc.basesel.fxdsel.service.impl; package com.brilliance.isc.funds.basesel.fxdsel.service.impl;
import com.brilliance.isc.funds.basesel.fxdsel.service.FxdselService;
import com.brilliance.isc.funds.bo.Fxd; import com.brilliance.isc.funds.bo.Fxd;
import com.brilliance.isc.mda.dao.FxdselMapper; import com.brilliance.isc.funds.mapper.FxdselMapper;
import com.brilliance.isc.funds.vo.FxdVo; import com.brilliance.isc.funds.vo.FxdVo;
import com.brilliance.isc.basesel.fxdsel.service.FxdselService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
......
<?xml version="1.0" encoding="UTF-8" ?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.brilliance.isc.mda.dao.FtdselMapper"> <mapper namespace="com.brilliance.isc.funds.mapper.FtdselMapper">
<resultMap id="BaseResultMap" type="com.brilliance.isc.funds.bo.Ftd"> <resultMap id="BaseResultMap" type="com.brilliance.isc.funds.bo.Ftd">
<result property="inr" column="inr" jdbcType="VARCHAR"/> <result property="inr" column="inr" jdbcType="VARCHAR"/>
......
<?xml version="1.0" encoding="UTF-8" ?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.brilliance.isc.mda.dao.FxdselMapper"> <mapper namespace="com.brilliance.isc.funds.mapper.FxdselMapper">
<resultMap id="BaseResultMap" type="com.brilliance.isc.funds.bo.Fxd"> <resultMap id="BaseResultMap" type="com.brilliance.isc.funds.bo.Fxd">
<result property="inr" column="inr" jdbcType="VARCHAR"/> <result property="inr" column="inr" jdbcType="VARCHAR"/>
......
package com.brilliance.isc.mda.dao; package com.brilliance.isc.funds.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.brilliance.isc.funds.bo.Ftd; import com.brilliance.isc.funds.bo.Ftd;
......
package com.brilliance.isc.mda.dao; package com.brilliance.isc.funds.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
......
...@@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; ...@@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
@Data @Data
......
package com.brilliance.isc.funds.vo; package com.brilliance.isc.funds.vo;
import com.brilliance.isc.common.vo.PageVo; import com.brilliance.isc.common.vo.PageVo;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.apache.camel.language.bean.Bean;
import org.apache.catalina.User;
import java.util.Date; import java.util.Date;
import java.math.BigDecimal;
import java.util.List;
/** /**
* @description: * @description:
......
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