test:(修改框架)

dev
zhang xu 2024-06-22 21:00:49 +08:00
parent dc0aa66dcf
commit c9c62e2a9d
10 changed files with 56 additions and 85 deletions

View File

@ -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("获取用户失败:{}");
}
};
}
}

View File

@ -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;
/**
* @PostContructspringspring
* @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 可以将消息 内容 以及 失败的原因 记录到 日志表中
}
}
}

View File

@ -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

View File

@ -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() {

View File

@ -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";
}

View File

@ -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;

View File

@ -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;