suntg 7 лет назад
Родитель
Сommit
267032574d

+ 7 - 7
src/main/java/com/uas/platform/b2b/service/impl/AttachServiceImpl.java

@@ -81,7 +81,7 @@ public class AttachServiceImpl implements AttachService {
 					File file = new File(fileMap.get(entry));
 					if (file.exists()) {
 						Map<String, Object> params = entryParams.get(entry);
-                        // multi sources
+						// multi sources
 						sources = params.get("sourceId").toString().split(",");
 						for (String sr : sources) {
 							Attach attach = new Attach(String.valueOf(params.get("name")), fileMap.get(entry), description, file.length(),
@@ -130,19 +130,19 @@ public class AttachServiceImpl implements AttachService {
 		String path = PathUtils.getFilePath() + "postattach";
 		File dir = new File(path);
 		if (!dir.isDirectory()) {
-            dir.mkdir();
-        }
+			dir.mkdir();
+		}
 		path += File.separator + parentDir;
 		dir = new File(path);
 		if (!dir.isDirectory()) {
-            dir.mkdir();
-        }
+			dir.mkdir();
+		}
 		if (SystemSession.getUser() != null) {
 			path += File.separator + SystemSession.getUser().getEnterprise().getUu();
 			dir = new File(path);
 			if (!dir.isDirectory()) {
-                dir.mkdir();
-            }
+				dir.mkdir();
+			}
 		}
 		return path;
 	}

+ 4 - 2
src/main/java/com/uas/platform/b2b/service/impl/CommunalLogServiceImpl.java

@@ -17,13 +17,15 @@ public class CommunalLogServiceImpl implements CommunalLogService {
 
     @Override
     public void save(CommunalLog communalLog) {
-        if(null != communalLog)
+        if(null != communalLog) {
             communalLogDao.save(communalLog);
+        }
     }
 
     @Override
     public void save(Iterable<CommunalLog> iterable) {
-        if(null != iterable)
+        if(null != iterable) {
             communalLogDao.save(iterable);
+        }
     }
 }

+ 23 - 0
src/test/java/com/uas/platform/b2b/BaseJunitTest.java

@@ -1,5 +1,8 @@
 package com.uas.platform.b2b;
 
+import com.uas.platform.b2b.model.Enterprise;
+import com.uas.platform.b2b.model.User;
+import com.uas.platform.b2b.support.SystemSession;
 import org.junit.Before;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -12,6 +15,9 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.context.WebApplicationContext;
 
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * Spring MVC 测试基类,所有测试类继承自这个类就可以直接写单元测试
  * @author stg
@@ -36,4 +42,21 @@ public class BaseJunitTest {
     public void setup() {
         this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
     }
+
+    /**
+     * 初始化用户信息
+     * @param userUU
+     * @param enUU
+     */
+    protected void initSystemSession(Long userUU, Long enUU) {
+        User user = new User();
+        user.setUserUU(userUU);
+        Enterprise enterprise = new Enterprise();
+        enterprise.setUu(enUU);
+        Set<Enterprise> enterprises = new HashSet<>();
+        enterprises.add(enterprise);
+        user.setEnterprises(enterprises);
+        user.setEnterprise(enterprise);
+        SystemSession.setUser(user);
+    }
 }