TienChin 渠道管理-渠道导入
1.TienChin 开篇-运行 RuoYiVue2.TienChin 代码格式化-项目结构大改造3.TienChin 项目改造完善&项目结构分析4.TienChin 验证码响应结果分析&验证码生成接口分析5.TienChin 运行 RuoYi-Vue36.TienChin-系统功能介绍7.TienChin 新建业务菜单8.TienChin 创建菜单页面9.TienChin 引入 MyBatisPlus10.TienChin 渠道管理-表创建11.TienChin 渠道管理-渠道类型12.TienChin 渠道管理-工程创建13.TienChin 渠道管理-查看渠道接口14.TienChin 渠道管理-前端展示渠道信息15.TienChin 渠道管理-配置字典常量16.TienChin 渠道管理-字典原理分析17.TienChin 渠道管理-权限分配18.TienChin 渠道管理-添加渠道19.TienChin 渠道管理-配置校验失败信息20.TienChin 渠道管理-添加渠道页面开发21.TienChin 渠道管理-更新渠道接口开发22.TienChin 渠道管理-删除渠道23.TienChin 渠道管理-渠道搜索24.TienChin 渠道管理-渠道导出
25.TienChin 渠道管理-渠道导入
26.TienChin 渠道管理-渠道页面完善27.TienChin 活动管理-准备工作28.TienChin 活动管理-工程创建29.TienChin 活动管理-活动列表展示30.TienChin 活动管理-活动状态完善31.TienChin 活动管理-添加活动页面32.TienChin 活动管理-添加活动接口33.TienChin 活动管理-设置活动的默认状态34.TienChin 活动管理-完成添加活动35.TienChin 活动管理-修改活动接口36.TienChin 活动管理-修改活动37.TienChin 活动管理-删除活动38.TienChin 活动管理-搜索活动39.TienChin 活动管理-活动导出40.TienChin-课程管理-数据表创建41.TienChin-课程管理-创建工程42.TienChin-课程管理-配置课程字典43.TienChin-课程管理-展示课程列表44.TienChin-课程管理-添加课程接口45.TienChin-课程管理-添加课程页面46.TienChin-课程管理-课程更新接口47.TienChin-课程管理-删除课程48.TienChin-课程管理-课程搜索49.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 方法:
...
else if (cs[i] == Byte.class) {
args[i] = Convert.toByte(args[i]);
}
...
配置 MySQL 批量插入
# 批量插入
&rewriteBatchedStatements=true
配置在 MySQL 的连接地址后面即可:
因为 MyBatisPlus 当中的批量插入,并没有达到我的预料效果,所以我们需要进行配置,配置方式如上。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· 写一个简单的SQL生成工具