仓库信息增删改查接口
This commit is contained in:
parent
24d64a9e17
commit
177699fb41
|
@ -0,0 +1,3 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
|
@ -0,0 +1,7 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
class InmConfig(AppConfig):
|
||||||
|
name = 'apps.inm'
|
||||||
|
verbose_name = '库存管理'
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
from django.db import models
|
||||||
|
from django.db.models.base import Model
|
||||||
|
import django.utils.timezone as timezone
|
||||||
|
from django.db.models.query import QuerySet
|
||||||
|
from apps.system.models import CommonAModel, CommonBModel, Organization, User, Dict, File
|
||||||
|
from utils.model import SoftModel, BaseModel
|
||||||
|
from simple_history.models import HistoricalRecords
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class WareHouse(CommonAModel):
|
||||||
|
"""
|
||||||
|
仓库信息
|
||||||
|
"""
|
||||||
|
number = models.CharField('仓库编号', max_length=20, unique=True)
|
||||||
|
name = models.CharField('仓库名称', max_length=20, unique=True)
|
||||||
|
place = models.CharField('具体地点', max_length=50)
|
||||||
|
class Meta:
|
||||||
|
verbose_name = '仓库信息'
|
||||||
|
verbose_name_plural = verbose_name
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
|
@ -0,0 +1,16 @@
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
from apps.inm.models import WareHouse
|
||||||
|
|
||||||
|
from apps.system.serializers import UserSimpleSerializer
|
||||||
|
|
||||||
|
class WareHouseSerializer(serializers. ModelSerializer):
|
||||||
|
create_by_=UserSimpleSerializer('create_by', read_only=True)
|
||||||
|
class Meta:
|
||||||
|
model = WareHouse
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class WareHouseCreateUpdateSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = WareHouse
|
||||||
|
fields = ['name', 'number', 'place']
|
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
|
@ -0,0 +1,12 @@
|
||||||
|
from django.db.models import base
|
||||||
|
from rest_framework import urlpatterns
|
||||||
|
from apps.inm.views import WarehouseViewSet
|
||||||
|
from django.urls import path, include
|
||||||
|
from rest_framework.routers import DefaultRouter
|
||||||
|
|
||||||
|
router = DefaultRouter()
|
||||||
|
router.register('warehouse', WarehouseViewSet, basename='warehouse')
|
||||||
|
urlpatterns = [
|
||||||
|
path('', include(router.urls)),
|
||||||
|
]
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
from rest_framework.viewsets import ModelViewSet
|
||||||
|
|
||||||
|
from apps.inm.models import WareHouse
|
||||||
|
from apps.inm.serializers import WareHouseSerializer, WareHouseCreateUpdateSerializer
|
||||||
|
from apps.system.mixins import CreateUpdateModelAMixin, OptimizationMixin
|
||||||
|
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
class WarehouseViewSet(CreateUpdateModelAMixin, ModelViewSet):
|
||||||
|
"""
|
||||||
|
仓库-增删改查
|
||||||
|
"""
|
||||||
|
perms_map = {'*': '*'}
|
||||||
|
queryset = WareHouse.objects.select_related('create_by').all()
|
||||||
|
serializer_class = WareHouseSerializer
|
||||||
|
search_fields = ['name', 'number', 'place']
|
||||||
|
filterset_fields = []
|
||||||
|
ordering_fields = ['create_time']
|
||||||
|
ordering = ['-create_time']
|
||||||
|
|
||||||
|
def get_serializer_class(self):
|
||||||
|
if self.action in ['create', 'update']:
|
||||||
|
return WareHouseCreateUpdateSerializer
|
||||||
|
return WareHouseSerializer
|
|
@ -51,7 +51,8 @@ INSTALLED_APPS = [
|
||||||
'apps.em',
|
'apps.em',
|
||||||
'apps.hrm',
|
'apps.hrm',
|
||||||
'apps.wf',
|
'apps.wf',
|
||||||
'apps.mtm'
|
'apps.mtm',
|
||||||
|
'apps.inm',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|
|
@ -64,6 +64,7 @@ urlpatterns = [
|
||||||
path('api/hrm/', include('apps.hrm.urls')),
|
path('api/hrm/', include('apps.hrm.urls')),
|
||||||
path('api/wf/', include('apps.wf.urls')),
|
path('api/wf/', include('apps.wf.urls')),
|
||||||
path('api/mtm/', include('apps.mtm.urls')),
|
path('api/mtm/', include('apps.mtm.urls')),
|
||||||
|
path('api/inm/', include('apps.inm.urls')),
|
||||||
# 工具
|
# 工具
|
||||||
path('api/utils/signature/', GenSignature.as_view()),
|
path('api/utils/signature/', GenSignature.as_view()),
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue