Commit a8831e5e by huangjinxin

fix:事务校验

1 parent c393a76a
package com.dituhui.pea.util;
import java.util.UUID;
/**
* uuid生成工具
* @author guoping
*
*/
public class UUIDUtil {
public static String getUuid() {
UUID uuid = UUID.randomUUID();
String sud = uuid.toString();
sud = sud.replaceAll("-", "");
return sud;
}
public static String getUid(){
return UUID.randomUUID().toString().replace("-", "").toLowerCase();
}
public static void main(String[] args) {
System.out.println(getUuid());
}
}
......@@ -15,7 +15,9 @@ import com.dituhui.pea.pojo.role.RoleResourceInfo;
import com.dituhui.pea.user.commom.RedisService;
import com.dituhui.pea.user.dao.*;
import com.dituhui.pea.user.entity.*;
import com.dituhui.pea.util.UUIDUtil;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -27,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
......@@ -36,6 +39,7 @@ import java.util.stream.Collectors;
* @author zl
*/
@Service
@Slf4j
public class RoleService {
@Autowired
......@@ -64,8 +68,21 @@ public class RoleService {
@Transactional
public RoleInfo addRole(RoleInfo roleInfo) {
RoleEntity roleEntity = BeanUtil.copyProperties(roleInfo, RoleEntity.class);
log.info("新增角色入参:"+JSONObject.toJSONString(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);
roleEntity = roleDao.save(roleEntity);
log.info("新增角色信息:"+JSONObject.toJSONString(roleEntity));
// // List<RoleResourceInfo> resourceInfos = roleInfo.getResourceInfos();
// // if (CollectionUtils.isNotEmpty(resourceInfos)) {
// // for (RoleResourceInfo resourceInfo : resourceInfos) {
......@@ -73,7 +90,7 @@ public class RoleService {
// // roleResourceDao.save(roleResourceEntity);
// // }
// // }
roleInfo = BeanUtil.copyProperties(roleEntity, RoleInfo.class);
// roleInfo = BeanUtil.copyProperties(roleEntity, RoleInfo.class);
return roleInfo;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!