💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
增删改查代码由工具生成,生成后再做调整即可 ``` package com.asiainfo.walk.webdemo.tools; import org.walkframework.base.system.common.Common; import org.walkframework.base.tools.dbtocrud.CrudFactory; import org.walkframework.batis.tools.dbtobean.CreateBeanConfig; import org.walkframework.data.util.IData; /** * 根据数据库表生成增删改查代码及实体类 * * @author shf675 * */ public abstract class DbToCrud { /** * 执行main方法生成增删改查代码及实体类代码 * * generate(表名,模块目录(英文),模块名(英文),功能名(中文)) * * @param args */ public static void main(String[] args) { //根包和输出路径设置 String basePackage = "com.asiainfo.walk.webdemo"; String outBasePath = "E:/codegen"; CrudFactory crudFactory = new CrudFactory(createBeanConfig(), basePackage, outBasePath); //开始生成 crudFactory.generate("TD_M_STAFF", "staff", "Staff", "工号管理"); crudFactory.generate("TD_M_USER", "user", "User", "用户管理"); } /** * 数据源设置 * * @return */ @SuppressWarnings("rawtypes") private static CreateBeanConfig createBeanConfig() throws IOException { String dbName = "ds_1";//设置数据库 Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties"); String dbAddr = props.getProperty(String.format("ds.%s.addr", dbName)); String dbUrl = props.getProperty(String.format("ds.%s.url", dbName)); CreateBeanConfig appConfig = new CreateBeanConfig(); appConfig.setDriverClassName(props.getProperty(String.format("ds.%s.driverClassName", dbName))); appConfig.setDburl(dbUrl.replaceAll(String.format("\\$\\{ds.%s.addr\\}", dbName), dbAddr)); appConfig.setDbusername(props.getProperty(String.format("ds.%s.username", dbName))); appConfig.setDbpassword(props.getProperty(String.format("ds.%s.password", dbName))); return appConfig; } } ```