test:(修改框架)
parent
dc0aa66dcf
commit
c9c62e2a9d
|
@ -0,0 +1,33 @@
|
|||
package com.muyu.common.system.remote.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.domain.EntInfo;
|
||||
import com.muyu.common.system.remote.RemoteNetworkingService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户服务降级处理
|
||||
*
|
||||
* @author muyu
|
||||
*/
|
||||
@Component
|
||||
public class RemoteUserFallbackFactory implements FallbackFactory<RemoteNetworkingService> {
|
||||
private static final Logger log = LoggerFactory.getLogger(RemoteUserFallbackFactory.class);
|
||||
|
||||
@Override
|
||||
public RemoteNetworkingService create (Throwable throwable) {
|
||||
log.error("用户服务调用失败:{}", throwable.getMessage());
|
||||
return new RemoteNetworkingService() {
|
||||
|
||||
@Override
|
||||
public Result<List<EntInfo>> list() {
|
||||
return Result.error("获取用户失败:{}");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package com.muyu.vehicle.config;
|
||||
|
||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* @ClassDescription:
|
||||
* @JdkVersion: 17
|
||||
* @Author: zhangxu
|
||||
* @Created: 2024/6/10 20:28
|
||||
*/
|
||||
@Component
|
||||
public class ConfirmCallbackConfig implements RabbitTemplate.ConfirmCallback{
|
||||
|
||||
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
/**
|
||||
* @PostContruct是spring框架的注解,在⽅法上加该注解会在项⽬启动的时候执⾏该⽅法,也可以理解为在spring容器初始化的时候执
|
||||
* @PostConstruct bean 被初始化的时候执行的方法的注解
|
||||
* @PreDestory bean 被销毁的时候执行的方法的注解
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
rabbitTemplate.setConfirmCallback(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 交换机不管是否收到消息的一个回调方法
|
||||
*
|
||||
* @param correlationData 消息相关数据
|
||||
* @param ack 交换机是否收到消息
|
||||
* @param cause 失败原因
|
||||
*/
|
||||
@Override
|
||||
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
|
||||
if (ack) {
|
||||
// 消息投递到 broker 的状态,true表示成功
|
||||
System.out.println("消息发送成功!");
|
||||
} else {
|
||||
// 发送异常
|
||||
System.out.println("发送异常原因 = " + cause);
|
||||
// TODO 可以将消息 内容 以及 失败的原因 记录到 日志表中
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,27 +1,19 @@
|
|||
package com.muyu.networking.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
package com.muyu.vehicle.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.domain.Certification;
|
||||
import com.muyu.networking.service.CertificationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.domain.Certification;
|
||||
import com.muyu.vehicle.service.CertificationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Controller
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.networking.mapper;
|
||||
package com.muyu.vehicle.mapper;
|
||||
|
||||
|
||||
import com.muyu.domain.Certification;
|
|
@ -2,7 +2,7 @@ package com.muyu.vehicle.myDatasource.aspect;
|
|||
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.remote.RemoteUserService;
|
||||
import com.muyu.common.system.remote.RemoteNetworkingService;
|
||||
import com.muyu.vehicle.myDatasource.holder.DynamicDataSourceHolder;
|
||||
import org.aspectj.lang.annotation.After;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
|
@ -21,7 +21,7 @@ import org.springframework.stereotype.Component;
|
|||
@Component
|
||||
public class DataSourceAsp {
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
private RemoteNetworkingService remoteUserService;
|
||||
|
||||
@Pointcut("execution(public * com.muyu.vehicle.controller.*(..))")
|
||||
public void pointcut() {
|
||||
|
|
|
@ -12,7 +12,7 @@ public class DatasourceConstant {
|
|||
|
||||
public final static String USER_NAME = "root";
|
||||
|
||||
public final static String PASSWORD = "122.152.211.1";
|
||||
public final static String PASSWORD = "zhangyang123";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,11 +2,12 @@ package com.muyu.vehicle.rabbit;
|
|||
import com.alibaba.fastjson2.JSON;
|
||||
import com.muyu.domain.FaultRecord;
|
||||
|
||||
import com.muyu.networking.service.FaultRecordService;
|
||||
import com.muyu.vehicle.myDatasource.holder.DynamicDataSourceHolder;
|
||||
|
||||
import com.muyu.vehicle.service.FaultRecordService;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.networking.service;
|
||||
package com.muyu.vehicle.service;
|
||||
|
||||
|
||||
import com.muyu.domain.Certification;
|
|
@ -1,10 +1,12 @@
|
|||
package com.muyu.networking.service.impl;
|
||||
package com.muyu.vehicle.service.Impl;
|
||||
|
||||
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.muyu.domain.Certification;
|
||||
import com.muyu.networking.mapper.CertificationMapper;
|
||||
import com.muyu.networking.service.CertificationService;
|
||||
|
||||
|
||||
import com.muyu.vehicle.mapper.CertificationMapper;
|
||||
import com.muyu.vehicle.service.CertificationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
Loading…
Reference in New Issue