parent
8d18692809
commit
1027110786
@ -0,0 +1,66 @@ |
||||
<template> |
||||
<div> |
||||
|
||||
<el-select v-model="use_storage_id" clearable filterable placeholder="请选择" @change="select_storage"> |
||||
<el-option-group |
||||
v-for="storage_group in fstorage_lists" |
||||
:key="storage_group.group_name" |
||||
:label="storage_group.group_name"> |
||||
<el-option |
||||
v-for="storage in storage_group.storage" |
||||
:key="storage.id" |
||||
:label="storage.name" |
||||
:value="storage.id"> |
||||
</el-option> |
||||
</el-option-group> |
||||
</el-select> |
||||
|
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import {getStorageinfo} from "../restful"; |
||||
|
||||
export default { |
||||
name: "FirUserProfileStorage", |
||||
data() { |
||||
return { |
||||
fstorage_lists:[[]], |
||||
use_storage_id:null |
||||
} |
||||
}, methods: { |
||||
select_storage(a){ |
||||
// eslint-disable-next-line no-console |
||||
console.log(a) |
||||
}, |
||||
format_storage(storage_lists){ |
||||
|
||||
|
||||
for(let key in storage_lists){ |
||||
let storage = storage_lists[key]; |
||||
if(storage[0].storage_type_display){ |
||||
this.fstorage_lists.unshift({'group_name':storage[0].storage_type_display,'storage':storage}) |
||||
} |
||||
} |
||||
}, |
||||
getstorageinfoFun() { |
||||
// eslint-disable-next-line no-console |
||||
getStorageinfo(data=>{ |
||||
if(data.code === 1000){ |
||||
this.format_storage(data.data); |
||||
this.use_storage_id = data.data.storage; |
||||
}else { |
||||
this.$message.error('存储获取失败,'+data); |
||||
} |
||||
},{"methods":false}); |
||||
} |
||||
}, mounted() { |
||||
this.$store.dispatch('douserInfoIndex', 2); |
||||
this.getstorageinfoFun(); |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
</style> |
@ -0,0 +1,47 @@ |
||||
#!/usr/bin/env python |
||||
# -*- coding:utf-8 -*- |
||||
# project: 3月 |
||||
# author: liuyu |
||||
# date: 2020/3/4 |
||||
|
||||
from rest_framework.views import APIView |
||||
from api.utils.response import BaseResponse |
||||
from api.utils.auth import ExpiringTokenAuthentication |
||||
from rest_framework.response import Response |
||||
from django.db.models import Sum |
||||
import os |
||||
from fir_ser import settings |
||||
from api.utils.app.randomstrings import make_from_user_uuid |
||||
from api.utils.storage.storage import Storage |
||||
from api.utils.storage.caches import del_cache_response_by_short,get_app_today_download_times |
||||
from api.models import Apps, AppReleaseInfo,AppStorage |
||||
from api.utils.serializer import StorageSerializer |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class StorageView(APIView): |
||||
authentication_classes = [ExpiringTokenAuthentication, ] |
||||
def get(self, request): |
||||
res = BaseResponse() |
||||
# [1,2] 表示七牛存储和阿里云存储 |
||||
storage_obj = AppStorage.objects.filter(user_id=request.user,storage_type__in=[1,2]) |
||||
if storage_obj: |
||||
storage_serializer = StorageSerializer(storage_obj,many=True) |
||||
storage_data_lists = storage_serializer.data |
||||
storage_lists={} |
||||
for storage_data in storage_data_lists: |
||||
storage_type = storage_data.get("storage_type") |
||||
if not storage_lists.get(storage_type): |
||||
storage_lists[storage_type]=[] |
||||
storage_lists[storage_type].append(storage_data) |
||||
res.data=storage_lists |
||||
|
||||
use_storage_obj = request.user.storage |
||||
if use_storage_obj: |
||||
res.storage=use_storage_obj.id |
||||
else: |
||||
res.storage = None |
||||
|
||||
return Response(res.dict) |
Loading…
Reference in new issue