主键自动增加(字符串)
mybatis中sql语句:
select MAX(CAST(userId as SIGNED INTEGER)) from user
service中语句:
// 确定用户id public String getUser(){ // 查询用户数量 int num = userMapper.userCount(); // 初始化用户id String userId = "1"; // 当数据库中用户存在时 if(num != 0){ int num1 = userMapper.userIdMax(); int userId1 = Integer.parseInt(userId)+num1; userId = Integer.toString(userId1); } return userId; }