rabin 6 years ago
commit
bcf7ce718e

+ 27 - 0
.gitignore

@@ -0,0 +1,27 @@
+.DS_Store
+*.mo
+*.egg-info
+*.egg
+*.EGG
+*.EGG-INFO
+.cache
+bin
+build
+develop-eggs
+downloads
+eggs
+fake-eggs
+parts
+dist
+.installed.cfg
+.mr.developer.cfg
+.hg
+.bzr
+.svn
+*.pyc
+*.pyo
+*.tmp*
+.idea
+demos/helloworld/runtime/*
+psycopg2
+influxdb

+ 8 - 0
README.rst

@@ -0,0 +1,8 @@
+# dm后台管理系统
+
+安装
+pip install -U git+https://github.com/shemic/demeter
+python install.py
+
+运行:
+python admin.py

+ 9 - 0
admin.py

@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+"""
+    demeter web
+    name:admin.py
+"""
+from demeter.core import *
+
+if __name__ == "__main__":
+	Demeter.webInit('admin')

+ 1 - 0
admin/__init__.py

@@ -0,0 +1 @@
+# -*- coding: utf-8 -*-

+ 5 - 0
admin/main.py

@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+from demeter.web import *
+import demeter.admin.page as admin_page
+import admin.page
+Web.start(application=[admin.page,admin_page])

+ 1 - 0
admin/page/__init__.py

@@ -0,0 +1 @@
+# -*- coding: utf-8 -*-

+ 2 - 0
admin/page/__load__.py

@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+from demeter.admin.page.__load__ import *

+ 159 - 0
admin/page/deploy.py

@@ -0,0 +1,159 @@
+# -*- coding: utf-8 -*-
+"""
+    demeter web page
+    name:score.py 积分相关
+    author:rabin
+"""
+from .__load__ import *
+
+class score_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		self.set(
+			name = u'积分设置'
+			,path = '/score/score'
+			,width = '600'
+			,height = '600'
+			,search = (('label-1','cdate-time-start','cdate-time-end'), (u'日期范围',u'开始时间',u'截止时间'))
+			,thead = (u'积分名', u'规则', u'更新时间')
+			,tbody = ('name', 'func', 'cdate')
+			,state = True
+		)
+
+		menu = (
+			{'name':'规则列表', 'url':'/score/score_rule'},
+			)
+
+		self.list('score')
+		if self.data['list']:
+			for key, value in enumerate(self.data['list']):
+				id = str(value['id'])
+				param = '?score_id=' + id + '&search_score_id-select-=' + id
+				self.data['list'][key]['func'] = ''
+				for i in menu:
+					self.data['list'][key]['func'] = self.data['list'][key]['func'] + '<a href="'+i['url']+''+param+'">'+i['name']+'</a>&nbsp;&nbsp;&nbsp;&nbsp;'
+
+		self.show('list')
+
+class score_update_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		self.set(
+			path = '/score/score'
+			,label = (u'积分名称',)
+			,update = ('name-input-required',)
+		)
+		self.one('score')
+		self.show('update')
+	@Web.auth
+	@Web.setting
+	def post(self):
+		self.update('score')
+	@Web.auth
+	@Web.setting
+	def delete(self):
+		self.drop('score')
+
+class score_rule_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		id = str(self.input('score_id'))
+		param = '?score_id=' + id + '&search_score_id-select-=' + id
+		self.set(
+			name = u'积分规则设置'
+			,path = '/score/score_rule'
+			,width = '600'
+			,height = '600'
+			,search = (('label-1','cdate-time-start','cdate-time-end','search_score_id-select-','record_type_id-select-'), (u'日期范围',u'开始时间',u'截止时间', u'选择积分', u'选择记录点类型'))
+			,thead = (u'积分名', u'记录点类型', u'规则', u'更新时间')
+			,tbody = ('name', 'type', 'rule', 'cdate')
+			,state = True
+		)
+
+		self.data['common']['search_record_type_id-select-'] = self.service('common').list('record_type')
+
+		self.data['common']['search_score_id-select-'] = self.service('common').list('score')
+
+		self.list('score_rule')
+		if self.data['list']:
+			for key, value in enumerate(self.data['list']):
+				typeData = self.service('common').one('record_type', id=value['record_type_id'])
+				self.data['list'][key]['type'] = typeData['name']
+
+				score = self.service('common').one('score', id=value['score_id'])
+				self.data['list'][key]['name'] = score['name']
+
+		self.show('list')
+
+class score_rule_update_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		self.set(
+			path = '/score/score_rule'
+			,label = (u'积分ID', u'记录点类型', u'积分规则公式')
+			,update = ('score_id-select-required','record_type_id-select-required','rule-text-required')
+			,update_record_type_id = self.service('common').list('record_type')
+			,update_score_id = self.service('common').list('score')
+		)
+		self.one('score_rule')
+		self.show('update')
+	@Web.auth
+	@Web.setting
+	def post(self):
+		self.update('score_rule')
+	@Web.auth
+	@Web.setting
+	def delete(self):
+		self.drop('score_rule')
+
+class level_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		id = str(self.input('score_id'))
+		param = '?score_id=' + id + '&search_score_id-select-=' + id
+		self.set(
+			name = u'等级设置'
+			,path = '/score/level'
+			,width = '600'
+			,height = '600'
+			,search = (('label-1','cdate-time-start','cdate-time-end','search_score_id-select-'), (u'日期范围',u'开始时间',u'截止时间', u'选择积分'))
+			,thead = (u'等级名',u'积分名', u'规则', u'更新时间')
+			,tbody = ('name', 'score', 'rule', 'cdate')
+			,state = True
+		)
+
+		self.data['common']['search_score_id-select-'] = self.service('common').list('score')
+
+		self.list('level')
+		if self.data['list']:
+			for key, value in enumerate(self.data['list']):
+				score = self.service('common').one('score', id=value['score_id'])
+				self.data['list'][key]['score'] = score['name']
+
+		self.show('list')
+
+class level_update_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		self.set(
+			path = '/score/level'
+			,label = (u'等级名', u'积分ID', u'规则公式')
+			,update = ('name-input-required','score_id-select-required','rule-text-required')
+			,update_score_id = self.service('common').list('score')
+		)
+		self.one('level')
+		self.show('update')
+	@Web.auth
+	@Web.setting
+	def post(self):
+		self.update('level')
+	@Web.auth
+	@Web.setting
+	def delete(self):
+		self.drop('level')

+ 91 - 0
admin/page/server.py

@@ -0,0 +1,91 @@
+# -*- coding: utf-8 -*-
+"""
+    demeter web page
+    name:server.py 服务器相关
+    author:rabin
+"""
+from .__load__ import *
+
+class group_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		self.set(
+			name = u'组管理'
+			,path = '/server/group'
+			,width = '600'
+			,height = '600'
+			,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'组名称'))
+			,thead = (u'组ID', u'组名称', u'更新时间')
+			,tbody = ('id','name', 'cdate')
+			,state = True
+		)
+
+		self.list('group')
+		self.show('list')
+
+class group_update_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		self.set(
+			path = '/server/group'
+			,label = (u'组名称',)
+			,update = ('name-input-required',)
+		)
+		self.one('group')
+		self.show('update')
+	@Web.auth
+	@Web.setting
+	def post(self):
+		self.update('group')
+	@Web.auth
+	@Web.setting
+	def delete(self):
+		self.drop('group')
+
+class node_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		self.set(
+			name = u'节点管理'
+			,path = '/server/node'
+			,width = '600'
+			,height = '600'
+			,search = (('label-1','cdate-time-start','cdate-time-end','group_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择组', u'节点名称'))
+			,thead = (u'节点ID', u'节点名称', u'组名', u'节点IP', u'更新时间')
+			,tbody = ('id', 'name', 'group', 'ip', 'cdate')
+			,state = True
+		)
+
+		self.data['common']['search_group_id-select-'] = self.service('common').list('group')
+
+		self.list('node')
+		if self.data['list']:
+			for key, value in enumerate(self.data['list']):
+				data = self.service('common').one('group', id=value['group_id'])
+				self.data['list'][key]['type'] = data['name']
+
+		self.show('list')
+
+class node_update_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		self.set(
+			path = '/server/node'
+			,label = (u'节点名称', u'选择组', u'节点IP')
+			,update = ('name-input-required','group_id-select-required', 'ip-input-required')
+			,update_group_id = self.service('common').list('group')
+		)
+		self.one('node')
+		self.show('update')
+	@Web.auth
+	@Web.setting
+	def post(self):
+		self.update('node')
+	@Web.auth
+	@Web.setting
+	def delete(self):
+		self.drop('node')

+ 55 - 0
conf/dev.conf

@@ -0,0 +1,55 @@
+[base]
+;开发环境配置
+[setting]
+name				= DM管理系统
+site				= http://www.dever.cc/
+copyright			= 2018 dever.cc v1.0.0
+;打印路由表
+route				= True
+
+[db]
+rdb					= mysql
+
+[mysql]
+host				= 0.0.0.0
+port				= 3309
+username			= root
+password			= 123456
+dbname				= dm
+prefix				= dm
+charset				= utf8
+;允许自动建表
+create				= True
+
+;定义一些tornado的配置,可为空
+[tornado]
+
+;后台配置
+[admin]
+port				= 8087
+debug				= True
+;请求的buffersize
+max_buffer_size		= 210763776
+;子进程
+process				= 0
+;定义后台父级菜单
+menu_parent			= 服务器设置:&#xe62e;,代码上线:&#xe62e;
+;定义后台子级菜单
+menu_child			= 组设置:/server/group,节点管理:/server/node;项目管理:/deploy/project,提交代码:/deploy/submit,代码审核:/deploy/look,文档管理:/deploy/doc
+
+;cookie
+cookie_secret       = 61oETzKXQAGaYekL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=
+login_url           = /user/login
+;是否使用安全cookie
+xsrf_cookies        = True
+
+;前台配置
+[front]
+port				= 8088
+debug				= True
+;请求的buffersize
+max_buffer_size		= 210763776
+;子进程
+process				= 0
+;支持手机版
+mobile				= True

+ 52 - 0
conf/env.conf

@@ -0,0 +1,52 @@
+[base]
+;线上环境配置,请设置环境变量DEMETER_CONF = env
+[setting]
+name				= 抢购平台
+site				= http://www.dever.cc/
+copyright			= 2017 dever.cc v1.0.0
+phantomjs			= http://192.168.15.10:8910/
+
+[db]
+rdb					= mysql
+
+[mysql]
+host				= 192.168.1.203
+port				= 3307
+username			= root
+password			= 123456
+dbname				= demeter
+prefix				= demeter
+charset				= utf8
+
+;定义一些tornado的配置,可为空
+[tornado]
+
+;后台配置
+[admin]
+port				= 8087
+debug				= True
+;请求的buffersize
+max_buffer_size		= 210763776
+;子进程
+process				= 0
+;定义后台父级菜单
+menu_parent			= 站点设置:&#xe62e;
+;定义后台子级菜单
+menu_child			= 站点管理:/site/site,抢购商品设置:/site/product
+
+;cookie
+cookie_secret		= 61oETzKXQAGaYekL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=
+login_url			= /user/login
+;是否使用安全cookie
+xsrf_cookies		= True
+
+;前台配置
+[front]
+port				= 8088
+debug				= True
+;请求的buffersize
+max_buffer_size		= 210763776
+;子进程
+process				= 0
+;支持手机版
+mobile				= True

+ 24 - 0
install.py

@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+from demeter.core import *
+
+def manage():
+	model = Demeter.model('manage_admin')
+	model.id = 1
+	info = model.select(type='fetchone')
+	if not info:
+		model.role_id = 1
+		model.username = 'admin'
+		model.mobile = '15810090845'
+		model.password = '123456'
+		model.insert()
+
+	model = Demeter.model('manage_role')
+	model.id = 1
+	info = model.select(type='fetchone')
+	if not info:
+		model.name = u'管理员'
+		model.insert()
+
+manage()
+
+Demeter.echo('install success!')

+ 1 - 0
model/__init__.py

@@ -0,0 +1 @@
+# -*- coding: utf-8 -*-

+ 7 - 0
model/__load__.py

@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+"""
+    demeter database
+    name:__load__.py
+"""
+from demeter.model import *
+from demeter.core import *

+ 14 - 0
model/group.py

@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+"""
+    demeter database
+    name:group.py 分组表
+"""
+from .__load__ import *
+
+class Group(Model):
+	__table__ = 'group'
+	__comment__ = '分组表'
+	id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='ID')
+	name = Fields(type='varchar(200)', comment='分组名称')
+	state = Fields(type='boolean', default='True', comment='数据存在状态')
+	cdate = Fields(type='int', default='time', comment='创建时间')

+ 16 - 0
model/node.py

@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+"""
+    demeter database
+    name:node.py 节点表
+"""
+from .__load__ import *
+
+class Node(Model):
+	__table__ = 'node'
+	__comment__ = '节点表'
+	id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='ID')
+	name = Fields(type='varchar(200)', comment='节点名')
+	group_id = Fields(type='int', comment='组id')
+	ip = Fields(type='varchar(32)', comment='ip地址')
+	state = Fields(type='boolean', default='True', comment='数据存在状态')
+	cdate = Fields(type='int', default='time', comment='创建时间')

+ 15 - 0
model/record_type.py

@@ -0,0 +1,15 @@
+# -*- coding: utf-8 -*-
+"""
+    demeter database
+    name:record_type.py 统计类型记录表,暂时用数据库
+"""
+from .__load__ import *
+
+class Record_type(Model):
+	__table__ = 'record_type'
+	__comment__ = '记录点类型表'
+	id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='ID')
+	name = Fields(type='varchar(200)', comment='操作名')
+	type = Fields(type='int', default='1', comment='操作类型1是浏览2是操作')
+	state = Fields(type='boolean', default='True', comment='数据存在状态')
+	cdate = Fields(type='int', default='time', comment='创建时间')

+ 14 - 0
model/score.py

@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+"""
+    demeter database
+    name:score.py 积分表
+"""
+from .__load__ import *
+
+class Score(Model):
+	__table__ = 'score'
+	__comment__ = '积分设置表'
+	id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='ID')
+	name = Fields(type='varchar(200)', comment='积分名称')
+	state = Fields(type='boolean', default='True', comment='数据存在状态')
+	cdate = Fields(type='int', default='time', comment='创建时间')

+ 17 - 0
model/score_rule.py

@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+"""
+    demeter database
+    name:score.py 积分表
+"""
+from .__load__ import *
+
+class Score_rule(Model):
+	__table__ = 'score_rule'
+	__comment__ = '积分规则表'
+	id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='ID')
+	score_id = Fields(type='int', comment='积分id')
+	record_type_id = Fields(type='int', comment='记录点类型id')
+	uid = Fields(type='varchar(200)', comment='用户id,特殊积分')
+	rule = Fields(type='varchar(800)', comment='积分规则公式')
+	state = Fields(type='boolean', default='True', comment='数据存在状态')
+	cdate = Fields(type='int', default='time', comment='创建时间')

+ 6 - 0
runtime/__init__.py

@@ -0,0 +1,6 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+    demeter init
+    author:rabin
+"""

+ 1 - 0
runtime/mysql/level

@@ -0,0 +1 @@
+[["name", 1], ["cdate", 1], ["rule", 1], ["state", 1], ["score_id", 1], ["id", 1]]

+ 1 - 0
runtime/mysql/manage_admin

@@ -0,0 +1 @@
+[["username", 1], ["mobile", 1], ["cdate", 1], ["role_id", 1], ["state", 1], ["password", 1], ["id", 1]]

+ 1 - 0
runtime/mysql/manage_log

@@ -0,0 +1 @@
+[["cdate", 1], ["admin_id", 1], ["method", 1], ["state", 1], ["model", 1], ["data", 1], ["id", 1]]

+ 1 - 0
runtime/mysql/manage_role

@@ -0,0 +1 @@
+[["oper", 1], ["name", 1], ["top", 1], ["state", 1], ["auth", 1], ["cdate", 1], ["id", 1]]

+ 1 - 0
runtime/mysql/record

@@ -0,0 +1 @@
+[["record_type_id", 1], ["name", 1], ["cdate", 1], ["state", 1], ["ua", 1], ["id", 1], ["uid", 1]]

+ 1 - 0
runtime/mysql/record_type

@@ -0,0 +1 @@
+[["type", 1], ["state", 1], ["cdate", 1], ["name", 1], ["id", 1]]

+ 1 - 0
runtime/mysql/score

@@ -0,0 +1 @@
+[["record_type_id", 1], ["name", 1], ["cdate", 1], ["rule", 1], ["state", 1], ["id", 1], ["uid", 1]]

+ 1 - 0
runtime/mysql/score_rule

@@ -0,0 +1 @@
+[["record_type_id", 1], ["uid", 1], ["cdate", 1], ["rule", 1], ["state", 1], ["score_id", 1], ["id", 1]]