1.使用SpringMVC方式开发用户信息
1.增加controller层、dao层、service层
在service层增加UserModel
public class UserModel {
private Integer id;
private String name;
private Byte gender;
private Integer age;
private String telphone;
private String regisitMode;
private Integer thirdPartyId;
private String encrptPassword;
}
UserModel需要增加 用户的密码,其通过userPasswordDOMapper从userPasswordDO得到。。。
2创建UserController
@Controller("user")
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService;
@RequestMapping("/get")
@ResponseBody
public UserModel getUser(@RequestParam(name = "id") Integer id) {
//调用service服务获取对应id的用户对象并返回给前端
UserModel userModel = userService.getUserById(id);
return userModel;
}
}
3.修改userPasswordDOMapper.xml和.java文件
增加方法 selectByUserId
<select id="selectByUserId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from user_password
where user_id = #{userId,jdbcType=INTEGER}
</select>
userPasswordDO selectByUserId(Integer UserId);
4.编写UserService
@Service
public class UserServiceImpl implements UserService {
@Autowired
private UserDOMapper userDOMapper;
@Autowired
private userPasswordDOMapper userPasswordDOMapper;
@