日历对接
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package com.cool.store.handler;
|
||||
|
||||
|
||||
import com.cool.store.exception.ApiException;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.response.error.ErrorResponse;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @FileName: CustomExceptionHandler
|
||||
* @Description: 自定义异常处理
|
||||
* @date 2023-06-13 19:42
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
public class CustomExceptionHandler {
|
||||
|
||||
@ExceptionHandler(value = ServiceException.class)
|
||||
public ResponseEntity<ErrorResponse> handleCustomException(ServiceException e) {
|
||||
ErrorResponse errorResponse = new ErrorResponse(e.getErrorCode(), e.getMessage());
|
||||
return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = ApiException.class)
|
||||
public ResponseEntity<ErrorResponse> handleCustomException(ApiException e) {
|
||||
ErrorResponse errorResponse = new ErrorResponse(e.getErrorCode(), e.getMessage());
|
||||
return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
public ResponseEntity<ErrorResponse> handleException(Exception e) {
|
||||
ErrorResponse errorResponse = new ErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage());
|
||||
return new ResponseEntity<>(errorResponse, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cool.store.http;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.dto.calendar.*;
|
||||
import com.cool.store.dto.enterprise.AuthInfoDTO;
|
||||
import com.cool.store.dto.enterprise.AuthScopeDTO;
|
||||
import com.cool.store.dto.enterprise.EnterpriseUserDTO;
|
||||
@@ -8,6 +9,8 @@ import com.cool.store.dto.enterprise.SysDepartmentDTO;
|
||||
import com.cool.store.dto.login.UserIdInfoDTO;
|
||||
import com.cool.store.dto.response.ResultDTO;
|
||||
import com.cool.store.entity.EnterpriseUserDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.exception.ApiException;
|
||||
import com.cool.store.mq.util.HttpRestTemplateService;
|
||||
import com.cool.store.request.EnterpriseUserRequest;
|
||||
import com.cool.store.utils.RestTemplateUtil;
|
||||
@@ -188,28 +191,84 @@ public class ISVHttpRequest {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<EnterpriseUserRequest> getDeptUsers(String deptId) {
|
||||
List<EnterpriseUserDTO> departmentUsers = getDepartmentUsers(deptId);
|
||||
if (CollectionUtils.isEmpty(departmentUsers)){
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<EnterpriseUserRequest> userList = Lists.newArrayList();
|
||||
for (EnterpriseUserDTO enterpriseUserDTO:departmentUsers) {
|
||||
EnterpriseUserDO enterpriseUser = new EnterpriseUserDO();
|
||||
enterpriseUser.setCreateTime(new Date());
|
||||
enterpriseUser.setIsAdmin(false);
|
||||
enterpriseUser.setRemark(enterpriseUserDTO.getRemark());
|
||||
enterpriseUser.setUserId(enterpriseUserDTO.getUserId());
|
||||
if (enterpriseUserDTO.getIsLeaderInDepts() != null) {
|
||||
//enterpriseUser.setIsLeaderInDepts(JSONObject.toJSONString(enterpriseUserDTO.getIsLeaderInDepts()));
|
||||
/**
|
||||
* 获取用户忙闲信息
|
||||
* @param userId
|
||||
* @param startTime 开始时间 毫秒时间戳
|
||||
* @param endTime 截止时间 毫秒时间戳
|
||||
* @return
|
||||
*/
|
||||
public List<UserFreeBusyInfoDTO> getFreeBusyList(String userId, long startTime, long endTime) throws ApiException{
|
||||
String url = isvDomain + "/isv/user/getFreeBusyList";
|
||||
HashMap requestMap = new HashMap();
|
||||
requestMap.put("userId", userId);
|
||||
requestMap.put("startTime", startTime);
|
||||
requestMap.put("endTime", endTime);
|
||||
ResultDTO responseEntity = null;
|
||||
try {
|
||||
responseEntity = httpRestTemplateService.getForObject(url, ResultDTO.class, requestMap);
|
||||
log.info("url:{}, response:{}", url, JSONObject.toJSONString(responseEntity));
|
||||
if(Objects.nonNull(responseEntity.getData()) && responseEntity.isSuccess()){
|
||||
return JSONObject.parseArray(JSONObject.toJSONString(responseEntity.getData()), UserFreeBusyInfoDTO.class);
|
||||
}
|
||||
EnterpriseUserRequest enterpriseUserRequest = new EnterpriseUserRequest();
|
||||
//enterpriseUserRequest.setEnterpriseUserDO(enterpriseUser);
|
||||
if (CollectionUtils.isNotEmpty(enterpriseUserDTO.getDepartmentLists())) {
|
||||
enterpriseUserRequest.setDepartment(JSONObject.toJSONString(enterpriseUserDTO.getDepartmentLists()));
|
||||
}
|
||||
userList.add(enterpriseUserRequest);
|
||||
} catch (Exception e) {
|
||||
log.info("调用isv出错{}", e);
|
||||
throw new ApiException(e.getMessage());
|
||||
}
|
||||
return userList;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建飞书日程
|
||||
* @param param
|
||||
* @return
|
||||
* @throws ApiException
|
||||
*/
|
||||
public UserCalendarsEventDTO createUserCalendarEvent(CreateCalendarEventDTO param) throws ApiException{
|
||||
String url = isvDomain + "/isv/user/createUserCalendarEvent";
|
||||
ResultDTO responseEntity = null;
|
||||
try {
|
||||
responseEntity = httpRestTemplateService.postForObject(url, param, ResultDTO.class);
|
||||
log.info("url:{}, response:{}", url, JSONObject.toJSONString(responseEntity));
|
||||
if(Objects.nonNull(responseEntity.getData()) && responseEntity.isSuccess()){
|
||||
return JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getData()), UserCalendarsEventDTO.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("调用isv出错{}", e);
|
||||
throw new ApiException(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public UserCalendarsEventDTO updateUserCalendarEvent(UpdateCalendarEventDTO param) throws ApiException{
|
||||
String url = isvDomain + "/isv/user/updateUserCalendarEvent";
|
||||
ResultDTO responseEntity = null;
|
||||
try {
|
||||
responseEntity = httpRestTemplateService.postForObject(url, param, ResultDTO.class);
|
||||
log.info("url:{}, response:{}", url, JSONObject.toJSONString(responseEntity));
|
||||
if(Objects.nonNull(responseEntity.getData()) && responseEntity.isSuccess()){
|
||||
return JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getData()), UserCalendarsEventDTO.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("调用isv出错{}", e);
|
||||
throw new ApiException(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public UserCalendarsEventDTO deleteUserCalendarEvent(DeleteCalendarEventDTO param) throws ApiException {
|
||||
String url = isvDomain + "/isv/user/deleteUserCalendarEvent";
|
||||
ResultDTO responseEntity = null;
|
||||
try {
|
||||
responseEntity = httpRestTemplateService.postForObject(url, param, ResultDTO.class);
|
||||
log.info("url:{}, response:{}", url, JSONObject.toJSONString(responseEntity));
|
||||
if(Objects.nonNull(responseEntity.getData()) && responseEntity.isSuccess()){
|
||||
return JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getData()), UserCalendarsEventDTO.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("调用isv出错{}", e);
|
||||
throw new ApiException(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.cool.store.service.impl;
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.dao.*;
|
||||
import com.cool.store.dto.buser.UserEventDTO;
|
||||
import com.cool.store.dto.calendar.DeleteCalendarEventDTO;
|
||||
import com.cool.store.dto.enterprise.*;
|
||||
import com.cool.store.entity.*;
|
||||
import com.cool.store.enums.DataSourceEnum;
|
||||
|
||||
Reference in New Issue
Block a user