mirror of
https://gitee.com/EMF/solon-manager.git
synced 2025-12-06 16:58:28 +08:00
mod: 全局异常提示
This commit is contained in:
parent
273def4069
commit
f5cc7e125a
@ -2,6 +2,7 @@ package vip.fuck.sm.common.exception.handler;
|
|||||||
|
|
||||||
import cn.dev33.satoken.exception.NotLoginException;
|
import cn.dev33.satoken.exception.NotLoginException;
|
||||||
import cn.dev33.satoken.exception.NotPermissionException;
|
import cn.dev33.satoken.exception.NotPermissionException;
|
||||||
|
import org.apache.ibatis.exceptions.PersistenceException;
|
||||||
import vip.fuck.sm.common.exception.BusinessException;
|
import vip.fuck.sm.common.exception.BusinessException;
|
||||||
import vip.fuck.sm.common.exception.code.BaseResponseCode;
|
import vip.fuck.sm.common.exception.code.BaseResponseCode;
|
||||||
import vip.fuck.sm.common.utils.DataResult;
|
import vip.fuck.sm.common.utils.DataResult;
|
||||||
@ -12,36 +13,64 @@ import org.noear.solon.core.handle.*;
|
|||||||
import org.noear.solon.validation.ValidatorException;
|
import org.noear.solon.validation.ValidatorException;
|
||||||
import org.thymeleaf.exceptions.TemplateEngineException;
|
import org.thymeleaf.exceptions.TemplateEngineException;
|
||||||
|
|
||||||
|
import java.sql.SQLIntegrityConstraintViolationException;
|
||||||
|
|
||||||
@Component(index = 0) //index 为顺序位(不加,则默认为0)
|
@Component(index = 0) //index 为顺序位(不加,则默认为0)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AppFilter implements Filter {
|
public class AppFilter implements Filter {
|
||||||
@Override
|
@Override
|
||||||
public void doFilter(Context ctx, FilterChain chain) throws Throwable {
|
public void doFilter(Context ctx, FilterChain chain) throws Throwable {
|
||||||
|
String pathNew = ctx.pathNew();
|
||||||
try {
|
try {
|
||||||
chain.doFilter(ctx);
|
chain.doFilter(ctx);
|
||||||
} catch (NotLoginException e){
|
} catch (NotLoginException e){
|
||||||
ctx.redirect("/index/login");
|
ctx.redirect("/index/login");
|
||||||
|
return;
|
||||||
} catch (NotPermissionException e){
|
} catch (NotPermissionException e){
|
||||||
ctx.redirect("/index/403");
|
ctx.redirect("/index/403");
|
||||||
|
return;
|
||||||
}catch (ValidatorException e) {
|
}catch (ValidatorException e) {
|
||||||
ctx.render(DataResult.getResult(
|
ctx.render(DataResult.getResult(
|
||||||
BaseResponseCode.METHODARGUMENTNOTVALIDEXCEPTION.getCode(),
|
BaseResponseCode.METHODARGUMENTNOTVALIDEXCEPTION.getCode(),
|
||||||
e.getMessage()));
|
e.getMessage()));
|
||||||
|
return;
|
||||||
}catch (BusinessException e){
|
}catch (BusinessException e){
|
||||||
ctx.render(new DataResult(e.getMessageCode(), e.getDetailMessage(),e.getThrowable(),null));
|
ctx.render(new DataResult(e.getMessageCode(), e.getDetailMessage(),e.getThrowable(),null));
|
||||||
} catch (StatusException e){
|
return;
|
||||||
ctx.status(e.getCode());
|
|
||||||
if (e.getCode() == 404){
|
|
||||||
String pathNew = ctx.pathNew();
|
|
||||||
log.error("404:{}",pathNew);
|
|
||||||
ctx.redirect("/index/404");
|
|
||||||
} else {
|
|
||||||
ctx.redirect("/index/500");
|
|
||||||
}
|
|
||||||
} catch (TemplateEngineException e){
|
} catch (TemplateEngineException e){
|
||||||
ctx.render(" /** 【页面异常】 **/");
|
ctx.render(" /** 【页面异常】 **/");
|
||||||
|
return;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
if ( e instanceof StatusException){
|
||||||
|
StatusException se = (StatusException) e;
|
||||||
|
ctx.status(se.getCode());
|
||||||
|
if (se.getCode() == 400){
|
||||||
|
log.error("400:{}",pathNew);
|
||||||
|
ctx.status(200);
|
||||||
|
ctx.render(new DataResult(BaseResponseCode.DATA_ERROR.getCode(), "参数错误", null,null));
|
||||||
|
return;
|
||||||
|
}else if (se.getCode() == 404){
|
||||||
|
log.error("404:{}",pathNew);
|
||||||
|
ctx.redirect("/index/404");
|
||||||
|
return;
|
||||||
|
} else if (se.getCode() == 403){
|
||||||
|
log.error("403:{}",pathNew);
|
||||||
|
ctx.redirect("/index/404");
|
||||||
|
return;
|
||||||
|
} else if(se.getCode() == 500){
|
||||||
|
log.error("500:{}",pathNew);
|
||||||
|
ctx.redirect("/index/500");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(e instanceof PersistenceException){
|
||||||
|
if(e.getMessage().contains("java.sql.SQLIntegrityConstraintViolationException: Duplicate entry")){
|
||||||
|
ctx.render(new DataResult(BaseResponseCode.OPERATION_ERRO.getCode(), "数据重复",e,null));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
log.error(e.getMessage(),e);
|
log.error(e.getMessage(),e);
|
||||||
|
ctx.status(500);
|
||||||
ctx.render(DataResult.getResult(BaseResponseCode.SYSTEM_BUSY));
|
ctx.render(DataResult.getResult(BaseResponseCode.SYSTEM_BUSY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package vip.fuck.sm.controller;
|
package vip.fuck.sm.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
@ -46,12 +47,28 @@ public class SysPlugsController {
|
|||||||
@ApiOperation(value = "查询分页数据")
|
@ApiOperation(value = "查询分页数据")
|
||||||
@Post @Mapping ("sysPlugs/listByPage")
|
@Post @Mapping ("sysPlugs/listByPage")
|
||||||
@SaCheckPermission("sysPlugs:list")
|
@SaCheckPermission("sysPlugs:list")
|
||||||
public DataResult findListByPage( SysPlugsEntity sysPlugs){
|
public DataResult findListByPage(SysPlugsEntity sysPlugs ,String key){
|
||||||
LambdaQueryWrapper<SysPlugsEntity> queryWrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<SysPlugsEntity> q = Wrappers.lambdaQuery();
|
||||||
//查询条件示例
|
if(ObjectUtil.isNotEmpty(key)){
|
||||||
queryWrapper.eq(sysPlugs.getQualifiedVersion() != null, SysPlugsEntity::getQualifiedVersion, sysPlugs.getQualifiedVersion());
|
q.or(qq->{
|
||||||
queryWrapper.orderByDesc(SysPlugsEntity::getQualifiedVersion);
|
qq.like(SysPlugsEntity::getQualifiedVersion,key);
|
||||||
IPage<SysPlugsEntity> iPage = sysPlugsService.page(sysPlugs.getQueryPage(), queryWrapper);
|
});
|
||||||
|
q.or(qq->{
|
||||||
|
qq.like(SysPlugsEntity::getAuthor,key);
|
||||||
|
});
|
||||||
|
q.or(qq->{
|
||||||
|
qq.like(SysPlugsEntity::getVersion,key);
|
||||||
|
});
|
||||||
|
q.or(qq->{
|
||||||
|
qq.like(SysPlugsEntity::getDescription,key);
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
//查询条件示例
|
||||||
|
q.eq(sysPlugs.getQualifiedVersion() != null, SysPlugsEntity::getQualifiedVersion, sysPlugs.getQualifiedVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
q.orderByDesc(SysPlugsEntity::getQualifiedVersion);
|
||||||
|
IPage<SysPlugsEntity> iPage = sysPlugsService.page(sysPlugs.getQueryPage(), q);
|
||||||
return DataResult.success(iPage);
|
return DataResult.success(iPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,8 @@
|
|||||||
package vip.fuck.sm.entity;
|
package vip.fuck.sm.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import vip.fuck.sm.entity.BasePageEntity;
|
import vip.fuck.sm.entity.BasePageEntity;
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@ -25,7 +23,7 @@ public class SysPlugsEntity extends BasePageEntity implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 全限版本
|
* 全限版本
|
||||||
*/
|
*/
|
||||||
@TableId("qualified_version")
|
@TableId(value = "qualified_version",type = IdType.INPUT)
|
||||||
private String qualifiedVersion;
|
private String qualifiedVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -37,15 +37,15 @@ var CoreUtil = (function () {
|
|||||||
},
|
},
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
top.layer.close(loadIndex);
|
top.layer.close(loadIndex);
|
||||||
if (res.code==0){
|
if (res.code===0){
|
||||||
if(ft!=null&&ft!=undefined){
|
if(typeof ft === 'function'){
|
||||||
ft(res);
|
ft(res);
|
||||||
}
|
}
|
||||||
}else if(res.code==401001){ //凭证过期重新登录
|
}else if(res.code===401001){ //凭证过期重新登录
|
||||||
layer.msg("凭证过期请重新登录", {time:2000}, function () {
|
layer.msg("凭证过期请重新登录", {time:2000}, function () {
|
||||||
top.window.location.href=ctx + "index/login"
|
top.window.location.href=ctx + "index/login"
|
||||||
})
|
})
|
||||||
}else if(res.code==401008){ //凭证过期重新登录
|
}else if(res.code===401008){ //凭证过期重新登录
|
||||||
layer.msg("抱歉!您暂无权限", {time:2000})
|
layer.msg("抱歉!您暂无权限", {time:2000})
|
||||||
} else {
|
} else {
|
||||||
layer.msg(res.msg);
|
layer.msg(res.msg);
|
||||||
@ -53,8 +53,10 @@ var CoreUtil = (function () {
|
|||||||
},
|
},
|
||||||
error:function (XMLHttpRequest, textStatus, errorThrown) {
|
error:function (XMLHttpRequest, textStatus, errorThrown) {
|
||||||
top.layer.close(loadIndex);
|
top.layer.close(loadIndex);
|
||||||
if(XMLHttpRequest.status==404){
|
if(XMLHttpRequest.status===404){
|
||||||
top.window.location.href= ctx + "index/404";
|
top.window.location.href= ctx + "index/404";
|
||||||
|
}else if(XMLHttpRequest.status === 400){
|
||||||
|
layer.msg("参数错误,请检查");
|
||||||
}else{
|
}else{
|
||||||
layer.msg("服务器好像除了点问题!请稍后试试");
|
layer.msg("服务器好像除了点问题!请稍后试试");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,9 +118,9 @@
|
|||||||
$(".title").html("新增");
|
$(".title").html("新增");
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
form.val('info', {
|
form.val('info', {
|
||||||
"test": "test"
|
"test": null
|
||||||
#foreach($column in $htmlColumns)
|
#foreach($column in $htmlColumns)
|
||||||
, "${column.attrname}": ""
|
, "${column.attrname}": null
|
||||||
#end
|
#end
|
||||||
});
|
});
|
||||||
}, 200);
|
}, 200);
|
||||||
@ -208,7 +208,7 @@
|
|||||||
$(".title").html("查看");
|
$(".title").html("查看");
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
form.val('info', {
|
form.val('info', {
|
||||||
"test": "test"
|
"test": null
|
||||||
#foreach($column in $htmlColumns)
|
#foreach($column in $htmlColumns)
|
||||||
, "${column.attrname}": data.${column.attrname}
|
, "${column.attrname}": data.${column.attrname}
|
||||||
#end
|
#end
|
||||||
|
|||||||
@ -11,7 +11,12 @@
|
|||||||
<div class="panel-heading title"></div>
|
<div class="panel-heading title"></div>
|
||||||
<div class="layui-card-body">
|
<div class="layui-card-body">
|
||||||
<form class="layui-form " action="" lay-filter="info">
|
<form class="layui-form " action="" lay-filter="info">
|
||||||
<input name="qualifiedVersion" hidden/>
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label">全限版本</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="qualifiedVersion" name="qualifiedVersion" placeholder="请输入全限版本" autocomplete="off" class="layui-input disabled">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">作者</label>
|
<label class="layui-form-label">作者</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user