新建 CooperationMind
This commit is contained in:
@@ -26,3 +26,10 @@
|
|||||||
3. 提交代码
|
3. 提交代码
|
||||||
4. 新建 Pull Request
|
4. 新建 Pull Request
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
python manage.py makemigrations server
|
||||||
|
|
||||||
|
python manage.py migrate server
|
||||||
|
|
||||||
|
```
|
||||||
|
|||||||
+17
-14
@@ -1,19 +1,25 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
class AbstractModel(models.Model):
|
||||||
|
id = models.AutoField(primary_key=True)
|
||||||
|
create_time = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
|
||||||
|
update_time = models.DateTimeField(verbose_name='修改时间', auto_now=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
class CooperationMind(models.Model):
|
class CooperationMind(AbstractModel):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
"""
|
"""
|
||||||
id = models.AutoField(primary_key=True)
|
|
||||||
coop_mind_name = models.CharField(verbose_name='脑图名称', max_length=64, null=False, blank=False)
|
coop_mind_name = models.CharField(verbose_name='脑图名称', max_length=64, null=False, blank=False)
|
||||||
creator = models.BigIntegerField(verbose_name='创建人', null=False, blank=False)
|
creator = models.BigIntegerField(verbose_name='创建人ID', null=False, blank=False)
|
||||||
client_id = models.CharField(verbose_name='客户端ID', max_length=64, null=False, blank=False)
|
client_id = models.CharField(verbose_name='客户端ID', max_length=64, null=False, blank=False)
|
||||||
data = models.TextField(verbose_name='脑图数据', null=True, )
|
snapshot_data = models.TextField(verbose_name='脑图数据', null=True, )
|
||||||
data_log_id = models.BigIntegerField(verbose_name='data对应的操作日志ID', null=True, )
|
snapshot_log_id = models.BigIntegerField(verbose_name='data对应的操作日志(cooperation_mind_log)ID', null=True, )
|
||||||
create_time = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
|
|
||||||
update_time = models.DateTimeField(verbose_name='修改时间', auto_now=True)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'cooperation_mind'
|
db_table = 'cooperation_mind'
|
||||||
@@ -25,25 +31,22 @@ class CooperationMind(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
class CooperationMindLog(models.Model):
|
class CooperationMindLog(AbstractModel):
|
||||||
"""
|
"""
|
||||||
操作日志表
|
操作日志表
|
||||||
"""
|
"""
|
||||||
id = models.AutoField(primary_key=True)
|
|
||||||
coop_mind_id = models.BigIntegerField(verbose_name='脑图ID', null=False, blank=False)
|
coop_mind_id = models.BigIntegerField(verbose_name='脑图ID', null=False, blank=False)
|
||||||
log_id = models.CharField(verbose_name='操作ID', max_length=64, null=False, blank=False)
|
log_uuid = models.CharField(verbose_name='操作UUID', max_length=64, null=False, blank=False)
|
||||||
log_event = models.CharField(verbose_name='操作事件', max_length=32, null=False, blank=False)
|
log_event = models.CharField(verbose_name='操作事件', max_length=32, null=False, blank=False)
|
||||||
log_content = models.CharField(verbose_name='操作内容', max_length=1024, null=False, blank=False)
|
log_content = models.CharField(verbose_name='操作内容', max_length=1024, null=False, blank=False)
|
||||||
operator = models.BigIntegerField(verbose_name='操作人', null=False)
|
operator = models.BigIntegerField(verbose_name='操作人', null=False)
|
||||||
operator_ip = models.CharField(verbose_name='操作人IP', null=False, max_length=32)
|
operator_ip = models.CharField(verbose_name='操作人IP', null=False, max_length=32)
|
||||||
client_id = models.CharField(verbose_name='客户端ID', max_length=64, null=False, blank=False)
|
client_id = models.CharField(verbose_name='客户端ID', max_length=64, null=False, blank=False)
|
||||||
create_time = models.DateTimeField(verbose_name='创建时时间', auto_now_add=True)
|
|
||||||
update_time = models.DateTimeField(verbose_name='修改时间', auto_now=True)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'cooperation_mind_log'
|
db_table = 'cooperation_mind_log'
|
||||||
ordering = ['-log_id']
|
ordering = ['id']
|
||||||
unique_together = (("coop_mind_id", "log_id"),)
|
unique_together = (("coop_mind_id", "log_uuid"),)
|
||||||
indexes = [
|
indexes = [
|
||||||
models.Index(fields=['coop_mind_id'], ),
|
models.Index(fields=['coop_mind_id'], ),
|
||||||
models.Index(fields=['operator'], )
|
models.Index(fields=['operator'], )
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from server.views import *
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', list),
|
path('', list),
|
||||||
|
path('create', JsMindLogView.as_view()),
|
||||||
path('detail', detail),
|
path('detail', detail),
|
||||||
path('jsmind_op', JsMindCallbackView.as_view()),
|
path('jsmind_op', JsMindCallbackView.as_view()),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
from rest_framework.response import Response
|
||||||
|
|
||||||
|
|
||||||
|
def build_response(code=0, msg='', data=''):
|
||||||
|
return Response({'code': code, 'msg': msg, 'data': data})
|
||||||
@@ -4,6 +4,7 @@ from rest_framework.response import Response
|
|||||||
from server.models import *
|
from server.models import *
|
||||||
from datetime import datetime as dt
|
from datetime import datetime as dt
|
||||||
from rest_framework.generics import GenericAPIView
|
from rest_framework.generics import GenericAPIView
|
||||||
|
from server.util import build_response
|
||||||
|
|
||||||
|
|
||||||
def list(request):
|
def list(request):
|
||||||
@@ -24,6 +25,11 @@ class JsMindLogView(GenericAPIView):
|
|||||||
def get(self, request):
|
def get(self, request):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def post(self, request):
|
||||||
|
coop_mind_name = request.data.get('mind_name')
|
||||||
|
CooperationMind(coop_mind_name=coop_mind_name, client_id='', snapshot_log_id=-1, creator=-1).save()
|
||||||
|
return build_response()
|
||||||
|
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
class JsMindCallbackView(APIView):
|
class JsMindCallbackView(APIView):
|
||||||
|
|||||||
@@ -89,7 +89,10 @@
|
|||||||
$('#c_').click(function () {
|
$('#c_').click(function () {
|
||||||
const mind_name = $('#mind_name').val()
|
const mind_name = $('#mind_name').val()
|
||||||
if (mind_name) {
|
if (mind_name) {
|
||||||
|
$.post('create', {'mind_name': mind_name}, function (resp) {
|
||||||
|
console.log(resp)
|
||||||
view.fetch_data()
|
view.fetch_data()
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
layer.msg('请输入导图名称')
|
layer.msg('请输入导图名称')
|
||||||
}
|
}
|
||||||
@@ -100,7 +103,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div style="margin-top: 5px;">
|
<div style="margin-top: 5px;">
|
||||||
<div class="layui-input-inline">
|
<div class="layui-input-inline">
|
||||||
<input type="password" name="password" required lay-verify="required" placeholder="请输入思维导图名称" autocomplete="off" class="layui-input" id="mind_name">
|
<input name="mind_name" required lay-verify="required" placeholder="请输入思维导图名称" autocomplete="off" class="layui-input" id="mind_name">
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="layui-btn" id="c_">创建导图</button>
|
<button type="button" class="layui-btn" id="c_">创建导图</button>
|
||||||
<button type="button" class="layui-btn">搜索</button>
|
<button type="button" class="layui-btn">搜索</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user