Commit ca97baf5 by YaoYuHang

社群运营 - 群SOP - 空素材insert SQL问题修复

1 parent 1324ae2e
......@@ -42,14 +42,6 @@ public interface WeKeywordGroupTaskMapper extends BaseMapper<WeKeywordGroupTask>
WeKeywordGroupTaskVo getTaskById(Long taskId);
/**
* 根据id列表批量删除任务
*
* @param ids id列表
* @return 删除行数
*/
int batchRemoveTaskByIds(Long[] ids);
/**
* 根据任务id获取对应所有的群聊名称
*
* @param taskId 任务id
......
......@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.domain.WeKeywordGroupTaskKeyword;
import com.linkwechat.wecom.domain.WeKeywordGroupTask;
import com.linkwechat.wecom.domain.WeGroupCode;
......@@ -96,9 +97,13 @@ public class WeCommunityKeywordToGroupServiceImpl extends ServiceImpl<WeKeywordG
public int addTask(WeKeywordGroupTask task, String[] keywords) {
if(this.save(task)) {
// 构建关键词对象并存储
List<WeKeywordGroupTaskKeyword> weKeywordGroupTaskKeywordList = Arrays.stream(keywords)
.map(word -> new WeKeywordGroupTaskKeyword(task.getTaskId(), word)).collect(Collectors.toList());
taskKwMapper.batchBindsTaskKeyword(weKeywordGroupTaskKeywordList);
List<WeKeywordGroupTaskKeyword> taskKeywordList = Arrays
.stream(keywords)
.map(word -> new WeKeywordGroupTaskKeyword(task.getTaskId(), word))
.collect(Collectors.toList());
if (StringUtils.isNotEmpty(taskKeywordList)) {
taskKwMapper.batchBindsTaskKeyword(taskKeywordList);
}
return 1;
}
return 0;
......@@ -120,9 +125,13 @@ public class WeCommunityKeywordToGroupServiceImpl extends ServiceImpl<WeKeywordG
taskKwQueryWrapper.eq("task_id", task.getTaskId());
taskKwMapper.delete(taskKwQueryWrapper);
// 再重新插入新的关键词
List<WeKeywordGroupTaskKeyword> weKeywordGroupTaskKeywordList = Arrays.stream(keywords)
.map(word -> new WeKeywordGroupTaskKeyword(task.getTaskId(), word)).collect(Collectors.toList());
taskKwMapper.batchBindsTaskKeyword(weKeywordGroupTaskKeywordList);
List<WeKeywordGroupTaskKeyword> taskKeywordList = Arrays
.stream(keywords)
.map(word -> new WeKeywordGroupTaskKeyword(task.getTaskId(), word))
.collect(Collectors.toList());
if (StringUtils.isNotEmpty(taskKeywordList)) {
taskKwMapper.batchBindsTaskKeyword(taskKeywordList);
}
return 1;
}
return 0;
......@@ -141,7 +150,9 @@ public class WeCommunityKeywordToGroupServiceImpl extends ServiceImpl<WeKeywordG
QueryWrapper<WeKeywordGroupTaskKeyword> taskKwQueryWrapper = new QueryWrapper<>();
taskKwQueryWrapper.in("task_id", Arrays.asList(ids));
taskKwMapper.delete(taskKwQueryWrapper);
return taskMapper.batchRemoveTaskByIds(ids);
QueryWrapper<WeKeywordGroupTask> taskQueryWrapper = new QueryWrapper<>();
taskKwQueryWrapper.in("task_id", Arrays.asList(ids));
return taskMapper.delete(taskQueryWrapper);
}
/**
......
......@@ -80,19 +80,21 @@ public class WeGroupSopServiceImpl extends ServiceImpl<WeGroupSopMapper, WeGroup
* @param weGroupSop 新增所用数据
* @param groupIdList 选中的群聊id
* @param materialIdList 素材
* @param picList 手动上传的图片URL
* @param picUrlList 手动上传的图片URL
* @return 结果
*/
@Override
@Transactional
public int addGroupSop(WeGroupSop weGroupSop, List<String> groupIdList, List<Long> materialIdList, List<String> picList) {
public int addGroupSop(WeGroupSop weGroupSop, List<String> groupIdList, List<Long> materialIdList, List<String> picUrlList) {
if (this.save(weGroupSop)) {
Long ruleId = weGroupSop.getRuleId();
// 保存群聊及素材关联
this.saveChatAndMaterialBinds(ruleId, groupIdList, materialIdList);
// 保存手动上传的图片素材
List<WeGroupSopPic> sopPicList = picList.stream().map(e -> new WeGroupSopPic(ruleId, e)).collect(Collectors.toList());
List<WeGroupSopPic> sopPicList = picUrlList.stream().map(picUrl -> new WeGroupSopPic(ruleId, picUrl)).collect(Collectors.toList());
if (StringUtils.isNotEmpty(sopPicList)) {
sopPicMapper.batchSopPic(sopPicList);
}
return 1;
}
return 0;
......@@ -104,12 +106,12 @@ public class WeGroupSopServiceImpl extends ServiceImpl<WeGroupSopMapper, WeGroup
* @param weGroupSop 更新所用数据
* @param groupIdList 选中的群聊id
* @param materialIdList 素材
* @param picList 手动上传的图片URL
* @param picUrlList 手动上传的图片URL
* @return 结果
*/
@Override
@Transactional
public int updateGroupSop(WeGroupSop weGroupSop, List<String> groupIdList, List<Long> materialIdList, List<String> picList) {
public int updateGroupSop(WeGroupSop weGroupSop, List<String> groupIdList, List<Long> materialIdList, List<String> picUrlList) {
if (this.updateById(weGroupSop)) {
Long ruleId = weGroupSop.getRuleId();
// 先删除旧数据
......@@ -121,8 +123,10 @@ public class WeGroupSopServiceImpl extends ServiceImpl<WeGroupSopMapper, WeGroup
sopPicMapper.delete(queryWrapper.eq("rule_id", ruleId));
// 保留新上传的图片
List<WeGroupSopPic> sopPicList = picList.stream().map(e -> new WeGroupSopPic(ruleId, e)).collect(Collectors.toList());
List<WeGroupSopPic> sopPicList = picUrlList.stream().map(picUrl -> new WeGroupSopPic(ruleId, picUrl)).collect(Collectors.toList());
if (StringUtils.isNotEmpty(sopPicList)) {
sopPicMapper.batchSopPic(sopPicList);
}
return 1;
}
return 0;
......@@ -166,7 +170,6 @@ public class WeGroupSopServiceImpl extends ServiceImpl<WeGroupSopMapper, WeGroup
return groupSopMapper.isRuleNameUnique(ruleName) == 0;
}
/**
* 根据关联条件查询该sop所关联的群聊及素材对象,并将其放入WeGroupSopVo相应属性中用于前端使用
*
......@@ -241,7 +244,7 @@ public class WeGroupSopServiceImpl extends ServiceImpl<WeGroupSopMapper, WeGroup
QueryWrapper<WeGroupSopPic> picQueryWrapper = new QueryWrapper<>();
picQueryWrapper.eq("rule_id", ruleId);
List<WeGroupSopPic> sopPicList = sopPicMapper.selectList(picQueryWrapper);
List<String> picList = sopPicList.stream().map(WeGroupSopPic::getPicUrl).collect(Collectors.toList());
sopVo.setPicList(picList);
List<String> picUrlList = sopPicList.stream().map(WeGroupSopPic::getPicUrl).collect(Collectors.toList());
sopVo.setPicList(picUrlList);
}
}
......@@ -173,8 +173,6 @@ public class WePresTagGroupTaskServiceImpl extends ServiceImpl<WePresTagGroupTas
taskTagMapper.batchBindsTaskTags(wePresTagGroupTaskTagList);
}
// 更新范围
// 先解除旧的员工绑定信息
QueryWrapper<WePresTagGroupTaskScope> taskScopeQueryWrapper = new QueryWrapper<>();
taskScopeQueryWrapper.eq("task_id", taskId);
......
......@@ -69,13 +69,6 @@
WHERE wkg.task_id = #{taskId}
</select>
<delete id="batchRemoveTaskByIds">
delete from we_keyword_group where task_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="checkNameUnique" parameterType="String" resultType="int">
select count(1) from we_keyword_group where task_name = #{taskName}
</select>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!