|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
import com.management.platform.controller.WeiXinCorpController;
|
|
|
import com.management.platform.entity.*;
|
|
|
import com.management.platform.mapper.*;
|
|
@@ -74,6 +75,13 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
//获取企业管理员列表
|
|
|
public static final String GET_ADMIN_LIST = "https://qyapi.weixin.qq.com/cgi-bin/service/get_admin_list?suite_access_token=SUITE_ACCESS_TOKEN";
|
|
|
|
|
|
+ //创建日历
|
|
|
+ public static final String ADD_CALENDAR = "https://qyapi.weixin.qq.com/cgi-bin/oa/calendar/add?access_token=ACCESS_TOKEN";
|
|
|
+
|
|
|
+ //获取日程
|
|
|
+ public static final String ADD_SCHEDULE = " https://qyapi.weixin.qq.com/cgi-bin/oa/schedule/add?access_token=ACCESS_TOKEN";
|
|
|
+
|
|
|
+
|
|
|
public static final int TEXT_CARD_MSG_BUSTRIP_WAITING_AUDIT = 0;//出差待审核
|
|
|
public static final int TEXT_CARD_MSG_BUSTRIP_AGREE = 1;//出差审核通过
|
|
|
public static final int TEXT_CARD_MSG_BUSTRIP_DENY = 2;//出差审核驳回
|
|
@@ -1868,4 +1876,43 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
result.put("dept",dept);
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ public String addCalendar(WxCorpInfo wxCorpInfo,String targetUsers, String description) throws Exception {
|
|
|
+ String result="";
|
|
|
+ String url = ADD_CALENDAR.replace("ACCESS_TOKEN",getCorpAccessToken(wxCorpInfo));
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+ MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
|
|
|
+ headers.setContentType(type);
|
|
|
+ headers.add("Accept", MediaType.APPLICATION_JSON.toString());
|
|
|
+ JSONObject requestMap = new JSONObject();
|
|
|
+ JSONObject calendar=new JSONObject();
|
|
|
+ JSONArray shares=new JSONArray();
|
|
|
+ String[] split = targetUsers.split("\\|");
|
|
|
+ List<String> userList = Arrays.asList(split);
|
|
|
+ for (String s : userList) {
|
|
|
+ JSONObject user=new JSONObject();
|
|
|
+ user.put("userid",s);
|
|
|
+ shares.add(user);
|
|
|
+ }
|
|
|
+ calendar.put("admins",split);
|
|
|
+ calendar.put("summary","工时管家任务");
|
|
|
+ calendar.put("color","#0000FF");
|
|
|
+ calendar.put("description",description);
|
|
|
+ calendar.put("is_public",0);
|
|
|
+ calendar.put("shares",shares);
|
|
|
+ calendar.put("is_corp_calendar",0);
|
|
|
+ requestMap.put("calendar", calendar);
|
|
|
+ requestMap.put("agentid", wxCorpInfo.getAgentid());
|
|
|
+ HttpEntity<JSONObject> entity = new HttpEntity<>(requestMap, headers);
|
|
|
+ ResponseEntity<String> ResponseEntity = restTemplate.postForEntity(url, entity, String.class);
|
|
|
+ if (ResponseEntity.getStatusCode() == HttpStatus.OK) {
|
|
|
+ String resp = ResponseEntity.getBody();
|
|
|
+ JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
+ if (respJson.getInteger("errcode")==0){
|
|
|
+ result+=respJson.getString("cal_id");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|