Commit 9f5553e6 by huangjinxin

fix:实验代码

1 parent 2acf9bda
......@@ -9,6 +9,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -54,9 +55,9 @@ public class RoleEntity implements Serializable {
/**
* 创建时间
*/
@Column(name = "CREATED_TIME")
@CreatedDate
private Date createdTime;
// @Column(name = "CREATED_TIME")
@Column(name = "CREATED_TIME", nullable = false, updatable = false, columnDefinition = "timestamp default current_timestamp")
private LocalDateTime createdTime;
/**
* 更新人
*/
......@@ -65,9 +66,9 @@ public class RoleEntity implements Serializable {
/**
* 更新时间
*/
@Column(name = "UPDATED_TIME")
@LastModifiedDate
private Date updatedTime;
// @Column(name = "UPDATED_TIME")
@Column(name = "UPDATED_TIME", nullable = false, columnDefinition = "timestamp default current_timestamp on update current_timestamp")
private LocalDateTime updatedTime;
/**
* 备注
......
......@@ -31,6 +31,7 @@ import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
......@@ -63,8 +64,8 @@ public class RoleService {
@Autowired
RedisService redisService;
@Autowired
private DataSourceTransactionManager dataSourceTransactionManager;
// @Autowired
// private DataSourceTransactionManager dataSourceTransactionManager;
/**
* 失效时间ms
*/
......@@ -79,7 +80,7 @@ public class RoleService {
RoleEntity roleEntity = new RoleEntity();
roleEntity.setName(name);
roleEntity.setCreatedBy(createdBy);
roleEntity.setCreatedTime(new Date());
roleEntity.setCreatedTime(LocalDateTime.now());
roleEntity.setNotes(notes);
// RoleEntity roleEntity = assembleRole(roleInfo);
log.info("新增角色入参:" + JSONObject.toJSONString(roleEntity));
......@@ -133,11 +134,6 @@ public class RoleService {
@Transactional(rollbackFor = Exception.class)
public RoleInfo deleteRole2(RoleInfo roleInfo) {
DefaultTransactionDefinition defaultTransactionDefinition = new DefaultTransactionDefinition();
defaultTransactionDefinition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
TransactionStatus transaction = dataSourceTransactionManager.getTransaction(defaultTransactionDefinition);
String name = roleInfo.getName();
String createdBy = roleInfo.getCreatedBy();
String notes = roleInfo.getNotes();
......@@ -160,15 +156,6 @@ public class RoleService {
}
log.info("新增角色信息:" + JSONObject.toJSONString(roleInfo));
try {
// 业务代码
// 手动提交事务
dataSourceTransactionManager.commit(transaction);
} catch (Exception e) {
// 手动回滚事务
dataSourceTransactionManager.rollback(transaction);
}
return roleInfo;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!