package com.consum.model.po; import com.walker.jdbc.BaseMapper; import com.walker.jdbc.ResultSetUtils; import com.walker.jdbc.SqlAndParameters; import com.walker.jdbc.sqlgen.DeleteBuilder; import com.walker.jdbc.sqlgen.InsertBuilder; import com.walker.jdbc.sqlgen.SelectBuilder; import com.walker.jdbc.sqlgen.UpdateBuilder; import com.walker.jdbc.util.StringUtils; import org.springframework.jdbc.core.RowMapper; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map; /** * 表名:BASE_CATEGORY * * @author genrator */ public class BaseCategory_mapper extends BaseCategory implements BaseMapper { // 序列化版本号 private static final long serialVersionUID = 1L; public static final RowMapper ROW_MAPPER = new BaseCategoryRowMapper(); // 主键 public static final String Id = "id"; // 普通属性 public static final String CategoryName = "category_name"; public static final String Classification = "classification"; public static final String OrderNumber = "order_number"; public static final String States = "states"; public static final String Levels = "levels"; public static final String FatherCategoryId = "father_category_id"; /** * 默认构造函数 */ public BaseCategory_mapper(BaseCategory baseCategory) { if (baseCategory == null) { throw new IllegalArgumentException("po参数不允许为空!"); } //主键 if (baseCategory.isset_id) { this.setId(baseCategory.getId()); } //普通属性 if (baseCategory.isset_categoryName) { this.setCategoryName(baseCategory.getCategoryName()); } if (baseCategory.isset_classification) { this.setClassification(baseCategory.getClassification()); } if (baseCategory.isset_orderNumber) { this.setOrderNumber(baseCategory.getOrderNumber()); } if (baseCategory.isset_states) { this.setStates(baseCategory.getStates()); } if (baseCategory.isset_levels) { this.setLevels(baseCategory.getLevels()); } if (baseCategory.isset_fatherCategoryId) { this.setFatherCategoryId(baseCategory.getFatherCategoryId()); } // 去掉,2022-09-07 // this.setDatabaseName_(base_category.getDatabaseName_()); } /** * 获取表名 */ @Override public String getTableName_() { String tableName = "base_category"; /** if (StringUtils.isNotEmpty(this.getDatabaseName_())) { return this.getDatabaseName_() + "." + tableName; } else { return tableName; } */ return tableName; } /** * 获取主键名称 */ @Override public String getPkName_() { return Id; } /** * 获取主键值 */ @Override public Object getPkValue_() { return this.getId(); } /** * 获取插入语句和参数 */ @Override public SqlAndParameters> getInsertSql_() { InsertBuilder ib = new InsertBuilder(this.getTableName_()); ib.set(Id, this.getId()); ib.set(CategoryName, this.getCategoryName(), this.isset_categoryName); ib.set(Classification, this.getClassification(), this.isset_classification); ib.set(OrderNumber, this.getOrderNumber(), this.isset_orderNumber); ib.set(States, this.getStates(), this.isset_states); ib.set(Levels, this.getLevels(), this.isset_levels); ib.set(FatherCategoryId, this.getFatherCategoryId(), this.isset_fatherCategoryId); return ib.genMapSql(); } /** * 获取更新语句和参数 */ @Override public SqlAndParameters> getUpdateSql_() { UpdateBuilder ub = new UpdateBuilder(this.getTableName_()); ub.set(CategoryName, this.getCategoryName(), this.isset_categoryName); ub.set(Classification, this.getClassification(), this.isset_classification); ub.set(OrderNumber, this.getOrderNumber(), this.isset_orderNumber); ub.set(States, this.getStates(), this.isset_states); ub.set(Levels, this.getLevels(), this.isset_levels); ub.set(FatherCategoryId, this.getFatherCategoryId(), this.isset_fatherCategoryId); ub.where(this.getPkName_(), this.getPkValue_()); return ub.genMapSql(); } /** * 获取更新语句和参数 */ @Override public SqlAndParameters> getUpdateSql_(String where, Map parameters) { UpdateBuilder ub = new UpdateBuilder(this.getTableName_()); ub.set(CategoryName, this.getCategoryName(), this.isset_categoryName); ub.set(Classification, this.getClassification(), this.isset_classification); ub.set(OrderNumber, this.getOrderNumber(), this.isset_orderNumber); ub.set(States, this.getStates(), this.isset_states); ub.set(Levels, this.getLevels(), this.isset_levels); ub.set(FatherCategoryId, this.getFatherCategoryId(), this.isset_fatherCategoryId); return ub.genMapSql(where, parameters); } /** * 获取更新语句和参数 */ @Override public SqlAndParameters getUpdateSql_(String where, Object[] parameters) { UpdateBuilder ub = new UpdateBuilder(this.getTableName_()); ub.set(CategoryName, this.getCategoryName(), this.isset_categoryName); ub.set(Classification, this.getClassification(), this.isset_classification); ub.set(OrderNumber, this.getOrderNumber(), this.isset_orderNumber); ub.set(States, this.getStates(), this.isset_states); ub.set(Levels, this.getLevels(), this.isset_levels); ub.set(FatherCategoryId, this.getFatherCategoryId(), this.isset_fatherCategoryId); return ub.genArraySql(where, parameters); } /** * 获取删除语句和参数 */ @Override public SqlAndParameters> getDeleteSql_() { DeleteBuilder db = new DeleteBuilder(this.getTableName_()); db.where(this.getPkName_(), this.getPkValue_()); return db.genMapSql(); } /** * 获取删除语句和参数 */ @Override public SqlAndParameters> getDeleteSql_(String where, Map parameters) { DeleteBuilder db = new DeleteBuilder(this.getTableName_()); return db.genMapSql(where, parameters); } /** * 获取删除语句和参数 */ @Override public SqlAndParameters getDeleteSql_(String where, Object[] parameters) { DeleteBuilder db = new DeleteBuilder(this.getTableName_()); return db.genArraySql(where, parameters); } /** * 获取单行查询语句和参数 */ @Override public SqlAndParameters> getSingleSql_() { SelectBuilder sb = new SelectBuilder(this.getTableName_()); sb.where(this.getPkName_(), this.getPkValue_()); return sb.genMapSql(); } /** * 获取查询语句和参数 */ @Override public SqlAndParameters> getSelectSql_(String where, Map parameters) { return new SqlAndParameters<>("select id, category_name, classification, order_number, states, levels, father_category_id from " + this.getTableName_() + " " + where, parameters); } /** * 获取查询语句和参数 */ @Override public SqlAndParameters getSelectSql_(String where, Object[] parameters) { return new SqlAndParameters<>("select id, category_name, classification, order_number, states, levels, father_category_id from " + this.getTableName_() + " " + where, parameters); } /** * 将resultset的一行转化为po */ @Override public BaseCategory mapRow(ResultSet rs, int i) throws SQLException { return ROW_MAPPER.mapRow(rs, i); } /** * 克隆 */ public BaseCategory toBaseCategory() { return super.$clone(); } } /** * base_category RowMapper * * @author genrator */ class BaseCategoryRowMapper implements RowMapper { @Override public BaseCategory mapRow(ResultSet rs, int i) throws SQLException { ResultSetUtils resultSetUtils = new ResultSetUtils(); BaseCategory base_category = new BaseCategory(); Integer columnIndex; //主键 columnIndex = resultSetUtils.findColumn(rs, BaseCategory_mapper.Id); if (columnIndex > 0) { base_category.setId(rs.getLong(columnIndex)); } //普通属性 columnIndex = resultSetUtils.findColumn(rs, BaseCategory_mapper.CategoryName); if (columnIndex > 0) { base_category.setCategoryName(rs.getString(columnIndex)); } columnIndex = resultSetUtils.findColumn(rs, BaseCategory_mapper.Classification); if (columnIndex > 0) { base_category.setClassification(rs.getString(columnIndex)); } columnIndex = resultSetUtils.findColumn(rs, BaseCategory_mapper.OrderNumber); if (columnIndex > 0) { if (rs.getBigDecimal(columnIndex) == null) { base_category.setOrderNumber(null); } else { base_category.setOrderNumber(rs.getInt(columnIndex)); } } columnIndex = resultSetUtils.findColumn(rs, BaseCategory_mapper.States); if (columnIndex > 0) { if (rs.getBigDecimal(columnIndex) == null) { base_category.setStates(null); } else { base_category.setStates(rs.getInt(columnIndex)); } } columnIndex = resultSetUtils.findColumn(rs, BaseCategory_mapper.Levels); if (columnIndex > 0) { if (rs.getBigDecimal(columnIndex) == null) { base_category.setLevels(null); } else { base_category.setLevels(rs.getInt(columnIndex)); } } columnIndex = resultSetUtils.findColumn(rs, BaseCategory_mapper.FatherCategoryId); if (columnIndex > 0) { if (rs.getBigDecimal(columnIndex) == null) { base_category.setFatherCategoryId(null); } else { base_category.setFatherCategoryId(rs.getLong(columnIndex)); } } return base_category; } }