diff --git a/fir_client/src/components/apps/FirApps.vue b/fir_client/src/components/apps/FirApps.vue index 7cb44d7..7f1ffca 100644 --- a/fir_client/src/components/apps/FirApps.vue +++ b/fir_client/src/components/apps/FirApps.vue @@ -727,9 +727,19 @@ export default { } } else { - this.$message.error("应用 " + analyseappinfo.appname + " 上传token获取失败,请刷新重试") + let err_msg = "应用 " + analyseappinfo.appname + if (data.code === 1003) { + err_msg += " 上传token获取失败,请刷新重试" + } else { + err_msg += data.msg + } + this.$message.error(err_msg) + if (this.currentfile) { + this.closeUpload() + } else { + this.trymultiFileList.push(file); + } resolve() - this.trymultiFileList.push(file); // this.multiFileList.splice(this.multiFileList.indexOf(file), 1) } loading.close(); @@ -993,10 +1003,11 @@ export default { this.willuploadApp = false; this.uploadflag = false; this.analyseappinfo = {}; - + this.currentfile = null; this.multiupload = false; this.multiuploaddisable = false; this.multiFileList = []; + this.trymultiFileList = []; this.$refs.upload.clearFiles(); this.$refs.upload.abort(); this.uploadprocess = deepCopy(fiveProcess); diff --git a/fir_ser/api/migrations/0003_appbundleidblacklist.py b/fir_ser/api/migrations/0003_appbundleidblacklist.py new file mode 100644 index 0000000..83ccafc --- /dev/null +++ b/fir_ser/api/migrations/0003_appbundleidblacklist.py @@ -0,0 +1,29 @@ +# Generated by Django 3.2.3 on 2022-02-23 22:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ('api', '0002_auto_20220215_2129'), + ] + + operations = [ + migrations.CreateModel( + name='AppBundleIdBlackList', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('user_uid', models.CharField(default='*', max_length=64, verbose_name='用户ID,*表示全局')), + ('bundle_id', models.CharField(blank=True, max_length=64, verbose_name='bundle id')), + ('enable', models.BooleanField(default=True, verbose_name='是否启用该配置项')), + ('status', models.SmallIntegerField(choices=[(0, '黑名单'), (1, '白名单')], default=1, verbose_name='状态')), + ('description', models.CharField(blank=True, default='', max_length=256, verbose_name='备注')), + ('updated_time', models.DateTimeField(auto_now=True, verbose_name='更新时间')), + ], + options={ + 'verbose_name': '新应用上传黑白名单', + 'verbose_name_plural': '新应用上传黑白名单', + 'unique_together': {('user_uid', 'bundle_id')}, + }, + ), + ] diff --git a/fir_ser/api/models.py b/fir_ser/api/models.py index 1230b7d..52d978b 100644 --- a/fir_ser/api/models.py +++ b/fir_ser/api/models.py @@ -118,8 +118,6 @@ class VerifyName(models.Model): return f"self.name" -######################################## APP表 ######################################## - class Apps(models.Model): app_id = models.CharField(max_length=64, unique=True, db_index=True) # ,唯一标识 user_id = models.ForeignKey(to=UserInfo, verbose_name="用户ID", on_delete=models.CASCADE) @@ -159,6 +157,27 @@ class Apps(models.Model): return "%s %s-%s %s" % (self.name, self.get_type_display(), self.short, self.issupersign) +class AppBundleIdBlackList(models.Model): + """ + :keyword 优先级:用户黑名单 > 用户白名单 > 全局黑名单 > 全局白名单 + """ + user_uid = models.CharField(max_length=64, verbose_name="用户ID,*表示全局", default='*') + bundle_id = models.CharField(max_length=64, blank=True, verbose_name="bundle id") + enable = models.BooleanField(default=True, verbose_name="是否启用该配置项") + status_choices = ((0, '黑名单'), (1, '白名单')) + status = models.SmallIntegerField(choices=status_choices, default=1, verbose_name="状态") + description = models.CharField(verbose_name="备注", max_length=256, default='', blank=True) + updated_time = models.DateTimeField(auto_now=True, verbose_name="更新时间") + + class Meta: + verbose_name = '新应用上传黑白名单' + verbose_name_plural = "新应用上传黑白名单" + unique_together = ('user_uid', 'bundle_id') + + def __str__(self): + return "%s-%s-%s" % (self.user_uid, self.bundle_id, self.enable) + + class AppScreenShot(models.Model): app_id = models.ForeignKey(to=Apps, on_delete=models.CASCADE, verbose_name="属于哪个APP") screenshot_url = models.CharField(max_length=128, blank=True, verbose_name="应用截图URL") @@ -242,8 +261,6 @@ class AppStorage(models.Model): return "%s %s" % (self.user_id.get_username(), self.name) -######################################## 订单表 ######################################## - class Order(models.Model): """订单""" payment_type_choices = ((0, '微信'), (1, '支付宝'), (2, '优惠码'), (4, '银联')) diff --git a/fir_ser/api/utils/modelutils.py b/fir_ser/api/utils/modelutils.py index dc302ab..7c9cee8 100644 --- a/fir_ser/api/utils/modelutils.py +++ b/fir_ser/api/utils/modelutils.py @@ -12,7 +12,8 @@ from urllib.parse import urljoin from django.db.models import Count from rest_framework.pagination import PageNumberPagination -from api.models import AppReleaseInfo, UserDomainInfo, DomainCnameInfo, UserAdDisplayInfo, RemoteClientInfo +from api.models import AppReleaseInfo, UserDomainInfo, DomainCnameInfo, UserAdDisplayInfo, RemoteClientInfo, \ + AppBundleIdBlackList from common.base.baseutils import get_server_domain_from_request, get_user_default_domain_name, get_real_ip_address, \ get_origin_domain_name @@ -178,3 +179,24 @@ class PageNumber(PageNumberPagination): page_size_query_param = 'size' # URL中每页显示条数的参数 page_query_param = 'page' # URL中页码的参数 max_page_size = 100 # 最大页码数限制 + + +def check_bundle_id_legal(user_uid, bundle_id): + """ + 优先级:用户黑名单 > 用户白名单 > 全局黑名单 > 全局白名单 + 1. 用户白 通过,用户黑,拒绝 + 2.全局白 通过,全局黑,拒绝 + :param user_uid: user uid + :param bundle_id: bundle id + :return: default is allow, True is black + """ + base_queryset = AppBundleIdBlackList.objects.filter(enable=True, bundle_id=bundle_id).all() + if base_queryset: + app_black_obj = base_queryset.filter(user_uid=user_uid).first() + if app_black_obj: + return app_black_obj.status == 0 + else: + app_black_obj = base_queryset.filter(user_uid='*').first() + if app_black_obj: + return app_black_obj.status == 0 + return False diff --git a/fir_ser/api/views/uploads.py b/fir_ser/api/views/uploads.py index 6a80eaf..2813549 100644 --- a/fir_ser/api/views/uploads.py +++ b/fir_ser/api/views/uploads.py @@ -12,7 +12,7 @@ from rest_framework.views import APIView from api.models import Apps, AppReleaseInfo, UserInfo, AppScreenShot, CertificationInfo, UserAdDisplayInfo from api.utils.apputils import get_random_short, save_app_infos -from api.utils.modelutils import get_app_download_uri +from api.utils.modelutils import get_app_download_uri, check_bundle_id_legal from api.utils.response import BaseResponse from common.base.baseutils import make_app_uuid, make_from_user_uuid from common.cache.state import MigrateStorageState @@ -40,6 +40,11 @@ class AppAnalyseView(APIView): # 1.接收 bundelid ,返回随机应用名称和短连接 bundle_id = request.data.get("bundleid", None) app_type = request.data.get("type", None) + if bundle_id: + if check_bundle_id_legal(request.user.uid, bundle_id): + res.code = 1004 + res.msg = "疑似违规,上传失败,如有疑问,请联系管理员" + return Response(res.dict) if MigrateStorageState(request.user.uid).get_state(): res.code = 1008