MybatisPlus相关接口

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

 /**
     * 分页插件
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

一、MybatisPlus

AUTO(0), // 数据库id自增

NONE(1), // 未设置主键

INPUT(2), // 手动输入

ID_WORKER(3), // 默认的方式,全局唯一id

UUID(4), // 全局唯一id uuid

ID_WORKER_STR(5); //ID_WORKER 字符串表示法

* AUTO:自动增长 *

ID_WORKER:mp自带策略,生成19位值,主键是数字类型时,使用这种策略 *

ID_WORKER_STR:mp自带策略,生成19位值,主键是String类型时,使用这种策略 *

INPUT:自己手动设置id *

NONE:手动设置 *

UUID:使用uuid随机生成唯一值

二、参数

原符号       <        <=      >       >=       &        '        "
替换符号    &lt;    &lt;=   &gt;    &gt;=   &amp;   &apos;  &quot;

四、

QueryWrapper<User> wrapper = new QueryWrapper<>();

五、模糊查询

Wrappers.<KnowType>lambdaQuery().like(KnowType::getName,name)

六、IN查询

UpdateWrapper<KnowType> wrapper = Wrappers.update();
wrapper.in(KnowType.COL_PARENT_ID,ids);

七配置

spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url= jdbc:mysql://ip:3306/数据库名?allowMultiQueries=true&characterEncoding=utf8&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
spring.datasource.username=账号
spring.datasource.password=密码
spring.datasource.hikari.maximum-pool-size=12
spring.datasource.hikari.connection-timeout=200000
spring.datasource.hikari.minimum-idle=10
spring.datasource.hikari.idle-timeout=500000
spring.datasource.hikari.max-lifetime=540000

swagger.title=知识库管理服务接口文档
swagger.description=知识库服务接口文档
swagger.base-package=com.shiyou.kbm.controller

#对以下URL进行放行,不拦截



spring.main.allow-bean-definition-overriding=true
security.oauth2.client.client-id=development
security.oauth2.client.client-secret=development
security.oauth2.client.scope=server


#热部署
spring.devtools.restart.enabled= true  
# 配置mapper的扫描,找到所有的mapper.xml映射文件
mybatis-plus.mapper-locations= classpath*:mapper/*Mapper.xml 
mybatis-plus.global-config.banner= false


# 全局映射器启用缓存
mybatis-plus.configuration.cache-enabled=true
# 查询时,关闭关联对象即时加载以提高性能
mybatis-plus.configuration.lazy-loading-enabled=false
#对于未知的SQL查询,允许返回不同的结果集以达到通用的效果
mybatis-plus.configuration.multiple-result-sets-enabled=true
#许使用列标签代替列名
mybatis-plus.configuration.use-column-label=true
#不允许使用自定义的主键值(比如由程序生成的UUID 32位编码作为键值),数据表的PK生成策略将被覆盖
mybatis-plus.configuration.use-generated-keys=false
#给予被嵌套的resultMap以字段-属性的映射支持 FULL,PARTIAL
mybatis-plus.configuration.auto-mapping-behavior=PARTIAL
#配置默认的执行器。SIMPLE 执行器没有什么特别之处。REUSE 执行器重用预处理语句。BATCH 执行器重用语句和批量更新
mybatis-plus.configuration.default-executor-type=REUSE
#不更新值为null
mybatis-plus.global-config.db-config.field-strategy=not_null
#全局唯一ID
mybatis-plus.global-config.db-config.id-type=NONE
#Allows using RowBounds on nested statements
mybatis-plus.configuration.safe-row-bounds-enabled=false
#Enables automatic mapping from classic database column names A_COLUMN 
#			to camel case classic Java property names aColumn. 
mybatis-plus.configuration.map-underscore-to-camel-case=true
#MyBatis uses local cache to prevent circular references and speed 
#			up repeated nested queries. By default (SESSION) all queries executed during 
#			a session are cached. If localCacheScope=STATEMENT local session will be 
#			used just for statement execution, no data will be shared between two different 
#			calls to the same SqlSession.
mybatis-plus.configuration.local-cache-scope=SESSION
#Specifies the JDBC type for null values when no specific JDBC type 
#			was provided for the parameter. Some drivers require specifying the column 
#			JDBC type but others work with generic values like NULL, VARCHAR or OTHER.
mybatis-plus.configuration.jdbc-type-for-null=OTHER
#Specifies which Object's methods trigger a lazy load 
mybatis-plus.configuration.lazy-load-trigger-methods=equals,clone,hashCode,toString
#设置关联对象加载的形态,此处为按需加载字段(加载字段由SQL指 定),不会加载关联表的所有字段,以提高性能 
mybatis-plus.configuration.aggressive-lazy-loading=true
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
#mybatis分页查询
pagehelper.helper-dialect=mysql
<resultMap id="userMap" type="xxx.entity.User">
        <id column="id" property="id"/>
        <result column="username" property="username"/>
        <result column="password" property="password"/>
        <result column="nick_name" property="nickName"/>
        <result column="real_name" property="realName"/>
        <result column="avatar" property="avatar"/>
        <result column="sex" property="sex"/>
        <result column="phone" property="phone"/>
        <result column="email" property="email"/>
        <result column="state" property="state"/>
        <result column="create_date" property="createDate"/>
        <result column="update_date" property="updateDate"/>
        <result column="company_id" property="companyId"/>
        <result column="company_name" property="companyName"/>
        <result column="office_id" property="officeId"/>
        <result column="office_name" property="officeName"/>

        <collection property="roles" ofType="xxx.entity.Role"
                    javaType="java.util.List" select="getRoleInfo" column="id">
<!-- {cityId=city_id,adr=addressCol, dis=districtCol}-->
        </collection>
    </resultMap>

    <resultMap id="roles" type="xxx.entity.Role">
        <id column="role_id" property="id"/>
        <result column="role_name" property="roleName"/>
    </resultMap>

<select id="getRoleInfo" parameterType="java.lang.String" resultMap="roles">
        select b.role_id, c.role_name
        from user_role b
        join role c on (b.role_id = c.id)
        where b.user_id = #{id}
</select>
    
<select id="listByPage" resultMap="userMap" parameterType="xxx.ReqParam">
        select a.*
        from user a
        <trim prefix="WHERE" prefixOverrides="AND|OR">
            <if test="searchKey != null and searchKey != '' and searchValue != null and searchValue != ''">
                AND a.${searchKey} like concat('%',#{searchValue},'%')
            </if>
        </trim>
        order by a.create_date
</select>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值