|
|
/*
|
|
|
* Copyright (c) 2019. 黄钰朝
|
|
|
*
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
* You may obtain a copy of the License at
|
|
|
*
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
*
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
* See the License for the specific language governing permissions and
|
|
|
* limitations under the License.
|
|
|
*/
|
|
|
|
|
|
package com.hyc.wechat.test;
|
|
|
|
|
|
import com.hyc.wechat.dao.MessageDao;
|
|
|
import com.hyc.wechat.dao.UserDao;
|
|
|
import com.hyc.wechat.factory.DaoProxyFactory;
|
|
|
import com.hyc.wechat.model.po.Message;
|
|
|
import com.hyc.wechat.model.po.User;
|
|
|
|
|
|
/**
|
|
|
* @author <a href="mailto:kobe524348@gmail.com">黄钰朝</a>
|
|
|
* @program wechat
|
|
|
* @description 测试SQLHandler,用于验证数据库操作是否正常工作
|
|
|
* @date 2019-05-01 17:50
|
|
|
*/
|
|
|
public class TestDao {
|
|
|
public static void main(String[] args) {
|
|
|
// 通过DaoProxyFactory获取MessageDao的代理实例
|
|
|
MessageDao messageDao = (MessageDao) DaoProxyFactory.getInstance().getProxyInstance(MessageDao.class);
|
|
|
|
|
|
// 以下是注释掉的代码,可能用于之前的测试或示例
|
|
|
// 通过DaoProxyFactory获取RecordDao的代理实例
|
|
|
// RecordDao recordDao = (RecordDao) DaoProxyFactory.getInstance().getProxyInstance(RecordDao.class);
|
|
|
// 删除聊天中的所有记录
|
|
|
// recordDao.deleteAllRecordInChat(210,59);
|
|
|
// 创建一个新用户并插入到数据库
|
|
|
// User user = new User();
|
|
|
// user.setName("testasdf中文");
|
|
|
// userDao.insert(user);
|
|
|
// 打印最后插入的用户ID
|
|
|
// System.out.println(userDao.getLastInsert().getId());
|
|
|
// 通过ID获取用户
|
|
|
// user = userDao.getUserById("50");
|
|
|
// 模糊查询用户名并打印查询到的记录数
|
|
|
// List list = userDao.listLikeName("%昵称%");
|
|
|
// System.out.println("查询到记录:" + list.size() + "条");
|
|
|
// 通过DaoProxyFactory获取ChatDao的代理实例
|
|
|
// ChatDao chatDao = (ChatDao) DaoProxyFactory.getInstance().getProxyInstance(ChatDao.class);
|
|
|
// 将聊天转换为好友聊天
|
|
|
// chatDao.toFriendChat("4", "123");
|
|
|
// 创建一条朋友圈动态并插入到数据库
|
|
|
// Moment moment = new Moment();
|
|
|
// moment.setOwnerId(BigInteger.valueOf(0));
|
|
|
// moment.setContent("一条朋友圈");
|
|
|
// moment.setLove(10L);
|
|
|
// 通过DaoProxyFactory获取MomentDao的代理实例
|
|
|
// MomentDao momentDao = (MomentDao) DaoProxyFactory.getInstance().getProxyInstance(MomentDao.class);
|
|
|
// momentDao.insert(moment);
|
|
|
// 查询用户在聊天中的消息
|
|
|
// messageDao.listMessageByUserIdAndChatId("0","0",10,1000);
|
|
|
|
|
|
// 创建一个News对象,但未使用
|
|
|
// News news = new News();
|
|
|
}
|
|
|
}
|