xiaoqiao 1 rok pred
rodič
commit
c7a156ac62

+ 0 - 7
src/main/java/com/bowintek/practice/AppConfig.java

@@ -60,17 +60,10 @@ public class AppConfig {
 
     @Value("${appconfig.oauthconfig.oauthUrl}")
     public String oauthconfig_oauthUrl;
-    @Value("${appconfig.oauthconfig.webServiceUrl}")
-    public String oauthconfig_webServiceUrl;
-    @Value("${appconfig.oauthconfig.mobileServiceUrl}")
-    public String oauthconfig_mobileServiceUrl;
-    @Value("${appconfig.oauthconfig.client_id}")
     public String oauthconfig_client_id;
     @Value("${appconfig.oauthconfig.client_secret}")
     public String oauthconfig_client_secret;
 
-
-
     /**
      * @Description //TODO 静态文件路径
      * @Date 10:17 2019/10/9

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 12 - 23
src/main/java/com/bowintek/practice/controller/AccountController.java


+ 4 - 4
src/main/java/com/bowintek/practice/controller/AppController.java

@@ -36,7 +36,7 @@ public class AppController {
     @Autowired
     private DesUtils desUtils;
 
-    @GetMapping("")
+  /*  @GetMapping("")
     public String web(HttpServletRequest request, HttpServletResponse response, String ticket,String loginType) {
         if (!stringUtils.IsNullOrEmpty(ticket))
             return "redirect:/web/index.html?ticket=" + encoderTicket(ticket,appConfig.oauthconfig_webServiceUrl);
@@ -45,9 +45,9 @@ public class AppController {
             return "redirect:/web/index.html?loginType=" + loginType;
 
         return "redirect:/web/index.html";
-    }
+    }*/
 
-    @GetMapping("web")
+   /* @GetMapping("web")
     public String web(String ticket,String loginType) {
         if (!stringUtils.IsNullOrEmpty(ticket))
             return "redirect:/web/index.html?ticket=" + encoderTicket(ticket,appConfig.oauthconfig_webServiceUrl);
@@ -67,7 +67,7 @@ public class AppController {
             return "redirect:/mobile/index.html?loginType=" + loginType;
 
         return "redirect:/mobile/index.html";
-    }
+    }*/
 
     //解析单点登录返回的ticket获取用户帐号
     private String encoderTicket(String ticket,String serviceUrl) {

+ 19 - 48
src/main/java/com/bowintek/practice/controller/OAuthController.java

@@ -2,6 +2,7 @@ package com.bowintek.practice.controller;
 
 import com.alibaba.druid.support.logging.Log;
 import com.alibaba.druid.support.logging.LogFactory;
+import com.alibaba.fastjson.JSONObject;
 import com.bowintek.practice.AppConfig;
 import com.bowintek.practice.filter.exception.*;
 import com.bowintek.practice.model.SysUser;
@@ -21,6 +22,7 @@ import java.net.URLDecoder;
 import java.net.URLEncoder;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
@@ -54,7 +56,7 @@ public class OAuthController {
     @GetMapping("/getOAuthUrl")
     public BaseResponse<String> getOAuthUrl(String appType, String oauthType) {
         String url = "";
-        String serviceUrl = "web".equals(appType) ? appConfig.oauthconfig_webServiceUrl : appConfig.oauthconfig_mobileServiceUrl;
+      /*  String serviceUrl = "web".equals(appType) ? appConfig.oauthconfig_webServiceUrl : appConfig.oauthconfig_mobileServiceUrl;
         if ("oauth".equals(oauthType)) {
             url = appConfig.oauthconfig_oauthUrl + "/auth/oauth/authorize?";
             url += "response_type=code";
@@ -72,7 +74,7 @@ public class OAuthController {
                 url += "service=" + serviceUrl;
 
             log.info("getOAuthUrl-cas:" + "appType:" + appType + ",url:" + url);
-        }
+        }*/
 
 
         return RespGenerstor.success(url);
@@ -102,60 +104,29 @@ public class OAuthController {
     }
 
     @GetMapping("/oauthLogin")
-    public BaseResponse<String> oauthLogin(String appType, String type, String token, String ticket, String tm) {
-        log.info("oauthLogin:ticket   " + ticket + "  ,  tm  " + tm + "  ,  appType  " + appType+ "  ,  type  " + type);
+    public BaseResponse<String> oauthLogin(String type, String token, String tm) {
+        log.info("oauthLogin:ticket    ,  tm  " + tm + "  ,   type  " + type);
 
         String userCode = "";
-        String serviceUrl = "web".equals(appType) ? appConfig.oauthconfig_webServiceUrl : appConfig.oauthconfig_mobileServiceUrl;
-
-        if (!stringUtils.IsNullOrEmpty(tm)) {
-            ticket = URLDecoder.decode(ticket);
-            tm = URLDecoder.decode(tm);
-            if (stringUtils.IsNullOrEmpty(ticket))
-                return RespGenerstor.success(false);
-
-            LocalDateTime expireDate = dateUtils.DateToDateTime(dateUtils.StrToDate(tm, "yyyy/MM/dd HH:mm:ss"));
-            if (LocalDateTime.now().compareTo(expireDate) > 0)
-                return RespGenerstor.success(false);
-
-            userCode = desUtils.decoder(ticket, expireDate);
-        } else {
-            if ("oauth".equals(type)) {
-                String reData;
-                Map<String, String> getParams = new HashMap<>();
-                getParams.put("access_token", token);
-
-                log.info("getUserInfo-oauth:access_token   " + token);
 
-                reData = remoteHelper.getJson(getParams, appConfig.oauthconfig_oauthUrl + "/user/get_user_info", "UTF-8");
-
-                log.info("getUserInfo-oauth:result   " + reData);
-
-                JsonNode result = jsonMapper.jsonToObject(reData, JsonNode.class);
-
-                if (result != null && result.get("code") != null && "1".equals(result.get("code").toString()) && result.get("data") != null) {
-                    userCode = result.get("data").get("user_code") != null ? result.get("data").get("user_code").toString() : "";
-                }
+        String reData;
+        Map<String, String> getParams = new HashMap<>();
+        getParams.put("Authorization", "Bearer ${token}");
 
-            } else {
-                String reData;
-                Map<String, String> getParams = new HashMap<>();
-                getParams.put("service", serviceUrl);
-                getParams.put("ticket", ticket);
 
-                log.info("getUserInfo-cas:ticket   " + ticket);
+        reData = remoteHelper.getJson( new HashMap<>(), appConfig.oauthconfig_oauthUrl + "/api/account/testpost", "UTF-8", getParams);
 
-                reData = remoteHelper.getJson(getParams, appConfig.oauthconfig_oauthUrl + "/auth/cas/p3/serviceValidate", "UTF-8");
+        log.info("getUserInfo-cas:result   " + reData);
 
-                log.info("getUserInfo-cas:result   " + reData);
+        JSONObject jsonData = JSONObject.parseObject(reData);
 
-                if (reData.indexOf("cas:authenticationSuccess") >= 0 && reData.indexOf("cas:user_code") >= 0) {
-                    userCode = reData.split("<cas:user_code>")[1].split("</cas:user_code>")[0];
-                }
-            }
+        if (!"success".equals(jsonData.getString("code"))) {
+            log.info("登录失败:" + jsonData.getString("msg"));
+            return RespGenerstor.success(false);
         }
+        userCode = jsonData.getJSONObject("data").getString("id");
 
-        log.info("oauthLogin:ticket   " + ticket + "  ,  userCode  " + userCode);
+        log.info("oauthLogin:token   " + token + "  ,  userCode  " + userCode);
 
         if (stringUtils.IsNullOrEmpty(userCode))
             return RespGenerstor.success(false);
@@ -167,10 +138,10 @@ public class OAuthController {
 
         UserModel user = accountService.getUserByUserID(userID);
         user.token = TokenUtils.sign(user.getUserId() + '|' + user.getUserTypeId());
-        user.dataRangeList = userService.getUserDataRange(user.getUserId());
+        user.dataRangeList =new ArrayList<>();
         user.permissionList = accountService.getUserPerms(user.getUserId());
 
-        logService.save("登录","","单点登录",user.userId);
+        logService.save("登录", "", "单点登录", user.userId);
 
         return RespGenerstor.success(user);
 

+ 1 - 3
src/main/resources/application.yml

@@ -132,9 +132,7 @@ appconfig:
           url: jdbc:oracle:thin:@//183.56.239.71:1521/edu_gdyfvccm
           driver-class-name: oracle.jdbc.OracleDriver
   oauthconfig:
-    oauthUrl: http://open.mh.gdyfvccm.edu.cn:8008
-    webServiceUrl: https://practice.gdyfvccm.edu.cn:8001/web/index.html#/login
-    mobileServiceUrl: https://practice.gdyfvccm.edu.cn:8001/mobile
+    oauthUrl: http://localhost:8077/
     client_id: 2d4a5b3c-dc6c-4231-914c-ca1a4d3a134b
     client_secret: e2afdc026c4e745714d2f3b2a2e393686c11f66f
 

+ 1 - 3
target/classes/application.yml

@@ -132,9 +132,7 @@ appconfig:
           url: jdbc:oracle:thin:@//183.56.239.71:1521/edu_gdyfvccm
           driver-class-name: oracle.jdbc.OracleDriver
   oauthconfig:
-    oauthUrl: http://open.mh.gdyfvccm.edu.cn:8008
-    webServiceUrl: https://practice.gdyfvccm.edu.cn:8001/web/index.html#/login
-    mobileServiceUrl: https://practice.gdyfvccm.edu.cn:8001/mobile
+    oauthUrl: http://localhost:8077/
     client_id: 2d4a5b3c-dc6c-4231-914c-ca1a4d3a134b
     client_secret: e2afdc026c4e745714d2f3b2a2e393686c11f66f
 

BIN
target/classes/com/bowintek/practice/AppConfig.class


BIN
target/classes/com/bowintek/practice/controller/AccountController.class


BIN
target/classes/com/bowintek/practice/controller/AppController.class


BIN
target/classes/com/bowintek/practice/controller/OAuthController.class


+ 2 - 1
vue/public/appconfig.json

@@ -1,3 +1,4 @@
 {
-  "isDev": true
+  "isDev": false,
+  "SSOLoginUrl": "http://www.baidu.com"
 }

+ 7 - 7
vue/src/App.vue

@@ -36,16 +36,16 @@ watchEffect(() => {
 const oauthLogin = function () {
   getConfig().then((res: any) => {
     if (!res.isDev && token.value == null) {
-      const ticket = getUrlParams()["ticket"];
-      const tm = getUrlParams()["tm"];
+      const token = getUrlParams()["token"];
 
-      if (!ticket) {
-        getOAuthUrl("cas").then(res => {
+      if (!token) {
+        window.location.href = res.SSOLoginUrl;
+        /*getOAuthUrl("cas").then(res => {
           if (res)
-            window.location.href = res;
-        });
+            window.location.href = res.SSOLoginUrl;
+        });*/
       } else {
-        userStore.oauthLogin("cas", ticket, tm).then(data => {
+        userStore.oauthLogin("cas", token, "").then(data => {
           loading.value = false;
           setTimeout(() => router.replace((route.query.redirect as string) ?? '/'));
         }, () => {

+ 13 - 12
vue/src/utils/config.ts

@@ -1,19 +1,20 @@
-import axios  from 'axios';
+import axios from 'axios';
+
 const service = axios.create({
-    timeout: 6000,
+  timeout: 6000,
 });
 
-export interface ConfigParams  {
-    isDev: boolean;
+export interface ConfigParams {
+  isDev: boolean;
+  SSOLoginUrl: string;
 }
 
-export const getConfig = async <ConfigParams>(
-): Promise<ConfigParams> => {
-    try {
-        const res = await service.request({url: 'appconfig.json'});
+export const getConfig = async <ConfigParams>(): Promise<ConfigParams> => {
+  try {
+    const res = await service.request({url: 'appconfig.json'});
 
-        return res.data as ConfigParams;
-    } catch (error: any) {
-        return Promise.reject(null);
-    }
+    return res.data as ConfigParams;
+  } catch (error: any) {
+    return Promise.reject(null);
+  }
 };

+ 23 - 10
vue/src/views/subject/detail.vue

@@ -2,12 +2,22 @@
   <div class="card-edit">
     <a-divider orientation="left">主题定义</a-divider>
     <a-descriptions title="" bordered>
-      <a-descriptions-item   :labelStyle="{'width':'12%'}" :contentStyle="{'width':'21%'}"  label="主题名称"> {{ dataModel.subjectName }}</a-descriptions-item>
-      <a-descriptions-item  :labelStyle="{'width':'12%'}" :contentStyle="{'width':'21%'}"  label="表编码"> {{ dataModel.tabCode }}</a-descriptions-item>
-      <a-descriptions-item  :labelStyle="{'width':'12%'}" :contentStyle="{'width':'21%'}"  label="表名称"> {{ dataModel.tabName }}</a-descriptions-item>
-      <a-descriptions-item   :labelStyle="{'width':'12%'}" :contentStyle="{'width':'21%'}"  label="描述"> {{ dataModel.tabDesc }}</a-descriptions-item>
-      <a-descriptions-item  :labelStyle="{'width':'12%'}" :contentStyle="{'width':'21%'}"  label="是否有外键字段"> {{ dataModel.isReferences==1?"是":"否" }}</a-descriptions-item>
-     </a-descriptions>
+      <a-descriptions-item :labelStyle="{'width':'12%'}" :contentStyle="{'width':'21%'}" label="主题名称">
+        {{ dataModel.subjectName }}
+      </a-descriptions-item>
+      <a-descriptions-item :labelStyle="{'width':'12%'}" :contentStyle="{'width':'21%'}" label="表编码">
+        {{ dataModel.tabCode }}
+      </a-descriptions-item>
+      <a-descriptions-item :labelStyle="{'width':'12%'}" :contentStyle="{'width':'21%'}" label="表名称">
+        {{ dataModel.tabName }}
+      </a-descriptions-item>
+      <a-descriptions-item :labelStyle="{'width':'12%'}" :contentStyle="{'width':'21%'}" label="描述">
+        {{ dataModel.tabDesc }}
+      </a-descriptions-item>
+      <a-descriptions-item :labelStyle="{'width':'12%'}" :contentStyle="{'width':'21%'}" label="是否有外键字段">
+        {{ dataModel.isReferences == 1 ? "是" : "否" }}
+      </a-descriptions-item>
+    </a-descriptions>
     <a-divider orientation="left">字段定义</a-divider>
     <a-table :columns="columns" :data-source="fieldData" :scroll="{ x:'100%', y: 500 }" :pagination="false"
              bordered>
@@ -27,8 +37,8 @@
     </a-form-item>
   </div>
 </template>
-<script  lang="ts">
-import { ref,defineComponent} from 'vue';
+<script lang="ts">
+import {ref, defineComponent} from 'vue';
 import {get} from "@/api/common";
 import {useTabsViewStore} from "@/store/modules/tabsView";
 import dayjs from "dayjs";
@@ -105,6 +115,9 @@ export default defineComponent({
       {title: '外键表显示列', dataIndex: 'displayColumn', key: 'displayColumn', align: "center"},
     ];
     const loadData = async (id) => {
+      if (id == undefined) {
+        return;
+      }
       get('subject/getSubject',
         {subjectId: id}).then(data => {
         dataModel.value = data;
@@ -120,8 +133,8 @@ export default defineComponent({
     };
 
     return {
-      loadData,columns,fieldData,sql,
-      onClose,solarizedLight,
+      loadData, columns, fieldData, sql,
+      onClose, solarizedLight,
       dataModel,
       dayjs
     };