Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public interface WxOpenMaBasicService {
* 8.6 修改类目
*/
String OPEN_MODIFY_CATEGORY = "https://api.weixin.qq.com/cgi-bin/wxopen/modifycategory";
/**
* 8.7 获取类目名称信息
*/
String OPEN_GET_ALL_CATEGORY_NAME = "https://api.weixin.qq.com/cgi-bin/wxopen/getallcategorynamelist";

/**
* 获取订单页path信息
Expand Down Expand Up @@ -222,6 +226,18 @@ WxFastMaSetNickameResult setNickname(String nickname, String idCard, String lice
*/
WxOpenResult modifyCategory(WxFastMaCategory category) throws WxErrorException;

/**
* 8.7 获取类目名称信息
* <pre>
* 获取所有类目名称信息,用于给用户展示选择
* https://developers.weixin.qq.com/doc/oplatform/openApi/miniprogram-management/category-management/api_getallcategoryname.html
* </pre>
*
* @return 类目名称列表
* @throws WxErrorException .
*/
WxOpenMaCategoryNameListResult getAllCategoryName() throws WxErrorException;

/**
* 获取订单页Path信息
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ public WxOpenResult modifyCategory(WxFastMaCategory category) throws WxErrorExce
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}

@Override
public WxOpenMaCategoryNameListResult getAllCategoryName() throws WxErrorException {
String response = get(OPEN_GET_ALL_CATEGORY_NAME, "");
return WxOpenGsonBuilder.create().fromJson(response, WxOpenMaCategoryNameListResult.class);
}

/**
* 获取订单页Path信息
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ public WxOpenResult modifyCategory(WxFastMaCategory category) throws WxErrorExce
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}

@Override
public WxOpenMaCategoryNameListResult getAllCategoryName() throws WxErrorException {
String response = wxMaService.get(OPEN_GET_ALL_CATEGORY_NAME, "");
return WxOpenGsonBuilder.create().fromJson(response, WxOpenMaCategoryNameListResult.class);
}

/**
* 获取订单页Path信息
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package me.chanjar.weixin.open.bean.result;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;

import java.io.Serializable;
import java.util.List;

/**
* 获取类目名称信息的返回结果.
* <p>
* 用于获取所有小程序类目的 ID 和名称信息,包括一级类目和二级类目。
* </p>
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* @see <a href="https://developers.weixin.qq.com/doc/oplatform/openApi/miniprogram-management/category-management/api_getallcategoryname.html">官方文档</a>
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class WxOpenMaCategoryNameListResult extends WxOpenResult {
private static final long serialVersionUID = 8989721350285449879L;

/**
* 类目名称列表.
*/
@SerializedName("category_name_list")
private List<CategoryName> categoryNameList;

@Override
public String toString() {
return WxOpenGsonBuilder.create().toJson(this);
}

/**
* 类目名称信息.
* <p>
* 包含一级类目和二级类目的 ID 和名称。
* </p>
*/
@Data
public static class CategoryName implements Serializable {
private static final long serialVersionUID = 8989721350285449880L;

/**
* 一级类目ID.
*/
@SerializedName("first_id")
private Integer firstId;

/**
* 一级类目名称.
*/
@SerializedName("first_name")
private String firstName;

/**
* 二级类目ID.
*/
@SerializedName("second_id")
private Integer secondId;

/**
* 二级类目名称.
*/
@SerializedName("second_name")
private String secondName;

@Override
public String toString() {
return WxOpenGsonBuilder.create().toJson(this);
}
}
}