refactor(webapp): 优化代码格式和日志输出
-调整代码缩进和空格,提高可读性 - 优化日志输出,移除冗余信息 - 统一异常处理方式
This commit is contained in:
parent
c1786b7cb8
commit
14a21b3168
|
@ -70,7 +70,7 @@ public class EntranceServiceImpl implements IEntranceService {
|
||||||
String body = ServletUtil.getBody(servletRequest);
|
String body = ServletUtil.getBody(servletRequest);
|
||||||
//获取类
|
//获取类
|
||||||
Object object = null;
|
Object object = null;
|
||||||
if(service == null || "".equals(service) || serviceMethod == null || "".equals(serviceMethod)){
|
if (service == null || "".equals(service) || serviceMethod == null || "".equals(serviceMethod)) {
|
||||||
return BaseResult.getFailureMessageEntity("非法请求,请检查");
|
return BaseResult.getFailureMessageEntity("非法请求,请检查");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -81,7 +81,7 @@ public class EntranceServiceImpl implements IEntranceService {
|
||||||
//获取类下面的方法
|
//获取类下面的方法
|
||||||
Method[] methods = object.getClass().getMethods();
|
Method[] methods = object.getClass().getMethods();
|
||||||
if (methods == null || methods.length == 0) {
|
if (methods == null || methods.length == 0) {
|
||||||
logger.error("当前service:" + service + "serviceMethod = " + serviceMethod+"未找到");
|
logger.error("当前service:" + service + "serviceMethod = " + serviceMethod + "未找到");
|
||||||
return BaseResult.getFailureMessageEntity(service + "未找到" + serviceMethod + "方法");
|
return BaseResult.getFailureMessageEntity(service + "未找到" + serviceMethod + "方法");
|
||||||
}
|
}
|
||||||
for (Method m : methods) {
|
for (Method m : methods) {
|
||||||
|
@ -89,7 +89,7 @@ public class EntranceServiceImpl implements IEntranceService {
|
||||||
if (m.getName().equals(serviceMethod.trim())) {
|
if (m.getName().equals(serviceMethod.trim())) {
|
||||||
if (m.getName().startsWith("thirdInterface")) {//TODO 后续可能要加强校验规则
|
if (m.getName().startsWith("thirdInterface")) {//TODO 后续可能要加强校验规则
|
||||||
logger.info("第三方接口,不校验是否登陆");
|
logger.info("第三方接口,不校验是否登陆");
|
||||||
}else if (!"doLogin".equals(m.getName())) {
|
} else if (!"doLogin".equals(m.getName())) {
|
||||||
try {
|
try {
|
||||||
StpUtil.checkLogin();
|
StpUtil.checkLogin();
|
||||||
//校验当前登陆人是否有权限
|
//校验当前登陆人是否有权限
|
||||||
|
@ -138,7 +138,8 @@ public class EntranceServiceImpl implements IEntranceService {
|
||||||
}
|
}
|
||||||
JsonResultEntity jsonResultEntity;
|
JsonResultEntity jsonResultEntity;
|
||||||
try {
|
try {
|
||||||
logger.info("invoke开始>>>>>>>>>>>>>>>>>>>>>>>>>>>>请求的参数:jsonObject:" + jsonObject.toJSONString());
|
// logger.info("invoke开始>>>>>>>>>>>>>>>>>>>>>>>>>>>>请求的参数:jsonObject:" + jsonObject.toJSONString());
|
||||||
|
logger.info("invoke开始>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
||||||
jsonResultEntity = (JsonResultEntity) m.invoke(object, jsonObject);
|
jsonResultEntity = (JsonResultEntity) m.invoke(object, jsonObject);
|
||||||
logger.info("invoke结束>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
logger.info("invoke结束>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
||||||
return jsonResultEntity;
|
return jsonResultEntity;
|
||||||
|
@ -227,26 +228,27 @@ public class EntranceServiceImpl implements IEntranceService {
|
||||||
@Override
|
@Override
|
||||||
public JsonResultEntity fileUpload(MultipartFile file, FileUploadDto entity, ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
|
public JsonResultEntity fileUpload(MultipartFile file, FileUploadDto entity, ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
|
||||||
StpUtil.checkLogin();
|
StpUtil.checkLogin();
|
||||||
FileUploadEntity fileUploadEntity = fileUploadService.fileUpload(file,entity);
|
FileUploadEntity fileUploadEntity = fileUploadService.fileUpload(file, entity);
|
||||||
return BaseResult.getSuccessMessageEntity("附件上传成功",fileUploadEntity);
|
return BaseResult.getSuccessMessageEntity("附件上传成功", fileUploadEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonResultEntity pluginfileUpload(MultipartFile file, FileUploadDto entity,String pluginPackageName, ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
|
public JsonResultEntity pluginfileUpload(MultipartFile file, FileUploadDto entity, String pluginPackageName, ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
|
||||||
StpUtil.checkLogin();
|
StpUtil.checkLogin();
|
||||||
FileUploadEntity fileUploadEntity = fileUploadService.pluginfileUpload(file,entity,pluginPackageName);
|
FileUploadEntity fileUploadEntity = fileUploadService.pluginfileUpload(file, entity, pluginPackageName);
|
||||||
return BaseResult.getSuccessMessageEntity("附件上传成功",fileUploadEntity);
|
return BaseResult.getSuccessMessageEntity("附件上传成功", fileUploadEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonResultEntity pluginZipUpate(FileUploadDto fileUploadDto) throws Exception{
|
public JsonResultEntity pluginZipUpate(FileUploadDto fileUploadDto) throws Exception {
|
||||||
StpUtil.checkLogin();
|
StpUtil.checkLogin();
|
||||||
FileDownloadEntity fileDownloadEntity = fileDownloadService.pluginZipUpate(fileUploadDto);
|
FileDownloadEntity fileDownloadEntity = fileDownloadService.pluginZipUpate(fileUploadDto);
|
||||||
return BaseResult.getSuccessMessageEntity("插件更新成功",fileDownloadEntity);
|
return BaseResult.getSuccessMessageEntity("插件更新成功", fileDownloadEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonResultEntity fileUpload(MultipartFile file, FileResultEntity entity, ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
|
public JsonResultEntity fileUpload(MultipartFile file, FileResultEntity entity, ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
|
||||||
entity = fileUploadService.fileUpload(file,entity);
|
entity = fileUploadService.fileUpload(file, entity);
|
||||||
return BaseResult.getSuccessMessageEntity("附件上传成功",entity);
|
return BaseResult.getSuccessMessageEntity("附件上传成功", entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -259,7 +261,7 @@ public class EntranceServiceImpl implements IEntranceService {
|
||||||
String body = ServletUtil.getBody(servletRequest);
|
String body = ServletUtil.getBody(servletRequest);
|
||||||
//获取类
|
//获取类
|
||||||
Object object = null;
|
Object object = null;
|
||||||
if(service == null || "".equals(service) || serviceMethod == null || "".equals(serviceMethod)){
|
if (service == null || "".equals(service) || serviceMethod == null || "".equals(serviceMethod)) {
|
||||||
return BaseResult.getFailureMessageEntity("非法请求,请检查");
|
return BaseResult.getFailureMessageEntity("非法请求,请检查");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -288,7 +290,7 @@ public class EntranceServiceImpl implements IEntranceService {
|
||||||
try {
|
try {
|
||||||
logger.info("invoke开始>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
logger.info("invoke开始>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
||||||
logger.info("请求的参数:jsonObject:" + jsonObject.toJSONString());
|
logger.info("请求的参数:jsonObject:" + jsonObject.toJSONString());
|
||||||
Object result = m.invoke(object, jsonObject);
|
Object result = m.invoke(object, jsonObject);
|
||||||
logger.info("invoke结束>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
logger.info("invoke结束>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
|
||||||
return result;
|
return result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -308,7 +310,7 @@ public class EntranceServiceImpl implements IEntranceService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new BaseSystemException( service + "未找到" + serviceMethod + "方法") ;
|
throw new BaseSystemException(service + "未找到" + serviceMethod + "方法");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue