Просмотр исходного кода

增加全局异常捕获

tags/v2.4.1
xiaoying 1 год назад
Родитель
Сommit
a2d0d5f8a5
5 измененных файлов: 42 добавлений и 6 удалений
  1. +26
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/common/ExceptionCatch.java
  2. +0
    -1
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java
  3. +6
    -1
      tuoheng_oidc_admin/target/classes/application-local.yml
  4. +7
    -3
      tuoheng_oidc_admin/target/classes/mapper/ClientUserMapper.xml
  5. +3
    -1
      tuoheng_oidc_admin/target/classes/mapper/TenantMapper.xml

+ 26
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/common/ExceptionCatch.java Просмотреть файл

@@ -0,0 +1,26 @@
package com.tuoheng.common;


import com.tuoheng.until.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice //控制器增强类
@Slf4j
public class ExceptionCatch {

/**
* 处理不可控异常1
* @param e
* @return
*/
@ExceptionHandler(Exception.class)
@ResponseBody
public JsonResult exception(Exception e){
e.printStackTrace();
log.error("catch exception:{}",e.getMessage());
return JsonResult.error(e.getMessage());
}
}

+ 0
- 1
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java Просмотреть файл

@@ -255,7 +255,6 @@ public class ClientUserServiceImpl implements ClientUserSevice {
IPage<UserPo> page = new Page<>(query.getPage(), query.getLimit());
IPage<UserVo> pageData = clientUserMapper.selectByTenantIdAndPage(query, page);
pageData.convert(x -> {

String platformCode = x.getPlatformCode();
if (platformCode.contains(HhzUrlConstant.HHZ_CLIENT)) {
x.setPlatformName(HhzUrlConstant.HHZ_NAME);

+ 6
- 1
tuoheng_oidc_admin/target/classes/application-local.yml Просмотреть файл

@@ -64,4 +64,9 @@ spring:
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制)
max-idle: 10 # 连接池中的最大空闲连接
min-idle: 1 # 连接池中的最小空闲连接
min-idle: 1 # 连接池中的最小空闲连接

# 自定义配置
tuoheng:
#airport配置地址
airport-url: http://192.168.11.22:8060

+ 7
- 3
tuoheng_oidc_admin/target/classes/mapper/ClientUserMapper.xml Просмотреть файл

@@ -11,12 +11,14 @@
select count(1)
from users
where username = #{username}
and enabled = 1
</select>

<select id="getUserByUserName" parameterType="java.lang.String" resultType="com.tuoheng.model.po.UserPo">
select *
from users
where username = #{username}
and enabled = 1
</select>
<select id="selectByUserId" resultType="com.tuoheng.model.po.UserPo">
SELECT id,
@@ -38,7 +40,9 @@
</select>
<select id="selectByTenantIdAndPage" resultType="com.tuoheng.model.vo.UserVo">
SELECT
u.*,
u.username,
u.create_time,
u.update_time,
a.authority platformCode
FROM
users u,
@@ -51,8 +55,8 @@
<if test="query.platformCode != null and query.platformCode != ''">
and a.authority LIKE concat('%',#{query.platformCode},'%')
</if>
AND u.tenant_id = a.create_user
and u.enabled =1
AND a.user_id = u.id
AND u.enabled = 1
GROUP BY u.username
</select>


+ 3
- 1
tuoheng_oidc_admin/target/classes/mapper/TenantMapper.xml Просмотреть файл

@@ -44,10 +44,12 @@
select *
from tuoheng_oidc.t_tenant
where code = #{code}
and enabled = 1
</select>
<select id="findList" resultType="com.tuoheng.model.po.TenantPo">
SELECT t.id, t.user_id, t.remark, t.code,
t.name,t.province_code,t.province_name,t.city_code,t.city_name,t.district_code,t.district_name,u.username username
t.name,t.province_code,t.province_name,t.city_code,t.city_name,t.district_code,t.district_name,u.username
username
FROM t_tenant t,users u
WHERE t.enabled = 1 and u.enabled =1 and t.user_id =u.id
<if test="query.tenantName != null and query.tenantName != ''">

Загрузка…
Отмена
Сохранить