import java.sql.SQLException;
import org.b3log.latke.Latkes;
import org.b3log.latke.model.Role;
import org.b3log.latke.model.User;
import org.b3log.latke.repository.RepositoryException;
import org.b3log.latke.repository.Transaction;
import org.b3log.latke.repository.jdbc.JdbcTransaction;
import org.b3log.latke.util.MD5;
import org.b3log.solo.model.UserExt;
import org.b3log.solo.repository.UserRepository;
import org.b3log.solo.repository.impl.UserRepositoryImpl;
import org.b3log.solo.service.InitService;
import org.json.JSONObject;
public class testInitService {
/**
* @param args
* @throws RepositoryException
* @throws SQLException
*/
public static void main(String[] args) throws RepositoryException, SQLException {
// TODO Auto-generated method stub
Latkes.initRuntimeEnv();
//JdbcTransaction huiGun=new JdbcTransaction();
final JSONObject admin = new JSONObject();
UserRepository userRepository = UserRepositoryImpl.getInstance();
final Transaction transaction = userRepository.beginTransaction();
admin.put(User.USER_NAME, "obama");
admin.put(User.USER_EMAIL, "whitehouse@qq.com");
admin.put(User.USER_URL, Latkes.getServePath());
admin.put(User.USER_ROLE, Role.ADMIN_ROLE);
admin.put(User.USER_PASSWORD, "123");
admin.put(UserExt.USER_ARTICLE_COUNT, 0);
admin.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, 0);
userRepository.add(admin);
transaction.commit();
//InitService myMy=InitService.getInstance();
}
}
从后台给b3log的表插入记录
最新推荐文章于 2024-07-02 01:00:25 发布