Просмотр исходного кода

获取产城注册条款接口

wangmh 7 лет назад
Родитель
Сommit
1141aa8dfa

+ 29 - 4
sso-server/src/main/java/com/uas/sso/controller/AppManageController.java

@@ -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);
     }
 }

+ 0 - 14
sso-server/src/main/java/com/uas/sso/entity/PageStyle.java

@@ -120,13 +120,6 @@ public class PageStyle implements Serializable {
     @Column(name = "need_remember_password")
     private Boolean needRememberPwd;
 
-    /**
-     * 注册条款地址(json字符串,name为条款名称,url为条款链接)
-     * eg:{"name": "优软云平台服务条款", "url": "/common/agreement"}
-     */
-    @Column(name = "agreement_url")
-    private String agreementUrl;
-
     public String getAppId() {
         return appId;
     }
@@ -257,11 +250,4 @@ public class PageStyle implements Serializable {
         this.needRememberPwd = needRememberPwd;
     }
 
-    public String getAgreementUrl() {
-        return agreementUrl;
-    }
-
-    public void setAgreementUrl(String agreementUrl) {
-        this.agreementUrl = agreementUrl;
-    }
 }