Browse Source

新代码

master
zxc 3 years ago
parent
commit
ab268ba798
  1. 97
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/OpenSyncBizDataDTO.java
  2. 33
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/dingtalk/CallbackController.java
  3. 16
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/OpenSyncBizDataDao.java
  4. 68
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/OpenSyncBizDataEntity.java
  5. 78
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/OpenSyncBizDataService.java
  6. 82
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/OpenSyncBizDataServiceImpl.java
  7. 6
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenSyncBizDataDao.xml

97
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/OpenSyncBizDataDTO.java

@ -0,0 +1,97 @@
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-09-14
*/
@Data
public class OpenSyncBizDataDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
private String id;
/**
* 第三方企业应用的suiteid加下划线0
*/
private String subscribeId;
/**
* 第三方企业应用的corpid
*/
private String corpId;
/**
* 第三方企业应用的suiteid
*/
private String bizId;
/**
* 数据为Json格式
*/
private String bizData;
/**
* 2第三方企业应用票据
4企业授权变更包含授权解除授权授权变更
7第三方企业应用变更包含停用启用删除(删除保留授权)
13企业用户变更包含用户添加修改删除
14企业部门变更包含部门添加修改删除
15企业角色变更包含角色添加修改删除
16企业变更包含企业修改删除
17市场订单
20企业外部联系人变更包含添加修改删除
22ISV自定义审批
25家校通讯录1.0(Deprecated)信息变更家校通讯录升级请查看家校通讯录2.0数据推送
32智能硬件绑定类型
37因订单到期或者用户退款等导致的服务关闭目前仅推送因退款等导致的服务关闭
50家校通讯录2.0部门信息变更
51家校通讯录2.0人员信息变更
63应用试用记录回调信息
66工作台组件变更回调事件
67钉钉假期相关回调事件
133CRM客户动态相关数据回调事件
137人事平台员工异动V2相关数据回调事件
139异步转译通讯录id任务完成通知
165人事平台员工档案变动事件相关数据的回调事件
175人事解决方案变更事件
*/
private String bizType;
/**
*
*/
private Integer delFlag;
/**
*
*/
private Date createdTime;
/**
*
*/
private String createdBy;
/**
*
*/
private Date updatedTime;
/**
*
*/
private String updatedBy;
}

33
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/dingtalk/CallbackController.java

@ -2,12 +2,20 @@ package com.epmet.controller.dingtalk;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.dingtalk.config.Constant;
import com.aliyun.dingtalk.util.DingCallbackCrypto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.entity.OpenSyncBizDataEntity;
import com.epmet.service.OpenSyncBizDataService;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* ISV 小程序回调信息处理
*/
@ -37,24 +45,33 @@ public class CallbackController {
*/
private static final String EVENT_TMP_AUTH_CODE = "tmp_auth_code";
private static final String EVENT_SYNC_HTTP_PUSH_HIGH = "SYNC_HTTP_PUSH_HIGH";
@Autowired
private OpenSyncBizDataService openSyncBizDataService;
@PostMapping(value = "dingCallback")
public Object dingCallback(
@RequestParam(value = "signature") String signature,
@RequestParam(value = "timestamp") Long timestamp,
@RequestParam(value = "nonce") String nonce,
@RequestParam(value = "id") int id,
@RequestBody(required = false) JSONObject body
) {
log.info("id is:"+id);
String params = "signature:" + signature + " timestamp:" + timestamp + " nonce:" + nonce + " body:" + body;
try {
log.info("begin callback:" + params);
DingCallbackCrypto dingTalkEncryptor = new DingCallbackCrypto(Constant.TOKEN, Constant.ENCODING_AES_KEY, Constant.SUITE_KEY);
DingCallbackCrypto dingTalkEncryptor = new DingCallbackCrypto("vTUvaf6QtOJZsa1h7Wkoteo", "csRpvVFGL7Cf1N9ubajix8tDWhCllROhaxCHKFnbuAz", "suite5yxliro6wawv514w");
// 从post请求的body中获取回调信息的加密数据进行解密处理
String encrypt = body.getString("encrypt");
String plainText = dingTalkEncryptor.getDecryptMsg(signature, timestamp.toString(), nonce, encrypt);
JSONObject callBackContent = JSON.parseObject(plainText);
log.info("推来的消息体:"+plainText);
// 根据回调事件类型做不同的业务处理
String eventType = callBackContent.getString("EventType");
if (EVENT_CHECK_CREATE_SUITE_URL.equals(eventType)) {
@ -70,7 +87,17 @@ public class CallbackController {
// 本事件应用应该异步进行授权开通企业的初始化,目的是尽最大努力快速返回给钉钉服务端。用以提升企业管理员开通应用体验
// 即使本接口没有收到数据或者收到事件后处理初始化失败都可以后续再用户试用应用时从前端获取到corpId并拉取授权企业信息,进而初始化开通及企业。
log.info("企业授权开通应用事件: " + plainText);
} else {
} else if (EVENT_SYNC_HTTP_PUSH_HIGH.equals(eventType)){
log.info("ticket: " + plainText);
List<Map<String, Object>> bizData = (List<Map<String, Object>>) callBackContent.get("bizData");
if (CollectionUtils.isNotEmpty(bizData)){
List<OpenSyncBizDataEntity> list = new ArrayList<>();
bizData.forEach(b -> {
list.add(ConvertUtils.mapToEntity(b, OpenSyncBizDataEntity.class));
});
openSyncBizDataService.insertBatch(list);
}
} else{
// 其他类型事件处理
}

16
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/OpenSyncBizDataDao.java

@ -0,0 +1,16 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.OpenSyncBizDataEntity;
import org.apache.ibatis.annotations.Mapper;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-09-14
*/
@Mapper
public interface OpenSyncBizDataDao extends BaseDao<OpenSyncBizDataEntity> {
}

68
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/OpenSyncBizDataEntity.java

@ -0,0 +1,68 @@
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-09-14
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("open_sync_biz_data")
public class OpenSyncBizDataEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 第三方企业应用的suiteid加下划线0
*/
private String subscribeId;
/**
* 第三方企业应用的corpid
*/
private String corpId;
/**
* 第三方企业应用的suiteid
*/
private String bizId;
/**
* 数据为Json格式
*/
private String bizData;
/**
* 2第三方企业应用票据
4企业授权变更包含授权解除授权授权变更
7第三方企业应用变更包含停用启用删除(删除保留授权)
13企业用户变更包含用户添加修改删除
14企业部门变更包含部门添加修改删除
15企业角色变更包含角色添加修改删除
16企业变更包含企业修改删除
17市场订单
20企业外部联系人变更包含添加修改删除
22ISV自定义审批
25家校通讯录1.0(Deprecated)信息变更家校通讯录升级请查看家校通讯录2.0数据推送
32智能硬件绑定类型
37因订单到期或者用户退款等导致的服务关闭目前仅推送因退款等导致的服务关闭
50家校通讯录2.0部门信息变更
51家校通讯录2.0人员信息变更
63应用试用记录回调信息
66工作台组件变更回调事件
67钉钉假期相关回调事件
133CRM客户动态相关数据回调事件
137人事平台员工异动V2相关数据回调事件
139异步转译通讯录id任务完成通知
165人事平台员工档案变动事件相关数据的回调事件
175人事解决方案变更事件
*/
private String bizType;
}

78
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/OpenSyncBizDataService.java

@ -0,0 +1,78 @@
package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.OpenSyncBizDataDTO;
import com.epmet.entity.OpenSyncBizDataEntity;
import java.util.List;
import java.util.Map;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-09-14
*/
public interface OpenSyncBizDataService extends BaseService<OpenSyncBizDataEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<OpenSyncBizDataDTO>
* @author generator
* @date 2022-09-14
*/
PageData<OpenSyncBizDataDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<OpenSyncBizDataDTO>
* @author generator
* @date 2022-09-14
*/
List<OpenSyncBizDataDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return OpenSyncBizDataDTO
* @author generator
* @date 2022-09-14
*/
OpenSyncBizDataDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2022-09-14
*/
void save(OpenSyncBizDataDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2022-09-14
*/
void update(OpenSyncBizDataDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2022-09-14
*/
void delete(String[] ids);
}

82
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/OpenSyncBizDataServiceImpl.java

@ -0,0 +1,82 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.OpenSyncBizDataDao;
import com.epmet.dto.OpenSyncBizDataDTO;
import com.epmet.entity.OpenSyncBizDataEntity;
import com.epmet.service.OpenSyncBizDataService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-09-14
*/
@Service
public class OpenSyncBizDataServiceImpl extends BaseServiceImpl<OpenSyncBizDataDao, OpenSyncBizDataEntity> implements OpenSyncBizDataService {
@Override
public PageData<OpenSyncBizDataDTO> page(Map<String, Object> params) {
IPage<OpenSyncBizDataEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, OpenSyncBizDataDTO.class);
}
@Override
public List<OpenSyncBizDataDTO> list(Map<String, Object> params) {
List<OpenSyncBizDataEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, OpenSyncBizDataDTO.class);
}
private QueryWrapper<OpenSyncBizDataEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<OpenSyncBizDataEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public OpenSyncBizDataDTO get(String id) {
OpenSyncBizDataEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, OpenSyncBizDataDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(OpenSyncBizDataDTO dto) {
OpenSyncBizDataEntity entity = ConvertUtils.sourceToTarget(dto, OpenSyncBizDataEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(OpenSyncBizDataDTO dto) {
OpenSyncBizDataEntity entity = ConvertUtils.sourceToTarget(dto, OpenSyncBizDataEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
}

6
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenSyncBizDataDao.xml

@ -0,0 +1,6 @@
<?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.epmet.dao.OpenSyncBizDataDao">
</mapper>
Loading…
Cancel
Save