taizhimin 5 years ago
parent
commit
85815e8a8a

+ 0 - 1
sys/src/main/java/com/rxida/xilinedu/sys/common/ShiroConfiguration.java

@@ -21,7 +21,6 @@ public class ShiroConfiguration {
         ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
         shiroFilterFactoryBean.setSecurityManager(securityManager);
         Map<String, String> map = new HashMap<String, String>();
-        map.put("jwt", new JWTFilter());
         //登出
         map.put("/logout", "logout");
         //对所有用户认证

+ 0 - 4
sys/src/main/java/com/rxida/xilinedu/sys/common/SystemAuthorizingRealm.java

@@ -61,10 +61,6 @@ public class SystemAuthorizingRealm extends AuthorizingRealm {
             //这里返回后会报出对应异常
             return null;
         } else {
-            final JWTToken authenticationToken1 = (JWTToken) authenticationToken;
-            if (user.getUsername() == null || !JWTUtil.verify(authenticationToken1, user.getUsername())) {
-                throw new AuthenticationException("token认证失败!");
-            }
             byte[] salt = Encodes.decodeHex(user.getPassword().substring(0, 16));
             return new SimpleAuthenticationInfo(
                     user,

+ 24 - 1
sys/src/main/java/com/rxida/xilinedu/sys/entity/Menu.java

@@ -1,10 +1,12 @@
 package com.rxida.xilinedu.sys.entity;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 
-public class Menu extends BaseEntity{
+public class Menu extends BaseEntity {
     private String id;
     private String parentId;
     private String name;
@@ -96,4 +98,25 @@ public class Menu extends BaseEntity{
     public Menu getChild(List<Menu> menuList) {
         return getChild(this, menuList);
     }
+
+    @JsonIgnore
+    public static void sortList(List<Menu> list, List<Menu> sourcelist, String parentId, boolean cascade) {
+        for (int i = 0; i < sourcelist.size(); i++) {
+            Menu e = sourcelist.get(i);
+            if (e.getParentId() != null && e.getParentId().equals(parentId)) {
+                list.add(e);
+                if (cascade) {
+                    // 判断是否还有子节点, 有则继续获取子节点
+                    for (int j = 0; j < sourcelist.size(); j++) {
+                        Menu child = sourcelist.get(j);
+                        if (child.getParentId() != null && child.getParentId() != null
+                                && child.getParentId().equals(e.getId())) {
+                            sortList(list, sourcelist, e.getId(), true);
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+    }
 }

+ 9 - 0
sys/src/main/java/com/rxida/xilinedu/sys/entity/User.java

@@ -12,6 +12,15 @@ public class User extends BaseEntity {
     private String phone;
     private List<Role> roles;
 
+    public User(String id) {
+        super();
+        this.id = id;
+    }
+
+    public User() {
+        super();
+    }
+
     public String getId() {
         return id;
     }

+ 3 - 3
sys/src/main/java/com/rxida/xilinedu/sys/service/MenuService.java

@@ -8,11 +8,11 @@ import javax.annotation.Resource;
 import java.util.List;
 
 @Service
-public class MenuService {
+public class MenuService extends BaseService<MenuDao, Menu> {
     @Resource
-    private MenuDao dao;
+    private MenuDao menuDao;
 
     public List<Menu> findAllList() {
-        return dao.findList(new Menu());
+        return menuDao.findList(new Menu());
     }
 }

+ 11 - 4
sys/src/main/java/com/rxida/xilinedu/sys/web/LoginController.java

@@ -49,7 +49,9 @@ public class LoginController {
             result.setCode(JsonResult.ERROE);
             result.setMsg("账号或密码错误");
         }
-
+        resultData.put("token", "admin");
+        result.setMsg("success!!!");
+        result.setCode(JsonResult.SUCCESS);
         return result;
     }
 
@@ -59,9 +61,14 @@ public class LoginController {
     }
 
     //登出
-    @RequestMapping(value = "/logout")
-    public String logout() {
-        return "logout";
+    @PostMapping(value = "/logout")
+    public JsonResult logout() {
+        Subject subject = SecurityUtils.getSubject();
+        subject.logout();
+        JsonResult jsonResult = new JsonResult();
+        jsonResult.setMsg("success!!!");
+        jsonResult.setCode(JsonResult.SUCCESS);
+        return jsonResult;
     }
 
     //错误页面展示

+ 19 - 2
sys/src/main/java/com/rxida/xilinedu/sys/web/MenuController.java

@@ -1,6 +1,8 @@
 package com.rxida.xilinedu.sys.web;
 
+import com.rxida.xilinedu.sys.common.JsonResult;
 import com.rxida.xilinedu.sys.entity.Menu;
+import com.rxida.xilinedu.sys.entity.User;
 import com.rxida.xilinedu.sys.service.MenuService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.CrossOrigin;
@@ -8,7 +10,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @RestController
 @CrossOrigin
@@ -26,8 +31,20 @@ public class MenuController {
     }
 
     @RequestMapping("/list")
-    public List<Menu> list() {
-        return menuService.findAllList();
+    public JsonResult list() {
+        List<Menu> allList = menuService.findAllList();
+        JsonResult result = new JsonResult();
+        result.setMsg("success");
+        result.setCode(JsonResult.SUCCESS);
+        Map<String, Object> data = new HashMap<>();
+        List<Menu> l = new ArrayList<>();
+        Menu.sortList(l, allList, "1", true);
+        Menu m = new Menu();
+        m.setId("1");
+        data.put("items", Menu.getChild(m, allList).getItems());
+        data.put("total", l.size());
+        result.setData(data);
+        return result;
     }
 
     @RequestMapping("/save")

+ 31 - 3
sys/src/main/java/com/rxida/xilinedu/sys/web/UserController.java

@@ -9,7 +9,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping("/user")
@@ -24,8 +27,19 @@ public class UserController {
     }
 
     @PostMapping("/list")
-    public List<User> findList(User user) {
-        return userService.findList(user);
+    public JsonResult findList(User user) {
+        JsonResult result = new JsonResult();
+        result.setMsg("success");
+        result.setCode(JsonResult.SUCCESS);
+        User u = userService.get(new User("1"));
+
+        Map<String, Object> data = new HashMap<>();
+        List<User> l = new ArrayList<>();
+        l.add(u);
+        data.put("items", l);
+        data.put("total", 1);
+        result.setData(data);
+        return result;
     }
 
     @PostMapping("/save")
@@ -41,11 +55,25 @@ public class UserController {
         User user = (User) subject.getPrincipal();
         JsonResult result = new JsonResult();
         result.setData(user);
+
+        User u = userService.get(new User("1"));
+        result.setData(u);
+        result.setCode(JsonResult.SUCCESS);
+        result.setMsg("success");
+        return result;
+    }
+    @GetMapping("/info")
+    public JsonResult info(String token) {
+        Subject subject = SecurityUtils.getSubject();
+        User user = (User) subject.getPrincipal();
+        JsonResult result = new JsonResult();
+        result.setData(user);
+        User u = userService.get(new User("1"));
+        result.setData(u);
         result.setCode(JsonResult.SUCCESS);
         result.setMsg("success");
         return result;
     }
-
     @RequestMapping("/infoById")
     public User infoById(User user) {
         return userService.get(user);

+ 1 - 1
sys/src/main/resources/mapper/sys/UserDao.xml

@@ -55,7 +55,7 @@
         LEFT JOIN sys_menu  sm ON sm.id = srm.menu_id
         WHERE a.id = #{id}
     </select>
-    <select id="findList" parameterType="java.lang.String" resultMap="userResult">
+    <select id="findList"  resultMap="userResult">
         select
           a.id AS "id",
           a.name AS "name",