Skip to content

Commit 74447fb

Browse files
committed
fix cast bug
1 parent 668a8d8 commit 74447fb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

spring-boot-restful-api/src/main/java/com/example/service/impl/UserServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public SysUser queryUserById(String userId) {
6060
e.printStackTrace();
6161
}
6262

63-
return userMapper.selectByPrimaryKey(userId);
63+
return userMapper.selectByPrimaryKey(Integer.parseInt(userId));
6464
}
6565

6666
@Override

spring-boot-restful-api/src/test/java/com/example/SpringBootRestfulApiApplicationTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package com.example;
22

3+
import com.alibaba.fastjson.JSON;
34
import com.example.dao.SysRoleMapper;
5+
import com.example.dao.SysUserMapper;
46
import com.example.entity.SysRole;
7+
import com.example.entity.SysUser;
58
import lombok.extern.slf4j.Slf4j;
69
import org.junit.Test;
710
import org.junit.runner.RunWith;
@@ -18,6 +21,8 @@ public class SpringBootRestfulApiApplicationTests {
1821

1922
@Resource
2023
private SysRoleMapper sysRoleMapper;
24+
@Resource
25+
private SysUserMapper sysUserMapper;
2126

2227
@Test
2328
public void contextLoads() {
@@ -36,4 +41,10 @@ public void testSendMail(){
3641
log.error("错误", e);
3742
}
3843

44+
@Test
45+
public void testGetOne(){
46+
SysUser sysUser = sysUserMapper.selectByPrimaryKey(1);
47+
System.out.println(JSON.toJSONString(sysUser));
48+
}
49+
3950
}

0 commit comments

Comments
 (0)