We construct a class of linear codes by choosing a proper defining set and determine their complete weight enumerators and weight enumerators. The results show that they have at most three weights and they are suitable for applications in secret sharing schemes. This is an extension of the results raised by Wang et al. (2017).