1. package com.kuankuan.lottery.infrastructure.config;
    2. import com.kuankuan.lottery.infrastructure.injector.EasySqlInjector;
    3. import org.springframework.context.annotation.Bean;
    4. import org.springframework.context.annotation.Configuration;
    5. /**
    6. * @author 宽宽
    7. * @Description: 增加 plus 配置插件
    8. * @Date: 2022/1/16 13:54
    9. * @Version: 1.0
    10. */
    11. @Configuration
    12. public class MybatisPlusConfig {
    13. @Bean
    14. public EasySqlInjector easySqlInjector() {
    15. return new EasySqlInjector();
    16. }
    17. }

    image.png

    1. package com.kuankuan.lottery.infrastructure.injector;
    2. import com.baomidou.mybatisplus.core.injector.AbstractMethod;
    3. import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
    4. import com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn;
    5. import java.util.List;
    6. /**
    7. * @author 宽宽
    8. * @Description: MybatisPlus 扩展
    9. * @Date: 2022/1/16 13:57
    10. * @Version: 1.0
    11. */
    12. public class EasySqlInjector extends DefaultSqlInjector {
    13. @Override
    14. public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
    15. // 仅支持mysql
    16. List<AbstractMethod> methodList = super.getMethodList(mapperClass);
    17. // 添加InsertBatchSomeColumn方法
    18. methodList.add(new InsertBatchSomeColumn());
    19. return methodList;
    20. }
    21. }

    image.png

    1. package com.kuankuan.lottery.infrastructure.dao;
    2. import com.baomidou.mybatisplus.core.mapper.BaseMapper;
    3. import com.kuankuan.lottery.infrastructure.po.AwardEntity;
    4. import java.util.Collection;
    5. /**
    6. * 奖品配置(Award)表数据库访问层
    7. *
    8. * @author makejava
    9. * @since 2022-01-07 11:48:10
    10. */
    11. public interface IAwardDao extends BaseMapper<AwardEntity> {
    12. /**
    13. * 批量插入(mysql)
    14. *
    15. * @param entityList 奖品配置集合
    16. * @return 成功条数
    17. */
    18. int insertBatchSomeColumn(Collection<AwardEntity> entityList);
    19. }

    image.png