优化代码

xsign
nineven 3 years ago
parent e9c6cadeb6
commit c6e78a6eab
  1. 22
      fir_client/src/components/apps/FirAppInfossupersign.vue
  2. 7
      fir_client/src/components/apps/FirApps.vue
  3. 7
      fir_client/src/components/user/FirSuperSignBase.vue
  4. 182
      fir_client/src/restful/index.js
  5. 9
      fir_ser/api/migrations/0001_initial.py
  6. 2
      fir_ser/api/views/uploads.py
  7. 8
      fir_ser/fir_ser/settings.py
  8. 3
      fir_ser/xsign/urls.py
  9. 42
      fir_ser/xsign/views/appinfo.py

@ -123,7 +123,7 @@
</template>
<script>
import {apputils,} from "@/restful"
import {appSignInfo,} from "@/restful"
import {deepCopy} from "@/utils";
import AppleDeveloperBindApp from "@/components/base/AppleDeveloperBindApp";
@ -164,13 +164,14 @@ export default {
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
apputils(data => {
appSignInfo(data => {
if (data.code === 1000) {
this.$message.success('数据更新成功');
} else {
this.$message.error('操作失败,' + data.msg);
this.$store.dispatch('doucurrentapp', this.orgcurrentapp);
}
this.getappinfo();
loading.close();
}, {
"methods": "PUT",
@ -178,6 +179,20 @@ export default {
"data": data
});
},
getappinfo(){
appSignInfo(data => {
if (data.code === 1000) {
for (let name of Object.keys(data.data)) {
this.currentapp[name] = data.data[name]
}
} else {
this.$message.error('数据获取失败,' + data.msg);
}
}, {
"methods": "GET",
"app_id": this.currentapp.app_id,
});
},
setbuttonsignshow(currentapp) {
if (currentapp.issupersign === true) {
this.supersignevent("on");
@ -229,6 +244,9 @@ export default {
},
appinit() {
this.currentapp = this.$store.state.currentapp;
if(this.currentapp.app_id){
this.getappinfo();
}
this.set_default_flag();
this.orgcurrentapp = deepCopy(this.currentapp);
this.set_default_ms(this.currentapp);

@ -587,7 +587,7 @@
</el-container>
</template>
<script>
import {analyseApps, apputils, get_package_prices, getapps, getuploadurl, my_order} from "@/restful";
import {analyseApps, apputils, checkCanSign, get_package_prices, getapps, getuploadurl, my_order} from "@/restful";
import {
dataURLtoFile,
deepCopy,
@ -715,8 +715,13 @@ export default {
analyseappinfo[name] = data.data[name]
}
if (this.currentfile) {
checkCanSign(res => {
if (res.code === 1000) {
analyseappinfo.sign = res.data.sign
}
this.willuploadApp = true;
resolve()
}, {methods: 'GET'})
} else {
this.uploadcloud(analyseappinfo, file, true, resolve)
}

@ -1579,7 +1579,14 @@ export default {
if (this.cert_pwd && this.cert_pwd.toString().trim().length > 0) {
let reader = new FileReader();
reader.onload = evt => {
const loadingobj = this.$loading({
lock: true,
text: '操作中,请耐心等待',
spinner: 'el-icon-loading',
// background: 'rgba(0, 0, 0, 0.7)'
});
developercert(data => {
loadingobj.close()
if (data.code === 1000) {
this.$message.success("证书导入成功");
this.importcertDeveloperVisible = false;

@ -73,7 +73,10 @@ export function set_auth_token() {
set_auth_token();
function ErrorMsg(error) {
function ErrorMsg(error, load) {
if (!load) {
return
}
if (error && error.response) {
switch (error.response.status) {
case 400:
@ -144,7 +147,7 @@ function getData(methods, url, params = {}, callBack, load, isCode = false) {
}
})
.catch(function (error) {
ErrorMsg(error);
ErrorMsg(error, load);
callBack({"code": -1});
});
@ -159,7 +162,7 @@ function getData(methods, url, params = {}, callBack, load, isCode = false) {
}
})
.catch(function (error) {
ErrorMsg(error);
ErrorMsg(error, load);
callBack({"code": -1});
});
@ -175,7 +178,7 @@ function getData(methods, url, params = {}, callBack, load, isCode = false) {
})
.catch(function (error) {
ErrorMsg(error);
ErrorMsg(error, load);
callBack({"code": -1});
});
} else if (methods === 'FILE') {
@ -185,7 +188,7 @@ function getData(methods, url, params = {}, callBack, load, isCode = false) {
convertRes2Blob(response)
})
.catch(function (error) {
ErrorMsg(error);
ErrorMsg(error, load);
callBack({"code": -1});
});
} else {
@ -195,7 +198,7 @@ function getData(methods, url, params = {}, callBack, load, isCode = false) {
callBack(response.data);
})
.catch(function (error) {
ErrorMsg(error);
ErrorMsg(error, load);
callBack({"code": -1});
});
}
@ -509,11 +512,27 @@ export function uploadimgs(callBack, params, load = true) {
);
}
/**超级签名 苹果开发者信息 */
export function iosdeveloper(callBack, params, load = true) {
/**获取充值价格信息 */
export function get_package_prices(callBack, params, load = true) {
getData(
'GET',
USERSEVER + '/package_prices',
params,
data => {
callBack(data);
},
load,
true,
true
);
}
/**用户订单 */
export function my_order(callBack, params, load = true) {
getData(
params.methods,
USERSEVER + '/supersign/developer',
USERSEVER + '/orders',
params.data,
data => {
callBack(data);
@ -524,11 +543,11 @@ export function iosdeveloper(callBack, params, load = true) {
);
}
/**超级签名 设备消耗信息 */
export function iosdevices(callBack, params, load = true) {
/**实名认证 */
export function user_certification(callBack, params, load = true) {
getData(
params.methods,
USERSEVER + '/supersign/devices',
USERSEVER + '/certification',
params.data,
data => {
callBack(data);
@ -539,12 +558,11 @@ export function iosdevices(callBack, params, load = true) {
);
}
/**超级签名 设备udid信息 */
export function iosdevicesudid(callBack, params, load = true) {
// eslint-disable-next-line no-console
/**用户信息修改验证 */
export function changeInfoFun(callBack, params, load = true) {
getData(
params.methods,
USERSEVER + '/supersign/udid',
USERSEVER + '/change',
params.data,
data => {
callBack(data);
@ -555,12 +573,12 @@ export function iosdevicesudid(callBack, params, load = true) {
);
}
/**超级签名 苹果开发设备udid信息 */
export function iosudevices(callBack, params, load = true) {
// eslint-disable-next-line no-console
/**用户绑定域名*/
export function domainFun(callBack, params, load = true) {
getData(
params.methods,
USERSEVER + '/supersign/udevices',
USERSEVER + '/cname_domain',
params.data,
data => {
callBack(data);
@ -571,12 +589,12 @@ export function iosudevices(callBack, params, load = true) {
);
}
/**获取充值价格信息 */
export function get_package_prices(callBack, params, load = true) {
/**获取签名任务状态 */
export function gettask(callBack, params, load = true) {
getData(
'GET',
USERSEVER + '/package_prices',
params,
USERSEVER + '/task/' + params.short,
params.data,
data => {
callBack(data);
},
@ -586,11 +604,12 @@ export function get_package_prices(callBack, params, load = true) {
);
}
/**用户订单 */
export function my_order(callBack, params, load = true) {
/**微信用户绑定 */
export function wxutils(callBack, params, load = true) {
getData(
params.methods,
USERSEVER + '/orders',
USERSEVER + '/twx/info',
params.data,
data => {
callBack(data);
@ -601,11 +620,11 @@ export function my_order(callBack, params, load = true) {
);
}
/**实名认证 */
export function user_certification(callBack, params, load = true) {
/**访问域名绑定 */
export function domaininfo(callBack, params, load = true) {
getData(
params.methods,
USERSEVER + '/certification',
USERSEVER + '/domain_info',
params.data,
data => {
callBack(data);
@ -616,11 +635,11 @@ export function user_certification(callBack, params, load = true) {
);
}
/**用户信息修改验证 */
export function changeInfoFun(callBack, params, load = true) {
/**自定义广告 */
export function advertinfo(callBack, params, load = true) {
getData(
params.methods,
USERSEVER + '/change',
USERSEVER + '/advert',
params.data,
data => {
callBack(data);
@ -631,12 +650,11 @@ export function changeInfoFun(callBack, params, load = true) {
);
}
/**用户绑定域名*/
export function domainFun(callBack, params, load = true) {
/**下载码大屏 */
export function qrcodeinfo(callBack, params, load = true) {
getData(
params.methods,
USERSEVER + '/cname_domain',
USERSEVER + '/qrcode',
params.data,
data => {
callBack(data);
@ -647,11 +665,12 @@ export function domainFun(callBack, params, load = true) {
);
}
/**获取签名任务状态 */
export function gettask(callBack, params, load = true) {
/**应用举报 */
export function appReport(callBack, params, load = true) {
getData(
'GET',
USERSEVER + '/task/' + params.short,
params.methods,
USERSEVER + '/report',
params.data,
data => {
callBack(data);
@ -662,12 +681,15 @@ export function gettask(callBack, params, load = true) {
);
}
// 超级签名相关api
/**签名证书 */
export function developercert(callBack, params, load = true) {
let SIGNSEVER = DOMAIN + '/api/v1/fir/xsign';
/** 超级签名--检测该账户是否可开启超级签名 */
export function checkCanSign(callBack, params, load = false) {
getData(
params.methods,
USERSEVER + '/supersign/cert',
SIGNSEVER + '/cansign',
params.data,
data => {
callBack(data);
@ -678,11 +700,11 @@ export function developercert(callBack, params, load = true) {
);
}
/**微信用户绑定 */
export function wxutils(callBack, params, load = true) {
/** 苹果签名应用操作 */
export function appSignInfo(callBack, params, load = true) {
getData(
params.methods,
USERSEVER + '/twx/info',
SIGNSEVER + '/signinfo/' + params.app_id,
params.data,
data => {
callBack(data);
@ -693,11 +715,11 @@ export function wxutils(callBack, params, load = true) {
);
}
/**访问域名绑定 */
export function domaininfo(callBack, params, load = true) {
/**签名账单 */
export function DeviceBillInfo(callBack, params, load = true) {
getData(
params.methods,
USERSEVER + '/domain_info',
SIGNSEVER + '/bill',
params.data,
data => {
callBack(data);
@ -708,11 +730,11 @@ export function domaininfo(callBack, params, load = true) {
);
}
/**自定义广告 */
export function advertinfo(callBack, params, load = true) {
/**设备流转账单 */
export function DeviceTransferBillInfo(callBack, params, load = true) {
getData(
params.methods,
USERSEVER + '/advert',
SIGNSEVER + '/devicebill',
params.data,
data => {
callBack(data);
@ -723,11 +745,11 @@ export function advertinfo(callBack, params, load = true) {
);
}
/**下载码大屏 */
export function qrcodeinfo(callBack, params, load = true) {
/**签名下载排行 */
export function DeviceRankInfo(callBack, params, load = true) {
getData(
params.methods,
USERSEVER + '/qrcode',
SIGNSEVER + '/rank',
params.data,
data => {
callBack(data);
@ -738,11 +760,11 @@ export function qrcodeinfo(callBack, params, load = true) {
);
}
/**签名账单 */
export function DeviceBillInfo(callBack, params, load = true) {
/**开发绑定应用*/
export function developerBindAppFun(callBack, params, load = true) {
getData(
params.methods,
USERSEVER + '/supersign/bill',
SIGNSEVER + '/bind',
params.data,
data => {
callBack(data);
@ -753,11 +775,12 @@ export function DeviceBillInfo(callBack, params, load = true) {
);
}
/**设备流转账单 */
export function DeviceTransferBillInfo(callBack, params, load = true) {
/**超级签名 苹果开发者信息 */
export function iosdeveloper(callBack, params, load = true) {
getData(
params.methods,
USERSEVER + '/supersign/devicebill',
SIGNSEVER + '/developer',
params.data,
data => {
callBack(data);
@ -768,11 +791,11 @@ export function DeviceTransferBillInfo(callBack, params, load = true) {
);
}
/**签名下载排行 */
export function DeviceRankInfo(callBack, params, load = true) {
/**超级签名 设备消耗信息 */
export function iosdevices(callBack, params, load = true) {
getData(
params.methods,
USERSEVER + '/supersign/rank',
SIGNSEVER + '/devices',
params.data,
data => {
callBack(data);
@ -783,11 +806,12 @@ export function DeviceRankInfo(callBack, params, load = true) {
);
}
/**开发绑定应用*/
export function developerBindAppFun(callBack, params, load = true) {
/**超级签名 设备udid信息 */
export function iosdevicesudid(callBack, params, load = true) {
// eslint-disable-next-line no-console
getData(
params.methods,
USERSEVER + '/supersign/bind',
SIGNSEVER + '/udid',
params.data,
data => {
callBack(data);
@ -798,11 +822,27 @@ export function developerBindAppFun(callBack, params, load = true) {
);
}
/**应用举报 */
export function appReport(callBack, params, load = true) {
/**超级签名 苹果开发设备udid信息 */
export function iosudevices(callBack, params, load = true) {
// eslint-disable-next-line no-console
getData(
params.methods,
USERSEVER + '/report',
SIGNSEVER + '/udevices',
params.data,
data => {
callBack(data);
},
load,
true,
true
);
}
/**签名证书 */
export function developercert(callBack, params, load = true) {
getData(
params.methods,
SIGNSEVER + '/cert',
params.data,
data => {
callBack(data);

@ -300,7 +300,8 @@ class Migration(migrations.Migration):
('created_time', models.DateTimeField(auto_now_add=True, verbose_name='订单创建时间')),
('description', models.TextField(blank=True, default='', null=True, verbose_name='备注')),
(
'user_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
'user_id',
models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
@ -332,7 +333,8 @@ class Migration(migrations.Migration):
('secret_key',
common.base.daobase.AESCharField(blank=True, max_length=128, null=True, verbose_name='存储访问secret')),
(
'bucket_name', models.CharField(blank=True, max_length=128, null=True, verbose_name='存储空间bucket_name')),
'bucket_name',
models.CharField(blank=True, max_length=128, null=True, verbose_name='存储空间bucket_name')),
('domain_name',
models.CharField(blank=True, help_text='fly-storage.dvcloud.xin,可以自定义端口', max_length=128, null=True,
verbose_name='下载域名')),
@ -401,7 +403,8 @@ class Migration(migrations.Migration):
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('is_master', models.BooleanField(default=True, verbose_name='是否master版本')),
(
'release_id', models.CharField(db_index=True, max_length=64, unique=True, verbose_name='release 版本id')),
'release_id',
models.CharField(db_index=True, max_length=64, unique=True, verbose_name='release 版本id')),
('build_version', models.CharField(blank=True, max_length=64, verbose_name='build版本')),
('app_version', models.CharField(blank=True, max_length=64, verbose_name='app版本')),
('release_type',

@ -23,7 +23,6 @@ from common.utils.caches import upload_file_tmp_name, del_cache_response_by_shor
from common.utils.storage import Storage
from common.utils.token import verify_token
from fir_ser import settings
from xsign.utils.modelutils import check_super_sign_permission
logger = logging.getLogger(__name__)
@ -90,7 +89,6 @@ class AppAnalyseView(APIView):
"storage": storage_type,
"is_new": is_new,
"binary_url": binary_url,
"sign": check_super_sign_permission(request.user),
"enable_sign": enable_sign
}
if storage_type not in [1, 2]:

@ -369,7 +369,7 @@ LOGGING = {
'encoding': 'utf-8',
},
'sql': {
'level': 'INFO',
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler', # 保存到文件,自动切
'filename': os.path.join(BASE_LOG_DIR, "flyapp_sql.log"), # 日志文件
'maxBytes': 1024 * 1024 * 50, # 日志大小 50M
@ -392,7 +392,7 @@ LOGGING = {
'django.db.backends': {
'handlers': ['console', 'sql'],
'propagate': True,
'level': 'DEBUG',
'level': 'INFO',
},
},
}
@ -453,7 +453,7 @@ CELERY_BEAT_SCHEDULE = {
'args': ()
},
'auto_check_ios_developer_active_job': {
'task': 'api.tasks.auto_check_ios_developer_active_job',
'task': 'xsign.tasks.auto_check_ios_developer_active_job',
# 'schedule': SYNC_CACHE_TO_DATABASE.get("auto_check_ios_developer_active_times"),
'schedule': crontab(hour=1, minute=1),
'args': ()
@ -470,7 +470,7 @@ CELERY_BEAT_SCHEDULE = {
'args': (),
},
'get_best_proxy_ips_job': {
'task': 'api.tasks.get_best_proxy_ips_job',
'task': 'xsign.tasks.get_best_proxy_ips_job',
'schedule': SYNC_CACHE_TO_DATABASE.get("best_proxy_ips_times"),
'args': (),
},

@ -15,6 +15,7 @@ Including another URLconf
"""
from django.urls import re_path
from xsign.views.appinfo import AppCanSignView, AppSignInfoView
from xsign.views.receiveudids import IosUDIDView, TaskView
from xsign.views.supersign import DeveloperView, SuperSignUsedView, AppUDIDUsedView, SuperSignCertView, \
DeviceUsedBillView, DeveloperDeviceView, DeviceUsedRankInfoView, AppleDeveloperBindAppsView, DeviceTransferBillView
@ -31,4 +32,6 @@ urlpatterns = [
re_path(r"^devicebill$", DeviceTransferBillView.as_view()),
re_path(r"^rank$", DeviceUsedRankInfoView.as_view()),
re_path(r"^bind$", AppleDeveloperBindAppsView.as_view()),
re_path(r"^cansign$", AppCanSignView.as_view()),
re_path(r"^signinfo/(?P<app_id>\w+)$", AppSignInfoView.as_view()),
]

@ -5,13 +5,12 @@
# date: 2020/3/6
import logging
from rest_framework.response import Response
from rest_framework.views import APIView
from api.models import Apps
from api.utils.response import BaseResponse
from common.cache.state import MigrateStorageState, CleanAppSignDataState
from common.core.auth import ExpiringTokenAuthentication
from common.core.response import ApiResponse
from common.core.sysconfig import Config
from common.utils.caches import del_cache_response_by_short
from xsign.models import AppUDID
@ -26,26 +25,22 @@ class AppSignInfoView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ]
def get(self, request, app_id):
res = BaseResponse()
data = None
if app_id:
app_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first()
if app_obj:
res.data = get_app_sign_info(app_obj)
data = get_app_sign_info(app_obj)
else:
logger.error(f"app_id:{app_id} is not found in user:{request.user}")
res.msg = "未找到该应用"
res.code = 1003
return ApiResponse(code=1003, msg="应用不存在")
return Response(res.dict)
return ApiResponse(data=data)
def put(self, request, app_id):
res = BaseResponse()
if app_id:
data = request.data
if MigrateStorageState(request.user.uid).get_state():
res.code = 1008
res.msg = "数据迁移中,无法处理该操作"
return Response(res.dict)
return ApiResponse(code=1008, msg="数据迁移中,无法处理该操作")
clean = data.get("clean", None)
if clean:
@ -55,14 +50,9 @@ class AppSignInfoView(APIView):
app_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first()
IosUtils.clean_app_by_user_obj(app_obj)
else:
res.code = 1008
res.msg = "数据清理中,请耐心等待"
return Response(res.dict)
return ApiResponse(code=1008, msg="数据清理中,请耐心等待")
return ApiResponse()
has_combo = data.get("has_combo", None)
if has_combo:
...
else:
try:
do_sign_flag = 0
app_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first()
@ -102,9 +92,7 @@ class AppSignInfoView(APIView):
if app_obj.type == 1 and data.get('issupersign', -1) != -1:
if data.get('issupersign', -1) == 1 and not check_super_sign_permission(request.user):
logger.error(f"app_id:{app_id} can't open super_sign,owner has no ios developer")
res.code = 1008
res.msg = "超级签余额不足,无法开启"
return Response(res.dict)
return ApiResponse(code=1008, msg="超级签余额不足,无法开启")
do_sign_flag = 3
app_obj.issupersign = data.get("issupersign", app_obj.issupersign)
update_fields.append("issupersign")
@ -145,7 +133,13 @@ class AppSignInfoView(APIView):
del_cache_response_by_short(app_obj.app_id)
except Exception as e:
logger.error(f"app_id:{app_id} update Exception:{e}")
res.code = 1005
res.msg = "短连接已经存在"
return ApiResponse(code=1005, msg="短连接已经存在")
return ApiResponse()
class AppCanSignView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ]
return Response(res.dict)
def get(self, request):
return ApiResponse(data={'sign': True})

Loading…
Cancel
Save