32 changed files with 855 additions and 19 deletions
			
			
		@ -0,0 +1,41 @@ | 
				
			|||
package com.epmet.dto.form; | 
				
			|||
 | 
				
			|||
import com.google.gson.annotations.SerializedName; | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @author zhaoqifeng | 
				
			|||
 * @dscription | 
				
			|||
 * @date 2020/8/20 13:44 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class ModifyDomainFormDTO implements Serializable { | 
				
			|||
	private static final long serialVersionUID = -1995778975498383130L; | 
				
			|||
	/** | 
				
			|||
	 * 客户ID | 
				
			|||
	 */ | 
				
			|||
	private String customerId; | 
				
			|||
	/** | 
				
			|||
	 * 客户端类型 | 
				
			|||
	 */ | 
				
			|||
	private String clientType; | 
				
			|||
	/** | 
				
			|||
	 * request 合法域名 | 
				
			|||
	 */ | 
				
			|||
	private List<String> requestDomain; | 
				
			|||
	/** | 
				
			|||
	 * socket 合法域名 | 
				
			|||
	 */ | 
				
			|||
	private List<String> wsRequestDomain; | 
				
			|||
	/** | 
				
			|||
	 * uploadFile 合法域名 | 
				
			|||
	 */ | 
				
			|||
	private List<String> uploadDomain; | 
				
			|||
	/** | 
				
			|||
	 * downloadFile 合法域名 | 
				
			|||
	 */ | 
				
			|||
	private List<String> downloadDomain; | 
				
			|||
} | 
				
			|||
@ -0,0 +1,28 @@ | 
				
			|||
package com.epmet.dto.form; | 
				
			|||
 | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @author zhaoqifeng | 
				
			|||
 * @dscription | 
				
			|||
 * @date 2020/8/19 17:46 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class WebviewDomainFormDTO implements Serializable { | 
				
			|||
	private static final long serialVersionUID = 8022056850984848597L; | 
				
			|||
	/** | 
				
			|||
	 * 客户ID | 
				
			|||
	 */ | 
				
			|||
	private String customerId; | 
				
			|||
	/** | 
				
			|||
	 * 客户端类型 | 
				
			|||
	 */ | 
				
			|||
	private String clientType; | 
				
			|||
	/** | 
				
			|||
	 * 业务域名 | 
				
			|||
	 */ | 
				
			|||
	private List<String> webViewDomain; | 
				
			|||
} | 
				
			|||
@ -0,0 +1,51 @@ | 
				
			|||
package com.epmet.controller; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.tools.utils.Result; | 
				
			|||
import com.epmet.dto.form.ModifyDomainFormDTO; | 
				
			|||
import com.epmet.dto.form.WebviewDomainFormDTO; | 
				
			|||
import com.epmet.service.SettingService; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.web.bind.annotation.PostMapping; | 
				
			|||
import org.springframework.web.bind.annotation.RequestBody; | 
				
			|||
import org.springframework.web.bind.annotation.RequestMapping; | 
				
			|||
import org.springframework.web.bind.annotation.RestController; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @author zhaoqifeng | 
				
			|||
 * @dscription | 
				
			|||
 * @date 2020/8/20 13:50 | 
				
			|||
 */ | 
				
			|||
@RestController | 
				
			|||
@RequestMapping("setting") | 
				
			|||
public class SettingController { | 
				
			|||
	@Autowired | 
				
			|||
	private SettingService settingService; | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 设置服务器域名 | 
				
			|||
	 * | 
				
			|||
	 * @param formDTO | 
				
			|||
	 * @return com.epmet.commons.tools.utils.Result | 
				
			|||
	 * @author zhaoqifeng | 
				
			|||
	 * @date 2020/8/20 13:51 | 
				
			|||
	 */ | 
				
			|||
	@PostMapping("modifydomain") | 
				
			|||
	public Result modifyDomain(@RequestBody ModifyDomainFormDTO formDTO) { | 
				
			|||
		settingService.modifyDomain(formDTO); | 
				
			|||
		return new Result<>(); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 设置业务域名 | 
				
			|||
	 * | 
				
			|||
	 * @param formDTO | 
				
			|||
	 * @return com.epmet.commons.tools.utils.Result | 
				
			|||
	 * @author zhaoqifeng | 
				
			|||
	 * @date 2020/8/20 13:51 | 
				
			|||
	 */ | 
				
			|||
	@PostMapping("setwebviewdomain") | 
				
			|||
	public Result setWebviewDomain(@RequestBody WebviewDomainFormDTO formDTO) { | 
				
			|||
		settingService.setWebviewDomain(formDTO); | 
				
			|||
		return new Result<>(); | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -0,0 +1,31 @@ | 
				
			|||
package com.epmet.service; | 
				
			|||
 | 
				
			|||
import com.epmet.dto.form.ModifyDomainFormDTO; | 
				
			|||
import com.epmet.dto.form.WebviewDomainFormDTO; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @author zhaoqifeng | 
				
			|||
 * @dscription | 
				
			|||
 * @date 2020/8/20 11:11 | 
				
			|||
 */ | 
				
			|||
public interface SettingService { | 
				
			|||
	/** | 
				
			|||
	 * 设置服务器域名 | 
				
			|||
	 * | 
				
			|||
	 * @param formDTO | 
				
			|||
	 * @return void | 
				
			|||
	 * @author zhaoqifeng | 
				
			|||
	 * @date 2020/8/20 13:46 | 
				
			|||
	 */ | 
				
			|||
	void modifyDomain(ModifyDomainFormDTO formDTO); | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 设置业务域名 | 
				
			|||
	 * | 
				
			|||
	 * @param formDTO | 
				
			|||
	 * @return void | 
				
			|||
	 * @author zhaoqifeng | 
				
			|||
	 * @date 2020/8/19 17:49 | 
				
			|||
	 */ | 
				
			|||
	void setWebviewDomain(WebviewDomainFormDTO formDTO); | 
				
			|||
} | 
				
			|||
@ -0,0 +1,63 @@ | 
				
			|||
package com.epmet.service.impl; | 
				
			|||
 | 
				
			|||
import com.epmet.commons.tools.exception.RenException; | 
				
			|||
import com.epmet.dao.AuthorizationInfoDao; | 
				
			|||
import com.epmet.dto.AuthorizationInfoDTO; | 
				
			|||
import com.epmet.dto.form.ModifyDomainFormDTO; | 
				
			|||
import com.epmet.dto.form.WebviewDomainFormDTO; | 
				
			|||
import com.epmet.service.SettingService; | 
				
			|||
import com.epmet.wxapi.param.WxMaModifyDomainReq; | 
				
			|||
import com.epmet.wxapi.param.WxMaSetWebviewDomainReq; | 
				
			|||
import com.epmet.wxapi.result.WxResult; | 
				
			|||
import com.epmet.wxapi.service.WxMaSettingService; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.stereotype.Service; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @author zhaoqifeng | 
				
			|||
 * @dscription | 
				
			|||
 * @date 2020/8/20 11:11 | 
				
			|||
 */ | 
				
			|||
@Service | 
				
			|||
public class SettingServiceImpl implements SettingService { | 
				
			|||
	@Autowired | 
				
			|||
	private AuthorizationInfoDao authorizationInfoDao; | 
				
			|||
	@Autowired | 
				
			|||
	private WxMaSettingService wxMaSettingService; | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public void modifyDomain(ModifyDomainFormDTO formDTO) { | 
				
			|||
		//获取小程序调用令牌
 | 
				
			|||
		AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); | 
				
			|||
		if (null == authInfo) { | 
				
			|||
			throw new RenException("未授权"); | 
				
			|||
		} | 
				
			|||
		WxMaModifyDomainReq request = new WxMaModifyDomainReq(); | 
				
			|||
		request.setDownloadDomain(formDTO.getDownloadDomain()); | 
				
			|||
		request.setRequestDomain(formDTO.getRequestDomain()); | 
				
			|||
		request.setWsRequestDomain(formDTO.getWsRequestDomain()); | 
				
			|||
		request.setUploadDomain(formDTO.getUploadDomain()); | 
				
			|||
		//设置业务域名
 | 
				
			|||
		WxResult setDomain = wxMaSettingService.modifyDomain(authInfo.getAuthorizerAccessToken(), request); | 
				
			|||
		if (!setDomain.success()) { | 
				
			|||
			throw new RenException(setDomain.getErrorCode(), setDomain.getErrorMsg()); | 
				
			|||
		} | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public void setWebviewDomain(WebviewDomainFormDTO formDTO) { | 
				
			|||
		//获取小程序调用令牌
 | 
				
			|||
		AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); | 
				
			|||
		if (null == authInfo) { | 
				
			|||
			throw new RenException("未授权"); | 
				
			|||
		} | 
				
			|||
		WxMaSetWebviewDomainReq request = new WxMaSetWebviewDomainReq(); | 
				
			|||
		request.setAction("set"); | 
				
			|||
		request.setWebViewDomain(formDTO.getWebViewDomain()); | 
				
			|||
		//设置业务域名
 | 
				
			|||
		WxResult setWebviewDomain = wxMaSettingService.setWebviewDomain(authInfo.getAuthorizerAccessToken(), request); | 
				
			|||
		if (!setWebviewDomain.success()) { | 
				
			|||
			throw new RenException(setWebviewDomain.getErrorCode(), setWebviewDomain.getErrorMsg()); | 
				
			|||
		} | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -0,0 +1,63 @@ | 
				
			|||
package com.epmet.wxapi.constant; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @author zhaoqifeng | 
				
			|||
 * @dscription | 
				
			|||
 * @date 2020/8/18 13:59 | 
				
			|||
 */ | 
				
			|||
public interface WxMaSettingConstant { | 
				
			|||
	/** | 
				
			|||
	 * 设置服务器域名 | 
				
			|||
	 */ | 
				
			|||
	String MODIFY_DOMAIN_URL = "https://api.weixin.qq.com/wxa/modify_domain"; | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 设置业务域名 | 
				
			|||
	 */ | 
				
			|||
	String SET_WEBVIEW_DOMAIN_URL = "https://api.weixin.qq.com/wxa/setwebviewdomain"; | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 设置名称 | 
				
			|||
	 */ | 
				
			|||
	String SET_NICK_NAME_URL = "https://api.weixin.qq.com/wxa/setnickname"; | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 获取可以设置的所有类目 | 
				
			|||
	 */ | 
				
			|||
	String GET_ALL_CATEGORIES_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/getallcategories"; | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 获取已设置的所有类目 | 
				
			|||
	 */ | 
				
			|||
	String GET_CATEGORY_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/getcategory"; | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 添加类目 | 
				
			|||
	 */ | 
				
			|||
	String ADD_CATEGORY_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/addcategory"; | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 删除类目 | 
				
			|||
	 */ | 
				
			|||
	String DELETE_CATEGORY_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/deletecategory"; | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 修改类目资质信息 | 
				
			|||
	 */ | 
				
			|||
	String MODIFY_CATEGORY_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/modifycategory"; | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 绑定微信用户为体验者 | 
				
			|||
	 */ | 
				
			|||
	String BIND_TESTER_URL = "https://api.weixin.qq.com/wxa/bind_tester"; | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 解除绑定体验者 | 
				
			|||
	 */ | 
				
			|||
	String UNBIND_TESTER_URL = "https://api.weixin.qq.com/wxa/unbind_tester"; | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 获取体验者列表 | 
				
			|||
	 */ | 
				
			|||
	String MEMBER_AUTH_URL = "https://api.weixin.qq.com/wxa/memberauth"; | 
				
			|||
} | 
				
			|||
@ -0,0 +1,42 @@ | 
				
			|||
package com.epmet.wxapi.param; | 
				
			|||
 | 
				
			|||
import lombok.Data; | 
				
			|||
import lombok.NoArgsConstructor; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @author zhaoqifeng | 
				
			|||
 * @dscription | 
				
			|||
 * @date 2020/8/18 15:14 | 
				
			|||
 */ | 
				
			|||
@NoArgsConstructor | 
				
			|||
@Data | 
				
			|||
public class WxAddCategoryReq implements Serializable { | 
				
			|||
 | 
				
			|||
	private static final long serialVersionUID = -3659216114599054052L; | 
				
			|||
 | 
				
			|||
	private List<CategoriesBean> categories; | 
				
			|||
 | 
				
			|||
	@NoArgsConstructor | 
				
			|||
	@Data | 
				
			|||
	public static class CategoriesBean { | 
				
			|||
		/** | 
				
			|||
		 * | 
				
			|||
		 */ | 
				
			|||
		private int first; | 
				
			|||
		private int second; | 
				
			|||
		private List<CerticatesBean> certicates; | 
				
			|||
 | 
				
			|||
		@NoArgsConstructor | 
				
			|||
		@Data | 
				
			|||
		public static class CerticatesBean { | 
				
			|||
			/** | 
				
			|||
			 * | 
				
			|||
			 */ | 
				
			|||
			private String key; | 
				
			|||
			private String value; | 
				
			|||
		} | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -0,0 +1,18 @@ | 
				
			|||
package com.epmet.wxapi.param; | 
				
			|||
 | 
				
			|||
import com.google.gson.annotations.SerializedName; | 
				
			|||
import lombok.Data; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @author zhaoqifeng | 
				
			|||
 * @dscription | 
				
			|||
 * @date 2020/8/18 15:43 | 
				
			|||
 */ | 
				
			|||
@Data | 
				
			|||
public class WxBindTesterReq implements Serializable { | 
				
			|||
	private static final long serialVersionUID = -6509988898376682232L; | 
				
			|||
	@SerializedName("wechatid") | 
				
			|||
	private String weChatId; | 
				
			|||
} | 
				
			|||
@ -0,0 +1,19 @@ | 
				
			|||
package com.epmet.wxapi.param; | 
				
			|||
 | 
				
			|||
import lombok.Data; | 
				
			|||
import lombok.NoArgsConstructor; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @author zhaoqifeng | 
				
			|||
 * @dscription | 
				
			|||
 * @date 2020/8/18 15:22 | 
				
			|||
 */ | 
				
			|||
@NoArgsConstructor | 
				
			|||
@Data | 
				
			|||
public class WxDelCategoryReq implements Serializable { | 
				
			|||
	private static final long serialVersionUID = 7179297618235954140L; | 
				
			|||
	private Integer first; | 
				
			|||
	private Integer second; | 
				
			|||
} | 
				
			|||
@ -0,0 +1,41 @@ | 
				
			|||
package com.epmet.wxapi.param; | 
				
			|||
 | 
				
			|||
import lombok.Data; | 
				
			|||
import lombok.NoArgsConstructor; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @author zhaoqifeng | 
				
			|||
 * @dscription | 
				
			|||
 * @date 2020/8/18 15:26 | 
				
			|||
 */ | 
				
			|||
@NoArgsConstructor | 
				
			|||
@Data | 
				
			|||
public class WxModifyCategoryReq implements Serializable { | 
				
			|||
 | 
				
			|||
	private static final long serialVersionUID = -428387175986769380L; | 
				
			|||
	/** | 
				
			|||
	 * 一级类目 ID | 
				
			|||
	 */ | 
				
			|||
	private int first; | 
				
			|||
	/** | 
				
			|||
	 * 二级类目 ID | 
				
			|||
	 */ | 
				
			|||
	private int second; | 
				
			|||
	/** | 
				
			|||
	 * [资质信息]列表 | 
				
			|||
	 */ | 
				
			|||
	private List<CerticatesBean> certicates; | 
				
			|||
 | 
				
			|||
	@NoArgsConstructor | 
				
			|||
	@Data | 
				
			|||
	public static class CerticatesBean { | 
				
			|||
		/** | 
				
			|||
		 * 资质图片 | 
				
			|||
		 */ | 
				
			|||
		private String key; | 
				
			|||
		private String value; | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -0,0 +1,61 @@ | 
				
			|||
package com.epmet.wxapi.result; | 
				
			|||
 | 
				
			|||
import com.google.gson.annotations.SerializedName; | 
				
			|||
import lombok.Data; | 
				
			|||
import lombok.NoArgsConstructor; | 
				
			|||
 | 
				
			|||
import java.io.Serializable; | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @author zhaoqifeng | 
				
			|||
 * @dscription | 
				
			|||
 * @date 2020/8/18 14:53 | 
				
			|||
 */ | 
				
			|||
@NoArgsConstructor | 
				
			|||
@Data | 
				
			|||
public class WxGetAllCategoriesResult implements Serializable { | 
				
			|||
 | 
				
			|||
	private static final long serialVersionUID = 4419968653961864521L; | 
				
			|||
	/** | 
				
			|||
	 * errcode : 0 | 
				
			|||
	 */ | 
				
			|||
	@SerializedName("errcode") | 
				
			|||
	private Integer errCode; | 
				
			|||
	@SerializedName("errmsg") | 
				
			|||
	private String errMsg; | 
				
			|||
	@SerializedName("categories_list") | 
				
			|||
	private CategoriesListBean categoriesList; | 
				
			|||
	@NoArgsConstructor | 
				
			|||
	@Data | 
				
			|||
	public static class CategoriesListBean { | 
				
			|||
		private List<CategoriesBean> categories; | 
				
			|||
 | 
				
			|||
		@NoArgsConstructor | 
				
			|||
		@Data | 
				
			|||
		public static class CategoriesBean { | 
				
			|||
			/** | 
				
			|||
			 * id : 0 | 
				
			|||
			 */ | 
				
			|||
			private int id; | 
				
			|||
			private QualifyBean qualify; | 
				
			|||
			private String name; | 
				
			|||
			private int level; | 
				
			|||
			private int father; | 
				
			|||
			@SerializedName("sensitive_type") | 
				
			|||
			private int sensitiveType; | 
				
			|||
			private List<Integer> children; | 
				
			|||
 | 
				
			|||
			@NoArgsConstructor | 
				
			|||
			@Data | 
				
			|||
			public static class QualifyBean { | 
				
			|||
				/** | 
				
			|||
				 * exter_list : [] | 
				
			|||
				 */ | 
				
			|||
				private String remark; | 
				
			|||
				@SerializedName("exter_list") | 
				
			|||
				private List<?> exterList; | 
				
			|||
			} | 
				
			|||
		} | 
				
			|||
	} | 
				
			|||
} | 
				
			|||
@ -0,0 +1,134 @@ | 
				
			|||
package com.epmet.wxapi.service; | 
				
			|||
 | 
				
			|||
import com.epmet.wxapi.param.*; | 
				
			|||
import com.epmet.wxapi.result.*; | 
				
			|||
 | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * 小程序修改服务器地址、类目管理、成员管理 API(大部分只能是第三方平台调用) | 
				
			|||
 * | 
				
			|||
 * @author zhaoqifeng | 
				
			|||
 * @date 2020/8/18 13:50 | 
				
			|||
 */ | 
				
			|||
public interface WxMaSettingService { | 
				
			|||
	/** | 
				
			|||
	 * 设置服务器域名 | 
				
			|||
	 * | 
				
			|||
	 * @param accessToken | 
				
			|||
	 * @param action | 
				
			|||
	 * @return com.epmet.wxapi.result.WxResult | 
				
			|||
	 * @author zhaoqifeng | 
				
			|||
	 * @date 2020/7/16 17:21 | 
				
			|||
	 */ | 
				
			|||
	WxResult<WxMaModifyDomainResult> modifyDomain(String accessToken, String action); | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 设置服务器域名 | 
				
			|||
	 * | 
				
			|||
	 * @param accessToken | 
				
			|||
	 * @param request | 
				
			|||
	 * @return com.epmet.wxapi.result.WxResult | 
				
			|||
	 * @author zhaoqifeng | 
				
			|||
	 * @date 2020/7/16 17:21 | 
				
			|||
	 */ | 
				
			|||
	WxResult modifyDomain(String accessToken, WxMaModifyDomainReq request); | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 设置业务域名 | 
				
			|||
	 * | 
				
			|||
	 * @param accessToken | 
				
			|||
	 * @param action | 
				
			|||
	 * @return com.epmet.wxapi.result.WxResult | 
				
			|||
	 * @author zhaoqifeng | 
				
			|||
	 * @date 2020/7/16 17:22 | 
				
			|||
	 */ | 
				
			|||
	WxResult<WxMaSetWebviewDomainResult> setWebviewDomain(String accessToken, String action); | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 设置业务域名 | 
				
			|||
	 * | 
				
			|||
	 * @param accessToken | 
				
			|||
	 * @param request | 
				
			|||
	 * @return com.epmet.wxapi.result.WxResult | 
				
			|||
	 * @author zhaoqifeng | 
				
			|||
	 * @date 2020/8/19 17:52 | 
				
			|||
	 */ | 
				
			|||
	WxResult setWebviewDomain(String accessToken, WxMaSetWebviewDomainReq request); | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 获取可以设置的所有类目 | 
				
			|||
	 * | 
				
			|||
	 * @param accessToken | 
				
			|||
	 * @return com.epmet.wxapi.result.WxResult<com.epmet.wxapi.result.WxGetAllCategoriesResult> | 
				
			|||
	 * @author zhaoqifeng | 
				
			|||
	 * @date 2020/8/18 15:06 | 
				
			|||
	 */ | 
				
			|||
	WxResult<WxGetAllCategoriesResult> getAllCategories(String accessToken); | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 获取已设置的所有类目 | 
				
			|||
	 * | 
				
			|||
	 * @param accessToken | 
				
			|||
	 * @return com.epmet.wxapi.result.WxResult<com.epmet.wxapi.result.WxOpenGetCategoryResult> | 
				
			|||
	 * @author zhaoqifeng | 
				
			|||
	 * @date 2020/8/6 10:47 | 
				
			|||
	 */ | 
				
			|||
	WxResult<WxOpenGetCategoryResult> getCategory(String accessToken); | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 添加类目 | 
				
			|||
	 * | 
				
			|||
	 * @param accessToken | 
				
			|||
	 * @param request | 
				
			|||
	 * @return com.epmet.wxapi.result.WxResult | 
				
			|||
	 * @author zhaoqifeng | 
				
			|||
	 * @date 2020/8/18 15:20 | 
				
			|||
	 */ | 
				
			|||
	WxResult addCategory(String accessToken, WxAddCategoryReq request); | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 删除类目 | 
				
			|||
	 * | 
				
			|||
	 * @param accessToken | 
				
			|||
	 * @param request | 
				
			|||
	 * @return com.epmet.wxapi.result.WxResult | 
				
			|||
	 * @author zhaoqifeng | 
				
			|||
	 * @date 2020/8/18 15:20 | 
				
			|||
	 */ | 
				
			|||
	WxResult delCategory(String accessToken, WxDelCategoryReq request); | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 修改类目资质信息 | 
				
			|||
	 * | 
				
			|||
	 * @param accessToken | 
				
			|||
	 * @param request | 
				
			|||
	 * @return com.epmet.wxapi.result.WxResult | 
				
			|||
	 * @author zhaoqifeng | 
				
			|||
	 * @date 2020/8/18 15:20 | 
				
			|||
	 */ | 
				
			|||
	WxResult modifyCategory(String accessToken, WxModifyCategoryReq request); | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 绑定微信用户为体验者 | 
				
			|||
	 * | 
				
			|||
	 * @param accessToken | 
				
			|||
	 * @param request | 
				
			|||
	 * @return com.epmet.wxapi.result.WxResult<java.lang.String> | 
				
			|||
	 * @author zhaoqifeng | 
				
			|||
	 * @date 2020/8/18 15:45 | 
				
			|||
	 */ | 
				
			|||
	WxResult<String> bindTester(String accessToken, WxBindTesterReq request); | 
				
			|||
 | 
				
			|||
	/** | 
				
			|||
	 * 解除绑定体验者 | 
				
			|||
	 * | 
				
			|||
	 * @param accessToken | 
				
			|||
	 * @param request | 
				
			|||
	 * @return com.epmet.wxapi.result.WxResult<java.lang.String> | 
				
			|||
	 * @author zhaoqifeng | 
				
			|||
	 * @date 2020/8/18 15:45 | 
				
			|||
	 */ | 
				
			|||
	WxResult unBindTester(String accessToken, WxBindTesterReq request); | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,244 @@ | 
				
			|||
package com.epmet.wxapi.service.impl; | 
				
			|||
 | 
				
			|||
import com.alibaba.fastjson.JSONObject; | 
				
			|||
import com.epmet.commons.tools.constant.NumConstant; | 
				
			|||
import com.epmet.commons.tools.utils.HttpClientManager; | 
				
			|||
import com.epmet.commons.tools.utils.Result; | 
				
			|||
import com.epmet.wxapi.constant.WxMaCodeConstant; | 
				
			|||
import com.epmet.wxapi.constant.WxMaSettingConstant; | 
				
			|||
import com.epmet.wxapi.enums.WxMaErrorMsgEnum; | 
				
			|||
import com.epmet.wxapi.param.*; | 
				
			|||
import com.epmet.wxapi.result.*; | 
				
			|||
import com.epmet.wxapi.service.WxMaSettingService; | 
				
			|||
import com.google.gson.Gson; | 
				
			|||
import com.google.gson.GsonBuilder; | 
				
			|||
import org.springframework.beans.factory.annotation.Autowired; | 
				
			|||
import org.springframework.stereotype.Service; | 
				
			|||
 | 
				
			|||
import java.util.List; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * @author zhaoqifeng | 
				
			|||
 * @dscription | 
				
			|||
 * @date 2020/8/18 13:57 | 
				
			|||
 */ | 
				
			|||
@Service | 
				
			|||
public class WxMaSettingServiceImpl implements WxMaSettingService { | 
				
			|||
	private static final String ERR_CODE = "errcode"; | 
				
			|||
	private static final String ERR_MSG = "errmsg"; | 
				
			|||
 | 
				
			|||
	@Autowired | 
				
			|||
	private WxMaDomainDTO wxMaDomainDTO; | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public WxResult<WxMaModifyDomainResult> modifyDomain(String accessToken, String action) { | 
				
			|||
		WxResult<WxMaModifyDomainResult> result = new WxResult<>(); | 
				
			|||
		String url = WxMaSettingConstant.MODIFY_DOMAIN_URL + "?" + "access_token=" + accessToken; | 
				
			|||
		WxMaModifyDomainReq request = new WxMaModifyDomainReq(); | 
				
			|||
		request.setAction(action); | 
				
			|||
		request.setRequestDomain(wxMaDomainDTO.getRequestDomain()); | 
				
			|||
		request.setUploadDomain(wxMaDomainDTO.getUploadDomain()); | 
				
			|||
		request.setWsRequestDomain(wxMaDomainDTO.getWsRequestDomain()); | 
				
			|||
		request.setDownloadDomain(wxMaDomainDTO.getDownloadDomain()); | 
				
			|||
		Result<String> modifyResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); | 
				
			|||
		if (!modifyResult.success()) { | 
				
			|||
			result.setErrorCode(modifyResult.getCode()); | 
				
			|||
			result.setErrorMsg(modifyResult.getMsg()); | 
				
			|||
			return result; | 
				
			|||
		} | 
				
			|||
		Gson gson = new Gson(); | 
				
			|||
		WxMaModifyDomainResult domainResult = gson.fromJson(modifyResult.getData(), WxMaModifyDomainResult.class); | 
				
			|||
		result.setErrorCode(domainResult.getErrcode()); | 
				
			|||
		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(domainResult.getErrcode())); | 
				
			|||
		result.setData(domainResult); | 
				
			|||
		return result; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public WxResult modifyDomain(String accessToken, WxMaModifyDomainReq request) { | 
				
			|||
		WxResult result = new WxResult<>(); | 
				
			|||
		String url = WxMaCodeConstant.MODIFY_DOMAIN_URL + "?" + "access_token=" + accessToken; | 
				
			|||
		Result<String> modifyResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); | 
				
			|||
		if (!modifyResult.success()) { | 
				
			|||
			result.setErrorCode(modifyResult.getCode()); | 
				
			|||
			result.setErrorMsg(modifyResult.getMsg()); | 
				
			|||
			return result; | 
				
			|||
		} | 
				
			|||
		Gson gson = new Gson(); | 
				
			|||
		WxMaModifyDomainResult domainResult = gson.fromJson(modifyResult.getData(), WxMaModifyDomainResult.class); | 
				
			|||
		result.setErrorCode(domainResult.getErrcode()); | 
				
			|||
		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(domainResult.getErrcode())); | 
				
			|||
		return result; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public WxResult<WxMaSetWebviewDomainResult> setWebviewDomain(String accessToken, String action) { | 
				
			|||
		WxResult<WxMaSetWebviewDomainResult> result = new WxResult<>(); | 
				
			|||
		String url = WxMaSettingConstant.SET_WEBVIEW_DOMAIN_URL + "?" + "access_token=" + accessToken; | 
				
			|||
		WxMaSetWebviewDomainReq request = new WxMaSetWebviewDomainReq(); | 
				
			|||
		request.setAction(action); | 
				
			|||
		request.setWebViewDomain(wxMaDomainDTO.getWebviewDomain()); | 
				
			|||
		Result<String> modifyResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); | 
				
			|||
		if (!modifyResult.success()) { | 
				
			|||
			result.setErrorCode(modifyResult.getCode()); | 
				
			|||
			result.setErrorMsg(modifyResult.getMsg()); | 
				
			|||
			return result; | 
				
			|||
		} | 
				
			|||
		Gson gson = new Gson(); | 
				
			|||
		WxMaSetWebviewDomainResult domainResult = gson.fromJson(modifyResult.getData(), WxMaSetWebviewDomainResult.class); | 
				
			|||
		result.setErrorCode(domainResult.getErrcode()); | 
				
			|||
		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(domainResult.getErrcode())); | 
				
			|||
		result.setData(domainResult); | 
				
			|||
		return result; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public WxResult setWebviewDomain(String accessToken, WxMaSetWebviewDomainReq request) { | 
				
			|||
		WxResult result = new WxResult<>(); | 
				
			|||
		String url = WxMaCodeConstant.SET_WEBVIEW_DOMAIN_URL + "?" + "access_token=" + accessToken; | 
				
			|||
		Result<String> modifyResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); | 
				
			|||
		if (!modifyResult.success()) { | 
				
			|||
			result.setErrorCode(modifyResult.getCode()); | 
				
			|||
			result.setErrorMsg(modifyResult.getMsg()); | 
				
			|||
			return result; | 
				
			|||
		} | 
				
			|||
		Gson gson = new Gson(); | 
				
			|||
		WxMaSetWebviewDomainResult domainResult = gson.fromJson(modifyResult.getData(), WxMaSetWebviewDomainResult.class); | 
				
			|||
		result.setErrorCode(domainResult.getErrcode()); | 
				
			|||
		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(domainResult.getErrcode())); | 
				
			|||
		return result; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public WxResult<WxGetAllCategoriesResult> getAllCategories(String accessToken) { | 
				
			|||
		WxResult<WxGetAllCategoriesResult> result = new WxResult<>(); | 
				
			|||
		String url = WxMaSettingConstant.GET_ALL_CATEGORIES_URL + "?" + "access_token=" + accessToken; | 
				
			|||
		Result<String> modifyResult = HttpClientManager.getInstance().sendGet(url, null); | 
				
			|||
		if (!modifyResult.success()) { | 
				
			|||
			result.setErrorCode(modifyResult.getCode()); | 
				
			|||
			result.setErrorMsg(modifyResult.getMsg()); | 
				
			|||
			return result; | 
				
			|||
		} | 
				
			|||
		Gson gson = new Gson(); | 
				
			|||
		WxGetAllCategoriesResult categoryResult = gson.fromJson(modifyResult.getData(), WxGetAllCategoriesResult.class); | 
				
			|||
		if (categoryResult.getErrCode() != NumConstant.ZERO) { | 
				
			|||
			result.setErrorCode(categoryResult.getErrCode()); | 
				
			|||
			result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(categoryResult.getErrCode())); | 
				
			|||
			return result; | 
				
			|||
		} | 
				
			|||
		result.setErrorCode(categoryResult.getErrCode()); | 
				
			|||
		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(categoryResult.getErrCode())); | 
				
			|||
		result.setData(categoryResult); | 
				
			|||
		return result; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public WxResult<WxOpenGetCategoryResult> getCategory(String accessToken) { | 
				
			|||
		WxResult<WxOpenGetCategoryResult> result = new WxResult<>(); | 
				
			|||
		String url = WxMaSettingConstant.GET_CATEGORY_URL + "?" + "access_token=" + accessToken; | 
				
			|||
		Result<String> statusResult = HttpClientManager.getInstance().sendGet(url, null); | 
				
			|||
		if (!statusResult.success()) { | 
				
			|||
			result.setErrorCode(statusResult.getCode()); | 
				
			|||
			result.setErrorMsg(statusResult.getMsg()); | 
				
			|||
			return result; | 
				
			|||
		} | 
				
			|||
		Gson gson = new Gson(); | 
				
			|||
		WxOpenGetCategoryResult categoryResult = gson.fromJson(statusResult.getData(), WxOpenGetCategoryResult.class); | 
				
			|||
		if (categoryResult.getErrcode() != NumConstant.ZERO) { | 
				
			|||
			result.setErrorCode(categoryResult.getErrcode()); | 
				
			|||
			result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(categoryResult.getErrcode())); | 
				
			|||
			return result; | 
				
			|||
		} | 
				
			|||
		result.ok(categoryResult); | 
				
			|||
		return result; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public WxResult addCategory(String accessToken, WxAddCategoryReq request) { | 
				
			|||
		WxResult result = new WxResult(); | 
				
			|||
		String url = WxMaSettingConstant.ADD_CATEGORY_URL + "?" + "access_token=" + accessToken; | 
				
			|||
		Result<String> categoryResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); | 
				
			|||
		if (!categoryResult.success()) { | 
				
			|||
			result.setErrorCode(categoryResult.getCode()); | 
				
			|||
			result.setErrorMsg(categoryResult.getMsg()); | 
				
			|||
			return result; | 
				
			|||
		} | 
				
			|||
		JSONObject jsonObject = JSONObject.parseObject(categoryResult.getData()); | 
				
			|||
		result.setErrorCode(jsonObject.getInteger(ERR_CODE)); | 
				
			|||
		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE))); | 
				
			|||
		return result; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public WxResult delCategory(String accessToken, WxDelCategoryReq request) { | 
				
			|||
		WxResult result = new WxResult(); | 
				
			|||
		String url = WxMaSettingConstant.DELETE_CATEGORY_URL + "?" + "access_token=" + accessToken; | 
				
			|||
		Result<String> categoryResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); | 
				
			|||
		if (!categoryResult.success()) { | 
				
			|||
			result.setErrorCode(categoryResult.getCode()); | 
				
			|||
			result.setErrorMsg(categoryResult.getMsg()); | 
				
			|||
			return result; | 
				
			|||
		} | 
				
			|||
		JSONObject jsonObject = JSONObject.parseObject(categoryResult.getData()); | 
				
			|||
		result.setErrorCode(jsonObject.getInteger(ERR_CODE)); | 
				
			|||
		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE))); | 
				
			|||
		return result; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public WxResult modifyCategory(String accessToken, WxModifyCategoryReq request) { | 
				
			|||
		WxResult result = new WxResult(); | 
				
			|||
		String url = WxMaSettingConstant.MODIFY_CATEGORY_URL + "?" + "access_token=" + accessToken; | 
				
			|||
		Result<String> categoryResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); | 
				
			|||
		if (!categoryResult.success()) { | 
				
			|||
			result.setErrorCode(categoryResult.getCode()); | 
				
			|||
			result.setErrorMsg(categoryResult.getMsg()); | 
				
			|||
			return result; | 
				
			|||
		} | 
				
			|||
		JSONObject jsonObject = JSONObject.parseObject(categoryResult.getData()); | 
				
			|||
		result.setErrorCode(jsonObject.getInteger(ERR_CODE)); | 
				
			|||
		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE))); | 
				
			|||
		return result; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public WxResult<String> bindTester(String accessToken, WxBindTesterReq request) { | 
				
			|||
		WxResult<String> result = new WxResult<>(); | 
				
			|||
		String url = WxMaSettingConstant.BIND_TESTER_URL + "?" + "access_token=" + accessToken; | 
				
			|||
		Result<String> testerResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); | 
				
			|||
		if (!testerResult.success()) { | 
				
			|||
			result.setErrorCode(testerResult.getCode()); | 
				
			|||
			result.setErrorMsg(testerResult.getMsg()); | 
				
			|||
			return result; | 
				
			|||
		} | 
				
			|||
		JSONObject jsonObject = JSONObject.parseObject(testerResult.getData()); | 
				
			|||
		result.setErrorCode(jsonObject.getInteger(ERR_CODE)); | 
				
			|||
		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE))); | 
				
			|||
		result.setData(jsonObject.getString("userstr")); | 
				
			|||
		return result; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	@Override | 
				
			|||
	public WxResult unBindTester(String accessToken, WxBindTesterReq request) { | 
				
			|||
		WxResult result = new WxResult(); | 
				
			|||
		String url = WxMaSettingConstant.UNBIND_TESTER_URL + "?" + "access_token=" + accessToken; | 
				
			|||
		Result<String> testerResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); | 
				
			|||
		if (!testerResult.success()) { | 
				
			|||
			result.setErrorCode(testerResult.getCode()); | 
				
			|||
			result.setErrorMsg(testerResult.getMsg()); | 
				
			|||
			return result; | 
				
			|||
		} | 
				
			|||
		JSONObject jsonObject = JSONObject.parseObject(testerResult.getData()); | 
				
			|||
		result.setErrorCode(jsonObject.getInteger(ERR_CODE)); | 
				
			|||
		result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE))); | 
				
			|||
		return result; | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
	private String toJson(Object object) { | 
				
			|||
		GsonBuilder gsonBuilder = new GsonBuilder(); | 
				
			|||
		gsonBuilder.setPrettyPrinting(); | 
				
			|||
		Gson gson = gsonBuilder.create(); | 
				
			|||
		return gson.toJson(object); | 
				
			|||
	} | 
				
			|||
 | 
				
			|||
} | 
				
			|||
					Loading…
					
					
				
		Reference in new issue