Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 45d8562c
authored
Sep 17, 2020
by
HaoN
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
企业微信客户相关接口提交
1 parent
2e964b4b
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
118 additions
and
97 deletions
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerController.java
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTagController.java
linkwe-common/src/main/java/com/linkwechat/common/constant/WeConstans.java
linkwe-framework/src/main/java/com/linkwechat/framework/handler/StringArrayJoinTypeHandler.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeCustomerDto.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeFollowUserDto.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerServiceImpl.java
linkwe-wecom/src/main/resources/mapper/wecom/WeUserMapper.xml
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCustomerController.java
View file @
45d8562
...
@@ -3,6 +3,7 @@ package com.linkwechat.web.controller.wecom;
...
@@ -3,6 +3,7 @@ package com.linkwechat.web.controller.wecom;
import
java.util.List
;
import
java.util.List
;
import
com.linkwechat.common.annotation.Log
;
import
com.linkwechat.common.annotation.Log
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.core.controller.BaseController
;
import
com.linkwechat.common.core.controller.BaseController
;
import
com.linkwechat.common.core.domain.AjaxResult
;
import
com.linkwechat.common.core.domain.AjaxResult
;
import
com.linkwechat.common.core.page.TableDataInfo
;
import
com.linkwechat.common.core.page.TableDataInfo
;
...
@@ -69,16 +70,7 @@ public class WeCustomerController extends BaseController
...
@@ -69,16 +70,7 @@ public class WeCustomerController extends BaseController
return
AjaxResult
.
success
(
weCustomerService
.
selectWeCustomerById
(
id
));
return
AjaxResult
.
success
(
weCustomerService
.
selectWeCustomerById
(
id
));
}
}
/**
* 新增企业微信客户
*/
@PreAuthorize
(
"@ss.hasPermi('wecom:customer:add')"
)
@Log
(
title
=
"企业微信客户"
,
businessType
=
BusinessType
.
INSERT
)
@PostMapping
public
AjaxResult
add
(
@RequestBody
WeCustomer
weCustomer
)
{
return
toAjax
(
weCustomerService
.
insertWeCustomer
(
weCustomer
));
}
/**
/**
* 修改企业微信客户
* 修改企业微信客户
...
@@ -91,17 +83,6 @@ public class WeCustomerController extends BaseController
...
@@ -91,17 +83,6 @@ public class WeCustomerController extends BaseController
return
toAjax
(
weCustomerService
.
updateWeCustomer
(
weCustomer
));
return
toAjax
(
weCustomerService
.
updateWeCustomer
(
weCustomer
));
}
}
/**
* 删除企业微信客户
*/
@PreAuthorize
(
"@ss.hasPermi('wecom:customer:remove')"
)
@Log
(
title
=
"企业微信客户"
,
businessType
=
BusinessType
.
DELETE
)
@DeleteMapping
(
"/{ids}"
)
public
AjaxResult
remove
(
@PathVariable
Long
[]
ids
)
{
return
toAjax
(
weCustomerService
.
deleteWeCustomerByIds
(
ids
));
}
/**
/**
* 客户同步接口
* 客户同步接口
...
@@ -114,7 +95,8 @@ public class WeCustomerController extends BaseController
...
@@ -114,7 +95,8 @@ public class WeCustomerController extends BaseController
weCustomerService
.
synchWeCustomer
();
weCustomerService
.
synchWeCustomer
();
return
null
;
return
AjaxResult
.
success
(
WeConstans
.
SYNCH_TIP
);
}
}
}
}
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeTagController.java
View file @
45d8562
package
com
.
linkwechat
.
web
.
controller
.
wecom
;
package
com
.
linkwechat
.
web
.
controller
.
wecom
;
import
java.util.List
;
import
com.linkwechat.common.annotation.Log
;
import
com.linkwechat.common.annotation.Log
;
import
com.linkwechat.common.core.controller.BaseController
;
import
com.linkwechat.common.core.controller.BaseController
;
import
com.linkwechat.common.core.domain.AjaxResult
;
import
com.linkwechat.common.core.domain.AjaxResult
;
import
com.linkwechat.common.core.page.TableDataInfo
;
import
com.linkwechat.common.enums.BusinessType
;
import
com.linkwechat.common.enums.BusinessType
;
import
com.linkwechat.common.utils.poi.ExcelUtil
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.linkwechat.wecom.domain.WeTag
;
import
com.linkwechat.wecom.domain.WeTag
;
import
com.linkwechat.wecom.service.IWeTagService
;
import
com.linkwechat.wecom.service.IWeTagService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
/**
/**
* 企业微信标签Controller
* 企业微信标签Controller
...
@@ -39,35 +28,13 @@ public class WeTagController extends BaseController
...
@@ -39,35 +28,13 @@ public class WeTagController extends BaseController
*/
*/
@PreAuthorize
(
"@ss.hasPermi('wecom:tag:list')"
)
@PreAuthorize
(
"@ss.hasPermi('wecom:tag:list')"
)
@GetMapping
(
"/list"
)
@GetMapping
(
"/list"
)
public
TableDataInfo
list
(
WeTag
weTag
)
public
AjaxResult
list
()
{
startPage
();
List
<
WeTag
>
list
=
weTagService
.
selectWeTagList
(
weTag
);
return
getDataTable
(
list
);
}
/**
* 导出企业微信标签列表
*/
@PreAuthorize
(
"@ss.hasPermi('wecom:tag:export')"
)
@Log
(
title
=
"企业微信标签"
,
businessType
=
BusinessType
.
EXPORT
)
@GetMapping
(
"/export"
)
public
AjaxResult
export
(
WeTag
weTag
)
{
{
List
<
WeTag
>
list
=
weTagService
.
selectWeTagList
(
weTag
);
return
AjaxResult
.
success
(
ExcelUtil
<
WeTag
>
util
=
new
ExcelUtil
<
WeTag
>(
WeTag
.
class
);
weTagService
.
selectWeTagList
(
new
WeTag
())
return
util
.
exportExcel
(
list
,
"tag"
);
);
}
}
/**
* 获取企业微信标签详细信息
*/
@PreAuthorize
(
"@ss.hasPermi('wecom:tag:query')"
)
@GetMapping
(
value
=
"/{id}"
)
public
AjaxResult
getInfo
(
@PathVariable
(
"id"
)
Long
id
)
{
return
AjaxResult
.
success
(
weTagService
.
selectWeTagById
(
id
));
}
/**
/**
* 新增企业微信标签
* 新增企业微信标签
...
...
linkwe-common/src/main/java/com/linkwechat/common/constant/WeConstans.java
View file @
45d8562
...
@@ -41,4 +41,10 @@ public class WeConstans {
...
@@ -41,4 +41,10 @@ public class WeConstans {
* 企业微信通讯录用户停用
* 企业微信通讯录用户停用
*/
*/
public
static
final
Integer
WE_USER_STOP
=
0
;
public
static
final
Integer
WE_USER_STOP
=
0
;
/**
* 同步功能提示语
*/
public
static
final
String
SYNCH_TIP
=
"后台开始同步数据,请稍后关注进度"
;
}
}
linkwe-framework/src/main/java/com/linkwechat/framework/handler/StringArrayJoinTypeHandler.java
View file @
45d8562
...
@@ -34,15 +34,16 @@ public class StringArrayJoinTypeHandler extends BaseTypeHandler<String[]> {
...
@@ -34,15 +34,16 @@ public class StringArrayJoinTypeHandler extends BaseTypeHandler<String[]> {
public
String
[]
getNullableResult
(
ResultSet
rs
,
String
columnName
)
throws
SQLException
{
public
String
[]
getNullableResult
(
ResultSet
rs
,
String
columnName
)
throws
SQLException
{
String
reString
=
rs
.
getString
(
columnName
);
String
reString
=
rs
.
getString
(
columnName
);
if
(
reString
!=
null
&&
reString
.
length
()
>
0
)
{
if
(
reString
!=
null
&&
reString
.
length
()
>
0
)
{
String
[]
arrs
=
reString
.
split
(
split
);
//
String[] arrs = reString.split(split);
List
<
Long
>
idList
=
new
ArrayList
<>(
arrs
.
length
);
// List<Long> idList = new ArrayList<>(arrs.length);
for
(
String
id
:
arrs
)
{
// for (String id : arrs) {
if
(
id
!=
null
&&
id
.
length
()
>
0
)
{
// if (id != null && id.length() > 0) {
idList
.
add
(
Long
.
valueOf
(
id
));
// idList.add(Long.valueOf(id));
}
// }
}
// }
return
idList
.
toArray
(
new
String
[
idList
.
size
()]);
// return idList.toArray(new String[idList.size()]);
return
reString
.
split
(
split
);
}
}
return
null
;
return
null
;
}
}
...
@@ -51,15 +52,15 @@ public class StringArrayJoinTypeHandler extends BaseTypeHandler<String[]> {
...
@@ -51,15 +52,15 @@ public class StringArrayJoinTypeHandler extends BaseTypeHandler<String[]> {
public
String
[]
getNullableResult
(
ResultSet
rs
,
int
columnIndex
)
throws
SQLException
{
public
String
[]
getNullableResult
(
ResultSet
rs
,
int
columnIndex
)
throws
SQLException
{
String
reString
=
rs
.
getString
(
columnIndex
);
String
reString
=
rs
.
getString
(
columnIndex
);
if
(
reString
!=
null
&&
reString
.
length
()
>
0
)
{
if
(
reString
!=
null
&&
reString
.
length
()
>
0
)
{
String
[]
arrs
=
reString
.
split
(
split
);
//
String[] arrs = reString.split(split);
List
<
Integer
>
idList
=
new
ArrayList
<>(
arrs
.
length
);
//
List<Integer> idList = new ArrayList<>(arrs.length);
for
(
String
id
:
arrs
)
{
//
for (String id : arrs) {
if
(
id
!=
null
&&
id
.
length
()
>
0
)
{
//
if (id != null && id.length() > 0) {
idList
.
add
(
Integer
.
valueOf
(
id
));
//
idList.add(Integer.valueOf(id));
}
//
}
}
//
}
return
idList
.
toArray
(
new
String
[
idList
.
size
()]
);
return
reString
.
split
(
split
);
}
}
return
null
;
return
null
;
}
}
...
@@ -68,15 +69,16 @@ public class StringArrayJoinTypeHandler extends BaseTypeHandler<String[]> {
...
@@ -68,15 +69,16 @@ public class StringArrayJoinTypeHandler extends BaseTypeHandler<String[]> {
public
String
[]
getNullableResult
(
CallableStatement
cs
,
int
columnIndex
)
throws
SQLException
{
public
String
[]
getNullableResult
(
CallableStatement
cs
,
int
columnIndex
)
throws
SQLException
{
String
reString
=
cs
.
getString
(
columnIndex
);
String
reString
=
cs
.
getString
(
columnIndex
);
if
(
reString
!=
null
&&
reString
.
length
()
>
0
)
{
if
(
reString
!=
null
&&
reString
.
length
()
>
0
)
{
String
[]
arrs
=
reString
.
split
(
split
);
// String[] arrs = reString.split(split);
//
List
<
Integer
>
idList
=
new
ArrayList
<>(
arrs
.
length
);
// List<Integer> idList = new ArrayList<>(arrs.length);
for
(
String
id
:
arrs
)
{
// for (String id : arrs) {
if
(
id
!=
null
&&
id
.
length
()
>
0
)
{
// if (id != null && id.length() > 0) {
idList
.
add
(
Integer
.
valueOf
(
id
));
// idList.add(Integer.valueOf(id));
}
// }
}
// }
return
idList
.
toArray
(
new
String
[
idList
.
size
()]);
// return idList.toArray(new String[idList.size()]);
return
reString
.
split
(
split
);
}
}
return
null
;
return
null
;
}
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeCustomerDto.java
View file @
45d8562
...
@@ -12,25 +12,36 @@ import java.util.List;
...
@@ -12,25 +12,36 @@ import java.util.List;
@Data
@Data
public
class
WeCustomerDto
extends
WeResultDto
{
public
class
WeCustomerDto
extends
WeResultDto
{
private
String
[]
external_userid
;
/** 客户id集合 */
private
String
[]
external_userid
;
/** 客户详情 */
private
ExternalContact
external_contact
;
private
ExternalContact
external_contact
;
/** 客户联系人 */
private
List
<
WeFollowUserDto
>
follow_user
;
private
List
<
WeFollowUserDto
>
follow_user
;
@Data
@Data
class
ExternalContact
{
class
ExternalContact
{
/** 外部联系人userId */
private
String
external_userid
;
private
String
external_userid
;
/** 外部联系人名称 */
private
String
name
;
private
String
name
;
/** 外部联系人职位 */
private
String
position
;
private
String
position
;
/** 外部联系人头像 */
private
String
avatar
;
private
String
avatar
;
/** 外部联系人所在企业简称 */
private
String
corp_name
;
private
String
corp_name
;
/** 外部联系人所在企业全称 */
private
String
corp_full_name
;
private
String
corp_full_name
;
/** 外部联系人的类型,1表示该外部联系人是微信用户,2表示该外部联系人是企业微信用户 */
private
Integer
type
;
private
Integer
type
;
/** 外部联系人性别 0-未知 1-男性 2-女性 */
private
Integer
gender
;
private
Integer
gender
;
/** 外部联系人在微信开放平台的唯一身份标识(微信unionid),通过此字段企业可将外部联系人与公众号/小程序用户关联起来。 */
private
String
unionid
;
private
String
unionid
;
}
}
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/dto/WeFollowUserDto.java
View file @
45d8562
...
@@ -11,26 +11,36 @@ import java.util.List;
...
@@ -11,26 +11,36 @@ import java.util.List;
**/
**/
@Data
@Data
public
class
WeFollowUserDto
extends
WeResultDto
{
public
class
WeFollowUserDto
extends
WeResultDto
{
/** 拥有通讯录功能的企业成员id集合 */
private
String
[]
follow_user
;
private
String
[]
follow_user
;
/** 拥有通讯录功能的企业成员id */
private
String
userid
;
private
String
userid
;
/** 外部联系人的备注 */
private
String
remark
;
private
String
remark
;
/** 外部联系人描述 */
private
String
description
;
private
String
description
;
/** 外部联系人创建时间 */
private
Long
createtime
;
private
Long
createtime
;
/** 添加外部联系人所打的标签 */
private
List
<
WeTagDto
>
tags
;
private
List
<
WeTagDto
>
tags
;
/** 客户备注的企业名称 */
private
String
remark_corp_name
;
private
String
remark_corp_name
;
/** 客户备注的手机号码 */
private
String
remark_mobiles
;
private
String
remark_mobiles
;
/** 该成员添加此客户的来源 */
private
Integer
add_way
;
private
Integer
add_way
;
/** 发起添加的userid,如果成员主动添加,为成员的userid;如果是客户主动添加,则为客户的外部联系人userid;如果是内部成员共享/管理员分配,则为对应的成员/管理员userid */
private
String
oper_userid
;
private
String
oper_userid
;
/** 企业自定义的state参数,用于区分客户具体是通过哪个「联系我」添加 */
private
Integer
state
;
private
Integer
state
;
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCustomerService.java
View file @
45d8562
...
@@ -64,5 +64,5 @@ public interface IWeCustomerService
...
@@ -64,5 +64,5 @@ public interface IWeCustomerService
* 同步客户接口
* 同步客户接口
* @return
* @return
*/
*/
public
int
synchWeCustomer
();
public
void
synchWeCustomer
();
}
}
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCustomerServiceImpl.java
View file @
45d8562
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
package
com
.
linkwechat
.
wecom
.
service
.
impl
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.util.ArrayUtil
;
import
com.linkwechat.common.constant.WeConstans
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.common.utils.DateUtils
;
import
com.linkwechat.wecom.client.WeCustomerClient
;
import
com.linkwechat.wecom.client.WeCustomerClient
;
import
com.linkwechat.wecom.domain.dto.WeCustomerDto
;
import
com.linkwechat.wecom.domain.dto.WeFollowUserDto
;
import
com.linkwechat.wecom.domain.dto.WeFollowUserDto
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -106,10 +111,48 @@ public class WeCustomerServiceImpl implements IWeCustomerService
...
@@ -106,10 +111,48 @@ public class WeCustomerServiceImpl implements IWeCustomerService
* @return
* @return
*/
*/
@Override
@Override
public
int
synchWeCustomer
()
{
public
void
synchWeCustomer
()
{
WeFollowUserDto
weFollowUserDto
=
weFollowUserClient
.
getFollowUserList
();
if
(
WeConstans
.
WE_SUCCESS_CODE
.
equals
(
weFollowUserDto
.
getErrcode
())
&&
ArrayUtil
.
isNotEmpty
(
weFollowUserDto
.
getFollow_user
())){
Arrays
.
asList
(
weFollowUserDto
.
getFollow_user
())
.
stream
().
forEach
(
k
->{
//获取指定联系人对应的客户
WeCustomerDto
externalUserid
=
weFollowUserClient
.
list
(
k
);
if
(
WeConstans
.
WE_SUCCESS_CODE
.
equals
(
externalUserid
.
getErrcode
())
&&
ArrayUtil
.
isNotEmpty
(
externalUserid
.
getExternal_userid
())){
Arrays
.
asList
(
externalUserid
.
getExternal_userid
()).
forEach
(
v
->{
//获取指定客户的详情
WeCustomerDto
externalContact
=
weFollowUserClient
.
get
(
v
);
if
(
WeConstans
.
WE_SUCCESS_CODE
.
equals
(
externalContact
.
getErrcode
())
&&
null
!=
externalContact
.
getExternal_contact
()){
//分装成需要入库的数据格式
}
});
}
});
}
WeFollowUserDto
followUserList
=
weFollowUserClient
.
getFollowUserList
();
System
.
out
.
println
(
followUserList
.
getErrmsg
());
return
0
;
}
}
}
}
linkwe-wecom/src/main/resources/mapper/wecom/WeUserMapper.xml
View file @
45d8562
...
@@ -123,9 +123,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -123,9 +123,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"mobile != null and mobile != ''"
>
mobile = #{mobile},
</if>
<if
test=
"mobile != null and mobile != ''"
>
mobile = #{mobile},
</if>
<if
test=
"email != null"
>
email = #{email},
</if>
<if
test=
"email != null"
>
email = #{email},
</if>
<if
test=
"wxAccount != null"
>
wx_account = #{wxAccount},
</if>
<if
test=
"wxAccount != null"
>
wx_account = #{wxAccount},
</if>
<if
test=
"department != null"
>
department = #{department},
</if>
<if
test=
"department != null"
>
department = #{department
,jdbcType=OTHER,typeHandler=com.linkwechat.framework.handler.StringArrayJoinTypeHandler
},
</if>
<if
test=
"position != null"
>
position = #{position},
</if>
<if
test=
"position != null"
>
position = #{position},
</if>
<if
test=
"isLeaderInDept != null"
>
is_leader_in_dept = #{isLeaderInDept},
</if>
<if
test=
"isLeaderInDept != null"
>
is_leader_in_dept = #{isLeaderInDept
,jdbcType=OTHER,typeHandler=com.linkwechat.framework.handler.StringArrayJoinTypeHandler
},
</if>
<if
test=
"joinTime != null"
>
join_time = #{joinTime},
</if>
<if
test=
"joinTime != null"
>
join_time = #{joinTime},
</if>
<if
test=
"enable != null"
>
enable = #{enable},
</if>
<if
test=
"enable != null"
>
enable = #{enable},
</if>
<if
test=
"idCard != null"
>
id_card = #{idCard},
</if>
<if
test=
"idCard != null"
>
id_card = #{idCard},
</if>
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment