소스 검색

Merge branch 'master' of http://47.92.109.230:8080/lu914596513/oa_center

dongql 7 년 전
부모
커밋
d599d8bed7

+ 8 - 4
oa_service/src/main/java/com/bjlt/spider/user/controller/SystemUserController.java

@@ -23,7 +23,7 @@ public class SystemUserController {
     private UserService userService;
 
     @Autowired
-    private RedisTemplate<String,String> redisTemplate;
+    private RedisTemplate<String, String> redisTemplate;
 
     //注册
     @PostMapping("/register")
@@ -59,16 +59,20 @@ public class SystemUserController {
         //开始登录
         List<User> users = userService.listUser(User.builder().nickname(uname).pswd(passWord).build());
 
-        if (users.size() == 0){
+        if (users.size() == 0) {
             return RespEntity.error("登陆失败");
         }
 
         String token = UUIDUtils.getUUID();
 
-        redisTemplate.opsForValue().set(uname,token,3, TimeUnit.HOURS);
+        redisTemplate.opsForValue().set(uname, token, 3, TimeUnit.HOURS);
 
+        User user = users.get(0);
 
-        return RespEntity.success(token);
+        user.setToken(token);
+
+
+        return RespEntity.success(user);
     }
 
 

+ 7 - 4
oa_service/src/main/java/com/bjlt/spider/user/dao/impl/UserDaoImpl.java

@@ -22,7 +22,7 @@ public class UserDaoImpl implements UserDao {
     @Override
     public List<User> listPageUUser(User uUser) {
         StringBuffer s = new StringBuffer();
-        String select = "select id, nickname, phone, pswd, create_time, last_login_time, status,rules  from u_user ";
+        String select = "select id, nickname, phone, pswd, create_time, last_login_time, status, permission, rules  from u_user ";
         s.append(select);
         Map<String, Object> m = map(uUser);
         String where = "where 1=1 " + m.keySet().stream().map(t -> " and " + t + "=?").collect(Collectors.joining(" "));
@@ -72,7 +72,7 @@ public class UserDaoImpl implements UserDao {
     @Override
     public List<User> listUUser(User uUser) {
         StringBuffer s = new StringBuffer();
-        String select = "select id, nickname, phone, pswd, create_time, last_login_time, status from u_user ";
+        String select = "select id, nickname, permission, rules ,phone, pswd, create_time, last_login_time, status from u_user ";
         s.append(select);
         Map<String, Object> m = map(uUser);
         String where = "where 1=1 " + m.keySet().stream().map(t -> " and " + t + "=?").collect(Collectors.joining(" "));
@@ -118,8 +118,11 @@ public class UserDaoImpl implements UserDao {
         if (uUser.getStatus() != null) {
             map.put("status", uUser.getStatus());
         }
-        if (uUser.getRules() != null){
-            map.put("rules",uUser.getRules());
+        if (uUser.getRulesIds() != null){
+            map.put("rules",uUser.getRulesIds());
+        }
+        if (uUser.getPermissionIds() != null){
+            map.put("permission",uUser.getPermissionIds());
         }
 
         return map;

+ 14 - 1
oa_service/src/main/java/com/bjlt/spider/user/entity/User.java

@@ -1,5 +1,6 @@
 package com.bjlt.spider.user.entity;
 import com.bjlt.spider.entity.Page;
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
@@ -34,6 +35,7 @@ public class User extends Page {
 	/**
 	   密码
 	 */
+	@JsonIgnore
 	private String pswd;
 	
 	/**
@@ -54,6 +56,17 @@ public class User extends Page {
 	/**
 	 * 简化开发 角色列表
 	 */
-	private String rules;
+	private String rulesIds;
+
+	/**
+	 * 简化开发 角色列表
+	 */
+	private String permissionIds;
+
+	/**
+	 * 登录返回的token
+	 */
+	private String token;
+
 
 }

+ 1 - 1
oa_service/src/main/java/com/bjlt/spider/user/service/RoleService.java

@@ -51,5 +51,5 @@ public interface RoleService {
      * @param targetName
      * @return
      */
-    RespEntity roles(User user, String rolesId , String targetName);
+    RespEntity roles(User user, String rolesId , String targetName,String permission);
 }

+ 15 - 6
oa_service/src/main/java/com/bjlt/spider/user/service/impl/RoleServiceImpl.java

@@ -55,21 +55,30 @@ public class RoleServiceImpl implements RoleService {
     }
 
     @Override
-    public RespEntity roles(User user, String rolesId, String sourceName) {
+    public RespEntity roles(User user, String rolesId, String sourceName,String permission) {
 
 
         //找到这个用户之前的角色
-        String rules = user.getRules();
-        StringBuffer sb = new StringBuffer(rules);
-        sb.append("|" + rolesId);
+        String rules = user.getRulesIds();
+        StringBuffer sbR = new StringBuffer(rules);
+        sbR.append("|" + rolesId);
 
         //把角色加到这个用户后面
-        user.setRules(sb.toString());
+        user.setRulesIds(sbR.toString());
+        StringBuffer sbP = new StringBuffer(rules);
+
+        sbP.append("|" + permission);
+
+        //把角色加到这个用户后面
+        user.setPermissionIds(sbR.toString());
+
 
         userDao.insertSelective(user);
 
         //插入日志
-        OaRulesLog oaRulesLog = OaRulesLog.builder().sourceUser(sourceName).targetUser(user.getNickname()).action(rolesId).build();
+        OaRulesLog oaRulesLog = OaRulesLog.builder().sourceUser(sourceName).targetUser(user.getNickname()).action("roles:"+rolesId+"permission:"+permission).build();
+
+        oaRulesLogDao.insertSelective(oaRulesLog);
 
         return RespEntity.success("角色赋值成功");
     }