优化代码

xsign
nineven 3 years ago
parent e9c6cadeb6
commit c6e78a6eab
  1. 22
      fir_client/src/components/apps/FirAppInfossupersign.vue
  2. 11
      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. 200
      fir_ser/xsign/views/appinfo.py

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

@ -587,7 +587,7 @@
</el-container> </el-container>
</template> </template>
<script> <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 { import {
dataURLtoFile, dataURLtoFile,
deepCopy, deepCopy,
@ -715,8 +715,13 @@ export default {
analyseappinfo[name] = data.data[name] analyseappinfo[name] = data.data[name]
} }
if (this.currentfile) { if (this.currentfile) {
this.willuploadApp = true; checkCanSign(res => {
resolve() if (res.code === 1000) {
analyseappinfo.sign = res.data.sign
}
this.willuploadApp = true;
resolve()
}, {methods: 'GET'})
} else { } else {
this.uploadcloud(analyseappinfo, file, true, resolve) this.uploadcloud(analyseappinfo, file, true, resolve)
} }

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

@ -73,7 +73,10 @@ export function set_auth_token() {
set_auth_token(); set_auth_token();
function ErrorMsg(error) { function ErrorMsg(error, load) {
if (!load) {
return
}
if (error && error.response) { if (error && error.response) {
switch (error.response.status) { switch (error.response.status) {
case 400: case 400:
@ -144,7 +147,7 @@ function getData(methods, url, params = {}, callBack, load, isCode = false) {
} }
}) })
.catch(function (error) { .catch(function (error) {
ErrorMsg(error); ErrorMsg(error, load);
callBack({"code": -1}); callBack({"code": -1});
}); });
@ -159,7 +162,7 @@ function getData(methods, url, params = {}, callBack, load, isCode = false) {
} }
}) })
.catch(function (error) { .catch(function (error) {
ErrorMsg(error); ErrorMsg(error, load);
callBack({"code": -1}); callBack({"code": -1});
}); });
@ -175,7 +178,7 @@ function getData(methods, url, params = {}, callBack, load, isCode = false) {
}) })
.catch(function (error) { .catch(function (error) {
ErrorMsg(error); ErrorMsg(error, load);
callBack({"code": -1}); callBack({"code": -1});
}); });
} else if (methods === 'FILE') { } else if (methods === 'FILE') {
@ -185,7 +188,7 @@ function getData(methods, url, params = {}, callBack, load, isCode = false) {
convertRes2Blob(response) convertRes2Blob(response)
}) })
.catch(function (error) { .catch(function (error) {
ErrorMsg(error); ErrorMsg(error, load);
callBack({"code": -1}); callBack({"code": -1});
}); });
} else { } else {
@ -195,7 +198,7 @@ function getData(methods, url, params = {}, callBack, load, isCode = false) {
callBack(response.data); callBack(response.data);
}) })
.catch(function (error) { .catch(function (error) {
ErrorMsg(error); ErrorMsg(error, load);
callBack({"code": -1}); 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( getData(
params.methods, params.methods,
USERSEVER + '/supersign/developer', USERSEVER + '/orders',
params.data, params.data,
data => { data => {
callBack(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( getData(
params.methods, params.methods,
USERSEVER + '/supersign/devices', USERSEVER + '/certification',
params.data, params.data,
data => { data => {
callBack(data); callBack(data);
@ -539,12 +558,11 @@ export function iosdevices(callBack, params, load = true) {
); );
} }
/**超级签名 设备udid信息 */ /**用户信息修改验证 */
export function iosdevicesudid(callBack, params, load = true) { export function changeInfoFun(callBack, params, load = true) {
// eslint-disable-next-line no-console
getData( getData(
params.methods, params.methods,
USERSEVER + '/supersign/udid', USERSEVER + '/change',
params.data, params.data,
data => { data => {
callBack(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( getData(
params.methods, params.methods,
USERSEVER + '/supersign/udevices', USERSEVER + '/cname_domain',
params.data, params.data,
data => { data => {
callBack(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( getData(
'GET', 'GET',
USERSEVER + '/package_prices', USERSEVER + '/task/' + params.short,
params, params.data,
data => { data => {
callBack(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( getData(
params.methods, params.methods,
USERSEVER + '/orders', USERSEVER + '/twx/info',
params.data, params.data,
data => { data => {
callBack(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( getData(
params.methods, params.methods,
USERSEVER + '/certification', USERSEVER + '/domain_info',
params.data, params.data,
data => { data => {
callBack(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( getData(
params.methods, params.methods,
USERSEVER + '/change', USERSEVER + '/advert',
params.data, params.data,
data => { data => {
callBack(data); callBack(data);
@ -631,12 +650,11 @@ export function changeInfoFun(callBack, params, load = true) {
); );
} }
/**下载码大屏 */
/**用户绑定域名*/ export function qrcodeinfo(callBack, params, load = true) {
export function domainFun(callBack, params, load = true) {
getData( getData(
params.methods, params.methods,
USERSEVER + '/cname_domain', USERSEVER + '/qrcode',
params.data, params.data,
data => { data => {
callBack(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( getData(
'GET', params.methods,
USERSEVER + '/task/' + params.short, USERSEVER + '/report',
params.data, params.data,
data => { data => {
callBack(data); callBack(data);
@ -662,12 +681,15 @@ export function gettask(callBack, params, load = true) {
); );
} }
// 超级签名相关api
/**签名证书 */ let SIGNSEVER = DOMAIN + '/api/v1/fir/xsign';
export function developercert(callBack, params, load = true) {
/** 超级签名--检测该账户是否可开启超级签名 */
export function checkCanSign(callBack, params, load = false) {
getData( getData(
params.methods, params.methods,
USERSEVER + '/supersign/cert', SIGNSEVER + '/cansign',
params.data, params.data,
data => { data => {
callBack(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( getData(
params.methods, params.methods,
USERSEVER + '/twx/info', SIGNSEVER + '/signinfo/' + params.app_id,
params.data, params.data,
data => { data => {
callBack(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( getData(
params.methods, params.methods,
USERSEVER + '/domain_info', SIGNSEVER + '/bill',
params.data, params.data,
data => { data => {
callBack(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( getData(
params.methods, params.methods,
USERSEVER + '/advert', SIGNSEVER + '/devicebill',
params.data, params.data,
data => { data => {
callBack(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( getData(
params.methods, params.methods,
USERSEVER + '/qrcode', SIGNSEVER + '/rank',
params.data, params.data,
data => { data => {
callBack(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( getData(
params.methods, params.methods,
USERSEVER + '/supersign/bill', SIGNSEVER + '/bind',
params.data, params.data,
data => { data => {
callBack(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( getData(
params.methods, params.methods,
USERSEVER + '/supersign/devicebill', SIGNSEVER + '/developer',
params.data, params.data,
data => { data => {
callBack(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( getData(
params.methods, params.methods,
USERSEVER + '/supersign/rank', SIGNSEVER + '/devices',
params.data, params.data,
data => { data => {
callBack(data); callBack(data);
@ -783,11 +806,12 @@ export function DeviceRankInfo(callBack, params, load = true) {
); );
} }
/**开发绑定应用*/ /**超级签名 设备udid信息 */
export function developerBindAppFun(callBack, params, load = true) { export function iosdevicesudid(callBack, params, load = true) {
// eslint-disable-next-line no-console
getData( getData(
params.methods, params.methods,
USERSEVER + '/supersign/bind', SIGNSEVER + '/udid',
params.data, params.data,
data => { data => {
callBack(data); callBack(data);
@ -798,11 +822,12 @@ export function developerBindAppFun(callBack, params, load = true) {
); );
} }
/**应用举报 */ /**超级签名 苹果开发设备udid信息 */
export function appReport(callBack, params, load = true) { export function iosudevices(callBack, params, load = true) {
// eslint-disable-next-line no-console
getData( getData(
params.methods, params.methods,
USERSEVER + '/report', SIGNSEVER + '/udevices',
params.data, params.data,
data => { data => {
callBack(data); callBack(data);
@ -812,3 +837,18 @@ export function appReport(callBack, params, load = true) {
true true
); );
} }
/**签名证书 */
export function developercert(callBack, params, load = true) {
getData(
params.methods,
SIGNSEVER + '/cert',
params.data,
data => {
callBack(data);
},
load,
true,
true
);
}

@ -300,7 +300,8 @@ class Migration(migrations.Migration):
('created_time', models.DateTimeField(auto_now_add=True, verbose_name='订单创建时间')), ('created_time', models.DateTimeField(auto_now_add=True, verbose_name='订单创建时间')),
('description', models.TextField(blank=True, default='', null=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( migrations.CreateModel(
@ -332,7 +333,8 @@ class Migration(migrations.Migration):
('secret_key', ('secret_key',
common.base.daobase.AESCharField(blank=True, max_length=128, null=True, verbose_name='存储访问secret')), 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', ('domain_name',
models.CharField(blank=True, help_text='fly-storage.dvcloud.xin,可以自定义端口', max_length=128, null=True, models.CharField(blank=True, help_text='fly-storage.dvcloud.xin,可以自定义端口', max_length=128, null=True,
verbose_name='下载域名')), verbose_name='下载域名')),
@ -401,7 +403,8 @@ class Migration(migrations.Migration):
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('is_master', models.BooleanField(default=True, verbose_name='是否master版本')), ('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版本')), ('build_version', models.CharField(blank=True, max_length=64, verbose_name='build版本')),
('app_version', models.CharField(blank=True, max_length=64, verbose_name='app版本')), ('app_version', models.CharField(blank=True, max_length=64, verbose_name='app版本')),
('release_type', ('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.storage import Storage
from common.utils.token import verify_token from common.utils.token import verify_token
from fir_ser import settings from fir_ser import settings
from xsign.utils.modelutils import check_super_sign_permission
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -90,7 +89,6 @@ class AppAnalyseView(APIView):
"storage": storage_type, "storage": storage_type,
"is_new": is_new, "is_new": is_new,
"binary_url": binary_url, "binary_url": binary_url,
"sign": check_super_sign_permission(request.user),
"enable_sign": enable_sign "enable_sign": enable_sign
} }
if storage_type not in [1, 2]: if storage_type not in [1, 2]:

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

@ -15,6 +15,7 @@ Including another URLconf
""" """
from django.urls import re_path from django.urls import re_path
from xsign.views.appinfo import AppCanSignView, AppSignInfoView
from xsign.views.receiveudids import IosUDIDView, TaskView from xsign.views.receiveudids import IosUDIDView, TaskView
from xsign.views.supersign import DeveloperView, SuperSignUsedView, AppUDIDUsedView, SuperSignCertView, \ from xsign.views.supersign import DeveloperView, SuperSignUsedView, AppUDIDUsedView, SuperSignCertView, \
DeviceUsedBillView, DeveloperDeviceView, DeviceUsedRankInfoView, AppleDeveloperBindAppsView, DeviceTransferBillView DeviceUsedBillView, DeveloperDeviceView, DeviceUsedRankInfoView, AppleDeveloperBindAppsView, DeviceTransferBillView
@ -31,4 +32,6 @@ urlpatterns = [
re_path(r"^devicebill$", DeviceTransferBillView.as_view()), re_path(r"^devicebill$", DeviceTransferBillView.as_view()),
re_path(r"^rank$", DeviceUsedRankInfoView.as_view()), re_path(r"^rank$", DeviceUsedRankInfoView.as_view()),
re_path(r"^bind$", AppleDeveloperBindAppsView.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 # date: 2020/3/6
import logging import logging
from rest_framework.response import Response
from rest_framework.views import APIView from rest_framework.views import APIView
from api.models import Apps from api.models import Apps
from api.utils.response import BaseResponse
from common.cache.state import MigrateStorageState, CleanAppSignDataState from common.cache.state import MigrateStorageState, CleanAppSignDataState
from common.core.auth import ExpiringTokenAuthentication from common.core.auth import ExpiringTokenAuthentication
from common.core.response import ApiResponse
from common.core.sysconfig import Config from common.core.sysconfig import Config
from common.utils.caches import del_cache_response_by_short from common.utils.caches import del_cache_response_by_short
from xsign.models import AppUDID from xsign.models import AppUDID
@ -26,26 +25,22 @@ class AppSignInfoView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ] authentication_classes = [ExpiringTokenAuthentication, ]
def get(self, request, app_id): def get(self, request, app_id):
res = BaseResponse() data = None
if app_id: if app_id:
app_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first() app_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first()
if app_obj: if app_obj:
res.data = get_app_sign_info(app_obj) data = get_app_sign_info(app_obj)
else: else:
logger.error(f"app_id:{app_id} is not found in user:{request.user}") logger.error(f"app_id:{app_id} is not found in user:{request.user}")
res.msg = "未找到该应用" return ApiResponse(code=1003, msg="应用不存在")
res.code = 1003
return Response(res.dict) return ApiResponse(data=data)
def put(self, request, app_id): def put(self, request, app_id):
res = BaseResponse()
if app_id: if app_id:
data = request.data data = request.data
if MigrateStorageState(request.user.uid).get_state(): if MigrateStorageState(request.user.uid).get_state():
res.code = 1008 return ApiResponse(code=1008, msg="数据迁移中,无法处理该操作")
res.msg = "数据迁移中,无法处理该操作"
return Response(res.dict)
clean = data.get("clean", None) clean = data.get("clean", None)
if clean: if clean:
@ -55,97 +50,96 @@ class AppSignInfoView(APIView):
app_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first() app_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first()
IosUtils.clean_app_by_user_obj(app_obj) IosUtils.clean_app_by_user_obj(app_obj)
else: else:
res.code = 1008 return ApiResponse(code=1008, msg="数据清理中,请耐心等待")
res.msg = "数据清理中,请耐心等待" return ApiResponse()
return Response(res.dict)
has_combo = data.get("has_combo", None) try:
if has_combo: do_sign_flag = 0
... app_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first()
else: logger.info("app_id:%s update old data:%s" % (app_id, app_obj.__dict__))
try: update_fields = []
do_sign_flag = 0 if app_obj.issupersign:
app_obj = Apps.objects.filter(user_id=request.user, app_id=app_id).first() app_obj.supersign_limit_number = data.get("supersign_limit_number",
logger.info("app_id:%s update old data:%s" % (app_id, app_obj.__dict__)) app_obj.supersign_limit_number)
update_fields = [] update_fields.append("supersign_limit_number")
if app_obj.issupersign: if app_obj.supersign_type in [x[0] for x in list(app_obj.supersign_type_choices)]:
app_obj.supersign_limit_number = data.get("supersign_limit_number", if app_obj.supersign_type != data.get("supersign_type", app_obj.supersign_type):
app_obj.supersign_limit_number) do_sign_flag = 1
update_fields.append("supersign_limit_number") app_obj.supersign_type = data.get("supersign_type", app_obj.supersign_type)
if app_obj.supersign_type in [x[0] for x in list(app_obj.supersign_type_choices)]: update_fields.append("supersign_type")
if app_obj.supersign_type != data.get("supersign_type", app_obj.supersign_type): new_bundle_id = data.get("new_bundle_id", None)
do_sign_flag = 1 new_bundle_name = data.get("new_bundle_name", None)
app_obj.supersign_type = data.get("supersign_type", app_obj.supersign_type) if new_bundle_id is not None:
update_fields.append("supersign_type") if new_bundle_id and new_bundle_id != app_obj.bundle_id and len(new_bundle_id) > 3:
new_bundle_id = data.get("new_bundle_id", None) if new_bundle_id != app_obj.new_bundle_id:
new_bundle_name = data.get("new_bundle_name", None) do_sign_flag = 2
if new_bundle_id is not None: app_obj.new_bundle_id = new_bundle_id
if new_bundle_id and new_bundle_id != app_obj.bundle_id and len(new_bundle_id) > 3: if new_bundle_id == '' or (app_obj.new_bundle_id != new_bundle_id):
if new_bundle_id != app_obj.new_bundle_id: if app_obj.bundle_id != app_obj.new_bundle_id:
do_sign_flag = 2 do_sign_flag = 2
app_obj.new_bundle_id = new_bundle_id app_obj.new_bundle_id = app_obj.bundle_id
if new_bundle_id == '' or (app_obj.new_bundle_id != new_bundle_id): update_fields.append('new_bundle_id')
if app_obj.bundle_id != app_obj.new_bundle_id: if new_bundle_name is not None:
do_sign_flag = 2 if new_bundle_name and new_bundle_name != app_obj.name and len(new_bundle_name) > 0:
app_obj.new_bundle_id = app_obj.bundle_id if new_bundle_name != app_obj.new_bundle_name:
update_fields.append('new_bundle_id') do_sign_flag = 2
if new_bundle_name is not None: app_obj.new_bundle_name = new_bundle_name
if new_bundle_name and new_bundle_name != app_obj.name and len(new_bundle_name) > 0: if new_bundle_name == '' or (app_obj.new_bundle_name != new_bundle_name):
if new_bundle_name != app_obj.new_bundle_name: if app_obj.name != app_obj.new_bundle_name:
do_sign_flag = 2 do_sign_flag = 2
app_obj.new_bundle_name = new_bundle_name app_obj.new_bundle_name = app_obj.name
if new_bundle_name == '' or (app_obj.new_bundle_name != new_bundle_name): update_fields.append('new_bundle_name')
if app_obj.name != app_obj.new_bundle_name: if app_obj.type == 1 and data.get('issupersign', -1) != -1:
do_sign_flag = 2 if data.get('issupersign', -1) == 1 and not check_super_sign_permission(request.user):
app_obj.new_bundle_name = app_obj.name logger.error(f"app_id:{app_id} can't open super_sign,owner has no ios developer")
update_fields.append('new_bundle_name') return ApiResponse(code=1008, msg="超级签余额不足,无法开启")
if app_obj.type == 1 and data.get('issupersign', -1) != -1: do_sign_flag = 3
if data.get('issupersign', -1) == 1 and not check_super_sign_permission(request.user): app_obj.issupersign = data.get("issupersign", app_obj.issupersign)
logger.error(f"app_id:{app_id} can't open super_sign,owner has no ios developer") update_fields.append("issupersign")
res.code = 1008 if app_obj.issupersign and data.get('change_auto_sign', -1) != -1:
res.msg = "超级签余额不足,无法开启" if data.get('change_auto_sign', -1) == 1:
return Response(res.dict)
do_sign_flag = 3 do_sign_flag = 3
app_obj.issupersign = data.get("issupersign", app_obj.issupersign) app_obj.change_auto_sign = data.get("change_auto_sign", app_obj.change_auto_sign)
update_fields.append("issupersign") update_fields.append("change_auto_sign")
if app_obj.issupersign and data.get('change_auto_sign', -1) != -1:
if data.get('change_auto_sign', -1) == 1: logger.info(f"app_id:{app_id} update new data:{app_obj.__dict__}")
do_sign_flag = 3 app_obj.save(update_fields=update_fields)
app_obj.change_auto_sign = data.get("change_auto_sign", app_obj.change_auto_sign) if app_obj.issupersign:
update_fields.append("change_auto_sign") c_task = None
if do_sign_flag == 1:
logger.info(f"app_id:{app_id} update new data:{app_obj.__dict__}") AppUDID.objects.filter(app_id=app_obj).update(sign_status=2)
app_obj.save(update_fields=update_fields) if app_obj.change_auto_sign:
if app_obj.issupersign: c_task = run_resign_task(app_obj.pk, True)
c_task = None
if do_sign_flag == 1: if do_sign_flag == 2:
AppUDID.objects.filter(app_id=app_obj).update(sign_status=2) AppUDID.objects.filter(app_id=app_obj, sign_status__gte=3).update(sign_status=3)
if app_obj.change_auto_sign: if app_obj.change_auto_sign:
c_task = run_resign_task(app_obj.pk, True) flag = False
if AppUDID.objects.filter(app_id=app_obj, sign_status=2,
if do_sign_flag == 2: udid__developerid__status__in=Config.DEVELOPER_WRITE_STATUS).first():
AppUDID.objects.filter(app_id=app_obj, sign_status__gte=3).update(sign_status=3) flag = True
if app_obj.change_auto_sign: c_task = run_resign_task(app_obj.pk, flag)
flag = False
if AppUDID.objects.filter(app_id=app_obj, sign_status=2, if do_sign_flag == 3:
udid__developerid__status__in=Config.DEVELOPER_WRITE_STATUS).first(): if app_obj.change_auto_sign:
flag = True flag = False
c_task = run_resign_task(app_obj.pk, flag) if AppUDID.objects.filter(app_id=app_obj, sign_status=2,
udid__developerid__status__in=Config.DEVELOPER_WRITE_STATUS).first():
if do_sign_flag == 3: flag = True
if app_obj.change_auto_sign: c_task = run_resign_task(app_obj.pk, flag, False)
flag = False
if AppUDID.objects.filter(app_id=app_obj, sign_status=2, if c_task:
udid__developerid__status__in=Config.DEVELOPER_WRITE_STATUS).first(): logger.info(f"app {app_obj} run_resign_task msg:{c_task}")
flag = True del_cache_response_by_short(app_obj.app_id)
c_task = run_resign_task(app_obj.pk, flag, False) except Exception as e:
logger.error(f"app_id:{app_id} update Exception:{e}")
if c_task: return ApiResponse(code=1005, msg="短连接已经存在")
logger.info(f"app {app_obj} run_resign_task msg:{c_task}")
del_cache_response_by_short(app_obj.app_id) return ApiResponse()
except Exception as e:
logger.error(f"app_id:{app_id} update Exception:{e}")
res.code = 1005 class AppCanSignView(APIView):
res.msg = "短连接已经存在" authentication_classes = [ExpiringTokenAuthentication, ]
return Response(res.dict) def get(self, request):
return ApiResponse(data={'sign': True})

Loading…
Cancel
Save