Browse Source

账户验证由资源点改为用户

sunyj 8 years ago
parent
commit
f1600244e7

+ 0 - 86
kanban-auth/src/main/java/com/uas/kanban/controller/ResourcePointController.java

@@ -1,19 +1,10 @@
 package com.uas.kanban.controller;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
 
-import com.uas.kanban.annotation.NotEmpty;
 import com.uas.kanban.base.BaseController;
-import com.uas.kanban.exception.OperationException;
 import com.uas.kanban.model.ResourcePoint;
-import com.uas.kanban.service.ResourcePointService;
-import com.uas.kanban.support.SessionHelper;
 
 /**
  * 用户
@@ -25,81 +16,4 @@ import com.uas.kanban.support.SessionHelper;
 @RequestMapping("/resourcePoint")
 public class ResourcePointController extends BaseController<ResourcePoint> {
 
-	@Autowired
-	private ResourcePointService resourcePointService;
-
-	@Autowired
-	private SessionHelper sessionHelper;
-
-	/**
-	 * 登陆
-	 * 
-	 * @param name
-	 *            名称
-	 * @param password
-	 *            密码
-	 * @param request
-	 * @return 是否成功登陆
-	 */
-	@RequestMapping("/login")
-	@ResponseBody
-	public boolean login(@NotEmpty("name") String name, @NotEmpty("password") String password,
-			HttpServletRequest request) {
-		ResourcePoint resourcePoint = resourcePointService.login(name, password);
-		if (resourcePoint != null) {
-			sessionHelper.saveSession(request, resourcePoint);
-			return true;
-		}
-		return false;
-	}
-
-	/**
-	 * 退出 登陆
-	 * 
-	 * @param request
-	 * @return 是否成功登陆
-	 * @throws OperationException
-	 */
-	@RequestMapping("/logout")
-	@ResponseBody
-	public boolean logout(HttpServletRequest request) throws OperationException {
-		HttpSession session = request.getSession();
-		if (session != null) {
-			sessionHelper.clearSession(session);
-			return true;
-		}
-		throw new OperationException("并非登陆状态");
-	}
-
-	/**
-	 * 重置密码
-	 * 
-	 * @param password
-	 *            旧密码
-	 * @param newPassword
-	 *            新密码
-	 * @param request
-	 * @return 是否重置成功
-	 * @throws OperationException
-	 */
-	@RequestMapping("/resetPwd")
-	@ResponseBody
-	public boolean resetPwd(@NotEmpty("password") String password, @NotEmpty("newPassword") String newPassword,
-			HttpServletRequest request) throws OperationException {
-		return resourcePointService.resetPassword(password, newPassword);
-	}
-
-	/**
-	 * 资源点已存在
-	 * 
-	 * @param name
-	 *            名称
-	 * @param request
-	 * @return 是否存在
-	 */
-	@RequestMapping("/exist")
-	@ResponseBody
-	public boolean exist(@NotEmpty("name") String name, HttpServletRequest request) {
-		return resourcePointService.exist(name);
-	}
 }

+ 73 - 0
kanban-auth/src/main/java/com/uas/kanban/controller/UserController.java

@@ -1,10 +1,19 @@
 package com.uas.kanban.controller;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
 
+import com.uas.kanban.annotation.NotEmpty;
 import com.uas.kanban.base.BaseController;
+import com.uas.kanban.exception.OperationException;
 import com.uas.kanban.model.User;
+import com.uas.kanban.service.UserService;
+import com.uas.kanban.support.SessionHelper;
 
 /**
  * 用户
@@ -16,4 +25,68 @@ import com.uas.kanban.model.User;
 @RequestMapping("/user")
 public class UserController extends BaseController<User> {
 
+	@Autowired
+	private UserService userService;
+
+	@Autowired
+	private SessionHelper sessionHelper;
+
+	/**
+	 * 登陆
+	 * 
+	 * @param name
+	 *            名称
+	 * @param password
+	 *            密码
+	 * @param request
+	 * @return 是否成功登陆
+	 */
+	@RequestMapping("/login")
+	@ResponseBody
+	public boolean login(@NotEmpty("name") String name, @NotEmpty("password") String password,
+			HttpServletRequest request) {
+		User user = userService.login(name, password);
+		if (user != null) {
+			sessionHelper.saveSession(request, user);
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * 退出 登陆
+	 * 
+	 * @param request
+	 * @return 是否成功登陆
+	 * @throws OperationException
+	 */
+	@RequestMapping("/logout")
+	@ResponseBody
+	public boolean logout(HttpServletRequest request) throws OperationException {
+		HttpSession session = request.getSession();
+		if (session != null) {
+			sessionHelper.clearSession(session);
+			return true;
+		}
+		throw new OperationException("并非登陆状态");
+	}
+
+	/**
+	 * 重置密码
+	 * 
+	 * @param password
+	 *            旧密码
+	 * @param newPassword
+	 *            新密码
+	 * @param request
+	 * @return 是否重置成功
+	 * @throws OperationException
+	 */
+	@RequestMapping("/resetPwd")
+	@ResponseBody
+	public boolean resetPwd(@NotEmpty("password") String password, @NotEmpty("newPassword") String newPassword,
+			HttpServletRequest request) throws OperationException {
+		return userService.resetPassword(password, newPassword);
+	}
+
 }

+ 9 - 9
kanban-auth/src/main/java/com/uas/kanban/filter/SecurityInterceptor.java

@@ -12,8 +12,8 @@ import org.springframework.stereotype.Component;
 import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
 
 import com.uas.kanban.exception.OperationException;
-import com.uas.kanban.model.ResourcePoint;
-import com.uas.kanban.model.ResourcePoint.Role;
+import com.uas.kanban.model.User;
+import com.uas.kanban.model.User.Role;
 import com.uas.kanban.support.SessionHelper;
 import com.uas.kanban.support.SystemSession;
 
@@ -38,31 +38,31 @@ public class SecurityInterceptor extends HandlerInterceptorAdapter {
 		String contextPath = request.getContextPath();
 		// 获取(去除 context path 后的)请求的路径
 		String url = requestURI.substring(contextPath.length());
-		ResourcePoint resourcePoint = sessionHelper.readSession(request);
+		User user = sessionHelper.readSession(request);
 
 		// 请求页面为 /login的话,特殊处理
 		if (url.equals("/login")) {
 			// session 中有登陆信息,重定向到首页
-			if (resourcePoint != null) {
+			if (user != null) {
 				response.sendRedirect("");
 			}
 			return true;
 		}
 
 		// session 中不存在登陆信息
-		if (resourcePoint == null) {
+		if (user == null) {
 			logger.info("No session for path: " + url + " , redirecting to page: login ...");
 			response.sendRedirect(
 					contextPath + "/login?returnUrl=" + URLEncoder.encode(request.getRequestURL().toString(), "UTF-8"));
 			return false;
 		}
-		if (url.startsWith("/resourcePoint/save") || url.startsWith("/resourcePoint/update")
-				|| url.startsWith("/resourcePoint/delete") || url.startsWith("/resourcePoint/get")) {
-			if (resourcePoint.getRole() != Role.Admin) {
+		if (url.startsWith("/user/save") || url.startsWith("/user/update") || url.startsWith("/user/delete")
+				|| url.startsWith("/user/get")) {
+			if (user.getRole() != Role.Admin) {
 				throw new OperationException("不允许的操作");
 			}
 		}
-		SystemSession.setResourcePoint(resourcePoint);
+		SystemSession.setUser(user);
 		return true;
 	}
 

+ 3 - 56
kanban-auth/src/main/java/com/uas/kanban/model/ResourcePoint.java

@@ -24,24 +24,6 @@ public class ResourcePoint extends BaseEntity {
 	@FieldProperty(nullable = false)
 	private String name;
 
-	/**
-	 * 密码
-	 */
-	@FieldProperty(nullable = false)
-	private String password;
-
-	/**
-	 * 角色
-	 */
-	@FieldProperty(nullable = false)
-	private Role role;
-
-	@Override
-	public void init() {
-		role = Role.Default;
-		super.init();
-	}
-
 	public String getName() {
 		return name;
 	}
@@ -50,25 +32,10 @@ public class ResourcePoint extends BaseEntity {
 		this.name = name;
 	}
 
-	public String getPassword() {
-		return password;
-	}
-
-	public void setPassword(String password) {
-		this.password = password;
-	}
-
-	public Role getRole() {
-		return role;
-	}
-
-	public void setRole(Role role) {
-		this.role = role;
-	}
-
 	@Override
 	public String toString() {
-		return "ResourcePoint [name=" + name + ", password=" + password + ", role=" + role + "]";
+		return "ResourcePoint [name=" + name + ", id=" + id + ", createTime=" + createTime + ", lastModified="
+				+ lastModified + ", version=" + version + ", code=" + code + "]";
 	}
 
 	@Override
@@ -80,26 +47,6 @@ public class ResourcePoint extends BaseEntity {
 			return false;
 		}
 		ResourcePoint other = (ResourcePoint) obj;
-		return Objects.equals(code, other.getCode()) && Objects.equals(name, other.getName())
-				&& Objects.equals(password, other.getPassword()) && Objects.equals(role, other.getRole());
-	}
-
-	/**
-	 * 角色
-	 * 
-	 * @author sunyj
-	 * @since 2017年9月1日 下午8:01:53
-	 */
-	public enum Role {
-
-		/**
-		 * 默认,普通角色
-		 */
-		Default,
-
-		/**
-		 * 管理员
-		 */
-		Admin;
+		return Objects.equals(code, other.getCode()) && Objects.equals(name, other.getName());
 	}
 }

+ 34 - 2
kanban-auth/src/main/java/com/uas/kanban/model/User.java

@@ -28,6 +28,12 @@ public class User extends BaseEntity {
 	@FieldProperty(nullable = false)
 	private String password;
 
+	/**
+	 * 角色
+	 */
+	@FieldProperty(nullable = false)
+	private Role role;
+
 	public String getName() {
 		return name;
 	}
@@ -44,10 +50,36 @@ public class User extends BaseEntity {
 		this.password = password;
 	}
 
+	public Role getRole() {
+		return role;
+	}
+
+	public void setRole(Role role) {
+		this.role = role;
+	}
+
 	@Override
 	public String toString() {
-		return "User [name=" + name + ", password=" + password + ", id=" + id + ", code=" + code + ", createTime="
-				+ createTime + ", lastModified=" + lastModified + ", version=" + version + "]";
+		return "User [name=" + name + ", password=" + password + ", role=" + role + ", id=" + id + ", createTime="
+				+ createTime + ", lastModified=" + lastModified + ", version=" + version + ", code=" + code + "]";
 	}
 
+	/**
+	 * 角色
+	 * 
+	 * @author sunyj
+	 * @since 2017年9月1日 下午8:01:53
+	 */
+	public enum Role {
+
+		/**
+		 * 默认,普通角色
+		 */
+		Default,
+
+		/**
+		 * 管理员
+		 */
+		Admin;
+	}
 }

+ 5 - 13
kanban-auth/src/main/java/com/uas/kanban/service/ResourcePointService.java → kanban-auth/src/main/java/com/uas/kanban/service/UserService.java

@@ -1,15 +1,15 @@
 package com.uas.kanban.service;
 
 import com.uas.kanban.annotation.NotEmpty;
-import com.uas.kanban.model.ResourcePoint;
+import com.uas.kanban.model.User;
 
 /**
- * 资源点
+ * 用户
  * 
  * @author sunyj
  * @since 2017年9月1日 下午4:45:50
  */
-public interface ResourcePointService {
+public interface UserService {
 
 	/**
 	 * 登陆
@@ -18,9 +18,9 @@ public interface ResourcePointService {
 	 *            名称
 	 * @param password
 	 *            密码
-	 * @return 资源点信息
+	 * @return 账户信息
 	 */
-	ResourcePoint login(@NotEmpty("name") String name, @NotEmpty("password") String password);
+	User login(@NotEmpty("name") String name, @NotEmpty("password") String password);
 
 	/**
 	 * 重置密码
@@ -33,12 +33,4 @@ public interface ResourcePointService {
 	 */
 	boolean resetPassword(@NotEmpty("password") String password, @NotEmpty("newPassword") String newPassword);
 
-	/**
-	 * 资源点已存在
-	 * 
-	 * @param name
-	 *            名称
-	 * @return 是否存在
-	 */
-	boolean exist(@NotEmpty("name") String name);
 }

+ 6 - 63
kanban-auth/src/main/java/com/uas/kanban/service/impl/ResourcePointServiceImpl.java

@@ -3,7 +3,6 @@ package com.uas.kanban.service.impl;
 import java.util.Objects;
 
 import org.mongodb.morphia.query.Query;
-import org.mongodb.morphia.query.UpdateOperations;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -12,9 +11,6 @@ import com.uas.kanban.base.BaseService;
 import com.uas.kanban.dao.ResourcePointDao;
 import com.uas.kanban.exception.OperationException;
 import com.uas.kanban.model.ResourcePoint;
-import com.uas.kanban.model.ResourcePoint.Role;
-import com.uas.kanban.service.ResourcePointService;
-import com.uas.kanban.support.SystemSession;
 
 /**
  * 资源点
@@ -23,7 +19,7 @@ import com.uas.kanban.support.SystemSession;
  * @since 2017年9月2日 下午8:47:20
  */
 @Service
-public class ResourcePointServiceImpl extends BaseService<ResourcePoint> implements ResourcePointService {
+public class ResourcePointServiceImpl extends BaseService<ResourcePoint> {
 
 	@Autowired
 	private ResourcePointDao resourcePointDao;
@@ -34,7 +30,6 @@ public class ResourcePointServiceImpl extends BaseService<ResourcePoint> impleme
 		if (exist(resourcePoint.getName())) {
 			throw new IllegalStateException("资源点已存在");
 		}
-		checkValid(resourcePoint);
 		return resourcePointDao.save(resourcePoint);
 	}
 
@@ -51,11 +46,6 @@ public class ResourcePointServiceImpl extends BaseService<ResourcePoint> impleme
 		if (rPoint == null) {
 			throw new IllegalStateException("资源点不存在");
 		}
-		if (rPoint.getRole() == Role.Admin) {
-			if (!Objects.equals(code, SystemSession.checkResourcePoint().getCode())) {
-				throw new OperationException("不允许修改其他管理员");
-			}
-		}
 		if (Objects.equals(resourcePoint, rPoint)) {
 			throw new IllegalStateException("未发现任何变更");
 		}
@@ -63,7 +53,6 @@ public class ResourcePointServiceImpl extends BaseService<ResourcePoint> impleme
 		if (!Objects.equals(name, rPoint.getName()) && exist(name)) {
 			throw new IllegalStateException("资源点已存在");
 		}
-		checkValid(resourcePoint);
 		return resourcePointDao.update(resourcePoint);
 	}
 
@@ -73,59 +62,13 @@ public class ResourcePointServiceImpl extends BaseService<ResourcePoint> impleme
 	}
 
 	/**
-	 * 对名称和密码长度进行校验
+	 * 资源点是否已存在
 	 * 
-	 * @param resourcePoint
+	 * @param name
+	 *            名称
+	 * @return 是否存在
 	 */
-	private void checkValid(@NotEmpty("resourcePoint") ResourcePoint resourcePoint) {
-		String name = resourcePoint.getName();
-		String password = resourcePoint.getPassword();
-		if (name != null && name.trim().length() < 3) {
-			throw new IllegalArgumentException("名称过短");
-		}
-		if (password != null && password.trim().length() < 3) {
-			throw new IllegalArgumentException("密码过短");
-		}
-	}
-
-	@Override
-	public ResourcePoint login(@NotEmpty("name") String name, @NotEmpty("password") String password) {
-		Query<ResourcePoint> query = resourcePointDao.createQuery();
-		query.field("name").equal(name);
-		query.field("password").equal(password);
-		long count = query.count();
-		if (count == 0) {
-			throw new IllegalStateException("名称不存在或密码错误");
-		}
-		if (count > 1) {
-			throw new IllegalStateException("资源点重复");
-		}
-		ResourcePoint resourcePoint = query.get();
-		return resourcePoint;
-	}
-
-	@Override
-	public boolean resetPassword(@NotEmpty("password") String password, @NotEmpty("newPassword") String newPassword) {
-		ResourcePoint rPoint = SystemSession.checkResourcePoint();
-		String code = rPoint.getCode();
-		ResourcePoint resourcePoint = resourcePointDao.findOne(code);
-		if (resourcePoint == null) {
-			throw new IllegalStateException("资源点不存在:" + rPoint);
-		}
-		if (!Objects.equals(password, resourcePoint.getPassword())) {
-			throw new IllegalStateException("旧密码错误");
-		}
-		if (Objects.equals(password, newPassword)) {
-			throw new IllegalStateException("新密码与旧密码相同");
-		}
-		UpdateOperations<ResourcePoint> operations = resourcePointDao.createUpdateOperations();
-		operations.set("password", newPassword);
-		resourcePointDao.update(code, operations);
-		return true;
-	}
-
-	@Override
-	public boolean exist(@NotEmpty("name") String name) {
+	private boolean exist(@NotEmpty("name") String name) {
 		Query<ResourcePoint> query = resourcePointDao.createQuery();
 		query.field("name").equal(name);
 		return query.count() > 0;

+ 126 - 1
kanban-auth/src/main/java/com/uas/kanban/service/impl/UserServiceImpl.java

@@ -1,9 +1,20 @@
 package com.uas.kanban.service.impl;
 
+import java.util.Objects;
+
+import org.mongodb.morphia.query.Query;
+import org.mongodb.morphia.query.UpdateOperations;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import com.uas.kanban.annotation.NotEmpty;
 import com.uas.kanban.base.BaseService;
+import com.uas.kanban.dao.UserDao;
+import com.uas.kanban.exception.OperationException;
 import com.uas.kanban.model.User;
+import com.uas.kanban.model.User.Role;
+import com.uas.kanban.service.UserService;
+import com.uas.kanban.support.SystemSession;
 
 /**
  * 用户
@@ -12,6 +23,120 @@ import com.uas.kanban.model.User;
  * @since 2017年9月2日 下午8:47:20
  */
 @Service
-public class UserServiceImpl extends BaseService<User> {
+public class UserServiceImpl extends BaseService<User> implements UserService {
+
+	@Autowired
+	private UserDao userDao;
+
+	@Override
+	public User save(@NotEmpty("json") String json) {
+		User user = userDao.parse(json);
+		if (exist(user.getName())) {
+			throw new IllegalStateException("用户已存在");
+		}
+		if (user.getRole() == null) {
+			user.setRole(Role.Default);
+		}
+		checkValid(user);
+		return userDao.save(user);
+	}
+
+	@Override
+	public User savePart(String json) {
+		return save(json);
+	}
+
+	@Override
+	public int update(@NotEmpty("json") String json) throws IllegalArgumentException, OperationException {
+		User user = userDao.parse(json);
+		String code = user.codeNotEmpty();
+		User rPoint = userDao.findOne(code);
+		if (rPoint == null) {
+			throw new IllegalStateException("用户不存在");
+		}
+		if (rPoint.getRole() == Role.Admin) {
+			if (!Objects.equals(code, SystemSession.checkUser().getCode())) {
+				throw new OperationException("不允许修改其他管理员");
+			}
+		}
+		if (Objects.equals(user, rPoint)) {
+			throw new IllegalStateException("未发现任何变更");
+		}
+		String name = user.getName();
+		if (!Objects.equals(name, rPoint.getName()) && exist(name)) {
+			throw new IllegalStateException("用户已存在");
+		}
+		checkValid(user);
+		return userDao.update(user);
+	}
+
+	@Override
+	public int updatePart(String json) throws IllegalArgumentException, OperationException {
+		return update(json);
+	}
+
+	/**
+	 * 对名称和密码长度进行校验
+	 * 
+	 * @param user
+	 */
+	private void checkValid(@NotEmpty("user") User user) {
+		String name = user.getName();
+		String password = user.getPassword();
+		if (name != null && name.trim().length() < 3) {
+			throw new IllegalArgumentException("名称过短");
+		}
+		if (password != null && password.trim().length() < 3) {
+			throw new IllegalArgumentException("密码过短");
+		}
+	}
+
+	@Override
+	public User login(@NotEmpty("name") String name, @NotEmpty("password") String password) {
+		Query<User> query = userDao.createQuery();
+		query.field("name").equal(name);
+		query.field("password").equal(password);
+		long count = query.count();
+		if (count == 0) {
+			throw new IllegalStateException("名称不存在或密码错误");
+		}
+		if (count > 1) {
+			throw new IllegalStateException("用户重复");
+		}
+		User user = query.get();
+		return user;
+	}
+
+	@Override
+	public boolean resetPassword(@NotEmpty("password") String password, @NotEmpty("newPassword") String newPassword) {
+		User rPoint = SystemSession.checkUser();
+		String code = rPoint.getCode();
+		User user = userDao.findOne(code);
+		if (user == null) {
+			throw new IllegalStateException("用户不存在:" + rPoint);
+		}
+		if (!Objects.equals(password, user.getPassword())) {
+			throw new IllegalStateException("旧密码错误");
+		}
+		if (Objects.equals(password, newPassword)) {
+			throw new IllegalStateException("新密码与旧密码相同");
+		}
+		UpdateOperations<User> operations = userDao.createUpdateOperations();
+		operations.set("password", newPassword);
+		userDao.update(code, operations);
+		return true;
+	}
 
+	/**
+	 * 用户是否已存在
+	 * 
+	 * @param name
+	 *            名称
+	 * @return 是否存在
+	 */
+	public boolean exist(@NotEmpty("name") String name) {
+		Query<User> query = userDao.createQuery();
+		query.field("name").equal(name);
+		return query.count() > 0;
+	}
 }

+ 14 - 15
kanban-auth/src/main/java/com/uas/kanban/support/SessionHelper.java

@@ -6,7 +6,7 @@ import javax.servlet.http.HttpSession;
 import org.springframework.stereotype.Component;
 
 import com.uas.kanban.annotation.NotEmpty;
-import com.uas.kanban.model.ResourcePoint;
+import com.uas.kanban.model.User;
 
 /**
  * session 辅助类
@@ -20,35 +20,34 @@ public class SessionHelper {
 	/**
 	 * 存在 session 中属性名称
 	 */
-	private static final String ATTRIBUTE_NAME = "resourcePoint";
+	private static final String ATTRIBUTE_NAME = "user";
 
 	/**
-	 * 将登录的资源点信息保存到 session
+	 * 将登录的账户信息保存到 session
 	 * 
 	 * @param request
 	 *            请求
-	 * @param resourcePoint
-	 *            资源点信息
+	 * @param user
+	 *            账户信息
 	 */
-	public void saveSession(@NotEmpty("request") HttpServletRequest request,
-			@NotEmpty("resourcePoint") ResourcePoint resourcePoint) {
-		request.getSession().setAttribute(ATTRIBUTE_NAME, resourcePoint);
-		SystemSession.setResourcePoint(resourcePoint);
+	public void saveSession(@NotEmpty("request") HttpServletRequest request, @NotEmpty("user") User user) {
+		request.getSession().setAttribute(ATTRIBUTE_NAME, user);
+		SystemSession.setUser(user);
 	}
 
 	/**
-	 * 取出 session 中已登录的资源点信息
+	 * 取出 session 中已登录的账户信息
 	 * 
 	 * @param request
 	 *            请求
-	 * @return 资源点信息,可能为 null
+	 * @return 账户信息,可能为 null
 	 */
-	public ResourcePoint readSession(@NotEmpty("request") HttpServletRequest request) {
-		Object resourcePoint = request.getSession().getAttribute(ATTRIBUTE_NAME);
-		if (resourcePoint == null) {
+	public User readSession(@NotEmpty("request") HttpServletRequest request) {
+		Object user = request.getSession().getAttribute(ATTRIBUTE_NAME);
+		if (user == null) {
 			return null;
 		}
-		return (ResourcePoint) resourcePoint;
+		return (User) user;
 	}
 
 	/**

+ 9 - 9
kanban-auth/src/main/java/com/uas/kanban/support/SystemSession.java

@@ -1,6 +1,6 @@
 package com.uas.kanban.support;
 
-import com.uas.kanban.model.ResourcePoint;
+import com.uas.kanban.model.User;
 
 /**
  * 存放身份信息
@@ -11,13 +11,13 @@ import com.uas.kanban.model.ResourcePoint;
  */
 public class SystemSession {
 
-	private static ThreadLocal<ResourcePoint> local = new ThreadLocal<>();
+	private static ThreadLocal<User> local = new ThreadLocal<>();
 
-	public static void setResourcePoint(ResourcePoint resourcePoint) {
-		local.set(resourcePoint);
+	public static void setUser(User user) {
+		local.set(user);
 	}
 
-	public static ResourcePoint getResourcePoint() {
+	public static User getUser() {
 		return local.get();
 	}
 
@@ -26,12 +26,12 @@ public class SystemSession {
 	 * @throws IllegalStateException
 	 *             未登录
 	 */
-	public static ResourcePoint checkResourcePoint() throws IllegalStateException {
-		ResourcePoint resourcePoint = getResourcePoint();
-		if (resourcePoint == null) {
+	public static User checkUser() throws IllegalStateException {
+		User user = getUser();
+		if (user == null) {
 			throw new IllegalStateException("未登陆");
 		}
-		return resourcePoint;
+		return user;
 	}
 
 	public static void clear() {

+ 2 - 2
kanban-console/src/main/java/com/uas/kanban/WebAppConfiguration.java

@@ -121,10 +121,10 @@ public class WebAppConfiguration extends WebMvcConfigurerAdapter {
 		// 排除路径
 		registration.excludePathPatterns("/WEB-INF/**", "/error");
 		// 排除路径,由 spring boot security 进行验证
-		registration.excludePathPatterns("/console", "/fileUpload", "/**/delete/all", "/druid/**", "/user/**");
+		registration.excludePathPatterns("/console", "/fileUpload", "/**/delete/all", "/druid/**");
 
 		// 不对下列路径进行验证
-		registration.excludePathPatterns("/resourcePoint/login", "/resourcePoint/logout", "/resourcePoint/exist");
+		registration.excludePathPatterns("/user/login", "/user/logout", "/user/exist");
 	}
 
 }

+ 4 - 4
kanban-console/src/main/java/com/uas/kanban/dao/KanbanDao.java

@@ -7,7 +7,7 @@ import org.springframework.stereotype.Component;
 
 import com.uas.kanban.base.BaseDao;
 import com.uas.kanban.model.Kanban;
-import com.uas.kanban.model.ResourcePoint;
+import com.uas.kanban.model.User;
 import com.uas.kanban.support.SystemSession;
 
 /**
@@ -21,10 +21,10 @@ public class KanbanDao extends BaseDao<Kanban> {
 
 	@Override
 	protected Map<String, Object> globalFilter() {
-		ResourcePoint resourcePoint = SystemSession.checkResourcePoint();
+		User user = SystemSession.checkUser();
 		Map<String, Object> filters = new HashMap<>();
-		// 根据资源点过滤
-		filters.put("resourcePointCode", resourcePoint.getCode());
+		// 根据用户过滤
+		filters.put("userCode", user.getCode());
 		return filters;
 	}
 

+ 12 - 12
kanban-console/src/main/java/com/uas/kanban/model/Kanban.java

@@ -22,10 +22,10 @@ public class Kanban extends BaseEntity {
 	public static final double DEFAULT_SWITCH_FREQUENCY = 10;
 
 	/**
-	 * 资源点 code
+	 * 用户 code
 	 */
 	@FieldProperty(nullable = false)
-	private String resourcePointCode;
+	private String userCode;
 
 	/**
 	 * 看板名称
@@ -57,17 +57,17 @@ public class Kanban extends BaseEntity {
 
 	@Override
 	public void init() {
-		ResourcePoint resourcePoint = SystemSession.checkResourcePoint();
-		resourcePointCode = resourcePoint.getCode();
+		User user = SystemSession.checkUser();
+		userCode = user.getCode();
 		super.init();
 	}
 
-	public String getResourcePointCode() {
-		return resourcePointCode;
+	public String getUserCode() {
+		return userCode;
 	}
 
-	public void setResourcePointCode(String resourcePointCode) {
-		this.resourcePointCode = resourcePointCode;
+	public void setUserCode(String userCode) {
+		this.userCode = userCode;
 	}
 
 	public String getName() {
@@ -112,10 +112,10 @@ public class Kanban extends BaseEntity {
 
 	@Override
 	public String toString() {
-		return "Kanban [resourcePointCode=" + resourcePointCode + ", name=" + name + ", templateCodes=" + templateCodes
-				+ ", display=" + display + ", switchFrequency=" + switchFrequency + ", iconCls=" + iconCls + ", id="
-				+ id + ", createTime=" + createTime + ", lastModified=" + lastModified + ", version=" + version
-				+ ", code=" + code + "]";
+		return "Kanban [userCode=" + userCode + ", name=" + name + ", templateCodes=" + templateCodes + ", display="
+				+ display + ", switchFrequency=" + switchFrequency + ", iconCls=" + iconCls + ", id=" + id
+				+ ", createTime=" + createTime + ", lastModified=" + lastModified + ", version=" + version + ", code="
+				+ code + "]";
 	}
 
 	/**

+ 1 - 1
kanban-console/src/main/java/com/uas/kanban/service/impl/KanbanServiceImpl.java

@@ -49,7 +49,7 @@ public class KanbanServiceImpl extends BaseService<Kanban> {
 		Kanban kanban = kanbanDao.parse(json);
 		checkTemplates(kanban.getTemplateCodes());
 		checkDisplay(kanban);
-		kanban.setResourcePointCode(SystemSession.checkResourcePoint().getCode());
+		kanban.setUserCode(SystemSession.checkUser().getCode());
 		return kanbanDao.update(kanban);
 	}
 

+ 1 - 1
kanban-console/src/main/resources/bootstrap.yml

@@ -15,7 +15,7 @@ spring:
 security:
  basic:
   enabled: true
-  path: /console, /fileUpload, /**/delete/all, /druid/*, /user/**
+  path: /console, /fileUpload, /**/delete/all, /druid/*
  user:
   name: admin
   password: select111***

+ 4 - 5
kanban-console/src/main/webapp/WEB-INF/views/console.html

@@ -18,6 +18,10 @@
 				<li><a target="_blank">user/get/all</a></li>
 				<li><a target="_blank">user/get/4EC2735D343</a></li>
 				<li><a target="_blank">user/get?page=1&size=10</a></li>
+				<br/>
+				<li><a target="_blank">user/login?name=name&password=123</a></li>
+				<li><a target="_blank">user/logout</a></li>
+				<li><a target="_blank">user/resetPwd?password=12&newPassword=34</a></li>
 			</ol>
 			<strong><li class="title">资源点</li></strong>
 			<ol>
@@ -29,11 +33,6 @@
 				<li><a target="_blank">resourcePoint/get/all</a></li>
 				<li><a target="_blank">resourcePoint/get/4EC2735D343</a></li>
 				<li><a target="_blank">resourcePoint/get?page=1&size=10</a></li>
-				<br/>
-				<li><a target="_blank">resourcePoint/login?name=name&password=123</a></li>
-				<li><a target="_blank">resourcePoint/logout</a></li>
-				<li><a target="_blank">resourcePoint/resetPwd?password=12&newPassword=34</a></li>
-				<li><a target="_blank">resourcePoint/exist?name=name</a></li>
 			</ol>
 			<strong><li class="title">数据源</li></strong>
 			<ol>

+ 1 - 1
kanban-console/src/main/webapp/resources/app/controller/login.js

@@ -28,7 +28,7 @@ Ext.define('erp.controller.login', {
 						Ext.Msg.alert('提示','请输入用户名和密码!');
 					}else{
 						Ext.Ajax.request({
-							url : basePath + 'resourcePoint/login',
+							url : basePath + 'user/login',
 							method : 'POST',
 							params : values,
 							callback : function(options, success, response) {

+ 1 - 1
kanban-console/src/main/webapp/resources/app/view/desktop/StartMenu.js

@@ -30,7 +30,7 @@ Ext.define('erp.view.desktop.StartMenu', {
                 iconCls:'logout',
                	handler: function(){
                		Ext.Ajax.request({
-               			url:basePath + 'resourcePoint/logout',
+               			url:basePath + 'user/logout',
                			method:'POST',
                			callback:function(options,success,response){
                				var res = Ext.decode(response.responseText);