public class SysUser implements Serializable {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private String userName;
@JsonIgnore
private String password;
private String nickName;
/** * 性别 0-未知 1-male,2-female */
private Integer gender;
/** * 头像地址 */
private String avatarUrl;
private String country;
private String province;
private String city;
@Email
private String email;
private String phone;
private String remarks;
// enabled=1 数据有效 enabled=0 逻辑已删除 数据失效
private Boolean enabled;
private Timestamp lastPasswordResetTime;
private Timestamp createTime;
@Builder.Default
private Timestamp updateTime = Timestamp.valueOf(LocalDateTime.now());
# application.yml
mybatis-plus:
global-config:
db-config:
logic-delete-value: 0 # 在某些表中使用enabled代表数据是否失效,enabled=0 代表逻辑已删除值
logic-not-delete-value: 1 # enabled=1 代表逻辑未删除
public class SysUser implements Serializable {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private String userName;
...
@TableLogic
private Boolean enabled;
@SpringBootTest
@Slf4j
public class TestLogicDelete {
@Test
public void test() {
SysUserMapper sysUserMapper = SpringContextHolder.getBean(SysUserMapper.class);
// 逻辑删除
sysUserMapper.deleteById(15L);
}
}
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://zhuhuix.blog.csdn.net/article/details/120262290
内容来源于网络,如有侵权,请联系作者删除!