Commit 19d4ed04 authored by fangxinjiang's avatar fangxinjiang

配置调整

parent 7c3cc077
......@@ -26,5 +26,10 @@ public class SysLogDTO {
*/
@Schema(description = "创建时间区间")
private LocalDateTime[] createTime;
/**
* 日志标题
*/
@Schema(description = "日志标题")
private String title;
}
......@@ -115,8 +115,8 @@ public class RoleController {
* @return 分页对象
*/
@GetMapping("/page")
public R<IPage<SysRole>> getRolePage(Page page) {
return R.ok(sysRoleService.page(page, Wrappers.emptyWrapper()));
public R<IPage<SysRole>> getRolePage(Page page, SysRole sysRole) {
return R.ok(sysRoleService.getSysRoleByPage(page, sysRole));
}
/**
......
......@@ -16,6 +16,7 @@
package com.yifu.cloud.plus.v1.yifu.admin.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRole;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.RoleExcelVO;
......@@ -55,4 +56,5 @@ public interface SysRoleService extends IService<SysRole> {
*/
List<RoleExcelVO> listRole();
Page<SysRole> getSysRoleByPage(Page page, SysRole sysRole);
}
......@@ -66,7 +66,9 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
if (StrUtil.isNotBlank(sysLog.getType())) {
wrapper.eq(SysLog::getType, sysLog.getType());
}
if (StrUtil.isNotBlank(sysLog.getTitle())){
wrapper.likeRight(SysLog::getTitle,sysLog.getTitle());
}
if (ArrayUtil.isNotEmpty(sysLog.getCreateTime())) {
wrapper.ge(SysLog::getCreateTime, sysLog.getCreateTime()[0]).le(SysLog::getCreateTime,
sysLog.getCreateTime()[1]);
......
......@@ -18,8 +18,14 @@ package com.yifu.cloud.plus.v1.yifu.admin.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.admin.api.dto.SysLogDTO;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysLog;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRole;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRoleMenu;
import com.yifu.cloud.plus.v1.yifu.admin.api.vo.RoleExcelVO;
......@@ -126,6 +132,23 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
}).collect(Collectors.toList());
}
@Override
public Page<SysRole> getSysRoleByPage(Page page, SysRole sysRole) {
return baseMapper.selectPage(page, buildQueryWrapper(sysRole));
}
/**
* 构建查询的 wrapper
* @param sysRole 查询条件
* @return LambdaQueryWrapper
*/
private LambdaQueryWrapper buildQueryWrapper(SysRole sysRole) {
LambdaQueryWrapper<SysRole> wrapper = Wrappers.lambdaQuery();
if (StrUtil.isNotBlank(sysRole.getRoleName())){
wrapper.likeRight(SysRole::getRoleName,sysRole.getRoleName());
}
return wrapper;
}
/**
* 插入excel Role
*/
......
......@@ -37,15 +37,15 @@
<artifactId>yifu-common-swagger</artifactId>
</dependency>-->
<!--注册中心客户端-->
<dependency>
<!--<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
</dependency>-->
<!--配置中心客户端-->
<dependency>
<!--<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
</dependency>-->
<!--断路器依赖-->
<!--<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
......
......@@ -20,7 +20,6 @@ import com.yifu.cloud.plus.v1.yifu.common.datasource.annotation.EnableDynamicDat
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.EnableYifuResourceServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* @author lengleng
......@@ -29,7 +28,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
//@EnableYifuDoc
@EnableDynamicDataSource
//@EnableYifuFeignClients
@EnableDiscoveryClient
//@EnableDiscoveryClient
@SpringBootApplication
@EnableYifuResourceServer
public class YifuCodeGenApplication {
......
# 加解密根密码
jasypt:
encryptor:
password: pig #根密码
## spring security 配置
security:
oauth2:
......@@ -5,14 +9,26 @@ security:
client-id: ENC(27v1agvAug87ANOVnbKdsw==)
client-secret: ENC(VbnkopxrwgbFVKp+UxJ2pg==)
scope: server
resource:
loadBalanced: true
token-info-uri: http://yifu-auth/oauth/check_token
ignore: # 通用放行URL,服务个性化,请在对应配置文件覆盖
urls:
- /v3/api-docs
- /actuator/**
# 数据源配置
spring:
config:
activate:
on-profile: dev
redis:
host: 127.0.0.1
password: '@yf_2017'
datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: uf_zsk
password: yf_zsk
url: jdbc:mysql://192.168.1.65:22306/yifu_codegen?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
web:
resources:
......
......@@ -74,7 +74,17 @@
<artifactId>httpcore-nio</artifactId>
<version>4.4.6</version>
</dependency>
</dependencies>
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.3.5.RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>yifu-sentinel-dashboard</finalName>
......
......@@ -15,18 +15,30 @@
*/
package com.alibaba.csp.sentinel.dashboard.controller;
import cn.hutool.core.util.StrUtil;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService;
import com.alibaba.csp.sentinel.dashboard.auth.SimpleWebAuthServiceImpl;
import com.alibaba.csp.sentinel.dashboard.config.DashboardConfig;
import com.alibaba.csp.sentinel.dashboard.domain.Result;
import com.google.common.net.HttpHeaders;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.util.SpringContextHolder;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.cache.CacheManager;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.authentication.event.LogoutSuccessEvent;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
......@@ -34,10 +46,19 @@ import javax.servlet.http.HttpServletRequest;
* @author cdfive
* @since 1.6.0
*/
@RequiredArgsConstructor
@RestController
@RequestMapping("/auth")
public class AuthController {
private final ClientDetailsService clientDetailsService;
private final TokenStore tokenStore;
private final RedisTemplate redisTemplate;
private final CacheManager cacheManager;
private static final Logger LOGGER = LoggerFactory.getLogger(AuthController.class);
@Value("${auth.username:sentinel}")
......@@ -91,4 +112,44 @@ public class AuthController {
return Result.ofSuccess(authUser);
}
/* *//**
* 退出并删除token
* @param authHeader Authorization
*//*
@DeleteMapping("/logout")
public R<Boolean> logout(@RequestHeader(value = HttpHeaders.AUTHORIZATION, required = false) String authHeader) {
if (StrUtil.isBlank(authHeader)) {
return R.ok();
}
String tokenValue = authHeader.replace(OAuth2AccessToken.BEARER_TYPE, StrUtil.EMPTY).trim();
return removeToken(tokenValue);
}
*//**
* 令牌管理调用
* @param token token
*//*
@DeleteMapping("/{token}")
public R<Boolean> removeToken(@PathVariable("token") String token) {
OAuth2AccessToken accessToken = tokenStore.readAccessToken(token);
if (accessToken == null || StrUtil.isBlank(accessToken.getValue())) {
return R.ok();
}
OAuth2Authentication auth2Authentication = tokenStore.readAuthentication(accessToken);
// 清空用户信息
cacheManager.getCache(CacheConstants.USER_DETAILS).evict(auth2Authentication.getName());
// 清空access token
tokenStore.removeAccessToken(accessToken);
// 清空 refresh token
OAuth2RefreshToken refreshToken = accessToken.getRefreshToken();
tokenStore.removeRefreshToken(refreshToken);
// 处理自定义退出事件,保存相关日志
SpringContextHolder.publishEvent(new LogoutSuccessEvent(auth2Authentication));
return R.ok();
}*/
}
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