完善初始化框架

master
zengchenxi 10 months ago
parent 62a3b6b0b9
commit 21092fd03a

@ -3,13 +3,11 @@ package com.chanko.yunxi.mes.heli.framework.web.config;
import com.chanko.yunxi.mes.heli.framework.apilog.core.service.ApiErrorLogFrameworkService;
import com.chanko.yunxi.mes.heli.framework.common.enums.WebFilterOrderEnum;
import com.chanko.yunxi.mes.heli.framework.web.core.filter.CacheRequestBodyFilter;
import com.chanko.yunxi.mes.heli.framework.web.core.filter.DemoFilter;
import com.chanko.yunxi.mes.heli.framework.web.core.handler.GlobalExceptionHandler;
import com.chanko.yunxi.mes.heli.framework.web.core.handler.GlobalResponseBodyHandler;
import com.chanko.yunxi.mes.heli.framework.web.core.util.WebFrameworkUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.client.RestTemplateBuilder;
@ -101,15 +99,6 @@ public class MesWebAutoConfiguration implements WebMvcConfigurer {
return createFilterBean(new CacheRequestBodyFilter(), WebFilterOrderEnum.REQUEST_BODY_CACHE_FILTER);
}
/**
* DemoFilter Bean
*/
@Bean
@ConditionalOnProperty(value = "mes.demo", havingValue = "true")
public FilterRegistrationBean<DemoFilter> demoFilter() {
return createFilterBean(new DemoFilter(), WebFilterOrderEnum.DEMO_FILTER);
}
public static <T extends Filter> FilterRegistrationBean<T> createFilterBean(T filter, Integer order) {
FilterRegistrationBean<T> bean = new FilterRegistrationBean<>(filter);
bean.setOrder(order);

@ -1,35 +0,0 @@
package com.chanko.yunxi.mes.heli.framework.web.core.filter;
import cn.hutool.core.util.StrUtil;
import com.chanko.yunxi.mes.heli.framework.common.pojo.CommonResult;
import com.chanko.yunxi.mes.heli.framework.common.util.servlet.ServletUtils;
import com.chanko.yunxi.mes.heli.framework.web.core.util.WebFrameworkUtils;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import static com.chanko.yunxi.mes.heli.framework.common.exception.enums.GlobalErrorCodeConstants.DEMO_DENY;
/**
* Filter
*
* @author
*/
public class DemoFilter extends OncePerRequestFilter {
@Override
protected boolean shouldNotFilter(HttpServletRequest request) {
String method = request.getMethod();
return !StrUtil.equalsAnyIgnoreCase(method, "POST", "PUT", "DELETE") // 写操作时,不进行过滤率
|| WebFrameworkUtils.getLoginUserId(request) == null; // 非登录用户时,不进行过滤
}
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) {
// 直接返回 DEMO_DENY 的结果。即,请求不继续
ServletUtils.writeJSON(response, CommonResult.error(DEMO_DENY));
}
}

@ -43,11 +43,11 @@ spring:
primary: master
datasource:
master:
name: ruoyi
url: jdbc:mysql://localhost:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
name: mes-heli
url: jdbc:mysql://222.71.165.188:3309/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
driver-class-name: com.mysql.jdbc.Driver
username: root
password: imysql
password: linus,.123
# slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
# name: ruoyi-vue-pro
# url: jdbc:mysql://localhost:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&serverTimezone=CTT&allowPublicKeyRetrieval=true

@ -5,7 +5,7 @@
<el-avatar :size="60">
<Icon icon="ep:avatar" :size="60" />
</el-avatar>
<span class="text-18px font-bold">芋道源码</span>
<span class="text-18px font-bold">合立MES</span>
</div>
<Icon icon="tdesign:qrcode" :size="20" />
</div>

@ -196,7 +196,7 @@ const loginData = reactive({
captchaEnable: import.meta.env.VITE_APP_CAPTCHA_ENABLE,
tenantEnable: import.meta.env.VITE_APP_TENANT_ENABLE,
loginForm: {
tenantName: '芋道源码',
tenantName: '系统租户',
username: 'admin',
password: 'admin123',
captchaVerification: '',

@ -184,7 +184,7 @@ const loginData = reactive({
captchaEnable: import.meta.env.VITE_APP_CAPTCHA_ENABLE,
tenantEnable: import.meta.env.VITE_APP_TENANT_ENABLE,
loginForm: {
tenantName: '芋道源码',
tenantName: '系统租户',
username: 'admin',
password: 'admin123',
captchaVerification: '',

@ -133,7 +133,7 @@ const loginData = reactive({
},
loginForm: {
uuid: '',
tenantName: '芋道源码',
tenantName: '系统租户',
mobileNumber: '',
code: ''
}

Loading…
Cancel
Save