Commit e904ad51 by huangjinxin

fix:不使用BeanUtil

1 parent 204cc264
...@@ -68,36 +68,26 @@ public class RoleService { ...@@ -68,36 +68,26 @@ public class RoleService {
@Transactional @Transactional
public RoleInfo addRole(RoleInfo roleInfo) { public RoleInfo addRole(RoleInfo roleInfo) {
// RoleEntity roleEntity=new RoleEntity(); RoleEntity roleEntity = assembleRole(roleInfo);
// roleEntity.setName("123"); log.info("新增角色入参:" + JSONObject.toJSONString(roleEntity));
// roleEntity.setId(UUIDUtil.getUuid());
// roleEntity.setCreatedBy("212121");
// roleEntity.setUpdatedBy("212121");
// roleEntity.setCreatedTime(new Date());
// roleEntity.setUpdatedTime(new Date());
// roleEntity.setGroupId("1q2hk");
// roleEntity.setNotes("1q2hk");
// roleEntity.setExtra("1q2hk");
RoleEntity roleEntity = BeanUtil.copyProperties(roleInfo, RoleEntity.class);
log.info("新增角色入参:"+JSONObject.toJSONString(roleEntity));
roleEntity = roleDao.save(roleEntity); roleEntity = roleDao.save(roleEntity);
// List<RoleResourceInfo> resourceInfos = roleInfo.getResourceInfos(); List<RoleResourceInfo> resourceInfos = roleInfo.getResourceInfos();
// if (CollectionUtils.isNotEmpty(resourceInfos)) { if (CollectionUtils.isNotEmpty(resourceInfos)) {
// for (RoleResourceInfo resourceInfo : resourceInfos) { for (RoleResourceInfo resourceInfo : resourceInfos) {
// RoleResourceEntity roleResourceEntity = assembleRoleResource(roleEntity.getId(), resourceInfo.getResourceId()); RoleResourceEntity roleResourceEntity = assembleRoleResource(roleEntity.getId(), resourceInfo.getResourceId());
// roleResourceDao.save(roleResourceEntity); roleResourceDao.save(roleResourceEntity);
// } }
// } }
roleInfo = BeanUtil.copyProperties(roleEntity, RoleInfo.class); roleInfo = BeanUtil.copyProperties(roleEntity, RoleInfo.class);
log.info("新增角色信息:"+JSONObject.toJSONString(roleEntity)); log.info("新增角色信息:" + JSONObject.toJSONString(roleEntity));
return roleInfo; return roleInfo;
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public RoleInfo updateRole(RoleInfo roleInfo) { public RoleInfo updateRole(RoleInfo roleInfo) {
RoleEntity roleEntity = BeanUtil.copyProperties(roleInfo, RoleEntity.class); RoleEntity roleEntity = assembleRole(roleInfo);
roleEntity = roleDao.save(roleEntity); roleEntity = roleDao.save(roleEntity);
List<RoleResourceInfo> resourceInfos = roleInfo.getResourceInfos(); List<RoleResourceInfo> resourceInfos = roleInfo.getResourceInfos();
if (CollectionUtils.isNotEmpty(resourceInfos)) { if (CollectionUtils.isNotEmpty(resourceInfos)) {
...@@ -255,6 +245,16 @@ public class RoleService { ...@@ -255,6 +245,16 @@ public class RoleService {
} }
private RoleEntity assembleRole(RoleInfo roleInfo) {
RoleEntity roleEntity = new RoleEntity();
roleEntity.setName(roleInfo.getName());
roleEntity.setCreatedBy(roleInfo.getCreatedBy());
roleEntity.setCreatedTime(new Date());
roleEntity.setNotes(roleInfo.getNotes());
return roleEntity;
}
public PageResult<RoleInfo> listRole(PageRequest pageRequest) { public PageResult<RoleInfo> listRole(PageRequest pageRequest) {
Sort sort = Sort.by(Sort.Order.desc("createdTime")); Sort sort = Sort.by(Sort.Order.desc("createdTime"));
Pageable pageable = org.springframework.data.domain.PageRequest.of(pageRequest.getPage() - 1, pageRequest.getSize(), sort); Pageable pageable = org.springframework.data.domain.PageRequest.of(pageRequest.getPage() - 1, pageRequest.getSize(), sort);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!