7 changed files with 277 additions and 4 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()); |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue