增加对接钉钉接口
This commit is contained in:
parent
51170f41a8
commit
5b52ffdcdc
|
@ -1015,7 +1015,9 @@
|
|||
<script th:src="@{/js/jquery.min.js}"></script>
|
||||
<script th:src="@{/js/bootstrap.min.js}"></script>
|
||||
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script>
|
||||
<script src="https://g.alicdn.com/dingding/dingtalk-jsapi/2.10.3/dingtalk.open.js"></script>
|
||||
<script type="text/javascript">
|
||||
var code;
|
||||
$('#pay-qrcode').click(function(){
|
||||
var html=$(this).html();
|
||||
parent.layer.open({
|
||||
|
@ -1027,6 +1029,17 @@
|
|||
content: html
|
||||
});
|
||||
});
|
||||
if (dd.env.platform !== 'notInDingTalk') {
|
||||
dd.ready(function () {
|
||||
dd.runtime.permission.requestAuthCode({
|
||||
corpId: 795114284, // 企业id
|
||||
onSuccess: function (info) {
|
||||
code = info.code; // 通过该免登授权码可以获取用户身份
|
||||
console.log("钉钉code" + code);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -9,7 +9,9 @@ package com.snow.common.enums;
|
|||
public enum DingTalkListenerType {
|
||||
DEPARTMENT_CREATE(1, "部门创建"),
|
||||
DEPARTMENT_UPDATE(2, "部门更新"),
|
||||
DEPARTMENT_DELETED(3, "部门删除");
|
||||
DEPARTMENT_DELETED(3, "部门删除"),
|
||||
|
||||
USER_CREATED(4,"用户创建");
|
||||
|
||||
private final Integer code;
|
||||
private final String info;
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package com.snow.common.enums;
|
||||
|
||||
/**
|
||||
* @author qimingjin
|
||||
* @Title:
|
||||
* @Description:
|
||||
* @date 2020/9/21 15:21
|
||||
*/
|
||||
public enum WorkRecordStatus {
|
||||
FINISHED(1, "完成"), NO_FINISHED(0, "未完成");
|
||||
|
||||
private final Integer code;
|
||||
private final String info;
|
||||
|
||||
WorkRecordStatus(Integer code, String info)
|
||||
{
|
||||
this.code = code;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public Integer getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getInfo()
|
||||
{
|
||||
return info;
|
||||
}
|
||||
}
|
|
@ -7,6 +7,11 @@ package com.snow.dingtalk.common;
|
|||
* @date 2020/9/16 11:02
|
||||
*/
|
||||
public class BaseConstantUrl {
|
||||
|
||||
/**
|
||||
* 创建用户
|
||||
*/
|
||||
public static final String USER_CREATE="https://oapi.dingtalk.com/user/create";
|
||||
/**
|
||||
* 获取token url
|
||||
*/
|
||||
|
@ -21,4 +26,19 @@ public class BaseConstantUrl {
|
|||
*
|
||||
*/
|
||||
public static final String FLOW_CREATE="https://oapi.dingtalk.com/topapi/processinstance/create";
|
||||
|
||||
/**
|
||||
* 创建任务待办
|
||||
*/
|
||||
public static final String WORK_RECORD_CREATE="https://oapi.dingtalk.com/topapi/workrecord/add";
|
||||
|
||||
|
||||
/**
|
||||
* 通过ID获取我的代办
|
||||
*/
|
||||
public static final String GET_WORK_RECORD_USER_ID_="https://oapi.dingtalk.com/topapi/workrecord/getbyuserid";
|
||||
/**
|
||||
* 更新待办
|
||||
*/
|
||||
public static final String WORK_RECORD_UPDATE="https://oapi.dingtalk.com/topapi/workrecord/update";
|
||||
}
|
||||
|
|
|
@ -34,6 +34,9 @@ public class SyncEventListener implements ApplicationListener<SyncEvent> {
|
|||
.parentid(sysDept.getParentName()).build();
|
||||
departmentService.createDepartment(departmentDTO);
|
||||
}
|
||||
else if(eventType == DingTalkListenerType.USER_CREATED.getCode()){
|
||||
|
||||
}
|
||||
|
||||
log.info("监听到的事件类型:"+eventType+JSON.toJSONString(syncEvent));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.snow.dingtalk.model;
|
||||
|
||||
import com.dingtalk.api.request.OapiProcessinstanceCreateRequest;
|
||||
|
||||
import com.taobao.api.internal.mapping.ApiField;
|
||||
import com.taobao.api.internal.mapping.ApiListField;
|
||||
import com.taobao.api.internal.util.json.JSONWriter;
|
||||
|
@ -14,7 +14,7 @@ import java.util.List;
|
|||
* @Description:
|
||||
* @date 2020/9/18 15:26
|
||||
*/
|
||||
public class ProcessinstanceCreateRequest {
|
||||
public class ProcessInstanceCreateRequest {
|
||||
/**
|
||||
*
|
||||
* 审批人userid列表,最大列表长度20。
|
||||
|
@ -59,7 +59,7 @@ public class ProcessinstanceCreateRequest {
|
|||
private String processCode;
|
||||
|
||||
|
||||
public ProcessinstanceCreateRequest() {
|
||||
public ProcessInstanceCreateRequest() {
|
||||
}
|
||||
|
||||
public void setApprovers(String approvers) {
|
||||
|
@ -74,7 +74,7 @@ public class ProcessinstanceCreateRequest {
|
|||
this.approversV2 = approversV2;
|
||||
}
|
||||
|
||||
public void setApproversV2(List<OapiProcessinstanceCreateRequest.ProcessInstanceApproverVo> approversV2) {
|
||||
public void setApproversV2(List<ProcessInstanceCreateRequest.ProcessInstanceApproverVo> approversV2) {
|
||||
this.approversV2 = (new JSONWriter(false, false, true)).write(approversV2);
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ public class ProcessinstanceCreateRequest {
|
|||
this.formComponentValues = formComponentValues;
|
||||
}
|
||||
|
||||
public void setFormComponentValues(List<OapiProcessinstanceCreateRequest.FormComponentValueVo> formComponentValues) {
|
||||
public void setFormComponentValues(List<ProcessInstanceCreateRequest.FormComponentValueVo> formComponentValues) {
|
||||
this.formComponentValues = (new JSONWriter(false, false, true)).write(formComponentValues);
|
||||
}
|
||||
|
|
@ -0,0 +1,263 @@
|
|||
package com.snow.dingtalk.model;
|
||||
|
||||
import lombok.NonNull;
|
||||
|
||||
/**
|
||||
* @author qimingjin
|
||||
* @Title:
|
||||
* @Description:
|
||||
* @date 2020/9/22 14:59
|
||||
*/
|
||||
public class UserCreateRequest {
|
||||
/**
|
||||
* 数组类型,数组里面值为整型,成员所属部门id列表
|
||||
*/
|
||||
@NonNull
|
||||
private String department;
|
||||
/**
|
||||
* 邮箱。长度为0~64个字符。企业内必须唯一,不可重复
|
||||
*/
|
||||
private String email;
|
||||
/**
|
||||
*
|
||||
* 扩展属性,可以设置多种属性(手机上最多显示10个扩展属性,具体显示哪些属性,请到OA管理后台->设置->通讯录信息设置和OA管理后台->设置->手机端显示信息设置)。
|
||||
*
|
||||
* 该字段的值支持链接类型填写,同时链接支持变量通配符自动替换,目前支持通配符有:userid,corpid。示例: [工位地址](http://www.dingtalk.com?userid=#userid#&corpid=#corpid#)
|
||||
*/
|
||||
private String extattr;
|
||||
/**
|
||||
* 入职时间,Unix时间戳,单位ms
|
||||
*/
|
||||
private Long hiredDate;
|
||||
/**
|
||||
* 是否号码隐藏。true表示隐藏,false表示不隐藏。
|
||||
*
|
||||
* 隐藏手机号后,手机号在个人资料页隐藏,但仍可对其发DING、发起钉钉免费商务电话。
|
||||
*/
|
||||
private Boolean isHide;
|
||||
/**
|
||||
*
|
||||
* 是否高管模式。true表示是,false表示不是。
|
||||
*
|
||||
* 开启后,手机号码对所有员工隐藏。普通员工无法对其发DING、发起钉钉免费商务电话。
|
||||
* 高管之间不受影响。
|
||||
*/
|
||||
private Boolean isSenior;
|
||||
/**
|
||||
* 员工工号。对应显示到OA后台和客户端个人资料的工号栏目。
|
||||
*
|
||||
* 长度为0~64个字符
|
||||
*/
|
||||
private String jobnumber;
|
||||
/**
|
||||
* 手机号码,企业内必须唯一,不可重复。如果是国际号码,请使用+xx-xxxxxx的格式
|
||||
*/
|
||||
@NonNull
|
||||
private String mobile;
|
||||
/**
|
||||
* 成员名称。
|
||||
*
|
||||
* 长度为1~64个字符
|
||||
*/
|
||||
@NonNull
|
||||
private String name;
|
||||
/**
|
||||
*
|
||||
* 在对应的部门中的排序,
|
||||
*
|
||||
* Map结构的json字符串,key是部门的id, value是人员在这个部门的排序值
|
||||
*/
|
||||
private String orderInDepts;
|
||||
/**
|
||||
*
|
||||
* 员工的企业邮箱,员工的企业邮箱已开通,才能增加此字段, 否则会报错
|
||||
*/
|
||||
private String orgEmail;
|
||||
/**
|
||||
* 职位信息。
|
||||
*
|
||||
* 长度为0~64个字符
|
||||
*/
|
||||
private String position;
|
||||
/**
|
||||
*
|
||||
* 设置用户在每个部门下的职位。
|
||||
*
|
||||
* Map结构的json字符串,
|
||||
*
|
||||
* Map的Key是deptId,表示部门id,
|
||||
*
|
||||
* Map的Value是职位,表示在这个部门下的职位
|
||||
*/
|
||||
private String positionInDepts;
|
||||
/**
|
||||
* 备注,长度为0~1000个字符
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 分机号,长度为0~50个字符,企业内必须唯一,不可重复
|
||||
*/
|
||||
private String tel;
|
||||
/**
|
||||
* 员工在当前企业内的唯一标识,也称staffId。可由企业在创建时指定,并代表一定含义比如工号,创建后不可修改,企业内必须唯一。
|
||||
*
|
||||
* 长度为1~64个字符,如果不传,服务器将自动生成一个userid。
|
||||
*/
|
||||
private String userid;
|
||||
/**
|
||||
*办公地点,长度为0~50个字符
|
||||
*/
|
||||
private String workPlace;
|
||||
|
||||
|
||||
public UserCreateRequest() {
|
||||
}
|
||||
|
||||
public void setDepartment(String department) {
|
||||
this.department = department;
|
||||
}
|
||||
|
||||
public String getDepartment() {
|
||||
return this.department;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return this.email;
|
||||
}
|
||||
|
||||
public void setExtattr(String extattr) {
|
||||
this.extattr = extattr;
|
||||
}
|
||||
|
||||
public void setExtattrString(String extattr) {
|
||||
this.extattr = extattr;
|
||||
}
|
||||
|
||||
public String getExtattr() {
|
||||
return this.extattr;
|
||||
}
|
||||
|
||||
public void setHiredDate(Long hiredDate) {
|
||||
this.hiredDate = hiredDate;
|
||||
}
|
||||
|
||||
public Long getHiredDate() {
|
||||
return this.hiredDate;
|
||||
}
|
||||
|
||||
public void setIsHide(Boolean isHide) {
|
||||
this.isHide = isHide;
|
||||
}
|
||||
|
||||
public Boolean getIsHide() {
|
||||
return this.isHide;
|
||||
}
|
||||
|
||||
public void setIsSenior(Boolean isSenior) {
|
||||
this.isSenior = isSenior;
|
||||
}
|
||||
|
||||
public Boolean getIsSenior() {
|
||||
return this.isSenior;
|
||||
}
|
||||
|
||||
public void setJobnumber(String jobnumber) {
|
||||
this.jobnumber = jobnumber;
|
||||
}
|
||||
|
||||
public String getJobnumber() {
|
||||
return this.jobnumber;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return this.mobile;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setOrderInDepts(String orderInDepts) {
|
||||
this.orderInDepts = orderInDepts;
|
||||
}
|
||||
|
||||
public void setOrderInDeptsString(String orderInDepts) {
|
||||
this.orderInDepts = orderInDepts;
|
||||
}
|
||||
|
||||
public String getOrderInDepts() {
|
||||
return this.orderInDepts;
|
||||
}
|
||||
|
||||
public void setOrgEmail(String orgEmail) {
|
||||
this.orgEmail = orgEmail;
|
||||
}
|
||||
|
||||
public String getOrgEmail() {
|
||||
return this.orgEmail;
|
||||
}
|
||||
|
||||
public void setPosition(String position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public String getPosition() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
public void setPositionInDepts(String positionInDepts) {
|
||||
this.positionInDepts = positionInDepts;
|
||||
}
|
||||
|
||||
public void setPositionInDeptsString(String positionInDepts) {
|
||||
this.positionInDepts = positionInDepts;
|
||||
}
|
||||
|
||||
public String getPositionInDepts() {
|
||||
return this.positionInDepts;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return this.remark;
|
||||
}
|
||||
|
||||
public void setTel(String tel) {
|
||||
this.tel = tel;
|
||||
}
|
||||
|
||||
public String getTel() {
|
||||
return this.tel;
|
||||
}
|
||||
|
||||
public void setUserid(String userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public String getUserid() {
|
||||
return this.userid;
|
||||
}
|
||||
|
||||
public void setWorkPlace(String workPlace) {
|
||||
this.workPlace = workPlace;
|
||||
}
|
||||
|
||||
public String getWorkPlace() {
|
||||
return this.workPlace;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
package com.snow.dingtalk.model;
|
||||
|
||||
import com.taobao.api.internal.mapping.ApiField;
|
||||
import com.taobao.api.internal.util.json.JSONWriter;
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qimingjin
|
||||
* @Title:
|
||||
* @Description:
|
||||
* @date 2020/9/21 14:37
|
||||
*/
|
||||
public class WorkrecordAddRequest {
|
||||
/**
|
||||
* 外部业务id,建议带上业务方来源字段,防止与其他业务方冲突
|
||||
*/
|
||||
private String bizId;
|
||||
/**
|
||||
* 待办时间。Unix时间戳,毫秒级
|
||||
*/
|
||||
private Long createTime;
|
||||
/**
|
||||
* 待办事项表单
|
||||
*/
|
||||
private String formItemList;
|
||||
|
||||
/**
|
||||
* pc端跳转url,不传则使用url参数
|
||||
*/
|
||||
private String pcUrl;
|
||||
/**
|
||||
* 待办的pc打开方式。2表示在pc端打开,4表示在浏览器打开
|
||||
*/
|
||||
private Long pcOpenType;
|
||||
/**
|
||||
* 待办来源名称
|
||||
*/
|
||||
private String sourceName;
|
||||
/**
|
||||
* 待办事项的标题,最多50个字符
|
||||
*/
|
||||
@NonNull
|
||||
private String title;
|
||||
/**
|
||||
* 待办事项的跳转链接。当链接是某个微应用链接时,希望在PC端工作台打开,可通过该方式实现。
|
||||
*/
|
||||
@NonNull
|
||||
private String url;
|
||||
/**
|
||||
* 待办事项对应的用户id
|
||||
*/
|
||||
@NonNull
|
||||
private String userid;
|
||||
|
||||
|
||||
public WorkrecordAddRequest() {
|
||||
}
|
||||
|
||||
public void setBizId(String bizId) {
|
||||
this.bizId = bizId;
|
||||
}
|
||||
|
||||
public String getBizId() {
|
||||
return this.bizId;
|
||||
}
|
||||
|
||||
public void setCreateTime(Long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Long getCreateTime() {
|
||||
return this.createTime;
|
||||
}
|
||||
|
||||
public void setFormItemList(String formItemList) {
|
||||
this.formItemList = formItemList;
|
||||
}
|
||||
|
||||
public void setFormItemList(List<WorkrecordAddRequest.FormItemVo> formItemList) {
|
||||
this.formItemList = (new JSONWriter(false, false, true)).write(formItemList);
|
||||
}
|
||||
|
||||
public String getFormItemList() {
|
||||
return this.formItemList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setPcUrl(String pcUrl) {
|
||||
this.pcUrl = pcUrl;
|
||||
}
|
||||
|
||||
public String getPcUrl() {
|
||||
return this.pcUrl;
|
||||
}
|
||||
|
||||
public void setPcOpenType(Long pcOpenType) {
|
||||
this.pcOpenType = pcOpenType;
|
||||
}
|
||||
|
||||
public Long getPcOpenType() {
|
||||
return this.pcOpenType;
|
||||
}
|
||||
|
||||
public void setSourceName(String sourceName) {
|
||||
this.sourceName = sourceName;
|
||||
}
|
||||
|
||||
public String getSourceName() {
|
||||
return this.sourceName;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
public void setUserid(String userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public String getUserid() {
|
||||
return this.userid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 待办事项表单
|
||||
*/
|
||||
public static class FormItemVo {
|
||||
private static final long serialVersionUID = 1767476148969288532L;
|
||||
/**
|
||||
* 表单标题
|
||||
*/
|
||||
@ApiField("content")
|
||||
private String content;
|
||||
/**
|
||||
* 表单内容
|
||||
*/
|
||||
@ApiField("title")
|
||||
private String title;
|
||||
|
||||
public FormItemVo() {
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return this.content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.snow.dingtalk.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author qimingjin
|
||||
* @Title:
|
||||
* @Description:
|
||||
* @date 2020/9/21 15:19
|
||||
*/
|
||||
@Data
|
||||
public class WorkrecordGetbyuseridRequest {
|
||||
private Long limit;
|
||||
private Long offset;
|
||||
private Long status;
|
||||
private String userid;
|
||||
}
|
|
@ -1,26 +1,19 @@
|
|||
package com.snow.dingtalk.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.dingtalk.api.DefaultDingTalkClient;
|
||||
import com.dingtalk.api.request.OapiProcessinstanceCreateRequest;
|
||||
import com.dingtalk.api.response.OapiProcessinstanceCreateResponse;
|
||||
import com.snow.common.constant.Constants;
|
||||
import com.snow.dingtalk.common.BaseConstantUrl;
|
||||
import com.snow.dingtalk.common.BaseService;
|
||||
import com.snow.dingtalk.model.ProcessinstanceCreateRequest;
|
||||
import com.snow.dingtalk.model.ProcessInstanceCreateRequest;
|
||||
import com.snow.system.service.ISysConfigService;
|
||||
import com.snow.system.service.ISysOperLogService;
|
||||
import com.taobao.api.ApiException;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qimingjin
|
||||
* @Title:
|
||||
|
@ -36,7 +29,7 @@ public class ProcessInstanceService extends BaseService {
|
|||
* 创建流程
|
||||
* @param processinstanceCreateRequest
|
||||
*/
|
||||
public String create(ProcessinstanceCreateRequest processinstanceCreateRequest){
|
||||
public String create(ProcessInstanceCreateRequest processinstanceCreateRequest){
|
||||
DefaultDingTalkClient client = new DefaultDingTalkClient(BaseConstantUrl.FLOW_CREATE);
|
||||
OapiProcessinstanceCreateRequest request = new OapiProcessinstanceCreateRequest();
|
||||
request.setAgentId(Long.parseLong(isysConfigService.selectConfigByKey(Constants.AGENT_ID)));
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package com.snow.dingtalk.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dingtalk.api.DefaultDingTalkClient;
|
||||
import com.dingtalk.api.DingTalkClient;
|
||||
import com.dingtalk.api.request.OapiUserCreateRequest;
|
||||
import com.dingtalk.api.request.OapiWorkrecordAddRequest;
|
||||
import com.dingtalk.api.response.OapiUserCreateResponse;
|
||||
import com.dingtalk.api.response.OapiWorkrecordAddResponse;
|
||||
import com.snow.dingtalk.common.BaseConstantUrl;
|
||||
import com.snow.dingtalk.common.BaseService;
|
||||
import com.snow.dingtalk.model.WorkrecordAddRequest;
|
||||
import com.snow.system.service.ISysConfigService;
|
||||
import com.taobao.api.ApiException;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author qimingjin
|
||||
* @Title:
|
||||
* @Description:
|
||||
* @date 2020/9/22 14:29
|
||||
*/
|
||||
@Service
|
||||
public class UserService extends BaseService {
|
||||
@Autowired
|
||||
private ISysConfigService isysConfigService;
|
||||
|
||||
/**
|
||||
* 创建工作待办
|
||||
* @param workrecordAddRequest
|
||||
* @return
|
||||
*/
|
||||
public String create(WorkrecordAddRequest workrecordAddRequest){
|
||||
DingTalkClient client = new DefaultDingTalkClient(BaseConstantUrl.USER_CREATE);
|
||||
OapiUserCreateRequest request = new OapiUserCreateRequest();
|
||||
BeanUtils.copyProperties(workrecordAddRequest,request);
|
||||
try {
|
||||
OapiUserCreateResponse response = client.execute(request, getDingTalkToken());
|
||||
if (response.getErrcode()==0){
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.USER_CREATE,response.getMessage(),"UserCreateRequest",JSON.toJSONString(request));
|
||||
return response.getUserid();
|
||||
}else {
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.USER_CREATE,response.getErrmsg(),"UserCreateRequest",JSON.toJSONString(request));
|
||||
}
|
||||
} catch (ApiException e) {
|
||||
e.printStackTrace();
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.USER_CREATE,e.getMessage(),"UserCreateRequest",JSON.toJSONString(request));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package com.snow.dingtalk.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dingtalk.api.DefaultDingTalkClient;
|
||||
import com.dingtalk.api.DingTalkClient;
|
||||
import com.dingtalk.api.request.OapiWorkrecordAddRequest;
|
||||
import com.dingtalk.api.request.OapiWorkrecordGetbyuseridRequest;
|
||||
import com.dingtalk.api.request.OapiWorkrecordUpdateRequest;
|
||||
import com.dingtalk.api.response.OapiWorkrecordAddResponse;
|
||||
import com.dingtalk.api.response.OapiWorkrecordGetbyuseridResponse;
|
||||
import com.dingtalk.api.response.OapiWorkrecordUpdateResponse;
|
||||
import com.snow.dingtalk.common.BaseConstantUrl;
|
||||
import com.snow.dingtalk.common.BaseService;
|
||||
import com.snow.dingtalk.model.WorkrecordAddRequest;
|
||||
import com.snow.dingtalk.model.WorkrecordGetbyuseridRequest;
|
||||
import com.snow.system.service.ISysConfigService;
|
||||
import com.taobao.api.ApiException;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author qimingjin
|
||||
* @Title:
|
||||
* @Description:
|
||||
* @date 2020/9/21 14:28
|
||||
*/
|
||||
@Service
|
||||
public class WorkRecodeService extends BaseService {
|
||||
@Autowired
|
||||
private ISysConfigService isysConfigService;
|
||||
|
||||
/**
|
||||
* 创建工作待办
|
||||
* @param workrecordAddRequest
|
||||
* @return
|
||||
*/
|
||||
public String create(WorkrecordAddRequest workrecordAddRequest){
|
||||
DingTalkClient client = new DefaultDingTalkClient(BaseConstantUrl.WORK_RECORD_CREATE);
|
||||
OapiWorkrecordAddRequest req = new OapiWorkrecordAddRequest();
|
||||
BeanUtils.copyProperties(workrecordAddRequest,req);
|
||||
OapiWorkrecordAddResponse rsp = null;
|
||||
try {
|
||||
rsp = client.execute(req, getDingTalkToken());
|
||||
if (rsp.getErrcode()==0){
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.WORK_RECORD_CREATE,rsp.getMessage(),"WorkRecordAddRequest",JSON.toJSONString(req));
|
||||
return rsp.getRecordId();
|
||||
}else {
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.WORK_RECORD_CREATE,rsp.getErrmsg(),"WorkRecordAddRequest",JSON.toJSONString(req));
|
||||
}
|
||||
} catch (ApiException e) {
|
||||
e.printStackTrace();
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.WORK_RECORD_CREATE,e.getMessage(),"WorkRecordAddRequest",JSON.toJSONString(req));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID获取待办
|
||||
* @param workrecordGetbyuseridRequest
|
||||
* @return
|
||||
*/
|
||||
public OapiWorkrecordGetbyuseridResponse.PageResult getWorkRecordByUserId(WorkrecordGetbyuseridRequest workrecordGetbyuseridRequest){
|
||||
DingTalkClient client = new DefaultDingTalkClient(BaseConstantUrl.GET_WORK_RECORD_USER_ID_);
|
||||
OapiWorkrecordGetbyuseridRequest req = new OapiWorkrecordGetbyuseridRequest();
|
||||
req.setUserid(workrecordGetbyuseridRequest.getUserid());
|
||||
req.setOffset(workrecordGetbyuseridRequest.getOffset());
|
||||
req.setLimit(workrecordGetbyuseridRequest.getLimit());
|
||||
req.setStatus(workrecordGetbyuseridRequest.getStatus());
|
||||
try {
|
||||
OapiWorkrecordGetbyuseridResponse rsp = client.execute(req, getDingTalkToken());
|
||||
if(rsp.getErrcode()==0){
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.GET_WORK_RECORD_USER_ID_,rsp.getMessage(),"WorkrecordGetbyuseridRequest",JSON.toJSONString(req));
|
||||
return rsp.getRecords();
|
||||
}else {
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.GET_WORK_RECORD_USER_ID_,rsp.getErrmsg(),"WorkrecordGetbyuseridRequest",JSON.toJSONString(req));
|
||||
}
|
||||
} catch (ApiException e) {
|
||||
e.printStackTrace();
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.GET_WORK_RECORD_USER_ID_,e.getMessage(),"WorkrecordGetbyuseridRequest",JSON.toJSONString(req));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新待办
|
||||
* @param userId
|
||||
* @param recordId
|
||||
* @return
|
||||
*/
|
||||
public Boolean update(String userId,String recordId){
|
||||
DingTalkClient client = new DefaultDingTalkClient(BaseConstantUrl.WORK_RECORD_UPDATE);
|
||||
OapiWorkrecordUpdateRequest req = new OapiWorkrecordUpdateRequest();
|
||||
req.setUserid(userId);
|
||||
req.setRecordId(recordId);
|
||||
OapiWorkrecordUpdateResponse rsp = null;
|
||||
try {
|
||||
rsp = client.execute(req, getDingTalkToken());
|
||||
if(rsp.getErrcode()==0){
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.WORK_RECORD_UPDATE,rsp.getMessage(),"WorkrecordUpdateRequest",JSON.toJSONString(req));
|
||||
return rsp.getResult();
|
||||
}else {
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.WORK_RECORD_UPDATE,rsp.getErrmsg(),"WorkrecordUpdateRequest",JSON.toJSONString(req));
|
||||
}
|
||||
} catch (ApiException e) {
|
||||
e.printStackTrace();
|
||||
syncDingTalkErrorOperLog(BaseConstantUrl.WORK_RECORD_UPDATE,e.getMessage(),"WorkrecordUpdateRequest",JSON.toJSONString(req));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -14,12 +14,15 @@ public class SyncEvent<T> extends ApplicationEvent {
|
|||
|
||||
private T t;
|
||||
|
||||
|
||||
|
||||
public SyncEvent(Object source,Integer eventType,T t) {
|
||||
super(source);
|
||||
this.eventType = eventType;
|
||||
this.t=t;
|
||||
}
|
||||
|
||||
|
||||
public T getT() {
|
||||
return t;
|
||||
}
|
||||
|
@ -35,4 +38,5 @@ public class SyncEvent<T> extends ApplicationEvent {
|
|||
public void setEventType(Integer eventType) {
|
||||
this.eventType = eventType;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,9 +5,11 @@ import java.util.List;
|
|||
|
||||
import com.snow.system.domain.SysUserPost;
|
||||
import com.snow.system.domain.SysUserRole;
|
||||
import com.snow.system.event.SyncEvent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.snow.common.annotation.DataScope;
|
||||
|
@ -55,6 +57,9 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
|
@ -203,6 +208,9 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
insertUserPost(user);
|
||||
// 新增用户与角色管理
|
||||
insertUserRole(user.getUserId(), user.getRoleIds());
|
||||
//同步用户数据
|
||||
SyncEvent syncEvent = new SyncEvent(user, 4, user);
|
||||
applicationContext.publishEvent(syncEvent);
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue