A compound of formula, or a tautomer, mesomer, racemate, enantiomer, diastereoisomer and mixtures thereof, or a pharmaceutical salt thereof: wherein: R 1 is selected from C 3 -C 20 cycloalkyl, heterocyclyl containing 3 to 20 ring atoms, 6 to 14-membered aryl and 5 to 14-membered heteroaryl, wherein the cycloalkyl, heterocyclyl, aryl and heteroaryl are each optionally substituted by one or more groups selected from halogen, cyano, C 1 -C 20 alkyl, C 1 -C 20 haloalkyl, C 1 -C 20 hydroxyalkyl, C 3 -C 20 cycloalkyl, C 1 -C 20 alkoxy, heterocyclyl containing 3 to 20 ring atoms, 6 to 14-membered aryl, 5 to 14-membered heteroaryl, carboxyl and alkoxycarbonyl; R 2 is selected from hydrogen atom, C 1 -C 20 alkyl, C 3 -C 20 cycloalkyl, heterocyclyl containing 3 to 20 ring atoms, 6 to 14-membered aryl and 5 to 14-membered heteroaryl, wherein the alkyl, cycloalkyl, heterocyclyl, aryl and heteroaryl are each optionally substituted by one or more groups selected from halogen, cyano, hydroxy, amino, C 1 -C 20 alkyl, C 1 -C 20 haloalkyl, C 1 -C 20 hydroxyalkyl, C 1 -C 20 alkoxy, C 3 -C 20 cycloalkyl, heterocyclyl containing 3 to 20 ring atoms, 6 to 14-membered aryl, 5 to 14-membered heteroaryl, carboxyl and alkoxycarbonyl; R 3 is selected from hydrogen atom and C 1 -C 20 alkyl; ring A is selected from 6 to 14-membered aryl and 5 to 14-membered heteroaryl, wherein the aryl and heteroaryl are each optionally substituted by one or more groups selected from halogen, cyano, C 1 -C 20 alkyl, C 1 -C 20 haloalkyl, C 1 -C 20 hydroxyalkyl, C 3 -C 20 cycloalkyl, C 1 -C 20 alkoxy, heterocyclyl containing 3 to 20 ring atoms, 6 to 14-membered aryl, 5 to 14-membered heteroaryl, carboxyl and alkoxycarbonyl; either R 4 and R 5 are each independently selected from hydrogen atom, halogen, cyano, hydroxy, C 1 -C 20 alkyl, C 1 -C 20 haloalkyl, C 1 -C 20 alkoxy, C 1 -C 20 haloalkoxy, C 3 -C 20 cycloalkyl, heterocyclyl containing 3 to 20 ring atoms, 6 to 14-membered aryl and 5 to 14-membered heteroaryl; or R 4 and R 5 are taken together to form a C 3 -C 20 cycloalkyl or heterocyclyl containing 3 to 20 ring atoms; R 6 and R 7 are each independently selected from hydrogen atom, C 1 -C 20 alkyl, C 3 -C 20 cycloalkyl, heterocyclyl containing 3 to 20 ring atoms, 6 to 14-membered aryl and 5 to 14-membered heteroaryl, wherein the alkyl, cycloalkyl, heterocyclyl, aryl and heteroaryl are each independently optionally substituted by one or more groups selected from halogen, cyano, hydroxy, amino, oxo, C 1 -C 20 alkyl, C 1 -C 20 haloalkyl, C 1 -C 20 hydroxyalkyl, C 1 -C 20 alkoxy, C 3 -C 20 cycloalkyl, heterocyclyl containing 3 to 20 ring atoms, 6 to 14-membered aryl, 5 to 14-membered heteroaryl, carboxyl and alkoxycarbonyl; and n is 0, 1 or 2. R 1 is selected from C 3 -C 20 cycloalkyl, heterocyclyl containing 3 to 20 ring atoms, 6 to 14-membered aryl and 5 to 14-membered heteroaryl, wherein the cycloalkyl, heterocyclyl, aryl and heteroaryl are each optionally substituted by one or more groups selected from halogen, cyano, C 1 -C 20 alkyl, C 1 -C 20 haloalkyl, C 1 -C 20 hydroxyalkyl, C 3 -C 20 cycloalkyl, C 1 -C 20 alkoxy, heterocyclyl containing 3 to 20 ring atoms, 6 to 14-membered aryl, 5 to 14-membered heteroaryl, carboxyl and alkoxycarbonyl; R 2 is selected from hydrogen atom, C 1 -C 20 alkyl, C 3 -C 20 cycloalkyl, heterocyclyl containing 3 to 20 ring atoms, 6 to 14-membered aryl and 5 to 14-membered heteroaryl, wherein the alkyl, cycloalkyl, heterocyclyl, aryl and heteroaryl are each optionally substituted by one or more groups selected from halogen, cyano, hydroxy, amino, C 1 -C 20 alkyl, C 1 -C 20 haloalkyl, C 1 -C 20 hydroxyalkyl, C 1 -C 20 alkoxy, C 3 -C 20 cycloalkyl, heterocyclyl containing 3 to 20 ring atoms, 6 to 14-membered aryl, 5 to 14-membered heteroaryl, carboxyl and alkoxycarbonyl; R 3 is selected from hydrogen atom and C 1 -C 20 alkyl; ring A is selected from 6 to 14-membered aryl and 5 to 14-membered heteroaryl, wherein the aryl and heteroaryl are each optionally substituted by one or more groups selected from halogen, cyano, C 1 -C 20 alkyl, C 1 -C 20 haloalkyl, C 1 -C 20 hydroxyalkyl, C 3 -C 20 cycloalkyl, C 1 -C 20 alkoxy, heterocyclyl containing 3 to 20 ring atoms, 6 to 14-membered aryl, 5 to 14-membered heteroaryl, carboxyl and alkoxycarbonyl; either R 4 and R 5 are each independently selected from hydrogen atom, halogen, cyano, hydroxy, C 1 -C 20 alkyl, C 1 -C 20 haloalkyl, C 1 -C 20 alkoxy, C 1 -C 20 haloalkoxy, C 3 -C 20 cycloalkyl, heterocyclyl containing 3 to 20 ring atoms, 6 to 14-membered aryl and 5 to 14-membered heteroaryl; or R 4 and R 5 are taken together to form a C 3 -C 20 cycloalkyl or heterocyclyl containing 3 to 20 ring atoms; R 6 and R 7 are each independently selected from hydrogen atom, C 1 -C 20 alkyl, C 3 -C 20 cycloalkyl, heterocyclyl containing 3 to 20 ring atoms, 6 to 14-membered aryl and 5 to 14-membered heteroaryl, wherein the alkyl, cycloalkyl, heterocyclyl, aryl and heteroaryl are each independently optionally substituted by one or more groups selected from halogen, cyano, hydroxy, amino, oxo, C 1 -C 20 alkyl, C 1 -C 20 haloalkyl, C 1 -C 20 hydroxyalkyl, C 1 -C 20 alkoxy, C 3 -C 20 cycloalkyl, heterocyclyl containing 3 to 20 ring atoms, 6 to 14-membered aryl, 5 to 14-membered heteroaryl, carboxyl and alkoxycarbonyl; and n is 0, 1 or 2.