优化标签处理

master
elliott 2 years ago
parent 624fc87942
commit ef01587e55

@ -1,13 +1,22 @@
package com.flossom.system.service.impl;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import com.flossom.common.core.domain.entity.SysTag;
import com.flossom.common.core.domain.entity.WxScriptTag;
import com.flossom.common.core.domain.entity.WxScriptTemplate;
import com.flossom.common.core.mapper.SysTagMapper;
import com.flossom.common.core.mapper.WxScriptTagMapper;
import com.flossom.common.core.mapper.WxScriptTemplateMapper;
import com.flossom.common.core.utils.DateUtils;
import com.flossom.common.core.utils.StringUtils;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.flossom.system.service.IWxScriptTagService;
import org.springframework.util.CollectionUtils;
/**
* Service
@ -20,6 +29,10 @@ public class WxScriptTagServiceImpl implements IWxScriptTagService
{
@Autowired
private WxScriptTagMapper wxScriptTagMapper;
@Autowired
private WxScriptTemplateMapper wxScriptTemplateMapper;
@Autowired
private SysTagMapper sysTagMapper;
/**
*
@ -97,6 +110,47 @@ public class WxScriptTagServiceImpl implements IWxScriptTagService
@Override
public int deleteWxScriptTagByTagId(Long tagId) {
// 先找出来,符合的所有标签
WxScriptTag tag = new WxScriptTag();
tag.setTagId(tagId);
List<WxScriptTag> wxScriptTags = wxScriptTagMapper.selectWxScriptTagList(tag);
// 开始组装新的数据以及更新源数据
if (!CollectionUtils.isEmpty(wxScriptTags)) {
for (WxScriptTag wxScriptTag: wxScriptTags) {
Long scriptId = wxScriptTag.getScriptId();
// 话术模板
WxScriptTemplate wxScriptTemplate = wxScriptTemplateMapper.selectWxScriptTemplateById(scriptId);
if (Objects.nonNull(wxScriptTemplate)) {
WxScriptTag tagsVO = new WxScriptTag();
tagsVO.setScriptId(scriptId);
// 反查得到所有的标签
List<WxScriptTag> wxScriptTotalTags = wxScriptTagMapper.selectWxScriptTagList(tagsVO);
// 过滤删除的标签
if (!CollectionUtils.isEmpty(wxScriptTotalTags)) {
// 获取过滤后的标签的信息
List<WxScriptTag> collectList = wxScriptTotalTags.stream().filter(x -> !String.valueOf(x.getTagId()).equals(String.valueOf(tagId))).collect(Collectors.toList());
List<SysTag> createSysTagList = Lists.newArrayList();
if (!CollectionUtils.isEmpty(collectList)) {
for (WxScriptTag scriptTag : collectList) {
SysTag sysTag = sysTagMapper.selectDeptById(scriptTag.getTagId());
if (Objects.nonNull(sysTag)) {
createSysTagList.add(sysTag);
}
}
}
if (!CollectionUtils.isEmpty(createSysTagList)) {
String tagNames = createSysTagList.stream().map(SysTag::getTagName).collect(Collectors.joining(","));
wxScriptTemplate.setTagNames(tagNames);
List<Long> resultList = createSysTagList.stream().map(SysTag::getId).collect(Collectors.toList());
String ids = StringUtils.join(resultList, ",");
wxScriptTemplate.setTagIds(ids);
wxScriptTemplateMapper.updateWxScriptTemplate(wxScriptTemplate);
}
}
}
}
}
return wxScriptTagMapper.deleteWxScriptTagByTagId(tagId);
}
}

@ -290,7 +290,7 @@
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel"> </el-button>
<el-button @click="reset"> </el-button>
<el-button type="primary" @click="submitForm"> </el-button>
</div>
</el-dialog>
@ -369,7 +369,7 @@ export default {
{ required: true, message: "跳转参数不能为空", trigger: "blur" }
],
redirectUrl: [
{ required: true, message: "页面链接不能为空", trigger: "blur" }
{ required: true, message: "小程序页面不能为空", trigger: "blur" }
],
videoNo: [
{ required: true, message: "视频号ID不能为空", trigger: "blur" }

@ -175,8 +175,8 @@
</el-form-item>
</el-col>
<el-col :span="24" v-if="form.parentId != 0 && form.type == 4" label-width="90px">
<el-form-item label="页面链接" prop="redirectUrl">
<el-input v-model="form.redirectUrl" placeholder="请输入页面链接" />
<el-form-item label="小程序页面" prop="redirectUrl">
<el-input v-model="form.redirectUrl" placeholder="请输入小程序页面" />
</el-form-item>
</el-col>
<el-col :span="24" v-if="form.parentId != 0 && form.type == 5 || form.type == 6">
@ -265,7 +265,7 @@ export default {
{ required: true, message: "小程序appid不能为空", trigger: "blur" }
],
redirectUrl: [
{ required: true, message: "跳转URL不能为空", trigger: "blur" }
{ required: true, message: "小程序页面不能为空", trigger: "blur" }
],
videoNo: [
{ required: true, message: "视频号ID不能为空", trigger: "blur" }

@ -398,7 +398,7 @@
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
<el-button @click="reset"> </el-button>
</div>
</el-dialog>
</div>
@ -615,10 +615,10 @@ export default {
channelId: null,
machineName: null,
machineId: null,
userType: null,
userType: 2,
operate: null,
signNumber: null,
orderNumber: null,
orderNumber: 1000,
type: null,
link: null,
linkParams: null,
@ -653,7 +653,7 @@ export default {
handleAdd() {
this.reset();
this.open = true;
this.title = "添加站点管理";
this.title = "添加轮播图";
this.form.orderNumber = 1000;
this.form.userType = 2;
},

@ -398,7 +398,7 @@
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
<el-button @click="reset"> </el-button>
</div>
</el-dialog>
</div>
@ -611,7 +611,7 @@ export default {
userType: null,
operate: null,
signNumber: null,
orderNumber: null,
orderNumber: 1000,
type: null,
link: null,
linkParams: null,

Loading…
Cancel
Save