Commit fa165dab authored by eddie.woo's avatar eddie.woo

merge

parent b182ecef
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.connectionURL=jdbc:mysql://10.157.107.89:3306/tax_longi?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
jdbc.connectionURL=jdbc:mysql://10.157.107.89:3306/tax_admin?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
jdbc.userId=root
jdbc.password=tax@Admin2018
......@@ -25,7 +25,7 @@ public class SwaggerConfig {
@Bean
public Docket petApi() {
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
.apis(RequestHandlerSelectors.basePackage("pwc.taxtech.atms.controller.*"))
.apis(RequestHandlerSelectors.basePackage("pwc.taxtech.atms.controller"))
.paths(PathSelectors.regex("/api/.*")).build()
.globalOperationParameters(buildGlobalOperationParameters());
......
package pwc.taxtech.atms.common;
import javax.servlet.http.HttpServletRequest;
import org.nutz.lang.Lang;
import org.nutz.lang.Strings;
import org.slf4j.Logger;
......@@ -14,11 +12,12 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.WebAuthenticationDetails;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import pwc.taxtech.atms.dao.UserMapper;
import pwc.taxtech.atms.entitiy.User;
import pwc.taxtech.atms.exception.ApplicationException;
import pwc.taxtech.atms.security.JwtUser;
import javax.servlet.http.HttpServletRequest;
@Component
public class AuthUserHelperImpl implements AuditorAware<String>, AuthUserHelper {
private static Logger logger = LoggerFactory.getLogger(AuthUserHelperImpl.class);
......
package pwc.taxtech.atms.common;
public class ServiceException extends RuntimeException{
public ServiceException() {
}
public ServiceException(String message) {
super(message);
}
public ServiceException(String message, Throwable cause) {
super(message, cause);
}
public ServiceException(Throwable cause) {
super(cause);
}
public ServiceException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
package pwc.taxtech.atms.common.util;
import com.esotericsoftware.reflectasm.FieldAccess;
import com.esotericsoftware.reflectasm.MethodAccess;
import org.apache.commons.lang3.StringUtils;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
@Component
public class BeanUtil {
......@@ -29,22 +32,23 @@ public class BeanUtil {
}
MethodAccess targetMa = getMethodAccess(targetObject.getClass());
FieldAccess targetFa = getFieldAccess(targetObject.getClass());
Field[] targetFields = targetFa.getFields();
List<Field> targetFieldList = getFieldList(targetObject.getClass());
MethodAccess sourceMa = getMethodAccess(sourceObject.getClass());
FieldAccess sourceFa = getFieldAccess(sourceObject.getClass());
for (Field field : targetFields) {
List<Field> sourceFieldList = getFieldList(sourceObject.getClass());
for (Field field : targetFieldList) {
String name = field.getName();
try {
sourceFa.getIndex(name);
} catch (Exception e) {
if (sourceFieldList.stream().noneMatch(x -> StringUtils.equals(x.getName(), name))) {
//不包含此属性 跳过
continue;
}
String upperName = upperCaseFirstChar(name);
targetMa.invoke(targetObject, PREFIX_SET + upperName,
sourceMa.invoke(sourceObject, PREFIX_GET + upperName));
try {
targetMa.invoke(targetObject, PREFIX_SET + upperName,
sourceMa.invoke(sourceObject, PREFIX_GET + upperName));
} catch (Exception e) {
e.printStackTrace();
}
}
return targetObject;
}
......@@ -55,8 +59,22 @@ public class BeanUtil {
}
@Cacheable(value = "reflectCache", key = "'fa_' + #className.getName()")
public FieldAccess getFieldAccess(Class className) {
return FieldAccess.get(className);
public List<Field> getFieldList(Class className) {
List<Field> fields = new ArrayList<>();
Class nextClass = className;
while (nextClass != Object.class) {
Field[] declaredFields = nextClass.getDeclaredFields();
for (int i = 0, n = declaredFields.length; i < n; i++) {
Field field = declaredFields[i];
// 反射所有
int modifiers = field.getModifiers();
if (Modifier.isStatic(modifiers)) continue;
// if (Modifier.isPrivate(modifiers)) continue;
fields.add(field);
}
nextClass = nextClass.getSuperclass();
}
return fields;
}
......
package pwc.taxtech.atms;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.websocket.jsr356.server.ServerContainer;
import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
//import org.eclipse.jetty.server.Server;
//import org.eclipse.jetty.webapp.WebAppContext;
//import org.eclipse.jetty.websocket.jsr356.server.ServerContainer;
//import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
public class JettyLauncher {
public static void main(String[] args) {
int port = 8180;
Server server = new Server(port);
WebAppContext webAppContext = new WebAppContext("webapp", "/");
webAppContext.setDescriptor("webapp/WEB-INF/web.xml");
webAppContext.setResourceBase("src/main/webapp");
webAppContext.setDisplayName("atms-api");
webAppContext.setClassLoader(Thread.currentThread().getContextClassLoader());
webAppContext.setConfigurationDiscovered(true);
webAppContext.setParentLoaderPriority(true);
server.setHandler(webAppContext);
System.out.println(webAppContext.getContextPath());
System.out.println(webAppContext.getDescriptor());
System.out.println(webAppContext.getResourceBase());
System.out.println(webAppContext.getBaseResource());
try {
ServerContainer wscontainer = WebSocketServerContainerInitializer.configureContext(webAppContext);
// Add WebSocket endpoint to javax.websocket layer
// wscontainer.addEndpoint(MyWebSocket.class); //这行是如果需要使用websocket就加上,不需要就注释掉这行,mywebsocket是自己写的websocket服务类
server.start();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("server is start, port is " + port + "............");
// int port = 8180;
// Server server = new Server(port);
// WebAppContext webAppContext = new WebAppContext("webapp", "/");
//
// webAppContext.setDescriptor("webapp/WEB-INF/web.xml");
// webAppContext.setResourceBase("src/main/webapp");
// webAppContext.setDisplayName("atms-api");
// webAppContext.setClassLoader(Thread.currentThread().getContextClassLoader());
// webAppContext.setConfigurationDiscovered(true);
// webAppContext.setParentLoaderPriority(true);
//
//
// server.setHandler(webAppContext);
// System.out.println(webAppContext.getContextPath());
// System.out.println(webAppContext.getDescriptor());
// System.out.println(webAppContext.getResourceBase());
// System.out.println(webAppContext.getBaseResource());
//
// try {
// ServerContainer wscontainer = WebSocketServerContainerInitializer.configureContext(webAppContext);
// // Add WebSocket endpoint to javax.websocket layer
//// wscontainer.addEndpoint(MyWebSocket.class); //这行是如果需要使用websocket就加上,不需要就注释掉这行,mywebsocket是自己写的websocket服务类
//
// server.start();
// } catch (Exception e) {
// e.printStackTrace();
// }
// System.out.println("server is start, port is " + port + "............");
}
}
package pwc.taxtech.atms.security;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.junit.Test;
import org.nutz.lang.Times;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.dto.vendor.LgItemDto;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class JwtGneratorTest {
public static void main(String[] args) {
......
package pwc.taxtech.atms.service.impl;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.text.ParseException;
import pwc.taxtech.atms.CommonIT;
import pwc.taxtech.atms.constant.enums.EnumInputInvoiceType;
import pwc.taxtech.atms.constant.enums.EnumTbImportType;
import pwc.taxtech.atms.dto.input.InputInvoiceQueryDto;
import pwc.taxtech.atms.service.InvoiceManageService;
public class InvoiceManageServiceImplTest extends CommonIT{
private static final Logger logger = LoggerFactory.getLogger(InvoiceManageServiceImplTest.class);
@Autowired
private InvoiceManageService invoiceManageService;
@Test
public void testGetInputInvoiceList() {
InputInvoiceQueryDto inputInvoiceQueryDto=new InputInvoiceQueryDto();
//inputInvoiceQueryDto.setBuyerBankName("aa");
//inputInvoiceQueryDto.setAmount(amount);
// inputInvoiceQueryDto.setInvoiceDate(new Date());
// inputInvoiceQueryDto.setInvoiceEntityType(1);
// inputInvoiceQueryDto.setInvoiceNumber("11");
// inputInvoiceQueryDto.setInvoiceSourceType(1);
// inputInvoiceQueryDto.setInvoiceType(1);
// inputInvoiceQueryDto.setSellerName("bb");
// inputInvoiceQueryDto.setSerialNo("sdada");
// inputInvoiceQueryDto.setStaffId("12231");
// inputInvoiceQueryDto.setStatus(1);
// inputInvoiceQueryDto.setUploadDate(new Date());
// inputInvoiceQueryDto.setUploadType(1);
// inputInvoiceQueryDto.setAmount(new BigDecimal(10));
// CamelPagingDto camelPagingDto=new CamelPagingDto();
// camelPagingDto.setPageIndex(1);
// camelPagingDto.setPageSize(10);
// inputInvoiceQueryDto.setPagingDto(camelPagingDto);
// List<InputInvoice> list=new InvoiceManageServiceImpl().getInputInvoiceList(inputInvoiceQueryDto);
}
public static Date StrToDate(String str) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
date = format.parse(str);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
public static void main(String[] args) throws ParseException {
Date date = new SimpleDateFormat("yyyy/MM/dd").parse("2018/06/04");
System.out.println(date);
//System.out.println(StrToDate("2018/06/04"));
for (EnumTbImportType e : EnumTbImportType.values()) {
System.out.println(e.name()+":"+e.getCode());
}
for (EnumInputInvoiceType e : EnumInputInvoiceType.values()) {
System.out.println(e.name()+":"+e.getCode()+":"+e.getName());
}
}
}
......@@ -4346,8 +4346,8 @@ PWC.Loader = function () {
/// <reference path="../../app.js" />
// apiInterceptor is responsible to handle the aspect of each request and response.
webservices.factory('apiInterceptor', ['$q', 'loginContext', '$log', '$window', '$injector',
function ($q, loginContext, $log, $window, $injector) {
webservices.factory('apiInterceptor', ['$q', 'loginContext', '$log', '$window', '$injector','$cookies',
function ($q, loginContext, $log, $window, $injector,$cookies) {
'use strict';
$log.debug('apiInterceptor.ctor()...');
......@@ -4363,7 +4363,9 @@ webservices.factory('apiInterceptor', ['$q', 'loginContext', '$log', '$window',
return {
//token save to services for further usage
tokenType: tokenType,
apiToken: apiToken,
apiToken: function () {
return apiToken;
},
webApiHostUrl: webApiHostUrl,
//for vat api
vatWebApiHostUrl: vatWebApiHostUrl,
......@@ -4385,14 +4387,15 @@ webservices.factory('apiInterceptor', ['$q', 'loginContext', '$log', '$window',
}
config.withCredentials = true;
//废弃 token有效期会自动判断
// before each api call, try to ensure user account has not been expired
// otherwise, force user to login again
var $http = $injector.get('$http');
$http.get(loginContext.serverUrl + '/Account/CheckLoginStatus?_=' + (new Date).valueOf(), { isBusyRequest: true }).success(function (data) {
if (data === false) {
redirectToLogOut();
}
});
// var $http = $injector.get('$http');
// $http.get(loginContext.serverUrl + '/Account/CheckLoginStatus?_=' + (new Date).valueOf(), { isBusyRequest: false }).success(function (data) {
// if (data === false) {
// redirectToLogOut();
// }
// });
}
return config;
......@@ -4409,6 +4412,11 @@ webservices.factory('apiInterceptor', ['$q', 'loginContext', '$log', '$window',
if (response.status === 401) {
redirectToLogOut();
}
var tmpToken = response.headers('refreshToken');
if (!!tmpToken) {
apiToken = tmpToken;
$log.info('refresh token: ' + apiToken);
}
return response || $q.when(response);
},
// On response failture
......@@ -4513,12 +4521,12 @@ webservices.factory('apiConfig', ['$log', 'vatSessionService',
}
cfg.isWebApiRequest = true;
if (config && config.dbName) {//TODO:from is not allowed ,future should open (neo)
cfg.headers = { 'from': config.dbName + '@cn.pwc.com' };
if (config && config.dbName) {
cfg.headers = { 'from': config.dbName + '@cn.pwc.com' };
}
else {
if (vatSessionService.project && vatSessionService.project.dbName) {
cfg.headers = { 'from': vatSessionService.project.dbName + '@cn.pwc.com' };
cfg.headers = { 'from': vatSessionService.project.dbName + '@cn.pwc.com' };
}
}
return cfg;
......
This diff is collapsed.
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