Commit 21ba9086 by chamberone
1 parent c1216fd6
......@@ -6,8 +6,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
/**
* 角色表(Role)表数据库访问层
*
......@@ -17,22 +15,4 @@ import java.util.List;
public interface RoleDao extends JpaRepository<RoleEntity, String>,
JpaSpecificationExecutor<RoleEntity>, CrudRepository<RoleEntity, String> {
/**
* 根据团队ID查询
* @param teamId 团队ID
* @return
*/
List<RoleEntity> findByTeamId(String teamId);
/**
* 根据角色ID和团队ID查询
* @param id 角色ID
* @param teamId 团队ID
* @return
*/
RoleEntity findByIdAndTeamId(String id, String teamId);
}
......@@ -42,12 +42,6 @@ public class UserRoleEntity implements Serializable {
@NotBlank(message = "角色ID不能为空")
private String roleId;
/**
* 团队id
*/
@Column(name = "team_id")
@NotBlank(message = "团队ID不能为空")
private String teamId;
/**
* 创建人
*/
@Column(name = "CREATED_BY")
......
......@@ -50,7 +50,6 @@
{
"timestamp": "@timestamp",
"userId": "%X{userId:-}",
"teamId": "%X{teamId:-}",
"severity": "%level",
"service": "${springAppName:-}",
"trace": "%X{traceId:-}",
......
package com.dituhui.pea.user;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@RunWith(SpringRunner.class)
@SpringBootTest
public class TeamControllerTest {
@Autowired
private WebApplicationContext wac;
private MockMvc mockMvc;
@Before
public void setup() {
mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
}
@Test
public void whenQueryTeamSuccess() throws Exception {
String result = mockMvc.perform(
get("/v1/team/get").param("id", "40288ac9764ba85101764baef86f0000")
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk()).andExpect(jsonPath("$.success").value(true))
.andReturn().getResponse().getContentAsString();
System.out.println(result);
}
@Test
public void whenAddTeamSuccess() throws Exception {
String content = "{\"name\":\"测试团队001\",\"business\":\"001团队\",\"province\":\"四川省\",\"city\":\"成都市\",\"county\":\"高新区\",\"size\":1000,\"address\":\"新川科技园成都超图大厦\",\"expireDate\":\"2020-12-23 00:00:00\"}";
String result = mockMvc.perform(post("/v1/team/add").contentType(MediaType.APPLICATION_JSON_UTF8)
.content(content))
.andExpect(status().isOk())
.andExpect(jsonPath("$.success").value(true))
.andReturn().getResponse().getContentAsString();
System.out.println(result);
}
@Test
public void whenUpdateTeamSuccess() throws Exception {
String content = "{\"id\":\"40288ac9768e57d101768e5808610000\",\"name\":\"测试团队002\",\"business\":\"002团队\",\"province\":\"四川省\",\"city\":\"成都市\",\"county\":\"高新区\",\"size\":1000,\"address\":\"新川科技园成都超图大厦\"}";
String result = mockMvc.perform(post("/v1/team/update").contentType(MediaType.APPLICATION_JSON_UTF8)
.content(content))
.andExpect(status().isOk())
.andExpect(jsonPath("$.success").value(true))
.andReturn().getResponse().getContentAsString();
System.out.println(result);
}
@Test
public void whenDeleteTeamSuccess() throws Exception {
String result = mockMvc.perform(post("/v1/team/delete").param("id", "40288ac9768e540101768e5437aa0000")
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk())
.andExpect(jsonPath("$.success").value(true))
.andReturn().getResponse().getContentAsString();
System.out.println(result);
}
@Test
public void whenAddTeamUserSuccess() throws Exception {
String result = mockMvc.perform(post("/v1/team/addUser").param("id","40288ac9768e57d101768e5808610000")
.param("userId", "9a29b842388148eda91eede9e11dddbb")
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk())
.andExpect(jsonPath("$.success").value(true))
.andReturn().getResponse().getContentAsString();
System.out.println(result);
}
@Test
public void whenDeleteTeamUserSuccess() throws Exception {
String result = mockMvc.perform(post("/v1/team/deleteUser").param("id","40288ac9768e57d101768e5808610000")
.param("userId", "9a29b842388148eda91eede9e11dddbb")
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk())
.andExpect(jsonPath("$.success").value(true))
.andReturn().getResponse().getContentAsString();
System.out.println(result);
}
@Test
public void whenGetTeamUserSuccess() throws Exception {
String result = mockMvc.perform(get("/v1/team/getUsers").param("teamId", "40288ac97673e23f017673e26ed90001")
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk()).andExpect(jsonPath("$.success").value(true))
.andReturn().getResponse().getContentAsString();
System.out.println(result);
}
@Test
public void whenGetTeamRoleSuccess() throws Exception {
String result = mockMvc.perform(get("/v1/team/getRoles").param("teamId", "40288ac97673e23f017673e26ed90001")
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isOk()).andExpect(jsonPath("$.success").value(true))
.andReturn().getResponse().getContentAsString();
System.out.println(result);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!