A compound represented by formula, an S enantiomer thereof, an R enantiomer thereof or a pharmaceutically acceptable salt thereof, wherein, R 1 is selected from the group consisting of H, F, Cl, Br, I, OH, NH 2, C 1-6 alkyl and C 1 -6 heteroalkyl, each of C 1-6 alkyl and C 1-6 heteroalkyl is optionally substituted by R, and the number of R is 1, 2 or 3; R 2 is independently selected from the group consisting of H, F, Cl, Br, I, OH, NH 2, C 1-6 alkyl and C 1-6 heteroalkyl, each of C 1-6 alkyl and C 1-6 heteroalkyl is optionally substituted by R, and the number of R is 1, 2 or 3; R 3 is selected from H; or R 1 and R 3 are linked together with the carbon atom to which they are attached form a C 3-6 cycloalkyl; ring B is selected from phenyl and 5-6 membered heteroaryl; n is selected from 0, 1, 2 or 3; R is selected from the group consisting of H, F, Cl, Br, I, OH, NH 2, C 1-6 alkyl and C 1-6 heteroalkyl, each of C 1-6 alkyl and C 1-6 heteroalkyl is optionally substituted by R', and the number of R' is 1, 2 or 3; R' is selected from F, Cl, Br, I, OH and NH 2; when R 1 is selected from H, or R 1 and R 3 are linked together with the carbon atom to which they are attached form a C 3-6 cycloalkyl, then the carbon atom with " ∗ " is not a chiral carbon atom; when R 1 is not selected from H, then the carbon atom with " ∗ " is a chiral carbon atom, and the compound represented by formula exists in the form of a single enantiomer of or or is enriched in one enantiomer; the "hetero" of the C 1-6 heteroalkyl and 5-6 membered heteroaryl is selected from the group consisting of N, -O-, -S-, -NH-; the above number of heteroatoms or heteroatom groups is independently selected from 1, 2, 3, or 4. R 1 is selected from the group consisting of H, F, Cl, Br, I, OH, NH 2, C 1-6 alkyl and C 1 -6 heteroalkyl, each of C 1-6 alkyl and C 1-6 heteroalkyl is optionally substituted by R, and the number of R is 1, 2 or 3; R 2 is independently selected from the group consisting of H, F, Cl, Br, I, OH, NH 2, C 1-6 alkyl and C 1-6 heteroalkyl, each of C 1-6 alkyl and C 1-6 heteroalkyl is optionally substituted by R, and the number of R is 1, 2 or 3; R 3 is selected from H; or R 1 and R 3 are linked together with the carbon atom to which they are attached form a C 3-6 cycloalkyl; ring B is selected from phenyl and 5-6 membered heteroaryl; n is selected from 0, 1, 2 or 3; R is selected from the group consisting of H, F, Cl, Br, I, OH, NH 2, C 1-6 alkyl and C 1-6 heteroalkyl, each of C 1-6 alkyl and C 1-6 heteroalkyl is optionally substituted by R', and the number of R' is 1, 2 or 3; R' is selected from F, Cl, Br, I, OH and NH 2; when R 1 is selected from H, or R 1 and R 3 are linked together with the carbon atom to which they are attached form a C 3-6 cycloalkyl, then the carbon atom with " ∗ " is not a chiral carbon atom; when R 1 is not selected from H, then the carbon atom with " ∗ " is a chiral carbon atom, and the compound represented by formula exists in the form of a single enantiomer of or or is enriched in one enantiomer; the "hetero" of the C 1-6 heteroalkyl and 5-6 membered heteroaryl is selected from the group consisting of N, -O-, -S-, -NH-; the above number of heteroatoms or heteroatom groups is independently selected from 1, 2, 3, or 4.