Explorar o código

1.bi用户同步uas用户

heqinwei %!s(int64=7) %!d(string=hai) anos
pai
achega
5293cba95f

+ 52 - 52
src/main/java/com/config/exception/GlobalException.java

@@ -1,52 +1,52 @@
-package com.config.exception;
-
-import com.auth0.jwt.exceptions.InvalidClaimException;
-import org.apache.ibatis.binding.BindingException;
-import org.springframework.web.bind.annotation.ControllerAdvice;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import javax.management.OperationsException;
-import java.util.HashMap;
-import java.util.Map;
-
-@ControllerAdvice
-public class GlobalException {
-    @ExceptionHandler(RuntimeException.class)
-    @ResponseBody
-    public Map<String, Object> exceptionHandle(){
-        Map<String, Object> result = new HashMap<String, Object>();
-        result.put("code" , "-502");
-        result.put("msg" , "服务器异常");
-        return result;
-    }
-
-    @ExceptionHandler(OperationsException.class)
-    @ResponseBody
-    public Map<String, Object> operationsException(){
-        Map<String, Object> result = new HashMap<String, Object>();
-        result.put("code" , "-503");
-        result.put("msg", "权限不足");
-        return result;
-    }
-
-
-    @ExceptionHandler(BindingException.class)
-    @ResponseBody
-    public Map<String, Object> BindingException(){
-        Map<String, Object> result = new HashMap<String, Object>();
-        result.put("code" , "-504");
-        result.put("msg" , "数据为空");
-        return result;
-    }
-
-    @ExceptionHandler(InvalidClaimException.class)
-    @ResponseBody
-    public Map<String, Object> InvalidClaimException(){
-        Map<String, Object> result = new HashMap<String, Object>();
-        result.put("code" , "-505");
-        result.put("msg" , "token过期");
-        return result;
-    }
-
-}
+//package com.config.exception;
+//
+//import com.auth0.jwt.exceptions.InvalidClaimException;
+//import org.apache.ibatis.binding.BindingException;
+//import org.springframework.web.bind.annotation.ControllerAdvice;
+//import org.springframework.web.bind.annotation.ExceptionHandler;
+//import org.springframework.web.bind.annotation.ResponseBody;
+//
+//import javax.management.OperationsException;
+//import java.util.HashMap;
+//import java.util.Map;
+//
+//@ControllerAdvice
+//public class GlobalException {
+//    @ExceptionHandler(RuntimeException.class)
+//    @ResponseBody
+//    public Map<String, Object> exceptionHandle(){
+//        Map<String, Object> result = new HashMap<String, Object>();
+//        result.put("code" , "-502");
+//        result.put("msg" , "服务器异常");
+//        return result;
+//    }
+//
+//    @ExceptionHandler(OperationsException.class)
+//    @ResponseBody
+//    public Map<String, Object> operationsException(){
+//        Map<String, Object> result = new HashMap<String, Object>();
+//        result.put("code" , "-503");
+//        result.put("msg", "权限不足");
+//        return result;
+//    }
+//
+//
+//    @ExceptionHandler(BindingException.class)
+//    @ResponseBody
+//    public Map<String, Object> BindingException(){
+//        Map<String, Object> result = new HashMap<String, Object>();
+//        result.put("code" , "-504");
+//        result.put("msg" , "数据为空");
+//        return result;
+//    }
+//
+//    @ExceptionHandler(InvalidClaimException.class)
+//    @ResponseBody
+//    public Map<String, Object> InvalidClaimException(){
+//        Map<String, Object> result = new HashMap<String, Object>();
+//        result.put("code" , "-505");
+//        result.put("msg" , "token过期");
+//        return result;
+//    }
+//
+//}

+ 14 - 2
src/main/java/com/dao/user/UserMapper.java

@@ -23,17 +23,29 @@ public interface UserMapper {
     更新用户数据
      */
     @Update("<script>" +
-            "UPDATE bi_users set" +
+            "UPDATE bi_users set " +
             "USER_NAME = #{userName}" +
             "<if test=\"passWord != null\"> , PASS_WORD = #{passWord} </if>" +
             " <if test=\"name != null\"> , bu_name = #{name} </if>" +
             " <if test=\"post != null\"> , BU_POST = #{post} </if>" +
             " <if test=\"department != null\"> , BU_DEPARTMENT = #{department} </if>" +
             " ,updata_date = to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss')" +
-            "  where bc_id = #{id}" +
+            "  where bu_id = #{id}" +
             " </script>")
     void updateUser(User user);
 
+    /*
+    查询id
+     */
+    @Select("select bu_id as id from bi_users where user_name = #{userName}")
+    int getUserId(String userName);
+
+    /*
+    查询Role
+     */
+    @Select("select bu_role as id from bi_users where bu_id = #{id}")
+    String getRole(int id);
+
     /*
     查询uas用户信息
      */

+ 4 - 0
src/main/java/com/server/user/UserService.java

@@ -68,8 +68,12 @@ public class UserService {
         }else {
             //存在则更新
             userMapper.updateUser(user);
+            int userId = userMapper.getUserId(userName);
+            user.setId(userId);
         }
 
+        user.setRole(userMapper.getRole(user.getId()));
+
         TokenData tokenData = jwtTokenUtil.createToke(user);
         tokenData.setUser(user);
         userMapper.updateToken(tokenData.getToken(),user.getId());

+ 10 - 0
src/main/resources/application-dev.properties

@@ -0,0 +1,10 @@
+profile = dev_envrimont  
+#数据连接池:据说阿里的最好
+spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
+
+#数据库驱动
+spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
+#数据库连接地址
+spring.datasource.url=jdbc:oracle:thin:@192.168.253.6:1521:orcl
+spring.datasource.username=UAS_DEV
+spring.datasource.password=select!#%*(

+ 10 - 0
src/main/resources/application-prod.properties

@@ -0,0 +1,10 @@
+profile = prod_envrimont  
+#数据连接池:据说阿里的最好
+spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
+
+#数据库驱动
+spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
+#数据库连接地址
+spring.datasource.url=jdbc:oracle:thin:@218.18.115.198:1523:orcl
+spring.datasource.username=BI_ADMIN
+spring.datasource.password=admin

+ 6 - 6
src/main/resources/application.properties

@@ -5,14 +5,14 @@ spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
 spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
 #数据库连接地址
 #默认数据源
-#spring.datasource.url=jdbc:oracle:thin:@192.168.253.6:1521:orcl
-#spring.datasource.username=UAS_DEV
-#spring.datasource.password=select!#%*(
+spring.datasource.url=jdbc:oracle:thin:@192.168.253.6:1521:orcl
+spring.datasource.username=UAS_DEV
+spring.datasource.password=select!#%*(
 
 #线上环境
-spring.datasource.url=jdbc:oracle:thin:@218.18.115.198:1523:orcl
-spring.datasource.username=BI_ADMIN
-spring.datasource.password=admin
+#spring.datasource.url=jdbc:oracle:thin:@218.18.115.198:1523:orcl
+#spring.datasource.username=BI_ADMIN
+#spring.datasource.password=admin
 
 
 #slave.datasource.names=UAS,UAS_DEV,YITOA_DATACENTER,N_USOFTSYS