Commit 9ace5515 by HaoN

整合标签分组与标签接口

1 parent a20ab7a9
package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.enums.BusinessType;
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
*
* @author ruoyi
* @date 2020-09-07
*/
@RestController
@RequestMapping("/wecom/tag")
public class WeTagController extends BaseController
{
@Autowired
private IWeTagService weTagService;
/**
* 查询企业微信标签列表
*/
@PreAuthorize("@ss.hasPermi('wecom:tag:list')")
@GetMapping("/list")
public AjaxResult list()
{
return AjaxResult.success(
weTagService.selectWeTagList(new WeTag())
);
}
/**
* 新增企业微信标签
*/
@PreAuthorize("@ss.hasPermi('wecom:tag:add')")
@Log(title = "企业微信标签", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody WeTag weTag)
{
return toAjax(weTagService.insertWeTag(weTag));
}
/**
* 修改企业微信标签
*/
@PreAuthorize("@ss.hasPermi('wecom:tag:edit')")
@Log(title = "企业微信标签", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody WeTag weTag)
{
return toAjax(weTagService.updateWeTag(weTag));
}
/**
* 删除企业微信标签
*/
@PreAuthorize("@ss.hasPermi('wecom:tag:remove')")
@Log(title = "企业微信标签", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(weTagService.deleteWeTagByIds(ids));
}
}
...@@ -6,6 +6,7 @@ import java.util.HashMap; ...@@ -6,6 +6,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.linkwechat.common.utils.DateUtils;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
/** /**
...@@ -75,9 +76,14 @@ public class BaseEntity implements Serializable ...@@ -75,9 +76,14 @@ public class BaseEntity implements Serializable
public void setCreateTime(Date createTime) public void setCreateTime(Date createTime)
{ {
if(createTime==null){
this.createTime= DateUtils.getNowDate();
}else{
this.createTime = createTime; this.createTime = createTime;
} }
}
public String getUpdateBy() public String getUpdateBy()
{ {
return updateBy; return updateBy;
......
...@@ -2,17 +2,17 @@ package com.linkwechat.common.enums; ...@@ -2,17 +2,17 @@ package com.linkwechat.common.enums;
public enum CustomerSource { public enum CustomerSource {
// CUSTOMER_SOURCE_WZLY(0,""), // CUSTOMER_SOURCE_WZLY(0,""),
// CUSTOMER_SOURCE_SMEWM(0,), // CUSTOMER_SOURCE_SMEWM(1,),
// CUSTOMER_SOURCE_SSSJH(0,), // CUSTOMER_SOURCE_SSSJH(2,),
// CUSTOMER_SOURCE_MPFX(0,), // CUSTOMER_SOURCE_MPFX(3,),
// CUSTOMER_SOURCE_QL(0,), // CUSTOMER_SOURCE_QL(4,),
// CUSTOMER_SOURCE_SJTXL(0,), // CUSTOMER_SOURCE_SJTXL(5,),
// CUSTOMER_SOURCE_WXLXR(0,), // CUSTOMER_SOURCE_WXLXR(6,),
// CUSTOMER_SOURCE_TJHYSQ(0,), // CUSTOMER_SOURCE_TJHYSQ(7,),
// CUSTOMER_SOURCE_DSFRJTJ(0,), // CUSTOMER_SOURCE_DSFRJTJ(8,),
// CUSTOMER_SOURCE_YXSS(0,), // CUSTOMER_SOURCE_YXSS(9,),
// CUSTOMER_SOURCE_NBCYGX(0,), // CUSTOMER_SOURCE_NBCYGX(201,),
// CUSTOMER_SOURCE_GLRYFP(0,) // CUSTOMER_SOURCE_GLRYFP(202,)
// ; // ;
// //
// private Integer code; // private Integer code;
......
package com.linkwechat.wecom.domain; package com.linkwechat.wecom.domain;
import com.linkwechat.common.annotation.Excel;
import com.linkwechat.common.core.domain.BaseEntity; import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/** /**
* 企业微信标签对象 we_tag * 企业微信标签对象 we_tag
...@@ -18,15 +16,16 @@ public class WeTag extends BaseEntity ...@@ -18,15 +16,16 @@ public class WeTag extends BaseEntity
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long id= SnowFlakeUtil.nextId();
/** 标签组id */ /** 标签组id */
@Excel(name = "标签组id") private Long groupId;
private String groupId;
/** 标签名 */ /** 标签名 */
@Excel(name = "标签名")
private String name; private String name;
/** 帐号状态(0正常 1删除) */
private String status;
} }
package com.linkwechat.wecom.domain; package com.linkwechat.wecom.domain;
import com.linkwechat.common.annotation.Excel;
import com.linkwechat.common.core.domain.BaseEntity; import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import java.util.List;
/** /**
* 标签组对象 we_tag_group * 标签组对象 we_tag_group
...@@ -17,49 +17,14 @@ public class WeTagGroup extends BaseEntity ...@@ -17,49 +17,14 @@ public class WeTagGroup extends BaseEntity
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** $column.columnComment */ private Long id= SnowFlakeUtil.nextId();
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
/** 分组名称 */
private String gourpName; private String gourpName;
// /** 标签组排序的次序值,order值大的排序靠前 */ /** 标签 */
// @Excel(name = "标签组排序的次序值,order值大的排序靠前") private List<WeTag> weTags;
// private Long order;
// public void setId(Long id) /** 帐号状态(0正常 1删除) */
// { private String status;
// 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();
// }
} }
...@@ -76,13 +76,7 @@ public class WeCustomerDto extends WeResultDto{ ...@@ -76,13 +76,7 @@ public class WeCustomerDto extends WeResultDto{
weCustomer.setDescription(weFollowUserDto.getDescription()); weCustomer.setDescription(weFollowUserDto.getDescription());
weCustomer.setRemarkMobiles(StringUtils.join(weFollowUserDto.getRemark_mobiles(),",")); weCustomer.setRemarkMobiles(StringUtils.join(weFollowUserDto.getRemark_mobiles(),","));
// weCustomer.setAddWay(); // weCustomer.setAddWay();
//
// weFollowUserDto.getAdd_way();
// followUser.getUserid();
// followUser.getDescription();
// followUser.getRemark_mobiles();
// followUser.getAdd_way();
} }
......
...@@ -2,6 +2,7 @@ package com.linkwechat.wecom.mapper; ...@@ -2,6 +2,7 @@ package com.linkwechat.wecom.mapper;
import java.util.List; import java.util.List;
import com.linkwechat.wecom.domain.WeTag; import com.linkwechat.wecom.domain.WeTag;
import org.apache.ibatis.annotations.Param;
/** /**
* 企业微信标签Mapper接口 * 企业微信标签Mapper接口
...@@ -58,4 +59,12 @@ public interface WeTagMapper ...@@ -58,4 +59,12 @@ public interface WeTagMapper
* @return 结果 * @return 结果
*/ */
public int deleteWeTagByIds(Long[] ids); public int deleteWeTagByIds(Long[] ids);
/**
* 批量插入标签
* @param weTags
* @return
*/
public int batchInsetWeTag(@Param("weTags") List<WeTag> weTags);
} }
...@@ -140,56 +140,17 @@ public class WeCustomerServiceImpl implements IWeCustomerService ...@@ -140,56 +140,17 @@ public class WeCustomerServiceImpl implements IWeCustomerService
if(WeConstans.WE_SUCCESS_CODE.equals(externalContact.getErrcode())){ if(WeConstans.WE_SUCCESS_CODE.equals(externalContact.getErrcode())){
//分装成需要入库的数据格式 WeCustomer weCustomer
WeCustomerDto.ExternalContact = externalContact.transformWeCustomer();
weExternalContact = externalContact.getExternal_contact();
if(null != weExternalContact){
WeCustomer.builder()
.externalUserid(weExternalContact.getExternal_userid())
.name(weExternalContact.getName())
.avatar(weExternalContact.getAvatar())
.type(weExternalContact.getType())
.gender(weExternalContact.getGender())
.unionid(weExternalContact.getUnionid())
// 自定义 .birthday()
// 添加人的id .userId(weExternalContact.getExternal_userid())
// 添加人的名称 .userName()
// 添加人所在部门 .departmentName()
// 添加人员描述 .description()
// 备注号码 .remarkMobiles()
.corpName(weExternalContact.getCorp_name())
.corpFullName(weExternalContact.getCorp_full_name())
.position(weExternalContact.getPosition());
// 客户来源 .addWay()
List<WeFollowUserDto> followUsers = externalContact.getFollow_user();
if(CollectionUtil.isNotEmpty(followUsers)){
WeFollowUserDto followUser = followUsers.get(0);
followUser.getUserid();
followUser.getDescription();
followUser.getRemark_mobiles();
followUser.getAdd_way();
WeUserDto weUserDto WeUserDto weUserDto
= weUserClient.getUserByUserId(followUser.getUserid()); = weUserClient.getUserByUserId(weCustomer.getUserId());
if(WeConstans.WE_SUCCESS_CODE.equals(weUserDto.getErrcode())){ if(WeConstans.WE_SUCCESS_CODE.equals(weUserDto.getErrcode())){
weUserDto.getName(); weCustomer.setName(weUserDto.getName());
}
} }
} }
}
}); });
} }
......
package com.linkwechat.wecom.service.impl; package com.linkwechat.wecom.service.impl;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil;
import com.linkwechat.common.utils.DateUtils; import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.wecom.domain.WeTag;
import com.linkwechat.wecom.mapper.WeTagMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.linkwechat.wecom.mapper.WeTagGroupMapper; import com.linkwechat.wecom.mapper.WeTagGroupMapper;
import com.linkwechat.wecom.domain.WeTagGroup; import com.linkwechat.wecom.domain.WeTagGroup;
import com.linkwechat.wecom.service.IWeTagGroupService; import com.linkwechat.wecom.service.IWeTagGroupService;
import org.springframework.transaction.annotation.Transactional;
/** /**
* 标签组Service业务层处理 * 标签组Service业务层处理
...@@ -21,6 +26,9 @@ public class WeTagGroupServiceImpl implements IWeTagGroupService ...@@ -21,6 +26,9 @@ public class WeTagGroupServiceImpl implements IWeTagGroupService
@Autowired @Autowired
private WeTagGroupMapper weTagGroupMapper; private WeTagGroupMapper weTagGroupMapper;
@Autowired
private WeTagMapper weTagMapper;
/** /**
* 查询标签组 * 查询标签组
* *
...@@ -52,10 +60,20 @@ public class WeTagGroupServiceImpl implements IWeTagGroupService ...@@ -52,10 +60,20 @@ public class WeTagGroupServiceImpl implements IWeTagGroupService
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional
public int insertWeTagGroup(WeTagGroup weTagGroup) public int insertWeTagGroup(WeTagGroup weTagGroup)
{ {
weTagGroup.setCreateTime(DateUtils.getNowDate()); int returnCode = weTagGroupMapper.insertWeTagGroup(weTagGroup);
return weTagGroupMapper.insertWeTagGroup(weTagGroup);
if(returnCode>0){
List<WeTag> weTags = weTagGroup.getWeTags();
if(CollectionUtil.isNotEmpty(weTags)){
weTags.stream().forEach(k->k.setGroupId(weTagGroup.getId()));
weTagMapper.batchInsetWeTag(weTags);
}
}
return returnCode;
} }
/** /**
......
...@@ -8,24 +8,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -8,24 +8,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="id" column="id" /> <result property="id" column="id" />
<result property="gourpName" column="gourp_name" /> <result property="gourpName" column="gourp_name" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="order" column="order" />
</resultMap> </resultMap>
<sql id="selectWeTagGroupVo"> <sql id="selectWeTagGroupVo">
select id, gourp_name, create_time, order from we_tag_group select id, gourp_name, create_time from we_tag_group
</sql> </sql>
<select id="selectWeTagGroupList" parameterType="WeTagGroup" resultMap="WeTagGroupResult"> <select id="selectWeTagGroupList" parameterType="WeTagGroup" resultMap="WeTagGroupResult">
<include refid="selectWeTagGroupVo"/> <include refid="selectWeTagGroupVo"/>
<where> <where>
<if test="gourpName != null and gourpName != ''"> and gourp_name like concat('%', #{gourpName}, '%')</if> <if test="gourpName != null and gourpName != ''"> and gourp_name like concat('%', #{gourpName}, '%')</if>
<if test="order != null "> and order = #{order}</if>
</where> </where>
</select> </select>
<select id="selectWeTagGroupById" parameterType="Long" resultMap="WeTagGroupResult"> <select id="selectWeTagGroupById" parameterType="Long" resultMap="WeTagGroupResult">
<include refid="selectWeTagGroupVo"/> <include refid="selectWeTagGroupVo"/>
where id = #{id} where id = #{id} and status=0
</select> </select>
<insert id="insertWeTagGroup" parameterType="WeTagGroup"> <insert id="insertWeTagGroup" parameterType="WeTagGroup">
...@@ -34,13 +32,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -34,13 +32,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="id != null">id,</if> <if test="id != null">id,</if>
<if test="gourpName != null">gourp_name,</if> <if test="gourpName != null">gourp_name,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="order != null">order,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if> <if test="id != null">#{id},</if>
<if test="gourpName != null">#{gourpName},</if> <if test="gourpName != null">#{gourpName},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="order != null">#{order},</if>
</trim> </trim>
</insert> </insert>
...@@ -49,7 +45,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -49,7 +45,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="gourpName != null">gourp_name = #{gourpName},</if> <if test="gourpName != null">gourp_name = #{gourpName},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="order != null">order = #{order},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
......
...@@ -9,11 +9,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -9,11 +9,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="groupId" column="group_id" /> <result property="groupId" column="group_id" />
<result property="name" column="name" /> <result property="name" column="name" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="order" column="order" />
</resultMap> </resultMap>
<sql id="selectWeTagVo"> <sql id="selectWeTagVo">
select id, group_id, name, create_time, order from we_tag select id, group_id, name, create_time from we_tag
</sql> </sql>
<select id="selectWeTagList" parameterType="WeTag" resultMap="WeTagResult"> <select id="selectWeTagList" parameterType="WeTag" resultMap="WeTagResult">
...@@ -21,13 +20,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -21,13 +20,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where> <where>
<if test="groupId != null "> and group_id = #{groupId}</if> <if test="groupId != null "> and group_id = #{groupId}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="order != null "> and order = #{order}</if>
</where> </where>
</select> </select>
<select id="selectWeTagById" parameterType="Long" resultMap="WeTagResult"> <select id="selectWeTagById" parameterType="Long" resultMap="WeTagResult">
<include refid="selectWeTagVo"/> <include refid="selectWeTagVo"/>
where id = #{id} where id = #{id} and status=0
</select> </select>
<insert id="insertWeTag" parameterType="WeTag"> <insert id="insertWeTag" parameterType="WeTag">
...@@ -37,14 +35,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -37,14 +35,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="groupId != null">group_id,</if> <if test="groupId != null">group_id,</if>
<if test="name != null">name,</if> <if test="name != null">name,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="order != null">order,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if> <if test="id != null">#{id},</if>
<if test="groupId != null">#{groupId},</if> <if test="groupId != null">#{groupId},</if>
<if test="name != null">#{name},</if> <if test="name != null">#{name},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="order != null">#{order},</if>
</trim> </trim>
</insert> </insert>
...@@ -54,7 +50,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -54,7 +50,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="groupId != null">group_id = #{groupId},</if> <if test="groupId != null">group_id = #{groupId},</if>
<if test="name != null">name = #{name},</if> <if test="name != null">name = #{name},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="order != null">order = #{order},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
...@@ -70,4 +65,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -70,4 +65,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
</delete> </delete>
<insert id="batchInsetWeTag" >
insert into person (id, group_id, name, create_time)
values
<foreach collection="tags" item="tag" index="index" separator=",">
(#{tag.id},#{tag.groupId},#{tag.name},#{tag.createTime})
</foreach>
</insert>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!