From e53e0843a363415ec264a28f5ce4d4f6dd072e10 Mon Sep 17 00:00:00 2001 From: youngS Date: Tue, 25 May 2021 16:53:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9F=9F=E5=90=8D=E9=BB=98=E8=AE=A4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fir_ser/api/models.py | 17 +-- fir_ser/api/utils/TokenManager.py | 4 +- fir_ser/api/views/domain.py | 3 +- fir_ser/dumpdata.json | 170 +++++++++++++++++++++++++++++- 4 files changed, 180 insertions(+), 14 deletions(-) diff --git a/fir_ser/api/models.py b/fir_ser/api/models.py index 1cde18c..669b9d5 100644 --- a/fir_ser/api/models.py +++ b/fir_ser/api/models.py @@ -5,7 +5,7 @@ from django.db import models from django.contrib.contenttypes.models import ContentType from api.utils.app.randomstrings import make_random_uuid from django.contrib.auth.models import AbstractUser -from api.utils.TokenManager import generateAlphanumericTokenOfLength +from api.utils.TokenManager import generateAlphanumericTokenOfLength, generateNumericTokenOfLength ######################################## 用户表 ######################################## @@ -457,11 +457,16 @@ class DomainCnameInfo(models.Model): created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间") class Meta: - verbose_name = '分发域名信息' - verbose_name_plural = "分发域名信息" + verbose_name = '系统分发域名配置' + verbose_name_plural = "系统分发域名配置" + + def save(self, *args, **kwargs): + if not self.domain_record or (self.domain_record and len(self.domain_record) < 26): # 最多3个启用的价格表 + self.domain_record = '%s.%s' % (generateNumericTokenOfLength(24, 'abcdef'), self.domain_record) + super(DomainCnameInfo, self).save(*args, **kwargs) def __str__(self): - return "%s-%s-%s" % (self.domain_record, self.ip_address, self.is_enable) + return "%s-%s-is_enable:%s-is_system:%s" % (self.domain_record, self.ip_address, self.is_enable, self.is_system) class UserDomainInfo(models.Model): @@ -473,8 +478,8 @@ class UserDomainInfo(models.Model): created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间") class Meta: - verbose_name = '分发域名绑定' - verbose_name_plural = "分发域名绑定" + verbose_name = '用户分发域名绑定' + verbose_name_plural = "用户分发域名绑定" def __str__(self): return "%s-%s-%s" % (self.user_id, self.cname_id, self.domain_name) diff --git a/fir_ser/api/utils/TokenManager.py b/fir_ser/api/utils/TokenManager.py index baede3b..cec65ca 100644 --- a/fir_ser/api/utils/TokenManager.py +++ b/fir_ser/api/utils/TokenManager.py @@ -60,8 +60,8 @@ def generateTokenForMedium(medium): return generateNumericTokenOfLength(6) -def generateNumericTokenOfLength(length): - return "".join([random.choice(string.digits) for _ in range(length)]) +def generateNumericTokenOfLength(length, random_str=''): + return "".join([random.choice(string.digits + random_str) for _ in range(length)]) def generateAlphanumericTokenOfLength(length): diff --git a/fir_ser/api/views/domain.py b/fir_ser/api/views/domain.py index 8b9b9b5..ab6c6be 100644 --- a/fir_ser/api/views/domain.py +++ b/fir_ser/api/views/domain.py @@ -6,7 +6,8 @@ from rest_framework.views import APIView -from api.utils.baseutils import is_valid_domain, get_cname_from_domain, get_user_domain_name, get_min_default_domain_cname_obj +from api.utils.baseutils import is_valid_domain, get_cname_from_domain, get_user_domain_name, \ + get_min_default_domain_cname_obj from api.utils.response import BaseResponse from api.utils.auth import ExpiringTokenAuthentication from rest_framework.response import Response diff --git a/fir_ser/dumpdata.json b/fir_ser/dumpdata.json index 998f6fe..f986fd8 100644 --- a/fir_ser/dumpdata.json +++ b/fir_ser/dumpdata.json @@ -6,11 +6,11 @@ "name": "1k_times", "title": "1k_times", "description": "1k_times", - "price": 2000, + "price": 2500, "package_size": 1000, "download_count_gift": 100, "is_enable": true, - "updated_time": "2021-04-14T17:37:05.512" + "updated_time": "2021-05-25T16:22:23.744" } }, { @@ -20,11 +20,11 @@ "name": "10k_times", "title": "10k_times", "description": "10k_times", - "price": 20000, + "price": 22000, "package_size": 10000, "download_count_gift": 800, "is_enable": true, - "updated_time": "2021-03-30T12:21:17.789" + "updated_time": "2021-05-25T16:22:35.404" } }, { @@ -38,7 +38,7 @@ "package_size": 100000, "download_count_gift": 8000, "is_enable": true, - "updated_time": "2021-03-29T18:28:31.942" + "updated_time": "2021-05-25T16:22:43.995" } }, { @@ -49,6 +49,7 @@ "ip_address": "d.ashort.top.w.kunlunsl.com", "is_enable": true, "is_system": true, + "is_https": false, "description": "d.ashort.top \u7cfb\u7edf\u81ea\u5e26\u57df\u540d\uff0c\u672a\u5907\u6848\uff0c\u56fd\u5916\u52a0\u901f\uff0c\u7528\u4e0e\u4e0b\u8f7d\u9875\u8df3\u8f6c\u57df\u540d", "created_time": "2021-05-21T21:25:33" } @@ -61,6 +62,7 @@ "ip_address": "d.bshort.top.w.kunlunsl.com", "is_enable": true, "is_system": true, + "is_https": false, "description": "d.bshort.top \u7cfb\u7edf\u81ea\u5e26\u57df\u540d\uff0c\u672a\u5907\u6848\uff0c\u56fd\u5916\u52a0\u901f\uff0c\u7528\u4e0e\u4e0b\u8f7d\u9875\u8df3\u8f6c\u57df\u540d", "created_time": "2021-05-21T21:25:33" } @@ -73,6 +75,7 @@ "ip_address": "d.cshort.top.w.kunlunsl.com", "is_enable": true, "is_system": true, + "is_https": false, "description": "d.cshort.top \u7cfb\u7edf\u81ea\u5e26\u57df\u540d\uff0c\u672a\u5907\u6848\uff0c\u56fd\u5916\u52a0\u901f\uff0c\u7528\u4e0e\u4e0b\u8f7d\u9875\u8df3\u8f6c\u57df\u540d", "created_time": "2021-05-21T21:25:33" } @@ -85,8 +88,165 @@ "ip_address": "d.eshort.top.w.kunlunsl.com", "is_enable": true, "is_system": true, + "is_https": false, "description": "d.eshort.top \u7cfb\u7edf\u81ea\u5e26\u57df\u540d\uff0c\u672a\u5907\u6848\uff0c\u56fd\u5916\u52a0\u901f\uff0c\u7528\u4e0e\u4e0b\u8f7d\u9875\u8df3\u8f6c\u57df\u540d", "created_time": "2021-05-21T21:25:33" } + }, + { + "model": "api.domaincnameinfo", + "pk": 5, + "fields": { + "domain_record": "234bfdd02542cf838cff76b9.dshort.top", + "ip_address": "47.241.30.190", + "is_enable": true, + "is_system": false, + "is_https": false, + "description": "", + "created_time": "2021-05-25T16:10:37.180" + } + }, + { + "model": "api.domaincnameinfo", + "pk": 6, + "fields": { + "domain_record": "03d9108cf7caf79ba2667a94.dshort.top", + "ip_address": "47.241.30.190", + "is_enable": true, + "is_system": false, + "is_https": false, + "description": "", + "created_time": "2021-05-25T16:14:17.624" + } + }, + { + "model": "api.domaincnameinfo", + "pk": 7, + "fields": { + "domain_record": "e61cc922e0227d4febfdd681.fshort.top", + "ip_address": "47.241.30.190", + "is_enable": true, + "is_system": false, + "is_https": false, + "description": "", + "created_time": "2021-05-25T16:16:17.067" + } + }, + { + "model": "api.domaincnameinfo", + "pk": 8, + "fields": { + "domain_record": "93bab80713ed87897d30e4db.fshort.top", + "ip_address": "47.241.30.190", + "is_enable": true, + "is_system": false, + "is_https": false, + "description": "", + "created_time": "2021-05-25T16:16:25.248" + } + }, + { + "model": "api.domaincnameinfo", + "pk": 9, + "fields": { + "domain_record": "b1cf45592f107520a29475dc.eshort.top", + "ip_address": "47.241.30.190", + "is_enable": true, + "is_system": false, + "is_https": false, + "description": "", + "created_time": "2021-05-25T16:36:38.244" + } + }, + { + "model": "api.domaincnameinfo", + "pk": 10, + "fields": { + "domain_record": "a897858c4775a288f99dd55e.eshort.top", + "ip_address": "47.241.30.190", + "is_enable": true, + "is_system": false, + "is_https": false, + "description": "", + "created_time": "2021-05-25T16:36:44.967" + } + }, + { + "model": "api.domaincnameinfo", + "pk": 11, + "fields": { + "domain_record": "2f717ce5b6d2ad8bc8216808.ashort.top", + "ip_address": "47.241.30.190", + "is_enable": true, + "is_system": false, + "is_https": false, + "description": "", + "created_time": "2021-05-25T16:37:38.661" + } + }, + { + "model": "api.domaincnameinfo", + "pk": 12, + "fields": { + "domain_record": "051466b64caf72a2de466400.ashort.top", + "ip_address": "47.241.30.190", + "is_enable": true, + "is_system": false, + "is_https": false, + "description": "", + "created_time": "2021-05-25T16:37:43.715" + } + }, + { + "model": "api.domaincnameinfo", + "pk": 13, + "fields": { + "domain_record": "eb7a92ce0b9c613f2dead7d4.bshort.top", + "ip_address": "47.241.30.190", + "is_enable": true, + "is_system": false, + "is_https": false, + "description": "", + "created_time": "2021-05-25T16:38:32.069" + } + }, + { + "model": "api.domaincnameinfo", + "pk": 14, + "fields": { + "domain_record": "798c2576b649ce38bdc16eb3.bshort.top", + "ip_address": "47.241.30.190", + "is_enable": true, + "is_system": false, + "is_https": false, + "description": "", + "created_time": "2021-05-25T16:38:36.919" + } + }, + { + "model": "api.domaincnameinfo", + "pk": 15, + "fields": { + "domain_record": "42ff0f107683baf335162f78.cshort.top", + "ip_address": "47.241.30.190", + "is_enable": true, + "is_system": false, + "is_https": false, + "description": "", + "created_time": "2021-05-25T16:39:18.063" + } + }, + { + "model": "api.domaincnameinfo", + "pk": 16, + "fields": { + "domain_record": "8fc3c8b4cc987c235a68b347.cshort.top", + "ip_address": "47.241.30.190", + "is_enable": true, + "is_system": false, + "is_https": false, + "description": "", + "created_time": "2021-05-25T16:39:23.235" + } } ] \ No newline at end of file