diff --git a/ym-admin/src/main/java/com/cnbm/admin/enums/WhetherEnum.java b/ym-admin/src/main/java/com/cnbm/admin/enums/WhetherEnum.java new file mode 100644 index 0000000..b1b2fc3 --- /dev/null +++ b/ym-admin/src/main/java/com/cnbm/admin/enums/WhetherEnum.java @@ -0,0 +1,52 @@ +package com.cnbm.admin.enums; + +/** + *
+ * 是、否有效枚举 + *
+ * + * @author xcc + * @date 2022年7月5日 + * @since 1.0 + */ +public enum WhetherEnum { + + NO(0, "否"), + + YES(1, "是"); + + private final Integer value; + private final String label; + private final String remark; + + WhetherEnum(final int value, final String label) { + this(value, label, null); + } + + WhetherEnum(final int value, final String label, final String remark) { + this.value = value; + this.label = label; + this.remark = remark; + } + + /** + * @return 数据值 + */ + public Integer getValue() { + return value; + } + + /** + * @return 标签名 + */ + public String getLabel() { + return label; + } + + /** + * @return 备注 + */ + public String getRemark() { + return remark; + } +} diff --git a/ym-admin/src/main/java/com/cnbm/admin/utils/BaseSupportUtils.java b/ym-admin/src/main/java/com/cnbm/admin/utils/BaseSupportUtils.java new file mode 100644 index 0000000..4f86c50 --- /dev/null +++ b/ym-admin/src/main/java/com/cnbm/admin/utils/BaseSupportUtils.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2018. + * http://www.ulabcare.com + */ + +package com.cnbm.admin.utils; + +import com.cnbm.admin.entity.LoginUser; +import com.cnbm.admin.entity.SysUserEntity; +import com.cnbm.admin.enums.WhetherEnum; +import lombok.Builder; +import lombok.Data; +import org.springframework.beans.BeanUtils; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.context.SecurityContextHolder; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * 接口支持基类 + * + * @author jiff + * @date 2018/11/1 + * @since 1.0 + */ +public abstract class BaseSupportUtils { + + /** + * 获取当前登录用户信息 + * + * @return + */ + private static SysUserEntity getLoginUser() { + //登录用户信息 + UsernamePasswordAuthenticationToken authentication = (UsernamePasswordAuthenticationToken) SecurityContextHolder.getContext().getAuthentication(); + LoginUser loginUser = (LoginUser) authentication.getPrincipal(); + return loginUser.getSysUserEntity(); + } + + /** + * 设置公共字段值,一般用于创建新记录,包含以下字段: + * + *
+ * {@link CommonField#enabled}
+ * {@link CommonField#valid}
+ * {@link CommonField#creatorId}
+ * {@link CommonField#creatorName}
+ * {@link CommonField#createTime}
+ * {@link CommonField#updaterId}
+ * {@link CommonField#updaterName}
+ * {@link CommonField#updateTime}
+ *
+ * {@link CommonField#updaterId}
+ * {@link CommonField#updaterName}
+ * {@link CommonField#updateTime}
+ *