SpringBoot+mybatis 注解形式 实现简单注册、登陆、修改、删除

 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&#
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值