def gen_controller_impl(module, folder, test_folder, has_view, prj, settings): kwargs = {} kwargs.update(settings) kwargs['now'] = datetime.now() kwargs['_module_'] = module['name'] kwargs['_moduleC_'] = string.capitalize(module['name']) kwargs['_cprj_'] = prj cprefix = prj if prj == 'pc': cprefix = '' elif prj == 'mobile': cprefix = 'Mobile' else: cprefix = 'Admin' #entity and service for tbl in module['tables']: name = dbm.java_name(tbl) kwargs['_entity_'] = name kwargs['_entityL_'] = dbm.java_name(tbl, upperFirst=False) # table info tbi = dbm.get_table(module, tbl) kwargs['_mvcurl_'] = tbi.mvc_url() cols = [] for c in tbi.columns: if c.isString: cols.append(c) kwargs['_cols_'] = cols kwargs['_tbi_'] = tbi # render controller fname = os.path.join(folder, cprefix + name + 'Controller.java') javagen.render_controller(fname, **kwargs) # render controller form fname = os.path.join(folder, cprefix + name + 'Form.java') javagen.render_form(fname, **kwargs) # gen controller test fname = os.path.join(test_folder, name + 'ControllerTest.java') javagen.render_controller_test(fname, **kwargs) # make view folder if not has_view: continue folder2 = os.path.join(settings['_root_'], 'Web/src/main/webapp/WEB-INF/views/') if prj == 'admin': folder2 = os.path.join(folder2, 'admin') folder2 = os.path.join(folder2, kwargs['_mvcurl_']) if not os.path.exists(folder2): os.makedirs(folder2) for name in ['add', 'view', 'list']: f = os.path.join(folder2, name + '.html') with open(f, 'w+') as fw: fw.write('')
def gen_service_def(module, folder, test_folder, settings): #mapper fname = os.path.join(folder, string.capitalize(module['name']) + 'Mappers.java') kwargs = {} kwargs.update(settings) kwargs['now'] = datetime.now() kwargs['_module_'] = module['name'] kwargs['_moduleC_'] = string.capitalize(module['name']) kwargs['_entitys_'] = [] for tbl in module['tables']: kwargs['_entitys_'].append(dbm.java_name(tbl)) javagen.render_mapper(fname, **kwargs) kwargs.pop('_entitys_') #entity and service for tbl in module['tables']: tbi = dbm.get_table(module, tbl) kwargs['_tbi_'] = tbi fname = os.path.join(folder, tbi.entityName + '.java') kwargs['_cols_'] = tbi.columns kwargs['_pks_'] = tbi.pks #entity javagen.render_entity(fname, **kwargs) kwargs['_service_'] = tbi.entityName + 'Service' fname = os.path.join(folder, 'service', tbi.entityName + 'Service.java') #service javagen.render_service(fname, **kwargs) fname = os.path.join(folder, 'service', tbi.entityName + 'Tx.java') #db-tx javagen.render_tx(fname, **kwargs) # service test fname = os.path.join(test_folder, tbi.entityName + 'ServiceTest.java') javagen.render_service_test(fname, **kwargs)
def gen_entity_def(module, folder, settings): #mapper fname = os.path.join(folder, string.capitalize(module['name']) + 'Mappers.java') kwargs = {} kwargs.update(settings) kwargs['now'] = datetime.now() kwargs['_module_'] = module['name'] kwargs['_moduleC_'] = string.capitalize(module['name']) kwargs['_entitys_'] = [] for tbl in module['tables']: kwargs['_entitys_'].append(dbm.java_name(tbl)) javagen.render_mapper(fname, **kwargs) kwargs.pop('_entitys_') #entity and service for tbl in module['tables']: tbi = dbm.get_table(module, tbl) kwargs['_tbi_'] = tbi fname = os.path.join(folder, tbi.entityName + '.java') kwargs['_cols_'] = tbi.columns kwargs['_pks_'] = tbi.pks #entity javagen.render_entity(fname, **kwargs) fname = os.path.join(folder, 'service', tbi.entityName + 'Tx.java') #db-tx javagen.render_tx(fname, **kwargs)
def gen_ios_service(module, folder, settings): kwargs = {} kwargs.update(settings) kwargs['now'] = datetime.now() kwargs['_module_'] = module['name'] kwargs['_moduleC_'] = string.capitalize(module['name']) #entity and service for tbl in module['tables']: name = 'TS' + dbm.java_name(tbl) tbi = dbm.get_table(module, tbl) kwargs['_tbi'] = tbi fname = os.path.join(folder, name) + 'Service' javagen.render_ios_service(fname, **kwargs)
def gen_service_impl(module, folder, settings): kwargs = {} kwargs.update(settings) kwargs['now'] = datetime.now() kwargs['_module_'] = module['name'] kwargs['_moduleC_'] = string.capitalize(module['name']) #entity and service for tbl in module['tables']: name = dbm.java_name(tbl) kwargs['_entity_'] = name kwargs['_tblname_'] = tbl fname = os.path.join(folder, name + 'ServiceImpl.java') javagen.render_service_impl(fname, **kwargs)