完善初始化框架

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.apilog.core.service.ApiErrorLogFrameworkService;
import com.chanko.yunxi.mes.heli.framework.common.enums.WebFilterOrderEnum; 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.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.GlobalExceptionHandler;
import com.chanko.yunxi.mes.heli.framework.web.core.handler.GlobalResponseBodyHandler; import com.chanko.yunxi.mes.heli.framework.web.core.handler.GlobalResponseBodyHandler;
import com.chanko.yunxi.mes.heli.framework.web.core.util.WebFrameworkUtils; import com.chanko.yunxi.mes.heli.framework.web.core.util.WebFrameworkUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfiguration; 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.autoconfigure.web.client.RestTemplateAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.client.RestTemplateBuilder; 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); 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) { public static <T extends Filter> FilterRegistrationBean<T> createFilterBean(T filter, Integer order) {
FilterRegistrationBean<T> bean = new FilterRegistrationBean<>(filter); FilterRegistrationBean<T> bean = new FilterRegistrationBean<>(filter);
bean.setOrder(order); 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 primary: master
datasource: datasource:
master: master:
name: ruoyi name: mes-heli
url: jdbc:mysql://localhost:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true 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 driver-class-name: com.mysql.jdbc.Driver
username: root username: root
password: imysql password: linus,.123
# slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 # slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改
# name: ruoyi-vue-pro # name: ruoyi-vue-pro
# url: jdbc:mysql://localhost:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&serverTimezone=CTT&allowPublicKeyRetrieval=true # 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"> <el-avatar :size="60">
<Icon icon="ep:avatar" :size="60" /> <Icon icon="ep:avatar" :size="60" />
</el-avatar> </el-avatar>
<span class="text-18px font-bold">芋道源码</span> <span class="text-18px font-bold">合立MES</span>
</div> </div>
<Icon icon="tdesign:qrcode" :size="20" /> <Icon icon="tdesign:qrcode" :size="20" />
</div> </div>

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

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

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

Loading…
Cancel
Save