feat: 增加应用profile 设置参数

This commit is contained in:
shaohuzhang1 2024-09-19 17:11:50 +08:00 committed by shaohuzhang1
parent 204676fa67
commit f2dae7b3e6
4 changed files with 25 additions and 36 deletions

View File

@ -716,6 +716,19 @@ class ApplicationSerializer(serializers.Serializer):
application_access_token = QuerySet(ApplicationAccessToken).filter(application_id=application.id).first()
if application_access_token is None:
raise AppUnauthorizedFailed(500, "非法用户")
application_setting_model = DBModelManage.get_model('application_setting')
X_PACK_LICENSE_IS_VALID = (settings.XPACK_LICENSE_IS_VALID if hasattr(settings,
'XPACK_LICENSE_IS_VALID') else False)
application_setting_dict = {}
if application_setting_model is not None and X_PACK_LICENSE_IS_VALID:
application_setting = QuerySet(application_setting_model).filter(
application_id=application_access_token.application_id).first()
application_setting_dict = {'show_source': application_access_token.show_source,
'show_history': application_setting.show_history,
'draggable': application_setting.draggable,
'show_guide': application_setting.show_guide,
'avatar': application_setting.avatar,
'float_icon': application_setting.float_icon}
return ApplicationSerializer.Query.reset_application(
{**ApplicationSerializer.ApplicationModel(application).data,
'stt_model_id': application.stt_model_id,
@ -724,7 +737,8 @@ class ApplicationSerializer(serializers.Serializer):
'tts_model_enable': application.tts_model_enable,
'tts_type': application.tts_type,
'work_flow': application.work_flow,
'show_source': application_access_token.show_source})
'show_source': application_access_token.show_source,
**application_setting_dict})
@transaction.atomic
def edit(self, instance: Dict, with_valid=True):

View File

@ -15,13 +15,11 @@ from io import BytesIO
from typing import Dict
import openpyxl
import xlwt
from django.core import validators
from django.core.cache import caches
from django.db import transaction, models
from django.db.models import QuerySet, Q
from django.http import HttpResponse, StreamingHttpResponse, HttpResponseServerError
from openpyxl.workbook import Workbook
from django.http import StreamingHttpResponse
from rest_framework import serializers
from application.flow.workflow_manage import Flow

View File

@ -35,19 +35,7 @@ const putAccessToken: (
return put(`${prefix}/${application_id}/setting`, data, undefined, loading)
}
/**
*
* @param
{
"access_token": "string"
}
*/
const getAppXpackProfile: (loading?: Ref<boolean>) => Promise<any> = (loading) => {
return get(`${prefix}/xpack/profile`, undefined, loading)
}
export default {
getAccessToken,
putAccessToken,
getAppXpackProfile
putAccessToken
}

View File

@ -79,25 +79,14 @@ const useApplicationStore = defineStore({
async asyncGetAppProfile(loading?: Ref<boolean>) {
return new Promise((resolve, reject) => {
const user = useUserStore()
if (user.isEnterprise()) {
applicationXpackApi
.getAppXpackProfile(loading)
.then((data) => {
resolve(data)
})
.catch((error) => {
reject(error)
})
} else {
applicationApi
.getAppProfile(loading)
.then((data) => {
resolve(data)
})
.catch((error) => {
reject(error)
})
}
applicationApi
.getAppProfile(loading)
.then((data) => {
resolve(data)
})
.catch((error) => {
reject(error)
})
})
},