Commit 473022bf by 水库浪子

系统框架引入mybatis-plus,修改后台企业微信账号,通讯录,企业标签等bug

1 parent 330141ad
Showing 49 changed files with 1067 additions and 247 deletions
package com.linkwechat;
import com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration;
import com.thebeastshop.forest.springboot.annotation.ForestScan;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
/**
* 启动程序
*
* @author ruoyi
*/
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, PageHelperAutoConfiguration.class })
@MapperScan("com.linkwechat.*.mapper")
@ForestScan(basePackages = "com.linkwechat.wecom.client")
public class LinkWeChatApplication
......
......@@ -10,6 +10,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -50,7 +51,7 @@ public class WeDepartmentController extends BaseController
@Log(title = "企业微信组织架构相关", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("添加部门")
public AjaxResult add(@RequestBody WeDepartment weDepartment)
public AjaxResult add(@Validated @RequestBody WeDepartment weDepartment)
{
return toAjax(weDepartmentService.insertWeDepartment(weDepartment));
}
......
......@@ -2,6 +2,7 @@ package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
......@@ -55,7 +56,9 @@ public class WeTagGroupController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody WeTagGroup weTagGroup)
{
return toAjax(weTagGroupService.insertWeTagGroup(weTagGroup));
weTagGroupService.insertWeTagGroup(weTagGroup);
return AjaxResult.success();
}
/**
......@@ -66,7 +69,8 @@ public class WeTagGroupController extends BaseController
@PutMapping
public AjaxResult edit(@RequestBody WeTagGroup weTagGroup)
{
return toAjax(weTagGroupService.updateWeTagGroup(weTagGroup));
weTagGroupService.updateWeTagGroup(weTagGroup);
return AjaxResult.success();
}
/**
......@@ -75,8 +79,22 @@ public class WeTagGroupController extends BaseController
@PreAuthorize("@ss.hasPermi('wecom:group:remove')")
@Log(title = "标签组", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(weTagGroupService.deleteWeTagGroupByIds(ids));
}
/**
* 同步标签
* @return
*/
@PreAuthorize("@ss.hasPermi('wecom:group:synchWeTags')")
@GetMapping("/synchWeTags")
public AjaxResult synchWeTags(){
weTagGroupService.synchWeTags();
return AjaxResult.success(WeConstans.SYNCH_TIP);
}
}
......@@ -14,6 +14,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -64,7 +65,7 @@ public class WeUserController extends BaseController {
@Log(title = "通讯录相关客户", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("新增通讯录客户")
public AjaxResult add(@RequestBody WeUser weUser)
public AjaxResult add(@Validated @RequestBody WeUser weUser)
{
return toAjax(weUserService.insertWeUser(weUser));
}
......@@ -144,6 +145,25 @@ public class WeUserController extends BaseController {
}
/**
* 同步成员
* @return
*/
@PreAuthorize("@ss.hasPermi('wecom:user:synchWeUser')")
@GetMapping({"/synchWeUser"})
public AjaxResult synchWeUser(){
weUserService.synchWeUser();
return AjaxResult.success(WeConstans.SYNCH_TIP);
}
}
# 数据源配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://146.56.222.200:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: LinkWe123
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username:
login-password:
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
......@@ -14,7 +14,6 @@
<typeHandlers>
<typeHandler handler="com.linkwechat.framework.handler.StringArrayJoinTypeHandler"/>
</typeHandlers>
</configuration>
......@@ -39,6 +39,12 @@
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 自定义验证注解 -->
......@@ -169,6 +175,14 @@
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
</dependencies>
......
......@@ -138,4 +138,11 @@ public class Constants
/** 删除状态 */
public static final String DELETE_CODE=new String("2");
/** 业务判断成功状态 */
public static final Integer SERVICE_RETURN_SUCCESS_CODE=0;
}
......@@ -101,4 +101,37 @@ public class WeConstans {
*/
public static final String WE_ERROR_FIELD="errcode";
/**
* 递归
*/
public static final Integer YES_IS_RECURSION=0;
/**
* 获取所有子部门数据
*/
public static final Integer DEPARTMENT_SUB_WEUSER=1;
/**
* 获取当前部门
*/
public static final Integer DEPARTMENT_CURRENT_WEUSER=0;
/**
* 通讯录用户激活
*/
public static final Integer YES_IS_ACTIVATE=1;
/**
* 通讯录用户未激活
*/
public static final Integer NO_IS_ACTIVATE=2;
}
......@@ -4,9 +4,12 @@ import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.common.utils.SecurityUtils;
import springfox.documentation.annotations.ApiIgnore;
/**
......
......@@ -5,13 +5,15 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import javax.sql.DataSource;
import com.baomidou.mybatisplus.autoconfigure.SpringBootVFS;
import org.apache.ibatis.io.VFS;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
//import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
......@@ -27,7 +29,7 @@ import org.springframework.util.ClassUtils;
*
* @author ruoyi
*/
@Configuration
//@Configuration
public class MyBatisConfig
{
@Autowired
......
......@@ -130,6 +130,7 @@ public class GlobalExceptionHandler
String errorMsg = forestExcetion.getMessage();
if(StringUtils.isNotEmpty(errorMsg)){
Integer errCode = JSONUtil.parseObj(errorMsg).getInt( WeConstans.WE_ERROR_FIELD);
......
......@@ -6,7 +6,7 @@ function resolve(dir) {
}
process.env.VUE_APP_TITLE = require('./package.json').description
process.env.VUE_APP_BASE_API = process.env.NODE_ENV === 'development' ? 'http://106.13.201.219:8080' : 'http://106.13.201.219:8080'
process.env.VUE_APP_BASE_API = process.env.NODE_ENV === 'development' ? 'http://127.0.0.1:8080' : 'http://127.0.0.1:8080'
// vue.config.js 配置说明
//官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions
// 这里只列一部分,具体配置参考文档
......
package com.linkwechat.wecom.client;
import com.dtflys.forest.annotation.DataObject;
import com.dtflys.forest.annotation.Request;
import com.linkwechat.wecom.domain.dto.WeCropGroupTagDto111;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import com.linkwechat.wecom.domain.dto.tag.*;
/**
* @description: 企业微信标签相关
* @author: HaoN
* @create: 2020-10-17 11:00
**/
public interface WeCropTagClient {
/**
* 保存标签
* @param weCropGroupTag dataType = "json"
* @return
*/
@Request(url="/externalcontact/add_corp_tag",
type = "POST"
)
WeCropGropTagDtlDto addCorpTag(@DataObject WeCropGroupTagDto weCropGroupTag);
/**
* 获取所有标签 WeCropGroupTagDto
* @return
*/
@Request(url = "/externalcontact/get_corp_tag_list",
type = "POST"
)
WeCropGroupTagListDto getAllCorpTagList();
/**
* 删除企业客户标签
* @param weCropDelDto
* @return
*/
@Request(url = "/externalcontact/del_corp_tag",
type = "POST"
)
WeResultDto delCorpTag(@DataObject WeCropDelDto weCropDelDto);
/**
* 编辑企业微信标签
* @param weCropTagDto
* @return
*/
@Request(url = "/externalcontact/edit_corp_tag",
type = "POST"
)
WeResultDto editCorpTag(@DataObject WeCropTagDto weCropTagDto);
}
\ No newline at end of file
......@@ -55,5 +55,14 @@ public interface WeDepartMentClient {
/**
* 获取所有部门列表
* @return
*/
@Request(url = "/department/list")
WeDepartMentDto weAllDepartMents();
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import com.dtflys.forest.annotation.Query;
import com.dtflys.forest.annotation.Request;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import com.linkwechat.wecom.domain.dto.WeUserDto;
import com.linkwechat.wecom.domain.dto.WeUserListDto;
/**
* @description: 企业微信通讯录成员
......@@ -51,4 +52,14 @@ public interface WeUserClient {
*/
@Request(url = "/user/delete")
WeResultDto deleteUserByUserId(@Query("userid") String userid);
/**
* 获取部门成员
* @param departmentId
* @param fetchChild
* @return
*/
@Request(url="/user/list")
WeUserListDto list(@Query("department_id") Long departmentId,@Query("fetch_child") Integer fetchChild);
}
......@@ -5,7 +5,13 @@ import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.common.utils.bean.BeanUtils;
import com.linkwechat.wecom.domain.dto.WeDepartMentDto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* 企业微信组织架构相关对象 we_department
......@@ -14,6 +20,9 @@ import lombok.Data;
* @date 2020-09-01
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class WeDepartment extends BaseEntity
{
private static final long serialVersionUID = 1L;
......@@ -23,10 +32,12 @@ public class WeDepartment extends BaseEntity
/** 部门名称 */
@NotBlank(message = "部门名称不可为空")
private String name;
/** 父节点的id */
@NotNull(message = "父节点的id不可为空")
private Long parentId;
......
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
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 java.util.Date;
/**
* 企业微信标签对象 we_tag
......@@ -11,21 +19,33 @@ import lombok.Data;
* @date 2020-09-07
*/
@Data
public class WeTag extends BaseEntity
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("we_tag")
public class WeTag
{
private static final long serialVersionUID = 1L;
private Long id= SnowFlakeUtil.nextId();
/** 标签组id */
private Long groupId;
private String groupId;
/** 标签名 */
private String name;
/** 帐号状态(0正常 1删除) */
/** 帐号状态(0正常 2删除) */
private String status;
/** 微信端返回的id */
@TableId
private String tagId;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime=new Date();
}
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.fasterxml.jackson.annotation.JsonFormat;
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 java.util.Date;
import java.util.List;
/**
......@@ -13,18 +21,40 @@ import java.util.List;
* @date 2020-09-07
*/
@Data
public class WeTagGroup extends BaseEntity
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("we_tag_group")
public class WeTagGroup
{
private static final long serialVersionUID = 1L;
private Long id= SnowFlakeUtil.nextId();
/** 分组名称 */
private String gourpName;
/** 标签 */
@TableField(exist = false)
private List<WeTag> weTags;
/** 帐号状态(0正常 1删除) */
private String status;
private String status=new String("0");
/** 分组id */
@TableId
private String groupId;
/** 创建者 */
private String createBy;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime=new Date();
}
......@@ -3,6 +3,7 @@ package com.linkwechat.wecom.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.linkwechat.common.config.jackson.StringArrayDeserialize;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.common.utils.bean.BeanUtils;
......@@ -11,6 +12,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.Date;
......@@ -35,6 +37,7 @@ public class WeUser extends BaseEntity
/** 用户名称 */
@ApiModelProperty("姓名")
@NotBlank(message = "姓名不可为空")
private String name;
/** 用户昵称 */
......@@ -43,6 +46,7 @@ public class WeUser extends BaseEntity
/** 账号 */
@ApiModelProperty("账号")
@NotBlank(message = "账号不可为空")
private String userId;
/** 性别。1表示男性,2表示女性 */
......@@ -51,6 +55,7 @@ public class WeUser extends BaseEntity
/** 手机号 */
@ApiModelProperty("手机号")
@NotBlank(message = "手机号不可为空")
private String mobile;
/** 邮箱 */
......@@ -108,6 +113,7 @@ public class WeUser extends BaseEntity
private Integer isActivate=new Integer(2);
/** 转化成企业微信需要的dto对象 */
public WeUserDto transformWeUserDto(){
WeUserDto weUserDto=new WeUserDto();
......
package com.linkwechat.wecom.domain.dto;
import lombok.Data;
import java.util.List;
/**
* @description: 标签组
* @author: HaoN
* @create: 2020-10-17 11:02
**/
@Data
public class WeCropGroupTagDto111 extends WeResultDto{
private List<WeCropGroupTagDto111> tag_group;
// public static WeCropGroupTagDto.WeCropGroupTag createWeCropGroupTag(WeTagGroup weTagGroup){
// WeCropGroupTag weCropGroupTag=new WeCropGroupTag();
// if(null != weTagGroup){
// weCropGroupTag.setGroup_id(weTagGroup.getId().toString());
// weCropGroupTag.setGroup_name(weTagGroup.getGourpName());
//
// List<WeTag> weTags = weTagGroup.getWeTags();
// if(CollectionUtil.isNotEmpty(weTags)){
// List<WeCropTag> weCropTags=new ArrayList<>();
// weTags.stream().forEach(k->{
// WeCropTag weCropTag = new WeCropTag();
// weCropTag.setName(k.getName());
// weCropTags.add(
// weCropTag
// );
// });
// weCropGroupTag.setTag(weCropTags);
// }
//
//
// }
//
// return weCropGroupTag;
// }
}
package com.linkwechat.wecom.domain.dto;
import cn.hutool.core.collection.CollectionUtil;
import com.linkwechat.common.utils.bean.BeanUtils;
import com.linkwechat.wecom.domain.WeDepartment;
import lombok.Data;
......@@ -31,6 +32,23 @@ public class WeDepartMentDto extends WeResultDto {
department.add(deartMentDto);
}
public List<WeDepartment> findWeDepartments(){
List<WeDepartment> weDepartments=new ArrayList<>();
if(CollectionUtil.isNotEmpty(this.department)){
this.department.stream().forEach(k->{
weDepartments.add(
WeDepartment.builder()
.id(k.getId())
.name(k.getName())
.parentId(k.getParentid())
.build()
);
});
}
return weDepartments;
}
@Data
......
package com.linkwechat.wecom.domain.dto;
import com.linkwechat.wecom.domain.WeUser;
import lombok.Data;
/**
......@@ -47,6 +48,9 @@ public class WeUserDto extends WeResultDto{
//地址
private String address;
//全局唯一。对于同一个服务商,不同应用获取到企业内同一个成员的open_userid是相同的,最多64个字节。仅第三方应用可获取
private String open_userid;
}
package com.linkwechat.wecom.domain.dto;
import cn.hutool.core.collection.CollectionUtil;
import com.linkwechat.common.utils.bean.BeanUtils;
import com.linkwechat.wecom.domain.WeUser;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* @description: 通讯录用户列表
* @author: HaoN
* @create: 2020-10-17 00:19
**/
@Data
public class WeUserListDto extends WeResultDto{
private List<WeUserDto> userlist;
public List<WeUser> getWeUsers(){
List<WeUser> weUsers=new ArrayList<>();
if(CollectionUtil.isNotEmpty(userlist)){
userlist.stream().forEach(k->{
WeUser weUser=new WeUser();
BeanUtils.copyPropertiesASM(k,weUser);
weUsers.add(weUser);
});
}
return weUsers;
}
}
package com.linkwechat.wecom.domain.dto.tag;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @description: 标签删除参数实体
* @author: HaoN
* @create: 2020-10-18 00:22
**/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class WeCropDelDto {
private String[] tag_id;
private String[] group_id;
}
package com.linkwechat.wecom.domain.dto.tag;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import lombok.Data;
/**
* @description: 单个标签组
* @author: HaoN
* @create: 2020-10-17 23:51
**/
@Data
public class WeCropGropTagDtlDto extends WeResultDto {
private WeCropGroupTagDto tag_group;
}
package com.linkwechat.wecom.domain.dto.tag;
import cn.hutool.core.collection.CollectionUtil;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.bean.BeanUtils;
import com.linkwechat.wecom.domain.WeTag;
import com.linkwechat.wecom.domain.WeTagGroup;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @description: 标签组
* @author: HaoN
* @create: 2020-10-17 20:02
**/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class WeCropGroupTagDto {
private String group_id;
private String group_name;
private Integer order;
private Long create_time;
private List<WeCropTagDto> tag;
/**
* 获取新增的实体
* @param weTagGroup
* @return
*/
public static WeCropGroupTagDto transformAddTag(WeTagGroup weTagGroup){
WeCropGroupTagDto weCropGroupTagDto=WeCropGroupTagDto.builder()
.group_name(weTagGroup.getGourpName())
.build();
List<WeTag> weTags = weTagGroup.getWeTags();
if(CollectionUtil.isNotEmpty(weTags)){
//新增的标签
List<WeTag> newAddWeTag
= weTags.stream().filter(v -> StringUtils.isEmpty(v.getTagId())).collect(Collectors.toList());
List<WeCropTagDto> weTagDtos=new ArrayList<>();
BeanUtils.copyPropertiesignoreOther(newAddWeTag,weTagDtos);
weCropGroupTagDto.setTag(weTagDtos);
}
return weCropGroupTagDto;
}
}
package com.linkwechat.wecom.domain.dto.tag;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import lombok.Data;
import java.util.List;
/**
* @description: 标签列表实体
* @author: HaoN
* @create: 2020-10-17 20:36
**/
@Data
public class WeCropGroupTagListDto extends WeResultDto {
private List<WeCropGroupTagDto> tag_group;
}
package com.linkwechat.wecom.domain.dto.tag;
import cn.hutool.core.collection.CollectionUtil;
import com.linkwechat.wecom.domain.WeTag;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.List;
/**
* @description: 企业标签
* @author: HaoN
* @create: 2020-10-17 20:03
**/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class WeCropTagDto {
private String id;
private String name;
private String order;
private Long create_time;
public static List<WeCropTagDto> transFormto(List<WeTag> weTags){
List<WeCropTagDto> weCropDelDtoList=new ArrayList();
if(CollectionUtil.isNotEmpty(weTags)){
weTags.stream().forEach(k->{
weCropDelDtoList.add(
WeCropTagDto.builder()
.name(k.getName())
.id(k.getTagId())
.build()
);
});
}
return weCropDelDtoList;
}
}
......@@ -45,11 +45,12 @@ public class WeAccessTokenInterceptor implements Interceptor{
String uri=request.getUrl().replace("http://","");
if(Arrays.asList(weComeConfig.getFileUplodUrl()).contains(uri)){
request.setContentType("application/json");
}else{
request.setContentType("multipart/form-data");
}
request.setContentType("application/json");
// if(Arrays.asList(weComeConfig.getFileUplodUrl()).contains(uri)){
// request.setContentType("application/json");
// }else{
// request.setContentType("multipart/form-data");
// }
......@@ -78,7 +79,6 @@ public class WeAccessTokenInterceptor implements Interceptor{
@Override
public void onError(ForestRuntimeException e, ForestRequest forestRequest, ForestResponse forestResponse) {
System.out.println("nihao");
}
......
......@@ -2,6 +2,7 @@ package com.linkwechat.wecom.mapper;
import java.util.List;
import com.linkwechat.wecom.domain.WeDepartment;
import org.apache.ibatis.annotations.Param;
/**
* 企业微信组织架构相关Mapper接口
......@@ -42,19 +43,18 @@ public interface WeDepartmentMapper
*/
public int updateWeDepartment(WeDepartment weDepartment);
/**
* 删除企业微信组织架构相关
*
* @param id 企业微信组织架构相关ID
* @return 结果
* 删除部门表所有数据
* @return
*/
public int deleteWeDepartmentById(Long id);
public int deleteAllWeDepartment();
/**
* 批量删除企业微信组织架构相关
*
* @param ids 需要删除的数据ID
* @return 结果
* 批量保存
* @param weDepartments
* @return
*/
public int deleteWeDepartmentByIds(Long[] ids);
public int batchInsertWeDepartment(@Param("weDepartments") List<WeDepartment> weDepartments);
}
package com.linkwechat.wecom.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeTagGroup;
import org.apache.ibatis.annotations.Param;
/**
* 标签组Mapper接口
......@@ -9,15 +12,15 @@ import com.linkwechat.wecom.domain.WeTagGroup;
* @author ruoyi
* @date 2020-09-07
*/
public interface WeTagGroupMapper
public interface WeTagGroupMapper extends BaseMapper<WeTagGroup>
{
/**
* 查询标签组
* 查询标签组ID集合查询标签
*
* @param id 标签组ID
* @param ids 标签组ID集合
* @return 标签组
*/
public WeTagGroup selectWeTagGroupById(Long id);
public List<WeTagGroup> getWeTagGroupByIds(Long[] ids);
/**
* 查询标签组列表
......@@ -43,19 +46,20 @@ public interface WeTagGroupMapper
*/
public int updateWeTagGroup(WeTagGroup weTagGroup);
/**
* 删除标签组
* 批量逻辑删除标签组
*
* @param id 标签组ID
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteWeTagGroupById(Long id);
public int deleteWeTagGroupByIds(String[] ids);
/**
* 批量删除标签组
*
* @param ids 需要删除的数据ID
* @return 结果
* 批量保存标签组
* @param weTagGroups
* @return
*/
public int deleteWeTagGroupByIds(Long[] ids);
public int batchInsetWeTagGroup(@Param("weTagGroups") List<WeTagGroup> weTagGroups);
}
package com.linkwechat.wecom.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeTag;
/**
......@@ -9,7 +11,7 @@ import com.linkwechat.wecom.domain.WeTag;
* @author ruoyi
* @date 2020-09-07
*/
public interface WeTagMapper
public interface WeTagMapper extends BaseMapper<WeTag>
{
/**
* 查询企业微信标签
......
......@@ -2,6 +2,7 @@ package com.linkwechat.wecom.mapper;
import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.domain.vo.WeLeaveUserVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -15,7 +16,7 @@ public interface WeUserMapper
{
/**
* 查询通讯录相关客户
*
*
* @param id 通讯录相关客户ID
* @return 通讯录相关客户
*/
......@@ -45,27 +46,26 @@ public interface WeUserMapper
*/
public int updateWeUser(WeUser weUser);
/**
* 删除通讯录相关客户
*
* @param id 通讯录相关客户ID
* @return 结果
* 离职员工
* @param weLeaveUserVo
* @return
*/
public int deleteWeUserById(Long id);
public List<WeLeaveUserVo> leaveUserList(WeLeaveUserVo weLeaveUserVo);
/**
* 批量删除通讯录相关客户
*
* @param ids 需要删除的数据ID
* @return 结果
* 删除当前表的员工
* @return
*/
public int deleteWeUserByIds(Long[] ids);
public int deleteWeUser();
/**
* 离职员工
* @param weLeaveUserVo
* 批量插入员工
* @param weUsers
* @return
*/
List<WeLeaveUserVo> leaveUserList(WeLeaveUserVo weLeaveUserVo);
public int batchInsertWeUser(@Param("weUsers") List<WeUser> weUsers);
}
......@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service;
import java.util.List;
import com.linkwechat.wecom.domain.WeDepartment;
import org.apache.ibatis.annotations.Param;
/**
* 企业微信组织架构相关Service接口
......@@ -42,19 +43,25 @@ public interface IWeDepartmentService
*/
public int updateWeDepartment(WeDepartment weDepartment);
/**
* 批量删除企业微信组织架构相关
*
* @param ids 需要删除的企业微信组织架构相关ID
* @return 结果
* 批量保存
* @param weDepartments
* @return
*/
public int deleteWeDepartmentByIds(Long[] ids);
public int batchInsertWeDepartment(List<WeDepartment> weDepartments);
/**
* 删除企业微信组织架构相关信息
*
* @param id 企业微信组织架构相关ID
* @return 结果
* 删除部门表所有数据
* @return
*/
public int deleteAllWeDepartment();
/**
* 同步部门
*/
public int deleteWeDepartmentById(Long id);
public List<WeDepartment> synchWeDepartment();
}
package com.linkwechat.wecom.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeTagGroup;
import com.linkwechat.wecom.domain.dto.tag.WeCropGroupTagDto;
/**
* 标签组Service接口
......@@ -9,15 +12,9 @@ import com.linkwechat.wecom.domain.WeTagGroup;
* @author ruoyi
* @date 2020-09-07
*/
public interface IWeTagGroupService
public interface IWeTagGroupService extends IService<WeTagGroup>
{
/**
* 查询标签组
*
* @param id 标签组ID
* @return 标签组
*/
public WeTagGroup selectWeTagGroupById(Long id);
/**
* 查询标签组列表
......@@ -33,7 +30,7 @@ public interface IWeTagGroupService
* @param weTagGroup 标签组
* @return 结果
*/
public int insertWeTagGroup(WeTagGroup weTagGroup);
public void insertWeTagGroup(WeTagGroup weTagGroup);
/**
* 修改标签组
......@@ -41,7 +38,7 @@ public interface IWeTagGroupService
* @param weTagGroup 标签组
* @return 结果
*/
public int updateWeTagGroup(WeTagGroup weTagGroup);
public void updateWeTagGroup(WeTagGroup weTagGroup);
/**
* 批量删除标签组
......@@ -49,13 +46,20 @@ public interface IWeTagGroupService
* @param ids 需要删除的标签组ID
* @return 结果
*/
public int deleteWeTagGroupByIds(Long[] ids);
public int deleteWeTagGroupByIds(String[] ids);
/**
* 删除标签组信息
*
* @param id 标签组ID
* @return 结果
* 同步标签
* @return
*/
public void synchWeTags();
/**
* 来自微信端批量保存或者更新标签组和标签
* @param tagGroup
*/
public int deleteWeTagGroupById(Long id);
public void batchSaveOrUpdateTagGroupAndTag(List<WeCropGroupTagDto> tagGroup);
}
package com.linkwechat.wecom.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeTag;
import com.linkwechat.wecom.domain.dto.WeTagDto;
......@@ -10,7 +12,7 @@ import com.linkwechat.wecom.domain.dto.WeTagDto;
* @author ruoyi
* @date 2020-09-07
*/
public interface IWeTagService
public interface IWeTagService extends IService<WeTag>
{
/**
* 查询企业微信标签
......
......@@ -16,7 +16,7 @@ public interface IWeUserService
{
/**
* 查询通讯录相关客户
*
*
* @param id 通讯录相关客户ID
* @return 通讯录相关客户
*/
......@@ -46,22 +46,6 @@ public interface IWeUserService
*/
public int updateWeUser(WeUser weUser);
/**
* 批量删除通讯录相关客户
*
* @param ids 需要删除的通讯录相关客户ID
* @return 结果
*/
public int deleteWeUserByIds(Long[] ids);
/**
* 删除通讯录相关客户信息
*
* @param id 通讯录相关客户ID
* @return 结果
*/
public int deleteWeUserById(Long id);
/**
* 启用或禁用用户
......@@ -86,4 +70,10 @@ public interface IWeUserService
*/
void allocateLeaveUserAboutData(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo);
/**
* 同步成员
*/
void synchWeUser();
}
package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import com.linkwechat.common.constant.HttpStatus;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.common.utils.bean.BeanUtils;
import com.linkwechat.wecom.client.WeDepartMentClient;
import com.linkwechat.wecom.domain.WeDepartment;
......@@ -83,23 +85,19 @@ public class WeDepartmentServiceImpl implements IWeDepartmentService
* @return 结果
*/
@Override
@Transactional
public int insertWeDepartment(WeDepartment weDepartment)
{
weDepartment.setId(SnowFlakeUtil.nextId());
int returnCode=weDepartmentMapper.insertWeDepartment(weDepartment);
if(returnCode>0){
WeDepartMentDto.DeartMentDto deartMentDto = weDepartment.transformDeartMentDto(weDepartment);
// WeResultDto weResultDto=weDepartMentClient.createWeDepartMent(
// weDepartment.transformDeartMentDto(weDepartment)
// );
//
// //微信端调用不成功
// if(!WeConstans.WE_SUCCESS_CODE.equals(weResultDto.getErrcode())){
// throw new WeComException(weResultDto.getErrmsg());
// }
weDepartMentClient.createWeDepartMent(
weDepartment.transformDeartMentDto(weDepartment)
);
}
......@@ -119,41 +117,53 @@ public class WeDepartmentServiceImpl implements IWeDepartmentService
int returnCode=weDepartmentMapper.updateWeDepartment(weDepartment);
if(returnCode>0){
WeResultDto weResultDto=weDepartMentClient.updateWeDepartMent(
weDepartMentClient.updateWeDepartMent(
weDepartment.transformDeartMentDto(weDepartment)
);
//微信端调用不成功
if(!WeConstans.WE_SUCCESS_CODE.equals(weResultDto.getErrcode())){
throw new WeComException(weResultDto.getErrmsg());
}
}
return returnCode;
}
/**
* 批量删除企业微信组织架构相关
*
* @param ids 需要删除的企业微信组织架构相关ID
* @return 结果
* 批量保存
* @param weDepartments
* @return
*/
@Override
public int deleteWeDepartmentByIds(Long[] ids)
{
return weDepartmentMapper.deleteWeDepartmentByIds(ids);
public int batchInsertWeDepartment(List<WeDepartment> weDepartments) {
return weDepartmentMapper.batchInsertWeDepartment(weDepartments);
}
/**
* 删除企业微信组织架构相关信息
*
* @param id 企业微信组织架构相关ID
* @return 结果
* 删除部门表所有数据
* @return
*/
@Override
public int deleteWeDepartmentById(Long id)
{
return weDepartmentMapper.deleteWeDepartmentById(id);
public int deleteAllWeDepartment() {
return weDepartmentMapper.deleteAllWeDepartment();
}
/**
* 同步部门
*/
@Override
@Transactional
public List<WeDepartment> synchWeDepartment() {
List<WeDepartment> weDepartments = weDepartMentClient.weAllDepartMents().findWeDepartments();
if(CollectionUtil.isNotEmpty(weDepartments)){
this.deleteAllWeDepartment();
this.batchInsertWeDepartment(weDepartments);
}
return weDepartments;
}
}
package com.linkwechat.wecom.service.impl;
import java.util.List;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil;
import com.linkwechat.common.utils.DateUtils;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ArrayUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.constant.Constants;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.bean.BeanUtils;
import com.linkwechat.wecom.client.WeCropTagClient;
import com.linkwechat.wecom.domain.WeGroup;
import com.linkwechat.wecom.domain.WeTag;
import com.linkwechat.wecom.domain.WeTagGroup;
import com.linkwechat.wecom.domain.dto.tag.*;
import com.linkwechat.wecom.mapper.WeTagGroupMapper;
import com.linkwechat.wecom.mapper.WeTagMapper;
import com.linkwechat.wecom.service.IWeTagGroupService;
import com.linkwechat.wecom.service.IWeTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.linkwechat.wecom.mapper.WeTagGroupMapper;
import com.linkwechat.wecom.domain.WeTagGroup;
import com.linkwechat.wecom.service.IWeTagGroupService;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 标签组Service业务层处理
*
......@@ -21,25 +40,21 @@ import org.springframework.transaction.annotation.Transactional;
* @date 2020-09-07
*/
@Service
public class WeTagGroupServiceImpl implements IWeTagGroupService
public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper,WeTagGroup> implements IWeTagGroupService
{
@Autowired
private WeTagGroupMapper weTagGroupMapper;
@Autowired
private WeTagMapper weTagMapper;
private WeCropTagClient weCropTagClient;
@Autowired
private IWeTagService iWeTagService;
/**
* 查询标签组
*
* @param id 标签组ID
* @return 标签组
*/
@Override
public WeTagGroup selectWeTagGroupById(Long id)
{
return weTagGroupMapper.selectWeTagGroupById(id);
}
/**
* 查询标签组列表
......@@ -60,20 +75,27 @@ public class WeTagGroupServiceImpl implements IWeTagGroupService
* @return 结果
*/
@Override
@Transactional
public int insertWeTagGroup(WeTagGroup weTagGroup)
@Transactional(rollbackFor = Exception.class)
public void insertWeTagGroup(WeTagGroup weTagGroup)
{
int returnCode = 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);
List<WeTag> weTags = weTagGroup.getWeTags();
if(CollectionUtil.isEmpty(weTags)){
this.save(weTagGroup);
}else{
WeCropGropTagDtlDto weCropGropTagDtlDto = weCropTagClient.addCorpTag(WeCropGroupTagDto.transformAddTag(weTagGroup));
if(weCropGropTagDtlDto.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)){
this.batchSaveOrUpdateTagGroupAndTag(ListUtil.toList(weCropGropTagDtlDto.getTag_group()));
}
}
return returnCode;
}
/**
......@@ -83,20 +105,74 @@ public class WeTagGroupServiceImpl implements IWeTagGroupService
* @return 结果
*/
@Override
@Transactional
public int updateWeTagGroup(WeTagGroup weTagGroup)
@Transactional(rollbackFor = Exception.class)
public void updateWeTagGroup(WeTagGroup weTagGroup)
{
int returnCode = weTagGroupMapper.updateWeTagGroup(weTagGroup);
if(returnCode>0){
if(this.updateById(weTagGroup)){
List<WeTag> weTags = weTagGroup.getWeTags();
if(CollectionUtil.isNotEmpty(weTags)){
weTagMapper.batchUpdateWeTag(weTags);
//获取新增的集合
if(CollectionUtil.isNotEmpty(weTags)) {
//同步新增标签到微信端
if(CollectionUtil.isNotEmpty(WeCropGroupTagDto.transformAddTag(weTagGroup).getTag())){
WeCropGropTagDtlDto
weCropGropTagDtlDto = weCropTagClient.addCorpTag( WeCropGroupTagDto.transformAddTag(weTagGroup));
if(weCropGropTagDtlDto.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)){
//微信端返回的标签主键,设置到weTags中
}
}
//同步更新微信端标签名称
WeCropTagDto.transFormto(weTags).stream().forEach(k->{
weCropTagClient.editCorpTag(k);
});
//获取需要删除的数据
List<WeTag> removeWeTags = iWeTagService.list( new LambdaQueryWrapper<WeTag>().notIn(WeTag::getTagId,
weTags.stream().map(WeTag::getTagId).collect(Collectors.toList())).eq(WeTag::getGroupId,weTagGroup.getGroupId())
.eq(WeTag::getStatus,Constants.NORMAL_CODE));
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());
//移除本地
removeWeTags.stream().forEach(v -> v.setStatus(Constants.DELETE_CODE));
iWeTagService.updateBatchById(removeWeTags);
}
//保存或更新wetag
weTags.stream().forEach(v->v.setGroupId(weTagGroup.getGroupId()));
iWeTagService.saveOrUpdateBatch(weTags);
}
}
return returnCode;
}
}
/**
* 批量删除标签组
*
......@@ -104,20 +180,100 @@ public class WeTagGroupServiceImpl implements IWeTagGroupService
* @return 结果
*/
@Override
public int deleteWeTagGroupByIds(Long[] ids)
@Transactional
public int deleteWeTagGroupByIds(String[] ids)
{
return weTagGroupMapper.deleteWeTagGroupByIds(ids);
int returnCode = weTagGroupMapper.deleteWeTagGroupByIds(ids);
if(returnCode> Constants.SERVICE_RETURN_SUCCESS_CODE){
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()
);
}
}
return returnCode;
}
/**
* 删除标签组信息
*
* @param id 标签组ID
* @return 结果
* 同步标签
*/
@Override
public int deleteWeTagGroupById(Long id)
{
return weTagGroupMapper.deleteWeTagGroupById(id);
@Transactional(rollbackFor = Exception.class)
public void synchWeTags() {
WeCropGroupTagListDto weCropGroupTagListDto = weCropTagClient.getAllCorpTagList();
if(weCropGroupTagListDto.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)){
this.batchSaveOrUpdateTagGroupAndTag(weCropGroupTagListDto.getTag_group());
}
}
/**
* 来自微信端批量保存或者更新标签组和标签
* @param tagGroup
*/
@Override
public void batchSaveOrUpdateTagGroupAndTag(List<WeCropGroupTagDto> tagGroup) {
List<WeTagGroup> weTagGroups=new ArrayList<>();
if(CollectionUtil.isNotEmpty(tagGroup)){
tagGroup.stream().forEach(k->{
WeTagGroup weTagGroup=new WeTagGroup();
weTagGroup.setCreateBy(SecurityUtils.getUsername());
weTagGroup.setGourpName(k.getGroup_name());
weTagGroup.setGroupId(k.getGroup_id());
List<WeCropTagDto> tag = k.getTag();
if(CollectionUtil.isNotEmpty(tag)){
List<WeTag> weTags=new ArrayList<>();
tag.stream().forEach(v->{
WeTag weTag=new WeTag();
weTag.setTagId(v.getId());
weTag.setGroupId(weTagGroup.getGroupId());
weTag.setName(v.getName());
weTags.add(weTag);
});
weTagGroup.setWeTags(weTags);
}
weTagGroups.add(weTagGroup);
});
}
this.saveOrUpdateBatch(weTagGroups);
List<WeTag> weTags =
weTagGroups.stream().map(WeTagGroup::getWeTags).collect(ArrayList::new, ArrayList::addAll, ArrayList::addAll);
if(CollectionUtil.isNotEmpty(weTags)){
iWeTagService.saveOrUpdateBatch(weTags);
}
}
}
......@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.wecom.domain.dto.WeTagDto;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -17,7 +18,7 @@ import com.linkwechat.wecom.service.IWeTagService;
* @date 2020-09-07
*/
@Service
public class WeTagServiceImpl implements IWeTagService
public class WeTagServiceImpl extends ServiceImpl<WeTagMapper,WeTag> implements IWeTagService
{
@Autowired
private WeTagMapper weTagMapper;
......
package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.framework.web.domain.server.Sys;
import com.linkwechat.wecom.client.WeDepartMentClient;
import com.linkwechat.wecom.client.WeUserClient;
import com.linkwechat.wecom.domain.WeDepartment;
import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.domain.dto.WeDepartMentDto;
import com.linkwechat.wecom.domain.dto.WeUserDto;
import com.linkwechat.wecom.domain.dto.WeUserListDto;
import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
import com.linkwechat.wecom.domain.vo.WeLeaveUserVo;
import com.linkwechat.wecom.mapper.WeUserMapper;
import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeDepartmentService;
import com.linkwechat.wecom.service.IWeGroupService;
import com.linkwechat.wecom.service.IWeUserService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -36,6 +44,7 @@ public class WeUserServiceImpl implements IWeUserService
@Autowired
private IWeCustomerService iWeCustomerService;
......@@ -43,9 +52,13 @@ public class WeUserServiceImpl implements IWeUserService
@Autowired
private IWeGroupService iWeGroupService;
@Autowired
private IWeDepartmentService iWeDepartmentService;
/**
* 查询通讯录相关客户
*
*
* @param id 通讯录相关客户ID
* @return 通讯录相关客户
*/
......@@ -111,29 +124,6 @@ public class WeUserServiceImpl implements IWeUserService
}
/**
* 批量删除通讯录相关客户
*
* @param ids 需要删除的通讯录相关客户ID
* @return 结果
*/
@Override
public int deleteWeUserByIds(Long[] ids)
{
return weUserMapper.deleteWeUserByIds(ids);
}
/**
* 删除通讯录相关客户信息
*
* @param id 通讯录相关客户ID
* @return 结果
*/
@Override
public int deleteWeUserById(Long id)
{
return weUserMapper.deleteWeUserById(id);
}
......@@ -195,4 +185,27 @@ public class WeUserServiceImpl implements IWeUserService
}
/**
* 同步成员
*/
@Override
@Transactional
public void synchWeUser(){
//同步部门
iWeDepartmentService.synchWeDepartment();
List<WeUser> weUsers
= weUserClient.list(WeConstans.WE_ROOT_DEPARMENT_ID, WeConstans.DEPARTMENT_SUB_WEUSER).getWeUsers();
if(CollectionUtil.isNotEmpty(weUsers)){
//删除当前员工表员工
weUserMapper.deleteWeUser();
//重新插入员工
weUserMapper.batchInsertWeUser(weUsers);
}
}
}
......@@ -23,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="description" column="description" />
<result property="createTime" column="create_time" />
<result property="remarkCorpName" column="remark_corp_name" />
<result property="remarkMobiles" column="remark_mobiles" />
<!-- <result property="remarkMobiles" column="remark_mobiles" />-->
<result property="operUserid" column="oper_userid" />
<result property="addWay" column="add_way" />
<result property="state" column="state" />
......
......@@ -46,15 +46,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</update>
<delete id="deleteWeDepartmentById" parameterType="Long">
delete from we_department where id = #{id}
<delete id="deleteAllWeDepartment" >
delete from we_department
</delete>
<delete id="deleteWeDepartmentByIds" parameterType="String">
delete from we_department where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
<insert id="batchInsertWeDepartment" >
insert into we_department (id, name, parent_id)
values
<foreach collection="weDepartments" item="weDepartment" index="index" separator=",">
(#{weDepartment.id},#{weDepartment.name},#{weDepartment.parentId})
</foreach>
</delete>
</insert>
</mapper>
\ No newline at end of file
......@@ -11,7 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="description" column="description" />
<result property="createTime" column="create_time" />
<result property="remarkCorpName" column="remark_corp_name" />
<result property="remarkMobiles" column="remark_mobiles" />
<!-- <result property="remarkMobiles" column="remark_mobiles" />-->
<result property="operUserid" column="oper_userid" />
<result property="addWay" column="add_way" />
<result property="state" column="state" />
......@@ -50,7 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="description != null">description,</if>
<if test="createTime != null">create_time,</if>
<if test="remarkCorpName != null">remark_corp_name,</if>
<if test="remarkMobiles != null">remark_mobiles,</if>
<!-- <if test="remarkMobiles != null">remark_mobiles,</if>-->
<if test="operUserid != null">oper_userid,</if>
<if test="addWay != null">add_way,</if>
<if test="state != null">state,</if>
......@@ -63,7 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="description != null">#{description},</if>
<if test="createTime != null">#{createTime},</if>
<if test="remarkCorpName != null">#{remarkCorpName},</if>
<if test="remarkMobiles != null">#{remarkMobiles},</if>
<!-- <if test="remarkMobiles != null">#{remarkMobiles},</if>-->
<if test="operUserid != null">#{operUserid},</if>
<if test="addWay != null">#{addWay},</if>
<if test="state != null">#{state},</if>
......@@ -79,7 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="description != null">description = #{description},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="remarkCorpName != null">remark_corp_name = #{remarkCorpName},</if>
<if test="remarkMobiles != null">remark_mobiles = #{remarkMobiles},</if>
<!-- <if test="remarkMobiles != null">remark_mobiles = #{remarkMobiles},</if>-->
<if test="operUserid != null">oper_userid = #{operUserid},</if>
<if test="addWay != null">add_way = #{addWay},</if>
<if test="state != null">state = #{state},</if>
......
......@@ -5,37 +5,54 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.linkwechat.wecom.mapper.WeTagGroupMapper">
<resultMap type="WeTagGroup" id="WeTagGroupResult">
<result property="id" column="id" />
<result property="gourpName" column="gourp_name" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="groupId" column="group_id" />
<collection property="weTags" column="weTags.id" ofType="com.linkwechat.wecom.domain.WeTag">
<id property="id" column="tagId"/>
<result property="groupId" column="group_id" />
<id property="tagId" column="tag_id"/>
<result property="groupId" column="tag_group_id" />
<result property="name" column="name" />
</collection>
</resultMap>
<sql id="selectWeTagGroupVo">
select id, gourp_name, create_time from we_tag_group
select gourp_name, create_time from we_tag_group
</sql>
<select id="selectWeTagGroupList" parameterType="WeTagGroup" resultMap="WeTagGroupResult">
SELECT
wtg.*,
wt.id as tagId,
wt.tag_id ,
wt.group_id,
wt.name
wt.name,
wtg.create_by,
wtg.group_id as tag_group_id
FROM
we_tag_group wtg
INNER JOIN we_tag wt ON wtg.id = wt.group_id
LEFT JOIN we_tag wt ON wtg.group_id = wt.group_id
where
wtg.status=0 and wt.status=0
wtg.status=0 and wt.status=0 or wt.status IS NULL
<if test="gourpName != null and gourpName != ''"> and gourp_name like concat('%', #{gourpName}, '%')</if>
</select>
<select id="selectWeTagGroupById" parameterType="Long" resultMap="WeTagGroupResult">
<include refid="selectWeTagGroupVo"/>
where id = #{id} and status=0
<select id="getWeTagGroupByIds" resultMap="WeTagGroupResult">
SELECT
wtg.*,
wt.group_id,
wt.name,
wtg.create_by,
wtg.group_id as tag_group_id
FROM
we_tag_group wtg
LEFT JOIN we_tag wt ON wtg.group_id = wt.group_id
where
wtg.status=0 and wt.status=0
and wtg.id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<insert id="insertWeTagGroup" parameterType="WeTagGroup">
......@@ -44,11 +61,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="id != null">id,</if>
<if test="gourpName != null">gourp_name,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="groupId != null">group_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="gourpName != null">#{gourpName},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="groupId != null">#{groupId},</if>
</trim>
</insert>
......@@ -61,17 +82,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</update>
<delete id="deleteWeTagGroupById" parameterType="Long">
delete from we_tag_group where id = #{id}
</delete>
<update id="deleteWeTagGroupByIds" parameterType="String">
update we_tag_group set status=1
where id in
update we_tag_group set status=2
where group_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<insert id="batchInsetWeTagGroup" >
insert into we_tag_group (id, gourp_name, create_time, create_by,group_id)
values
<foreach collection="weTagGroups" item="weTagGroup" index="index" separator=",">
(#{weTagGroup.id},#{weTagGroup.gourpName},#{weTagGroup.createTime},#{weTagGroup.createBy},#{weTagGroup.groupId})
</foreach>
</insert>
</mapper>
\ No newline at end of file
......@@ -67,10 +67,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="batchInsetWeTag" >
insert into we_tag (id, group_id, name, create_time)
insert into we_tag (id, group_id, name, create_time,tag_id)
values
<foreach collection="list" item="tag" index="index" separator=",">
(#{tag.id},#{tag.groupId},#{tag.name},#{tag.createTime})
(#{tag.id},#{tag.groupId},#{tag.name},#{tag.createTime},#{tag.tagId})
</foreach>
</insert>
......
......@@ -139,16 +139,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</update>
<delete id="deleteWeUserById" parameterType="Long">
delete from we_user where id = #{id}
</delete>
<delete id="deleteWeUserByIds" parameterType="String">
delete from we_user where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="leaveUserList" parameterType="WeLeaveUserVo" resultType="com.linkwechat.wecom.domain.vo.WeLeaveUserVo">
......@@ -170,8 +161,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<delete id="deleteWeUser">
delete from we_user
</delete>
<insert id="batchInsertWeUser" >
insert into we_user (id, head_image_url, user_name, alias,
user_id, gender, mobile, email, wx_account,
department, position, is_leader_in_dept,
join_time, enable, id_card,
qq_account, telephone, address,
birthday, remark, is_activate)
values
<foreach collection="weUsers" item="weUser" index="index" separator=",">
( #{weUser.id},#{weUser.avatarMediaid},#{weUser.name},#{weUser.alias},
#{weUser.userId},#{weUser.gender},#{weUser.mobile},#{weUser.email},#{weUser.wxAccount},
#{weUser.department},#{weUser.position},#{weUser.isLeaderInDept},
#{weUser.joinTime},#{weUser.enable},#{weUser.idCard},
#{weUser.qqAccount},#{weUser.telephone},#{weUser.address},
#{weUser.birthday},#{weUser.remark},#{weUser.isActivate}
)
</foreach>
on duplicate key update head_image_url= values(head_image_url),
id=values(id),
user_name= values(user_name),alias= values(alias),
mobile= values(mobile),email= values(email),
wx_account= values(wx_account),department= values(department),
position= values(position),is_leader_in_dept= values(is_leader_in_dept),
join_time= values(join_time),enable= values(enable),
id_card= values(id_card),qq_account= values(qq_account),
telephone= values(telephone),address= values(address),
birthday= values(birthday),remark= values(remark),
is_activate= values(is_activate)
</insert>
</mapper>
\ No newline at end of file
......@@ -18,7 +18,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<mybatis.boot.version>1.3.2</mybatis.boot.version>
<!-- <mybatis.boot.version>1.3.2</mybatis.boot.version>-->
<druid.version>1.1.14</druid.version>
<bitwalker.version>1.19</bitwalker.version>
<swagger.version>2.9.2</swagger.version>
......@@ -36,6 +36,7 @@
<reflectasm.version>1.11.9</reflectasm.version>
<hutool.version>5.4.1</hutool.version>
<zxing.version>3.3.3</zxing.version>
<mybatis-plus.version>3.4.0</mybatis-plus.version>
</properties>
<!-- 依赖声明 -->
......@@ -228,6 +229,12 @@
<version>${zxing.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!