Procházet zdrojové kódy

* 商品详情接口bug修复

libo před 4 roky
rodič
revize
488ad362e9

+ 0 - 33
src/test/java/com/tdba/cxb/ares/api/user/UserDto.java

@@ -1,33 +0,0 @@
1
-package com.tdba.cxb.ares.api.user;
2
-
3
-/**
4
- * @program: admin-web
5
- * @description:
6
- * @author: libo
7
- * @create: 2022-06-06 15:26:14
8
- */
9
-public class UserDto {
10
-
11
-    /** 用户ID*/
12
-    private Integer uid;
13
-
14
-    /** 推荐人用户ID*/
15
-    private Integer spread_uid;
16
-
17
-    public Integer getUid() {
18
-        return uid;
19
-    }
20
-
21
-    public void setUid(Integer uid) {
22
-        this.uid = uid;
23
-    }
24
-
25
-    public Integer getSpread_uid() {
26
-        return spread_uid;
27
-    }
28
-
29
-    public void setSpread_uid(Integer spread_uid) {
30
-        this.spread_uid = spread_uid;
31
-    }
32
-
33
-}

+ 0 - 27
src/test/java/com/tdba/cxb/ares/api/user/UserRelateTest.java

@@ -1,27 +0,0 @@
1
-package com.tdba.cxb.ares.api.user;
2
-
3
-import com.tdba.cxb.ares.api.ApplicationStartup;
4
-import com.tdba.cxb.ares.api.service.UserService;
5
-import org.junit.jupiter.api.Test;
6
-import org.springframework.boot.test.context.SpringBootTest;
7
-
8
-import javax.annotation.Resource;
9
-import java.time.LocalDate;
10
-
11
-/**
12
- * @program: order-web
13
- * @description:
14
- * @author: libo
15
- * @create: 2022-06-06 17:40:27
16
- */
17
-@SpringBootTest(classes = ApplicationStartup.class)
18
-public class UserRelateTest {
19
-
20
-    @Resource
21
-    private UserService userService;
22
-
23
-    @Test
24
-    public void test(){
25
-        userService.createSpreadInfo(LocalDate.of(2021, 4, 9));
26
-    }
27
-}

+ 0 - 68
src/test/java/com/tdba/cxb/ares/api/user/UserTest.java

@@ -1,68 +0,0 @@
1
-package com.tdba.cxb.ares.api.user;
2
-
3
-import com.tdba.cxb.ares.api.util.TDBAException;
4
-import org.junit.jupiter.api.Test;
5
-import org.slf4j.Logger;
6
-import org.slf4j.LoggerFactory;
7
-import org.springframework.util.CollectionUtils;
8
-
9
-import java.util.List;
10
-
11
-/**
12
- * @program: admin-web
13
- * @description:
14
- * @author: libo
15
- * @create: 2022-06-06 15:17:42
16
- */
17
-public class UserTest {
18
-
19
-    private static Logger logger = LoggerFactory.getLogger(UserTest.class);
20
-
21
-    @Test
22
-    public void test(){
23
-
24
-        List<UserDto> list = List.of(UserDto.UserDtoBuilder.anUserDto()
25
-                .withUid(2)
26
-                .withSpread_uid(1)
27
-                .build(),
28
-                UserDto.UserDtoBuilder.anUserDto()
29
-                        .withUid(3)
30
-                        .withSpread_uid(2)
31
-                        .build(),
32
-                UserDto.UserDtoBuilder.anUserDto()
33
-                        .withUid(1)
34
-                        .withSpread_uid(0)
35
-                        .build(),
36
-                UserDto.UserDtoBuilder.anUserDto()
37
-                        .withUid(4)
38
-                        .withSpread_uid(0)
39
-                        .build());
40
-
41
-        list.stream().forEach(row -> {
42
-            logger.info("uid = {}, count = {}", row.getUid(), countOfChildren(row, list));
43
-        });
44
-
45
-    }
46
-
47
-    public static Integer countOfChildren(UserDto userDto, List<UserDto> list){
48
-
49
-        if(userDto == null || CollectionUtils.isEmpty(list)){
50
-            return 0;
51
-        }
52
-
53
-        Integer result = 0;
54
-        for(UserDto row : list){
55
-            if(userDto.getUid() == row.getUid()){
56
-                continue;
57
-            }
58
-           if(row.getSpread_uid() == userDto.getUid()){
59
-               if(row.getUid() == userDto.getSpread_uid()){
60
-                   logger.error("循环嵌套 row.getSpread_uid() = {}, userDto.getUid() = {}", row.getSpread_uid(), userDto.getSpread_uid());
61
-                   throw new TDBAException("循环嵌套");
62
-               }
63
-                result = 1 + countOfChildren(row, list);
64
-           }
65
-        }
66
-        return result;
67
-    }
68
-}