mybaits-plus 实现的查询操作

一 项目介绍

1.1 工程结构

mybaits-plus 实现的查询操作_第1张图片

 1.2  定义类结构

1.2.1 service层

package com.atguigu.mpdemo1010.service;

import com.atguigu.mpdemo1010.entity.User;
import com.baomidou.mybatisplus.extension.service.IService;

public interface UserService extends IService {
    User selectById(String id);
}

1.2.2 service层的实现层

package com.atguigu.mpdemo1010.service;

import com.atguigu.mpdemo1010.entity.User;
import com.atguigu.mpdemo1010.mapper.UserMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @ClassName: UserServiceImpl
 * @Description: TODO
 * @Author: admin
 * @Date: 2023/04/24 20:07:41 
 * @Version: V1.0
 **/
@Service
public class UserServiceImpl extends ServiceImpl implements UserService {
   public  User selectById(String id){
       User  u=new User();
       u.setName("ljf");
       u.setAge(34);
       u.setCreateTime(new Date());
      return  baseMapper.selectById(id);
      //  return u;
    }


}

1.2.3 mapper层

package com.atguigu.mpdemo1010.mapper;

import com.atguigu.mpdemo1010.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;

@Repository
public interface UserMapper extends BaseMapper {
}

1.2.4  测试

mybaits-plus 实现的查询操作_第2张图片

 

你可能感兴趣的:(mybaits,mybatis,java,spring)