mirror of
https://gitee.com/y_project/RuoYi-Cloud.git
synced 2026-01-26 11:51:55 +08:00
2024-09-15 半流程
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package com.ruoyi.system.api;
|
||||
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.http.Customer;
|
||||
import com.ruoyi.system.api.factory.RemoteCustomerFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 用户服务
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@FeignClient(contextId = "remoteCustomerService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteCustomerFallbackFactory.class)
|
||||
public interface RemoteCustomerService
|
||||
{
|
||||
/**
|
||||
* 通过用户名查询用户信息
|
||||
*
|
||||
* @param id 用户名
|
||||
* @param source 请求来源
|
||||
* @return 结果
|
||||
*/
|
||||
@GetMapping("/customer/{id}")
|
||||
public R<Customer> getCustomerInfoById(@PathVariable("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 通过手机号MD5查询用户信息
|
||||
*
|
||||
* @param phoneMD5 用户名
|
||||
* @param source 请求来源
|
||||
* @return 结果
|
||||
*/
|
||||
@GetMapping("/customer/getByMd5")
|
||||
public R<Customer> getCustomerInfoByPhoneMd5(@RequestParam("phoneMD5")String phoneMD5, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 通过手机号MD5更新用户信息
|
||||
*
|
||||
* @param customer 用户
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/customer/updateByPhoneMd5")
|
||||
public R updateByPhoneMd5(Customer customer ,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 新增客户信息
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/customer/addNewCustomer")
|
||||
public R add(@RequestBody Customer customer,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.ruoyi.system.api.factory;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.http.Customer;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.system.api.RemoteCustomerService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 用户服务降级处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class RemoteCustomerFallbackFactory implements FallbackFactory<RemoteCustomerService>
|
||||
{
|
||||
@Override
|
||||
public RemoteCustomerService create(Throwable throwable)
|
||||
{
|
||||
log.error("用户服务调用失败:{}", throwable.getMessage());
|
||||
return new RemoteCustomerService()
|
||||
{
|
||||
@Override
|
||||
public R<Customer> getCustomerInfoById(Long id, String source)
|
||||
{
|
||||
return R.fail("获取用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<Customer> getCustomerInfoByPhoneMd5(String phoneMD5, String source) {
|
||||
log.info("查询用户失败:{}",throwable.getMessage());
|
||||
return R.fail("查询用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R updateByPhoneMd5(Customer customer, String source) {
|
||||
return R.fail("更新用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R add(Customer customer, String source) {
|
||||
log.info("新增用户失败:{}",throwable.getMessage());
|
||||
return R.fail("新增用户失败");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user