🆕 #1416: 企业微信增加获取OA审批模板详情接口

This commit is contained in:
Gyv12345 2020-02-27 16:40:44 +08:00 committed by GitHub
parent 6aa8559970
commit bb0771736f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 386 additions and 7 deletions

View File

@ -124,4 +124,12 @@ public interface WxCpOaService {
List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset,
Integer limit) throws WxErrorException;
/**
* 获取审批模板详情
* @param templateId 模板ID
* @return
* @throws WxErrorException
*/
WxCpTemplateResult getTemplateDetail(@NonNull String templateId)throws WxErrorException;
}

View File

@ -209,4 +209,13 @@ public class WxCpOaServiceImpl implements WxCpOaService {
}.getType()
);
}
@Override
public WxCpTemplateResult getTemplateDetail(@NonNull String templateId) throws WxErrorException {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("template_id",templateId);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_TEMPLATE_DETAIL);
String responseContent = this.mainService.post(url, jsonObject.toString());
return WxCpGsonBuilder.create().fromJson(responseContent,WxCpTemplateResult.class);
}
}

View File

@ -47,4 +47,8 @@ public class WxCpCheckinData implements Serializable {
@SerializedName("mediaids")
private List<String> mediaIds;
private Integer lat;
private Integer lng;
}

View File

@ -0,0 +1,35 @@
package me.chanjar.weixin.cp.bean.oa;
import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.cp.bean.oa.templatedata.TemplateContent;
import me.chanjar.weixin.cp.bean.oa.templatedata.TemplateControls;
import me.chanjar.weixin.cp.bean.oa.templatedata.TemplateTitle;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* 审批模板详情
*
* @author gyv12345@163.com
*/
@Data
public class WxCpTemplateResult implements Serializable {
private static final long serialVersionUID = 6690547131189343887L;
@SerializedName("errcode")
private Integer errCode;
@SerializedName("errmsg")
private String errMsg;
@SerializedName("template_names")
private List<TemplateTitle> templateNames;
@SerializedName("template_content")
private TemplateContent templateContent;
}

View File

@ -0,0 +1,37 @@
package me.chanjar.weixin.cp.bean.oa.templatedata;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.cp.bean.oa.templatedata.control.*;
import java.io.Serializable;
/**
* 模板控件配置包含了部分控件类型的附加类型属性详见附录说明
* 目前有配置信息的控件类型有
* Date-日期/日期+时间
* Selector-单选/多选
* Contact-成员/部门
* Table-明细
* Attendance-假勤组件请假外出出差加班
* @author gyv12345@163.com
*/
@Data
public class TemplateConfig implements Serializable {
private static final long serialVersionUID = 6993937809371277669L;
private TemplateDate date;
private TemplateSelector selector;
private TemplateContact contact;
private TemplateTable table;
private TemplateAttendance attendance;
@SerializedName("vacation_list")
private TemplateVacation vacationList;
}

View File

@ -0,0 +1,17 @@
package me.chanjar.weixin.cp.bean.oa.templatedata;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author gyv12345@163.com
*/
@Data
public class TemplateContent implements Serializable {
private static final long serialVersionUID = -5640250983775840865L;
private List<TemplateControls> controls;
}

View File

@ -0,0 +1,19 @@
package me.chanjar.weixin.cp.bean.oa.templatedata;
import lombok.Data;
import java.io.Serializable;
import java.util.Map;
/**
* @author Administrator
*/
@Data
public class TemplateControls implements Serializable {
private static final long serialVersionUID = -7496794407355510374L;
private TemplateProperty property;
private TemplateConfig config;
}

View File

@ -0,0 +1,19 @@
package me.chanjar.weixin.cp.bean.oa.templatedata;
import lombok.Data;
import java.io.Serializable;
/**
* @author gyv12345@163.com
*/
@Data
public class TemplateDateRange implements Serializable {
private static final long serialVersionUID = -9209035461466543180L;
/**
* 时间刻度hour-精确到分钟, halfday上午/下午
*/
private String type;
}

View File

@ -0,0 +1,16 @@
package me.chanjar.weixin.cp.bean.oa.templatedata;
import java.io.Serializable;
import java.util.List;
/**
* @author gyv123@163.com
*/
public class TemplateOptions implements Serializable {
private static final long serialVersionUID = -7883792668568772078L;
private String key;
private List<TemplateTitle> value;
}

View File

@ -0,0 +1,41 @@
package me.chanjar.weixin.cp.bean.oa.templatedata;
import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;
import me.chanjar.weixin.cp.bean.oa.WxCpTemplateResult;
import me.chanjar.weixin.cp.bean.oa.templatedata.control.TemplateContact;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* @author gyv12345@163.com
*/
public class TemplateProperty implements Serializable {
private static final long serialVersionUID = -3429251158540167453L;
private String control;
private String id;
private List<TemplateTitle> title;
/**
* 控件说明向申请者展示的控件填写说明若配置了多语言则会包含中英文的控件说明默认为zh_CN中文
*/
private List<TemplateTitle> placeholder;
/**
* 是否必填1-必填0-非必填
*/
private Integer require;
/**
* 是否参与打印1-不参与打印0-参与打印
*/
@SerializedName("un_print")
private Integer unPrint;
private TemplateConfig config;
}

View File

@ -0,0 +1,18 @@
package me.chanjar.weixin.cp.bean.oa.templatedata;
import lombok.Data;
import java.io.Serializable;
/**
* @author gyv12345@163.com
*/
@Data
public class TemplateTitle implements Serializable {
private static final long serialVersionUID = -3229779834737051398L;
private String text;
private String lang;
}

View File

@ -0,0 +1,18 @@
package me.chanjar.weixin.cp.bean.oa.templatedata;
import lombok.Data;
import java.io.Serializable;
/**
* @author gyv12345@163.com
*/
@Data
public class TemplateVacationItem implements Serializable {
private static final long serialVersionUID = 4510594801023791319L;
private Integer id;
private TemplateTitle name;
}

View File

@ -0,0 +1,25 @@
package me.chanjar.weixin.cp.bean.oa.templatedata.control;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.cp.bean.oa.templatedata.TemplateDateRange;
import java.io.Serializable;
import java.util.Map;
/**
* @author gyv12345@163.com
*/
@Data
public class TemplateAttendance implements Serializable {
private static final long serialVersionUID = 5800412600894589065L;
@SerializedName("date_range")
private TemplateDateRange dateRange;
/**
* 假勤控件类型1-请假3-出差4-外出5-加班
*/
private Integer type;
}

View File

@ -0,0 +1,22 @@
package me.chanjar.weixin.cp.bean.oa.templatedata.control;
import lombok.Data;
import java.io.Serializable;
/**
* @author gyv12345@163.com
*/
@Data
public class TemplateContact implements Serializable {
private static final long serialVersionUID = -7840088884653172851L;
/**
* 选择方式single-单选multi-多选
*/
private String type;
/**
* 选择对象user-成员department-部门
*/
private String mode;
}

View File

@ -0,0 +1,18 @@
package me.chanjar.weixin.cp.bean.oa.templatedata.control;
import lombok.Data;
import java.io.Serializable;
/**
* @author Administrator
*/
@Data
public class TemplateDate implements Serializable {
private static final long serialVersionUID = 1300634733160349684L;
/**
* day-日期hour-日期+时间
*/
private String type;
}

View File

@ -0,0 +1,20 @@
package me.chanjar.weixin.cp.bean.oa.templatedata.control;
import me.chanjar.weixin.cp.bean.oa.templatedata.TemplateOptions;
import java.io.Serializable;
import java.util.List;
/**
* @author
*/
public class TemplateSelector implements Serializable {
private static final long serialVersionUID = 4995408101489736881L;
/**
* single-单选multi-多选
*/
private String type;
private List<TemplateOptions> options;
}

View File

@ -0,0 +1,23 @@
package me.chanjar.weixin.cp.bean.oa.templatedata.control;
import lombok.Data;
import me.chanjar.weixin.cp.bean.oa.templatedata.TemplateControls;
import java.io.Serializable;
import java.util.List;
/**
*
* @author gyv12345@163.com
*/
@Data
public class TemplateTable implements Serializable {
private static final long serialVersionUID = -8181588935694605858L;
private List<TemplateControls> children;
private String[] statField;
}

View File

@ -0,0 +1,17 @@
package me.chanjar.weixin.cp.bean.oa.templatedata.control;
import lombok.Data;
import me.chanjar.weixin.cp.bean.oa.templatedata.TemplateVacationItem;
import java.io.Serializable;
import java.util.List;
/**
* @author gyv12345@163.com
*/
@Data
public class TemplateVacation implements Serializable {
private List<TemplateVacationItem> item;
}

View File

@ -69,6 +69,8 @@ public final class WxCpApiPathConsts {
public static final String GET_DIAL_RECORD = "/cgi-bin/dial/get_dial_record";
@Deprecated
public static final String GET_APPROVAL_DATA = "/cgi-bin/corp/getapprovaldata";
public static final String GET_TEMPLATE_DETAIL = "/cgi-bin/oa/gettemplatedetail";
public static final String APPLY_EVENT="/cgi-bin/oa/applyevent";
}
public static class Tag {

View File

@ -94,6 +94,11 @@ public class WxCpConsts {
*/
public static final String CHANGE_EXTERNAL_CONTACT = "change_external_contact";
/**
* 企业微信审批事件推送
*/
public static final String OPEN_APPROVAL_CHANGE = "open_approval_change";
}

View File

@ -5,10 +5,7 @@ import com.google.inject.Inject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.ApiTestModule;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.oa.WxCpApprovalDetailResult;
import me.chanjar.weixin.cp.bean.oa.WxCpApprovalInfo;
import me.chanjar.weixin.cp.bean.oa.WxCpCheckinData;
import me.chanjar.weixin.cp.bean.oa.WxCpCheckinOption;
import me.chanjar.weixin.cp.bean.oa.*;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
@ -62,8 +59,8 @@ public class WxCpOaServiceImplTest {
@Test
public void testGetApprovalInfo() throws WxErrorException, ParseException {
Date startTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-04-11");
Date endTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-05-10");
Date startTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-12-01");
Date endTime = DateFormatUtils.ISO_8601_EXTENDED_DATE_FORMAT.parse("2019-12-31");
WxCpApprovalInfo result = wxService.getOAService().getApprovalInfo(startTime, endTime);
assertThat(result).isNotNull();
@ -74,7 +71,7 @@ public class WxCpOaServiceImplTest {
@Test
public void testGetApprovalDetail() throws WxErrorException {
String spNo = "201909270001";
String spNo = "201912020001";
WxCpApprovalDetailResult result = wxService.getOAService().getApprovalDetail(spNo);
assertThat(result).isNotNull();
@ -83,4 +80,13 @@ public class WxCpOaServiceImplTest {
System.out.println(gson.toJson(result));
}
@Test
public void testGetTemplateDetail() throws WxErrorException{
String templateId="3TkZjxugodbqpEMk9j7X6h6zKqYkc7MxQrrFmT7H";
WxCpTemplateResult result=wxService.getOAService().getTemplateDetail(templateId);
assertThat(result).isNotNull();
System.out.println("result ");
System.out.println(gson.toJson(result));
}
}