@Override public User getUserInfo(User user) { UseruserInfo= userMapper.getUserInfo(user); return userInfo; }
mapper层:
1 2 3 4
@Mapper publicinterfaceUserMapper{ User getUserInfo(User User); }
mapper.xml:
1 2 3 4 5 6
<selectid="getUserInfo"parameterType="User"resultType="com.pojo.User"> select userId from users where userId=#{userId} and sex=#{sex}; </select>
Map传入
service层:
1 2 3 4 5
@Override public User getUserInfo(Map map) { Useruser= userMapper.getUserInfo(map); return user; }
mapper层:
1 2 3 4
@Mapper publicinterfaceUserMapper{ User getUserInfo(Map map); }
mapper.xml层:
1 2 3 4 5 6
<!--查询--> <selectid="getUserInfo"parameterType="Map"resultType="com.pojo.User"> select userId from users where userId=#{userId} and sex=#{sex}; </select>
注解@Param传入
service层:
1 2 3 4 5
@Override public User getUserInfo(User user,Integer age) { UseruserResult= userMapper.getUserInfo(user,age); return userResult; }
mapper层:
1 2 3 4
@Mapper publicinterfaceUserMapper{ User getUserInfo(@Param("userInfo") User user,@Param("age") Integer age); }
mapper.xml:
1 2 3 4 5 6
<!--查询--> <selectid="getUserInfo"resultType="com.pojo.User"> select userId from users where userId=#{userInfo.userId} and sex=#{userInfo.sex} and age=#{age}; </select>