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