package com;

import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.dialect.SqlServerDialect;
import com.jfinal.plugin.druid.DruidPlugin;
import com.model.Menu;
import com.model.Org;
import com.model.UserMenu;
import com.model._MappingKit;

import java.util.Date;
import java.util.List;

public class CreateUser {


    public static Menu userDao = new Menu().dao();
    public static Org dao = new Org().dao();
    public static Integer a = 5760;

    public static void main(String args[]){
        try {
            PropKit.use("config.txt");
            String jdbcUtil2 = PropKit.get("jdbcUrl");
            String username2 = PropKit.get("user");
            String password2 = PropKit.get("password");
            DruidPlugin druidPlugin = new DruidPlugin(jdbcUtil2, username2, password2);
            ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin);
            arp.setDialect(new SqlServerDialect());
            _MappingKit.mapping(arp);
            druidPlugin.start();
            arp.start();
            UserMenu dao = new UserMenu().dao();
            List<Menu> userlist = userDao.find("select * from t_menu");
            Date time = new Date();
            int i= 0;
            for(Menu menu :userlist){i++;
                UserMenu bean = new UserMenu();
                bean.setCreatetime(time).setMenuid(menu.getId()).setOperatorid(1).setUserid(1484).save();
                System.out.println(i);
            }
            System.out.println(" is end");
        }catch(Exception e){
            e.printStackTrace();
        }
    }



}
