package com.zr0701.service.Impl;import com.zr0701.bean.User;import com.zr0701.dao.UserDao;import com.zr0701.service.UserService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import java.util.List;
@Service
publicclassUserServiceImplimplementsUserService{
@Autowired
private UserDao userDao;
@Override
public User findById(Integer id){return userDao.findUserById(id);}
@Override
public boolean update(User user){
int upd = userDao.update(user);if(upd>0){returntrue;}else{returnfalse;}}
@Override
public List<User>searchByName(String name){return userDao.searchByName(name);}}
UserMapper.xml
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC"-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.zr0701.dao.UserDao"><select id="findUserById" parameterType="Integer" resultType="User">
select *from user where id =#{id}</select><update id="update" parameterType="User">
update user set name=#{name},password=#{password} where id=#{id}</update><select id="searchByName" parameterType="String" resultType="User">
select *from user where name like concat('%',#{name},'%');</select></mapper>