|
|
@ -1,18 +1,14 @@
|
|
|
|
package au.com.royalpay.payment.manage.support.cms.core.Impl;
|
|
|
|
package au.com.royalpay.payment.manage.support.cms.core.Impl;
|
|
|
|
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.support.cms.core.AppStyleService;
|
|
|
|
import au.com.royalpay.payment.manage.support.cms.core.AppStyleService;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
|
|
|
import au.com.royalpay.payment.tools.cms.RoyalPayCMSSupport;
|
|
|
|
import cn.yixblog.platform.http.HttpRequestGenerator;
|
|
|
|
|
|
|
|
import cn.yixblog.platform.http.HttpRequestResult;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class AppStyleServiceImpl implements AppStyleService {
|
|
|
|
public class AppStyleServiceImpl implements AppStyleService {
|
|
|
@ -21,81 +17,29 @@ public class AppStyleServiceImpl implements AppStyleService {
|
|
|
|
private String cmsHost;
|
|
|
|
private String cmsHost;
|
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private RoyalPayCMSSupport royalPayCMSSupport;
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public JSONObject listAppStyleGroup(int page, int limit) {
|
|
|
|
public JSONObject listAppStyleGroup(int page, int limit) {
|
|
|
|
String url = concatUrl("/app/style_group");
|
|
|
|
return royalPayCMSSupport.listAppStyleGroup(page,limit);
|
|
|
|
HttpRequestGenerator gen = new HttpRequestGenerator(url, RequestMethod.GET).addQueryString("page", page + "").addQueryString("limit", limit + "");
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
HttpRequestResult res = gen.execute();
|
|
|
|
|
|
|
|
if (res.isSuccess()) {
|
|
|
|
|
|
|
|
return res.getResponseContentJSONObj();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (URISyntaxException | IOException e) {
|
|
|
|
|
|
|
|
logger.error(e.getMessage(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new ServerErrorException("Failed to request CMS");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public JSONObject getAppStyleByStyleId(String style_id) {
|
|
|
|
public JSONObject getAppStyleByStyleId(String style_id) {
|
|
|
|
String url = concatUrl("/app/style_group/" + style_id);
|
|
|
|
return royalPayCMSSupport.getAppStyleByStyleId(style_id);
|
|
|
|
HttpRequestGenerator gen = new HttpRequestGenerator(url, RequestMethod.GET);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
HttpRequestResult res = gen.execute();
|
|
|
|
|
|
|
|
if (res.isSuccess()) {
|
|
|
|
|
|
|
|
return res.getResponseContentJSONObj();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (URISyntaxException | IOException e) {
|
|
|
|
|
|
|
|
logger.error(e.getMessage(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new ServerErrorException("Failed to request CMS");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void switchGroupByStyleId(String style_id) {
|
|
|
|
public void switchGroupByStyleId(String style_id) {
|
|
|
|
String url = concatUrl("/app/style_group/" + style_id);
|
|
|
|
royalPayCMSSupport.switchGroupByStyleId(style_id);
|
|
|
|
try {
|
|
|
|
|
|
|
|
HttpRequestResult res = new HttpRequestGenerator(url, RequestMethod.PUT).execute();
|
|
|
|
|
|
|
|
if (res.isSuccess()) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (URISyntaxException e) {
|
|
|
|
|
|
|
|
logger.error(e.getMessage(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new ServerErrorException("Failed to request CMS");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void addAppStyle(String style_id, JSONObject appStyleGroup) {
|
|
|
|
public void addAppStyle(String style_id, JSONObject appStyleGroup) {
|
|
|
|
String url = concatUrl("/app/style_group");
|
|
|
|
royalPayCMSSupport.addAppStyle(style_id,appStyleGroup);
|
|
|
|
try {
|
|
|
|
|
|
|
|
HttpRequestResult gen = new HttpRequestGenerator(url, RequestMethod.POST).addQueryString("style_id", style_id).setJSONEntity(appStyleGroup).execute();
|
|
|
|
|
|
|
|
if (gen.isSuccess()) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (URISyntaxException e) {
|
|
|
|
|
|
|
|
logger.error(e.getMessage(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new ServerErrorException("Failed to request CMS");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void updateAppStyleByStyleId(String style_id, String originStyleId, JSONObject appStyleGroup) {
|
|
|
|
public void updateAppStyleByStyleId(String style_id, String originStyleId, JSONObject appStyleGroup) {
|
|
|
|
String url = concatUrl("/app/style_group/" + style_id + "/style");
|
|
|
|
royalPayCMSSupport.updateAppStyleByStyleId(style_id,originStyleId,appStyleGroup);
|
|
|
|
try {
|
|
|
|
|
|
|
|
HttpRequestResult gen = new HttpRequestGenerator(url, RequestMethod.PUT).addQueryString("originStyleId", originStyleId).setJSONEntity(appStyleGroup).execute();
|
|
|
|
|
|
|
|
if (gen.isSuccess()) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (URISyntaxException e) {
|
|
|
|
|
|
|
|
logger.error(e.getMessage(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new ServerErrorException("Failed to request CMS");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String concatUrl(String uri) {
|
|
|
|
|
|
|
|
String host = cmsHost.endsWith("/") ? cmsHost.substring(0, cmsHost.length() - 1) : cmsHost;
|
|
|
|
|
|
|
|
uri = uri.startsWith("/") ? uri.substring(1) : uri;
|
|
|
|
|
|
|
|
return host + "/" + uri;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|