添加提交初始代码
This commit is contained in:
parent
5f256ce508
commit
e7df2227c9
|
@ -33,6 +33,7 @@ replay_pid*
|
|||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
|
@ -78,3 +79,5 @@ $RECYCLE.BIN/
|
|||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
.idea/
|
||||
/webapp/src/test/java/
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>kangarooDataCenter</artifactId>
|
||||
<groupId>com.hzya.frame</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>application</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.hzya.frame</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,14 @@
|
|||
package com.hzya.frame.testApplication.dao;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.hzya.frame.testApplication.entity.TestApplicationEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ITestApplicationDao extends BaseMapper<TestApplicationEntity> {
|
||||
List<TestApplicationEntity> queryAll(TestApplicationEntity testApplicationEntity);
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?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">
|
||||
<mapper namespace="com.hzya.frame.testApplication.dao.ITestApplicationDao">
|
||||
|
||||
<!--通过ID获取数据 -->
|
||||
<select id="queryAll" resultType="com.hzya.frame.testApplication.entity.TestApplicationEntity">
|
||||
select * from sys_test_return
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.hzya.frame.testApplication.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
@TableName("sys_test_return")
|
||||
public class TestApplicationEntity {
|
||||
//sys_test_return
|
||||
@TableId("id")
|
||||
private String id;
|
||||
@TableField("type")
|
||||
private String type;
|
||||
@TableField("value")
|
||||
private String value;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.hzya.frame.testApplication.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.entity.JsonResultEntity;
|
||||
|
||||
public interface ITestApplicationService {
|
||||
|
||||
JsonResultEntity testApplication(JSONObject jsonObject);
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.hzya.frame.testApplication.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.entity.BaseResult;
|
||||
import com.hzya.frame.entity.JsonResultEntity;
|
||||
import com.hzya.frame.testApplication.dao.ITestApplicationDao;
|
||||
import com.hzya.frame.testApplication.entity.TestApplicationEntity;
|
||||
import com.hzya.frame.testApplication.service.ITestApplicationService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service(value = "testApplicationService")
|
||||
public class TestApplicationServiceImpl implements ITestApplicationService {
|
||||
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Resource
|
||||
private ITestApplicationDao testApplicationDao;
|
||||
|
||||
@Override
|
||||
public JsonResultEntity testApplication(JSONObject jsonObject) {
|
||||
logger.info("testApplication{}","qweqwe");
|
||||
logger.error("testApplication{},参数{}","qweqwe","12312312");
|
||||
TestApplicationEntity testApplicationEntity = new TestApplicationEntity();
|
||||
testApplicationEntity.setValue("名字");
|
||||
List<TestApplicationEntity> testApplicationEntities = testApplicationDao.queryAll(testApplicationEntity);
|
||||
return BaseResult.getSuccessMessageEntity("testApplication",testApplicationEntities);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>kangarooDataCenter</artifactId>
|
||||
<groupId>com.hzya.frame</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>core</artifactId>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>local</id> <!--本地环境-->
|
||||
<properties>
|
||||
<profile.active>local</profile.active>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>dev</id> <!--开发环境-->
|
||||
<properties>
|
||||
<profile.active>dev</profile.active>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
|
@ -0,0 +1,50 @@
|
|||
package com.hzya.frame.action;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Content
|
||||
* @Author 👻👻👻👻👻👻👻👻👻👻 gjh
|
||||
* @Date 2022-12-05 9:40
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Component
|
||||
public class ApplicationContextUtil implements ApplicationContextAware {
|
||||
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private static ApplicationContext context;
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
context = applicationContext;
|
||||
}
|
||||
public static ApplicationContext getApplicationContext(){
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过name获取 Bean
|
||||
* @param name beanName
|
||||
* @return Object
|
||||
*/
|
||||
public static Object getBeanByName(String name){
|
||||
return getApplicationContext().getBean(name);
|
||||
}
|
||||
public static <T> Map<String, T> getBeansOfType(Class beaNameClass){
|
||||
return getApplicationContext().getBeansOfType(beaNameClass);
|
||||
}
|
||||
|
||||
public static <T> T getBeanByClass(Class<T> requiredType) throws BeansException {
|
||||
return getApplicationContext().getBean(requiredType);
|
||||
}
|
||||
|
||||
public static Object getBeanByName2(String name){
|
||||
return getApplicationContext().getParentBeanFactory();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
package com.hzya.frame.entity;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
/**
|
||||
* @Content定义全局
|
||||
* @Author 👻👻👻👻👻👻👻👻👻👻 gjh
|
||||
* @Date 2022-12-06 9:54
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class BaseResult {
|
||||
|
||||
/**
|
||||
* 请求失败
|
||||
*
|
||||
* @param message 提示信息
|
||||
* @return
|
||||
*/
|
||||
public static JsonResultEntity getFailureMessageEntity(String message) {
|
||||
return new JsonResultEntity(message, false,"500");
|
||||
}
|
||||
/**
|
||||
* 请求失败
|
||||
*
|
||||
* @param message 提示信息
|
||||
* @return
|
||||
*/
|
||||
public static JsonResultEntity getFailureMessageEntity(String message, Object mo) {
|
||||
return new JsonResultEntity(message,false,"500", mo);
|
||||
}
|
||||
/***
|
||||
* @Content:请求失败
|
||||
* @Author 👻👻👻👻👻👻👻👻 gjh
|
||||
* @Date 2022-12-06 11:00
|
||||
* @Param [message, type, status, mo]
|
||||
* @return com.hzya.frame.web.entity.JsonResultEntity
|
||||
**/
|
||||
public static JsonResultEntity getFailureMessageEntity(String message, String status) {
|
||||
return new JsonResultEntity(message, false, status);
|
||||
}
|
||||
/***
|
||||
* @Content:请求失败
|
||||
* @Author 👻👻👻👻👻👻👻👻 gjh
|
||||
* @Date 2022-12-06 11:00
|
||||
* @Param [message, type, status, mo]
|
||||
* @return com.hzya.frame.web.entity.JsonResultEntity
|
||||
**/
|
||||
public static JsonResultEntity getFailureMessageEntity(String message, String status,Object mo) {
|
||||
return new JsonResultEntity(message, false, status,mo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求成功
|
||||
*
|
||||
* @param message 提示消息
|
||||
* @return
|
||||
*/
|
||||
public static JsonResultEntity getSuccessMessageEntity(String message) {
|
||||
return new JsonResultEntity(message,true,"200");
|
||||
}
|
||||
/**
|
||||
* 请求成功
|
||||
*
|
||||
* @param type 类型
|
||||
* @param message 提示消息
|
||||
* @param mo 返回对象
|
||||
* @return
|
||||
*/
|
||||
public static String getSuccessMessageEntityByStringResult(String message, String type, Object mo) {
|
||||
return JSON.toJSONString(new JsonResultEntity(message, true,type, mo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求成功
|
||||
*
|
||||
* @param message 提示消息
|
||||
* @return
|
||||
*/
|
||||
public static String getSuccessMessageEntityByStringResult(String message) {
|
||||
return JSON.toJSONString( new JsonResultEntity( message,true));
|
||||
}
|
||||
|
||||
/****
|
||||
* @Content: 返回失败结果,返回的是字符串格式
|
||||
* @Author 👻👻👻👻👻👻👻👻 gjh
|
||||
* @Date 2020-11-23 18:41
|
||||
* @Param [message, type]
|
||||
* @return java.lang.String
|
||||
**/
|
||||
public static String getFailureMessageEntityByString(String message) {
|
||||
return JSON.toJSONString(new JsonResultEntity( message,false));
|
||||
}
|
||||
/**
|
||||
* 请求失败
|
||||
*
|
||||
* @param type 类型
|
||||
* @param message 提示信息
|
||||
* @return
|
||||
*/
|
||||
public static String getFailureMessageEntityByString(String message, String type, Object mo) {
|
||||
return JSON.toJSONString(new JsonResultEntity(message,false , type, mo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求成功
|
||||
* @return
|
||||
*/
|
||||
public static JsonResultEntity getSuccessMessageEntity(Object obj) {
|
||||
return new JsonResultEntity("成功",true,"200" ,obj);
|
||||
}
|
||||
public static JsonResultEntity getSuccessMessageEntity(String message, Object mo) {
|
||||
return new JsonResultEntity(message,true,"200" ,mo);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package com.hzya.frame.entity;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 郭军辉
|
||||
* 2016年12月14日下午5:21:35
|
||||
*/
|
||||
public class JsonResultEntity {
|
||||
/** 提示信息 */
|
||||
private String msg;
|
||||
/** 返回类型 */
|
||||
private String type;
|
||||
/** 是否成功 true成功 false失败 */
|
||||
private boolean flag;
|
||||
/** 状态码*/
|
||||
private String status;
|
||||
/** request 域放的对象 */
|
||||
private Object attribute;
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean isFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setFlag(boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public Object getAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
|
||||
public void setAttribute(Object attribute) {
|
||||
this.attribute = attribute;
|
||||
}
|
||||
|
||||
public JsonResultEntity(String msg, boolean flag, Object attribute) {
|
||||
super();
|
||||
this.msg = msg;
|
||||
this.flag = flag;
|
||||
this.attribute = attribute;
|
||||
}
|
||||
|
||||
public JsonResultEntity(String msg, boolean flag, String status) {
|
||||
this.msg = msg;
|
||||
this.flag = flag;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public JsonResultEntity(String msg, boolean flag, String status, Object attribute) {
|
||||
this.msg = msg;
|
||||
this.flag = flag;
|
||||
this.status = status;
|
||||
this.attribute = attribute;
|
||||
}
|
||||
|
||||
public JsonResultEntity(String msg, boolean flag) {
|
||||
super();
|
||||
this.msg = msg;
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public JsonResultEntity() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.hzya.frame.exception;
|
||||
|
||||
/**
|
||||
* @Auther: xiang2lin
|
||||
* @Date: 2020/3/24 08:43
|
||||
* 异常类,业务代码全部抛出这个异常
|
||||
*/
|
||||
public class BaseSystemException extends RuntimeException {
|
||||
public BaseSystemException(String message) {
|
||||
super(message);
|
||||
}
|
||||
public BaseSystemException(String message, Exception e) {
|
||||
super(message,e);
|
||||
}
|
||||
|
||||
public BaseSystemException(Exception ex) {
|
||||
super(ex);
|
||||
}
|
||||
|
||||
public BaseSystemException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public BaseSystemException(Throwable throwable) {
|
||||
super(throwable);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.hzya.frame.test.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.hzya.frame.test.entity.TestEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ITestDao extends BaseMapper<TestEntity> {
|
||||
List<TestEntity> queryAll(TestEntity testEntity);
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?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">
|
||||
<mapper namespace="com.hzya.frame.test.dao.ITestDao">
|
||||
|
||||
|
||||
<!--通过ID获取数据 -->
|
||||
<select id="queryAll" resultType="com.hzya.frame.test.entity.TestEntity">
|
||||
select * from sys_test_return
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.hzya.frame.test.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
@TableName("sys_test_return")
|
||||
public class TestEntity {
|
||||
//sys_test_return
|
||||
@TableId("id")
|
||||
private String id;
|
||||
@TableField("type")
|
||||
private String type;
|
||||
@TableField("value")
|
||||
private String value;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.hzya.frame.test.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.entity.JsonResultEntity;
|
||||
|
||||
public interface ITestService {
|
||||
|
||||
|
||||
JsonResultEntity testCore(JSONObject jsonObject);
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.hzya.frame.test.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.entity.BaseResult;
|
||||
import com.hzya.frame.entity.JsonResultEntity;
|
||||
import com.hzya.frame.test.dao.ITestDao;
|
||||
import com.hzya.frame.test.entity.TestEntity;
|
||||
import com.hzya.frame.test.service.ITestService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service(value = "testService")
|
||||
public class TestServiceImpl implements ITestService {
|
||||
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Resource
|
||||
private ITestDao testDao;
|
||||
@Override
|
||||
public JsonResultEntity testCore(JSONObject jsonObject) {
|
||||
logger.info("testCore");
|
||||
logger.error("testCore");
|
||||
TestEntity testEntity = new TestEntity();
|
||||
testEntity.setValue("名字");
|
||||
List<TestEntity> testEntityList = testDao.queryAll(testEntity);
|
||||
return BaseResult.getSuccessMessageEntity("testCore",testEntityList);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.hzya.frame.unifiedEntry.service;
|
||||
|
||||
import com.hzya.frame.entity.JsonResultEntity;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public interface IUnifiedEntryService {
|
||||
|
||||
/**
|
||||
* @Description 请求统一入口
|
||||
**/
|
||||
JsonResultEntity doBusiness(ServletRequest servletRequest, ServletResponse servletResponse) throws InvocationTargetException, IllegalAccessException;
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
package com.hzya.frame.unifiedEntry.service.impl;
|
||||
|
||||
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import com.hzya.frame.action.ApplicationContextUtil;
|
||||
import com.hzya.frame.entity.BaseResult;
|
||||
import com.hzya.frame.entity.JsonResultEntity;
|
||||
import com.hzya.frame.exception.BaseSystemException;
|
||||
import com.hzya.frame.unifiedEntry.service.IUnifiedEntryService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@Service(value = "unifiedEntryService")
|
||||
public class UnifiedEntryServiceImpl implements IUnifiedEntryService {
|
||||
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Override
|
||||
public JsonResultEntity doBusiness(ServletRequest servletRequest, ServletResponse servletResponse) throws InvocationTargetException, IllegalAccessException {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||
String method = request.getMethod();
|
||||
//tailuo 要访问的Bean名称
|
||||
String service = request.getHeader("tl");
|
||||
//数据库表名称对于缓存的key
|
||||
String tableKey = request.getHeader("as");
|
||||
//bean方法
|
||||
String serviceMethod = request.getHeader("dj");
|
||||
/** 根据调用的 serviceMethod 获取相关table名称*/
|
||||
//String tableName = serviceMethodCache.get(tableKey);
|
||||
//
|
||||
//if (ObjectUtils.isEmpty(tableName)) {
|
||||
// throw new BaseSystemException("根据tableKey获取tableName失败!未获取到数据!请检查参数tableKey。");
|
||||
//}
|
||||
String body = ServletUtil.getBody(servletRequest);
|
||||
//获取类
|
||||
Object object = null;
|
||||
try {
|
||||
object = ApplicationContextUtil.getBeanByName(service);
|
||||
} catch (SecurityException e) {
|
||||
return BaseResult.getFailureMessageEntity(service + "未找到");
|
||||
}
|
||||
//获取类下面的方法
|
||||
Method[] methods = object.getClass().getMethods();
|
||||
logger.info("methodsLength:" + methods.length);
|
||||
if (methods == null || methods.length == 0) {
|
||||
logger.info("当前methods:" + methods + "methodsLength = " + methods.length);
|
||||
|
||||
return BaseResult.getFailureMessageEntity(service + "未找到" + serviceMethod + "方法");
|
||||
} else {
|
||||
logger.info("当前methods222222:" + methods + "methodsLength = " + methods.length);
|
||||
|
||||
}
|
||||
for (Method m : methods) {
|
||||
logger.info("当前mnAME:" + m.getName() + " :serviceMethod = " + serviceMethod.trim());
|
||||
|
||||
if (null != m) {
|
||||
if (m.getName().equals(serviceMethod.trim())) {
|
||||
if (m.getName().startsWith("thirdInterface")) {//TODO 后续可能要加强校验规则
|
||||
logger.info("第三方接口,不校验是否登陆");
|
||||
} else if (!"doLogin".equals(m.getName())) {
|
||||
try {
|
||||
//TODO 暂时先不校验
|
||||
//StpUtil.checkLogin();
|
||||
}catch (NotLoginException e){
|
||||
logger.error("token无效");
|
||||
return BaseResult.getFailureMessageEntity("token无效");
|
||||
}
|
||||
}
|
||||
logger.info("m.getNameEquals成功");
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
if (!ObjectUtils.isEmpty(body)) {
|
||||
jsonObject.put("jsonStr", body);
|
||||
}
|
||||
//jsonObject.put("tableName", tableName);
|
||||
|
||||
JsonResultEntity jsonResultEntity;
|
||||
try {
|
||||
logger.info("invoke开始>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
||||
logger.info("请求的参数:jsonObject:" + jsonObject.toJSONString());
|
||||
jsonResultEntity = (JsonResultEntity) m.invoke(object, jsonObject);
|
||||
if (jsonResultEntity != null) {
|
||||
jsonResultEntity.setType(serviceMethod);
|
||||
}
|
||||
logger.info("invoke结束>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
||||
return jsonResultEntity;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("METHOD doBusiness invokeException", e);
|
||||
if (e instanceof InvocationTargetException) {
|
||||
Throwable targetException = ((InvocationTargetException) e).getTargetException();
|
||||
if (targetException instanceof BaseSystemException) {
|
||||
throw new BaseSystemException(targetException.getMessage());
|
||||
} else {
|
||||
logger.info("METHOD doBusiness :", e);
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return BaseResult.getFailureMessageEntity(service + "未找到" + serviceMethod + "方法");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
########################开发环境#######################
|
||||
logging:
|
||||
#日志级别 指定目录级别
|
||||
level:
|
||||
root: INFO
|
|
@ -0,0 +1,5 @@
|
|||
#######################本地环境#######################
|
||||
logging:
|
||||
#日志级别 指定目录级别
|
||||
level:
|
||||
root: error
|
|
@ -0,0 +1,47 @@
|
|||
server:
|
||||
port: 9999
|
||||
servlet:
|
||||
context-path: /kangarooDataCenter
|
||||
localIP: 127.0.0.1
|
||||
spring:
|
||||
mvc:
|
||||
pathmatch:
|
||||
use-suffix-pattern: true
|
||||
profiles:
|
||||
# active: @profileActive@
|
||||
active: @profile.active@
|
||||
# active: dev
|
||||
servlet:
|
||||
multipart:
|
||||
enabled: true
|
||||
#单个文件的大小
|
||||
max-file-size: 500MB
|
||||
#单次请求的文件的总大小
|
||||
max-request-size: 550MB
|
||||
# 默认数据源设置
|
||||
datasource:
|
||||
dynamic:
|
||||
primary: master #设置默认的数据源或者数据源组,默认值即为master
|
||||
strict: true #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:mysql://hzya.ufyct.com:9096/businesscenter?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowLoadLocalInfile=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=30000&socketTimeout=30000&autoReconnectForPools=true
|
||||
username: root
|
||||
password: hzya1314
|
||||
driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置
|
||||
|
||||
logging:
|
||||
#日志配置路径
|
||||
config: classpath:logback-spring.xml
|
||||
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath:/com/hzya/frame/**/dao/*.xml
|
||||
type-aliases-package: com.hzya.frame.*.entity;
|
||||
global-config:
|
||||
id-type: 3
|
||||
db-column-underline: true
|
||||
field-strategy: 2
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
map-underscore-to-camel-case: false
|
||||
call-setters-on-nulls: true
|
|
@ -0,0 +1,23 @@
|
|||
${AnsiColor.BRIGHT_YELLOW}
|
||||
|
||||
|
||||
_ooOoo_
|
||||
o8888888o
|
||||
88" . "88
|
||||
(| -_- |)
|
||||
O\ = /O
|
||||
____/`---'\____
|
||||
.' \\| |// `.
|
||||
/ \\||| : |||// \
|
||||
/ _||||| -:- |||||- \
|
||||
| | \\\ - /// | |
|
||||
| \_| ''\---/'' | |
|
||||
\ .-\__ `-` ___/-. /
|
||||
___`. .' /--.--\ `. . __
|
||||
."" '< `.___\_<|>_/___.' >'"".
|
||||
| | : `- \`.;`\ _ /`;.`/ - ` : | |
|
||||
\ \ `-. \_ __\ /__ _/ .-` / /
|
||||
======`-.____`-.___\_____/___.-`____.-'======
|
||||
`=---='
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// 佛祖保佑 永不宕机 永无BUG //
|
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration >
|
||||
<!-- 彩色日志(IDE下载插件才可以生效) -->
|
||||
<!-- 彩色日志依赖的渲染类 -->
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
|
||||
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
|
||||
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
|
||||
<!-- 彩色日志格式 -->
|
||||
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%1p}) %clr(${PID:- }){magenta} %clr(--){faint} %clr([%1.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
||||
|
||||
<!--定义日志文档的存储地址 勿在 LogBack 的配置中使用相对路径-->
|
||||
<property name="LOG_HOME_LOCAL" value="/Users/apple/Desktop/log/local" />
|
||||
<property name="LOG_HOME_DEV" value="/Users/apple/Desktop/log/dev" />
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- 控制面板输出 -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>INFO</level>
|
||||
</filter>
|
||||
<encoder>
|
||||
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
|
||||
<!-- 设置字符集 -->
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 按照每天生成日志文档 -->
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!--日志文档输出的文档名-->
|
||||
<springProfile name="local">
|
||||
<FileNamePattern>${LOG_HOME_LOCAL}/%d{yyyy-MM-dd}/kangarooDataCenter%d{yyyy-MM}.log</FileNamePattern>
|
||||
</springProfile>
|
||||
<springProfile name="dev">
|
||||
<FileNamePattern>${LOG_HOME_DEV}/%d{yyyy-MM-dd}/kangarooDataCenter_%d{yyyy-MM}.log</FileNamePattern>
|
||||
</springProfile>
|
||||
<!--日志文档保留天数-->
|
||||
<MaxHistory>50</MaxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread] %logger{50} - %msg%n</pattern>
|
||||
</encoder>
|
||||
<!--日志文档最大的大小-->
|
||||
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
||||
<MaxFileSize>50MB</MaxFileSize>
|
||||
</triggeringPolicy>
|
||||
</appender>
|
||||
<!-- 日志输出级别 ,就是说在整个项目中,日志级别在info一上的日志都打印。 root是根日志打印器,只有一个,负责整个系统的日志输出 -->
|
||||
<root level="INFO">
|
||||
<!-- 控制面板输出 -->
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<!-- 按照每天生成日志文档 -->
|
||||
<appender-ref ref="FILE"/>
|
||||
</root>
|
||||
<!-- 指定特定包下面的日志输出级别。logger是root的子打印器,可以有多个,输出name配置的包中的日志。 -->
|
||||
<!-- <logger name="com.repository" level="info"/>-->
|
||||
|
||||
</configuration>
|
|
@ -0,0 +1,192 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.hzya.frame</groupId>
|
||||
<artifactId>kangarooDataCenter</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<modules>
|
||||
<module>webapp</module>
|
||||
<module>core</module>
|
||||
<module>application</module>
|
||||
</modules>
|
||||
<properties>
|
||||
<boot-version>2.5.14</boot-version>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.5.14</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${boot-version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- SLF4J API -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.30</version>
|
||||
</dependency>
|
||||
<!-- Logback implementation -->
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>2.0.33</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.19</version>
|
||||
</dependency>
|
||||
|
||||
<!-- sa-token-->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
<version>1.30.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-oauth2</artifactId>
|
||||
<version>1.30.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-jwt</artifactId>
|
||||
<version>1.30.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 多数据源-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||
<version>3.5.2</version>
|
||||
</dependency>
|
||||
<!-- mysql-->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.49</version>
|
||||
</dependency>
|
||||
<!-- mybatis-plus-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.3.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>kangarooDataCenter</finalName>
|
||||
<plugins>
|
||||
<!-- 资源文件拷贝插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- java编译插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.7.4</version>
|
||||
<configuration>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<mainClass>none</mainClass> <!-- 取消查找本项目下的Main方法:为了解决Unable to find main class的问题 -->
|
||||
<classifier>execute</classifier> <!-- 为了解决依赖模块找不到此模块中的类或属性 -->
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
<!--加载src/main/java下的xml-->
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.yml</include>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.xmreport</include>
|
||||
<include>**/*.xlsx</include>
|
||||
<include>**/*.json</include>
|
||||
<include>**/*.xdb</include>
|
||||
</includes>
|
||||
</resource>
|
||||
|
||||
<!--扫描配置文件所在的目录-->
|
||||
<resource>
|
||||
<directory>src/</directory>
|
||||
<includes>
|
||||
<include>**/*.yml</include>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.json</include>
|
||||
</includes>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,16 @@
|
|||
package com.hzya.frame;
|
||||
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
@SpringBootApplication()
|
||||
@MapperScan({"com.hzya.frame.testApplication.dao","com.hzya.frame.test.dao"})
|
||||
public class AppRepository extends SpringBootServletInitializer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AppRepository.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.hzya.frame.controller;
|
||||
|
||||
import com.hzya.frame.entity.JsonResultEntity;
|
||||
import com.hzya.frame.unifiedEntry.service.IUnifiedEntryService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/entranceController")
|
||||
public class EntranceController {
|
||||
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private IUnifiedEntryService unifiedEntryService;
|
||||
|
||||
@RequestMapping("/queryTest")
|
||||
@ResponseBody
|
||||
public String queryTest() {
|
||||
logger.info("请求成功info");
|
||||
logger.error("请求成功error");
|
||||
return "请求成功";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param servletRequest
|
||||
* @param servletResponse
|
||||
* @Description 请求统一入口
|
||||
**/
|
||||
@RequestMapping(value = "/option")
|
||||
@ResponseBody
|
||||
public JsonResultEntity option(ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
|
||||
return unifiedEntryService.doBusiness(servletRequest, servletResponse);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue