2 Commits ab33fd79ef ... 45b98dddac

Author SHA1 Message Date
  DYaiu 45b98dddac basic的Menu菜单生成数据库和models,配置视图使用ModelViewSet 4 years ago
  DYaiu 5dc2a3d8e3 basic的init 4 years ago

+ 0 - 0
basic/__init__.py


+ 0 - 0
basic/admin.py


+ 5 - 0
basic/apps.py

@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class BasicConfig(AppConfig):
+    name = 'basic'

+ 39 - 0
basic/migrations/0001_initial.py

@@ -0,0 +1,39 @@
+# Generated by Django 3.0.8 on 2020-07-29 06:54
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+import mptt.fields
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Menu',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('name', models.CharField(max_length=100)),
+                ('config', models.TextField()),
+                ('create_at', models.DateTimeField(auto_now_add=True)),
+                ('code', models.CharField(max_length=100)),
+                ('lft', models.PositiveIntegerField(editable=False)),
+                ('rght', models.PositiveIntegerField(editable=False)),
+                ('tree_id', models.PositiveIntegerField(db_index=True, editable=False)),
+                ('level', models.PositiveIntegerField(editable=False)),
+                ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
+                ('parent', mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='basic.Menu')),
+            ],
+            options={
+                'verbose_name': '报表菜单',
+                'verbose_name_plural': '报表菜单列表',
+                'db_table': 'basic_menu',
+            },
+        ),
+    ]

+ 0 - 0
basic/migrations/__init__.py


+ 19 - 0
basic/models.py

@@ -0,0 +1,19 @@
+from django.contrib.auth.models import User
+from mptt.fields import TreeForeignKey
+from mptt.models import MPTTModel
+from django.db import models
+
+
+class Menu(MPTTModel):
+    name = models.CharField(max_length=100)
+    config = models.TextField()
+    create_at = models.DateTimeField(auto_now_add=True)
+    create_by = models.ForeignKey(User, blank=True, null=True, on_delete=models.CASCADE)
+    parent = TreeForeignKey('self', blank=True, null=True, on_delete=models.CASCADE)
+    code = models.CharField(max_length=100)
+
+    class Meta:
+        app_label = 'basic'
+        db_table = 'basic_menu'
+        verbose_name = '报表菜单'
+        verbose_name_plural = '报表菜单列表'

+ 11 - 0
basic/serializer.py

@@ -0,0 +1,11 @@
+from rest_framework import serializers
+from rest_framework.serializers import ListSerializer
+
+from basic.models import Menu
+
+
+class MenuSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Menu
+        list_serializer = ListSerializer
+        fields = '__all__'

+ 0 - 0
basic/tests.py


+ 11 - 0
basic/urls.py

@@ -0,0 +1,11 @@
+from rest_framework_bulk.routes import BulkRouter
+
+from basic.views import MenuView
+
+router = BulkRouter()
+router.register(r'menu', MenuView)
+
+urlpatterns = router.urls
+
+urlpatterns += [
+]

+ 10 - 0
basic/views.py

@@ -0,0 +1,10 @@
+from rest_framework.viewsets import ModelViewSet
+
+from basic.models import Menu
+from basic.serializer import MenuSerializer
+
+
+class MenuView(ModelViewSet):
+    queryset = Menu.objects.all()
+    serializer_class = MenuSerializer
+    pagination_class = None

+ 2 - 1
my_project/settings.py

@@ -41,7 +41,8 @@ INSTALLED_APPS = [
     'mptt',
     'workTtree',
     'treeAndTable',
-    'payment'
+    'payment',
+    'basic',
 ]
 
 MIDDLEWARE = [

+ 2 - 1
my_project/urls.py

@@ -22,5 +22,6 @@ urlpatterns = [
     url(r'^', include('workreport.urls')),
     url(r'^', include('workTtree.urls')),
     url(r'^treeAndTable/', include('treeAndTable.urls')),
-    url(r'^payment/',include('payment.urls'))
+    url(r'^payment/', include('payment.urls')),
+    url(r'^basic/', include('basic.urls')),
 ]