Mybatis-plus簡單配置

.pom文件java

<!-- mybatis-plus -->
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.2.0</version>
</dependency>

 mybatis-plus配置spring

package com.example.baseproject.config;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisPlusConfig {
    @Bean
    public PaginationInterceptor paginationInterceptor(){
        return new PaginationInterceptor();
    }
}

 實體類mybatis

package com.example.baseproject.pojo;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import java.math.BigDecimal;

/**
 * 水果實體類
 */
@Data
@TableName(value="go_fruits",autoResultMap = true)
public class FruitsEntity extends Model<FruitsEntity> {
    /**
     * id
     */
    @TableId(type = IdType.INPUT)
    private Integer fId;
    /**
     * 水果類型
     */
    private String fType;
    /**
     * 水果名稱
     */
    //增長查詢條件
    @TableField(condition = SqlCondition.LIKE)
    private String fName;
    /**
     * 水果價格
     */
    private BigDecimal fPrice;
    /**
     * 菜單數量
     */
    private String fNum;
    /**
     * 刪除標識
     */
    @TableLogic
    @TableField(exist = false)
    private Integer delFlag;
    private String createTime;
}

serviceapp

package com.example.baseproject.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.example.baseproject.pojo.FruitsEntity;

public interface FruitsService extends IService<FruitsEntity> {

}

serviceImplui

package com.example.baseproject.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.baseproject.dao.FruitsMapper;
import com.example.baseproject.pojo.FruitsEntity;
import com.example.baseproject.service.FruitsService;
import org.springframework.stereotype.Service;

@Service
public class FruitsServiceImpl extends ServiceImpl<FruitsMapper, FruitsEntity> implements FruitsService {

}

 daospa

package com.example.baseproject.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.baseproject.pojo.FruitsEntity;

public interface FruitsMapper extends BaseMapper<FruitsEntity> {

}
相關文章
相關標籤/搜索