-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
【企业微信】增加家校应用-复学码接口支持 #2676
Merged
Merged
【企业微信】增加家校应用-复学码接口支持 #2676
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package me.chanjar.weixin.cp.api; | ||
|
||
import me.chanjar.weixin.common.error.WxErrorException; | ||
import me.chanjar.weixin.cp.bean.school.WxCpCustomizeHealthInfo; | ||
import me.chanjar.weixin.cp.bean.school.WxCpResultList; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import java.util.List; | ||
|
||
/** | ||
* 企业微信家校应用 复学码相关接口. | ||
* https://developer.work.weixin.qq.com/document/path/93744 | ||
* <p> | ||
* 权限说明: | ||
* 仅复学码应用可以调用 | ||
* | ||
* @author <a href="https://github.com/0katekate0">Wang_Wong</a> | ||
* @date: 2022/5/31 9:10 | ||
*/ | ||
public interface WxCpSchoolService { | ||
|
||
/** | ||
* 获取老师健康信息 | ||
* 请求方式: POST(HTTPS) | ||
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/school/user/get_teacher_customize_health_info?access_token=ACCESS_TOKEN | ||
* | ||
* @param date | ||
* @param nextKey | ||
* @param limit | ||
* @return | ||
* @throws WxErrorException | ||
*/ | ||
WxCpCustomizeHealthInfo getTeacherCustomizeHealthInfo(@NotNull String date, String nextKey, Integer limit) throws WxErrorException; | ||
|
||
/** | ||
* 获取学生健康信息 | ||
* 请求方式: POST(HTTPS) | ||
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/school/user/get_student_customize_health_info?access_token=ACCESS_TOKEN | ||
* | ||
* @param date | ||
* @param nextKey | ||
* @param limit | ||
* @return | ||
* @throws WxErrorException | ||
*/ | ||
WxCpCustomizeHealthInfo getStudentCustomizeHealthInfo(@NotNull String date, String nextKey, Integer limit) throws WxErrorException; | ||
|
||
/** | ||
* 获取师生健康码 | ||
* 请求方式:POST(HTTPS) | ||
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/get_health_qrcode?access_token=ACCESS_TOKEN | ||
* | ||
* @param userIds | ||
* @param type | ||
* @return | ||
* @throws WxErrorException | ||
*/ | ||
WxCpResultList getHealthQrCode(@NotNull List<String> userIds, @NotNull Integer type) throws WxErrorException; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package me.chanjar.weixin.cp.api.impl; | ||
|
||
import com.google.gson.JsonObject; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import me.chanjar.weixin.common.error.WxErrorException; | ||
import me.chanjar.weixin.cp.api.WxCpSchoolService; | ||
import me.chanjar.weixin.cp.api.WxCpService; | ||
import me.chanjar.weixin.cp.bean.school.WxCpCustomizeHealthInfo; | ||
import me.chanjar.weixin.cp.bean.school.WxCpResultList; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.School.*; | ||
|
||
/** | ||
* 企业微信家校应用 复学码相关接口实现类. | ||
* https://developer.work.weixin.qq.com/document/path/93744 | ||
* | ||
* @author <a href="https://github.com/0katekate0">Wang_Wong</a> | ||
* @date: 2022/6/1 14:05 | ||
*/ | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class WxCpSchoolServiceImpl implements WxCpSchoolService { | ||
|
||
private final WxCpService cpService; | ||
|
||
@Override | ||
public WxCpCustomizeHealthInfo getTeacherCustomizeHealthInfo(@NotNull String date, String nextKey, Integer limit) throws WxErrorException { | ||
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_TEACHER_CUSTOMIZE_HEALTH_INFO); | ||
JsonObject jsonObject = new JsonObject(); | ||
jsonObject.addProperty("date", date); | ||
jsonObject.addProperty("limit", Optional.ofNullable(limit).orElse(100)); | ||
if (nextKey != null) { | ||
jsonObject.addProperty("next_key", nextKey); | ||
} | ||
String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); | ||
return WxCpCustomizeHealthInfo.fromJson(responseContent); | ||
} | ||
|
||
@Override | ||
public WxCpCustomizeHealthInfo getStudentCustomizeHealthInfo(@NotNull String date, String nextKey, Integer limit) throws WxErrorException { | ||
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_STUDENT_CUSTOMIZE_HEALTH_INFO); | ||
JsonObject jsonObject = new JsonObject(); | ||
jsonObject.addProperty("date", date); | ||
jsonObject.addProperty("limit", Optional.ofNullable(limit).orElse(100)); | ||
if (nextKey != null) { | ||
jsonObject.addProperty("next_key", nextKey); | ||
} | ||
String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); | ||
return WxCpCustomizeHealthInfo.fromJson(responseContent); | ||
} | ||
|
||
@Override | ||
public WxCpResultList getHealthQrCode(@NotNull List<String> userIds, @NotNull Integer type) throws WxErrorException { | ||
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_HEALTH_QRCODE); | ||
JsonObject jsonObject = new JsonObject(); | ||
jsonObject.addProperty("type", type); | ||
jsonObject.addProperty("userids", userIds.toString()); | ||
String responseContent = this.cpService.post(apiUrl, jsonObject.toString()); | ||
return WxCpResultList.fromJson(responseContent); | ||
} | ||
|
||
} |
150 changes: 150 additions & 0 deletions
150
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/school/WxCpCustomizeHealthInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
package me.chanjar.weixin.cp.bean.school; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
import lombok.Data; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import me.chanjar.weixin.cp.bean.WxCpBaseResp; | ||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
|
||
/** | ||
* 获取健康信息. | ||
* | ||
* @author Wang_Wong | ||
*/ | ||
@Data | ||
public class WxCpCustomizeHealthInfo extends WxCpBaseResp implements Serializable { | ||
private static final long serialVersionUID = -5028321625142879581L; | ||
|
||
@SerializedName("health_infos") | ||
private List<HealthInfo> healthInfos; | ||
|
||
@SerializedName("template_id") | ||
private String templateId; | ||
|
||
@SerializedName("next_key") | ||
private String nextKey; | ||
|
||
@SerializedName("ending") | ||
private Integer ending; | ||
|
||
@Getter | ||
@Setter | ||
public static class HealthInfo implements Serializable { | ||
private static final long serialVersionUID = -5696099236344075582L; | ||
|
||
@SerializedName("userid") | ||
private String userId; | ||
|
||
@SerializedName("health_qrcode_status") | ||
private Integer healthQrCodeStatus; | ||
|
||
@SerializedName("self_submit") | ||
private Integer selfSubmit; | ||
|
||
@SerializedName("report_values") | ||
private List<ReportValue> reportValues; | ||
|
||
@SerializedName("question_templates") | ||
private List<QuestionTemplate> questionTemplates; | ||
|
||
public static HealthInfo fromJson(String json) { | ||
return WxCpGsonBuilder.create().fromJson(json, HealthInfo.class); | ||
} | ||
|
||
public String toJson() { | ||
return WxCpGsonBuilder.create().toJson(this); | ||
} | ||
|
||
} | ||
|
||
@Getter | ||
@Setter | ||
public static class ReportValue implements Serializable { | ||
private static final long serialVersionUID = -5696099236344075582L; | ||
|
||
@SerializedName("question_id") | ||
private Integer questionId; | ||
|
||
@SerializedName("single_chose") | ||
private Integer singleChose; | ||
|
||
@SerializedName("text") | ||
private String text; | ||
|
||
public static ReportValue fromJson(String json) { | ||
return WxCpGsonBuilder.create().fromJson(json, ReportValue.class); | ||
} | ||
|
||
public String toJson() { | ||
return WxCpGsonBuilder.create().toJson(this); | ||
} | ||
|
||
} | ||
|
||
@Getter | ||
@Setter | ||
public static class QuestionTemplate implements Serializable { | ||
private static final long serialVersionUID = -5696099236344075582L; | ||
|
||
@SerializedName("question_id") | ||
private Integer questionId; | ||
|
||
@SerializedName("question_type") | ||
private Integer questionType; | ||
|
||
@SerializedName("title") | ||
private String title; | ||
|
||
@SerializedName("is_must_fill") | ||
private Integer isMustFill; | ||
|
||
@SerializedName("is_not_display") | ||
private Integer isNotDisplay; | ||
|
||
@SerializedName("option_list") | ||
private List<OptionList> optionList; | ||
|
||
public static QuestionTemplate fromJson(String json) { | ||
return WxCpGsonBuilder.create().fromJson(json, QuestionTemplate.class); | ||
} | ||
|
||
public String toJson() { | ||
return WxCpGsonBuilder.create().toJson(this); | ||
} | ||
|
||
} | ||
|
||
@Getter | ||
@Setter | ||
public static class OptionList implements Serializable { | ||
private static final long serialVersionUID = -5696099236344075582L; | ||
|
||
@SerializedName("option_id") | ||
private Integer optionId; | ||
|
||
@SerializedName("option_text") | ||
private String optionText; | ||
|
||
public static OptionList fromJson(String json) { | ||
return WxCpGsonBuilder.create().fromJson(json, OptionList.class); | ||
} | ||
|
||
public String toJson() { | ||
return WxCpGsonBuilder.create().toJson(this); | ||
} | ||
|
||
} | ||
|
||
public static WxCpCustomizeHealthInfo fromJson(String json) { | ||
return WxCpGsonBuilder.create().fromJson(json, WxCpCustomizeHealthInfo.class); | ||
} | ||
|
||
public String toJson() { | ||
return WxCpGsonBuilder.create().toJson(this); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EmptyBlockTag: A block tag (@param, @return, @throws, @deprecated) has an empty description. Block tags without descriptions don't add much value for future readers of the code; consider removing the tag entirely or adding a description.
(at-me in a reply with
help
orignore
)Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]