首页 > 其他分享 >TienChin 渠道管理-渠道导入

TienChin 渠道管理-渠道导入

时间:2023-09-18 00:00:04浏览次数:30  
标签:updateSupport channelList 导入 渠道 boolean TienChin channel

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 方法:

img

...

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

...

配置 MySQL 批量插入

# 批量插入
&rewriteBatchedStatements=true

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

img

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

标签:updateSupport,channelList,导入,渠道,boolean,TienChin,channel
From: https://www.cnblogs.com/BNTang/p/17710280.html

相关文章

  • TienChin 渠道管理-渠道页面完善
    最后附上渠道管理的数据installSQL语句:INSERTINTOTienChin.tienchin_channel(channel_id,channel_name,status,remark,type,create_by,update_by,create_time,update_time,del_flag)VALUES(3,'小红书渠道',1,'小红书渠道',1,'qudao','qu......
  • TienChin 渠道管理-渠道搜索
    ChannelController@PreAuthorize("hasPermission('tienchin:channel:list')")@GetMapping("/list")TableDataInfolist(ChannelVOchannelVO){startPage();List<Channel>list=iChannelService.selectChannelList(channe......
  • TienChin 渠道管理-渠道导出
    ChannelController/***导出渠道列表*/@PreAuthorize("hasPermission('tienchin:channel:export')")@Log(title="渠道管理",businessType=BusinessType.EXPORT)@PostMapping("/export")publicvoidexport(HttpServletResponser......
  • TienChin 渠道管理-删除渠道
    更改一下菜单权限,将删除渠道的delete改为remove:ChannelController.java@PreAuthorize("hasPermission('tienchin:channel:remove')")@Log(title="渠道管理",businessType=BusinessType.DELETE)@DeleteMapping("/{channelIds}")AjaxResult......
  • TienChin 渠道管理-更新渠道接口开发
    ChannelController/***修改渠道*/@PreAuthorize("hasPermission('tienchin:channel:edit')")@Log(title="渠道管理",businessType=BusinessType.UPDATE)@PutMappingAjaxResultedit(@Validated@RequestBodyChannelVOchannelVO){......
  • OpenAI原生GPT问答记录直接导入博客方法
    OpenAI原生GPT问答记录直接导入博客方法一般常见的方法是截图放在博客,但是这种方法有点过于粗糙,浪费阅读者流量资源不说,还显得十分不专业。但是对于原生GPT来说,在网页内全选复制并不能达成我们想要的效果,甚至有时候很难区分哪些是用户哪些是AI的话。于是本篇文章应运而生,Openai......
  • tinymce编辑器导入docx、doc格式Word文档完整版
    看此文章之前需要注意一点在前端使用导入Word文档并自动解析成html再插入到tinymce编辑器中,在这里我使用的是mammoth.js识别Word内容,并set到编辑器中,使用mammoth只可解析.docx格式的Word,目前的mammoth不支持.doc格式,后续升级也许会加上解析doc的功能。为什么解析不了.doc.docx......
  • TienChin 渠道管理-配置校验失败信息
    新建ValidationMessages.properties:channel.name.notnull=渠道名称不能为空channel.type.notnull=渠道类型不能为空channel.status.notnull=渠道状态不能为空channel.type.invalid=渠道类型无效channel.status.invalid=渠道状态无效......
  • TinyMCE富文本编辑器导入word文件内容,使word文件上的的图文内容能正常显示图片
    今天在使用后台管理系统录入富文本数据时,发现从微信等APP上复制过来的图文内容直接粘贴到TinyMCE富文本编辑器上时图片可以正常显示,而从word上复制过来的图文内容,粘贴时只能显示文字,图片内容不能正常显示。查找问题后发现从微信上复制过来的是Base64图片,而从word上复制过来的图片......
  • TienChin 渠道管理-添加渠道
    在我们平时新建一个全新的Java类,这个类需要存放的包不存在,可以使用如下的方式进行创建:含义就是说,将ChannelVO这个类放在vo这个包当中,如果存在则不创建,存在就将新建的类放入其中。ChannelVO/***@authorBNTang*@version1.0*@description渠道管理,前端展示对象......