mybatis+mysql 通过sql脚本生成mapper的部分内容
SQL mysql
SELECT concat('<if test="', COLUMN_NAME, ' != null"> ', COLUMN_NAME, ',</if>') FROM information_schema.COLUMNS WHERE TABLE_NAME = 'view_opportunity' AND TABLE_SCHEMA = 'helenbergh_mcrm_pro'; SELECT concat('<if test="', COLUMN_NAME, ' != null"> #{', COLUMN_NAME, '},</if>') FROM information_schema.COLUMNS WHERE TABLE_NAME = 'view_opportunity' AND TABLE_SCHEMA = 'helenbergh_mcrm_pro'; SELECT concat('<if test="', COLUMN_NAME, ' != null"> ', COLUMN_NAME, ' = #{', COLUMN_NAME, '},</if>') FROM information_schema.COLUMNS WHERE TABLE_NAME = 'view_opportunity' AND TABLE_SCHEMA = 'helenbergh_mcrm_pro'; SELECT concat('private ', CASE WHEN DATA_TYPE = 'varchar' OR DATA_TYPE = 'nvarchar' OR DATA_TYPE = 'char' THEN 'String ' WHEN DATA_TYPE = 'bigint' OR DATA_TYPE = 'int' THEN 'Integer ' WHEN DATA_TYPE = 'datetime' OR DATA_TYPE = 'timestamp' THEN 'Date ' WHEN DATA_TYPE = 'decimal' OR DATA_TYPE = 'timestamp' THEN 'BigDecimal ' ELSE concat('****', DATA_TYPE, '****') END , COLUMN_NAME, ';') FROM information_schema.COLUMNS WHERE TABLE_NAME = 'view_opportunity' AND TABLE_SCHEMA = 'helenbergh_mcrm_pro';