Commit aa8b5b88 by xinla

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

2 parents 57eaa83f 1d704f6c
Showing 36 changed files with 1023 additions and 338 deletions
package com.linkwechat.web.controller.wecom;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.StringUtils;
import com.linkwechat.wecom.domain.WeMsgTlp;
import com.linkwechat.wecom.domain.WeMsgTlpScope;
import com.linkwechat.wecom.service.IWeMsgTlpScopeService;
import com.linkwechat.wecom.service.IWeMsgTlpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
/**
* 欢迎语模板Controller
*
......@@ -27,6 +30,8 @@ public class WeMsgTlpController extends BaseController
private IWeMsgTlpService weMsgTlpService;
@Autowired
private IWeMsgTlpScopeService iWeMsgTlpScopeService;
/**
* 查询欢迎语模板列表
......@@ -36,48 +41,54 @@ public class WeMsgTlpController extends BaseController
public TableDataInfo list(WeMsgTlp weMsgTlp)
{
startPage();
return getDataTable(weMsgTlpService.list(
new LambdaQueryWrapper<WeMsgTlp>()
.like(StringUtils.isNotEmpty(weMsgTlp.getWelcomeMsg()),WeMsgTlp::getWelcomeMsg,weMsgTlp.getWelcomeMsg())
.eq(weMsgTlp.getWelcomeMsgTplType() !=null,WeMsgTlp::getWelcomeMsgTplType,weMsgTlp.getWelcomeMsgTplType())
.like(StringUtils.isNotEmpty(weMsgTlp.getUserIds()),WeMsgTlp::getUserIds,weMsgTlp.getUserIds())
));
List<WeMsgTlp> list = weMsgTlpService.selectWeMsgTlpList(weMsgTlp);
return getDataTable(list);
}
/**
* 获取欢迎语模板详细信息
*/
// @PreAuthorize("@ss.hasPermi('wecom:tlp:query')")
@GetMapping(value = "/scop/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(
iWeMsgTlpScopeService.selectWeMsgTlpScopeList(WeMsgTlpScope.builder().msgTlpId(id).build())
);
}
/**
* 新增欢迎语模板
*/
// @PreAuthorize("@ss.hasPermi('wecom:tlp:add')")
@Log(title = "新增欢迎语模板", businessType = BusinessType.INSERT)
@PostMapping(value = "/addorUpdate")
public AjaxResult addorUpdate(@RequestBody WeMsgTlp weMsgTlp)
@PostMapping
public AjaxResult add(@RequestBody WeMsgTlp weMsgTlp)
{
weMsgTlpService.addorUpdate(weMsgTlp);
return AjaxResult.success();
return toAjax(weMsgTlpService.insertWeMsgTlp(weMsgTlp));
}
/**
* 修改欢迎语模板
*/
// @PreAuthorize("@ss.hasPermi('wecom:tlp:edit')")
@Log(title = "修改欢迎语模板", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult add(@RequestBody WeMsgTlp weMsgTlp){
weMsgTlpService.save(weMsgTlp);
return AjaxResult.success();
public AjaxResult edit(@RequestBody WeMsgTlp weMsgTlp)
{
return toAjax(weMsgTlpService.updateWeMsgTlp(weMsgTlp));
}
/**
* 删除欢迎语模板
*/
// @PreAuthorize("@ss.hasPermi('wecom:tlp:remove')")
@Log(title = "删除欢迎语模板", businessType = BusinessType.DELETE)
@DeleteMapping("/remove/{ids}")
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
weMsgTlpService.removeByIds(CollectionUtil.toList(ids));
return AjaxResult.success();
return toAjax(weMsgTlpService.batchRemoveByids(Arrays.asList(ids)));
}
}
......@@ -100,7 +100,8 @@ public class WeTagGroupController extends BaseController
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(weTagGroupService.deleteWeTagGroupByIds(ids));
weTagGroupService.deleteWeTagGroupByIds(ids);
return AjaxResult.success();
}
......
......@@ -215,6 +215,8 @@ mybatis-plus:
logic-delete-field: delFlag
logic-delete-value: 1
logic-not-delete-value: 0
mpp:
entityBasePath: com.linkwechat.**.domain
## MyBatis配置
#mybatis:
......
......@@ -120,7 +120,7 @@ public class Finance {
System.loadLibrary("libcurl");
System.loadLibrary("WeWorkFinanceSdk");
} else {
System.load("/Users/robin/work/sr_project/sdk/libWeWorkFinanceSdk_Java.so");
System.load("/app/projects/libWeWorkFinanceSdk_Java.so");
}
}
......
package com.linkwechat.framework.config;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
import com.github.pagehelper.PageInterceptor;
import com.linkwechat.common.config.RuoYiConfig;
import com.linkwechat.common.config.WeComeConfig;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.common.utils.SecurityUtils;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.StringValue;
import org.apache.ibatis.plugin.Interceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Arrays;
/**
......@@ -35,55 +28,57 @@ public class MyBatisPlusConfig {
@Bean
public Interceptor[] plugins() {
if(ruoYiConfig.isStartTenant()){ //多租户相关
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(
new TenantLineHandler() {
// 获取租户 ID 值表达式,只支持单个 ID 值
@Override
public Expression getTenantId() {
try {
WeCorpAccount weCorpAccount
= SecurityUtils.getLoginUser().getUser().getWeCorpAccount();
if(null != weCorpAccount){
return new StringValue(weCorpAccount.getCorpId());
}
}catch (Exception e){
return null;
}
return null;
}
// 这是 default 方法,默认返回 false 表示所有表都需要拼多租户条件,
// 这里设置 role表不需要该条件
@Override
public boolean ignoreTable(String tableName) {
if(this.getTenantId()==null){
return true;
}
if (Arrays.asList(weComeConfig.getNeedTenant())
.contains(tableName)){
return false;
}
return true;
}
@Override
public String getTenantIdColumn() {
return "corp_id";
}
}));
return new Interceptor[]{interceptor,new PageInterceptor()
};
}else{
return new Interceptor[]{new PageInterceptor()};
}
return new Interceptor[]{new PageInterceptor()};
// if(ruoYiConfig.isStartTenant()){ //多租户相关
// MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(
// new TenantLineHandler() {
// // 获取租户 ID 值表达式,只支持单个 ID 值
// @Override
// public Expression getTenantId() {
//
// try {
// WeCorpAccount weCorpAccount
// = SecurityUtils.getLoginUser().getUser().getWeCorpAccount();
// if(null != weCorpAccount){
// return new StringValue(weCorpAccount.getCorpId());
// }
// }catch (Exception e){
// return null;
// }
//
// return null;
// }
// // 这是 default 方法,默认返回 false 表示所有表都需要拼多租户条件,
// // 这里设置 role表不需要该条件
// @Override
// public boolean ignoreTable(String tableName) {
//
// if(this.getTenantId()==null){
// return true;
// }
//
//
// if (Arrays.asList(weComeConfig.getNeedTenant())
// .contains(tableName)){
// return false;
// }
// return true;
// }
//
// @Override
// public String getTenantIdColumn() {
//
// return "corp_id";
// }
// }));
// return new Interceptor[]{interceptor,new PageInterceptor()
// };
//
// }else{
// return new Interceptor[]{new PageInterceptor()};
// }
}
}
\ No newline at end of file
......@@ -2,7 +2,6 @@ package com.linkwechat.framework.handler;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.linkwechat.wecom.domain.WeMsgTlp;
import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
......
......@@ -120,7 +120,7 @@ public class SysJobController extends BaseController
/**
* 定时任务立即执行一次
*/
@PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
//@PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
@PutMapping("/run")
public AjaxResult run(@RequestBody SysJob job) throws SchedulerException
......
package com.linkwechat.quartz.task;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @description: 客户画像
* @author: HaoN
* @create: 2021-05-02 21:08
**/
@Slf4j
@Component("customerPortraitTask")
public class CustomerPortraitTask {
}
......@@ -4,6 +4,7 @@ import com.dtflys.forest.annotation.*;
import com.linkwechat.wecom.domain.dto.WeDepartMentDto;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor;
import com.linkwechat.wecom.interceptor.WeCommonAccessTokenInterceptor;
import com.linkwechat.wecom.retry.WeCommonRetryWhen;
/**
......@@ -11,7 +12,7 @@ import com.linkwechat.wecom.retry.WeCommonRetryWhen;
* @author: HaoN
* @create: 2020-08-27 16:40
**/
@BaseRequest(baseURL = "${weComServerUrl}${weComePrefix}", interceptor = WeAccessTokenInterceptor.class)
@BaseRequest(baseURL = "${weComServerUrl}${weComePrefix}", interceptor = WeCommonAccessTokenInterceptor.class)
@Retry(maxRetryCount = "3", maxRetryInterval = "1000", condition = WeCommonRetryWhen.class)
public interface WeDepartMentClient {
......
......@@ -4,6 +4,7 @@ import com.dtflys.forest.annotation.*;
import com.linkwechat.wecom.domain.dto.*;
import com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor;
import com.linkwechat.wecom.interceptor.WeAppAccessTokenInterceptor;
import com.linkwechat.wecom.interceptor.WeCommonAccessTokenInterceptor;
import com.linkwechat.wecom.retry.WeCommonRetryWhen;
/**
......@@ -11,7 +12,7 @@ import com.linkwechat.wecom.retry.WeCommonRetryWhen;
* @author: HaoN
* @create: 2020-08-27 16:42
**/
@BaseRequest(baseURL = "${weComServerUrl}${weComePrefix}", interceptor = WeAccessTokenInterceptor.class)
@BaseRequest(baseURL = "${weComServerUrl}${weComePrefix}", interceptor = WeCommonAccessTokenInterceptor.class)
@Retry(maxRetryCount = "3", maxRetryInterval = "1000", condition = WeCommonRetryWhen.class)
public interface WeUserClient {
......
......@@ -179,6 +179,19 @@ public class WeCustomer extends BaseEntity {
private Date firstAddTime;
//qq
private String qq;
//邮箱
private String email;
//地址
private String address;
//手机号
private String phone;
/**
* 0:正常;1:删除
*/
......
......@@ -55,4 +55,8 @@ public class WeCustomerPortrait {
//客户社交关系
private WeCustomerSocialConn socialConn;
private String tagNames;
private String tagIds;
}
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.wecom.handler.GenericTypeHandler;
import io.swagger.models.auth.In;
import lombok.Data;
......@@ -19,75 +15,29 @@ import java.util.List;
* @date 2020-10-04
*/
@Data
@TableName(value = "we_msg_tlp",autoResultMap = true)
public class WeMsgTlp extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
@TableId
private Long id;
private Long id= SnowFlakeUtil.nextId();
/** 欢迎语 */
private String welcomeMsg;
/**图片url*/
private String picUrl;
/**图文*/
@TableField(typeHandler = GenericTypeHandler.class)
private List<ImageText> imageText;
/**小程序*/
@TableField(typeHandler = GenericTypeHandler.class)
private List<Applet> applet;
/** 素材的id */
private Long mediaId;
/** 0:正常;1:删除; */
private Integer delFlag;
/** 欢迎语模板类型:1:活码欢迎语;2:员工欢迎语;3:入群欢迎语 */
private Integer welcomeMsgTplType;
/**用户名 */
private String userNames;
/**用户id,用逗号隔开*/
private String userIds;
@Data
public static class Applet{
//小程序标题
private String appTile;
//小程序id
private String appId;
//小程序路径
private String appPath;
//小程序图片
private String appPic;
}
@Data
public static class ImageText{
private Integer delFlag=new Integer(0);
//图文标题
private String imageTextTile;
/** 欢迎语模板类型:1:员工欢迎语;2:部门员工欢迎语;3:客户群欢迎语 */
private Long welcomeMsgTplType;
//图文url
private String imageTextUrl;
/** 欢迎语模板使用范围 */
private List<WeMsgTlpScope> weMsgTlpScopes;
}
private String materialUrl;
......
package com.linkwechat.wecom.domain;
import com.linkwechat.common.annotation.Excel;
import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.SuperBuilder;
/**
* 模板使用人员范围对象 we_msg_tlp_scope
*
* @author ruoyi
* @date 2020-10-04
*/
@Data
@SuperBuilder
public class WeMsgTlpScope extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id= SnowFlakeUtil.nextId();
/** 模板id */
@Excel(name = "模板id")
private Long msgTlpId;
/** 使用人id */
@Excel(name = "使用人id")
private Long useUserId;
/** 0:正常;1:删除; */
private Integer delFlag=new Integer(0);
}
......@@ -40,6 +40,10 @@ public class WeTagGroup extends BaseEntity
@TableField(exist = false)
private List<WeTag> weTags;
/**新增标签 */
@TableField(exist = false)
private List<WeTag> addWeTags;
/** 分组id */
@TableId
......
......@@ -41,7 +41,7 @@ public class WeCropGroupTagDto {
.group_id(weTagGroup.getGroupId())
.group_name(weTagGroup.getGourpName())
.build();
List<WeTag> newAddWeTag = weTagGroup.getWeTags();
List<WeTag> newAddWeTag = weTagGroup.getAddWeTags();
if(CollectionUtil.isNotEmpty(newAddWeTag)){
//新增的标签
// List<WeTag> newAddWeTag
......
......@@ -3,7 +3,6 @@ package com.linkwechat.wecom.handler;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.linkwechat.wecom.domain.WeMoments;
import com.linkwechat.wecom.domain.WeMsgTlp;
import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
......@@ -20,7 +19,7 @@ import java.sql.SQLException;
* @param <T>
*/
@SuppressWarnings("all")
@MappedTypes(value = {JSONObject.class, CustomerMessagePushDto.class, WeMsgTlp.Applet.class,WeMsgTlp.ImageText.class,
@MappedTypes(value = {JSONObject.class, CustomerMessagePushDto.class,
WeMoments.OtherContent.class})
@MappedJdbcTypes(value = {JdbcType.VARCHAR}, includeNullJdbcType = true)
public class GenericTypeHandler<T extends Object> extends BaseTypeHandler<T> {
......
......@@ -17,7 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @description: 微信token拦截器
* @description: 微信token拦截器(外部联系人)
* @author: HaoN
* @create: 2020-08-27 22:36
**/
......
package com.linkwechat.wecom.interceptor;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.dtflys.forest.exceptions.ForestRuntimeException;
import com.dtflys.forest.http.ForestRequest;
import com.dtflys.forest.http.ForestResponse;
import com.dtflys.forest.interceptor.Interceptor;
import com.linkwechat.common.config.WeComeConfig;
import com.linkwechat.common.enums.WeErrorCodeEnum;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import com.linkwechat.wecom.service.IWeAccessTokenService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @description: 微信token拦截器(外部联系人)
* @author: HaoN
* @create: 2020-08-27 22:36
**/
@Slf4j
@Component
public class WeCommonAccessTokenInterceptor implements Interceptor<WeResultDto> {
@Autowired
private IWeAccessTokenService iWeAccessTokenService;
@Autowired
private WeComeConfig weComeConfig;
/**
* 该方法在请求发送之前被调用, 若返回false则不会继续发送请求
*/
@Override
public boolean beforeExecute(ForestRequest request) {
String token = iWeAccessTokenService.findCommonAccessToken();
request.replaceOrAddQuery("access_token", token);
return true;
}
/**
* 请求发送失败时被调用
*
* @param e
* @param forestRequest
* @param forestResponse
*/
@Override
public void onError(ForestRuntimeException e, ForestRequest forestRequest, ForestResponse forestResponse) {
log.info("url:{},------params:{},----------result:" + forestRequest.getUrl(), JSONObject.toJSONString(forestRequest.getArguments()), forestResponse.getContent());
if (StringUtils.isNotEmpty(forestResponse.getContent())) {
throw new ForestRuntimeException(forestResponse.getContent());
} else {
throw new ForestRuntimeException("网络请求超时");
}
}
/**
* 请求成功调用(微信端错误异常统一处理)
*
* @param resultDto
* @param forestRequest
* @param forestResponse
*/
@Override
public void onSuccess(WeResultDto resultDto, ForestRequest forestRequest, ForestResponse forestResponse) {
log.info("url:{},result:{}", forestRequest.getUrl(), forestResponse.getContent());
if (null != resultDto.getErrcode() && !ObjectUtil.equal(WeErrorCodeEnum.ERROR_CODE_0.getErrorCode(), resultDto.getErrcode())
&& !weComeConfig.getWeNeedRetryErrorCodes().contains(resultDto.getErrcode())) {
throw new ForestRuntimeException(WeErrorCodeEnum.parseEnum(resultDto.getErrcode()).getErrorMsg());
}
}
/**
* 请求重试
* @param request 请求
* @param response 返回值
*/
@Override
public void onRetry(ForestRequest request, ForestResponse response) {
log.info("url:{}, query:{},params:{}, 重试原因:{}, 当前重试次数:{}",request.getUrl(),request.getQueryString(), JSONObject.toJSONString(request.getArguments()),response.getContent(), request.getCurrentRetryCount());
WeResultDto weResultDto = JSONUtil.toBean(response.getContent(), WeResultDto.class);
//当错误码符合重置token时,刷新token
if(!ObjectUtil.equal(WeErrorCodeEnum.ERROR_CODE_OWE_1.getErrorCode(),weResultDto.getErrcode())
&& weComeConfig.getWeNeedRetryErrorCodes().contains(weResultDto.getErrcode())){
//删除缓存
iWeAccessTokenService.removeCommonAccessToken();
//重新查询token
String token = iWeAccessTokenService.findCommonAccessToken();
request.replaceOrAddQuery("access_token", token);
}
}
}
package com.linkwechat.wecom.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeMsgTlp;
import org.apache.ibatis.annotations.Param;
......@@ -12,7 +10,7 @@ import org.apache.ibatis.annotations.Param;
* @author ruoyi
* @date 2020-10-04
*/
public interface WeMsgTlpMapper extends BaseMapper<WeMsgTlp>
public interface WeMsgTlpMapper
{
/**
* 查询欢迎语模板
......@@ -22,13 +20,13 @@ public interface WeMsgTlpMapper extends BaseMapper<WeMsgTlp>
*/
public WeMsgTlp selectWeMsgTlpById(Long id);
// /**
// * 查询欢迎语模板列表
// *
// * @param weMsgTlp 欢迎语模板
// * @return 欢迎语模板集合
// */
// public List<WeMsgTlp> selectWeMsgTlpList(WeMsgTlp weMsgTlp);
/**
* 查询欢迎语模板列表
*
* @param weMsgTlp 欢迎语模板
* @return 欢迎语模板集合
*/
public List<WeMsgTlp> selectWeMsgTlpList(WeMsgTlp weMsgTlp);
/**
* 新增欢迎语模板
......
package com.linkwechat.wecom.mapper;
import java.util.List;
import com.linkwechat.wecom.domain.WeMsgTlpScope;
import org.apache.ibatis.annotations.Param;
/**
* 模板使用人员范围Mapper接口
*
* @author ruoyi
* @date 2020-10-04
*/
public interface WeMsgTlpScopeMapper
{
/**
* 查询模板使用人员范围
*
* @param id 模板使用人员范围ID
* @return 模板使用人员范围
*/
public WeMsgTlpScope selectWeMsgTlpScopeById(Long id);
/**
* 查询模板使用人员范围列表
*
* @param weMsgTlpScope 模板使用人员范围
* @return 模板使用人员范围集合
*/
public List<WeMsgTlpScope> selectWeMsgTlpScopeList(WeMsgTlpScope weMsgTlpScope);
/**
* 新增模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
public int insertWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope);
/**
* 修改模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
public int updateWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope);
/**
* 删除模板使用人员范围
*
* @param id 模板使用人员范围ID
* @return 结果
*/
public int deleteWeMsgTlpScopeById(Long id);
/**
* 批量删除模板使用人员范围
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteWeMsgTlpScopeByIds(Long[] ids);
/**
* 批量保存模板使用人员范围
* @param weMsgTlpScopes
* @return
*/
public int batchInsetWeMsgTlpScope(@Param("weMsgTlpScopes") List<WeMsgTlpScope> weMsgTlpScopes);
/**
* 模板id,批量删除
* @param msgTlpIds
* @return
*/
public int batchRemoveWeMsgTlpScopesByMsgTlpIds(List<Long> msgTlpIds);
}
......@@ -66,10 +66,11 @@ public interface WeTagGroupMapper extends BaseMapper<WeTagGroup>
/**
* 根据企业员工与添加客户关系id给客户打标签
* @param flowerCustomerRelId
* @param externalUserid
* @param userid
* @return
*/
public List<WeTagGroup> findCustomerTagByFlowerCustomerRelId(@Param("flowerCustomerRelId") String flowerCustomerRelId);
public List<WeTagGroup> findCustomerTagByFlowerCustomerRelId(@Param("externalUserid") String externalUserid, @Param("userid") String userid);
......
......@@ -30,7 +30,7 @@ public interface IWeAccessTokenService {
public void removeToken(WeCorpAccount wxCorpAccount);
public void removeCommonAccessToken();
public void removeContactAccessToken();
public void removeChatAccessToken();
......
package com.linkwechat.wecom.service;
import java.util.List;
import com.linkwechat.wecom.domain.WeMsgTlpScope;
/**
* 模板使用人员范围Service接口
*
* @author ruoyi
* @date 2020-10-04
*/
public interface IWeMsgTlpScopeService
{
/**
* 查询模板使用人员范围
*
* @param id 模板使用人员范围ID
* @return 模板使用人员范围
*/
public WeMsgTlpScope selectWeMsgTlpScopeById(Long id);
/**
* 查询模板使用人员范围列表
*
* @param weMsgTlpScope 模板使用人员范围
* @return 模板使用人员范围集合
*/
public List<WeMsgTlpScope> selectWeMsgTlpScopeList(WeMsgTlpScope weMsgTlpScope);
/**
* 新增模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
public int insertWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope);
/**
* 修改模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
public int updateWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope);
/**
* 批量删除模板使用人员范围
*
* @param ids 需要删除的模板使用人员范围ID
* @return 结果
*/
public int deleteWeMsgTlpScopeByIds(Long[] ids);
/**
* 删除模板使用人员范围信息
*
* @param id 模板使用人员范围ID
* @return 结果
*/
public int deleteWeMsgTlpScopeById(Long id);
/**
* 批量保存模板使用人员范围
* @param weMsgTlpScopes
* @return
*/
public int batchInsetWeMsgTlpScope(List<WeMsgTlpScope> weMsgTlpScopes);
/**
* 通过使用者id批量删除
* @param useUserIds
* @return
*/
public int batchRemoveWeMsgTlpScopesByMsgTlpIds(List<Long> useUserIds);
}
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import com.linkwechat.wecom.domain.WeMsgTlp;
/**
......@@ -9,9 +9,23 @@ import com.linkwechat.wecom.domain.WeMsgTlp;
* @author ruoyi
* @date 2020-10-04
*/
public interface IWeMsgTlpService extends IService<WeMsgTlp>
public interface IWeMsgTlpService
{
/**
* 查询欢迎语模板
*
* @param id 欢迎语模板ID
* @return 欢迎语模板
*/
public WeMsgTlp selectWeMsgTlpById(Long id);
/**
* 查询欢迎语模板列表
*
* @param weMsgTlp 欢迎语模板
* @return 欢迎语模板集合
*/
public List<WeMsgTlp> selectWeMsgTlpList(WeMsgTlp weMsgTlp);
/**
* 新增欢迎语模板
......@@ -19,7 +33,37 @@ public interface IWeMsgTlpService extends IService<WeMsgTlp>
* @param weMsgTlp 欢迎语模板
* @return 结果
*/
void addorUpdate(WeMsgTlp weMsgTlp);
public int insertWeMsgTlp(WeMsgTlp weMsgTlp);
/**
* 修改欢迎语模板
*
* @param weMsgTlp 欢迎语模板
* @return 结果
*/
public int updateWeMsgTlp(WeMsgTlp weMsgTlp);
/**
* 批量删除欢迎语模板
*
* @param ids 需要删除的欢迎语模板ID
* @return 结果
*/
public int deleteWeMsgTlpByIds(Long[] ids);
/**
* 删除欢迎语模板信息
*
* @param id 欢迎语模板ID
* @return 结果
*/
public int deleteWeMsgTlpById(Long id);
/**
* 批量逻辑删除
* @param msgTlpIds
* @return
*/
public int batchRemoveByids(List<Long> msgTlpIds);
}
......@@ -46,7 +46,7 @@ public interface IWeTagGroupService extends IService<WeTagGroup>
* @param ids 需要删除的标签组ID
* @return 结果
*/
public int deleteWeTagGroupByIds(String[] ids);
public void deleteWeTagGroupByIds(String[] ids);
......@@ -77,5 +77,5 @@ public interface IWeTagGroupService extends IService<WeTagGroup>
* @param flowerCustomerRelId
* @return
*/
public List<WeTagGroup> findCustomerTagByFlowerCustomerRelId(String flowerCustomerRelId);
public List<WeTagGroup> findCustomerTagByFlowerCustomerRelId(String externalUserid, String userid);
}
......@@ -272,6 +272,12 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
}
@Override
public void removeCommonAccessToken() {
redisCache.deleteObject(WeConstans.WE_COMMON_ACCESS_TOKEN);
}
@Override
public void removeContactAccessToken() {
redisCache.deleteObject(WeConstans.WE_CONTACT_ACCESS_TOKEN);
}
......
......@@ -599,7 +599,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
//获取当前客户拥有得标签
weCustomerPortrait.setWeTagGroupList(
iWeTagGroupService.findCustomerTagByFlowerCustomerRelId(
weCustomerPortrait.getFlowerCustomerRelId()
externalUserid,userid
)
);
......@@ -621,12 +621,22 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
WeCustomer weCustomer
= WeCustomer.builder().build();
BeanUtils.copyBeanProp(weCustomer,weCustomerPortrait);
//手机号
weCustomer.setPhone(weCustomerPortrait.getRemarkMobiles());
weCustomer.setCorpName(weCustomerPortrait.getRemarkCorpName());
weCustomer.setFirstUserId(weCustomerPortrait.getUserId());
this.update(weCustomer,new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getFirstUserId,weCustomerPortrait.getUserId())
.eq(WeCustomer::getExternalUserid,weCustomerPortrait.getExternalUserid()));
//更新用户基本信息表
this.updateById(
weCustomer
);
WeFlowerCustomerRel weFlowerCustomerRel = WeFlowerCustomerRel.builder().build();
BeanUtils.copyBeanProp(weFlowerCustomerRel,weCustomerPortrait);
// this.baseMapper.batchAddOrUpdate(ListUtil.toList(weCustomer));
// this.updateById(
// weCustomer
// );
// WeFlowerCustomerRel weFlowerCustomerRel = WeFlowerCustomerRel.builder().build();
// BeanUtils.copyBeanProp(weFlowerCustomerRel,weCustomerPortrait);
//添加轨迹内容(信息动态)
iWeCustomerTrajectoryService.inforMationNews(weCustomerPortrait.getUserId(),weCustomerPortrait.getExternalUserid(), TrajectorySceneType.TRAJECTORY_TYPE_XXDT_BCZL.getKey());
}
......
package com.linkwechat.wecom.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.linkwechat.wecom.mapper.WeMsgTlpScopeMapper;
import com.linkwechat.wecom.domain.WeMsgTlpScope;
import com.linkwechat.wecom.service.IWeMsgTlpScopeService;
/**
* 模板使用人员范围Service业务层处理
*
* @author ruoyi
* @date 2020-10-04
*/
@Service
public class WeMsgTlpScopeServiceImpl implements IWeMsgTlpScopeService
{
@Autowired
private WeMsgTlpScopeMapper weMsgTlpScopeMapper;
/**
* 查询模板使用人员范围
*
* @param id 模板使用人员范围ID
* @return 模板使用人员范围
*/
@Override
public WeMsgTlpScope selectWeMsgTlpScopeById(Long id)
{
return weMsgTlpScopeMapper.selectWeMsgTlpScopeById(id);
}
/**
* 查询模板使用人员范围列表
*
* @param weMsgTlpScope 模板使用人员范围
* @return 模板使用人员范围
*/
@Override
public List<WeMsgTlpScope> selectWeMsgTlpScopeList(WeMsgTlpScope weMsgTlpScope)
{
return weMsgTlpScopeMapper.selectWeMsgTlpScopeList(weMsgTlpScope);
}
/**
* 新增模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
@Override
public int insertWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope)
{
return weMsgTlpScopeMapper.insertWeMsgTlpScope(weMsgTlpScope);
}
/**
* 修改模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
@Override
public int updateWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope)
{
return weMsgTlpScopeMapper.updateWeMsgTlpScope(weMsgTlpScope);
}
/**
* 批量删除模板使用人员范围
*
* @param ids 需要删除的模板使用人员范围ID
* @return 结果
*/
@Override
public int deleteWeMsgTlpScopeByIds(Long[] ids)
{
return weMsgTlpScopeMapper.deleteWeMsgTlpScopeByIds(ids);
}
/**
* 删除模板使用人员范围信息
*
* @param id 模板使用人员范围ID
* @return 结果
*/
@Override
public int deleteWeMsgTlpScopeById(Long id)
{
return weMsgTlpScopeMapper.deleteWeMsgTlpScopeById(id);
}
/**
* 批量保存模板使用人员范围
* @param weMsgTlpScopes
* @return
*/
@Override
public int batchInsetWeMsgTlpScope(List<WeMsgTlpScope> weMsgTlpScopes) {
return weMsgTlpScopeMapper.batchInsetWeMsgTlpScope(weMsgTlpScopes);
}
/**
* 通过使用者id,批量删除
* @param useUserIds
* @return
*/
@Override
public int batchRemoveWeMsgTlpScopesByMsgTlpIds(List<Long> useUserIds) {
return weMsgTlpScopeMapper.batchRemoveWeMsgTlpScopesByMsgTlpIds(useUserIds);
}
}
package com.linkwechat.wecom.service.impl;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.service.IWeUserService;
import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.wecom.domain.WeMsgTlpScope;
import com.linkwechat.wecom.service.IWeMsgTlpScopeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.linkwechat.wecom.mapper.WeMsgTlpMapper;
......@@ -23,12 +24,37 @@ import org.springframework.transaction.annotation.Transactional;
* @date 2020-10-04
*/
@Service
public class WeMsgTlpServiceImpl extends ServiceImpl<WeMsgTlpMapper,WeMsgTlp> implements IWeMsgTlpService
public class WeMsgTlpServiceImpl implements IWeMsgTlpService
{
@Autowired
private WeMsgTlpMapper weMsgTlpMapper;
@Autowired
private IWeUserService iWeUserService;
private IWeMsgTlpScopeService iWeMsgTlpScopeService;
/**
* 查询欢迎语模板
*
* @param id 欢迎语模板ID
* @return 欢迎语模板
*/
@Override
public WeMsgTlp selectWeMsgTlpById(Long id)
{
return weMsgTlpMapper.selectWeMsgTlpById(id);
}
/**
* 查询欢迎语模板列表
*
* @param weMsgTlp 欢迎语模板
* @return 欢迎语模板
*/
@Override
public List<WeMsgTlp> selectWeMsgTlpList(WeMsgTlp weMsgTlp)
{
return weMsgTlpMapper.selectWeMsgTlpList(weMsgTlp);
}
/**
* 新增欢迎语模板
......@@ -37,34 +63,91 @@ public class WeMsgTlpServiceImpl extends ServiceImpl<WeMsgTlpMapper,WeMsgTlp> im
* @return 结果
*/
@Override
@Transactional
public void addorUpdate(WeMsgTlp weMsgTlp)
public int insertWeMsgTlp(WeMsgTlp weMsgTlp)
{
weMsgTlp.setCreateBy(SecurityUtils.getUsername());
weMsgTlp.setCreateTime(new Date());
return weMsgTlpMapper.insertWeMsgTlp(weMsgTlp);
// if(returnCode>0){
// List<WeMsgTlpScope> weMsgTlpScopess = weMsgTlp.getWeMsgTlpScopes();
// if(CollectionUtil.isNotEmpty(weMsgTlpScopess)){
//
// List<WeMsgTlpScope> weMsgTlpScopes=weMsgTlp.getWeMsgTlpScopes().stream().filter(c -> c.getUseUserId() != null).collect(Collectors.toList());
// if(CollectionUtil.isNotEmpty(weMsgTlpScopes)){
//
// weMsgTlpScopes.forEach(v->{
// v.setMsgTlpId(weMsgTlp.getId());
// v.setId(SnowFlakeUtil.nextId());
// });
//
// iWeMsgTlpScopeService.batchInsetWeMsgTlpScope(weMsgTlpScopes);
// }
//
// }
// }
// return returnCode;
}
/**
* 修改欢迎语模板
*
* @param weMsgTlp 欢迎语模板
* @return 结果
*/
@Override
public int updateWeMsgTlp(WeMsgTlp weMsgTlp)
{
if(weMsgTlp.getWelcomeMsgTplType()
.equals(new Integer(2))) {
String userIds = weMsgTlp.getUserIds();
if (StringUtils.isNotEmpty(userIds)) {
List<WeUser> weUsers = iWeUserService.listByIds(
ListUtil.toList(userIds.split(","))
);
if (CollectionUtil.isNotEmpty(weUsers)) {
weMsgTlp.setUserNames(String.join(",",
weUsers.stream().map(WeUser::getName).collect(Collectors.toList())));
}
}
}
this.saveOrUpdate(weMsgTlp);
// int returnCode = weMsgTlpMapper.updateWeMsgTlp(weMsgTlp);
//
// if(returnCode>0){
// iWeMsgTlpScopeService.batchRemoveWeMsgTlpScopesByMsgTlpIds(ListUtil.toList(weMsgTlp.getId()));
// List<WeMsgTlpScope> weMsgTlpScopes = weMsgTlp.getWeMsgTlpScopes().stream().filter(c -> c.getUseUserId() != null).collect(Collectors.toList());
//
// if(CollectionUtil.isNotEmpty(weMsgTlpScopes)){
// weMsgTlpScopes.stream().forEach(v->v.setMsgTlpId(weMsgTlp.getId()));
// iWeMsgTlpScopeService.batchInsetWeMsgTlpScope(weMsgTlpScopes);
// }
//
// }
return weMsgTlpMapper.updateWeMsgTlp(weMsgTlp);
}
/**
* 批量删除欢迎语模板
*
* @param ids 需要删除的欢迎语模板ID
* @return 结果
*/
@Override
public int deleteWeMsgTlpByIds(Long[] ids)
{
return weMsgTlpMapper.deleteWeMsgTlpByIds(ids);
}
/**
* 删除欢迎语模板信息
*
* @param id 欢迎语模板ID
* @return 结果
*/
@Override
public int deleteWeMsgTlpById(Long id)
{
return weMsgTlpMapper.deleteWeMsgTlpById(id);
}
/**
* 批量逻辑删除
* @param msgTlpIds
* @return
*/
@Override
public int batchRemoveByids(List<Long> msgTlpIds) {
return weMsgTlpMapper.batchRemoveByids(msgTlpIds);
}
}
......@@ -101,47 +101,103 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
public void updateWeTagGroup(WeTagGroup weTagGroup) {
List<WeTag> weTags = weTagGroup.getWeTags();
//获取新增的集合
if (CollectionUtil.isNotEmpty(weTags)) {
List<WeTag> filterWeTags = weTags.stream().filter(v -> StringUtils.isEmpty(v.getTagId())).collect(Collectors.toList());
//同步新增标签到微信端
if (CollectionUtil.isNotEmpty(WeCropGroupTagDto.transformAddTag(weTagGroup).getTag())) {
WeCropGropTagDtlDto
List<WeTag> removeWeTags =new ArrayList<>();
if(CollectionUtil.isNotEmpty(weTags)){
//新增的标签
List<WeTag> addWeTags = weTags.stream().filter(v -> StringUtils.isEmpty(v.getTagId())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(addWeTags)){
weTagGroup.setAddWeTags(addWeTags);
WeCropGropTagDtlDto
weCropGropTagDtlDto = weCropTagClient.addCorpTag(WeCropGroupTagDto.transformAddTag(weTagGroup));
if (weCropGropTagDtlDto.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)) {
//微信端返回的标签主键,设置到weTags中
Map<String, String> weCropTagMap = weCropGropTagDtlDto.getTag_group().getTag().stream()
.collect(Collectors.toMap(weCropTagDto -> weCropTagDto.getName(), weCropTagDto -> weCropTagDto.getId()));
filterWeTags.stream().forEach(tag -> {
addWeTags.stream().forEach(tag -> {
tag.setTagId(weCropTagMap.get(tag.getName()));
});
}
}
addWeTags.stream().forEach(v -> v.setGroupId(weTagGroup.getGroupId()));
iWeTagService.saveBatch(addWeTags);
}
//获取需要删除的数据
List<WeTag> removeWeTags = iWeTagService.list(new LambdaQueryWrapper<WeTag>().notIn(WeTag::getTagId,
weTags.stream().map(WeTag::getTagId).collect(Collectors.toList())).eq(WeTag::getGroupId, weTagGroup.getGroupId()));
}
removeWeTags.addAll(
iWeTagService.list(new LambdaQueryWrapper<WeTag>().notIn(WeTag::getTagId,
weTags.stream().map(WeTag::getTagId).collect(Collectors.toList()))
.eq(WeTag::getGroupId, weTagGroup.getGroupId()))
);
}else{//删除所有标签
removeWeTags.addAll(
iWeTagService.list(new LambdaQueryWrapper<WeTag>()
.eq(WeTag::getGroupId, weTagGroup.getGroupId()))
);
}
if (CollectionUtil.isNotEmpty(removeWeTags)) {
//同步删除微信端的标签
if(CollectionUtil.isNotEmpty(removeWeTags)){
//同步删除微信端的标签
try {
weCropTagClient.delCorpTag(
WeCropDelDto.builder()
.group_id(ArrayUtil.toArray(ListUtil.toList(weTagGroup.getGroupId()), String.class))
.tag_id(ArrayUtil.toArray(removeWeTags.stream().map(WeTag::getTagId).collect(Collectors.toList()), String.class))
.build());
}catch (Exception e){
log.error(e.getMessage());
} finally {
//移除本地
iWeTagService.removeByIds(removeWeTags.stream().map(WeTag::getTagId).collect(Collectors.toList()));
}
}
//保存或更新wetag
filterWeTags.stream().forEach(v -> v.setGroupId(weTagGroup.getGroupId()));
iWeTagService.saveOrUpdateBatch(filterWeTags);
}
//获取新增的集合
// if (CollectionUtil.isNotEmpty(weTags)) {
// List<WeTag> filterWeTags = weTags.stream().filter(v -> StringUtils.isEmpty(v.getTagId())).collect(Collectors.toList());
//
// //同步新增标签到微信端
// if (CollectionUtil.isNotEmpty(WeCropGroupTagDto.transformAddTag(weTagGroup).getTag())) {
// WeCropGropTagDtlDto
// weCropGropTagDtlDto = weCropTagClient.addCorpTag(WeCropGroupTagDto.transformAddTag(weTagGroup));
// if (weCropGropTagDtlDto.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)) {
// //微信端返回的标签主键,设置到weTags中
// Map<String, String> weCropTagMap = weCropGropTagDtlDto.getTag_group().getTag().stream()
// .collect(Collectors.toMap(weCropTagDto -> weCropTagDto.getName(), weCropTagDto -> weCropTagDto.getId()));
// filterWeTags.stream().forEach(tag -> {
// tag.setTagId(weCropTagMap.get(tag.getName()));
// });
// }
// }
//
//
// //获取需要删除的数据
// List<WeTag> removeWeTags = iWeTagService.list(new LambdaQueryWrapper<WeTag>().notIn(WeTag::getTagId,
// weTags.stream().map(WeTag::getTagId).collect(Collectors.toList())).eq(WeTag::getGroupId, weTagGroup.getGroupId()));
//
// if (CollectionUtil.isNotEmpty(removeWeTags)) {
// //同步删除微信端的标签
// weCropTagClient.delCorpTag(
// WeCropDelDto.builder()
// .group_id(ArrayUtil.toArray(ListUtil.toList(weTagGroup.getGroupId()), String.class))
// .tag_id(ArrayUtil.toArray(removeWeTags.stream().map(WeTag::getTagId).collect(Collectors.toList()), String.class))
// .build());
//
// //移除本地
// iWeTagService.removeByIds(removeWeTags.stream().map(WeTag::getTagId).collect(Collectors.toList()));
// }
//
//
// //保存或更新wetag
// filterWeTags.stream().forEach(v -> v.setGroupId(weTagGroup.getGroupId()));
// iWeTagService.saveOrUpdateBatch(filterWeTags);
//
// }
}
......@@ -154,27 +210,26 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
*/
@Override
@Transactional
public int deleteWeTagGroupByIds(String[] ids) {
int returnCode = weTagGroupMapper.deleteWeTagGroupByIds(ids);
if (returnCode > Constants.SERVICE_RETURN_SUCCESS_CODE) {
public void deleteWeTagGroupByIds(String[] ids) {
if (this.removeByIds(CollectionUtil.toList(ids))) {
List<WeTag> weTags
= iWeTagService.list(new LambdaQueryWrapper<WeTag>().in(WeTag::getGroupId, ids));
if (CollectionUtil.isNotEmpty(weTags)) {
weCropTagClient.delCorpTag(
WeCropDelDto.builder()
.group_id(ids)
.tag_id(weTags.stream().map(WeTag::getTagId).toArray(String[]::new))
.build()
);
try {
weCropTagClient.delCorpTag(
WeCropDelDto.builder()
.group_id(ids)
.tag_id(weTags.stream().map(WeTag::getTagId).toArray(String[]::new))
.build()
);
}catch (Exception e){//防止数据不同步产生的错误
log.error(e.getMessage());
}
}
}
return returnCode;
}
......@@ -336,8 +391,8 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
}
@Override
public List<WeTagGroup> findCustomerTagByFlowerCustomerRelId(String flowerCustomerRelId) {
return this.baseMapper.findCustomerTagByFlowerCustomerRelId(flowerCustomerRelId);
public List<WeTagGroup> findCustomerTagByFlowerCustomerRelId(String externalUserid, String userid) {
return this.baseMapper.findCustomerTagByFlowerCustomerRelId(externalUserid, userid);
}
......
......@@ -438,26 +438,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="findCustomerByOperUseridAndCustomerId" resultType="com.linkwechat.wecom.domain.WeCustomerPortrait">
SELECT
wc.`name`,
wfcr.remark,
wfcr.remark_mobiles,
wc.birthday,
wfcr.email,
wfcr.address,
wfcr.qq,
wc.position,
wfcr.remark_corp_name,
wfcr.description,
wfcr.id as flowerCustomerRelId,
wfcr.user_id,
wc.avatar,
wfcr.external_userid,
wc.gender
FROM
we_customer wc
LEFT JOIN we_flower_customer_rel wfcr on wc.external_userid=wfcr.external_userid
WHERE wc.external_userid=#{externalUserid} and wfcr.user_id=#{userid}
SELECT
wc.`name`,
wc.other_descr as remark,
wc.phone as remark_mobiles,
wc.birthday,
wc.email,
wc.address,
wc.qq,
wc.position,
wc.corp_name as remark_corp_name,
wc.other_descr as description,
wc.first_user_id as user_id,
wc.avatar,
wc.external_userid,
wc.gender,
GROUP_CONCAT(wt.`name`) as tagNames,
GROUP_CONCAT(wt.`tag_id`) as tagIds
FROM
we_customer wc
LEFT JOIN we_flower_customer_tag_rel wfcrf ON wfcrf.user_id = wc.first_user_id
LEFT JOIN we_tag wt ON wt.tag_id = wfcrf.tag_id
WHERE wc.external_userid=#{externalUserid} and wc.first_user_id=#{userid}
</select>
......@@ -467,7 +469,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT
count(*)
FROM
we_flower_customer_rel wfcr WHERE wfcr.external_userid=wc.external_userid
we_customer wfcr WHERE wfcr.external_userid=wc.external_userid
) AS addEmployeNum,
(
SELECT
......@@ -485,7 +487,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
`we_group_member` where union_id=wc.external_userid
) and user_id=#{userid}
) AS commonGroupNum
FROM we_customer wc WHERE wc.external_userid=#{externalUserid}
FROM we_customer wc WHERE wc.external_userid=#{externalUserid} and wc.first_user_id=#{userid}
</select>
......@@ -526,44 +528,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<insert id="batchAddOrUpdate">
INSERT INTO we_customer(
external_userid,
NAME,
avatar,
type,
gender,
unionid,
birthday,
corp_name,
corp_full_name,
position,
is_open_chat,
create_time,
create_by,
first_user_id,
first_add_time
) values
<foreach collection="weCustomers" item="item" index="index" separator=",">
(#{item.externalUserid},#{item.name},#{item.avatar},#{item.type},#{item.gender}, #{item.unionid},#{item.birthday},
#{item.corpName},#{item.corpFullName},#{item.position},#{item.isOpenChat}, #{item.createTime},
#{item.createBy},#{item.firstUserId},#{item.firstAddTime}
)
</foreach>
ON DUPLICATE KEY UPDATE
NAME=IF(we_customer.NAME != null, VALUES(NAME), we_customer.NAME),
avatar=IF(we_customer.avatar != null, VALUES(avatar), we_customer.avatar),
type=IF(we_customer.type != null, VALUES(type), we_customer.type),
gender=IF(we_customer.gender != null, VALUES(gender), we_customer.gender),
unionid=IF(we_customer.unionid != null, VALUES(unionid), we_customer.unionid),
birthday=IF(we_customer.birthday != null,VALUES(birthday), we_customer.birthday),
corp_name=IF(we_customer.corp_name != null, VALUES(corp_name), we_customer.corp_name),
corp_full_name=IF(we_customer.corp_full_name != null, VALUES(corp_full_name), we_customer.corp_full_name),
position=IF(we_customer.position != null, VALUES(position), we_customer.position),
is_open_chat=IF(we_customer.is_open_chat != null, VALUES(is_open_chat), we_customer.is_open_chat),
first_user_id=IF(we_customer.first_user_id != null, VALUES(first_user_id), we_customer.first_user_id),
first_add_time=IF(we_customer.first_add_time != null, VALUES(first_add_time), we_customer.first_add_time);
</insert>
<!-- <insert id="batchAddOrUpdate">-->
<!-- INSERT INTO we_customer(-->
<!-- external_userid,-->
<!-- NAME,-->
<!-- avatar,-->
<!-- type,-->
<!-- gender,-->
<!-- unionid,-->
<!-- birthday,-->
<!-- corp_name,-->
<!-- corp_full_name,-->
<!-- position,-->
<!-- is_open_chat,-->
<!-- create_time,-->
<!-- create_by,-->
<!-- first_user_id,-->
<!-- first_add_time-->
<!-- ) values-->
<!-- <foreach collection="weCustomers" item="item" index="index" separator=",">-->
<!-- (#{item.externalUserid},#{item.name},#{item.avatar},#{item.type},#{item.gender}, #{item.unionid},#{item.birthday},-->
<!-- #{item.corpName},#{item.corpFullName},#{item.position},#{item.isOpenChat}, #{item.createTime},-->
<!-- #{item.createBy},#{item.firstUserId},#{item.firstAddTime}-->
<!-- )-->
<!-- </foreach>-->
<!-- ON DUPLICATE KEY UPDATE-->
<!-- NAME=IF(we_customer.NAME != null, VALUES(NAME), we_customer.NAME),-->
<!-- avatar=IF(we_customer.avatar != null, VALUES(avatar), we_customer.avatar),-->
<!-- type=IF(we_customer.type != null, VALUES(type), we_customer.type),-->
<!-- gender=IF(we_customer.gender != null, VALUES(gender), we_customer.gender),-->
<!-- unionid=IF(we_customer.unionid != null, VALUES(unionid), we_customer.unionid),-->
<!-- birthday=IF(we_customer.birthday != null,VALUES(birthday), we_customer.birthday),-->
<!-- corp_name=IF(we_customer.corp_name != null, VALUES(corp_name), we_customer.corp_name),-->
<!-- corp_full_name=IF(we_customer.corp_full_name != null, VALUES(corp_full_name), we_customer.corp_full_name),-->
<!-- position=IF(we_customer.position != null, VALUES(position), we_customer.position),-->
<!-- is_open_chat=IF(we_customer.is_open_chat != null, VALUES(is_open_chat), we_customer.is_open_chat),-->
<!-- first_user_id=IF(we_customer.first_user_id != null, VALUES(first_user_id), we_customer.first_user_id),-->
<!-- first_add_time=IF(we_customer.first_add_time != null, VALUES(first_add_time), we_customer.first_add_time);-->
<!-- </insert>-->
......@@ -583,12 +585,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
create_time,
create_by,
first_user_id,
first_add_time
first_add_time,
qq,
email,
address,
phone
) values
<foreach collection="weCustomers" item="item" index="index" separator=",">
(#{item.externalUserid},#{item.name},#{item.avatar},#{item.type},#{item.gender}, #{item.unionid},#{item.birthday},
#{item.corpName},#{item.corpFullName},#{item.position},#{item.isOpenChat}, #{item.createTime},
#{item.createBy},#{item.firstUserId},#{item.firstAddTime}
#{item.createBy},#{item.firstUserId},#{item.firstAddTime},#{item.qq},#{item.email},#{item.address},#{item.phone}
)
</foreach>
ON DUPLICATE KEY UPDATE
......@@ -603,7 +609,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
position=IF(we_customer.position != null, VALUES(position), we_customer.position),
is_open_chat=IF(we_customer.is_open_chat != null, VALUES(is_open_chat), we_customer.is_open_chat),
first_user_id=IF(we_customer.first_user_id != null, VALUES(first_user_id), we_customer.first_user_id),
first_add_time=IF(we_customer.first_add_time != null, VALUES(first_add_time), we_customer.first_add_time);
first_add_time=IF(we_customer.first_add_time != null, VALUES(first_add_time), we_customer.first_add_time),
qq=IF(we_customer.qq != null, VALUES(qq), we_customer.qq),
email=IF(we_customer.email != null, VALUES(email), we_customer.email),
address=IF(we_customer.address != null, VALUES(address), we_customer.address),
phone=IF(we_customer.phone != null, VALUES(phone), we_customer.phone);
</insert>
......
......@@ -19,25 +19,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select id, welcome_msg, media_id, del_flag, welcome_msg_tpl_type,create_by,create_time from we_msg_tlp
</sql>
<!-- <select id="selectWeMsgTlpList" parameterType="WeMsgTlp" resultMap="WeMsgTlpResult">-->
<!-- SELECT-->
<!-- wmt.id,-->
<!-- wmt.welcome_msg,-->
<!-- wmt.media_id,-->
<!-- wmt.del_flag,-->
<!-- wmt.welcome_msg_tpl_type,-->
<!-- wmt.create_by,-->
<!-- wmt.create_time,-->
<!-- wm.material_url-->
<!-- FROM-->
<!-- we_msg_tlp wmt-->
<!-- LEFT JOIN we_material wm ON wmt.media_id=wm.id-->
<!-- <where> -->
<!-- <if test="welcomeMsg != null and welcomeMsg != ''"> and wmt.welcome_msg like CONCAT('%',#{welcomeMsg,jdbcType=VARCHAR},'%') </if>-->
<!-- <if test="welcomeMsgTplType !=null "> and wmt.welcome_msg_tpl_type = #{welcomeMsgTplType}</if>-->
<!-- and wmt.del_flag = 0-->
<!-- </where>-->
<!-- </select>-->
<select id="selectWeMsgTlpList" parameterType="WeMsgTlp" resultMap="WeMsgTlpResult">
SELECT
wmt.id,
wmt.welcome_msg,
wmt.media_id,
wmt.del_flag,
wmt.welcome_msg_tpl_type,
wmt.create_by,
wmt.create_time,
wm.material_url
FROM
we_msg_tlp wmt
LEFT JOIN we_material wm ON wmt.media_id=wm.id
<where>
<if test="welcomeMsg != null and welcomeMsg != ''"> and wmt.welcome_msg like CONCAT('%',#{welcomeMsg,jdbcType=VARCHAR},'%') </if>
<if test="welcomeMsgTplType !=null "> and wmt.welcome_msg_tpl_type = #{welcomeMsgTplType}</if>
and wmt.del_flag = 0
</where>
</select>
<select id="selectWeMsgTlpById" parameterType="Long" resultMap="WeMsgTlpResult">
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeMsgTlpScopeMapper">
<resultMap type="WeMsgTlpScope" id="WeMsgTlpScopeResult">
<result property="id" column="id" />
<result property="msgTlpId" column="msg_tlp_id" />
<result property="useUserId" column="use_user_id" />
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="selectWeMsgTlpScopeVo">
select id, msg_tlp_id, use_user_id, del_flag from we_msg_tlp_scope
</sql>
<select id="selectWeMsgTlpScopeList" parameterType="WeMsgTlpScope" resultMap="WeMsgTlpScopeResult">
<include refid="selectWeMsgTlpScopeVo"/>
<where>
<if test="msgTlpId != null "> and msg_tlp_id = #{msgTlpId}</if>
<if test="useUserId != null "> and use_user_id = #{useUserId}</if>
</where>
</select>
<select id="selectWeMsgTlpScopeById" parameterType="Long" resultMap="WeMsgTlpScopeResult">
<include refid="selectWeMsgTlpScopeVo"/>
where id = #{id}
</select>
<insert id="insertWeMsgTlpScope" parameterType="WeMsgTlpScope">
insert into we_msg_tlp_scope
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="msgTlpId != null">msg_tlp_id,</if>
<if test="useUserId != null">use_user_id,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="msgTlpId != null">#{msgTlpId},</if>
<if test="useUserId != null">#{useUserId},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<update id="updateWeMsgTlpScope" parameterType="WeMsgTlpScope">
update we_msg_tlp_scope
<trim prefix="SET" suffixOverrides=",">
<if test="msgTlpId != null">msg_tlp_id = #{msgTlpId},</if>
<if test="useUserId != null">use_user_id = #{useUserId},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteWeMsgTlpScopeById" parameterType="Long">
delete from we_msg_tlp_scope where id = #{id}
</delete>
<delete id="deleteWeMsgTlpScopeByIds" parameterType="String">
delete from we_msg_tlp_scope where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<insert id="batchInsetWeMsgTlpScope">
insert into we_msg_tlp_scope (id,msg_tlp_id,use_user_id,del_flag)
values
<foreach collection="weMsgTlpScopes" item="scop" index="index" separator=",">
(#{scop.id},#{scop.msgTlpId},#{scop.useUserId},#{scop.delFlag})
</foreach>
</insert>
<update id="batchRemoveWeMsgTlpScopesByMsgTlpIds">
update we_msg_tlp_scope set
del_flag = 2
where msgTlpId in
<foreach collection="msgTlpIds" item="msgTlpId" index="index"
separator="," open="(" close=")">
#{msgTlpId.msgTlpId}
</foreach>
</update>
</mapper>
\ No newline at end of file
......@@ -35,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wtg.del_flag=0 and wt.del_flag=0
<if test="gourpName != null and gourpName != ''"> and gourp_name like concat('%', #{gourpName}, '%')</if>
<if test="groupTagType != null">and wtg.group_tag_type=#{groupTagType}</if>
ORDER BY wtg.create_time DESC
</select>
<select id="getWeTagGroupByIds" resultMap="WeTagGroupResult">
......@@ -113,7 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
we_flower_customer_tag_rel wfctr
INNER JOIN we_tag wt ON wfctr.tag_id = wt.tag_id
INNER JOIN we_tag_group wtg ON wt.group_id = wtg.group_id
WHERE wt.`status`=0 and wtg.`status`=0 and wfctr.flower_customer_rel_id=#{flowerCustomerRelId}
WHERE wt.`status`=0 and wtg.`status`=0 and wfctr.user_id=#{userid} and wfctr.external_userid=#{externalUserid}
</select>
......
......@@ -255,6 +255,13 @@
<version>${mybatis-plus.version}</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
......@@ -298,6 +305,15 @@
<artifactId>protobuf-java</artifactId>
<version>${protobuf.vaersion}</version>
</dependency>
<dependency>
<groupId>com.github.jeffreyning</groupId>
<artifactId>mybatisplus-plus</artifactId>
<version>1.5.1-RELEASE</version>
</dependency>
</dependencies>
</dependencyManagement>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!