liceal 4 роки тому
батько
коміт
516f8714a4
44 змінених файлів з 290 додано та 10 видалено
  1. 8 0
      .idea/dataSources.xml
  2. BIN
      Django_test/__pycache__/settings.cpython-37.pyc
  3. BIN
      Django_test/__pycache__/urls.cpython-37.pyc
  4. 3 1
      Django_test/settings.py
  5. 2 0
      Django_test/urls.py
  6. 0 0
      basic/__init__.py
  7. BIN
      basic/__pycache__/__init__.cpython-37.pyc
  8. BIN
      basic/__pycache__/admin.cpython-37.pyc
  9. BIN
      basic/__pycache__/models.cpython-37.pyc
  10. BIN
      basic/__pycache__/serializers.cpython-37.pyc
  11. BIN
      basic/__pycache__/urls.cpython-37.pyc
  12. BIN
      basic/__pycache__/views.cpython-37.pyc
  13. 3 0
      basic/admin.py
  14. 5 0
      basic/apps.py
  15. 39 0
      basic/migrations/0001_initial.py
  16. 0 0
      basic/migrations/__init__.py
  17. BIN
      basic/migrations/__pycache__/0001_initial.cpython-37.pyc
  18. BIN
      basic/migrations/__pycache__/__init__.cpython-37.pyc
  19. 21 0
      basic/models.py
  20. 14 0
      basic/serializers.py
  21. 3 0
      basic/tests.py
  22. 27 0
      basic/urls.py
  23. 13 0
      basic/views.py
  24. BIN
      even_table/__pycache__/views.cpython-37.pyc
  25. 34 9
      even_table/views.py
  26. 0 0
      payment/__init__.py
  27. BIN
      payment/__pycache__/__init__.cpython-37.pyc
  28. BIN
      payment/__pycache__/admin.cpython-37.pyc
  29. BIN
      payment/__pycache__/models.cpython-37.pyc
  30. BIN
      payment/__pycache__/serializers.cpython-37.pyc
  31. BIN
      payment/__pycache__/urls.cpython-37.pyc
  32. BIN
      payment/__pycache__/views.cpython-37.pyc
  33. 3 0
      payment/admin.py
  34. 5 0
      payment/apps.py
  35. 32 0
      payment/migrations/0001_initial.py
  36. 0 0
      payment/migrations/__init__.py
  37. BIN
      payment/migrations/__pycache__/0001_initial.cpython-37.pyc
  38. BIN
      payment/migrations/__pycache__/__init__.cpython-37.pyc
  39. 19 0
      payment/models.py
  40. 13 0
      payment/serializers.py
  41. 3 0
      payment/tests.py
  42. 29 0
      payment/urls.py
  43. 14 0
      payment/views.py
  44. BIN
      workreport/__pycache__/views.cpython-37.pyc

+ 8 - 0
.idea/dataSources.xml

@@ -14,5 +14,13 @@
       <jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
       <jdbc-url>jdbc:mysql://srv.test.linkerplus.com:3310/linxa_django_demo</jdbc-url>
     </data-source>
+    <data-source source="LOCAL" name="django远程" uuid="83127bc5-0b81-4c32-80b7-0be5a2b46baa">
+      <driver-ref>mysql.8</driver-ref>
+      <synchronize>true</synchronize>
+      <imported>true</imported>
+      <remarks>$PROJECT_DIR$/Django_test/settings.py</remarks>
+      <jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
+      <jdbc-url>jdbc:mysql://www.test.linkerplus.com:3310/linxa_django_demo</jdbc-url>
+    </data-source>
   </component>
 </project>

BIN
Django_test/__pycache__/settings.cpython-37.pyc


BIN
Django_test/__pycache__/urls.cpython-37.pyc


+ 3 - 1
Django_test/settings.py

@@ -39,7 +39,9 @@ INSTALLED_APPS = [
     'workreport',
     'mptt',
     'mptt_test',
-    'even_table'
+    'even_table',
+    'payment',
+    'basic'
 ]
 
 MIDDLEWARE = [

+ 2 - 0
Django_test/urls.py

@@ -25,4 +25,6 @@ urlpatterns = [
     url(r'work/', include('workreport.urls')),  # 使用workreport工作区的路由
     url(r'work/', include('mptt_test.urls')),  # 使用mptt
     url(r'work/', include('even_table.urls')),
+    url(r'work/', include('payment.urls')),
+    url(r'work/', include('basic.urls'))
 ]

+ 0 - 0
basic/__init__.py


BIN
basic/__pycache__/__init__.cpython-37.pyc


BIN
basic/__pycache__/admin.cpython-37.pyc


BIN
basic/__pycache__/models.cpython-37.pyc


BIN
basic/__pycache__/serializers.cpython-37.pyc


BIN
basic/__pycache__/urls.cpython-37.pyc


BIN
basic/__pycache__/views.cpython-37.pyc


+ 3 - 0
basic/admin.py

@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.

+ 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-28 08:27
+
+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


BIN
basic/migrations/__pycache__/0001_initial.cpython-37.pyc


BIN
basic/migrations/__pycache__/__init__.cpython-37.pyc


+ 21 - 0
basic/models.py

@@ -0,0 +1,21 @@
+from django.contrib.auth.models import User
+from django.db import models
+
+# Create your models here.
+from mptt.fields import TreeForeignKey
+from mptt.models import MPTTModel
+
+
+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 = '报表菜单列表'

+ 14 - 0
basic/serializers.py

@@ -0,0 +1,14 @@
+
+#序列号定义
+from rest_framework import serializers
+from rest_framework.serializers import ListSerializer
+
+from basic.models import Menu
+from payment.models import Payment
+
+
+class MenuSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Menu
+        list_serializer = ListSerializer
+        fields = '__all__'

+ 3 - 0
basic/tests.py

@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.

+ 27 - 0
basic/urls.py

@@ -0,0 +1,27 @@
+"""Django_test URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+    https://docs.djangoproject.com/en/3.0/topics/http/urls/
+Examples:
+Function views
+    1. Add an import:  from my_app import views
+    2. Add a URL to urlpatterns:  path('', views.home, name='home')
+Class-based views
+    1. Add an import:  from other_app.views import Home
+    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
+Including another URLconf
+    1. Import the include() function: from django.urls import include, path
+    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
+"""
+
+# 主入口请求出口
+from rest_framework_bulk.routes import BulkRouter
+
+from basic.views import MenuView
+
+router = BulkRouter()
+router.register(r'menu', MenuView)
+
+urlpatterns = router.urls
+urlpatterns += [
+]

+ 13 - 0
basic/views.py

@@ -0,0 +1,13 @@
+from django.shortcuts import render
+
+# Create your views here.
+from rest_framework.viewsets import ModelViewSet
+
+from basic.models import Menu
+from basic.serializers import MenuSerializer
+
+
+class MenuView(ModelViewSet):
+    queryset = Menu.objects.all()
+    serializer_class = MenuSerializer  # 序列化
+    pagination_class = None

BIN
even_table/__pycache__/views.cpython-37.pyc


+ 34 - 9
even_table/views.py

@@ -66,17 +66,22 @@ class deptView(APIView):
 
     """
     删除节点
-    {id:节点id}
+    {id:部门id}
     """
 
     def delete(self, request):
         data = request.data
-        # 部门 删除这个部门
-        res = Dept.objects.filter(id=data['id']).delete()
 
         # 岗位 删除这个部门下面的所有岗位
-        # Jobs.objects.filter()
-        # Dept2Jobs.objects.filter(dept_id=data['id'])
+        # 这个部门下面的所有岗位
+        jobs = Dept2Jobs.objects.filter(dept_id=data['id']).values('job_id').all()
+        job_ids = []
+        for job in jobs:
+            job_ids.append(job['job_id'])
+        Jobs.objects.filter(id__in=job_ids).delete()
+
+        # 部门 删除这个部门
+        res = Dept.objects.filter(id=data['id']).delete()
 
         # 关联表 删除跟这个部门关联的
         Dept2Jobs.objects.filter(dept_id=data['id']).delete()
@@ -143,14 +148,34 @@ class userView(APIView):
     def post(self, request):
         pass
 
-    # 用户查询
+    # 用户查询 {job_id:岗位id(可空,有则选这个岗位下的用户)}
     def get(self, request):
         data = request.GET
-        res = User.objects.values('id', 'username', 'email')
-        return Response(data={'result': res, 'message': '查询所有用户基础数据'}, status=status.HTTP_200_OK)
+        if 'job_id' in data:
+            job_ids = Dept2Jobs.objects.filter(job_id=data['job_id'], user_id__isnull=False).values()
+            ids = []
+            for id in job_ids:
+                ids.append(id)
+            res = User.objects.filter(id__in=ids).values()
+        else:
+            res = User.objects.values()
+
+        return Response(data={'result': res, 'message': '查询用户基础数据'}, status=status.HTTP_200_OK)
 
+    # 用户替换部门 {job_id:岗位id,user_ids:用户id数组,type:移除用户还是新增用户(0移除,1新增)}
     def put(self, request):
-        pass
+        data = request.data
+        res = {}
+        if data['type'] == 0:
+            # 岗位下删除这个用户
+            Dept2Jobs.objects.filter(job_id=data['job_id'], user_id__in=data['user_ids']).delete()
+            res = {'message': '删除用户'}
+        elif data['type'] == 1:
+            # 岗位下新增用户
+            for user_id in data['user_ids']:
+                Dept2Jobs.objects.create(job_id=data['job_id'], user_id=user_id)
+            res = {'message': '新增用户'}
+        return Response(data=res, status=status.HTTP_200_OK)
 
     def delete(self, request):
         pass

+ 0 - 0
payment/__init__.py


BIN
payment/__pycache__/__init__.cpython-37.pyc


BIN
payment/__pycache__/admin.cpython-37.pyc


BIN
payment/__pycache__/models.cpython-37.pyc


BIN
payment/__pycache__/serializers.cpython-37.pyc


BIN
payment/__pycache__/urls.cpython-37.pyc


BIN
payment/__pycache__/views.cpython-37.pyc


+ 3 - 0
payment/admin.py

@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.

+ 5 - 0
payment/apps.py

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

+ 32 - 0
payment/migrations/0001_initial.py

@@ -0,0 +1,32 @@
+# Generated by Django 3.0.8 on 2020-07-28 01:07
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Payment',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('payment_type', models.CharField(max_length=100)),
+                ('price_type', models.CharField(max_length=100)),
+                ('item_type', models.CharField(max_length=100)),
+                ('index_type', models.CharField(max_length=100)),
+                ('index_price', models.IntegerField()),
+                ('year', models.CharField(max_length=4)),
+                ('month', models.CharField(max_length=2)),
+            ],
+            options={
+                'verbose_name': '支出报表',
+                'verbose_name_plural': '支出报表列表',
+                'db_table': 'pay',
+            },
+        ),
+    ]

+ 0 - 0
payment/migrations/__init__.py


BIN
payment/migrations/__pycache__/0001_initial.cpython-37.pyc


BIN
payment/migrations/__pycache__/__init__.cpython-37.pyc


+ 19 - 0
payment/models.py

@@ -0,0 +1,19 @@
+from django.db import models
+
+
+# Create your models here.
+
+class Payment(models.Model):
+    payment_type = models.CharField(max_length=100)
+    price_type = models.CharField(max_length=100)
+    item_type = models.CharField(max_length=100)
+    index_type = models.CharField(max_length=100)
+    index_price = models.IntegerField()
+    year = models.CharField(max_length=4)
+    month = models.CharField(max_length=2)
+
+    class Meta:
+        app_label = "payment" # 指向自己的文件夹,不是项目,是这个模型的
+        db_table = "pay" # 定义生成表的名称
+        verbose_name = "支出报表" # 注解
+        verbose_name_plural = "支出报表列表" #注解

+ 13 - 0
payment/serializers.py

@@ -0,0 +1,13 @@
+
+#序列号定义
+from rest_framework import serializers
+from rest_framework.serializers import ListSerializer
+
+from payment.models import Payment
+
+
+class PaymentSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Payment
+        list_serializer = ListSerializer
+        fields = '__all__'

+ 3 - 0
payment/tests.py

@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.

+ 29 - 0
payment/urls.py

@@ -0,0 +1,29 @@
+"""Django_test URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+    https://docs.djangoproject.com/en/3.0/topics/http/urls/
+Examples:
+Function views
+    1. Add an import:  from my_app import views
+    2. Add a URL to urlpatterns:  path('', views.home, name='home')
+Class-based views
+    1. Add an import:  from other_app.views import Home
+    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
+Including another URLconf
+    1. Import the include() function: from django.urls import include, path
+    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
+"""
+
+from django.conf.urls import url
+
+# 主入口请求出口
+from rest_framework_bulk.routes import BulkRouter
+
+from payment.views import PaymentView
+
+router = BulkRouter()
+router.register(r'payment', PaymentView)
+
+urlpatterns = router.urls
+urlpatterns += [
+]

+ 14 - 0
payment/views.py

@@ -0,0 +1,14 @@
+from django.shortcuts import render
+
+# Create your views here.
+from rest_framework.viewsets import ModelViewSet
+
+from payment.models import Payment
+from payment.serializers import PaymentSerializer
+
+
+class PaymentView(ModelViewSet):
+    queryset = Payment.objects.all()
+    serializer_class = PaymentSerializer
+    pagination_class = None
+

BIN
workreport/__pycache__/views.cpython-37.pyc