user %!s(int64=4) %!d(string=hai) anos
pai
achega
1eff478078
Modificáronse 65 ficheiros con 547 adicións e 9 borrados
  1. 8 0
      .idea/dataSources.xml
  2. 1 1
      .idea/misc.xml
  3. 1 1
      .idea/testthree.iml
  4. 1 0
      .idea/vcs.xml
  5. 9 1
      Pipfile.lock
  6. 0 0
      detailmptt/__init__.py
  7. BIN=BIN
      detailmptt/__pycache__/__init__.cpython-37.pyc
  8. BIN=BIN
      detailmptt/__pycache__/admin.cpython-37.pyc
  9. BIN=BIN
      detailmptt/__pycache__/models.cpython-37.pyc
  10. BIN=BIN
      detailmptt/__pycache__/urls.cpython-37.pyc
  11. BIN=BIN
      detailmptt/__pycache__/views.cpython-37.pyc
  12. 3 0
      detailmptt/admin.py
  13. 5 0
      detailmptt/apps.py
  14. 36 0
      detailmptt/migrations/0001_initial.py
  15. 0 0
      detailmptt/migrations/__init__.py
  16. BIN=BIN
      detailmptt/migrations/__pycache__/0001_initial.cpython-37.pyc
  17. BIN=BIN
      detailmptt/migrations/__pycache__/__init__.cpython-37.pyc
  18. 28 0
      detailmptt/models.py
  19. 11 0
      detailmptt/tests.py
  20. 24 0
      detailmptt/urls.py
  21. 44 0
      detailmptt/views.py
  22. 0 0
      django-admin
  23. 0 0
      pivottable/__init__.py
  24. BIN=BIN
      pivottable/__pycache__/__init__.cpython-37.pyc
  25. BIN=BIN
      pivottable/__pycache__/admin.cpython-37.pyc
  26. BIN=BIN
      pivottable/__pycache__/models.cpython-37.pyc
  27. BIN=BIN
      pivottable/__pycache__/serializer.cpython-37.pyc
  28. BIN=BIN
      pivottable/__pycache__/urls.cpython-37.pyc
  29. BIN=BIN
      pivottable/__pycache__/views.cpython-37.pyc
  30. 3 0
      pivottable/admin.py
  31. 5 0
      pivottable/apps.py
  32. 0 0
      pivottable/migrations/__init__.py
  33. BIN=BIN
      pivottable/migrations/__pycache__/__init__.cpython-37.pyc
  34. 18 0
      pivottable/models.py
  35. 13 0
      pivottable/serializer.py
  36. 3 0
      pivottable/tests.py
  37. 28 0
      pivottable/urls.py
  38. 13 0
      pivottable/views.py
  39. 0 0
      relation/__init__.py
  40. BIN=BIN
      relation/__pycache__/__init__.cpython-37.pyc
  41. BIN=BIN
      relation/__pycache__/admin.cpython-37.pyc
  42. BIN=BIN
      relation/__pycache__/models.cpython-37.pyc
  43. BIN=BIN
      relation/__pycache__/serializer.cpython-37.pyc
  44. BIN=BIN
      relation/__pycache__/urls.cpython-37.pyc
  45. BIN=BIN
      relation/__pycache__/views.cpython-37.pyc
  46. 3 0
      relation/admin.py
  47. 5 0
      relation/apps.py
  48. 37 0
      relation/migrations/0001_initial.py
  49. 49 0
      relation/migrations/0002_daptpost_daptuser_postuser.py
  50. 0 0
      relation/migrations/__init__.py
  51. BIN=BIN
      relation/migrations/__pycache__/0001_initial.cpython-37.pyc
  52. BIN=BIN
      relation/migrations/__pycache__/0002_daptpost_daptuser_postuser.cpython-37.pyc
  53. BIN=BIN
      relation/migrations/__pycache__/__init__.cpython-37.pyc
  54. 47 0
      relation/models.py
  55. 23 0
      relation/serializer.py
  56. 4 0
      relation/tests.py
  57. 30 0
      relation/urls.py
  58. 82 0
      relation/views.py
  59. BIN=BIN
      testthree/__pycache__/settings.cpython-37.pyc
  60. BIN=BIN
      testthree/__pycache__/urls.cpython-37.pyc
  61. 8 4
      testthree/settings.py
  62. 4 1
      testthree/urls.py
  63. BIN=BIN
      workreport/__pycache__/urls.cpython-37.pyc
  64. 1 1
      workreport/migrations/0001_initial.py
  65. BIN=BIN
      workreport/migrations/__pycache__/0001_initial.cpython-37.pyc

+ 8 - 0
.idea/dataSources.xml

@@ -7,5 +7,13 @@
       <jdbc-driver>org.sqlite.JDBC</jdbc-driver>
       <jdbc-url>jdbc:sqlite:E:\python\test\testthree\lvsh_django</jdbc-url>
     </data-source>
+    <data-source source="LOCAL" name="Django default" uuid="632ce503-001e-47c7-9113-f213d84c308a">
+      <driver-ref>mysql.8</driver-ref>
+      <synchronize>true</synchronize>
+      <imported>true</imported>
+      <remarks>$PROJECT_DIR$/testthree/settings.py</remarks>
+      <jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
+      <jdbc-url>jdbc:mysql://www.test.linkerplus.com:3310/lvsh_django</jdbc-url>
+    </data-source>
   </component>
 </project>

+ 1 - 1
.idea/misc.xml

@@ -3,5 +3,5 @@
   <component name="JavaScriptSettings">
     <option name="languageLevel" value="ES6" />
   </component>
-  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (lvshihai-w2fUPLQ-)" project-jdk-type="Python SDK" />
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (testthree-kKtqvWDd)" project-jdk-type="Python SDK" />
 </project>

+ 1 - 1
.idea/testthree.iml

@@ -14,7 +14,7 @@
   </component>
   <component name="NewModuleRootManager">
     <content url="file://$MODULE_DIR$" />
-    <orderEntry type="jdk" jdkName="Python 3.7 (lvshihai-w2fUPLQ-)" jdkType="Python SDK" />
+    <orderEntry type="jdk" jdkName="Python 3.7 (testthree-kKtqvWDd)" jdkType="Python SDK" />
     <orderEntry type="sourceFolder" forTests="false" />
   </component>
   <component name="TemplatesService">

+ 1 - 0
.idea/vcs.xml

@@ -2,5 +2,6 @@
 <project version="4">
   <component name="VcsDirectoryMappings">
     <mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
   </component>
 </project>

+ 9 - 1
Pipfile.lock

@@ -1,7 +1,7 @@
 {
     "_meta": {
         "hash": {
-            "sha256": "a82a50f1ac082a5c593ae284fef3ad41c1207d45234dae53e38582c753d012eb"
+            "sha256": "c775d44ee2191d8fc65e8105b1a7afca200d75a5af7ce971f8795749e825283d"
         },
         "pipfile-spec": 6,
         "requires": {
@@ -32,6 +32,14 @@
             "markers": "python_version >= '3.6'",
             "version": "==3.0.8"
         },
+        "django-filter": {
+            "hashes": [
+                "sha256:11e63dd759835d9ba7a763926ffb2662cf8a6dcb4c7971a95064de34dbc7e5af",
+                "sha256:616848eab6fc50193a1b3730140c49b60c57a3eda1f7fc57fa8505ac156c6c75"
+            ],
+            "index": "pypi",
+            "version": "==2.3.0"
+        },
         "djangorestframework": {
             "hashes": [
                 "sha256:05809fc66e1c997fd9a32ea5730d9f4ba28b109b9da71fccfa5ff241201fd0a4",

+ 0 - 0
detailmptt/__init__.py


BIN=BIN
detailmptt/__pycache__/__init__.cpython-37.pyc


BIN=BIN
detailmptt/__pycache__/admin.cpython-37.pyc


BIN=BIN
detailmptt/__pycache__/models.cpython-37.pyc


BIN=BIN
detailmptt/__pycache__/urls.cpython-37.pyc


BIN=BIN
detailmptt/__pycache__/views.cpython-37.pyc


+ 3 - 0
detailmptt/admin.py

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

+ 5 - 0
detailmptt/apps.py

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

+ 36 - 0
detailmptt/migrations/0001_initial.py

@@ -0,0 +1,36 @@
+# Generated by Django 3.0.8 on 2020-07-24 07:47
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='DailyMptt',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('title', models.CharField(max_length=50)),
+                ('content', models.TextField()),
+                ('create_at', models.DateTimeField(auto_now=True)),
+                ('son_size', models.IntegerField(default=0)),
+                ('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', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='detailmptt.DailyMptt', verbose_name='上级区域')),
+            ],
+            options={
+                'abstract': False,
+            },
+        ),
+    ]

+ 0 - 0
detailmptt/migrations/__init__.py


BIN=BIN
detailmptt/migrations/__pycache__/0001_initial.cpython-37.pyc


BIN=BIN
detailmptt/migrations/__pycache__/__init__.cpython-37.pyc


+ 28 - 0
detailmptt/models.py

@@ -0,0 +1,28 @@
+from django.contrib.auth.models import User
+from django.db import models
+
+# Create your models here.
+from mptt.models import MPTTModel
+
+
+class DailyMptt(MPTTModel):
+    #verbose_name表示,on_delete父级删除时的处理
+    parent = models.ForeignKey('self', verbose_name='上级区域', null=True, blank=True, related_name='children', on_delete = models.CASCADE)
+    title = models.CharField(max_length=50)
+    content = models.TextField()
+    create_at = models.DateTimeField(auto_now=True)
+    create_by = models.ForeignKey(User, blank=True, null=True, on_delete=models.CASCADE)
+    son_size = models.IntegerField(default=0)
+
+    # def toKeyToVal(self):
+
+
+    def getObject(self, data):
+        for key, val in data.items():
+            if hasattr(self, key):
+                self.__setattr__(key, val)
+        return self
+
+    class MPTTMeta:
+        order_insertion_by = ['title']#自然顺序
+

+ 11 - 0
detailmptt/tests.py

@@ -0,0 +1,11 @@
+from random import random
+
+from django.test import TestCase
+
+# Create your tests here.
+from detailmptt.models import DailyMptt
+
+
+
+
+

+ 24 - 0
detailmptt/urls.py

@@ -0,0 +1,24 @@
+"""testthree 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 django.contrib import admin
+from django.urls import path, include
+
+from detailmptt.views import DetailMpttView
+
+urlpatterns = [
+    url(r'^detail/', DetailMpttView.as_view())
+]

+ 44 - 0
detailmptt/views.py

@@ -0,0 +1,44 @@
+from random import random
+
+from django.shortcuts import render
+
+# Create your views here.
+from rest_framework import status
+from rest_framework.response import Response
+from rest_framework.views import APIView
+from rest_framework.viewsets import ModelViewSet
+
+from detailmptt.models import DailyMptt
+from workreport.models import DailyRreport
+from workreport.serializer import DailyReportSerializer
+
+
+class DetailMpttView(APIView):
+    # def get(self,request):
+    #     objects_all = DailyMptt.objects.all()
+    #     dailyMpttList =
+    #设置查询条件
+    def get(self,request):
+        dailyMptt = DailyMptt()
+        #获取全部get信息
+        params = request.GET
+        #赋值
+        dailyMptt.getObject(params)
+        parent_id = params.get('parent_id')
+        dailyMpttList = DailyMptt.objects.filter(parent_id = parent_id).values()
+        return Response(data=dailyMpttList, status=status.HTTP_200_OK)
+
+    def post(self, request):
+        # pass
+        data = request.data
+        dailyMptt = DailyMptt()
+        dailyMptt.getObject(data)
+
+        dailyMptt.save()
+        return Response(status = status.HTTP_201_CREATED)
+
+    def delete(self, request):
+        id = request.data['id']
+        DailyMptt.objects.filter(id = id).delete()
+
+        return Response(data=True, status=status.HTTP_200_OK)

+ 0 - 0
django-admin


+ 0 - 0
pivottable/__init__.py


BIN=BIN
pivottable/__pycache__/__init__.cpython-37.pyc


BIN=BIN
pivottable/__pycache__/admin.cpython-37.pyc


BIN=BIN
pivottable/__pycache__/models.cpython-37.pyc


BIN=BIN
pivottable/__pycache__/serializer.cpython-37.pyc


BIN=BIN
pivottable/__pycache__/urls.cpython-37.pyc


BIN=BIN
pivottable/__pycache__/views.cpython-37.pyc


+ 3 - 0
pivottable/admin.py

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

+ 5 - 0
pivottable/apps.py

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

+ 0 - 0
pivottable/migrations/__init__.py


BIN=BIN
pivottable/migrations/__pycache__/__init__.cpython-37.pyc


+ 18 - 0
pivottable/models.py

@@ -0,0 +1,18 @@
+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
pivottable/serializer.py

@@ -0,0 +1,13 @@
+
+from rest_framework import serializers
+from rest_framework.serializers import ListSerializer
+
+from pivottable.models import Payment
+
+
+class PaymentSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Payment
+        # fields = ['url', 'username', 'email', 'is_staff']
+        list_serializer = ListSerializer
+        fields = '__all__'

+ 3 - 0
pivottable/tests.py

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

+ 28 - 0
pivottable/urls.py

@@ -0,0 +1,28 @@
+"""testthree 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 pivottable.views import PaymentViews
+
+router = BulkRouter()
+router.register(r'payment', PaymentViews)
+# router.register(r'post',PostViews)
+
+urlpatterns = router.urls
+urlpatterns += [
+
+]

+ 13 - 0
pivottable/views.py

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

+ 0 - 0
relation/__init__.py


BIN=BIN
relation/__pycache__/__init__.cpython-37.pyc


BIN=BIN
relation/__pycache__/admin.cpython-37.pyc


BIN=BIN
relation/__pycache__/models.cpython-37.pyc


BIN=BIN
relation/__pycache__/serializer.cpython-37.pyc


BIN=BIN
relation/__pycache__/urls.cpython-37.pyc


BIN=BIN
relation/__pycache__/views.cpython-37.pyc


+ 3 - 0
relation/admin.py

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

+ 5 - 0
relation/apps.py

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

+ 37 - 0
relation/migrations/0001_initial.py

@@ -0,0 +1,37 @@
+# Generated by Django 3.0.8 on 2020-07-24 07:47
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Post',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('name', models.CharField(max_length=50)),
+            ],
+        ),
+        migrations.CreateModel(
+            name='Dapt',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('name', models.CharField(max_length=50)),
+                ('lft', models.PositiveIntegerField(editable=False)),
+                ('rght', models.PositiveIntegerField(editable=False)),
+                ('tree_id', models.PositiveIntegerField(db_index=True, editable=False)),
+                ('level', models.PositiveIntegerField(editable=False)),
+                ('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='pid', to='relation.Dapt', verbose_name='上级部门')),
+            ],
+            options={
+                'abstract': False,
+            },
+        ),
+    ]

+ 49 - 0
relation/migrations/0002_daptpost_daptuser_postuser.py

@@ -0,0 +1,49 @@
+# Generated by Django 3.0.8 on 2020-07-24 07:50
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+        ('relation', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='PostUser',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pu_post', to='relation.Post', verbose_name='岗位')),
+                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pu_user', to=settings.AUTH_USER_MODEL, verbose_name='人员')),
+            ],
+            options={
+                'unique_together': {('post', 'user')},
+            },
+        ),
+        migrations.CreateModel(
+            name='DaptUser',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('dapt', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='du_dapt', to='relation.Dapt', verbose_name='部门')),
+                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='du_user', to=settings.AUTH_USER_MODEL, verbose_name='人员')),
+            ],
+            options={
+                'unique_together': {('dapt', 'user')},
+            },
+        ),
+        migrations.CreateModel(
+            name='DaptPost',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('dapt', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='dp_dapt', to='relation.Dapt', verbose_name='部门')),
+                ('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='dp_post', to='relation.Post', verbose_name='岗位')),
+            ],
+            options={
+                'unique_together': {('dapt', 'post')},
+            },
+        ),
+    ]

+ 0 - 0
relation/migrations/__init__.py


BIN=BIN
relation/migrations/__pycache__/0001_initial.cpython-37.pyc


BIN=BIN
relation/migrations/__pycache__/0002_daptpost_daptuser_postuser.cpython-37.pyc


BIN=BIN
relation/migrations/__pycache__/__init__.cpython-37.pyc


+ 47 - 0
relation/models.py

@@ -0,0 +1,47 @@
+from django.contrib.auth.models import User
+from django.db import models
+
+# Create your models here.
+from mptt.models import MPTTModel
+
+#部门表
+class Dapt(MPTTModel):
+    name = models.CharField(max_length=50)
+    parent = models.ForeignKey('self', verbose_name='上级部门', null=True, blank=True, related_name='pid',
+                               on_delete=models.CASCADE)
+    def setObject(self, data):
+        for key, val in data.items():
+            if hasattr(self, key):
+                self.__setattr__(key, val)
+        return self
+
+#岗位
+class Post(models.Model):
+    name = models.CharField(max_length=50)
+
+#部门岗位关联表
+class DaptPost(models.Model):
+    dapt = models.ForeignKey('Dapt', verbose_name='部门', null=False, blank=False, related_name='dp_dapt', on_delete=models.CASCADE)
+    post = models.ForeignKey('Post', verbose_name='岗位', null=False, blank=False, related_name='dp_post', on_delete=models.CASCADE)
+
+    class Meta:
+        unique_together = ('dapt', 'post')
+
+#部门人员关联表
+class DaptUser(models.Model):
+    dapt = models.ForeignKey('Dapt', verbose_name='部门', null=False, blank=False, related_name='du_dapt', on_delete=models.CASCADE)
+    user = models.ForeignKey(User, verbose_name='人员', null=False, blank=False, related_name='du_user', on_delete=models.CASCADE)
+    def setObject(self, data):
+        for key, val in data.items():
+            if hasattr(self, key):
+                self.__setattr__(key, val)
+        return self
+    class Meta:
+        unique_together = ('dapt', 'user')
+
+#岗位人员关联表
+class PostUser(models.Model):
+    post = models.ForeignKey('Post', verbose_name='岗位', null=False, blank=False, related_name='pu_post', on_delete=models.CASCADE)
+    user = models.ForeignKey(User, verbose_name='人员', null=False, blank=False, related_name='pu_user', on_delete=models.CASCADE)
+    class Meta:
+        unique_together = ('post', 'user')

+ 23 - 0
relation/serializer.py

@@ -0,0 +1,23 @@
+from rest_framework import serializers
+from rest_framework.serializers import ListSerializer
+
+from relation.models import *
+class DaptSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Dapt
+        fields = '__all__'
+
+class PostSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = Post
+        fields = '__all__'
+
+class UserSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = User
+        fields = '__all__'
+
+class DaptUserSerializer(serializers.ModelSerializer):
+    class Meta:
+        model = DaptUser
+        fields = '__all__'

+ 4 - 0
relation/tests.py

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

+ 30 - 0
relation/urls.py

@@ -0,0 +1,30 @@
+"""testthree 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 relation.views import *
+
+# 给智能路由注册
+# router = BulkRouter()
+# router.register(r'dept', DaptViews)
+# # router.register(r'post',PostViews)
+#
+# urlpatterns = router.urls
+urlpatterns = [
+    url(r'^daptuser/', DaptUserViews.as_view()),
+    url(r'^dapt/', DaptViews.as_view()),
+    url(r'^user/', UserViews.as_view())
+]

+ 82 - 0
relation/views.py

@@ -0,0 +1,82 @@
+from django.shortcuts import render
+
+# Create your views here.
+from rest_framework import status
+from rest_framework.views import APIView
+from rest_framework.viewsets import ModelViewSet
+
+from relation.models import *
+from relation.serializer import *
+from rest_framework.response import Response
+
+class DaptViews(APIView):
+    def get(self, request):
+        parent_id = request.GET.get('parent_id')
+        daptSet = Dapt.objects.filter(parent_id = parent_id).values()
+        return Response(data=daptSet, status=status.HTTP_200_OK)
+
+    def post(self, request):
+        dapt = Dapt()
+        data = request.data
+        dapt.setObject(data)
+        dapt.save()
+        return Response(data=dapt.id, status=status.HTTP_200_OK)
+
+    def delete(self, request):
+        id = request.data['id']
+        Dapt.objects.filter(id = id).delete()
+        return Response(data=True, status=status.HTTP_200_OK)
+
+class PostViews(ModelViewSet):
+    queryset = Post.objects.all()
+    serializer_class = PostSerializer
+
+class UserViews(APIView):
+    def post(self, request):
+        data = request.data
+        user = User(last_name = data['last_name'], id=data['id'])
+        user.save()
+        return Response(data=True, status=status.HTTP_200_OK)
+    def get(self, request):
+        user = User.objects.values()
+        return Response(data=user, status=status.HTTP_200_OK)
+
+# class DaptPostViews(APIView):
+#     def get(self, request):
+#         get = request.GET
+#         return Response(status=status.HTTP_200_OK)
+#部门人员
+class DaptUserViews(APIView):
+    def get(self, request):
+        daptId = request.GET.get('dapt_id')
+        userId = request.GET.get('user_id')
+        if daptId != None:
+            daptUserList = list(DaptUser.objects.filter(dapt_id=daptId))
+            userList = list()
+            for daptUser in daptUserList:
+                userList.append(daptUser.user)
+            data = UserSerializer(userList, many=True)
+        elif userId != None:
+            daptUserList = list(DaptUser.objects.filter(user_id=userId))
+            daptList = list()
+            for daptUser in daptUserList:
+                daptList.append(daptUser.dapt)
+            data = DaptSerializer(daptList, many=True)
+        return Response(data=data.data, status=status.HTTP_200_OK)
+
+    def post(self, reques):
+        data = reques.data
+        daptUser = DaptUser()
+        daptUser.setObject(data)
+        daptUser.save()
+        return Response(data=True, status=status.HTTP_200_OK)
+
+    def delete(self, reques):
+        userId = reques.data['user_id']
+        daptId = reques.data['dapt_id']
+        DaptUser.objects.get(user_id = userId, dapt_id=daptId).delete()
+        return Response(data=True, status=status.HTTP_200_OK)
+
+
+
+        

BIN=BIN
testthree/__pycache__/settings.cpython-37.pyc


BIN=BIN
testthree/__pycache__/urls.cpython-37.pyc


+ 8 - 4
testthree/settings.py

@@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
 INSTALLED_APPS = [
     'django.contrib.admin',
     'django.contrib.auth',
+    'mptt',
     'django.contrib.contenttypes',
     'django.contrib.sessions',
     'django.contrib.messages',
@@ -38,6 +39,9 @@ INSTALLED_APPS = [
     'rest_framework',
     'django_filters',
     'workreport',
+    'detailmptt',
+    'relation',
+    'pivottable'
 ]
 
 MIDDLEWARE = [
@@ -79,7 +83,7 @@ DATABASES = {
         'NAME': "lvsh_django",
         'USER': 'root',
         'PASSWORD': 'abc.123',
-        'HOST': 'srv.test.linkerplus.com',
+        'HOST': 'www.test.linkerplus.com',
         'PORT': '3310'
     }
 }
@@ -133,6 +137,6 @@ REST_FRAMEWORK = {
     ]
 }
 
-# AUTHENTICATION_BACKENDS = (
-#     'django.contrib.auth.backends.ModelBackend'
-# )
+AUTHENTICATION_BACKENDS = (
+    'django.contrib.auth.backends.ModelBackend'
+)

+ 4 - 1
testthree/urls.py

@@ -20,5 +20,8 @@ from django.urls import path, include
 urlpatterns = [
     path('admin/', admin.site.urls),
     url(r'^api-auth/', include('rest_framework.urls')),
-    url(r'^report/', include('workreport.urls'))
+    url(r'^report/', include('workreport.urls')),
+    url(r'^report/mptt/', include('detailmptt.urls')),
+    url(r'^report/relation/', include('relation.urls')),
+    url(r'^report/pivottable/', include('pivottable.urls'))
 ]

BIN=BIN
workreport/__pycache__/urls.cpython-37.pyc


+ 1 - 1
workreport/migrations/0001_initial.py

@@ -1,4 +1,4 @@
-# Generated by Django 3.0.8 on 2020-07-16 03:36
+# Generated by Django 3.0.8 on 2020-07-24 07:47
 
 from django.conf import settings
 from django.db import migrations, models

BIN=BIN
workreport/migrations/__pycache__/0001_initial.cpython-37.pyc