Commit 8a3fec62 by xinlaa

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

2 parents 7a1b8638 ca73dcfd
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));
}
}
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.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.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -39,36 +37,15 @@ public class WeTagGroupController extends BaseController ...@@ -39,36 +37,15 @@ public class WeTagGroupController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('wecom:group:list')") @PreAuthorize("@ss.hasPermi('wecom:group:list')")
@GetMapping("/list") @GetMapping("/list")
public AjaxResult list() public TableDataInfo list(WeTagGroup weTagGroup)
{ {
startPage();
return AjaxResult.success( return getDataTable(
weTagGroupService.selectWeTagGroupList(new WeTagGroup()) weTagGroupService.selectWeTagGroupList(weTagGroup)
); );
} }
/**
* 导出标签组列表
*/
@PreAuthorize("@ss.hasPermi('wecom:group:export')")
@Log(title = "标签组", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(WeTagGroup weTagGroup)
{
List<WeTagGroup> list = weTagGroupService.selectWeTagGroupList(weTagGroup);
ExcelUtil<WeTagGroup> util = new ExcelUtil<WeTagGroup>(WeTagGroup.class);
return util.exportExcel(list, "group");
}
/**
* 获取标签组详细信息
*/
@PreAuthorize("@ss.hasPermi('wecom:group:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(weTagGroupService.selectWeTagGroupById(id));
}
/** /**
* 新增标签组 * 新增标签组
......
...@@ -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;
/** /**
...@@ -25,7 +26,7 @@ public class BaseEntity implements Serializable ...@@ -25,7 +26,7 @@ public class BaseEntity implements Serializable
/** 创建时间 */ /** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime; private Date createTime=new Date();
/** 更新者 */ /** 更新者 */
private String updateBy; private String updateBy;
...@@ -75,7 +76,12 @@ public class BaseEntity implements Serializable ...@@ -75,7 +76,12 @@ public class BaseEntity implements Serializable
public void setCreateTime(Date createTime) public void setCreateTime(Date createTime)
{ {
this.createTime = createTime; if(createTime==null){
this.createTime= DateUtils.getNowDate();
}else{
this.createTime = createTime;
}
} }
public String getUpdateBy() public String getUpdateBy()
......
package com.linkwechat.common.enums;
public enum CustomerSource {
// CUSTOMER_SOURCE_WZLY(0,""),
// CUSTOMER_SOURCE_SMEWM(1,),
// CUSTOMER_SOURCE_SSSJH(2,),
// CUSTOMER_SOURCE_MPFX(3,),
// CUSTOMER_SOURCE_QL(4,),
// CUSTOMER_SOURCE_SJTXL(5,),
// CUSTOMER_SOURCE_WXLXR(6,),
// CUSTOMER_SOURCE_TJHYSQ(7,),
// CUSTOMER_SOURCE_DSFRJTJ(8,),
// CUSTOMER_SOURCE_YXSS(9,),
// CUSTOMER_SOURCE_NBCYGX(201,),
// CUSTOMER_SOURCE_GLRYFP(202,)
// ;
//
// private Integer code;
//
// private String label;
//
// private CustomerSource(Integer code, String label){
// this.code = code;
// this.label = label;
// }
//
// public Integer getCode() {
// return code;
// }
//
// public OrderType setCode(Integer code) {
// this.code = code;
// return this;
// }
//
// public String getLabel() {
// return label;
// }
//
// public OrderType setLabel(String label) {
// this.label = label;
// return this;
// }
//
// public OrderType getOrderTypeByCode(Integer code){
// OrderType[] orderTypes = OrderType.values();
// for(OrderType orderType:orderTypes){
// if(orderType.getCode().equals(code)){
// return orderType;
// }
// }
// throw new RuntimeException("未知的订单类型");
// }
}
...@@ -3,6 +3,11 @@ package com.linkwechat.wecom.domain; ...@@ -3,6 +3,11 @@ package com.linkwechat.wecom.domain;
import java.util.Date; import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.core.domain.BaseEntity; import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
...@@ -12,12 +17,16 @@ import org.apache.commons.lang3.builder.ToStringStyle; ...@@ -12,12 +17,16 @@ import org.apache.commons.lang3.builder.ToStringStyle;
* @author ruoyi * @author ruoyi
* @date 2020-09-13 * @date 2020-09-13
*/ */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class WeCustomer extends BaseEntity public class WeCustomer extends BaseEntity
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** $column.columnComment */ /** $column.columnComment */
private Long id; private Long id= SnowFlakeUtil.nextId();;
/** 外部联系人的userid */ /** 外部联系人的userid */
private String externalUserid; private String externalUserid;
...@@ -29,10 +38,10 @@ public class WeCustomer extends BaseEntity ...@@ -29,10 +38,10 @@ public class WeCustomer extends BaseEntity
private String avatar; private String avatar;
/** 外部联系人的类型,1表示该外部联系人是微信用户,2表示该外部联系人是企业微信用户 */ /** 外部联系人的类型,1表示该外部联系人是微信用户,2表示该外部联系人是企业微信用户 */
private Long type; private Integer type;
/** 外部联系人性别 0-未知 1-男性 2-女性 */ /** 外部联系人性别 0-未知 1-男性 2-女性 */
private Long gender; private Integer gender;
/** 外部联系人在微信开放平台的唯一身份标识,通过此字段企业可将外部联系人与公众号/小程序用户关联起来。 */ /** 外部联系人在微信开放平台的唯一身份标识,通过此字段企业可将外部联系人与公众号/小程序用户关联起来。 */
private String unionid; private String unionid;
...@@ -56,154 +65,20 @@ public class WeCustomer extends BaseEntity ...@@ -56,154 +65,20 @@ public class WeCustomer extends BaseEntity
/** 客户备注的手机号码 */ /** 客户备注的手机号码 */
private String remarkMobiles; private String remarkMobiles;
/** 客户备注的企业名称 */ /** 客户企业简称 */
private String remarkCorpName; private String corpName;
public void setId(Long id) /** 客户企业全称 */
{ private String corpFullName;
this.id = id;
} /** 职位 */
private String position;
public Long getId()
{
return id; /** 客户来源 */
} private String addWay;
public void setExternalUserid(String externalUserid)
{
this.externalUserid = externalUserid;
}
public String getExternalUserid()
{
return externalUserid;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setAvatar(String avatar)
{
this.avatar = avatar;
}
public String getAvatar()
{
return avatar;
}
public void setType(Long type)
{
this.type = type;
}
public Long getType()
{
return type;
}
public void setGender(Long gender)
{
this.gender = gender;
}
public Long getGender()
{
return gender;
}
public void setUnionid(String unionid)
{
this.unionid = unionid;
}
public String getUnionid()
{
return unionid;
}
public void setBirthday(Date birthday)
{
this.birthday = birthday;
}
public Date getBirthday()
{
return birthday;
}
public void setUserId(String userId)
{
this.userId = userId;
}
public String getUserId()
{
return userId;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public String getUserName()
{
return userName;
}
public void setDepartmentName(String departmentName)
{
this.departmentName = departmentName;
}
public String getDepartmentName()
{
return departmentName;
}
public void setDescription(String description)
{
this.description = description;
}
public String getDescription()
{
return description;
}
public void setRemarkMobiles(String remarkMobiles)
{
this.remarkMobiles = remarkMobiles;
}
public String getRemarkMobiles()
{
return remarkMobiles;
}
public void setRemarkCorpName(String remarkCorpName)
{
this.remarkCorpName = remarkCorpName;
}
public String getRemarkCorpName()
{
return remarkCorpName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("externalUserid", getExternalUserid())
.append("name", getName())
.append("avatar", getAvatar())
.append("type", getType())
.append("gender", getGender())
.append("unionid", getUnionid())
.append("birthday", getBirthday())
.append("userId", getUserId())
.append("userName", getUserName())
.append("createTime", getCreateTime())
.append("departmentName", getDepartmentName())
.append("description", getDescription())
.append("remarkMobiles", getRemarkMobiles())
.append("remarkCorpName", getRemarkCorpName())
.toString();
}
} }
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();
// }
} }
package com.linkwechat.wecom.domain.dto; package com.linkwechat.wecom.domain.dto;
import cn.hutool.core.collection.CollectionUtil;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.bean.BeanUtils;
import com.linkwechat.wecom.domain.WeCustomer;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
...@@ -24,7 +28,7 @@ public class WeCustomerDto extends WeResultDto{ ...@@ -24,7 +28,7 @@ public class WeCustomerDto extends WeResultDto{
@Data @Data
class ExternalContact{ public class ExternalContact{
/** 外部联系人userId */ /** 外部联系人userId */
private String external_userid; private String external_userid;
/** 外部联系人名称 */ /** 外部联系人名称 */
...@@ -58,4 +62,30 @@ public class WeCustomerDto extends WeResultDto{ ...@@ -58,4 +62,30 @@ public class WeCustomerDto extends WeResultDto{
} }
public WeCustomer transformWeCustomer(){
WeCustomer weCustomer=new WeCustomer();
if(null != external_contact){
BeanUtils.copyPropertiesignoreOther(external_contact,weCustomer);
}
if(CollectionUtil.isNotEmpty(follow_user)){
WeFollowUserDto weFollowUserDto = follow_user.get(0);
weCustomer.setUserId(weFollowUserDto.getUserid());
weCustomer.setDescription(weFollowUserDto.getDescription());
weCustomer.setRemarkMobiles(StringUtils.join(weFollowUserDto.getRemark_mobiles(),","));
// weCustomer.setAddWay();
}
return weCustomer;
}
} }
...@@ -33,7 +33,7 @@ public class WeFollowUserDto extends WeResultDto{ ...@@ -33,7 +33,7 @@ public class WeFollowUserDto extends WeResultDto{
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;
......
...@@ -8,7 +8,7 @@ import lombok.Data; ...@@ -8,7 +8,7 @@ import lombok.Data;
* @create: 2020-08-28 10:45 * @create: 2020-08-28 10:45
**/ **/
@Data @Data
public class WeUserDto { public class WeUserDto extends WeResultDto{
//成员头像的mediaid,通过素材管理接口上传图片获得的mediaid //成员头像的mediaid,通过素材管理接口上传图片获得的mediaid
private String avatar_mediaid; private String avatar_mediaid;
......
...@@ -58,4 +58,20 @@ public interface WeTagMapper ...@@ -58,4 +58,20 @@ public interface WeTagMapper
* @return 结果 * @return 结果
*/ */
public int deleteWeTagByIds(Long[] ids); public int deleteWeTagByIds(Long[] ids);
/**
* 批量插入标签
* @param weTags
* @return
*/
public int batchInsetWeTag(List<WeTag> weTags);
/**
* 标签批量更新
* @param weTags
* @return
*/
public int batchUpdateWeTag(List<WeTag> weTags);
} }
...@@ -8,8 +8,10 @@ import cn.hutool.core.util.ArrayUtil; ...@@ -8,8 +8,10 @@ import cn.hutool.core.util.ArrayUtil;
import com.linkwechat.common.constant.WeConstans; 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.client.WeUserClient;
import com.linkwechat.wecom.domain.dto.WeCustomerDto; import com.linkwechat.wecom.domain.dto.WeCustomerDto;
import com.linkwechat.wecom.domain.dto.WeFollowUserDto; import com.linkwechat.wecom.domain.dto.WeFollowUserDto;
import com.linkwechat.wecom.domain.dto.WeUserDto;
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.WeCustomerMapper; import com.linkwechat.wecom.mapper.WeCustomerMapper;
...@@ -32,6 +34,10 @@ public class WeCustomerServiceImpl implements IWeCustomerService ...@@ -32,6 +34,10 @@ public class WeCustomerServiceImpl implements IWeCustomerService
@Autowired @Autowired
private WeCustomerClient weFollowUserClient; private WeCustomerClient weFollowUserClient;
@Autowired
private WeUserClient weUserClient;
/** /**
* 查询企业微信客户 * 查询企业微信客户
* *
...@@ -132,12 +138,16 @@ public class WeCustomerServiceImpl implements IWeCustomerService ...@@ -132,12 +138,16 @@ public class WeCustomerServiceImpl implements IWeCustomerService
//获取指定客户的详情 //获取指定客户的详情
WeCustomerDto externalContact = weFollowUserClient.get(v); WeCustomerDto externalContact = weFollowUserClient.get(v);
if(WeConstans.WE_SUCCESS_CODE.equals(externalContact.getErrcode()) if(WeConstans.WE_SUCCESS_CODE.equals(externalContact.getErrcode())){
&& null != externalContact.getExternal_contact()){
//分装成需要入库的数据格式
WeCustomer weCustomer
= externalContact.transformWeCustomer();
WeUserDto weUserDto
= weUserClient.getUserByUserId(weCustomer.getUserId());
if(WeConstans.WE_SUCCESS_CODE.equals(weUserDto.getErrcode())){
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;
} }
/** /**
...@@ -65,9 +83,18 @@ public class WeTagGroupServiceImpl implements IWeTagGroupService ...@@ -65,9 +83,18 @@ public class WeTagGroupServiceImpl implements IWeTagGroupService
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional
public int updateWeTagGroup(WeTagGroup weTagGroup) public int updateWeTagGroup(WeTagGroup weTagGroup)
{ {
return weTagGroupMapper.updateWeTagGroup(weTagGroup); int returnCode = weTagGroupMapper.updateWeTagGroup(weTagGroup);
if(returnCode>0){
List<WeTag> weTags = weTagGroup.getWeTags();
if(CollectionUtil.isNotEmpty(weTags)){
weTagMapper.batchUpdateWeTag(weTags);
}
}
return returnCode;
} }
/** /**
......
...@@ -8,24 +8,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -8,24 +8,34 @@ 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" /> <collection property="weTags" column="weTags.id" ofType="com.linkwechat.wecom.domain.WeTag">
<id property="id" column="tagId"/>
<result property="groupId" column="group_id" />
<result property="name" column="name" />
</collection>
</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"/> SELECT
<where> wtg.*,
<if test="gourpName != null and gourpName != ''"> and gourp_name like concat('%', #{gourpName}, '%')</if> wt.id as tagId,
<if test="order != null "> and order = #{order}</if> wt.group_id,
</where> wt.name
FROM
we_tag_group wtg
INNER JOIN we_tag wt ON wtg.id = wt.group_id
where
wtg.status=0 and wt.status=0
<if test="gourpName != null and gourpName != ''"> and gourp_name like concat('%', #{gourpName}, '%')</if>
</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 +44,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -34,13 +44,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 +57,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -49,7 +57,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>
...@@ -58,11 +65,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -58,11 +65,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delete from we_tag_group where id = #{id} delete from we_tag_group where id = #{id}
</delete> </delete>
<delete id="deleteWeTagGroupByIds" parameterType="String"> <update id="deleteWeTagGroupByIds" parameterType="String">
delete from we_tag_group where id in update we_tag_group set status=1
where id in
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
</delete> </update>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -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>
...@@ -69,5 +64,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -69,5 +64,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
<insert id="batchInsetWeTag" >
insert into we_tag (id, group_id, name, create_time)
values
<foreach collection="list" item="tag" index="index" separator=",">
(#{tag.id},#{tag.groupId},#{tag.name},#{tag.createTime})
</foreach>
</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> </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!