| @@ -124,4 +124,12 @@ public interface WxCpOaService { | |||||
| List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset, | List<WxCpDialRecord> getDialRecord(Date startTime, Date endTime, Integer offset, | ||||
| Integer limit) throws WxErrorException; | Integer limit) throws WxErrorException; | ||||
| /** | |||||
| * 获取审批模板详情 | |||||
| * @param templateId 模板ID | |||||
| * @return | |||||
| * @throws WxErrorException | |||||
| */ | |||||
| WxCpTemplateResult getTemplateDetail(@NonNull String templateId)throws WxErrorException; | |||||
| } | } | ||||
| @@ -209,4 +209,13 @@ public class WxCpOaServiceImpl implements WxCpOaService { | |||||
| }.getType() | }.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); | |||||
| } | |||||
| } | } | ||||
| @@ -47,4 +47,8 @@ public class WxCpCheckinData implements Serializable { | |||||
| @SerializedName("mediaids") | @SerializedName("mediaids") | ||||
| private List<String> mediaIds; | private List<String> mediaIds; | ||||
| private Integer lat; | |||||
| private Integer lng; | |||||
| } | } | ||||
| @@ -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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -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; | |||||
| } | |||||
| @@ -69,6 +69,8 @@ public final class WxCpApiPathConsts { | |||||
| public static final String GET_DIAL_RECORD = "/cgi-bin/dial/get_dial_record"; | public static final String GET_DIAL_RECORD = "/cgi-bin/dial/get_dial_record"; | ||||
| @Deprecated | @Deprecated | ||||
| public static final String GET_APPROVAL_DATA = "/cgi-bin/corp/getapprovaldata"; | 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 { | public static class Tag { | ||||
| @@ -94,6 +94,11 @@ public class WxCpConsts { | |||||
| */ | */ | ||||
| public static final String CHANGE_EXTERNAL_CONTACT = "change_external_contact"; | public static final String CHANGE_EXTERNAL_CONTACT = "change_external_contact"; | ||||
| /** | |||||
| * 企业微信审批事件推送 | |||||
| */ | |||||
| public static final String OPEN_APPROVAL_CHANGE = "open_approval_change"; | |||||
| } | } | ||||
| @@ -5,10 +5,7 @@ import com.google.inject.Inject; | |||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import me.chanjar.weixin.cp.api.ApiTestModule; | import me.chanjar.weixin.cp.api.ApiTestModule; | ||||
| import me.chanjar.weixin.cp.api.WxCpService; | 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.apache.commons.lang3.time.DateFormatUtils; | ||||
| import org.testng.annotations.Guice; | import org.testng.annotations.Guice; | ||||
| import org.testng.annotations.Test; | import org.testng.annotations.Test; | ||||
| @@ -62,8 +59,8 @@ public class WxCpOaServiceImplTest { | |||||
| @Test | @Test | ||||
| public void testGetApprovalInfo() throws WxErrorException, ParseException { | 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); | WxCpApprovalInfo result = wxService.getOAService().getApprovalInfo(startTime, endTime); | ||||
| assertThat(result).isNotNull(); | assertThat(result).isNotNull(); | ||||
| @@ -74,7 +71,7 @@ public class WxCpOaServiceImplTest { | |||||
| @Test | @Test | ||||
| public void testGetApprovalDetail() throws WxErrorException { | public void testGetApprovalDetail() throws WxErrorException { | ||||
| String spNo = "201909270001"; | |||||
| String spNo = "201912020001"; | |||||
| WxCpApprovalDetailResult result = wxService.getOAService().getApprovalDetail(spNo); | WxCpApprovalDetailResult result = wxService.getOAService().getApprovalDetail(spNo); | ||||
| assertThat(result).isNotNull(); | assertThat(result).isNotNull(); | ||||
| @@ -83,4 +80,13 @@ public class WxCpOaServiceImplTest { | |||||
| System.out.println(gson.toJson(result)); | 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)); | |||||
| } | |||||
| } | } | ||||