فهرست منبع

金融申请跳转到金融项目正式网址

scr 8 سال پیش
والد
کامیت
5098509798

+ 78 - 0
src/main/java/com/uas/platform/home/controller/CommonController.java

@@ -0,0 +1,78 @@
+package com.uas.platform.home.controller;
+
+import com.alibaba.fastjson.JSON;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.ui.ModelMap;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * controller基础类
+ * 
+ * @author yingp
+ *
+ */
+public class CommonController {
+
+	protected static final String defultCharset = "UTF-8";
+
+	@Autowired
+	protected HttpServletRequest request;
+
+	@Autowired
+	protected HttpServletResponse response;
+
+	protected static ModelMap success() {
+		return new ModelMap("success", true);
+	}
+
+	protected static ModelMap success(Object data) {
+		return new ModelMap("success", true).addAttribute("content", data);
+	}
+
+	protected static ModelMap error(String errMsg) {
+		return new ModelMap("error", true).addAttribute("errMsg", errMsg);
+	}
+
+	protected static ModelMap error(String errCode, String errMsg) {
+		return new ModelMap("error", true).addAttribute("errCode", errCode).addAttribute("errMsg", errMsg);
+	}
+
+	/**
+	 * 输出json格式
+	 * 
+	 * @param obj
+	 * @throws IOException
+	 */
+	protected void printJson(Object obj) throws IOException {
+		response.setStatus(HttpStatus.FORBIDDEN.value());
+		response.addHeader("Content-Type", "application/json; charset=" + defultCharset);
+		PrintWriter printWriter = response.getWriter();
+		printWriter.append(JSON.toJSONString(obj));
+		printWriter.flush();
+		printWriter.close();
+	}
+
+	/**
+	 * 输出流
+	 * 
+	 * @param fileName
+	 *            文件名
+	 * @param bytes
+	 * @throws IOException
+	 */
+	protected ResponseEntity<byte[]> outputStream(String fileName, byte[] bytes) {
+		HttpHeaders headers = new HttpHeaders();
+		headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
+		headers.setContentDispositionFormData("attachment", fileName);
+		return new ResponseEntity<byte[]>(bytes, headers, HttpStatus.CREATED);
+	}
+
+}

+ 1 - 0
src/main/java/com/uas/platform/home/controller/FinanceController.java

@@ -48,4 +48,5 @@ public class FinanceController {
     }
 
 
+
 }

+ 26 - 0
src/main/java/com/uas/platform/home/controller/SecurityController.java

@@ -0,0 +1,26 @@
+package com.uas.platform.home.controller;
+
+
+import com.uas.platform.home.core.support.SystemSession;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 账号登录配置
+ *
+ * Created by hejq on 2017-11-15.
+ */
+@RequestMapping(value = "/sso")
+@RestController
+public class SecurityController extends CommonController {
+    /**
+     * 账户信息、SSO配置
+     *
+     * @return
+     */
+    @RequestMapping(value = "/account", method = RequestMethod.GET)
+    public ModelMap getAccountInfo() {
+        return success(SystemSession.getUser());
+    }
+
+}

+ 1 - 1
src/main/webapp/WEB-INF/views/normal/finance.html

@@ -331,7 +331,7 @@
                     利率超低,随借随还<br/>
                     不限银行,不限额度
                 </p>
-                <a id="applyLoan">
+                <a onclick="applyLoan()">
                     立即申请
                 </a>
             </div>

+ 18 - 2
src/main/webapp/resources/js/finance/finance.js

@@ -79,7 +79,7 @@ function checkEvent() {
 
 $(function() {
     'use strict';
-
+    //applyLoan:理解立即申请的id
     // 打开申请页面
     $('#applyLoan').click(applyModal1);
 
@@ -91,4 +91,20 @@ $(function() {
 
     // 判断是否已同意
     $("#check2").click(checkEvent);
-});
+});
+function applyLoan() {
+    $.ajax({
+        url:'/sso/account',
+        type:'GET',
+        success:function (data) {
+            if(data.content!=null){
+                window.location.href='http://finance.ubtob.com';
+            }else{
+                toastr.warning('请先登录');
+            }
+        },
+        error:function(){
+            toastr.error('系统错误');
+        }
+    })
+}