Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
仟微科技
Link Wechat
提交
d622ac7e
Link Wechat
项目概览
仟微科技
/
Link Wechat
通知
48
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Link Wechat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d622ac7e
编写于
6月 21, 2021
作者:
孙
孙喜旺
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
标签相关接口及方法修改
上级
e68279ed
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
287 addition
and
425 deletion
+287
-425
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTagGroupController.java
...linkwechat/web/controller/wecom/WeTagGroupController.java
+3
-4
linkwe-wecom/src/main/java/com/linkwechat/wecom/aspectj/InsertAndUpdateAspect.java
...a/com/linkwechat/wecom/aspectj/InsertAndUpdateAspect.java
+100
-0
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/tag/WeCropDelDto.java
...ava/com/linkwechat/wecom/domain/dto/tag/WeCropDelDto.java
+4
-2
linkwe-wecom/src/main/java/com/linkwechat/wecom/factory/impl/tag/WeCallBackDeleteCustomerTagImpl.java
...com/factory/impl/tag/WeCallBackDeleteCustomerTagImpl.java
+1
-1
linkwe-wecom/src/main/java/com/linkwechat/wecom/mapper/WeTagGroupMapper.java
...in/java/com/linkwechat/wecom/mapper/WeTagGroupMapper.java
+5
-36
linkwe-wecom/src/main/java/com/linkwechat/wecom/mapper/WeTagMapper.java
...rc/main/java/com/linkwechat/wecom/mapper/WeTagMapper.java
+1
-57
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeTagGroupService.java
...java/com/linkwechat/wecom/service/IWeTagGroupService.java
+5
-3
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeTagService.java
...main/java/com/linkwechat/wecom/service/IWeTagService.java
+33
-15
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerServiceImpl.java
.../linkwechat/wecom/service/impl/WeCustomerServiceImpl.java
+1
-5
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeTagGroupServiceImpl.java
.../linkwechat/wecom/service/impl/WeTagGroupServiceImpl.java
+39
-88
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeTagServiceImpl.java
...a/com/linkwechat/wecom/service/impl/WeTagServiceImpl.java
+67
-77
linkwe-wecom/src/main/resources/mapper/wecom/WeTagGroupMapper.xml
...ecom/src/main/resources/mapper/wecom/WeTagGroupMapper.xml
+22
-59
linkwe-wecom/src/main/resources/mapper/wecom/WeTagMapper.xml
linkwe-wecom/src/main/resources/mapper/wecom/WeTagMapper.xml
+6
-78
未找到文件。
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTagGroupController.java
浏览文件 @
d622ac7e
...
...
@@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.RestController;
import
com.linkwechat.wecom.domain.WeTagGroup
;
import
com.linkwechat.wecom.service.IWeTagGroupService
;
import
java.util.Arrays
;
import
java.util.List
;
/**
...
...
@@ -101,7 +102,8 @@ public class WeTagGroupController extends BaseController
@DeleteMapping
(
"/{ids}"
)
public
AjaxResult
remove
(
@PathVariable
String
[]
ids
)
{
return
toAjax
(
weTagGroupService
.
deleteWeTagGroupByIds
(
ids
));
weTagGroupService
.
deleteWeTagGroupByIds
(
Arrays
.
asList
(
ids
));
return
AjaxResult
.
success
();
}
...
...
@@ -112,9 +114,7 @@ public class WeTagGroupController extends BaseController
// @PreAuthorize("@ss.hasPermi('customerManage:tag:sync')")
@GetMapping
(
"/synchWeTags"
)
public
AjaxResult
synchWeTags
(){
SecurityContext
securityContext
=
SecurityContextHolder
.
getContext
();
//异步同步一下标签库,解决标签不同步问题
Threads
.
SINGLE_THREAD_POOL
.
execute
(
new
Runnable
()
{
@Override
...
...
@@ -123,7 +123,6 @@ public class WeTagGroupController extends BaseController
weTagGroupService
.
synchWeTags
();
}
});
return
AjaxResult
.
success
(
WeConstans
.
SYNCH_TIP
);
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/aspectj/InsertAndUpdateAspect.java
0 → 100644
浏览文件 @
d622ac7e
package
com.linkwechat.wecom.aspectj
;
import
com.linkwechat.common.core.domain.BaseEntity
;
import
com.linkwechat.common.utils.SecurityUtils
;
import
org.aspectj.lang.JoinPoint
;
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
java.util.Collection
;
import
java.util.Date
;
import
java.util.Iterator
;
/**
* @author danmo
*/
@Aspect
@Configuration
public
class
InsertAndUpdateAspect
{
@Pointcut
(
"execution(public * com.linkwechat.wecom.mapper.*Mapper.insert*(..)))"
)
public
void
executeInsert
()
{
}
@Pointcut
(
"execution(public * com.linkwechat.wecom.mapper.*Mapper.update*(..)))"
)
public
void
executeUpdate
()
{
}
@Before
(
value
=
"executeInsert()"
)
public
void
insertHandle
(
JoinPoint
joinPoint
)
{
Object
[]
args
=
joinPoint
.
getArgs
();
if
(
args
.
length
>
0L
)
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
Object
arg
=
args
[
i
];
if
(
arg
instanceof
Collection
){
Collection
collection
=
(
Collection
)
arg
;
Iterator
iterator
=
collection
.
iterator
();
if
(
iterator
.
hasNext
()){
Object
next
=
iterator
.
next
();
isInsertBaseEntity
(
next
);
}
}
else
if
(
arg
instanceof
BaseEntity
)
{
isInsertBaseEntity
(
arg
);
}
}
}
}
private
void
isInsertBaseEntity
(
Object
arg
)
{
if
(
arg
instanceof
BaseEntity
)
{
BaseEntity
next1
=
(
BaseEntity
)
arg
;
next1
.
setCreateBy
(
SecurityUtils
.
getUsername
());
next1
.
setUpdateBy
(
SecurityUtils
.
getUsername
());
Date
date
=
new
Date
();
if
(
next1
.
getCreateTime
()
==
null
)
{
next1
.
setCreateTime
(
date
);
}
if
(
next1
.
getUpdateTime
()
==
null
)
{
next1
.
setUpdateTime
(
date
);
}
}
}
@Before
(
value
=
"executeUpdate()"
)
public
void
updateHandle
(
JoinPoint
joinPoint
)
{
Object
[]
args
=
joinPoint
.
getArgs
();
if
(
args
.
length
>
0L
)
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
Object
arg
=
args
[
i
];
if
(
arg
instanceof
Collection
){
Collection
collection
=
(
Collection
)
arg
;
Iterator
iterator
=
collection
.
iterator
();
if
(
iterator
.
hasNext
()){
Object
next
=
iterator
.
next
();
if
(
next
instanceof
BaseEntity
)
{
BaseEntity
next1
=
(
BaseEntity
)
next
;
next1
.
setUpdateBy
(
SecurityUtils
.
getUsername
());
Date
date
=
new
Date
();
if
(
next1
.
getUpdateTime
()
==
null
)
{
next1
.
setUpdateTime
(
date
);
}
}
}
}
else
if
(
arg
instanceof
BaseEntity
)
{
BaseEntity
arg1
=
(
BaseEntity
)
arg
;
arg1
.
setUpdateBy
(
SecurityUtils
.
getUsername
());
Date
date
=
new
Date
();
if
(
arg1
.
getUpdateTime
()
==
null
)
{
arg1
.
setUpdateTime
(
date
);
}
}
}
}
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/tag/WeCropDelDto.java
浏览文件 @
d622ac7e
...
...
@@ -5,6 +5,8 @@ import lombok.experimental.SuperBuilder;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
/**
* @description: 标签删除参数实体
* @author: HaoN
...
...
@@ -16,8 +18,8 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
public
class
WeCropDelDto
{
private
String
[]
tag_id
;
private
List
<
String
>
tag_id
;
private
String
[]
group_id
;
private
List
<
String
>
group_id
;
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/factory/impl/tag/WeCallBackDeleteCustomerTagImpl.java
浏览文件 @
d622ac7e
...
...
@@ -28,7 +28,7 @@ public class WeCallBackDeleteCustomerTagImpl extends WeEventStrategy {
weTagGroupService
.
deleteTagGroup
(
message
.
getTagId
());
break
;
case
tag:
weTagService
.
delete
Tag
(
message
.
getTagId
());
weTagService
.
delete
ByTagId
(
message
.
getTagId
());
break
;
default
:
break
;
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/mapper/WeTagGroupMapper.java
浏览文件 @
d622ac7e
...
...
@@ -15,13 +15,6 @@ import org.apache.ibatis.annotations.Param;
*/
public
interface
WeTagGroupMapper
extends
BaseMapper
<
WeTagGroup
>
{
/**
* 查询标签组ID集合查询标签
*
* @param ids 标签组ID集合
* @return 标签组
*/
public
List
<
WeTagGroupVo
>
getWeTagGroupByIds
(
List
<
Long
>
ids
);
/**
* 查询标签组列表
...
...
@@ -31,46 +24,22 @@ public interface WeTagGroupMapper extends BaseMapper<WeTagGroup>
*/
public
List
<
WeTagGroupVo
>
selectWeTagGroupList
(
WeTagGroup
weTagGroup
);
/**
* 新增标签组
*
* @param weTagGroup 标签组
* @return 结果
*/
public
int
insertWeTagGroup
(
WeTagGroup
weTagGroup
);
/**
* 修改标签组
*
* @param weTagGroup 标签组
* @return 结果
*/
public
int
updateWeTagGroup
(
WeTagGroup
weTagGroup
);
/**
* 批量逻辑删除标签组
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public
int
deleteWeTagGroupByIds
(
String
[]
ids
);
/**
* 批量保存标签组
* @param weTagGroups
* @return
*/
public
int
batchInsetWeTagGroup
(
@Param
(
"weTagGroups"
)
List
<
WeTagGroup
>
weTagGroups
);
public
void
insetWeTagGroupBatch
(
@Param
(
"weTagGroups"
)
List
<
WeTagGroup
>
weTagGroups
);
/**
* 根据企业员工与添加客户关系id给客户打标签
* @param
flowerCustomerRelI
d
* @param
externalUseri
d
* @return
*/
public
List
<
WeTagGroupVo
>
findCustomerTagByFlowerCustomerRelId
(
@Param
(
"flowerCustomerRelId"
)
String
flowerCustomerRelId
);
public
List
<
WeTagGroupVo
>
findCustomerTag
(
@Param
(
"externalUserid"
)
String
externalUserid
,
@Param
(
"userId"
)
String
userId
,
@Param
(
"type"
)
Integer
type
);
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/mapper/WeTagMapper.java
浏览文件 @
d622ac7e
...
...
@@ -16,67 +16,11 @@ import org.springframework.stereotype.Repository;
@Repository
public
interface
WeTagMapper
extends
BaseMapper
<
WeTag
>
{
/**
* 查询企业微信标签
*
* @param id 企业微信标签ID
* @return 企业微信标签
*/
public
WeTag
selectWeTagById
(
Long
id
);
/**
* 查询企业微信标签列表
*
* @param weTag 企业微信标签
* @return 企业微信标签集合
*/
public
List
<
WeTag
>
selectWeTagList
(
WeTag
weTag
);
/**
* 新增企业微信标签
*
* @param weTag 企业微信标签
* @return 结果
*/
public
int
insertWeTag
(
WeTag
weTag
);
/**
* 修改企业微信标签
*
* @param weTag 企业微信标签
* @return 结果
*/
public
int
updateWeTag
(
WeTag
weTag
);
/**
* 删除企业微信标签
*
* @param id 企业微信标签ID
* @return 结果
*/
public
int
deleteWeTagById
(
@Param
(
"id"
)
String
id
);
/**
* 批量删除企业微信标签
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public
int
deleteWeTagByIds
(
@Param
(
"ids"
)
String
[]
ids
);
/**
* 批量插入标签
* @param weTags
* @return
*/
public
int
batchInsetWeTag
(
List
<
WeTag
>
weTags
);
public
void
insetWeTagBatch
(
List
<
WeTag
>
weTags
);
/**
* 标签批量更新
* @param weTags
* @return
*/
public
int
batchUpdateWeTag
(
List
<
WeTag
>
weTags
);
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeTagGroupService.java
浏览文件 @
d622ac7e
...
...
@@ -47,7 +47,7 @@ public interface IWeTagGroupService extends IService<WeTagGroup>
* @param ids 需要删除的标签组ID
* @return 结果
*/
public
int
deleteWeTagGroupByIds
(
String
[]
ids
);
public
boolean
deleteWeTagGroupByIds
(
List
<
String
>
ids
);
...
...
@@ -75,8 +75,10 @@ public interface IWeTagGroupService extends IService<WeTagGroup>
/**
* 根据企业员工与添加客户关系id给客户打标签
* @param flowerCustomerRelId
* @param externalUserid 客户id
* @param userId 员工id
* @param type 标签类型
* @return
*/
public
List
<
WeTagGroupVo
>
findCustomerTag
ByFlowerCustomerRelId
(
String
flowerCustomerRelId
);
public
List
<
WeTagGroupVo
>
findCustomerTag
(
String
externalUserid
,
String
userId
,
Integer
type
);
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeTagService.java
浏览文件 @
d622ac7e
...
...
@@ -4,6 +4,7 @@ import java.util.List;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.linkwechat.wecom.domain.WeTag
;
import
com.linkwechat.wecom.domain.WeTagGroup
;
import
com.linkwechat.wecom.domain.dto.WeTagDto
;
/**
...
...
@@ -16,7 +17,7 @@ public interface IWeTagService extends IService<WeTag>
{
/**
* 查询企业微信标签
*
*
* @param id 企业微信标签ID
* @return 企业微信标签
*/
...
...
@@ -32,47 +33,64 @@ public interface IWeTagService extends IService<WeTag>
/**
* 新增企业微信标签
*
*
* @param weTag 企业微信标签
* @return 结果
*/
public
int
insertWeTag
(
WeTag
weTag
);
public
boolean
insertWeTag
(
WeTag
weTag
);
/**
* 修改企业微信标签
*
*
* @param weTag 企业微信标签
* @return 结果
*/
public
int
updateWeTag
(
WeTag
weTag
);
public
boolean
updateWeTag
(
WeTag
weTag
);
/**
* 批量删除企业微信标签
*
*
* @param ids 需要删除的企业微信标签ID
* @return 结果
*/
public
int
deleteWeTagByIds
(
String
[]
ids
);
public
boolean
deleteWeTagByIds
(
List
<
String
>
ids
);
/**
* 删除企业微信标签信息
*
*
* @param id 企业微信标签ID
* @return 结果
*/
public
int
deleteWeTagById
(
String
id
);
public
boolean
deleteWeTagById
(
String
id
);
/**
* 来自企业微信传输实体添加标签
* @param weTagDto
* 根据标签id创建标签
* @param tagId 标签id
* @return
*/
public
void
creatTag
(
String
tagId
);
/**
* 根据标签id删除标签
* @param tagId 标签id
* @return
*/
public
int
insertWeTagFromWeTagDto
(
WeTagDto
weTagDto
);
public
boolean
deleteByTagId
(
String
tagId
);
void
creatTag
(
String
tagId
);
/**
* 根据标签id修改标签
* @param tagId 标签id
* @return
*/
public
void
updateTag
(
String
tagId
);
void
deleteTag
(
String
tagId
);
void
updateTag
(
String
tagId
);
/**
* 批量保存标签组
* @param weTagGroups
* @return
*/
public
void
insetWeTagBatch
(
List
<
WeTag
>
weTagGroups
);
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerServiceImpl.java
浏览文件 @
d622ac7e
...
...
@@ -544,11 +544,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
}
//获取当前客户拥有得标签
weCustomerPortrait
.
setWeTagGroupList
(
iWeTagGroupService
.
findCustomerTagByFlowerCustomerRelId
(
weCustomerPortrait
.
getFlowerCustomerRelId
()
)
);
weCustomerPortrait
.
setWeTagGroupList
(
iWeTagGroupService
.
findCustomerTag
(
externalUserid
,
userid
,
2
));
//客户社交关系
weCustomerPortrait
.
setSocialConn
(
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeTagGroupServiceImpl.java
浏览文件 @
d622ac7e
...
...
@@ -17,6 +17,7 @@ import com.linkwechat.wecom.domain.vo.tag.WeTagGroupVo;
import
com.linkwechat.wecom.mapper.WeTagGroupMapper
;
import
com.linkwechat.wecom.service.IWeTagGroupService
;
import
com.linkwechat.wecom.service.IWeTagService
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -122,8 +123,8 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
//同步删除微信端的标签
weCropTagClient
.
delCorpTag
(
WeCropDelDto
.
builder
()
.
group_id
(
ArrayUtil
.
toArray
(
ListUtil
.
toList
(
weTagGroup
.
getGroupId
()),
String
.
class
))
.
tag_id
(
ArrayUtil
.
toArray
(
removeWeTags
.
stream
().
map
(
WeTag:
:
getTagId
).
collect
(
Collectors
.
toList
()),
String
.
class
))
.
group_id
(
ListUtil
.
toList
(
weTagGroup
.
getGroupId
()
))
.
tag_id
(
removeWeTags
.
stream
().
map
(
WeTag:
:
getTagId
).
collect
(
Collectors
.
toList
()
))
.
build
());
//移除本地
...
...
@@ -148,24 +149,20 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
* @return 结果
*/
@Override
@Transactional
public
int
deleteWeTagGroupByIds
(
String
[]
ids
)
{
int
returnCode
=
this
.
baseMapper
.
deleteWeTagGroupByIds
(
ids
);
if
(
returnCode
>
Constants
.
SERVICE_RETURN_SUCCESS_CODE
)
{
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
boolean
deleteWeTagGroupByIds
(
List
<
String
>
ids
)
{
boolean
returnCode
=
this
.
removeByIds
(
ids
);
if
(
returnCode
)
{
List
<
WeTag
>
weTags
=
iWeTagService
.
list
(
new
LambdaQueryWrapper
<
WeTag
>().
in
(
WeTag:
:
getGroupId
,
ids
));
if
(
CollectionUtil
.
isNotEmpty
(
weTags
))
{
weCropTagClient
.
delCorpTag
(
WeCropDelDto
.
builder
()
.
group_id
(
ids
)
.
tag_id
(
weTags
.
stream
().
map
(
WeTag:
:
getTagId
).
toArray
(
String
[]::
new
))
.
tag_id
(
weTags
.
stream
().
map
(
WeTag:
:
getTagId
).
collect
(
Collectors
.
toList
()
))
.
build
()
);
}
}
return
returnCode
;
...
...
@@ -178,9 +175,7 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
@Override
@Transactional
public
void
synchWeTags
()
{
WeCropGroupTagListDto
weCropGroupTagListDto
=
weCropTagClient
.
getAllCorpTagList
();
if
(
weCropGroupTagListDto
.
getErrcode
().
equals
(
WeConstans
.
WE_SUCCESS_CODE
))
{
this
.
batchSaveOrUpdateTagGroupAndTag
(
weCropGroupTagListDto
.
getTag_group
(),
true
);
}
...
...
@@ -191,40 +186,36 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
/**
* 来自微信端批量保存或者更新标签组和标签
*
* @param tagGroup
* @param tagGroup
s
* @param isSync 是否同步
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
batchSaveOrUpdateTagGroupAndTag
(
List
<
WeCropGroupTagDto
>
tagGroup
,
Boolean
isSync
)
{
public
void
batchSaveOrUpdateTagGroupAndTag
(
List
<
WeCropGroupTagDto
>
tagGroup
s
,
Boolean
isSync
)
{
List
<
WeTagGroup
>
weTagGroups
=
new
ArrayList
<>();
if
(
CollectionUtil
.
isNotEmpty
(
tagGroup
))
{
tagGroup
.
stream
().
forEach
(
k
->
{
if
(
CollectionUtil
.
isNotEmpty
(
tagGroup
s
))
{
tagGroup
s
.
forEach
(
tagGroup
->
{
WeTagGroup
weTagGroup
=
new
WeTagGroup
();
weTagGroup
.
setCreateBy
(
SecurityUtils
.
getUsername
());
weTagGroup
.
setGourpName
(
k
.
getGroup_name
());
weTagGroup
.
setGroupId
(
k
.
getGroup_id
());
List
<
WeCropTagDto
>
tag
=
k
.
getTag
();
if
(
CollectionUtil
.
isNotEmpty
(
tag
))
{
weTagGroup
.
setGourpName
(
tagGroup
.
getGroup_name
());
weTagGroup
.
setGroupId
(
tagGroup
.
getGroup_id
());
List
<
WeCropTagDto
>
tag
s
=
tagGroup
.
getTag
();
if
(
CollectionUtil
.
isNotEmpty
(
tag
s
))
{
List
<
WeTag
>
weTags
=
new
ArrayList
<>();
tag
.
stream
().
forEach
(
v
->
{
tag
s
.
forEach
(
tag
->
{
WeTag
weTag
=
new
WeTag
();
weTag
.
setTagId
(
v
.
getId
());
weTag
.
setTagId
(
tag
.
getId
());
weTag
.
setGroupId
(
weTagGroup
.
getGroupId
());
weTag
.
setName
(
v
.
getName
());
weTag
.
setName
(
tag
.
getName
());
weTags
.
add
(
weTag
);
});
weTagGroup
.
setWeTags
(
weTags
);
}
weTagGroups
.
add
(
weTagGroup
);
});
}
//先逻辑删除不存在得组
if
(
CollectionUtil
.
isNotEmpty
(
weTagGroups
))
{
...
...
@@ -233,110 +224,70 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
=
this
.
list
(
new
LambdaQueryWrapper
<
WeTagGroup
>().
notIn
(
WeTagGroup:
:
getGroupId
,
weTagGroups
.
stream
().
map
(
WeTagGroup:
:
getGroupId
).
collect
(
Collectors
.
toList
())));
//企业微信端删除得标签
if
(
CollectionUtil
.
isNotEmpty
(
noExist
))
{
noExist
.
stream
().
forEach
(
k
->
k
.
setDelFlag
(
Constants
.
DELETE
));
this
.
updateBatchById
(
noExist
);
this
.
removeByIds
(
noExist
.
stream
().
map
(
WeTagGroup:
:
getId
).
collect
(
Collectors
.
toList
()));
}
}
this
.
saveOrUpdateBatch
(
weTagGroups
);
this
.
baseMapper
.
insetWeTagGroupBatch
(
weTagGroups
);
List
<
WeTag
>
weTags
=
weTagGroups
.
stream
().
map
(
WeTagGroup:
:
getWeTags
).
collect
(
ArrayList:
:
new
,
ArrayList:
:
addAll
,
ArrayList:
:
addAll
);
if
(
CollectionUtil
.
isNotEmpty
(
weTags
))
{
if
(
isSync
)
{
List
<
WeTag
>
noExistWeTags
=
iWeTagService
.
list
(
new
LambdaQueryWrapper
<
WeTag
>().
notIn
(
WeTag:
:
getTagId
,
weTags
.
stream
().
map
(
WeTag:
:
getTagId
).
collect
(
Collectors
.
toList
())));
if
(
CollectionUtil
.
isNotEmpty
(
noExistWeTags
))
{
noExistWeTags
.
stream
().
forEach
(
k
->
k
.
setDelFlag
(
Constants
.
DELETE
));
iWeTagService
.
updateBatchById
(
noExistWeTags
);
iWeTagService
.
removeByIds
(
noExistWeTags
.
stream
().
map
(
WeTag:
:
getId
).
collect
(
Collectors
.
toList
()));
}
}
iWeTagService
.
saveOrUpdateBatch
(
weTags
);
iWeTagService
.
insetWeTagBatch
(
weTags
);
}
}
else
{
//不存在删除所有标签组,以标签
if
(
isSync
)
{
List
<
WeTagGroup
>
weTagGroupList
=
this
.
list
(
new
LambdaQueryWrapper
<
WeTagGroup
>().
eq
(
WeTagGroup:
:
getDelFlag
,
Constants
.
NORMAL
));
if
(
CollectionUtil
.
isNotEmpty
(
weTagGroupList
))
{
weTagGroupList
.
stream
().
forEach
(
k
->
k
.
setDelFlag
(
Constants
.
DELETE
));
this
.
updateBatchById
(
weTagGroupList
);
this
.
removeByIds
(
weTagGroupList
.
stream
().
map
(
WeTagGroup:
:
getId
).
collect
(
Collectors
.
toList
()));
}
List
<
WeTag
>
weTags
=
iWeTagService
.
list
(
new
LambdaQueryWrapper
<
WeTag
>().
eq
(
WeTag:
:
getDelFlag
,
Constants
.
NORMAL
));
if
(
CollectionUtil
.
isNotEmpty
(
weTags
))
{
weTags
.
stream
().
forEach
(
k
->
k
.
setDelFlag
(
Constants
.
DELETE
));
iWeTagService
.
updateBatchById
(
weTags
);
iWeTagService
.
removeByIds
(
weTags
.
stream
().
map
(
WeTag:
:
getId
).
collect
(
Collectors
.
toList
()));
}
}
}
}
@Override
public
void
createTagGroup
(
String
id
)
{
List
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
id
);
WeFindCropTagParam
build
=
WeFindCropTagParam
.
builder
().
group_id
(
list
).
build
();
WeFindCropTagParam
build
=
WeFindCropTagParam
.
builder
().
group_id
(
ListUtil
.
toList
(
id
)).
build
();
WeCropGroupTagListDto
weCropGroupTagListDto
=
weCropTagClient
.
getCorpTagListByTagIds
(
build
);
List
<
WeCropGroupTagDto
>
tag
_group
=
weCropGroupTagListDto
.
getTag_group
();
if
(
CollectionUtil
.
isNotEmpty
(
tag
_group
))
{
List
<
WeCropGroupTagDto
>
tag
Groups
=
weCropGroupTagListDto
.
getTag_group
();
if
(
CollectionUtil
.
isNotEmpty
(
tag
Groups
))
{
List
<
WeTagGroup
>
tagGroupsList
=
new
ArrayList
<>();
tag_group
.
stream
().
forEach
(
k
->
{
WeTagGroup
tagGroupInfo
=
this
.
baseMapper
.
selectOne
(
new
LambdaQueryWrapper
<
WeTagGroup
>()
.
eq
(
WeTagGroup:
:
getGroupId
,
k
.
getGroup_id
())
.
eq
(
WeTagGroup:
:
getDelFlag
,
Constants
.
NORMAL
));
if
(
tagGroupInfo
==
null
)
{
WeTagGroup
weTagGroup
=
new
WeTagGroup
();
weTagGroup
.
setCreateBy
(
"sys"
);
weTagGroup
.
setGourpName
(
k
.
getGroup_name
());
weTagGroup
.
setGroupId
(
k
.
getGroup_id
());
tagGroupsList
.
add
(
weTagGroup
);
}
});
this
.
saveBatch
(
tagGroupsList
);
tagGroups
.
forEach
(
k
->
WeTagGroup
.
builder
().
groupId
(
k
.
getGroup_id
()).
gourpName
(
k
.
getGroup_name
()).
build
());
this
.
baseMapper
.
insetWeTagGroupBatch
(
tagGroupsList
);
}
}
@Override
public
void
deleteTagGroup
(
String
i
d
)
{
this
.
baseMapper
.
deleteWeTagGroupByIds
(
id
.
split
(
","
));
public
void
deleteTagGroup
(
String
groupI
d
)
{
remove
(
new
LambdaQueryWrapper
<
WeTagGroup
>().
eq
(
WeTagGroup:
:
getGroupId
,
groupId
));
}
@Override
public
void
updateTagGroup
(
String
id
)
{
List
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
id
);
WeFindCropTagParam
build
=
WeFindCropTagParam
.
builder
().
group_id
(
list
).
build
();
WeFindCropTagParam
build
=
WeFindCropTagParam
.
builder
().
group_id
(
ListUtil
.
toList
(
id
)).
build
();
WeCropGroupTagListDto
weCropGroupTagListDto
=
weCropTagClient
.
getCorpTagListByTagIds
(
build
);
List
<
WeCropGroupTagDto
>
tag
_group
=
weCropGroupTagListDto
.
getTag_group
();
if
(
CollectionUtil
.
isNotEmpty
(
tag
_group
))
{
List
<
WeCropGroupTagDto
>
tag
Groups
=
weCropGroupTagListDto
.
getTag_group
();
if
(
CollectionUtil
.
isNotEmpty
(
tag
Groups
))
{
List
<
WeTagGroup
>
tagGroupsList
=
new
ArrayList
<>();
WeTagGroup
weTagGroup
=
new
WeTagGroup
();
tag_group
.
stream
().
forEach
(
k
->
{
weTagGroup
.
setCreateBy
(
"sys"
);
weTagGroup
.
setGourpName
(
k
.
getGroup_name
());
weTagGroup
.
setGroupId
(
k
.
getGroup_id
());
tagGroupsList
.
add
(
weTagGroup
);
});
this
.
saveOrUpdateBatch
(
tagGroupsList
);
tagGroups
.
forEach
(
k
->
WeTagGroup
.
builder
().
groupId
(
k
.
getGroup_id
()).
gourpName
(
k
.
getGroup_name
()).
build
());
this
.
baseMapper
.
insetWeTagGroupBatch
(
tagGroupsList
);
}
}
@Override
public
List
<
WeTagGroupVo
>
findCustomerTag
ByFlowerCustomerRelId
(
String
flowerCustomerRelId
)
{
return
this
.
baseMapper
.
findCustomerTag
ByFlowerCustomerRelId
(
flowerCustomerRelId
);
public
List
<
WeTagGroupVo
>
findCustomerTag
(
String
externalUserid
,
String
userId
,
Integer
type
)
{
return
this
.
baseMapper
.
findCustomerTag
(
externalUserid
,
userId
,
type
);
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeTagServiceImpl.java
浏览文件 @
d622ac7e
package
com.linkwechat.wecom.service.impl
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.ListUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.linkwechat.common.utils.DateUtils
;
...
...
@@ -24,6 +23,7 @@ import org.springframework.stereotype.Service;
import
com.linkwechat.wecom.mapper.WeTagMapper
;
import
com.linkwechat.wecom.domain.WeTag
;
import
com.linkwechat.wecom.service.IWeTagService
;
import
org.springframework.transaction.annotation.Transactional
;
/**
* 企业微信标签Service业务层处理
...
...
@@ -34,23 +34,19 @@ import com.linkwechat.wecom.service.IWeTagService;
@Service
public
class
WeTagServiceImpl
extends
ServiceImpl
<
WeTagMapper
,
WeTag
>
implements
IWeTagService
{
@Autowired
private
WeTagMapper
weTagMapper
;
@Autowired
private
WeCropTagClient
weCropTagClient
;
@Autowired
private
IWeTagGroupService
weTagGroupService
;
/**
* 查询企业微信标签
*
*
* @param id 企业微信标签ID
* @return 企业微信标签
*/
@Override
public
WeTag
selectWeTagById
(
Long
id
)
{
return
weTagMapper
.
selectWeTag
ById
(
id
);
return
get
ById
(
id
);
}
/**
...
...
@@ -62,102 +58,90 @@ public class WeTagServiceImpl extends ServiceImpl<WeTagMapper,WeTag> implements
@Override
public
List
<
WeTag
>
selectWeTagList
(
WeTag
weTag
)
{
return
weTagMapper
.
selectWeTagList
(
weTag
);
LambdaQueryWrapper
<
WeTag
>
wrapper
=
new
LambdaQueryWrapper
<>();
if
(
StringUtils
.
isNotEmpty
(
weTag
.
getGroupId
())){
wrapper
.
eq
(
WeTag:
:
getGroupId
,
weTag
.
getGroupId
());
}
if
(
StringUtils
.
isNotEmpty
(
weTag
.
getName
())){
wrapper
.
like
(
WeTag:
:
getName
,
weTag
.
getName
());
}
if
(
StringUtils
.
isNotEmpty
(
weTag
.
getTagId
())){
wrapper
.
eq
(
WeTag:
:
getTagId
,
weTag
.
getTagId
());
}
if
(
StringUtils
.
isNotEmpty
(
weTag
.
getTagId
())){
wrapper
.
eq
(
WeTag:
:
getTagId
,
weTag
.
getTagId
());
}
return
list
(
wrapper
);
}
/**
* 新增企业微信标签
*
*
* @param weTag 企业微信标签
* @return 结果
*/
@Override
public
int
insertWeTag
(
WeTag
weTag
)
public
boolean
insertWeTag
(
WeTag
weTag
)
{
weTag
.
setCreateTime
(
DateUtils
.
getNowDate
());
return
weTagMapper
.
insertWeTag
(
weTag
);
return
save
(
weTag
);
}
/**
* 修改企业微信标签
*
*
* @param weTag 企业微信标签
* @return 结果
*/
@Override
public
int
updateWeTag
(
WeTag
weTag
)
public
boolean
updateWeTag
(
WeTag
weTag
)
{
return
weTagMapper
.
updateWeTag
(
weTag
);
return
updateById
(
weTag
);
}
/**
* 批量删除企业微信标签
*
*
* @param ids 需要删除的企业微信标签ID
* @return 结果
*/
@Override
public
int
deleteWeTagByIds
(
String
[]
ids
)
public
boolean
deleteWeTagByIds
(
List
<
String
>
ids
)
{
return
weTagMapper
.
deleteWeTag
ByIds
(
ids
);
return
remove
ByIds
(
ids
);
}
/**
* 删除企业微信标签信息
*
*
* @param id 企业微信标签ID
* @return 结果
*/
@Override
public
int
deleteWeTagById
(
String
id
)
public
boolean
deleteWeTagById
(
String
id
)
{
return
weTagMapper
.
deleteWeTag
ById
(
id
);
return
remove
ById
(
id
);
}
/**
* 来自weTagDto实体添加标签(该实体为获取客户时相关联系人下的实体)
* @param weTagDto
* @return
*/
@Override
public
int
insertWeTagFromWeTagDto
(
WeTagDto
weTagDto
)
{
//查询有无当前标签组,没有则创建一个标签组,同时创建该标签
//查询当前标签组+标签名校验查询当前标签,没有,则创建标签
//之后将标签体转化为关系入库
return
0
;
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
creatTag
(
String
tagId
)
{
if
(
StringUtils
.
isNotEmpty
(
tagId
)){
List
<
String
>
tagList
=
Arrays
.
stream
(
tagId
.
split
(
","
)).
collect
(
Collectors
.
toList
()
);
List
<
String
>
tagList
=
ListUtil
.
toList
(
tagId
);
WeCropGroupTagListDto
weCropGroupTagListDto
=
weCropTagClient
.
getCorpTagListByTagIds
(
WeFindCropTagParam
.
builder
().
tag_id
(
tagList
).
build
());
List
<
WeCropGroupTagDto
>
tag
_group
=
weCropGroupTagListDto
.
getTag_group
();
if
(
CollectionUtil
.
isNotEmpty
(
tag
_group
))
{
tag
_group
.
stream
().
forEach
(
k
->
{
List
<
WeCropTagDto
>
tag
=
k
.
getTag
();
if
(
CollectionUtil
.
isNotEmpty
(
tag
))
{
List
<
WeCropGroupTagDto
>
tag
Groups
=
weCropGroupTagListDto
.
getTag_group
();
if
(
CollectionUtil
.
isNotEmpty
(
tag
Groups
))
{
tag
Groups
.
forEach
(
tagGroup
->
{
List
<
WeCropTagDto
>
tag
s
=
tagGroup
.
getTag
();
if
(
CollectionUtil
.
isNotEmpty
(
tag
s
))
{
List
<
WeTag
>
weTags
=
new
ArrayList
<>();
tag
.
stream
().
forEach
(
v
->
{
WeTag
tagInfo
=
this
.
getOne
(
new
LambdaQueryWrapper
<
WeTag
>()
.
eq
(
WeTag:
:
getGroupId
,
k
.
getGroup_id
())
.
eq
(
WeTag:
:
getTagId
,
v
.
getId
()));
if
(
tagInfo
==
null
)
{
WeTag
weTag
=
new
WeTag
();
weTag
.
setTagId
(
v
.
getId
());
weTag
.
setGroupId
(
k
.
getGroup_id
());
weTag
.
setName
(
v
.
getName
());
weTags
.
add
(
weTag
);
}
});
this
.
saveBatch
(
weTags
);
tags
.
forEach
(
tag
->
WeTag
.
builder
()
.
tagId
(
tag
.
getId
())
.
groupId
(
tagGroup
.
getGroup_id
())
.
name
(
tag
.
getName
())
.
build
());
this
.
baseMapper
.
insetWeTagBatch
(
weTags
);
}
});
}
...
...
@@ -165,32 +149,38 @@ public class WeTagServiceImpl extends ServiceImpl<WeTagMapper,WeTag> implements
}
@Override
public
void
deleteTag
(
String
tagId
)
{
this
.
deleteWeTagById
(
tagId
);
public
boolean
deleteByTagId
(
String
tagId
)
{
return
this
.
remove
(
new
LambdaQueryWrapper
<
WeTag
>().
eq
(
WeTag:
:
getTagId
,
tagId
)
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateTag
(
String
tagId
)
{
if
(
StringUtils
.
isNotEmpty
(
tagId
)){
List
<
String
>
tagList
=
Arrays
.
stream
(
tagId
.
split
(
","
)).
collect
(
Collectors
.
toList
()
);
List
<
String
>
tagList
=
ListUtil
.
toList
(
tagId
);
WeCropGroupTagListDto
weCropGroupTagListDto
=
weCropTagClient
.
getCorpTagListByTagIds
(
WeFindCropTagParam
.
builder
().
tag_id
(
tagList
).
build
());
List
<
WeCropGroupTagDto
>
tag
_group
=
weCropGroupTagListDto
.
getTag_group
();
if
(
CollectionUtil
.
isNotEmpty
(
tag
_group
))
{
tag
_group
.
stream
().
forEach
(
k
->
{
List
<
WeCropTagDto
>
tag
=
k
.
getTag
();
if
(
CollectionUtil
.
isNotEmpty
(
tag
))
{
List
<
WeCropGroupTagDto
>
tag
Groups
=
weCropGroupTagListDto
.
getTag_group
();
if
(
CollectionUtil
.
isNotEmpty
(
tag
Groups
))
{
tag
Groups
.
forEach
(
tagGroup
->
{
List
<
WeCropTagDto
>
tag
s
=
tagGroup
.
getTag
();
if
(
CollectionUtil
.
isNotEmpty
(
tag
s
))
{
List
<
WeTag
>
weTags
=
new
ArrayList
<>();
tag
.
stream
().
forEach
(
v
->
{
WeTag
weTag
=
new
WeTag
();
weTag
.
setTagId
(
v
.
getId
());
weTag
.
setGroupId
(
k
.
getGroup_id
());
weTag
.
setName
(
v
.
getName
());
weTags
.
add
(
weTag
);
});
this
.
saveOrUpdateBatch
(
weTags
);
tags
.
forEach
(
tag
->
WeTag
.
builder
()
.
tagId
(
tag
.
getId
())
.
groupId
(
tagGroup
.
getGroup_id
())
.
name
(
tag
.
getName
())
.
build
());
this
.
baseMapper
.
insetWeTagBatch
(
weTags
);
}
});
}
}
}
@Override
public
void
insetWeTagBatch
(
List
<
WeTag
>
weTags
)
{
this
.
baseMapper
.
insetWeTagBatch
(
weTags
);
}
}
linkwe-wecom/src/main/resources/mapper/wecom/WeTagGroupMapper.xml
浏览文件 @
d622ac7e
...
...
@@ -40,76 +40,39 @@
</where>
</select>
<select
id=
"getWeTagGroupByIds"
resultMap=
"WeTagGroupResult"
>
<include
refid=
"selectWeTagGroupVo"
/>
<where>
<if
test=
"ids != null and ids.length >0 "
>
and wtg.id in
<foreach
item=
"id"
collection=
"ids"
open=
"("
separator=
","
close=
")"
>
#{id}
</foreach>
</if>
and wtg.del_flag=0
</where>
</select>
<insert
id=
"insertWeTagGroup"
parameterType=
"WeTagGroup"
>
insert into we_tag_group
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
id,
</if>
<if
test=
"gourpName != null"
>
gourp_name,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"createBy != null"
>
create_by,
</if>
<if
test=
"groupId != null"
>
group_id,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
#{id},
</if>
<if
test=
"gourpName != null"
>
#{gourpName},
</if>
<if
test=
"createTime != null"
>
#{createTime},
</if>
<if
test=
"createBy != null"
>
#{createBy},
</if>
<if
test=
"groupId != null"
>
#{groupId},
</if>
</trim>
</insert>
<update
id=
"updateWeTagGroup"
parameterType=
"WeTagGroup"
>
update we_tag_group
<trim
prefix=
"SET"
suffixOverrides=
","
>
<if
test=
"gourpName != null"
>
gourp_name = #{gourpName},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
</trim>
where id = #{id}
</update>
<update
id=
"deleteWeTagGroupByIds"
parameterType=
"String"
>
update we_tag_group set status=2
where group_id in
<foreach
item=
"id"
collection=
"array"
open=
"("
separator=
","
close=
")"
>
#{id}
</foreach>
</update>
<insert
id=
"batchInsetWeTagGroup"
>
insert into we_tag_group (id, gourp_name, create_time, create_by,group_id)
<insert
id=
"insetWeTagGroupBatch"
>
insert into we_tag_group (group_id,gourp_name,create_by,update_by,create_time,update_time)
values
<foreach
collection=
"weTagGroups"
item=
"weTagGroup"
index=
"index"
separator=
","
>
(#{weTagGroup.id},#{weTagGroup.gourpName},#{weTagGroup.createTime},#{weTagGroup.createBy},#{weTagGroup.groupId})
(#{weTagGroup.groupId},#{weTagGroup.gourpName},
#{weTagGroup.createBy},#{weTagGroup.updateBy},#{weTagGroup.createTime},#{weTagGroup.updateTime})
</foreach>
on duplicate key update group_id= values(group_id),gourp_name= values(gourp_name)
</insert>
<select
id=
"findCustomerTag
ByFlowerCustomerRelId
"
resultMap=
"WeTagGroupResult"
>
<select
id=
"findCustomerTag"
resultMap=
"WeTagGroupResult"
>
SELECT
wt.tag_id,
wt.`name`,
wtg.gourp_name,
wtg.group_id
wtg.group_id,
wt.tag_id,
wt.`name`
FROM
we_flower_customer_tag_rel wfctr
INNER JOIN we_tag wt ON wfctr.tag_id = wt.tag_id
INNER JOIN we_tag_group wtg ON wt.group_id = wtg.group_id
WHERE wt.`status`=0 and wtg.`status`=0 and wfctr.flower_customer_rel_id=#{flowerCustomerRelId}
INNER JOIN we_tag wt ON wfctr.tag_id = wt.tag_id and wt.`del_flag`=0
INNER JOIN we_tag_group wtg ON wt.group_id = wtg.group_id and wtg.`del_flag`=0
<where>
<if
test=
"externalUserid != null and externalUserid != ''"
>
and wfctr.external_userid = #{externalUserid}
</if>
<if
test=
"userId != null and userId != ''"
>
and wfctr.user_id = #{userId}
</if>
<if
test=
"type != null"
>
and wt.type = #{type}
</if>
</where>
</select>
...
...
linkwe-wecom/src/main/resources/mapper/wecom/WeTagMapper.xml
浏览文件 @
d622ac7e
...
...
@@ -11,88 +11,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"createTime"
column=
"create_time"
/>
</resultMap>
<sql
id=
"selectWeTagVo"
>
select id, group_id, name, create_time from we_tag
</sql>
<select
id=
"selectWeTagList"
parameterType=
"WeTag"
resultMap=
"WeTagResult"
>
<include
refid=
"selectWeTagVo"
/>
<where>
<if
test=
"groupId != null "
>
and group_id = #{groupId}
</if>
<if
test=
"name != null and name != ''"
>
and name like concat('%', #{name}, '%')
</if>
</where>
</select>
<select
id=
"selectWeTagById"
parameterType=
"Long"
resultMap=
"WeTagResult"
>
<include
refid=
"selectWeTagVo"
/>
where id = #{id} and status=0
</select>
<insert
id=
"insertWeTag"
parameterType=
"WeTag"
>
insert into we_tag
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
id,
</if>
<if
test=
"groupId != null"
>
group_id,
</if>
<if
test=
"name != null"
>
name,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
#{id},
</if>
<if
test=
"groupId != null"
>
#{groupId},
</if>
<if
test=
"name != null"
>
#{name},
</if>
<if
test=
"createTime != null"
>
#{createTime},
</if>
</trim>
</insert>
<update
id=
"updateWeTag"
parameterType=
"WeTag"
>
update we_tag
<trim
prefix=
"SET"
suffixOverrides=
","
>
<if
test=
"groupId != null"
>
group_id = #{groupId},
</if>
<if
test=
"name != null"
>
name = #{name},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
</trim>
where id = #{id}
</update>
<delete
id=
"deleteWeTagById"
>
update we_tag set status=2 where tag_id = #{id}
</delete>
<delete
id=
"deleteWeTagByIds"
>
update we_tag set status=2 where tag_id in
<foreach
item=
"id"
collection=
"array"
open=
"("
separator=
","
close=
")"
>
#{id}
</foreach>
</delete>
<insert
id=
"batchInsetWeTag"
>
insert into we_tag (id, group_id, name, create_time,tag_id)
<insert
id=
"insetWeTagBatch"
>
insert into we_tag (group_id, `name`, tag_id, create_by,update_by,create_time,update_time)
values
<foreach
collection=
"list"
item=
"tag"
index=
"index"
separator=
","
>
(#{tag.id},#{tag.groupId},#{tag.name},#{tag.createTime},#{tag.tagId})
<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)
</insert>
<update
id=
"batchUpdateWeTag"
>
update we_tag set
name=
<foreach
collection=
"list"
item=
"tag"
index=
"index"
separator=
" "
open=
"case id"
close=
"end"
>
when #{tag.id} then #{tag.name}
</foreach>
,status=
<foreach
collection=
"list"
item=
"tag"
index=
"index"
separator=
" "
open=
"case id"
close=
"end"
>
when #{tag.id} then #{tag.status}
</foreach>
where id in
<foreach
collection=
"list"
item=
"tag"
index=
"index"
separator=
","
open=
"("
close=
")"
>
#{tag.id}
</foreach>
</update>
</mapper>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录