models.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. from django.db import models
  2. # Create your models here.
  3. # wechat access_token
  4. class WeChatAccessToken(models.Model):
  5. id = models.AutoField(primary_key=True)
  6. application = models.CharField(max_length=64)
  7. # 每个微信公众号设定自己的application,保证自己access_token刷新
  8. requestTime = models.DateTimeField(auto_now=True)
  9. accessTokenKey = models.CharField(max_length=512)
  10. @staticmethod
  11. def search_by_application(name):
  12. try:
  13. return WeChatAccessToken.objects.get(application=name)
  14. except Exception as e:
  15. print(e)
  16. return None
  17. # jsapi_token
  18. class JsapiAccessToken(models.Model):
  19. id = models.AutoField(primary_key=True)
  20. application = models.CharField(max_length=64)
  21. # 每个微信公众号设定自己的application,保证自己jsapi_token刷新
  22. requestTime = models.DateTimeField(auto_now=True)
  23. accessTokenKey = models.CharField(max_length=512)
  24. @staticmethod
  25. def search_by_application(name):
  26. try:
  27. return JsapiAccessToken.objects.get(application=name)
  28. except Exception as e:
  29. print(e)
  30. return None