TienChin 渠道管理-渠道导入

简介: TienChin 渠道管理-渠道导入

ChannelController

@PostMapping("/importTemplate")
void importTemplate(HttpServletResponse response) {
    ExcelUtil<Channel> util = new ExcelUtil<>(Channel.class);
    util.importTemplateExcel(response, "渠道数据");
}
@Log(title = "渠道管理", businessType = BusinessType.IMPORT)
@PreAuthorize("hasPermission('tienchin:channel:import')")
@PostMapping("/importData")
AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
    ExcelUtil<Channel> util = new ExcelUtil<>(Channel.class);
    List<Channel> channelList = util.importExcel(file.getInputStream());
    return AjaxResult.success(iChannelService.importChannel(channelList, updateSupport));
}

IChannelService

/**
 * 导入渠道数据
 *
 * @param channelList   渠道数据列表
 * @param updateSupport 是否更新支持,如果已存在,则进行更新数据
 * @return {@code boolean} {@code true} 导入成功 {@code false} 导入失败
 */
boolean importChannel(List<Channel> channelList, boolean updateSupport);

ChannelServiceImpl

@Override
@Transactional(rollbackFor = Exception.class)
public boolean importChannel(List<Channel> channelList, boolean updateSupport) {
    String username = SecurityUtils.getUsername();
    LocalDateTime currentTime = LocalDateTime.now();
    List<Channel> channels = channelList
            .stream()
            .peek(channel -> {
                if (updateSupport) {
                    channel.setUpdateBy(username);
                    channel.setUpdateTime(currentTime);
                } else {
                    channel.setCreateBy(username);
                    channel.setCreateTime(currentTime);
                    channel.setChannelId(null);
                }
            }).collect(Collectors.toList());
    if (updateSupport) {
        return updateBatchById(channels);
    } else {
        return saveBatch(channels);
    }
}

!> 修复若依框架导入数据 Byte 类型数据报错的问题


更改 ReflectUtils.java 中的 invokeMethodByName 方法:

2105804-20230917233341026-1413251200.png

...
else if (cs[i] == Byte.class) {
    args[i] = Convert.toByte(args[i]);
}
...

配置 MySQL 批量插入

# 批量插入
&rewriteBatchedStatements=true

配置在 MySQL 的连接地址后面即可:



因为 MyBatisPlus 当中的批量插入,并没有达到我的预料效果的批量插入,所以我们需要进行配置,配置方式如上。

目录
打赏
0
0
0
0
20
分享
相关文章
TienChin 渠道管理-渠道导出
TienChin 渠道管理-渠道导出
63 0
TienChin 渠道管理-渠道页面完善
TienChin 渠道管理-渠道页面完善
57 0
会员系统02--,后台管理系统,包含网站运营,统计分析,用户中心,财务管理,资金明细,系统管理,参数配置,后台管理系统可以观看配置资料,广告位的相关资料,客服工单最主要是客户反馈给我们的问题,登录统计
会员系统02--,后台管理系统,包含网站运营,统计分析,用户中心,财务管理,资金明细,系统管理,参数配置,后台管理系统可以观看配置资料,广告位的相关资料,客服工单最主要是客户反馈给我们的问题,登录统计
【易售小程序项目】私聊功能后端实现 (买家、卖家 沟通商品信息)【后端基于若依管理系统开发】
【易售小程序项目】私聊功能后端实现 (买家、卖家 沟通商品信息)【后端基于若依管理系统开发】
187 0
TienChin 渠道管理-前端展示渠道信息
TienChin 渠道管理-前端展示渠道信息
71 0
TienChin 渠道管理-前端展示渠道信息
【易售小程序项目】私聊功能uniapp界面实现 (买家、卖家 沟通商品信息)【后端基于若依管理系统开发】
【易售小程序项目】私聊功能uniapp界面实现 (买家、卖家 沟通商品信息)【后端基于若依管理系统开发】
212 0
会员管理系统实战开发教程03-会员管理功能
会员管理系统实战开发教程03-会员管理功能
TienChin 渠道管理-删除渠道
TienChin 渠道管理-删除渠道
69 0
TienChin 渠道管理-更新渠道接口开发
TienChin 渠道管理-更新渠道接口开发
96 0
TienChin 渠道管理-添加渠道
TienChin 渠道管理-添加渠道
86 0