代码如下:
public String getElectronicBookByTypeAndBooktextVersion(Integer type, Integer textbookVersion) {
SQL sql = new SQL() {
{
SELECT( " book_num ,book_name,book_reversion,t.version_name,eb.grade_id,term,phase,picture_url,type,eb.create_time,eb.create_by,g.grade_name " );
FROM( "electronic_book eb " );
JOIN( " grade g ON eb.grade_id = g.grade_id join text_book_version t on eb.book_reversion = t.id" );
WHERE( " type = #{type}" );
if (textbookVersion != null) {
WHERE( "book_reversion = #{textbookVersion}" );
}
}
};
return sql.toString();
}