提交 36913558 编写于 作者: X xinla

Merge branch 'master' of https://gitee.com/LinkWeChat/link-wechat into master

......@@ -3,6 +3,7 @@ package com.linkwechat.web.controller.wecom;
import java.util.List;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
......@@ -69,16 +70,7 @@ public class WeCustomerController extends BaseController
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
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
weCustomerService.synchWeCustomer();
return null;
return AjaxResult.success(WeConstans.SYNCH_TIP);
}
}
package com.linkwechat.web.controller.wecom;
import java.util.List;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
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.service.IWeTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
/**
* 企业微信标签Controller
......@@ -39,35 +28,13 @@ public class WeTagController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('wecom:tag:list')")
@GetMapping("/list")
public TableDataInfo list(WeTag weTag)
{
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)
public AjaxResult list()
{
List<WeTag> list = weTagService.selectWeTagList(weTag);
ExcelUtil<WeTag> util = new ExcelUtil<WeTag>(WeTag.class);
return util.exportExcel(list, "tag");
return AjaxResult.success(
weTagService.selectWeTagList(new WeTag())
);
}
/**
* 获取企业微信标签详细信息
*/
@PreAuthorize("@ss.hasPermi('wecom:tag:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(weTagService.selectWeTagById(id));
}
/**
* 新增企业微信标签
......
......@@ -39,11 +39,12 @@ public class WeTagGroupController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('wecom:group:list')")
@GetMapping("/list")
public TableDataInfo list(WeTagGroup weTagGroup)
public AjaxResult list()
{
startPage();
List<WeTagGroup> list = weTagGroupService.selectWeTagGroupList(weTagGroup);
return getDataTable(list);
return AjaxResult.success(
weTagGroupService.selectWeTagGroupList(new WeTagGroup())
);
}
/**
......
......@@ -41,4 +41,10 @@ public class WeConstans {
* 企业微信通讯录用户停用
*/
public static final Integer WE_USER_STOP= 0;
/**
* 同步功能提示语
*/
public static final String SYNCH_TIP="后台开始同步数据,请稍后关注进度";
}
......@@ -34,15 +34,16 @@ public class StringArrayJoinTypeHandler extends BaseTypeHandler<String[]> {
public String[] getNullableResult(ResultSet rs, String columnName) throws SQLException {
String reString = rs.getString(columnName);
if (reString != null && reString.length() > 0) {
String[] arrs = reString.split(split);
// String[] arrs = reString.split(split);
List<Long> idList = new ArrayList<>(arrs.length);
for (String id : arrs) {
if (id != null && id.length() > 0) {
idList.add(Long.valueOf(id));
}
}
return idList.toArray(new String[idList.size()]);
// List<Long> idList = new ArrayList<>(arrs.length);
// for (String id : arrs) {
// if (id != null && id.length() > 0) {
// idList.add(Long.valueOf(id));
// }
// }
// return idList.toArray(new String[idList.size()]);
return reString.split(split);
}
return null;
}
......@@ -51,15 +52,15 @@ public class StringArrayJoinTypeHandler extends BaseTypeHandler<String[]> {
public String[] getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
String reString = rs.getString(columnIndex);
if (reString != null && reString.length() > 0) {
String[] arrs = reString.split(split);
// String[] arrs = reString.split(split);
List<Integer> idList = new ArrayList<>(arrs.length);
for (String id : arrs) {
if (id != null && id.length() > 0) {
idList.add(Integer.valueOf(id));
}
}
return idList.toArray(new String[idList.size()]);
// List<Integer> idList = new ArrayList<>(arrs.length);
// for (String id : arrs) {
// if (id != null && id.length() > 0) {
// idList.add(Integer.valueOf(id));
// }
// }
return reString.split(split);
}
return null;
}
......@@ -68,15 +69,16 @@ public class StringArrayJoinTypeHandler extends BaseTypeHandler<String[]> {
public String[] getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
String reString = cs.getString(columnIndex);
if (reString != null && reString.length() > 0) {
String[] arrs = reString.split(split);
List<Integer> idList = new ArrayList<>(arrs.length);
for (String id : arrs) {
if (id != null && id.length() > 0) {
idList.add(Integer.valueOf(id));
}
}
return idList.toArray(new String[idList.size()]);
// String[] arrs = reString.split(split);
//
// List<Integer> idList = new ArrayList<>(arrs.length);
// for (String id : arrs) {
// if (id != null && id.length() > 0) {
// idList.add(Integer.valueOf(id));
// }
// }
// return idList.toArray(new String[idList.size()]);
return reString.split(split);
}
return null;
}
......
......@@ -2,6 +2,7 @@ package com.linkwechat.wecom.domain;
import com.linkwechat.common.annotation.Excel;
import com.linkwechat.common.core.domain.BaseEntity;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
......@@ -11,70 +12,21 @@ import org.apache.commons.lang3.builder.ToStringStyle;
* @author ruoyi
* @date 2020-09-07
*/
@Data
public class WeTag extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 标签组id */
@Excel(name = "标签组id")
private Long groupId;
private String groupId;
/** 标签名 */
@Excel(name = "标签名")
private String name;
/** 标签排序的次序值,order值大的排序靠前。 */
@Excel(name = "标签排序的次序值,order值大的排序靠前。")
private Long order;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setGroupId(Long groupId)
{
this.groupId = groupId;
}
public Long getGroupId()
{
return groupId;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setOrder(Long order)
{
this.order = order;
}
public Long getOrder()
{
return order;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("groupId", getGroupId())
.append("name", getName())
.append("createTime", getCreateTime())
.append("order", getOrder())
.toString();
}
}
......@@ -2,6 +2,7 @@ package com.linkwechat.wecom.domain;
import com.linkwechat.common.annotation.Excel;
import com.linkwechat.common.core.domain.BaseEntity;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
......@@ -11,56 +12,54 @@ import org.apache.commons.lang3.builder.ToStringStyle;
* @author ruoyi
* @date 2020-09-07
*/
@Data
public class WeTagGroup extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 标签组id */
private Long id;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String gourpName;
/** 标签组排序的次序值,order值大的排序靠前 */
@Excel(name = "标签组排序的次序值,order值大的排序靠前")
private Long order;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setGourpName(String gourpName)
{
this.gourpName = gourpName;
}
public String getGourpName()
{
return gourpName;
}
public void setOrder(Long order)
{
this.order = order;
}
public Long getOrder()
{
return order;
}
// /** 标签组排序的次序值,order值大的排序靠前 */
// @Excel(name = "标签组排序的次序值,order值大的排序靠前")
// private Long order;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("gourpName", getGourpName())
.append("createTime", getCreateTime())
.append("order", getOrder())
.toString();
}
// public void setId(Long id)
// {
// this.id = id;
// }
//
// public Long getId()
// {
// return id;
// }
// public void setGourpName(String gourpName)
// {
// this.gourpName = gourpName;
// }
//
// public String getGourpName()
// {
// return gourpName;
// }
// public void setOrder(Long order)
// {
// this.order = order;
// }
//
// public Long getOrder()
// {
// return order;
// }
//
// @Override
// public String toString() {
// return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
// .append("id", getId())
// .append("gourpName", getGourpName())
// .append("createTime", getCreateTime())
// .append("order", getOrder())
// .toString();
// }
}
......@@ -12,25 +12,36 @@ import java.util.List;
@Data
public class WeCustomerDto extends WeResultDto{
private String[] external_userid;
/** 客户id集合 */
private String[] external_userid;
/** 客户详情 */
private ExternalContact external_contact;
/** 客户联系人 */
private List<WeFollowUserDto> follow_user;
@Data
class ExternalContact{
/** 外部联系人userId */
private String external_userid;
/** 外部联系人名称 */
private String name;
/** 外部联系人职位 */
private String position;
/** 外部联系人头像 */
private String avatar;
/** 外部联系人所在企业简称 */
private String corp_name;
/** 外部联系人所在企业全称 */
private String corp_full_name;
/** 外部联系人的类型,1表示该外部联系人是微信用户,2表示该外部联系人是企业微信用户 */
private Integer type;
/** 外部联系人性别 0-未知 1-男性 2-女性 */
private Integer gender;
/** 外部联系人在微信开放平台的唯一身份标识(微信unionid),通过此字段企业可将外部联系人与公众号/小程序用户关联起来。 */
private String unionid;
}
......
......@@ -11,26 +11,36 @@ import java.util.List;
**/
@Data
public class WeFollowUserDto extends WeResultDto{
/** 拥有通讯录功能的企业成员id集合 */
private String[] follow_user;
/** 拥有通讯录功能的企业成员id */
private String userid;
/** 外部联系人的备注 */
private String remark;
/** 外部联系人描述 */
private String description;
/** 外部联系人创建时间 */
private Long createtime;
/** 添加外部联系人所打的标签 */
private List<WeTagDto> tags;
/** 客户备注的企业名称 */
private String remark_corp_name;
/** 客户备注的手机号码 */
private String remark_mobiles;
/** 该成员添加此客户的来源 */
private Integer add_way;
/** 发起添加的userid,如果成员主动添加,为成员的userid;如果是客户主动添加,则为客户的外部联系人userid;如果是内部成员共享/管理员分配,则为对应的成员/管理员userid */
private String oper_userid;
/** 企业自定义的state参数,用于区分客户具体是通过哪个「联系我」添加 */
private Integer state;
}
......@@ -64,5 +64,5 @@ public interface IWeCustomerService
* 同步客户接口
* @return
*/
public int synchWeCustomer();
public void synchWeCustomer();
}
package com.linkwechat.wecom.service.impl;
import java.util.Arrays;
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.wecom.client.WeCustomerClient;
import com.linkwechat.wecom.domain.dto.WeCustomerDto;
import com.linkwechat.wecom.domain.dto.WeFollowUserDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -106,10 +111,48 @@ public class WeCustomerServiceImpl implements IWeCustomerService
* @return
*/
@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;
}
}
......@@ -123,9 +123,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mobile != null and mobile != ''">mobile = #{mobile},</if>
<if test="email != null">email = #{email},</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="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="enable != null">enable = #{enable},</if>
<if test="idCard != null">id_card = #{idCard},</if>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册