The invention discloses a method for generating a code by a frame-based
code generation tool. The method comprises the following steps that: configuring
database link information and a
code generation path; configuring a table name and a
package name corresponding to the code, and configuring whether the table name and the
package name are intermediate
table information or not; checking a code option to be generated; connecting with
database information; reading a template; generating a BO layer, a Dao layer, a Dao layer implementation class, a
Service layer, a
Service layer implementation class, mybatis, Mapper and a View layer code; when the table name and the
package name are the intermediate table, generating a view
layer interface code; generating an interface permission control code; if the table name and the
package name are not the intermediate table, generating a query condition sub interface; generating a
list sub interface; generating a new / revised sub interface; and generating a checking sub interface. The
code generation process is simple, efficiency is high, parameter
verification is carried out on a front side and a service side, code robustness is good,
code development cost is lowered, a development cost is shortened, and the repeated coding and the difference of the code can be reduced.