提交 55d3c117 编写于 作者: 孙喜旺

标签相关接口及方法修改,统一拦截批量新增方法

上级 d622ac7e
......@@ -67,11 +67,10 @@ public class WeTagGroupController extends BaseController
{
//校验标签组名称与标签名称是否相同
if(StrUtil.isNotBlank(weTagGroup.getGourpName())){
if(StrUtil.isNotBlank(weTagGroup.getGroupName())){
List<WeTag> weTags = weTagGroup.getWeTags();
if(CollectionUtil.isNotEmpty(weTags)){
if(weTags.stream().filter(m -> m.getName().equals(weTagGroup.getGourpName())).findAny().isPresent()){
if(weTags.stream().anyMatch(m -> m.getName().equals(weTagGroup.getGroupName()))){
return AjaxResult.error("标签组名称与标签名不可重复");
}
......
......@@ -16,7 +16,7 @@ export default {
dialogVisible: false,
// 表单参数
form: {
gourpName: '',
groupName: '',
weTags: [],
},
// 添加标签输入框
......@@ -25,7 +25,7 @@ export default {
newInputVisible: false,
// 表单验证规则
rules: Object.freeze({
gourpName: [{ required: true, message: '必填项', trigger: 'blur' }],
groupName: [{ required: true, message: '必填项', trigger: 'blur' }],
}),
// 选中数组
ids: [],
......@@ -135,7 +135,7 @@ export default {
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="标签组" align="center" prop="gourpName" />
<el-table-column label="标签组" align="center" prop="groupName" />
<el-table-column label="标签" align="center" prop="weTags">
<template slot-scope="scope">
<el-tag
......
......@@ -8,6 +8,7 @@ import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import java.util.Collection;
import java.util.Date;
......@@ -21,11 +22,11 @@ import java.util.Iterator;
public class InsertAndUpdateAspect {
@Pointcut("execution(public * com.linkwechat.wecom.mapper.*Mapper.insert*(..)))")
@Pointcut("execution( * com.linkwechat.wecom.mapper.*Mapper.insert*(..)))")
public void executeInsert() {
}
@Pointcut("execution(public * com.linkwechat.wecom.mapper.*Mapper.update*(..)))")
@Pointcut("execution( * com.linkwechat.wecom.mapper.*Mapper.update*(..)))")
public void executeUpdate() {
}
......@@ -38,9 +39,7 @@ public class InsertAndUpdateAspect {
Object arg = args[i];
if (arg instanceof Collection){
Collection collection = (Collection)arg;
Iterator iterator = collection.iterator();
if (iterator.hasNext()){
Object next = iterator.next();
for (Object next : collection) {
isInsertBaseEntity(next);
}
}
......@@ -74,9 +73,7 @@ public class InsertAndUpdateAspect {
Object arg = args[i];
if (arg instanceof Collection){
Collection collection = (Collection)arg;
Iterator iterator = collection.iterator();
if (iterator.hasNext()){
Object next = iterator.next();
for (Object next : collection) {
if (next instanceof BaseEntity) {
BaseEntity next1 = (BaseEntity) next;
next1.setUpdateBy(SecurityUtils.getUsername());
......
......@@ -49,7 +49,7 @@ public class WeTagGroup extends BaseEntity
@ApiModelProperty(value = "分组名称")
@TableField("group_name")
private String gourpName;
private String groupName;
@ApiModelProperty(value = "状态(0正常 1删除)")
@TableField("del_flag")
......
......@@ -39,7 +39,7 @@ public class WeCropGroupTagDto {
public static WeCropGroupTagDto transformAddTag(WeTagGroup weTagGroup){
WeCropGroupTagDto weCropGroupTagDto=WeCropGroupTagDto.builder()
.group_id(weTagGroup.getGroupId())
.group_name(weTagGroup.getGourpName())
.group_name(weTagGroup.getGroupName())
.build();
List<WeTag> weTags = weTagGroup.getWeTags();
if(CollectionUtil.isNotEmpty(weTags)){
......
......@@ -30,7 +30,7 @@ public class WeTagGroupVo {
* 分组名称
*/
@ApiModelProperty("分组名称")
private String gourpName;
private String groupName;
/** 创建时间 */
......
......@@ -22,7 +22,7 @@ public interface WeCustomerMapper extends BaseMapper<WeCustomer>
* 批量新增
* @param customerList
*/
void saveBatch(@Param("weCustomerList") List<WeCustomer> customerList);
void insertBatch(@Param("weCustomerList") List<WeCustomer> customerList);
/**
* 查询id企业微信客户
......
......@@ -85,11 +85,11 @@ public interface WeFlowerCustomerRelMapper extends BaseMapper<WeFlowerCustomerRe
* @param weFlowerCustomerRel
* @return
*/
public List<Map<String,Object>> getUserAddCustomerStat(WeFlowerCustomerRel weFlowerCustomerRel);
public List<Map<String,Object>> getUserAddCustomerStat(@Param("weFlowerCustomerRel") WeFlowerCustomerRel weFlowerCustomerRel);
/**
* 批量新增
* @param customerRelList
*/
void saveBatch(@Param("customerRelList") List<WeFlowerCustomerRel> customerRelList);
void insertBatch(@Param("customerRelList") List<WeFlowerCustomerRel> customerRelList);
}
......@@ -70,5 +70,5 @@ public interface WeFlowerCustomerTagRelMapper extends BaseMapper<WeFlowerCustom
*/
public int batchInsetWeFlowerCustomerTagRel(List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels);
public void saveBatch(@Param("weFlowerCustomerTagRels") List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels);
public void insertBatch(@Param("weFlowerCustomerTagRels") List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels);
}
......@@ -29,7 +29,7 @@ public interface WeTagGroupMapper extends BaseMapper<WeTagGroup>
* @param weTagGroups
* @return
*/
public void insetWeTagGroupBatch(@Param("weTagGroups") List<WeTagGroup> weTagGroups);
public void insertWeTagGroupBatch(@Param("weTagGroups") List<WeTagGroup> weTagGroups);
/**
......
......@@ -21,6 +21,6 @@ public interface WeTagMapper extends BaseMapper<WeTag>
* @param weTags
* @return
*/
public void insetWeTagBatch(List<WeTag> weTags);
public void insertWeTagBatch(@Param("weTags") List<WeTag> weTags);
}
......@@ -19,7 +19,7 @@ public interface IWeFlowerCustomerRelService extends IService<WeFlowerCustomerRe
* 批量新增
* @param customerRelList
*/
public void saveBatch(List<WeFlowerCustomerRel> customerRelList);
public void insertBatch(List<WeFlowerCustomerRel> customerRelList);
/**
* 删除服务跟进人
......
......@@ -76,5 +76,5 @@ public interface IWeFlowerCustomerTagRelService extends IService<WeFlowerCustome
* @param weFlowerCustomerTagRels
* @return
*/
public void saveBatch(List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels);
public void insertBatch(List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels);
}
......@@ -92,5 +92,5 @@ public interface IWeTagService extends IService<WeTag>
* @param weTagGroups
* @return
*/
public void insetWeTagBatch(List<WeTag> weTagGroups);
public void insertWeTagBatch(List<WeTag> weTagGroups);
}
......@@ -199,24 +199,20 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
.userId(userId)
.externalUserid(weCustomer.getExternalUserid())
.tagId(tagId)
.createTime(new Date())
.updateTime(new Date())
.createBy(StringUtils.isEmpty(SecurityUtils.getUsername())?"0":SecurityUtils.getUsername())
.updateBy(StringUtils.isEmpty(SecurityUtils.getUsername())?"0":SecurityUtils.getUsername())
.build());
});
}
});
if (CollectionUtil.isNotEmpty(customerList)) {
this.weCustomerMapper.saveBatch(customerList);
this.weCustomerMapper.insertBatch(customerList);
}
if (CollectionUtil.isNotEmpty(weFlowerCustomerRels)) {
iWeFlowerCustomerRelService.saveBatch(weFlowerCustomerRels);
iWeFlowerCustomerRelService.insertBatch(weFlowerCustomerRels);
}
if (CollectionUtil.isNotEmpty(weFlowerCustomerTagRels)) {
iWeFlowerCustomerTagRelService.saveBatch(weFlowerCustomerTagRels);
iWeFlowerCustomerTagRelService.insertBatch(weFlowerCustomerTagRels);
}
});
}
......@@ -481,24 +477,20 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
.userId(followUser.getUserid())
.externalUserid(externalUserid)
.tagId(tag.getTag_id())
.createTime(new Date())
.updateTime(new Date())
.createBy(StringUtils.isEmpty(SecurityUtils.getUsername())?"0":SecurityUtils.getUsername())
.updateBy(StringUtils.isEmpty(SecurityUtils.getUsername())?"0":SecurityUtils.getUsername())
.build());
});
}
});
if (CollectionUtil.isNotEmpty(customerList)) {
this.weCustomerMapper.saveBatch(customerList);
this.weCustomerMapper.insertBatch(customerList);
}
if (CollectionUtil.isNotEmpty(weFlowerCustomerRels)) {
iWeFlowerCustomerRelService.saveBatch(weFlowerCustomerRels);
iWeFlowerCustomerRelService.insertBatch(weFlowerCustomerRels);
}
if (CollectionUtil.isNotEmpty(weFlowerCustomerTagRels)) {
iWeFlowerCustomerTagRelService.saveBatch(weFlowerCustomerTagRels);
iWeFlowerCustomerTagRelService.insertBatch(weFlowerCustomerTagRels);
}
}
......
......@@ -25,8 +25,8 @@ public class WeFlowerCustomerRelServiceImpl extends ServiceImpl<WeFlowerCustomer
@Override
public void saveBatch(List<WeFlowerCustomerRel> customerRelList) {
this.baseMapper.saveBatch(customerRelList);
public void insertBatch(List<WeFlowerCustomerRel> customerRelList) {
this.baseMapper.insertBatch(customerRelList);
}
@Override
......
......@@ -106,7 +106,7 @@ public class WeFlowerCustomerTagRelServiceImpl extends ServiceImpl<WeFlowerCusto
}
@Override
public void saveBatch(List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels) {
weFlowerCustomerTagRelMapper.saveBatch(weFlowerCustomerTagRels);
public void insertBatch(List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels) {
weFlowerCustomerTagRelMapper.insertBatch(weFlowerCustomerTagRels);
}
}
......@@ -199,7 +199,7 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
tagGroups.forEach(tagGroup -> {
WeTagGroup weTagGroup = new WeTagGroup();
weTagGroup.setCreateBy(SecurityUtils.getUsername());
weTagGroup.setGourpName(tagGroup.getGroup_name());
weTagGroup.setGroupName(tagGroup.getGroup_name());
weTagGroup.setGroupId(tagGroup.getGroup_id());
List<WeCropTagDto> tags = tagGroup.getTag();
if (CollectionUtil.isNotEmpty(tags)) {
......@@ -227,7 +227,7 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
this.removeByIds(noExist.stream().map(WeTagGroup::getId).collect(Collectors.toList()));
}
}
this.baseMapper.insetWeTagGroupBatch(weTagGroups);
this.baseMapper.insertWeTagGroupBatch(weTagGroups);
List<WeTag> weTags =
weTagGroups.stream().map(WeTagGroup::getWeTags).collect(ArrayList::new, ArrayList::addAll, ArrayList::addAll);
if (CollectionUtil.isNotEmpty(weTags)) {
......@@ -238,7 +238,7 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
iWeTagService.removeByIds(noExistWeTags.stream().map(WeTag::getId).collect(Collectors.toList()));
}
}
iWeTagService.insetWeTagBatch(weTags);
iWeTagService.insertWeTagBatch(weTags);
}
} else {//不存在删除所有标签组,以标签
if (isSync) {
......@@ -263,8 +263,8 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
List<WeCropGroupTagDto> tagGroups = weCropGroupTagListDto.getTag_group();
if (CollectionUtil.isNotEmpty(tagGroups)) {
List<WeTagGroup> tagGroupsList = new ArrayList<>();
tagGroups.forEach(k -> WeTagGroup.builder().groupId(k.getGroup_id()).gourpName(k.getGroup_name()).build());
this.baseMapper.insetWeTagGroupBatch(tagGroupsList);
tagGroups.forEach(k -> WeTagGroup.builder().groupId(k.getGroup_id()).groupName(k.getGroup_name()).build());
this.baseMapper.insertWeTagGroupBatch(tagGroupsList);
}
}
......@@ -280,8 +280,8 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
List<WeCropGroupTagDto> tagGroups = weCropGroupTagListDto.getTag_group();
if (CollectionUtil.isNotEmpty(tagGroups)) {
List<WeTagGroup> tagGroupsList = new ArrayList<>();
tagGroups.forEach(k -> WeTagGroup.builder().groupId(k.getGroup_id()).gourpName(k.getGroup_name()).build());
this.baseMapper.insetWeTagGroupBatch(tagGroupsList);
tagGroups.forEach(k -> WeTagGroup.builder().groupId(k.getGroup_id()).groupName(k.getGroup_name()).build());
this.baseMapper.insertWeTagGroupBatch(tagGroupsList);
}
}
......
......@@ -141,7 +141,7 @@ public class WeTagServiceImpl extends ServiceImpl<WeTagMapper,WeTag> implements
.groupId(tagGroup.getGroup_id())
.name(tag.getName())
.build());
this.baseMapper.insetWeTagBatch(weTags);
this.baseMapper.insertWeTagBatch(weTags);
}
});
}
......@@ -170,7 +170,7 @@ public class WeTagServiceImpl extends ServiceImpl<WeTagMapper,WeTag> implements
.groupId(tagGroup.getGroup_id())
.name(tag.getName())
.build());
this.baseMapper.insetWeTagBatch(weTags);
this.baseMapper.insertWeTagBatch(weTags);
}
});
}
......@@ -178,8 +178,8 @@ public class WeTagServiceImpl extends ServiceImpl<WeTagMapper,WeTag> implements
}
@Override
public void insetWeTagBatch(List<WeTag> weTags) {
this.baseMapper.insetWeTagBatch(weTags);
public void insertWeTagBatch(List<WeTag> weTags) {
this.baseMapper.insertWeTagBatch(weTags);
}
......
......@@ -285,7 +285,7 @@
</select>
<insert id="saveBatch">
<insert id="insertBatch">
insert into we_customer
(external_userid, `name`, avatar, `type`, gender, unionid, birthday, corp_name, corp_full_name,
`position`,create_by, create_time, update_time, update_by) values
......@@ -302,7 +302,7 @@
`type`= values(`type`),gender= values(gender),
unionid= values(unionid),birthday= values(birthday),
corp_name= values(corp_name),corp_full_name= values(corp_full_name),
`position`= values(`position`)
`position`= values(`position`),update_by= values(update_by),update_time= values(update_time)
</insert>
</mapper>
\ No newline at end of file
......@@ -142,7 +142,7 @@
</select>
<insert id="saveBatch">
<insert id="insertBatch">
insert into we_flower_customer_rel (user_id, external_userid, remark, description, add_time, remark_corp_name,
remark_mobiles, oper_userid, add_way, `state`,create_by, create_time, update_time, update_by)
values
......@@ -157,6 +157,6 @@
description= values(description),add_time= values(add_time),
add_time= values(add_time),remark_corp_name= values(remark_corp_name),
remark_mobiles= values(remark_mobiles),oper_userid= values(oper_userid),
add_way= values(add_way),`state`= values(`state`)
add_way= values(add_way),`state`= values(`state`),update_by= values(update_by),update_time= values(update_time)
</insert>
</mapper>
\ No newline at end of file
......@@ -75,7 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</insert>
<insert id="saveBatch" >
<insert id="insertBatch" >
insert into we_flower_customer_tag_rel (external_userid, user_id, tag_id,create_by, create_time, update_time, update_by)
values
<foreach collection="weFlowerCustomerTagRels" item="item" index="index" separator=",">
......@@ -83,7 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item.createTime},#{item.updateTime},#{item.updateBy})
</foreach>
on duplicate key update corp_id= values(corp_id),external_userid= values(external_userid),
user_id = values(user_id), tag_id= values(tag_id)
user_id = values(user_id), tag_id= values(tag_id),update_by= values(update_by),update_time= values(update_time)
</insert>
</mapper>
\ No newline at end of file
......@@ -5,7 +5,7 @@
<mapper namespace="com.linkwechat.wecom.mapper.WeTagGroupMapper">
<resultMap type="com.linkwechat.wecom.domain.vo.tag.WeTagGroupVo" id="WeTagGroupResult">
<result property="gourpName" column="gourp_name"/>
<result property="groupName" column="group_name"/>
<result property="groupId" column="group_id"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
......@@ -19,7 +19,7 @@
<sql id="selectWeTagGroupVo">
SELECT
wtg.group_id ,
wtg.gourp_name ,
wtg.group_name ,
wtg.create_time ,
wtg.create_by ,
wt.tag_id ,
......@@ -33,28 +33,29 @@
<select id="selectWeTagGroupList" parameterType="WeTagGroup" resultMap="WeTagGroupResult">
<include refid="selectWeTagGroupVo"/>
<where>
<if test="gourpName != null and gourpName != ''">
and gourp_name like concat('%', #{gourpName}, '%')
<if test="groupName != null and groupName != ''">
and group_name like concat('%', #{groupName}, '%')
</if>
and wtg.del_flag=0
</where>
</select>
<insert id="insetWeTagGroupBatch">
insert into we_tag_group (group_id,gourp_name,create_by,update_by,create_time,update_time)
<insert id="insertWeTagGroupBatch">
insert into we_tag_group (group_id,group_name,create_by,update_by,create_time,update_time)
values
<foreach collection="weTagGroups" item="weTagGroup" index="index" separator=",">
(#{weTagGroup.groupId},#{weTagGroup.gourpName},
(#{weTagGroup.groupId},#{weTagGroup.groupName},
#{weTagGroup.createBy},#{weTagGroup.updateBy},#{weTagGroup.createTime},#{weTagGroup.updateTime})
</foreach>
on duplicate key update group_id= values(group_id),gourp_name= values(gourp_name)
on duplicate key update group_id= values(group_id),group_name= values(group_name),
update_by= values(update_by),update_time= values(update_time)
</insert>
<select id="findCustomerTag" resultMap="WeTagGroupResult">
SELECT
wtg.gourp_name,
wtg.group_name,
wtg.group_id,
wt.tag_id,
wt.`name`
......
......@@ -12,14 +12,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<insert id="insetWeTagBatch" >
<insert id="insertWeTagBatch" >
insert into we_tag (group_id, `name`, tag_id, create_by,update_by,create_time,update_time)
values
<foreach collection="weTags" item="tag" index="index" separator=",">
(#{tag.groupId},#{tag.name},#{tag.tagId},
#{tag.createBy},#{tag.updateBy},#{tag.createTime},#{tag.updateTime})
</foreach>
on duplicate key update group_id= values(group_id),`name`= values(`name`),tag_id= values(tag_id)
on duplicate key update group_id= values(group_id),`name`= values(`name`),tag_id= values(tag_id),
update_by= values(update_by),update_time= values(update_time)
</insert>
......
......@@ -102,9 +102,7 @@
telephone= values(telephone),address= values(address),
birthday= values(birthday),remark= values(remark),
is_activate= values(is_activate),
create_by= values(create_by),
update_by= values(update_by),
create_time= values(create_time),
update_time= values(update_time)
</insert>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册