Commit e904ad51 by huangjinxin

fix:不使用BeanUtil

1 parent 204cc264
......@@ -68,36 +68,26 @@ public class RoleService {
@Transactional
public RoleInfo addRole(RoleInfo roleInfo) {
// RoleEntity roleEntity=new RoleEntity();
// roleEntity.setName("123");
// 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 roleEntity = assembleRole(roleInfo);
log.info("新增角色入参:" + JSONObject.toJSONString(roleEntity));
roleEntity = roleDao.save(roleEntity);
// List<RoleResourceInfo> resourceInfos = roleInfo.getResourceInfos();
// if (CollectionUtils.isNotEmpty(resourceInfos)) {
// for (RoleResourceInfo resourceInfo : resourceInfos) {
// RoleResourceEntity roleResourceEntity = assembleRoleResource(roleEntity.getId(), resourceInfo.getResourceId());
// roleResourceDao.save(roleResourceEntity);
// }
// }
List<RoleResourceInfo> resourceInfos = roleInfo.getResourceInfos();
if (CollectionUtils.isNotEmpty(resourceInfos)) {
for (RoleResourceInfo resourceInfo : resourceInfos) {
RoleResourceEntity roleResourceEntity = assembleRoleResource(roleEntity.getId(), resourceInfo.getResourceId());
roleResourceDao.save(roleResourceEntity);
}
}
roleInfo = BeanUtil.copyProperties(roleEntity, RoleInfo.class);
log.info("新增角色信息:"+JSONObject.toJSONString(roleEntity));
log.info("新增角色信息:" + JSONObject.toJSONString(roleEntity));
return roleInfo;
}
@Transactional(rollbackFor = Exception.class)
public RoleInfo updateRole(RoleInfo roleInfo) {
RoleEntity roleEntity = BeanUtil.copyProperties(roleInfo, RoleEntity.class);
RoleEntity roleEntity = assembleRole(roleInfo);
roleEntity = roleDao.save(roleEntity);
List<RoleResourceInfo> resourceInfos = roleInfo.getResourceInfos();
if (CollectionUtils.isNotEmpty(resourceInfos)) {
......@@ -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) {
Sort sort = Sort.by(Sort.Order.desc("createdTime"));
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!