|
@@ -13,13 +13,21 @@ import com.dingtalk.api.response.OapiGettokenResponse;
|
|
|
import com.dingtalk.api.response.OapiMessageCorpconversationAsyncsendV2Response;
|
|
|
import com.dingtalk.api.response.OapiUserGetByMobileResponse;
|
|
|
import com.taobao.api.ApiException;
|
|
|
+import com.zjugis.framework.common.pojo.CommonResult;
|
|
|
import com.zjugis.module.infra.api.ding.dto.*;
|
|
|
+import com.zjugis.module.infra.dal.dataobject.msg.MsgSendRecordDO;
|
|
|
+import com.zjugis.module.infra.enums.msg.SendTypeEnum;
|
|
|
+import com.zjugis.module.infra.service.msg.MsgSendRecordService;
|
|
|
+import com.zjugis.module.system.api.user.AdminUserApi;
|
|
|
+import com.zjugis.module.system.api.user.dto.AdminUserRespDTO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -44,6 +52,12 @@ public class DingServiceImpl implements DingService {
|
|
|
@Value("${zjugis.ding.appsecret}")
|
|
|
private String appsecret;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MsgSendRecordService msgSendRecordService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AdminUserApi adminUserApi;
|
|
|
+
|
|
|
/**
|
|
|
* @param mobile
|
|
|
* @param
|
|
@@ -70,9 +84,27 @@ public class DingServiceImpl implements DingService {
|
|
|
}
|
|
|
request.setMsg(msg);
|
|
|
OapiMessageCorpconversationAsyncsendV2Response rsp = client.execute(request, token);
|
|
|
+ saveLog(dingMessageDto,rsp,userId,mobile);
|
|
|
return rsp.toString();
|
|
|
}
|
|
|
|
|
|
+ private void saveLog(DingMessageDto dingMessageDto, OapiMessageCorpconversationAsyncsendV2Response rsp, String userId,String mobile) {
|
|
|
+ MsgSendRecordDO record = new MsgSendRecordDO();
|
|
|
+ CommonResult<AdminUserRespDTO> userRes = adminUserApi.getUser(userId);
|
|
|
+ AdminUserRespDTO user = userRes.getCheckedData();
|
|
|
+ record.setSendPerson(user.getNickname());
|
|
|
+ record.setSendPersonId(userId);
|
|
|
+ record.setSendMobile(mobile);
|
|
|
+ record.setSendContent(dingMessageDto.getContent());
|
|
|
+ record.setSendType(SendTypeEnum.DING.getType());
|
|
|
+ record.setSendTime(LocalDateTime.now());
|
|
|
+ record.setMsgType(dingMessageDto.getMsgType().name());
|
|
|
+ record.setSendState(rsp.isSuccess()?1:0);
|
|
|
+ record.setSendResult(rsp.toString());
|
|
|
+ record.setThirdId(String.valueOf(rsp.getTaskId()));
|
|
|
+ msgSendRecordService.createMsgSendRecord(record);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public String createStaff(StaffDTO dto) throws ApiException {
|
|
|
String accessToken = getDingTalkToken();
|