UserBean实体类
package com.example.springbootdemo.bean;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class UserBean {
private String user_name;
private String user_password;
private String user_phone;
public UserBean(String user_name, String user_phone, String user_password) {
this.user_name = user_name;
this.user_password = user_password;
this.user_phone = user_phone;
}
}
UserService业务接口
package com.example.springbootdemo.service;
import com.example.springbootdemo.bean.UserBean;
public interface UserService {
UserBean getUserByName(String name);
void addUser(UserBean userBean);
void modifyUser(String oldPassword, String newPassword);
void delUser(String username, String password);
}
UserServiceImpl实现层
package com.example.springbootdemo.service.impl;
import com.example.springbootdemo.bean.UserBean;
import com.example.springbootdemo.mapper.UserMapper;
import com.example.springbootdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service("UserService")
public class UserServiceImpl implements UserService {
@Autowired(required = false)
public UserMapper userMapper;
@Override
public UserBean getUserByName(String name) {
return userMapper.getUserByName(name);
}
@Override
public void addUser(UserBean userBean) {
userMapper.addUser(userBean);
}
@Override
public void modifyUser(String oldPassword, String newPassword) {
userMapper.modifyUser(oldPassword, newPassword);
}
@Override
public void delUser(String username, String password) {
userMapper.delUser(username, password);
}
}
Mapper层
package com.example.springbootdemo.mapper;
import com.example.springbootdemo.bean.UserBean;
import org.apache.ibatis.annotations.*;
public interface UserMapper {
@Select("Select * from t_dev_user Where user_name&#