Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QianQiXiang
haoban-manage3.0
Commits
ede972c4
Commit
ede972c4
authored
Jun 22, 2021
by
fudahua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
企业微信标签同步
parent
1a4a14aa
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
398 additions
and
21 deletions
+398
-21
QywxTagInfoDTO.java
...in/java/com/gic/haoban/manage/api/dto/QywxTagInfoDTO.java
+12
-0
QywxTagItemDTO.java
...in/java/com/gic/haoban/manage/api/dto/QywxTagItemDTO.java
+10
-0
QywxTagRelationTypeEnum.java
.../gic/haoban/manage/api/enums/QywxTagRelationTypeEnum.java
+23
-3
QywxTagItemMapper.java
...c/haoban/manage/service/dao/mapper/QywxTagItemMapper.java
+10
-0
QywxTagRelationMapper.java
...oban/manage/service/dao/mapper/QywxTagRelationMapper.java
+11
-1
QywxTagService.java
...com/gic/haoban/manage/service/service/QywxTagService.java
+39
-1
QywxTagServiceImpl.java
...aoban/manage/service/service/impl/QywxTagServiceImpl.java
+28
-2
QywxTagApiServiceImpl.java
...anage/service/service/out/impl/QywxTagApiServiceImpl.java
+242
-13
QywxTagItemMapper.xml
...3-service/src/main/resources/mapper/QywxTagItemMapper.xml
+10
-0
QywxTagRelationMapper.xml
...rvice/src/main/resources/mapper/QywxTagRelationMapper.xml
+13
-1
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/dto/QywxTagInfoDTO.java
View file @
ede972c4
...
@@ -50,11 +50,23 @@ public class QywxTagInfoDTO implements Serializable {
...
@@ -50,11 +50,23 @@ public class QywxTagInfoDTO implements Serializable {
*
*
*/
*/
private
Date
updateTime
;
private
Date
updateTime
;
/**
* 标签id
*/
private
String
memberTagId
;
/**
/**
*/
*/
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
public
String
getMemberTagId
()
{
return
memberTagId
;
}
public
void
setMemberTagId
(
String
memberTagId
)
{
this
.
memberTagId
=
memberTagId
;
}
/**
/**
* This method returns the value of the database column tab_haoban_qywx_tag.qywx_tag_id
* This method returns the value of the database column tab_haoban_qywx_tag.qywx_tag_id
*
*
...
...
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/dto/QywxTagItemDTO.java
View file @
ede972c4
...
@@ -61,10 +61,20 @@ public class QywxTagItemDTO implements Serializable {
...
@@ -61,10 +61,20 @@ public class QywxTagItemDTO implements Serializable {
*/
*/
private
Date
updateTime
;
private
Date
updateTime
;
private
String
memberTagItemId
;
/**
/**
*/
*/
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
public
String
getMemberTagItemId
()
{
return
memberTagItemId
;
}
public
void
setMemberTagItemId
(
String
memberTagItemId
)
{
this
.
memberTagItemId
=
memberTagItemId
;
}
/**
/**
* This method returns the value of the database column tab_haoban_qywx_tag_item.qywx_tag_item_id
* This method returns the value of the database column tab_haoban_qywx_tag_item.qywx_tag_item_id
*
*
...
...
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/enums/QywxTagRelationTypeEnum.java
View file @
ede972c4
...
@@ -4,15 +4,25 @@ package com.gic.haoban.manage.api.enums;
...
@@ -4,15 +4,25 @@ package com.gic.haoban.manage.api.enums;
* Created by hua on 2021/6/21.
* Created by hua on 2021/6/21.
*/
*/
public
enum
QywxTagRelationTypeEnum
{
public
enum
QywxTagRelationTypeEnum
{
TAG_GROUP
(
0
,
"标签组"
),
TAG_GROUP
(
0
,
"标签组"
,
"tag_group"
),
TAG_ITEM
(
1
,
"标签项"
);
TAG_ITEM
(
1
,
"标签项"
,
"tag"
);
private
int
type
;
private
int
type
;
private
String
name
;
private
String
name
;
private
String
tagType
;
QywxTagRelationTypeEnum
(
int
type
,
String
name
)
{
QywxTagRelationTypeEnum
(
int
type
,
String
name
,
String
tagType
)
{
this
.
type
=
type
;
this
.
type
=
type
;
this
.
name
=
name
;
this
.
name
=
name
;
this
.
tagType
=
tagType
;
}
public
String
getTagType
()
{
return
tagType
;
}
public
void
setTagType
(
String
tagType
)
{
this
.
tagType
=
tagType
;
}
}
public
int
getType
()
{
public
int
getType
()
{
...
@@ -30,4 +40,14 @@ public enum QywxTagRelationTypeEnum {
...
@@ -30,4 +40,14 @@ public enum QywxTagRelationTypeEnum {
public
void
setName
(
String
name
)
{
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
this
.
name
=
name
;
}
}
public
static
QywxTagRelationTypeEnum
getByTagType
(
String
type
)
{
QywxTagRelationTypeEnum
[]
values
=
QywxTagRelationTypeEnum
.
values
();
for
(
QywxTagRelationTypeEnum
value
:
values
)
{
if
(
value
.
getTagType
().
equals
(
type
))
{
return
value
;
}
}
return
null
;
}
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/QywxTagItemMapper.java
View file @
ede972c4
...
@@ -58,4 +58,13 @@ public interface QywxTagItemMapper {
...
@@ -58,4 +58,13 @@ public interface QywxTagItemMapper {
* @return
* @return
*/
*/
int
delByQywxTagGroupKey
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
,
@Param
(
"qywxTagGroupKey"
)
String
qywxTagGroupKey
);
int
delByQywxTagGroupKey
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
,
@Param
(
"qywxTagGroupKey"
)
String
qywxTagGroupKey
);
/**
* 根据id 获取标签项信息
*
* @param wxEnterpriseId
* @param qywxTagKey
* @return
*/
TabQywxTagItem
getByQywxTagKey
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
,
@Param
(
"qywxTagKey"
)
String
qywxTagKey
);
}
}
\ No newline at end of file
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/QywxTagRelationMapper.java
View file @
ede972c4
...
@@ -47,7 +47,7 @@ public interface QywxTagRelationMapper {
...
@@ -47,7 +47,7 @@ public interface QywxTagRelationMapper {
* @param memberTagId
* @param memberTagId
* @return
* @return
*/
*/
List
<
TabQywxTagRelation
>
listByTagId
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
,
@Param
(
"memberTagId"
)
String
memberTagId
);
List
<
TabQywxTagRelation
>
listBy
Member
TagId
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
,
@Param
(
"memberTagId"
)
String
memberTagId
);
/**
/**
* 删除同步信息
* 删除同步信息
...
@@ -57,4 +57,13 @@ public interface QywxTagRelationMapper {
...
@@ -57,4 +57,13 @@ public interface QywxTagRelationMapper {
* @return
* @return
*/
*/
int
delByMemberTagId
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
,
@Param
(
"memberTagId"
)
String
memberTagId
);
int
delByMemberTagId
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
,
@Param
(
"memberTagId"
)
String
memberTagId
);
/**
* 查询企业下所有同步的
*
* @param wxEnterpriseId
* @param qywxTagId
* @return
*/
List
<
TabQywxTagRelation
>
listByQywxTagId
(
@Param
(
"wxEnterpriseId"
)
String
wxEnterpriseId
,
@Param
(
"qywxTagId"
)
String
qywxTagId
);
}
}
\ No newline at end of file
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/QywxTagService.java
View file @
ede972c4
...
@@ -27,6 +27,15 @@ public interface QywxTagService {
...
@@ -27,6 +27,15 @@ public interface QywxTagService {
public
TabQywxTag
getQywxTagByQywxGroupKey
(
String
wxEnterpriseId
,
String
groupKey
);
public
TabQywxTag
getQywxTagByQywxGroupKey
(
String
wxEnterpriseId
,
String
groupKey
);
/**
/**
* 根据标签组key 查询详情
*
* @param wxEnterpriseId
* @param id
* @return
*/
public
TabQywxTag
getQywxTagByQywxTagId
(
String
wxEnterpriseId
,
String
id
);
/**
* 根据id 查询列表
* 根据id 查询列表
*
*
* @param wxEnterpriseId
* @param wxEnterpriseId
...
@@ -100,7 +109,15 @@ public interface QywxTagService {
...
@@ -100,7 +109,15 @@ public interface QywxTagService {
* @param memberTagId
* @param memberTagId
* @return
* @return
*/
*/
public
TabQywxTagRelation
getQywxTagRelationByMemberTagId
(
String
memberTagId
);
public
List
<
TabQywxTagRelation
>
listQywxTagRelationByMemberTagId
(
String
wxEnterpriseId
,
String
memberTagId
);
/**
* 根据qywxTagId查询
*
* @param qywxTagId
* @return
*/
public
List
<
TabQywxTagRelation
>
listQywxTagRelationByQywxTagId
(
String
wxEnterpriseId
,
String
qywxTagId
);
/**
/**
* 删除企业微信的标签
* 删除企业微信的标签
...
@@ -110,4 +127,25 @@ public interface QywxTagService {
...
@@ -110,4 +127,25 @@ public interface QywxTagService {
* @return
* @return
*/
*/
public
boolean
delQywxTag
(
String
groupKey
,
String
wxEnterpriseId
);
public
boolean
delQywxTag
(
String
groupKey
,
String
wxEnterpriseId
);
/**
* 根据企业微信的标签项获取 标签项
*
* @param wxEnterpriseId
* @param qywxTagKey
* @return
*/
public
TabQywxTagItem
getQywxTagItemByQywxItemKey
(
String
wxEnterpriseId
,
String
qywxTagKey
);
/**
* 删除标签项
*
* @param wxEnterpriseId
* @param id
* @return
*/
public
boolean
delQywxTagItemById
(
String
wxEnterpriseId
,
String
id
);
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/QywxTagServiceImpl.java
View file @
ede972c4
...
@@ -43,6 +43,11 @@ public class QywxTagServiceImpl implements QywxTagService {
...
@@ -43,6 +43,11 @@ public class QywxTagServiceImpl implements QywxTagService {
}
}
@Override
@Override
public
TabQywxTag
getQywxTagByQywxTagId
(
String
wxEnterpriseId
,
String
id
)
{
return
qywxTagMapper
.
selectByPrimaryKey
(
id
);
}
@Override
public
List
<
TabQywxTagItem
>
listByQywxTagId
(
String
wxEnterpriseId
,
String
qywxTagId
)
{
public
List
<
TabQywxTagItem
>
listByQywxTagId
(
String
wxEnterpriseId
,
String
qywxTagId
)
{
return
qywxTagItemMapper
.
listByQywxTagId
(
wxEnterpriseId
,
qywxTagId
);
return
qywxTagItemMapper
.
listByQywxTagId
(
wxEnterpriseId
,
qywxTagId
);
}
}
...
@@ -158,7 +163,28 @@ public class QywxTagServiceImpl implements QywxTagService {
...
@@ -158,7 +163,28 @@ public class QywxTagServiceImpl implements QywxTagService {
}
}
@Override
@Override
public
TabQywxTagRelation
getQywxTagRelationByMemberTagId
(
String
memberTagId
)
{
public
List
<
TabQywxTagRelation
>
listQywxTagRelationByMemberTagId
(
String
wxEnterpriseId
,
String
memberTagId
)
{
return
null
;
return
qywxTagRelationMapper
.
listByMemberTagId
(
wxEnterpriseId
,
memberTagId
);
}
@Override
public
List
<
TabQywxTagRelation
>
listQywxTagRelationByQywxTagId
(
String
wxEnterpriseId
,
String
qywxTagId
)
{
List
<
TabQywxTagRelation
>
ret
=
qywxTagRelationMapper
.
listByQywxTagId
(
wxEnterpriseId
,
qywxTagId
);
return
ret
;
}
@Override
public
TabQywxTagItem
getQywxTagItemByQywxItemKey
(
String
wxEnterpriseId
,
String
qywxTagKey
)
{
return
qywxTagItemMapper
.
getByQywxTagKey
(
wxEnterpriseId
,
qywxTagKey
);
}
@Override
public
boolean
delQywxTagItemById
(
String
wxEnterpriseId
,
String
id
)
{
TabQywxTagItem
item
=
new
TabQywxTagItem
();
item
.
setQywxTagItemId
(
id
);
item
.
setUpdateTime
(
new
Date
());
item
.
setStatusFlag
(
0
);
qywxTagItemMapper
.
updateByPrimaryKey
(
item
);
return
true
;
}
}
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/QywxTagApiServiceImpl.java
View file @
ede972c4
...
@@ -7,6 +7,7 @@ import com.gic.haoban.manage.api.dto.*;
...
@@ -7,6 +7,7 @@ import com.gic.haoban.manage.api.dto.*;
import
com.gic.haoban.manage.api.enums.QywxTagRelationTypeEnum
;
import
com.gic.haoban.manage.api.enums.QywxTagRelationTypeEnum
;
import
com.gic.haoban.manage.api.service.QywxTagApiService
;
import
com.gic.haoban.manage.api.service.QywxTagApiService
;
import
com.gic.haoban.manage.service.config.Config
;
import
com.gic.haoban.manage.service.config.Config
;
import
com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise
;
import
com.gic.haoban.manage.service.entity.TabQywxTag
;
import
com.gic.haoban.manage.service.entity.TabQywxTag
;
import
com.gic.haoban.manage.service.entity.TabQywxTagItem
;
import
com.gic.haoban.manage.service.entity.TabQywxTagItem
;
import
com.gic.haoban.manage.service.entity.TabQywxTagRelation
;
import
com.gic.haoban.manage.service.entity.TabQywxTagRelation
;
...
@@ -18,6 +19,7 @@ import com.gic.wechat.api.dto.qywx.response.QywxGetCorpTagListDTO;
...
@@ -18,6 +19,7 @@ import com.gic.wechat.api.dto.qywx.response.QywxGetCorpTagListDTO;
import
com.gic.wechat.api.dto.qywx.response.QywxResponseDTO
;
import
com.gic.wechat.api.dto.qywx.response.QywxResponseDTO
;
import
com.gic.wechat.api.service.qywx.QywxSuiteApiService
;
import
com.gic.wechat.api.service.qywx.QywxSuiteApiService
;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -99,7 +101,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
...
@@ -99,7 +101,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
//保存关联关系
//保存关联关系
saveRelation
(
wxEnterpriseId
,
enterpriseId
,
infoDTO
,
items
,
savePair
);
saveRelation
(
wxEnterpriseId
,
enterpriseId
,
infoDTO
,
items
,
savePair
);
//todo 后续处理 比如同步会员标签等
//todo 后续处理 比如同步会员标签等
操作标签项的会员同步过来
}
}
...
@@ -117,16 +119,19 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
...
@@ -117,16 +119,19 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
List
<
TabQywxTagItem
>
tabQywxTagItems
=
localQywxTagPair
.
getRight
();
List
<
TabQywxTagItem
>
tabQywxTagItems
=
localQywxTagPair
.
getRight
();
List
<
TabQywxTagRelation
>
saveRelationList
=
new
ArrayList
<>();
List
<
TabQywxTagRelation
>
saveRelationList
=
new
ArrayList
<>();
TabQywxTagRelation
groupRelation
=
new
TabQywxTagRelation
();
//如果存在qywxGroupKey 说明已经创建过了
groupRelation
.
setEnterpriseId
(
enterpriseId
);
if
(
StringUtils
.
isBlank
(
infoDTO
.
getQywxGroupKey
()))
{
groupRelation
.
setMemberTagId
(
infoDTO
.
getQywxGroupKey
());
TabQywxTagRelation
groupRelation
=
new
TabQywxTagRelation
();
groupRelation
.
setQywxTagId
(
groupKey
.
getQywxTagId
());
groupRelation
.
setEnterpriseId
(
enterpriseId
);
groupRelation
.
setRelationType
(
QywxTagRelationTypeEnum
.
TAG_GROUP
.
getType
());
groupRelation
.
setMemberTagId
(
infoDTO
.
getMemberTagId
());
groupRelation
.
setStatusFlag
(
1
);
groupRelation
.
setQywxTagId
(
groupKey
.
getQywxTagId
());
groupRelation
.
setSyncFlag
(
1
);
groupRelation
.
setRelationType
(
QywxTagRelationTypeEnum
.
TAG_GROUP
.
getType
());
groupRelation
.
setQywxTagRelationId
(
ToolUtil
.
randomUUID
());
groupRelation
.
setStatusFlag
(
1
);
groupRelation
.
setWxEnterpriseId
(
wxEnterpriseId
);
groupRelation
.
setSyncFlag
(
1
);
saveRelationList
.
add
(
groupRelation
);
groupRelation
.
setQywxTagRelationId
(
ToolUtil
.
randomUUID
());
groupRelation
.
setWxEnterpriseId
(
wxEnterpriseId
);
saveRelationList
.
add
(
groupRelation
);
}
List
<
TabQywxTagRelation
>
itemList
=
tabQywxTagItems
.
stream
().
map
(
tab
->
{
List
<
TabQywxTagRelation
>
itemList
=
tabQywxTagItems
.
stream
().
map
(
tab
->
{
QywxTagItemDTO
orgItem
=
orgMap
.
get
(
tab
.
getQywxTagName
());
QywxTagItemDTO
orgItem
=
orgMap
.
get
(
tab
.
getQywxTagName
());
TabQywxTagRelation
itemRelation
=
new
TabQywxTagRelation
();
TabQywxTagRelation
itemRelation
=
new
TabQywxTagRelation
();
...
@@ -136,7 +141,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
...
@@ -136,7 +141,7 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
itemRelation
.
setStatusFlag
(
1
);
itemRelation
.
setStatusFlag
(
1
);
itemRelation
.
setRelationType
(
QywxTagRelationTypeEnum
.
TAG_ITEM
.
getType
());
itemRelation
.
setRelationType
(
QywxTagRelationTypeEnum
.
TAG_ITEM
.
getType
());
itemRelation
.
setQywxTagId
(
groupKey
.
getQywxTagId
());
itemRelation
.
setQywxTagId
(
groupKey
.
getQywxTagId
());
itemRelation
.
setMemberTagId
(
infoDTO
.
get
QywxGroupKey
());
itemRelation
.
setMemberTagId
(
infoDTO
.
get
MemberTagId
());
itemRelation
.
setEnterpriseId
(
enterpriseId
);
itemRelation
.
setEnterpriseId
(
enterpriseId
);
itemRelation
.
setQywxTagItemId
(
tab
.
getQywxTagItemId
());
itemRelation
.
setQywxTagItemId
(
tab
.
getQywxTagItemId
());
itemRelation
.
setTagItemId
(
orgItem
.
getQywxTagKey
());
itemRelation
.
setTagItemId
(
orgItem
.
getQywxTagKey
());
...
@@ -158,11 +163,13 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
...
@@ -158,11 +163,13 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
QywxTagGroupDTO
qywxTagGroupDTO
=
new
QywxTagGroupDTO
();
QywxTagGroupDTO
qywxTagGroupDTO
=
new
QywxTagGroupDTO
();
qywxTagGroupDTO
.
setGroupName
(
"GIC"
+
infoDTO
.
getQywxGroupName
());
qywxTagGroupDTO
.
setGroupName
(
"GIC"
+
infoDTO
.
getQywxGroupName
());
qywxTagGroupDTO
.
setOrder
(
infoDTO
.
getOrder
());
qywxTagGroupDTO
.
setOrder
(
infoDTO
.
getOrder
());
qywxTagGroupDTO
.
setGroupId
(
infoDTO
.
getQywxGroupKey
());
List
<
QywxTagDTO
>
tagItems
=
items
.
stream
().
map
(
item
->
{
List
<
QywxTagDTO
>
tagItems
=
items
.
stream
().
map
(
item
->
{
QywxTagDTO
qywxTagDTO
=
new
QywxTagDTO
();
QywxTagDTO
qywxTagDTO
=
new
QywxTagDTO
();
qywxTagDTO
.
setName
(
item
.
getQywxTagName
());
qywxTagDTO
.
setName
(
item
.
getQywxTagName
());
qywxTagDTO
.
setOrder
(
item
.
getOrder
());
qywxTagDTO
.
setOrder
(
item
.
getOrder
());
qywxTagDTO
.
setId
(
item
.
getQywxTagKey
());
return
qywxTagDTO
;
return
qywxTagDTO
;
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
qywxTagGroupDTO
.
setTag
(
tagItems
);
qywxTagGroupDTO
.
setTag
(
tagItems
);
...
@@ -173,13 +180,18 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
...
@@ -173,13 +180,18 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
@Override
@Override
public
void
closeSync
(
String
wxEnterpriseId
,
String
memberTagId
)
{
public
void
closeSync
(
String
wxEnterpriseId
,
String
memberTagId
)
{
WxEnterpriseDTO
wxEnterpriseDTO
=
wxEnterpriseService
.
selectById
(
wxEnterpriseId
);
WxEnterpriseDTO
wxEnterpriseDTO
=
wxEnterpriseService
.
selectById
(
wxEnterpriseId
);
List
<
TabQywxTagRelation
>
tagRelations
=
qywxTagService
.
listQywxTagRelationByMemberTagId
(
wxEnterpriseId
,
memberTagId
);
if
(
CollectionUtils
.
isEmpty
(
tagRelations
))
{
return
;
}
TabQywxTag
tabQywxTag
=
qywxTagService
.
getQywxTagByQywxTagId
(
wxEnterpriseId
,
tagRelations
.
get
(
0
).
getQywxTagId
());
//关闭同步
//关闭同步
qywxTagService
.
closeSync
(
wxEnterpriseId
,
memberTagId
);
qywxTagService
.
closeSync
(
wxEnterpriseId
,
memberTagId
);
List
<
String
>
delIds
=
new
ArrayList
<>();
List
<
String
>
delIds
=
new
ArrayList
<>();
delIds
.
add
(
memberTagId
);
delIds
.
add
(
memberTagId
);
QywxResponseDTO
responseDTO
=
qywxSuiteApiService
.
delCorpTag
(
wxEnterpriseDTO
.
getCorpid
(),
config
.
getWxSuiteid
(),
delIds
,
0
);
QywxResponseDTO
responseDTO
=
qywxSuiteApiService
.
delCorpTag
(
wxEnterpriseDTO
.
getCorpid
(),
config
.
getWxSuiteid
(),
delIds
,
0
);
if
(
responseDTO
.
getErrcode
()
==
0
)
{
if
(
responseDTO
.
getErrcode
()
==
0
)
{
qywxTagService
.
delQywxTag
(
memberTagId
,
wxEnterpriseId
);
qywxTagService
.
delQywxTag
(
tabQywxTag
.
getQywxGroupKey
()
,
wxEnterpriseId
);
}
}
}
}
...
@@ -193,15 +205,232 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
...
@@ -193,15 +205,232 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
@Override
@Override
public
void
addQywxTag
(
QywxTagCallbackDTO
callbackDTO
)
{
public
void
addQywxTag
(
QywxTagCallbackDTO
callbackDTO
)
{
logger
.
info
(
"企业微信新增标签回调:{}"
,
JSONObject
.
toJSONString
(
callbackDTO
));
logger
.
info
(
"企业微信新增标签回调:{}"
,
JSONObject
.
toJSONString
(
callbackDTO
));
if
(!
config
.
getSuiteId
().
equals
(
callbackDTO
.
getSuiteId
()))
{
logger
.
info
(
"非第三方回调"
);
return
;
}
TabHaobanWxEnterprise
wxEnterpriseDto
=
wxEnterpriseService
.
getEnterpriseBycorpId
(
callbackDTO
.
getAuthCorpId
());
if
(
null
==
wxEnterpriseDto
)
{
logger
.
info
(
"企业不存在:{}"
,
callbackDTO
.
getAuthCorpId
());
return
;
}
QywxTagRelationTypeEnum
relationTypeEnum
=
QywxTagRelationTypeEnum
.
getByTagType
(
callbackDTO
.
getTagType
());
//标签组
if
(
relationTypeEnum
.
getTagType
()
==
QywxTagRelationTypeEnum
.
TAG_GROUP
.
getTagType
())
{
TabQywxTag
qywxGroupKey
=
qywxTagService
.
getQywxTagByQywxGroupKey
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
callbackDTO
.
getTagId
());
if
(
null
==
qywxGroupKey
)
{
logger
.
info
(
"原型不存在,不需要处理"
);
return
;
}
List
<
TabQywxTagRelation
>
relations
=
qywxTagService
.
listQywxTagRelationByQywxTagId
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
qywxGroupKey
.
getQywxTagId
());
//没有同步的关系 删除保存企业微信标签
if
(
CollectionUtils
.
isEmpty
(
relations
))
{
logger
.
info
(
"删除保存的企业微信标签"
);
qywxTagService
.
delQywxTag
(
callbackDTO
.
getTagId
(),
wxEnterpriseDto
.
getWxEnterpriseId
());
return
;
}
List
<
String
>
groupIds
=
new
ArrayList
<>();
groupIds
.
add
(
callbackDTO
.
getTagId
());
qywxSuiteApiService
.
delCorpTag
(
wxEnterpriseDto
.
getCorpid
(),
config
.
getWxSuiteid
(),
groupIds
,
QywxTagRelationTypeEnum
.
TAG_GROUP
.
getType
());
//标签项
}
else
if
(
relationTypeEnum
.
getTagType
()
==
QywxTagRelationTypeEnum
.
TAG_ITEM
.
getTagType
())
{
TabQywxTagItem
qywxTagItem
=
qywxTagService
.
getQywxTagItemByQywxItemKey
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
callbackDTO
.
getTagId
());
if
(
null
==
qywxTagItem
)
{
logger
.
info
(
"没有关联,无需操作"
);
return
;
}
List
<
TabQywxTagRelation
>
relations
=
qywxTagService
.
listQywxTagRelationByMemberTagId
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
qywxTagItem
.
getQywxTagId
());
if
(
CollectionUtils
.
isEmpty
(
relations
))
{
logger
.
info
(
"直接删除标签项"
);
qywxTagService
.
delQywxTagItemById
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
qywxTagItem
.
getQywxTagItemId
());
return
;
}
List
<
String
>
items
=
new
ArrayList
<>();
items
.
add
(
callbackDTO
.
getTagId
());
qywxSuiteApiService
.
delCorpTag
(
wxEnterpriseDto
.
getCorpid
(),
config
.
getWxSuiteid
(),
items
,
QywxTagRelationTypeEnum
.
TAG_ITEM
.
getType
());
}
}
}
@Override
@Override
public
void
delQywxTag
(
QywxTagCallbackDTO
callbackDTO
)
{
public
void
delQywxTag
(
QywxTagCallbackDTO
callbackDTO
)
{
logger
.
info
(
"企业微信删除标签回调:{}"
,
JSONObject
.
toJSONString
(
callbackDTO
));
logger
.
info
(
"企业微信删除标签回调:{}"
,
JSONObject
.
toJSONString
(
callbackDTO
));
if
(!
config
.
getSuiteId
().
equals
(
callbackDTO
.
getSuiteId
()))
{
logger
.
info
(
"非第三方回调"
);
return
;
}
TabHaobanWxEnterprise
wxEnterpriseDto
=
wxEnterpriseService
.
getEnterpriseBycorpId
(
callbackDTO
.
getAuthCorpId
());
if
(
null
==
wxEnterpriseDto
)
{
logger
.
info
(
"企业不存在:{}"
,
callbackDTO
.
getAuthCorpId
());
return
;
}
QywxTagRelationTypeEnum
relationTypeEnum
=
QywxTagRelationTypeEnum
.
getByTagType
(
callbackDTO
.
getTagType
());
//标签组
if
(
relationTypeEnum
.
getTagType
()
==
QywxTagRelationTypeEnum
.
TAG_GROUP
.
getTagType
())
{
TabQywxTag
qywxGroupKey
=
qywxTagService
.
getQywxTagByQywxGroupKey
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
callbackDTO
.
getTagId
());
if
(
null
==
qywxGroupKey
)
{
logger
.
info
(
"原型不存在,不需要处理"
);
return
;
}
List
<
TabQywxTagRelation
>
relations
=
qywxTagService
.
listQywxTagRelationByQywxTagId
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
qywxGroupKey
.
getQywxTagId
());
//没有同步的关系 删除保存企业微信标签
if
(
CollectionUtils
.
isEmpty
(
relations
))
{
logger
.
info
(
"删除保存的企业微信标签"
);
qywxTagService
.
delQywxTag
(
callbackDTO
.
getTagId
(),
wxEnterpriseDto
.
getWxEnterpriseId
());
return
;
}
//存在同步关系 需要回写回去
List
<
TabQywxTagItem
>
tabQywxTagItems
=
qywxTagService
.
listByQywxTagId
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
qywxGroupKey
.
getQywxTagId
());
this
.
reSyncTagGroupBack
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
relations
,
qywxGroupKey
,
tabQywxTagItems
);
//标签项
}
else
if
(
relationTypeEnum
.
getTagType
()
==
QywxTagRelationTypeEnum
.
TAG_ITEM
.
getTagType
())
{
TabQywxTagItem
qywxTagItem
=
qywxTagService
.
getQywxTagItemByQywxItemKey
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
callbackDTO
.
getTagId
());
if
(
null
==
qywxTagItem
)
{
logger
.
info
(
"没有关联,无需操作"
);
return
;
}
List
<
TabQywxTagRelation
>
relations
=
qywxTagService
.
listQywxTagRelationByMemberTagId
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
qywxTagItem
.
getQywxTagId
());
if
(
CollectionUtils
.
isEmpty
(
relations
))
{
logger
.
info
(
"直接删除标签项"
);
qywxTagService
.
delQywxTagItemById
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
qywxTagItem
.
getQywxTagItemId
());
return
;
}
//同步
reSyncQywxTagItem
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
relations
,
qywxTagItem
);
}
}
/**
* 重新同步
*
* @param wxEnterpriseId
* @param relations
* @param qywxGroupKey
* @param tabQywxTagItems
*/
private
void
reSyncTagGroupBack
(
String
wxEnterpriseId
,
List
<
TabQywxTagRelation
>
relations
,
TabQywxTag
qywxGroupKey
,
List
<
TabQywxTagItem
>
tabQywxTagItems
)
{
TabQywxTagRelation
tagRelation
=
relations
.
get
(
0
);
String
enterpriseId
=
tagRelation
.
getEnterpriseId
();
String
memberTagId
=
tagRelation
.
getMemberTagId
();
//关闭同步
qywxTagService
.
closeSync
(
wxEnterpriseId
,
memberTagId
);
qywxTagService
.
delQywxTag
(
qywxGroupKey
.
getQywxGroupKey
(),
wxEnterpriseId
);
//重新同步
Map
<
String
,
TabQywxTagRelation
>
relationMap
=
relations
.
stream
().
collect
(
Collectors
.
toMap
(
dto
->
{
if
(
dto
.
getRelationType
()
==
QywxTagRelationTypeEnum
.
TAG_GROUP
.
getType
())
{
return
dto
.
getQywxTagId
();
}
else
{
return
dto
.
getQywxTagItemId
();
}
},
dto
->
dto
));
QywxTagInfoDTO
qywxTagInfoDTO
=
new
QywxTagInfoDTO
();
qywxTagInfoDTO
.
setQywxGroupKey
(
memberTagId
);
qywxTagInfoDTO
.
setQywxGroupName
(
qywxGroupKey
.
getQywxGroupName
());
qywxTagInfoDTO
.
setWxEnterpriseId
(
qywxGroupKey
.
getWxEnterpriseId
());
List
<
QywxTagItemDTO
>
items
=
tabQywxTagItems
.
stream
().
map
(
item
->
{
TabQywxTagRelation
relation
=
relationMap
.
get
(
item
.
getQywxTagItemId
());
QywxTagItemDTO
mid
=
new
QywxTagItemDTO
();
mid
.
setQywxTagKey
(
relation
.
getTagItemId
());
mid
.
setQywxTagName
(
item
.
getQywxTagName
());
return
mid
;
}).
collect
(
Collectors
.
toList
());
//同步回去
this
.
syncTagToQywx
(
wxEnterpriseId
,
enterpriseId
,
qywxTagInfoDTO
,
items
);
}
/**
* 同步标签项
*
* @param wxEnterpriseId
* @param qywxTagItem
*/
private
void
reSyncQywxTagItem
(
String
wxEnterpriseId
,
List
<
TabQywxTagRelation
>
relations
,
TabQywxTagItem
qywxTagItem
)
{
//删除标签
qywxTagService
.
delQywxTagItemById
(
wxEnterpriseId
,
qywxTagItem
.
getQywxTagItemId
());
//同步标签项
TabQywxTag
qywxGroupKey
=
qywxTagService
.
getQywxTagByQywxGroupKey
(
wxEnterpriseId
,
qywxTagItem
.
getQywxGroupKey
());
//各自关联关系
TabQywxTagRelation
groupRelation
=
relations
.
stream
().
filter
(
dto
->
dto
.
getRelationType
()
==
QywxTagRelationTypeEnum
.
TAG_GROUP
.
getType
()).
findFirst
().
get
();
TabQywxTagRelation
itemRelation
=
relations
.
stream
().
filter
(
dto
->
(
dto
.
getRelationType
()
==
QywxTagRelationTypeEnum
.
TAG_ITEM
.
getType
()
&&
qywxTagItem
.
getQywxTagItemId
().
equals
(
dto
.
getQywxTagItemId
()))).
findFirst
().
orElse
(
null
);
QywxTagInfoDTO
qywxTagInfoDTO
=
new
QywxTagInfoDTO
();
qywxTagInfoDTO
.
setWxEnterpriseId
(
wxEnterpriseId
);
qywxTagInfoDTO
.
setMemberTagId
(
groupRelation
.
getMemberTagId
());
qywxTagInfoDTO
.
setQywxGroupKey
(
qywxGroupKey
.
getQywxGroupKey
());
qywxTagInfoDTO
.
setOrder
(
qywxGroupKey
.
getOrder
());
List
<
QywxTagItemDTO
>
itemList
=
new
ArrayList
<>();
QywxTagItemDTO
qywxTagItemDTO
=
new
QywxTagItemDTO
();
qywxTagItemDTO
.
setMemberTagItemId
(
itemRelation
.
getTagItemId
());
qywxTagItemDTO
.
setQywxTagName
(
qywxTagItem
.
getQywxTagName
());
qywxTagItemDTO
.
setWxEnterpriseId
(
wxEnterpriseId
);
qywxTagItemDTO
.
setOrder
(
qywxTagItem
.
getOrder
());
itemList
.
add
(
qywxTagItemDTO
);
//同步
this
.
syncTagToQywx
(
wxEnterpriseId
,
groupRelation
.
getEnterpriseId
(),
qywxTagInfoDTO
,
itemList
);
}
}
@Override
@Override
public
void
editQywxTag
(
QywxTagCallbackDTO
callbackDTO
)
{
public
void
editQywxTag
(
QywxTagCallbackDTO
callbackDTO
)
{
logger
.
info
(
"企业微信修改标签回调:{}"
,
JSONObject
.
toJSONString
(
callbackDTO
));
logger
.
info
(
"企业微信修改标签回调:{}"
,
JSONObject
.
toJSONString
(
callbackDTO
));
if
(!
config
.
getSuiteId
().
equals
(
callbackDTO
.
getSuiteId
()))
{
logger
.
info
(
"非第三方回调"
);
return
;
}
TabHaobanWxEnterprise
wxEnterpriseDto
=
wxEnterpriseService
.
getEnterpriseBycorpId
(
callbackDTO
.
getAuthCorpId
());
if
(
null
==
wxEnterpriseDto
)
{
logger
.
info
(
"企业不存在:{}"
,
callbackDTO
.
getAuthCorpId
());
return
;
}
QywxTagRelationTypeEnum
relationTypeEnum
=
QywxTagRelationTypeEnum
.
getByTagType
(
callbackDTO
.
getTagType
());
//标签组
if
(
relationTypeEnum
.
getTagType
()
==
QywxTagRelationTypeEnum
.
TAG_GROUP
.
getTagType
())
{
TabQywxTag
qywxGroupKey
=
qywxTagService
.
getQywxTagByQywxGroupKey
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
callbackDTO
.
getTagId
());
if
(
null
==
qywxGroupKey
)
{
logger
.
info
(
"原型不存在,不需要处理"
);
return
;
}
List
<
TabQywxTagRelation
>
relations
=
qywxTagService
.
listQywxTagRelationByQywxTagId
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
qywxGroupKey
.
getQywxTagId
());
//没有同步的关系 删除保存企业微信标签
if
(
CollectionUtils
.
isEmpty
(
relations
))
{
logger
.
info
(
"删除保存的企业微信标签"
);
qywxTagService
.
delQywxTag
(
callbackDTO
.
getTagId
(),
wxEnterpriseDto
.
getWxEnterpriseId
());
return
;
}
//名称同步回去
QywxTagDTO
qywxTagDTO
=
new
QywxTagDTO
();
qywxTagDTO
.
setId
(
callbackDTO
.
getTagId
());
qywxTagDTO
.
setName
(
qywxGroupKey
.
getQywxGroupName
());
qywxTagDTO
.
setOrder
(
qywxGroupKey
.
getOrder
());
qywxSuiteApiService
.
editCorpTagNameOrOrder
(
wxEnterpriseDto
.
getCorpid
(),
config
.
getWxSuiteid
(),
qywxTagDTO
);
//标签项
}
else
if
(
relationTypeEnum
.
getTagType
()
==
QywxTagRelationTypeEnum
.
TAG_ITEM
.
getTagType
())
{
TabQywxTagItem
qywxTagItem
=
qywxTagService
.
getQywxTagItemByQywxItemKey
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
callbackDTO
.
getTagId
());
if
(
null
==
qywxTagItem
)
{
logger
.
info
(
"没有关联,无需操作"
);
return
;
}
List
<
TabQywxTagRelation
>
relations
=
qywxTagService
.
listQywxTagRelationByMemberTagId
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
qywxTagItem
.
getQywxTagId
());
if
(
CollectionUtils
.
isEmpty
(
relations
))
{
logger
.
info
(
"直接删除标签项"
);
qywxTagService
.
delQywxTagItemById
(
wxEnterpriseDto
.
getWxEnterpriseId
(),
qywxTagItem
.
getQywxTagItemId
());
return
;
}
//名称同步回去
QywxTagDTO
qywxTagDTO
=
new
QywxTagDTO
();
qywxTagDTO
.
setId
(
callbackDTO
.
getTagId
());
qywxTagDTO
.
setName
(
qywxTagItem
.
getQywxTagName
());
qywxTagDTO
.
setOrder
(
qywxTagItem
.
getOrder
());
qywxSuiteApiService
.
editCorpTagNameOrOrder
(
wxEnterpriseDto
.
getCorpid
(),
config
.
getWxSuiteid
(),
qywxTagDTO
);
}
}
}
}
}
haoban-manage3-service/src/main/resources/mapper/QywxTagItemMapper.xml
View file @
ede972c4
...
@@ -178,4 +178,13 @@
...
@@ -178,4 +178,13 @@
and wx_enterprise_id=#{wxEnterpriseId}
and wx_enterprise_id=#{wxEnterpriseId}
</update>
</update>
<select
id=
"getByQywxTagKey"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_haoban_qywx_tag_item
where qywx_tag_key = #{qywxTagKey}
and status_flag=1
and wx_enterprise_id=#{wxEnterpriseId}
</select>
</mapper>
</mapper>
\ No newline at end of file
haoban-manage3-service/src/main/resources/mapper/QywxTagRelationMapper.xml
View file @
ede972c4
...
@@ -196,13 +196,14 @@
...
@@ -196,13 +196,14 @@
and status_flag=1
and status_flag=1
</select>
</select>
<select
id=
"listByTagId"
parameterType=
"java.lang.String"
resultMap=
"BaseResultMap"
>
<select
id=
"listBy
Member
TagId"
parameterType=
"java.lang.String"
resultMap=
"BaseResultMap"
>
select
select
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from tab_haoban_qywx_tag_relation
from tab_haoban_qywx_tag_relation
where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
and member_tag_id = #{memberTagId,jdbcType=VARCHAR}
and member_tag_id = #{memberTagId,jdbcType=VARCHAR}
and status_flag=1
and status_flag=1
and sync_flag=1
</select>
</select>
<update
id=
"delByMemberTagId"
>
<update
id=
"delByMemberTagId"
>
update tab_haoban_qywx_tag_relation
update tab_haoban_qywx_tag_relation
...
@@ -213,4 +214,14 @@
...
@@ -213,4 +214,14 @@
and member_tag_id = #{memberTagId,jdbcType=VARCHAR}
and member_tag_id = #{memberTagId,jdbcType=VARCHAR}
and status_flag=1
and status_flag=1
</update>
</update>
<select
id=
"listByQywxTagId"
parameterType=
"java.lang.String"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_haoban_qywx_tag_relation
where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
and qywx_tag_id = #{qywxTagId,jdbcType=VARCHAR}
and status_flag=1
and sync_flag=1
</select>
</mapper>
</mapper>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment