Browse Source

1、代码路径迁移

master
bjang03 6 months ago
parent
commit
a0f99040d0
  1. 3
      win-framework/win-spring-boot-starter-web/src/main/java/com/win/framework/web/config/WinWebAutoConfiguration.java
  2. 6
      win-module-system/win-module-system-biz/src/main/java/com/win/module/system/framework/web/config/ModuleAuthenInterceptor.java
  3. 2
      win-module-system/win-module-system-biz/src/main/java/com/win/module/system/framework/web/config/MyCommandLineRunner.java
  4. 13
      win-module-system/win-module-system-biz/src/main/java/com/win/module/system/framework/web/config/SystemWebConfiguration.java
  5. 2
      win-module-system/win-module-system-biz/src/main/java/com/win/module/system/job/ModuleLicencesJob.java
  6. 6
      win-module-system/win-module-system-biz/src/main/java/com/win/module/system/mq/consumer/licences/LicencesConsumer.java
  7. 17
      win-module-system/win-module-system-biz/src/main/java/com/win/module/system/mq/message/licences/LicencesMessage.java
  8. 9
      win-module-system/win-module-system-biz/src/main/java/com/win/module/system/mq/producer/licences/LicencesProducer.java
  9. 10
      win-module-system/win-module-system-biz/src/main/java/com/win/module/system/service/licences/LicencesServiceImpl.java
  10. 2
      win-module-system/win-module-system-biz/src/main/java/com/win/module/system/util/ModuleAuthenUtils.java

3
win-framework/win-spring-boot-starter-web/src/main/java/com/win/framework/web/config/WinWebAutoConfiguration.java

@ -5,7 +5,6 @@ import com.win.framework.common.enums.WebFilterOrderEnum;
import com.win.framework.web.constant.Constant;
import com.win.framework.web.core.filter.CacheRequestBodyFilter;
import com.win.framework.web.core.filter.DemoFilter;
import com.win.framework.web.core.filter.ModuleAuthenInterceptor;
import com.win.framework.web.core.filter.MyI18nInterceptor;
import com.win.framework.web.core.handler.GlobalExceptionHandler;
import com.win.framework.web.core.handler.GlobalResponseBodyHandler;
@ -152,8 +151,6 @@ public class WinWebAutoConfiguration implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new ModuleAuthenInterceptor()).addPathPatterns("/**");// 模块权限拦截器 张斌 2024-05-15 10:29
// 注册拦截器
MyI18nInterceptor myHandlerInterceptor = new MyI18nInterceptor();
InterceptorRegistration loginRegistry = registry.addInterceptor(myHandlerInterceptor);

6
win-framework/win-spring-boot-starter-web/src/main/java/com/win/framework/web/core/filter/ModuleAuthenInterceptor.java → win-module-system/win-module-system-biz/src/main/java/com/win/module/system/framework/web/config/ModuleAuthenInterceptor.java

@ -1,10 +1,9 @@
package com.win.framework.web.core.filter;
package com.win.module.system.framework.web.config;
import cn.hutool.crypto.digest.MD5;
import cn.hutool.json.JSONObject;
import com.win.framework.common.exception.enums.GlobalErrorCodeConstants;
import com.win.framework.common.pojo.CommonResult;
import com.win.framework.web.core.util.ModuleAuthenUtils;
import com.win.module.system.util.ModuleAuthenUtils;
import lombok.Cleanup;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.HandlerInterceptor;
@ -12,7 +11,6 @@ import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

2
win-module-system/win-module-system-biz/src/main/java/com/win/module/system/framework/web/config/MyCommandLineRunner.java

@ -1,6 +1,6 @@
package com.win.module.system.framework.web.config;
import com.win.framework.web.core.util.ModuleAuthenUtils;
import com.win.module.system.util.ModuleAuthenUtils;
import org.springframework.boot.CommandLineRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

13
win-module-system/win-module-system-biz/src/main/java/com/win/module/system/framework/web/config/SystemWebConfiguration.java

@ -1,9 +1,13 @@
package com.win.module.system.framework.web.config;
import com.win.framework.swagger.config.WinSwaggerAutoConfiguration;
import com.win.framework.web.core.filter.MyI18nInterceptor;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* system 模块的 web 组件的 Configuration
@ -11,7 +15,8 @@ import org.springframework.context.annotation.Configuration;
* @author 闻荫源码
*/
@Configuration(proxyBeanMethods = false)
public class SystemWebConfiguration {
public class SystemWebConfiguration implements WebMvcConfigurer {
/**
* system 模块的 API 分组
@ -20,5 +25,11 @@ public class SystemWebConfiguration {
public GroupedOpenApi systemGroupedOpenApi() {
return WinSwaggerAutoConfiguration.buildGroupedOpenApi("system");
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new ModuleAuthenInterceptor()).addPathPatterns("/**");// 模块权限拦截器 张斌 2024-05-15 10:29
}
}

2
win-module-system/win-module-system-biz/src/main/java/com/win/module/system/job/ModuleLicencesJob.java

@ -1,6 +1,6 @@
package com.win.module.system.job;
import com.win.framework.web.core.util.ModuleAuthenUtils;
import com.win.module.system.util.ModuleAuthenUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.EnableScheduling;

6
win-module-system/win-module-system-biz/src/main/java/com/win/module/system/mq/consumer/licences/LicencesConsumer.java

@ -5,5 +5,9 @@ import com.win.module.system.mq.message.licences.LicencesMessage;
import org.springframework.stereotype.Component;
@Component
public class LicencesConsumer {
public class LicencesConsumer extends AbstractStreamMessageListener<LicencesMessage>{
@Override
public void onMessage(LicencesMessage message) {
System.out.println(message);
}
}

17
win-module-system/win-module-system-biz/src/main/java/com/win/module/system/mq/message/licences/LicencesMessage.java

@ -1,8 +1,21 @@
package com.win.module.system.mq.message.licences;
import com.win.framework.mq.core.stream.AbstractStreamMessage;
import lombok.Data;
import lombok.EqualsAndHashCode;
public class LicencesMessage{
import java.util.Map;
import static com.win.module.system.util.ModuleAuthenUtils.LICENCES_UPDATE_MESSAGE;
@Data
@EqualsAndHashCode(callSuper = true)
public class LicencesMessage extends AbstractStreamMessage{
private String secretKey;
private String data;
private Map data;
@Override
public String getStreamKey() {
return LICENCES_UPDATE_MESSAGE;
}
}

9
win-module-system/win-module-system-biz/src/main/java/com/win/module/system/mq/producer/licences/LicencesProducer.java

@ -1,11 +1,13 @@
package com.win.module.system.mq.producer.licences;
import com.win.framework.mq.core.RedisMQTemplate;
import com.win.module.system.mq.message.licences.LicencesMessage;
import com.win.module.system.mq.message.mail.MailSendMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Map;
/**
* 模块权限 Producer
@ -19,11 +21,8 @@ public class LicencesProducer {
@Resource
private RedisMQTemplate redisMQTemplate;
public void sendMessage(Long sendLogId, String mail, Long accountId,
String nickname, String title, String content) {
MailSendMessage message = new MailSendMessage()
.setLogId(sendLogId).setMail(mail).setAccountId(accountId)
.setNickname(nickname).setTitle(title).setContent(content);
public void sendMessage(String secretKey, Map data) {
LicencesMessage message = new LicencesMessage().setSecretKey(secretKey).setData(data);
redisMQTemplate.send(message);
}

10
win-module-system/win-module-system-biz/src/main/java/com/win/module/system/service/licences/LicencesServiceImpl.java

@ -5,12 +5,11 @@ import cn.hutool.crypto.digest.MD5;
import cn.hutool.extra.qrcode.QrCodeUtil;
import cn.hutool.extra.qrcode.QrConfig;
import cn.hutool.json.JSONObject;
import com.win.framework.web.core.util.ModuleAuthenUtils;
import com.win.module.system.controller.licences.vo.GenerateLicenceReqVO;
import com.win.module.system.mq.producer.licences.LicencesProducer;
import com.win.module.system.util.ModuleAuthenUtils;
import lombok.Data;
import org.apache.calcite.util.Util;
import org.springframework.data.redis.connection.stream.ObjectRecord;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -62,11 +61,10 @@ public class LicencesServiceImpl implements LicencesService {
//todo 需迁移至mq订阅逻辑中
ModuleAuthenUtils.secretKey = licences.getSecretKey();
ModuleAuthenUtils.module = licences.getData();
redisTemplate.opsForValue().set(ModuleAuthenUtils.LICENCES_REDIS_KEY,new JSONObject(licences).toString());
String licencesStr = new JSONObject(licences).toString();
redisTemplate.opsForValue().set(ModuleAuthenUtils.LICENCES_REDIS_KEY,licencesStr);
//todo 更新到redis并使用发布订阅通知其他pods拉取过滤路径
redisTemplate.opsForStream().add(ObjectRecord.create("stream:queue:licences",1));
// redisTemplate.convertAndSend(ModuleAuthenUtils.LICENCES_UPDATE_MESSAGE, ModuleAuthenUtils.module.toString());
licencesProducer.sendMessage(licences.getSecretKey(),licences.getData());
} catch (Exception e) {
throw exception(500, e);
}

2
win-framework/win-spring-boot-starter-web/src/main/java/com/win/framework/web/core/util/ModuleAuthenUtils.java → win-module-system/win-module-system-biz/src/main/java/com/win/module/system/util/ModuleAuthenUtils.java

@ -1,4 +1,4 @@
package com.win.framework.web.core.util;
package com.win.module.system.util;
import cn.hutool.core.codec.Base64;
import cn.hutool.json.JSONObject;
Loading…
Cancel
Save