Beispiel #1
0
 def add_file(self, file_data):
     file_seq = pg_update.getSeq('file')
     file_data['id'] = int(file_seq)
     file_data['exist'] = 1
     file_data['path'] = file_data['path'] + str(file_seq) + '_' + file_data['file_name']
     pg_update.insertOne("file", file_data)
     return file_data
def add_role(data_map):
    '''
    新增角色
    '''
    try:
        pg_update.insertOne("role", data_map)
    except Exception, e:
        raise Exception("角色代码已存在", data_map)
Beispiel #3
0
 def add_file(self, file_data):
     file_seq = pg_update.getSeq('file')
     file_data['id'] = int(file_seq)
     file_data['exist'] = 1
     file_data['path'] = file_data['path'] + str(
         file_seq) + '_' + file_data['file_name']
     pg_update.insertOne("file", file_data)
     return file_data
Beispiel #4
0
 def add_role_business(self, role_code, business_code):
     '''
     添加角色拥有业务
     '''
     pg_update.insertOne("role_business", {
         'role_code': role_code,
         'business_code': business_code
     })
def add_user(data_map):
    '''
    新增用户
    '''
    try:
        pg_update.insertOne("user_info", data_map)
    except Exception, e:
        raise Exception("用户已存在", data_map)
Beispiel #6
0
 def add_business_api(self, business_code, api):
     '''
     添加业务拥有api
     '''
     pg_update.insertOne("business_api", {
         'api': api,
         'business_code': business_code
     })
Beispiel #7
0
 def add_message(self, message, message_type, send_type, send_value, receive_type, receive_value):
     message_data = {}
     message_data['id'] = int(pg_update.getSeq('message'))
     message_data['message'] = message
     message_data['message_type'] = message_type
     message_data['send_type'] = send_type
     message_data['send_value'] = send_value
     message_data['receive_type'] = receive_type
     message_data['receive_value'] = receive_value
     pg_update.insertOne("message", message_data)
     MessageSendRecord.add_message_send_record(message_data)
Beispiel #8
0
 def add_role(data_map):
     '''
     新增角色
     '''
     try:
         pg_update.insertOne("role", data_map)
     except Exception, e:
         if str(e).find('unique') != -1:
             raise CooError(text='角色代码已存在:' + data_map['role_code'])
         else:
             raise CooError(text='未知错误')
Beispiel #9
0
 def add_role(data_map):
     '''
     新增角色
     '''
     try:
         pg_update.insertOne("role", data_map)
     except Exception, e:
         if str(e).find('unique') != -1:
             raise CooError(text='角色代码已存在:' + data_map['role_code'])
         else:
             raise CooError(text='未知错误')
Beispiel #10
0
 def add_user(self):
     '''
     新增用户
     '''
     try:
         pg_update.insertOne("user_info", self.user_map)
     except Exception, e:
         if str(e).find('unique') != -1:
             raise CooError(text='用户已存在:' + self.user_map['account'])
         else:
             print e
             raise CooError(text='未知错误')
Beispiel #11
0
 def add_user(self):
     '''
     新增用户
     '''
     try:
         pg_update.insertOne("user_info", self.user_map)
     except Exception, e:
         if str(e).find('unique') != -1:
             raise CooError(text='用户已存在:' + self.user_map['account'])
         else:
             print e
             raise CooError(text='未知错误')
Beispiel #12
0
 def add_message(self, message, message_type, send_type, send_value,
                 receive_type, receive_value):
     message_data = {}
     message_data['id'] = int(pg_update.getSeq('message'))
     message_data['message'] = message
     message_data['message_type'] = message_type
     message_data['send_type'] = send_type
     message_data['send_value'] = send_value
     message_data['receive_type'] = receive_type
     message_data['receive_value'] = receive_value
     pg_update.insertOne("message", message_data)
     MessageSendRecord.add_message_send_record(message_data)
Beispiel #13
0
def __addBusinessApi(api, business):
    '''
    传入api及business
    添加到business_code表中
    '''
    sql = '''
      select * from business_api
        where api = '%s' and business_code = '%s'
    ''' % (api, business)
    business_apis = pg_update.selectBySql(sql)
    if len(business_apis) == 0:
        data_map['api'] = api
        data_map['business_code'] = business
        pg_update.insertOne("business_api", data_map)
Beispiel #14
0
def __addRoleBusiness(role, business):
    '''
    传入role及business
    添加到role_business表中
    '''
    sql = '''
      select * from role_business
        where role = '%s' and business_code = '%s'
    ''' % (role, business)
    role_business = pg_update.selectBySql(sql)
    if len(business_apis) == 0:
        data_map['role_code'] = api
        data_map['business_code'] = business
        pg_update.insertOne("role_business", data_map)
Beispiel #15
0
 def add_message_send_record(self, message_data):
     if message_data['receive_type'] == 'user':
         message_record_data = {}
         message_record_data['message_id'] = message_data['id']
         message_record_data['send_status'] = 0
         message_record_data['receive_account'] = message_data['receive_value']
         pg_update.insertOne("message_send_record", message_record_data)
     if message_data['receive_type'] == 'role':
         message_record_datas = []
         users = User.get_users_by_role(message_data['receive_value'])
         for user in users:
             message_record_data = {}
             message_record_data['message_id'] = message_data['id']
             message_record_data['send_status'] = 0
             message_record_data['receive_account'] = user['account']
             message_record_datas.append(message_record_data)
         pg_update.insert("message_send_record", message_record_datas)
Beispiel #16
0
 def add_message_send_record(self, message_data):
     if message_data['receive_type'] == 'user':
         message_record_data = {}
         message_record_data['message_id'] = message_data['id']
         message_record_data['send_status'] = 0
         message_record_data['receive_account'] = message_data[
             'receive_value']
         pg_update.insertOne("message_send_record", message_record_data)
     if message_data['receive_type'] == 'role':
         message_record_datas = []
         users = User.get_users_by_role(message_data['receive_value'])
         for user in users:
             message_record_data = {}
             message_record_data['message_id'] = message_data['id']
             message_record_data['send_status'] = 0
             message_record_data['receive_account'] = user['account']
             message_record_datas.append(message_record_data)
         pg_update.insert("message_send_record", message_record_datas)
Beispiel #17
0
def __addApi():
    '''
    将其api接口函数信息添加到api表中
    '''
    funs = __getFuns()
    for fun in funs:
        if pg_update.select("api", where=" api = '%s' " % fun.__name__):
            # 已存在则跳过
            continue
        data_map = {}
        data_map['api'] = fun.__name__
        data_map['api_explain'] = fun.__doc__.strip('\n').split('\n')[0].strip(
            ' ').strip('\n') if fun.__doc__ else ''
        data_map['path'] = fun.__module__
        data_map['disable'] = 0
        data_map['error'] = 0
        data_map['session'] = 1
        data_map['restrict'] = (0 if fun.__module__
                                == 'model.businessLayer.base_business' else 1)
        pg_update.insertOne("api", data_map)
Beispiel #18
0
 def add_session_by_account(self, account):
     '''
     session注册
     '''
     where = "account = '%s' and status = 0 and invalid_time > now() " % account
     session = pg_update.select("session", where=where)
     if session:
         raise CooError(text='该帐号已被登陆!')
     data = {}
     data['account'] = account
     data['session'] = str(uuid.uuid4())
     # 60秒后失效
     data['invalid_time'] = str(datetime.datetime.now() + datetime.timedelta(seconds=600))[:19]
     try:
         pg_update.insertOne("session", data)
         return data['session']
     except Exception, e:
         if str(e).find('unique') != -1:
             return add_session_by_account(account)
         else:
             print e
             raise CooError(text='未知错误')
Beispiel #19
0
 def add_session_by_account(self, account):
     '''
     session注册
     '''
     where = "account = '%s' and status = 0 and invalid_time > now() " % account
     session = pg_update.select("session", where=where)
     if session:
         raise CooError(text='该帐号已被登陆!')
     data = {}
     data['account'] = account
     data['session'] = str(uuid.uuid4())
     # 60秒后失效
     data['invalid_time'] = str(datetime.datetime.now() +
                                datetime.timedelta(seconds=600))[:19]
     try:
         pg_update.insertOne("session", data)
         return data['session']
     except Exception, e:
         if str(e).find('unique') != -1:
             return add_session_by_account(account)
         else:
             print e
             raise CooError(text='未知错误')
Beispiel #20
0
 def add_business_api(self, business_code, api):
     '''
     添加业务拥有api
     '''
     pg_update.insertOne("business_api", {'api': api, 'business_code': business_code})
Beispiel #21
0
 def add_role_business(self, role_code, business_code):
     '''
     添加角色拥有业务
     '''
     pg_update.insertOne("role_business", {'role_code': role_code, 'business_code': business_code})
Beispiel #22
0
 def add_business(self, data_map):
     '''
     新增业务
     '''
     pg_update.insertOne("business", data_map)
Beispiel #23
0
 def add_business(self, data_map):
     '''
     新增业务
     '''
     pg_update.insertOne("business", data_map)
Beispiel #24
0
def initializeDb():
    forciblyCreateAllTable()
    data = pg_update.insertOne("user_info", {'name': '陈力', "account": 'chenli', 'password': "******"})
    data = pg_update.insertOne("role", {'role_code': 'root', "role_name": 'root', 'role_explain': "超级用户,拥有系统中所有的模块和权限",
                               'role_type': 'root', 'seq_code': 'root', 'parent_role_code': 'None'})
    data = pg_update.insertOne("role", {'role_code': 'user_root', "role_name": '超级用户', 'role_explain': "超级用户,拥有系统中所有用户相关的模块和权限",
                               'role_type': 'root', 'seq_code': 'root.user_root', 'parent_role_code': 'root'})
    data = pg_update.insertOne("role", {'role_code': 'sys_root', "role_name": '超级管理员', 'role_explain': "超级管理员,拥有系统中所有系统相关的模块和权限",
                               'role_type': 'root', 'seq_code': 'root.sys_root', 'parent_role_code': 'root'})
    data = pg_update.insertOne("role", {'role_code': 'sys_manage', "role_name": '系统管理员', 'role_explain': "管理系统系统业务",
                               'role_type': 'norm', 'seq_code': 'root.sys_root.sys_manage', 'parent_role_code': 'sys_root'})

    data = pg_update.insertOne("user_role", {'role_code': 'sys_manage', "account": 'chenli'})

    data = pg_update.insertOne("business", {'business_code': 'top', "business_name": '顶层业务', 'business_explain': "系统顶层业务,其它业务都是其子孙业务",
                               'parent_business_code': 'None', 'is_leaf': 0, 'seq_code': 'top'})
    data = pg_update.insertOne("business", {'business_code': 'sys', "business_name": '系统业务', 'business_explain': "包括所有系统管理的业务",
                               'parent_business_code': 'top', 'is_leaf': 0, 'seq_code': 'top.sys'})
    data = pg_update.insertOne("business", {'business_code': 'sys_base_deploy', "business_name": '基础配置', 'business_explain': "系统基础数据的更新(单表)",
                               'parent_business_code': 'sys', 'is_leaf': 0, 'seq_code': 'top.sys.sys_base_deploy'})
    data = pg_update.insertOne("business", {'business_code': 'user_management', "business_name": '用户管理', 'business_explain': "用户管理",
                               'parent_business_code': 'sys_base_deploy', 'is_leaf': 1, 'component': 'user_management', 'icon': 'users', 'seq_code': 'top.sys.sys_base_deploy.user_management'})
    data = pg_update.insertOne("business", {'business_code': 'role_management', "business_name": '角色管理', 'business_explain': "角色管理",
                               'parent_business_code': 'sys_base_deploy', 'is_leaf': 1, 'component': 'role_management', 'icon': 'spy', 'seq_code': 'top.sys.sys_base_deploy.role_management'})
    data = pg_update.insertOne("business", {'business_code': 'business_management', "business_name": '业务管理', 'business_explain': "业务管理",
                               'parent_business_code': 'sys_base_deploy', 'is_leaf': 1, 'component': 'business_management', 'icon': 'users', 'seq_code': 'top.sys.sys_base_deploy.business_management'})
    data = pg_update.insertOne("business", {'business_code': 'api_management', "business_name": 'API管理', 'business_explain': "API管理",
                               'parent_business_code': 'sys_base_deploy', 'is_leaf': 1, 'component': 'api_management', 'icon': 'users', 'seq_code': 'top.sys.sys_base_deploy.api_management'})

    data = pg_update.insertOne("role_business", {'role_code': 'root', "business_code": 'top'})
    data = pg_update.insertOne("role_business", {'role_code': 'sys_root', "business_code": 'sys'})
    data = pg_update.insertOne("role_business", {'role_code': 'sys_manage', "business_code": 'sys_base_deploy'})

    data = pg_update.insertOne("business_api", {'api': 'get_businesses_tree', 'business_code': 'business_management'})
    data = pg_update.insertOne("business_api", {'api': 'save_business', 'business_code': 'business_management'})
    data = pg_update.insertOne("business_api", {'api': 'get_roles', 'business_code': 'role_management'})
    data = pg_update.insertOne("business_api", {'api': 'get_roles_tree', 'business_code': 'role_management'})
    data = pg_update.insertOne("business_api", {'api': 'save_role', 'business_code': 'role_management'})
    data = pg_update.insertOne("business_api", {'api': 'change_user_role', 'business_code': 'user_management'})
    data = pg_update.insertOne("business_api", {'api': 'edit_user', 'business_code': 'user_management'})
    data = pg_update.insertOne("business_api", {'api': 'new_user', 'business_code': 'user_management'})
    data = pg_update.insertOne("business_api", {'api': 'get_users', 'business_code': 'user_management'})
    data = pg_update.insertOne("business_api", {'api': 'edit_api', 'business_code': 'user_management'})
    data = pg_update.insertOne("business_api", {'api': 'get_apis', 'business_code': 'user_management'})
Beispiel #25
0
def initializeDb():
    forciblyCreateAllTable()
    data = pg_update.insertOne("user_info", {'name': '陈力', "account": 'chenli', 'password': "******"})
    data = pg_update.insertOne("role", {'role_code': 'root', "role_name": 'root', 'role_explain': "超级用户,拥有系统中所有的模块和权限",
                               'role_type': 'root', 'seq_code': 'root', 'parent_role_code': 'None'})
    data = pg_update.insertOne("role", {'role_code': 'user_root', "role_name": '超级用户', 'role_explain': "超级用户,拥有系统中所有用户相关的模块和权限",
                               'role_type': 'root', 'seq_code': 'root.user_root', 'parent_role_code': 'root'})
    data = pg_update.insertOne("role", {'role_code': 'sys_root', "role_name": '超级管理员', 'role_explain': "超级管理员,拥有系统中所有系统相关的模块和权限",
                               'role_type': 'root', 'seq_code': 'root.sys_root', 'parent_role_code': 'root'})
    data = pg_update.insertOne("role", {'role_code': 'sys_manage', "role_name": '系统管理员', 'role_explain': "管理系统系统业务",
                               'role_type': 'norm', 'seq_code': 'root.sys_root.sys_manage', 'parent_role_code': 'sys_root'})

    data = pg_update.insertOne("user_role", {'role_code': 'sys_manage', "account": 'chenli'})

    data = pg_update.insertOne("business", {'business_code': 'top', "business_name": '顶层业务', 'business_explain': "系统顶层业务,其它业务都是其子孙业务",
                               'parent_business_code': 'None', 'is_leaf': 0, 'seq_code': 'top'})
    data = pg_update.insertOne("business", {'business_code': 'sys', "business_name": '系统业务', 'business_explain': "包括所有系统管理的业务",
                               'parent_business_code': 'top', 'is_leaf': 0, 'seq_code': 'top.sys'})
    data = pg_update.insertOne("business", {'business_code': 'sys_base_deploy', "business_name": '基础配置', 'business_explain': "系统基础数据的更新(单表)",
                               'parent_business_code': 'sys', 'is_leaf': 0, 'seq_code': 'top.sys.sys_base_deploy'})
    data = pg_update.insertOne("business", {'business_code': 'user_management', "business_name": '用户管理', 'business_explain': "用户管理",
                               'parent_business_code': 'sys_base_deploy', 'is_leaf': 1, 'component': 'user_management', 'icon': 'users', 'seq_code': 'top.sys.sys_base_deploy.user_management'})
    data = pg_update.insertOne("business", {'business_code': 'role_management', "business_name": '角色管理', 'business_explain': "角色管理",
                               'parent_business_code': 'sys_base_deploy', 'is_leaf': 1, 'component': 'role_management', 'icon': 'spy', 'seq_code': 'top.sys.sys_base_deploy.role_management'})
    data = pg_update.insertOne("business", {'business_code': 'business_management', "business_name": '业务管理', 'business_explain': "业务管理",
                               'parent_business_code': 'sys_base_deploy', 'is_leaf': 1, 'component': 'business_management', 'icon': 'users', 'seq_code': 'top.sys.sys_base_deploy.business_management'})
    data = pg_update.insertOne("business", {'business_code': 'api_management', "business_name": 'API管理', 'business_explain': "API管理",
                               'parent_business_code': 'sys_base_deploy', 'is_leaf': 1, 'component': 'api_management', 'icon': 'users', 'seq_code': 'top.sys.sys_base_deploy.api_management'})

    data = pg_update.insertOne("role_business", {'role_code': 'root', "business_code": 'top'})
    data = pg_update.insertOne("role_business", {'role_code': 'sys_root', "business_code": 'sys'})
    data = pg_update.insertOne("role_business", {'role_code': 'sys_manage', "business_code": 'sys_base_deploy'})

    data = pg_update.insertOne("business_api", {'api': 'get_businesses_tree', 'business_code': 'business_management'})
    data = pg_update.insertOne("business_api", {'api': 'save_business', 'business_code': 'business_management'})
    data = pg_update.insertOne("business_api", {'api': 'get_roles', 'business_code': 'role_management'})
    data = pg_update.insertOne("business_api", {'api': 'get_roles_tree', 'business_code': 'role_management'})
    data = pg_update.insertOne("business_api", {'api': 'save_role', 'business_code': 'role_management'})
    data = pg_update.insertOne("business_api", {'api': 'change_user_role', 'business_code': 'user_management'})
    data = pg_update.insertOne("business_api", {'api': 'edit_user', 'business_code': 'user_management'})
    data = pg_update.insertOne("business_api", {'api': 'new_user', 'business_code': 'user_management'})
    data = pg_update.insertOne("business_api", {'api': 'get_users', 'business_code': 'user_management'})
    data = pg_update.insertOne("business_api", {'api': 'edit_api', 'business_code': 'user_management'})
    data = pg_update.insertOne("business_api", {'api': 'get_apis', 'business_code': 'user_management'})