A compound represented by formula, a stereoisomer thereof, or a pharmaceutically acceptable salt of the same, wherein, X is independently N or CH; m is 0, 1 or 2; n is 1 or 2; D is -C(=O)-, -C(=O)O-, -CH 2 -; R 1 is C 1-6 alkyl, C 1-6 heteroalkyl or C 3 - 6 cycloalkyl, each of which is optionally substituted by one, two or three R; each of R 2 and R 3 is H, halogen, OH, NH 2, CN or R 4 -L-, or selected from the group consisting of C 1-6 alkyl, C 1-6 heteroalkyl, phenyl and 5-6 membered heteroaryl, each of which is optionally substituted by one, two or three R; R 4 is C 3-6 cycloalkyl, 3-6 membered heterocyclic alkyl, phenyl or 5-6 membered heteroaryl, each of which is optionally substituted by one, two or three R; L is - 1-3 -, or -O- 0-3 -; ring A is 5 membered heteroaryl; ring B is phenyl or 5-9 membered heteroaryl; R is H, F, Cl, Br, I, CN, OH, NH 2, COOH, or optionally selected from the group consisting of C 1-6 alkyl and C 1-6 heteroalkyl, each of which is optionally substituted by one, two or three R'; R' is H, F, Cl, Br, I, OH, CN, NH 2, COOH, Me, Et, CF 3, CHF 2, CH 2 F, NHCH 3, N(CH 3) 2; "hetero" represents a heteroatom or a heteroatom group, which is selected from the group consisting of -C(=O)N -, -N -, -C(=NR)-, -S(=O) 2 N -, -S(=O)N -, -O-, -S-, =O, =S, -O-N=, -C(=O)O-, -C(=O)-, -C(=S)-, -S(=O)-, -S(=O) 2 -, and -N C(=O)N -; in any one of the above cases, the number of heteroatom or heteroatom group is independently selected from one, two and three. X is independently N or CH; m is 0, 1 or 2; n is 1 or 2; D is -C(=O)-, -C(=O)O-, -CH 2 -; R 1 is C 1-6 alkyl, C 1-6 heteroalkyl or C 3 - 6 cycloalkyl, each of which is optionally substituted by one, two or three R; each of R 2 and R 3 is H, halogen, OH, NH 2, CN or R 4 -L-, or selected from the group consisting of C 1-6 alkyl, C 1-6 heteroalkyl, phenyl and 5-6 membered heteroaryl, each of which is optionally substituted by one, two or three R; R 4 is C 3-6 cycloalkyl, 3-6 membered heterocyclic alkyl, phenyl or 5-6 membered heteroaryl, each of which is optionally substituted by one, two or three R; L is - 1-3 -, or -O- 0-3 -; ring A is 5 membered heteroaryl; ring B is phenyl or 5-9 membered heteroaryl; R is H, F, Cl, Br, I, CN, OH, NH 2, COOH, or optionally selected from the group consisting of C 1-6 alkyl and C 1-6 heteroalkyl, each of which is optionally substituted by one, two or three R'; R' is H, F, Cl, Br, I, OH, CN, NH 2, COOH, Me, Et, CF 3, CHF 2, CH 2 F, NHCH 3, N(CH 3) 2; "hetero" represents a heteroatom or a heteroatom group, which is selected from the group consisting of -C(=O)N -, -N -, -C(=NR)-, -S(=O) 2 N -, -S(=O)N -, -O-, -S-, =O, =S, -O-N=, -C(=O)O-, -C(=O)-, -C(=S)-, -S(=O)-, -S(=O) 2 -, and -N C(=O)N -; in any one of the above cases, the number of heteroatom or heteroatom group is independently selected from one, two and three. "hetero" represents a heteroatom or a heteroatom group, which is selected from the group consisting of -C(=O)N -, -N -, -C(=NR)-, -S(=O) 2 N -, -S(=O)N -, -O-, -S-, =O, =S, -O-N=, -C(=O)O-, -C(=O)-, -C(=S)-, -S(=O)-, -S(=O) 2 -, and -N C(=O)N -; in any one of the above cases, the number of heteroatom or heteroatom group is independently selected from one, two and three.