use of com.albedo.java.modules.sys.domain.dto.DeptDto in project albedo by somowhere.
the class DeptDoResourceIntTest method updateDept.
@Test
@Transactional(rollbackFor = Exception.class)
public void updateDept() throws Exception {
// Initialize the database
deptService.saveOrUpdate(dept);
int databaseSizeBeforeUpdate = deptService.list().size();
// Update the dept
DeptDo updatedDeptDo = deptService.getById(dept.getId());
DeptDto managedDeptVM = new DeptDto();
managedDeptVM.setName(UPDATED_NAME);
managedDeptVM.setSort(UPDATED_SORT);
managedDeptVM.setParentId(UPDATED_PARENT_ID);
managedDeptVM.setDescription(UPDATED_DESCRIPTION);
managedDeptVM.setId(updatedDeptDo.getId());
restDeptMockMvc.perform(post(DEFAULT_API_URL).contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(managedDeptVM))).andExpect(status().isOk()).andExpect(jsonPath("$.code").value(CommonConstants.SUCCESS));
// Validate the Dept in the database
List<DeptDo> deptDoList = deptService.list();
assertThat(deptDoList).hasSize(databaseSizeBeforeUpdate);
DeptDo testDeptDo = deptService.getById(updatedDeptDo.getId());
assertThat(testDeptDo.getName()).isEqualTo(UPDATED_NAME);
assertThat(testDeptDo.getSort()).isEqualTo(UPDATED_SORT);
assertThat(testDeptDo.getParentId()).isEqualTo(UPDATED_PARENT_ID);
// assertThat(testDept.getParentIds()).contains(UPDATED_PARENT_ID);
assertThat(testDeptDo.isLeaf()).isEqualTo(true);
assertThat(testDeptDo.getDescription()).isEqualTo(UPDATED_DESCRIPTION);
assertThat(testDeptDo.getDelFlag()).isEqualTo(DeptDo.FLAG_NORMAL);
}
use of com.albedo.java.modules.sys.domain.dto.DeptDto in project albedo by somowhere.
the class DeptRelationServiceImpl method saveDeptRelation.
/**
* 维护部门关系
*
* @param deptDto 部门
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void saveDeptRelation(DeptDto deptDto) {
// 增加部门关系表
DeptRelationDo condition = new DeptRelationDo();
condition.setDescendant(deptDto.getParentId());
List<DeptRelationDo> relationList = deptRelationRepository.selectList(Wrappers.<DeptRelationDo>query().lambda().eq(DeptRelationDo::getDescendant, deptDto.getParentId())).stream().map(relation -> {
relation.setDescendant(deptDto.getId());
return relation;
}).collect(Collectors.toList());
if (CollUtil.isNotEmpty(relationList)) {
this.saveBatch(relationList);
}
// 自己也要维护到关系表中
DeptRelationDo own = new DeptRelationDo();
own.setDescendant(deptDto.getId());
own.setAncestor(deptDto.getId());
deptRelationRepository.insert(own);
}
use of com.albedo.java.modules.sys.domain.dto.DeptDto in project albedo by somowhere.
the class DeptDoResourceIntTest method createEntity.
/**
* Create a Dept.
* <p>
* This is a static method, as tests for other entities might also need it, if they
* test an domain which has a required relationship to the Dept domain.
*/
public DeptDto createEntity() {
DeptDto dept = new DeptDto();
dept.setName(DEFAULT_NAME);
dept.setSort(DEFAULT_SORT);
dept.setDescription(DEFAULT_DESCRIPTION);
return dept;
}
Aggregations