List<CustomerService> customerlist = customerService.selectByExample(customerexample);
//如果在customer_service 表有用户的信息,则返回提示
System.out.println("cus:" + (null == customerlist)); // 如果没有查出数据,customerlist 也不是 null, 可用 isEmpty() 函数判断,输出: cus:false
if (!customerlist.isEmpty()) {
return new JsonResult(false,"该手机号已经是客服号");
}
mysql 数据类型 java
bigint(20) jdbcType="BIGINT"
enum('0','1') jdbcType="CHAR"
timestamp jdbcType="TIMESTAMP"
text jdbcType="VARCHAR"
char(1) jdbcType="VARCHAR"
smallint(6) jdbcType="BIGINT"
二:建表:
CREATE TABLE `user` (
`user_id` bigint(10) NOT NULL AUTO_INCREMENT COMMENT '用户Id',
`name` varchar(40) DEFAULT NULL COMMENT '姓名',
`password` varchar(30) DEFAULT NULL COMMENT '密码',
`age` bigint(10) DEFAULT NULL COMMENT '年龄',
`deleteFlag` enum('0','1') DEFAULT '0' COMMENT '状态',
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=utf8mb4
创建User对象:
private Long user_id;
private String name;
private String password;
private Long age;
private String deleteFlag;
删除表记录的语句:
User user = new User();
user.setUser_id(4L);
int f = userMapper.deleteUser(user);
<!-- 对应userDao中的deleteUser 方法 -->
<delete id="deleteUser" parameterType="com.dy.entity.User">
delete from user where user_id like CONCAT('%', #{user_id}, '%');
</delete>
如果表中 user_id 有 4 这个数字的有5条记录。删除语句如下:
2018-08-15 18:13:31 [ main:399 ] - [ DEBUG ] ==> Preparing: delete from user where user_id like CONCAT('%', ?, '%');
2018-08-15 18:13:31 [ main:439 ] - [ DEBUG ] ==> Parameters: 4(Long)
2018-08-15 18:13:31 [ main:499 ] - [ DEBUG ] <== Updates: 5
返回的 f 值是 5 。