jfinal 生成常量式getset方法规则(main方法)jun

package com.lemo.test;

import java.util.List;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.c3p0.C3p0Plugin;

public class TestModel {

 public static void main(String[] args) {
   C3p0Plugin plugin = new C3p0Plugin("url", "zhanghao", "password");
        plugin.start();
        ActiveRecordPlugin recordPlugin = new ActiveRecordPlugin(plugin);
        recordPlugin.start();
          String sql="select COLUMN_NAME,data_type from information_schema.COLUMNS where table_name = 'task_user';";
        List find = Db.find(sql);
        for (int i = 0; i < find.size(); i++) {
          String lie = find.get(i).getStr("COLUMN_NAME").toUpperCase();
             String ziudan=  find.get(i).getStr("COLUMN_NAME");
          String str="  public static final String  "+lie+"  =\""+ziudan+"\""+";";
          System.out.println(str);
        }
}
}
class changliang{
     public static void main(String[] args) {
       C3p0Plugin plugin = new C3p0Plugin("url", "zhanghao", "password");   
       plugin.start();
       ActiveRecordPlugin recordPlugin = new ActiveRecordPlugin(plugin);
       recordPlugin.start();
         String sql="select COLUMN_NAME,data_type from information_schema.COLUMNS where table_name = 'task_user';";
       List find = Db.find(sql);
       for (int i = 0; i < find.size(); i++) {
         String lie = find.get(i).getStr("COLUMN_NAME").toUpperCase();
            String ziudan=  find.get(i).getStr("COLUMN_NAME");
       String getwayming= ziudan.substring(0,1).toUpperCase()+ziudan.substring(1, ziudan.length());
       String dataType = find.get(i).get("data_type");
       if (dataType.equals("int")|| dataType.equals("tinyint")|| dataType.equals("smallint")||dataType.equals("mediumint")) {
         String get=" public " +"Integer"+ " get"+getwayming+"(){"+"\n"+" return this.getInt("+lie+")"+";"+"\n"+" }";
         String set=" public void set"+getwayming+"(Integer "+ziudan+"){"+"\n"+" this.set("+lie+","+ziudan+");"+"\n"+" }";
         System.out.println(get+"\n");
         System.out.println(set+"\n");
       }else if (dataType.equals("timestamp")||dataType.equals("datetime")) {
         String get=" public " +"Date"+ " get"+getwayming+"(){"+"\n"+" return this.getDate("+lie+")"+";"+"\n"+" }";
         String set=" public void set"+getwayming+"(Date "+ziudan+"){"+"\n"+" this.set("+lie+","+ziudan+");"+"\n"+" }";
         System.out.println(get+"\n");
         System.out.println(set+"\n");
       }else if (dataType.equals("varchar")||dataType.equals("text")||dataType.equals("longtext")) {
         String get=" public " +"String"+ " get"+getwayming+"(){"+"\n"+" return this.getStr("+lie+")"+";"+"\n"+" }";
         String set=" public void set"+getwayming+"(String "+ziudan+"){"+"\n"+" this.set("+lie+","+ziudan+");"+"\n"+" }";
         System.out.println(get+"\n");
         System.out.println(set+"\n");
       }else if (dataType.equals("bigint")) {
         String get=" public " +"Long"+ " get"+getwayming+"(){"+"\n"+" return this.getLong("+lie+")"+";"+"\n"+" }";
         String set=" public void set"+getwayming+"(Long "+ziudan+"){"+"\n"+" this.set("+lie+","+ziudan+");"+"\n"+" }";
         System.out.println(get+"\n");
         System.out.println(set+"\n");
        
      }
       }
    }
}




你可能感兴趣的:(java,jfinal)