Parcourir la source

Merge branch 'feture-cityLogin-wangmh' into feature-mallRegister-wangmh

wangmh il y a 7 ans
Parent
commit
9473ebb232

+ 42 - 5
sso-server/src/main/java/com/uas/sso/controller/AppManageController.java

@@ -1,20 +1,57 @@
 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 org.springframework.stereotype.Controller;
+import com.uas.sso.exception.VisibleError;
+import com.uas.sso.service.AppService;
+import org.springframework.ui.ModelMap;
+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;
 
 /**
  * Created by uas on 2018/1/5.
  */
-@Controller
+@RestController
+@RequestMapping("/api/app")
 public class AppManageController extends BaseController {
 
+    @Autowired
+    private AppService appService;
+
     /**
      * 保存应用信息
      *
-     * @param app
+     * @param appId 应用id
      */
-    public void save(App app) {
-
+    @RequestMapping("/getAgreementUrl")
+    public ModelMap getAgreementUrl(@RequestParam(defaultValue = "sso") String appId) {
+        App app = appService.findOne(appId);
+        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);
     }
 }

+ 17 - 2
sso-server/src/main/java/com/uas/sso/entity/PageStyle.java

@@ -108,12 +108,18 @@ public class PageStyle implements Serializable {
     private String terms;
 
     /**
-     * 登录返回首页(json字符串,name为链接名称,url为返回链接)
-     * eg:{"name": "优软云首页", "url": "https://www.ubtob.com/"}
+     * 登录返回首页(json字符串,name为链接名称,url为返回链接, needHelp为是否需要帮助按钮
+     * eg:{"name": "优软云首页", "url": "https://www.ubtob.com/", "needHelp": true}
      */
     @Column(name = "return_home_url")
     private String returnHomeUrl;
 
+    /**
+     * 是否需要记住密码功能
+     */
+    @Column(name = "need_remember_password")
+    private Boolean needRememberPwd;
+
     public String getAppId() {
         return appId;
     }
@@ -235,4 +241,13 @@ public class PageStyle implements Serializable {
     public void setReturnHomeUrl(String returnHomeUrl) {
         this.returnHomeUrl = returnHomeUrl;
     }
+
+    public Boolean getNeedRememberPwd() {
+        return needRememberPwd;
+    }
+
+    public void setNeedRememberPwd(Boolean needRememberPwd) {
+        this.needRememberPwd = needRememberPwd;
+    }
+
 }