|
|
@@ -1,11 +1,16 @@
|
|
|
package com.uas.sso.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.uas.sso.ResultWrap;
|
|
|
+import com.uas.sso.common.util.HttpUtil;
|
|
|
import com.uas.sso.entity.App;
|
|
|
+import com.uas.sso.exception.VisibleError;
|
|
|
import com.uas.sso.service.AppService;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
/**
|
|
|
@@ -24,9 +29,29 @@ public class AppManageController extends BaseController {
|
|
|
* @param appId 应用id
|
|
|
*/
|
|
|
@RequestMapping("/getAgreementUrl")
|
|
|
- public ModelMap getAgreementUrl(String appId) {
|
|
|
+ public ModelMap getAgreementUrl(@RequestParam(defaultValue = "sso") String appId) {
|
|
|
App app = appService.findOne(appId);
|
|
|
- app = StringUtils.isEmpty(app.getUserControl()) ? app : appService.findOne(app.getUserControl());
|
|
|
- return success(app.getPageStyle() == null ? null : app.getPageStyle().getAgreementUrl());
|
|
|
+ String html = null;
|
|
|
+ if (app.getPageStyle() != null) {
|
|
|
+ JSONObject jsonObject = JSON.parseObject(app.getPageStyle().getTerms());
|
|
|
+ if (jsonObject != null) {
|
|
|
+ try {
|
|
|
+ HttpUtil.ResponseWrap res = HttpUtil.doGet(jsonObject.getString("url"));
|
|
|
+ if (res.isSuccess()) {
|
|
|
+ ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ throw new VisibleError(result.getErrMsg());
|
|
|
+ } else {
|
|
|
+ html = (String) result.getContent();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ModelMap data = new ModelMap();
|
|
|
+ data.addAllAttributes(JSON.parseObject(JSON.toJSONString(app.getPageStyle()))).addAttribute("term", html);
|
|
|
+ return success(data);
|
|
|
}
|
|
|
}
|