use of com.maxqiu.demo.entity.User in project demo-SpringBoot by Max-Qiu.
the class TestUser method updateById.
@Test
void updateById() {
// UPDATE smp_user SET username=? WHERE id=?
User user = new User();
user.setId(123L);
user.setUsername("11111111111");
boolean b = user.updateById();
System.out.println(b);
}
use of com.maxqiu.demo.entity.User in project demo-SpringBoot by Max-Qiu.
the class TestUser method selectOne.
@Test
void selectOne() {
// SELECT id,username,age,email FROM smp_user WHERE (age > ? AND age < ?)
LambdaQueryWrapper<User> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.gt(User::getAge, 50).lt(User::getAge, 100);
// 慎用!!!除非保证查询后的结果只有一条或者为空,否则会抛出异常 Expected one result (or null) to be returned by selectOne(), but found: 5
User user = new User().selectOne(queryWrapper);
System.out.println(user);
}
use of com.maxqiu.demo.entity.User in project demo-SpringBoot by Max-Qiu.
the class StringOperationsTest method get.
/**
* GET
*/
@Test
@Order(1)
void get() {
// 获取不存在的键
assertNull(stringValueOperations.get("nonexistent"));
// 获取String类型的数据
stringValueOperations.set("key", "hello");
assertEquals("hello", stringValueOperations.get("key"));
// 获取对象类型的数据
User user = new User(1, "tom", new BigDecimal(18));
userValueOperations.set("user", user);
assertEquals(user, userValueOperations.get("user"));
integerValueOperations.set("num", 1);
assertEquals(1, integerValueOperations.get("num"));
redisTemplate.delete(Arrays.asList("user", "key", "num"));
}
use of com.maxqiu.demo.entity.User in project demo-SpringBoot by Max-Qiu.
the class SetOperationsTest method type.
/**
* 测试不同类型
*/
@Test
@Order(2)
void type() {
// 对象类型
Long add = userSetOperations.add("users", new User(1, "tom", new BigDecimal(185)), new User(2, "tom", new BigDecimal(183)));
Long size = userSetOperations.size("users");
assertEquals(add, size);
// 数字类型
Long nums = integerSetOperations.add("nums", 1, 2, 3, 3);
assertEquals(3, nums);
// 删除数据
redisTemplate.delete(Arrays.asList("users", "nums"));
}
use of com.maxqiu.demo.entity.User in project demo-SpringBoot by Max-Qiu.
the class UserMapper2Test method addUser.
@Test
void addUser() {
for (int i = 0; i < 10; i++) {
User user = new User();
user.setUsername("TOM" + i);
user.setGroupId(i % 2);
user.setEmail(i + "xxx@xxx.com");
userMapper.insert(user);
}
}
Aggregations