phpcjl
2024-12-04 c4ce0d4971f8b64f853575bf378df454a2fd4f30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.ruoyi.account.api.factory;
 
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.account.api.model.AppUserShop;
import com.ruoyi.common.core.domain.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.web.bind.annotation.PostMapping;
 
import java.util.List;
 
/**
 * @author zhibing.pu
 * @Date 2024/11/21 9:52
 */
@Slf4j
public class AppUserClientFallbackFactory implements FallbackFactory<AppUserClient> {
    
    
    
    @Override
    public AppUserClient create(Throwable cause) {
        
        return new AppUserClient() {
            @PostMapping("/appUser/getAppUserById")
            @Override
            public AppUser getAppUserById(Long id) {
                log.error("根据id获取用户失败:{}", cause.getMessage());
                throw new RuntimeException("根据id获取用户失败");
            }
 
            @Override
            public R<Void> editAppUserById(AppUser appUser) {
                log.error("编辑用户信息失败:{}", cause.getMessage());
                return R.fail("编辑用户信息失败");
            }
 
            @Override
            public R<Long> getCouponCount(Long userId, Integer couponId) {
                log.error("获取优惠券数量失败:{}", cause.getMessage());
                throw new RuntimeException("获取优惠券数量失败");
            }
 
            @Override
            public R<List<AppUserShop>> getAppUserShop(Long userId) {
                log.error("获取用户门店信息失败:{}", cause.getMessage());
                throw new RuntimeException("获取用户门店信息失败");
            }
 
            @Override
            public R<List<AppUser>> getUserAncestorList(Long id) {
                log.error("获取用户祖籍列表失败:{}", cause.getMessage());
                throw new RuntimeException("获取用户祖籍列表失败");
            }
            @Override
            public R<Long> getVipCount(Long userId, Integer vipId) {
                log.error("获取直推会员数失败:{}", cause.getMessage());
                throw new RuntimeException("获取直推会员数失败");
            }
 
 
        };
    }
}