dcs 5 місяців тому
батько
коміт
0e158e715f

+ 13 - 0
virgo.core/src/main/java/com/bosshand/virgo/core/controller/UserContextController.java

@@ -172,6 +172,19 @@ public class UserContextController {
 		return Response.ok(ContextUtils.getUserContext());
 	}
 
+	@ApiOperation(value = "切换身份", notes = "切换身份")
+	@RequestMapping(value = "/userContext/identity/{id}", method = RequestMethod.PUT)
+	public Response saveLastIdentity(@PathVariable long id) {
+		Subject subject = SecurityUtils.getSubject();
+		if (!subject.isAuthenticated()) {
+			return Response.fail(Constant.CODE_AUTH_FAILED, Constant.RET_AUTH_FAILED);
+		}
+		MgrUser user = ContextUtils.getCurrentUser();
+		mgrUserService.switchIdentity(user, id);
+		mgrUserService.loadContext(subject);
+		return Response.ok(ContextUtils.getUserContext());
+	}
+
 	@ApiOperation(value = "刷新上下文", notes = "刷新上下文")
 	@RequestMapping(value = "/userContext/refresh", method = RequestMethod.GET)
 	public Response refresh() {

+ 2 - 0
virgo.core/src/main/java/com/bosshand/virgo/core/dao/MgrUserDao.java

@@ -24,6 +24,8 @@ public interface MgrUserDao {
 
 	public int updateLastProjectId(MgrUser user);
 
+	public int updateLastIdentityId(MgrUser user);
+
 	public int update(MgrUser user);
 
 	public int updatePhone(MgrUser user);

+ 10 - 0
virgo.core/src/main/java/com/bosshand/virgo/core/model/MgrUser.java

@@ -35,6 +35,8 @@ public class MgrUser implements BaseModel {
 
 	private int faceStatus;
 
+	private long lastIdentityId;
+
 	private long lastProjectId;
 
 	private long lastOrganizationId;
@@ -163,6 +165,14 @@ public class MgrUser implements BaseModel {
 		this.faceStatus = faceStatus;
 	}
 
+	public long getLastIdentityId() {
+		return lastIdentityId;
+	}
+
+	public void setLastIdentityId(long lastIdentityId) {
+		this.lastIdentityId = lastIdentityId;
+	}
+
 	public long getLastProjectId() {
 		return lastProjectId;
 	}

+ 12 - 1
virgo.core/src/main/java/com/bosshand/virgo/core/model/UserContext.java

@@ -37,7 +37,9 @@ public class UserContext implements BaseModel{
 	private long organizationId;
 	
 	private long projectId;
-	
+
+	private long identityId;
+
 	private String organizedName;
 	
 	private String roleName;
@@ -102,6 +104,14 @@ public class UserContext implements BaseModel{
 		this.projectId = projectId;
 	}
 
+	public long getIdentityId() {
+		return identityId;
+	}
+
+	public void setIdentityId(long identityId) {
+		this.identityId = identityId;
+	}
+
 	public MgrOrganization getOrganization() {
 		return organization;
 	}
@@ -264,6 +274,7 @@ public class UserContext implements BaseModel{
 			flowUser.setPracticeCertificate(user.getPracticeCertificate());
 			flowUser.setPracticeSeal(user.getPracticeSeal());
 			flowUser.setProjectId(user.getLastProjectId());
+			flowUser.setIdentityId(user.getLastIdentityId());
 			flowUser.setOrganization(currentOrganization);
 			flowUser.setOrganizationList(organizationList);
 			if (currentOrganization != null) {

+ 4 - 0
virgo.core/src/main/java/com/bosshand/virgo/core/service/MgrUserService.java

@@ -210,6 +210,10 @@ public class MgrUserService {
 		mgrUserDao.updateLastProjectId(user);
 	}
 
+	public void switchIdentity(MgrUser user, long id) {
+		user.setLastIdentityId(id);
+		mgrUserDao.updateLastIdentityId(user);
+	}
 
 	/**
 	 * 缓存身份列表

+ 4 - 0
virgo.core/src/main/resources/mapper/MgrUserMapper.xml

@@ -66,6 +66,10 @@
 	UPDATE mgr_user set lastProjectId = #{lastProjectId} WHERE id=#{id}
 </update>
 
+<update id="updateLastIdentityId" parameterType="com.bosshand.virgo.core.model.MgrUser">
+	UPDATE mgr_user set lastIdentityId = #{lastIdentityId} WHERE id=#{id}
+</update>
+
 <update id="update" parameterType="com.bosshand.virgo.core.model.MgrUser">
 	UPDATE mgr_user
 		<trim prefix="set" suffixOverrides=",">

+ 3 - 5
virgo.file/src/main/java/com/bosshand/virgo/file/dao/FileNodeDao.java

@@ -1,11 +1,10 @@
 package com.bosshand.virgo.file.dao;
 
-import java.util.List;
-import java.util.Map;
-
+import com.bosshand.virgo.file.model.FileNode;
 import org.apache.ibatis.annotations.Mapper;
 
-import com.bosshand.virgo.file.model.FileNode;
+import java.util.List;
+import java.util.Map;
 
 @Mapper
 public interface FileNodeDao {
@@ -15,7 +14,6 @@ public interface FileNodeDao {
 	FileNode get(int id);
 	void insert(FileNode node);
 	void remove(int id);
-	void removeList(List<FileNode> nodeList);
 	void update(FileNode fileNode);
 	List<FileNode> getIds(List<Integer> fileNodeIds);