获取参数配置
parent
a19c95bd42
commit
d8ea729d2e
|
@ -1,7 +1,7 @@
|
|||
from django.urls import re_path
|
||||
from rest_framework.routers import DefaultRouter
|
||||
|
||||
from apps.system.views import DictDataModelViewSet, DictDetailsModelViewSet, DictDetailsListModelViewSet, \
|
||||
from apps.system.views import DictDataModelViewSet, DictDetailsModelViewSet, \
|
||||
ConfigSettingsModelViewSet
|
||||
|
||||
router = DefaultRouter()
|
||||
|
@ -9,6 +9,7 @@ router.register(r'dict/type', DictDataModelViewSet)
|
|||
router.register(r'dict/data', DictDetailsModelViewSet)
|
||||
router.register(r'config', ConfigSettingsModelViewSet)
|
||||
urlpatterns = [
|
||||
re_path('dict/get/type/(?P<pk>.*)/', DictDetailsListModelViewSet.as_view({'get': 'list'})),
|
||||
re_path('dict/get/type/(?P<pk>.*)/', DictDetailsModelViewSet.as_view({'get': 'dict_details_list'})),
|
||||
re_path('config/configKey/(?P<pk>.*)/', ConfigSettingsModelViewSet.as_view({'get': 'get_config_key'})),
|
||||
]
|
||||
urlpatterns += router.urls
|
||||
|
|
|
@ -42,22 +42,18 @@ class DictDetailsModelViewSet(CustomModelViewSet):
|
|||
search_fields = ('dictLabel',)
|
||||
ordering = 'sort' # 默认排序
|
||||
|
||||
|
||||
class DictDetailsListModelViewSet(CustomModelViewSet):
|
||||
"""
|
||||
根据字典类型查询字典数据信息 模型的CRUD视图
|
||||
"""
|
||||
queryset = DictDetails.objects.filter(status=0)
|
||||
serializer_class = DictDetailsListSerializer
|
||||
filter_class = DictDetailsFilter
|
||||
search_fields = ('dictLabel',)
|
||||
ordering = 'sort' # 默认排序
|
||||
|
||||
def list(self, request: Request, *args, **kwargs):
|
||||
def dict_details_list(self, request: Request, *args, **kwargs):
|
||||
"""
|
||||
根据字典类型查询字典数据信息
|
||||
:param request:
|
||||
:param args:
|
||||
:param kwargs:
|
||||
:return:
|
||||
"""
|
||||
queryset = self.queryset.filter(dict_data__dictType=kwargs.get('pk')).order_by('sort')
|
||||
if hasattr(self, 'handle_logging'):
|
||||
self.handle_logging(request, *args, **kwargs)
|
||||
serializer = self.get_serializer(queryset, many=True)
|
||||
serializer = DictDetailsListSerializer(queryset, many=True)
|
||||
return SuccessResponse(serializer.data)
|
||||
|
||||
|
||||
|
@ -73,5 +69,18 @@ class ConfigSettingsModelViewSet(CustomModelViewSet):
|
|||
# update_extra_permission_classes = (IsManagerPermission,)
|
||||
# destroy_extra_permission_classes = (IsManagerPermission,)
|
||||
# create_extra_permission_classes = (IsManagerPermission,)
|
||||
search_fields = ('name',)
|
||||
search_fields = ('configName',)
|
||||
ordering = 'id' # 默认排序
|
||||
|
||||
def get_config_key(self, request: Request, *args, **kwargs):
|
||||
"""
|
||||
根据 参数键名 查询参数数据信息
|
||||
:param request:
|
||||
:param args:
|
||||
:param kwargs:
|
||||
:return:
|
||||
"""
|
||||
queryset = self.queryset.filter(configKey=kwargs.get('pk')).first()
|
||||
# if hasattr(self, 'handle_logging'):
|
||||
# self.handle_logging(request, *args, **kwargs)
|
||||
return SuccessResponse(msg=queryset.configValue if queryset else '')
|
||||
|
|
|
@ -20,7 +20,7 @@ export function getConfig(configId) {
|
|||
// 根据参数键名查询参数值
|
||||
export function getConfigKey(configKey) {
|
||||
return request({
|
||||
url: '/system/config/configKey/' + configKey,
|
||||
url: '/system/config/configKey/' + configKey + '/',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue