Quellcode durchsuchen

授权系统-应用id获取方式统一由客户端id获取,而非应用端传值

ZhangWenQiang vor 5 Jahren
Ursprung
Commit
5a099b9b32

+ 7 - 0
happy-cloud-auth/src/main/java/org/jeecg/modules/api/controller/HlwCompanyController.java

@@ -6,6 +6,8 @@ import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.modules.auth.entity.OauthApplication;
+import org.jeecg.modules.auth.service.AuthService;
 import org.jeecg.modules.feign.client.HlwCompanyServiceClient;
 import org.jeecg.modules.util.CryptTool;
 import org.jeecg.modules.util.SecurityUtils;
@@ -25,6 +27,8 @@ public class HlwCompanyController {
 
     @Autowired
     private HlwCompanyServiceClient hlwCompanyServiceClient;
+    @Autowired
+    private AuthService authService;
 
     /**
      * @return
@@ -50,6 +54,9 @@ public class HlwCompanyController {
         //数据解密
         json = CryptTool.decode(json);
         JSONObject jsonObject = JSONObject.parseObject(json);
+        //获取应用信息
+        OauthApplication oauthApplication = authService.getApplication(SecurityUtils.getClient());
+        jsonObject.put("applicationId", oauthApplication.getApplicationId());
         Result<?> result = hlwCompanyServiceClient.saveCompany(jsonObject);
         return result;
     }

+ 25 - 0
happy-cloud-auth/src/main/java/org/jeecg/modules/auth/entity/OauthApplication.java

@@ -0,0 +1,25 @@
+package org.jeecg.modules.auth.entity;
+
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * @author zwq
+ * @date 2020-05-22
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@Builder
+public class OauthApplication implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 应用id
+     */
+    private Integer applicationId;
+
+}

+ 15 - 0
happy-cloud-auth/src/main/java/org/jeecg/modules/auth/mapper/AuthMapper.java

@@ -0,0 +1,15 @@
+package org.jeecg.modules.auth.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.auth.entity.OauthApplication;
+
+/**
+ * @Author: zwq
+ * @Date: Create in 2020/6/9 9:36
+ * @Description:
+ */
+public interface AuthMapper extends BaseMapper<OauthApplication> {
+
+    OauthApplication getApplication(@Param("clientId") String clientId);
+}

+ 16 - 0
happy-cloud-auth/src/main/java/org/jeecg/modules/auth/mapper/xml/AuthMapper.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.auth.mapper.AuthMapper">
+
+    <!-- 根据用户名查询 -->
+    <select id="getApplication" resultType="org.jeecg.modules.auth.entity.OauthApplication">
+		select
+		a.id
+		from
+		hlw_application_setting a
+		where
+		a.appid = #{clientId}
+	</select>
+
+
+</mapper>

+ 20 - 0
happy-cloud-auth/src/main/java/org/jeecg/modules/auth/service/AuthService.java

@@ -0,0 +1,20 @@
+package org.jeecg.modules.auth.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.auth.entity.OauthApplication;
+
+/**
+ * @Author: zwq
+ * @Date: Create in 2020/6/9 9:46
+ * @Description:
+ */
+public interface AuthService extends IService<OauthApplication> {
+
+    /**
+     * 通过客户端id获取应用信息
+     *
+     * @param clientId
+     * @return
+     */
+    OauthApplication getApplication(String clientId);
+}

+ 22 - 0
happy-cloud-auth/src/main/java/org/jeecg/modules/auth/service/impl/AuthServiceImpl.java

@@ -0,0 +1,22 @@
+package org.jeecg.modules.auth.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.auth.entity.OauthApplication;
+import org.jeecg.modules.auth.mapper.AuthMapper;
+import org.jeecg.modules.auth.service.AuthService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Author: zwq
+ * @Date: Create in 2020/6/9 9:47
+ * @Description:
+ */
+@Service
+public class AuthServiceImpl extends ServiceImpl<AuthMapper, OauthApplication> implements AuthService {
+
+    @Override
+    public OauthApplication getApplication(String clientId) {
+        OauthApplication oauthApplication = baseMapper.getApplication(clientId);
+        return oauthApplication;
+    }
+}

+ 1 - 1
happy-cloud-wisdom/happy-cloud-wisdom-biz/src/main/java/org/jeecg/modules/hlwapplication/entity/HlwApplicationSetting.java

@@ -41,7 +41,7 @@ public class HlwApplicationSetting implements Serializable {
      */
     @TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "主键")
-    private java.lang.String id;
+    private java.lang.Integer id;
     /**
      * 应用名称
      */