Java后端正式版:表名规范化 + Flyway启用 + 数据库导出

- 所有实体 @TableName 改为规范格式(t_sys_/t_biz_/t_ugc_/t_user_)
- Flyway 启用(V1重命名+V2新审计字段)
- BaseEntity 启用新审计字段(create_by/update_by/deleted)
- 逻辑删除启用(deleted字段)
- SysUserMapper.xml 和 SysLogMapper SQL 更新为新表名
- 导出规范化数据库: backend-java/src/main/resources/db/competition_management_java.sql
  - 41张表,全部 t_{module}_ 前缀
  - 含完整数据(用户/租户/权限/活动/作品/评分等)
  - admin 密码统一为 admin123

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
aid 2026-04-02 14:57:26 +08:00
parent a6b056520d
commit 58c232dadc
47 changed files with 1872 additions and 69 deletions

View File

@ -8,7 +8,7 @@ import java.time.LocalDateTime;
/** /**
* 基础实体类所有实体继承此类 * 基础实体类所有实体继承此类
* 当前阶段使用现有数据库列名新审计字段暂不映射 Flyway 迁移后启用 * 包含新审计字段Java规范和旧审计字段过渡期兼容
*/ */
@Data @Data
public abstract class BaseEntity implements Serializable { public abstract class BaseEntity implements Serializable {
@ -17,21 +17,22 @@ public abstract class BaseEntity implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private Long id; private Long id;
// ====== 新审计字段列尚未存在暂不映射到数据库 ====== // ====== 新审计字段Java 规范 ======
/** 创建人账号(待 Flyway V2 后启用) */ /** 创建人账号 */
@TableField(exist = false) @TableField(value = "create_by", fill = FieldFill.INSERT)
private String createBy; private String createBy;
/** 更新人账号(待 Flyway V2 后启用) */ /** 更新人账号 */
@TableField(exist = false) @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
private String updateBy; private String updateBy;
/** 逻辑删除标识(待 Flyway V2 后启用) */ /** 逻辑删除标识0-未删除1-已删除) */
@TableField(exist = false) @TableLogic
@TableField(value = "deleted", fill = FieldFill.INSERT)
private Integer deleted; private Integer deleted;
// ====== 现有审计字段与当前数据库一致 ====== // ====== 旧审计字段过渡期保留 ======
/** 创建人 ID */ /** 创建人 ID */
@TableField(value = "creator", fill = FieldFill.INSERT) @TableField(value = "creator", fill = FieldFill.INSERT)
@ -45,7 +46,7 @@ public abstract class BaseEntity implements Serializable {
@TableField(value = "create_time", fill = FieldFill.INSERT) @TableField(value = "create_time", fill = FieldFill.INSERT)
private LocalDateTime createTime; private LocalDateTime createTime;
/** 修改时间(数据库列名为 modify_time */ /** 修改时间 */
@TableField(value = "modify_time", fill = FieldFill.INSERT_UPDATE) @TableField(value = "modify_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime modifyTime; private LocalDateTime modifyTime;

View File

@ -19,8 +19,15 @@ public class AuditMetaObjectHandler implements MetaObjectHandler {
@Override @Override
public void insertFill(MetaObject metaObject) { public void insertFill(MetaObject metaObject) {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
String username = SecurityUtil.getCurrentUsername();
Long userId = SecurityUtil.getCurrentUserIdOrNull(); Long userId = SecurityUtil.getCurrentUserIdOrNull();
// 新审计字段
this.strictInsertFill(metaObject, "createBy", String.class, username);
this.strictInsertFill(metaObject, "updateBy", String.class, username);
this.strictInsertFill(metaObject, "deleted", Integer.class, 0);
// 旧审计字段
this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, now); this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, now);
this.strictInsertFill(metaObject, "modifyTime", LocalDateTime.class, now); this.strictInsertFill(metaObject, "modifyTime", LocalDateTime.class, now);
this.strictInsertFill(metaObject, "validState", Integer.class, 1); this.strictInsertFill(metaObject, "validState", Integer.class, 1);
@ -34,8 +41,13 @@ public class AuditMetaObjectHandler implements MetaObjectHandler {
@Override @Override
public void updateFill(MetaObject metaObject) { public void updateFill(MetaObject metaObject) {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
String username = SecurityUtil.getCurrentUsername();
Long userId = SecurityUtil.getCurrentUserIdOrNull(); Long userId = SecurityUtil.getCurrentUserIdOrNull();
// 新审计字段
this.strictUpdateFill(metaObject, "updateBy", String.class, username);
// 旧审计字段
this.strictUpdateFill(metaObject, "modifyTime", LocalDateTime.class, now); this.strictUpdateFill(metaObject, "modifyTime", LocalDateTime.class, now);
if (userId != null) { if (userId != null) {

View File

@ -16,7 +16,7 @@ import java.util.List;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName(value = "t_contest", autoResultMap = true) @TableName(value = "t_biz_contest", autoResultMap = true)
public class BizContest extends BaseEntity { public class BizContest extends BaseEntity {
/** 赛事名称(唯一) */ /** 赛事名称(唯一) */

View File

@ -8,7 +8,7 @@ import lombok.EqualsAndHashCode;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("t_contest_attachment") @TableName("t_biz_contest_attachment")
public class BizContestAttachment extends BaseEntity { public class BizContestAttachment extends BaseEntity {
@TableField("contest_id") @TableField("contest_id")

View File

@ -10,7 +10,7 @@ import java.time.LocalDateTime;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("t_contest_notice") @TableName("t_biz_contest_notice")
public class BizContestNotice extends BaseEntity { public class BizContestNotice extends BaseEntity {
@TableField("contest_id") @TableField("contest_id")

View File

@ -10,7 +10,7 @@ import java.time.LocalDateTime;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("t_contest_registration") @TableName("t_biz_contest_registration")
public class BizContestRegistration extends BaseEntity { public class BizContestRegistration extends BaseEntity {
@TableField("contest_id") @TableField("contest_id")

View File

@ -7,7 +7,7 @@ import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Data @Data
@TableName("t_contest_registration_teacher") @TableName("t_biz_contest_registration_teacher")
public class BizContestRegistrationTeacher implements Serializable { public class BizContestRegistrationTeacher implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -8,7 +8,7 @@ import lombok.EqualsAndHashCode;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("t_contest_team") @TableName("t_biz_contest_team")
public class BizContestTeam extends BaseEntity { public class BizContestTeam extends BaseEntity {
@TableField("tenant_id") @TableField("tenant_id")

View File

@ -7,7 +7,7 @@ import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Data @Data
@TableName("t_contest_team_member") @TableName("t_biz_contest_team_member")
public class BizContestTeamMember implements Serializable { public class BizContestTeamMember implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -13,7 +13,7 @@ import java.util.List;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName(value = "t_contest_work", autoResultMap = true) @TableName(value = "t_biz_contest_work", autoResultMap = true)
public class BizContestWork extends BaseEntity { public class BizContestWork extends BaseEntity {
@TableField("tenant_id") @TableField("tenant_id")

View File

@ -7,7 +7,7 @@ import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Data @Data
@TableName("t_contest_work_attachment") @TableName("t_biz_contest_work_attachment")
public class BizContestWorkAttachment implements Serializable { public class BizContestWorkAttachment implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -11,7 +11,7 @@ import java.time.LocalDateTime;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName(value = "t_homework", autoResultMap = true) @TableName(value = "t_biz_homework", autoResultMap = true)
public class BizHomework extends BaseEntity { public class BizHomework extends BaseEntity {
@TableField("tenant_id") @TableField("tenant_id")

View File

@ -9,7 +9,7 @@ import lombok.EqualsAndHashCode;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName(value = "t_homework_review_rule", autoResultMap = true) @TableName(value = "t_biz_homework_review_rule", autoResultMap = true)
public class BizHomeworkReviewRule extends BaseEntity { public class BizHomeworkReviewRule extends BaseEntity {
@TableField("tenant_id") @TableField("tenant_id")

View File

@ -12,7 +12,7 @@ import java.time.LocalDateTime;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName(value = "t_homework_score", autoResultMap = true) @TableName(value = "t_biz_homework_score", autoResultMap = true)
public class BizHomeworkScore extends BaseEntity { public class BizHomeworkScore extends BaseEntity {
@TableField("tenant_id") @TableField("tenant_id")

View File

@ -12,7 +12,7 @@ import java.time.LocalDateTime;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName(value = "t_homework_submission", autoResultMap = true) @TableName(value = "t_biz_homework_submission", autoResultMap = true)
public class BizHomeworkSubmission extends BaseEntity { public class BizHomeworkSubmission extends BaseEntity {
@TableField("tenant_id") @TableField("tenant_id")

View File

@ -10,7 +10,7 @@ import java.math.BigDecimal;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("t_contest_judge") @TableName("t_biz_contest_judge")
public class BizContestJudge extends BaseEntity { public class BizContestJudge extends BaseEntity {
@TableField("contest_id") @TableField("contest_id")

View File

@ -9,7 +9,7 @@ import lombok.EqualsAndHashCode;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName(value = "t_contest_review_rule", autoResultMap = true) @TableName(value = "t_biz_contest_review_rule", autoResultMap = true)
public class BizContestReviewRule extends BaseEntity { public class BizContestReviewRule extends BaseEntity {
@TableField("tenant_id") @TableField("tenant_id")

View File

@ -10,7 +10,7 @@ import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Data @Data
@TableName("t_contest_work_judge_assignment") @TableName("t_biz_contest_work_judge_assignment")
public class BizContestWorkJudgeAssignment implements Serializable { public class BizContestWorkJudgeAssignment implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -12,7 +12,7 @@ import java.time.LocalDateTime;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName(value = "t_contest_work_score", autoResultMap = true) @TableName(value = "t_biz_contest_work_score", autoResultMap = true)
public class BizContestWorkScore extends BaseEntity { public class BizContestWorkScore extends BaseEntity {
@TableField("tenant_id") @TableField("tenant_id")

View File

@ -10,7 +10,7 @@ import java.math.BigDecimal;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("t_preset_comment") @TableName("t_biz_preset_comment")
public class BizPresetComment extends BaseEntity { public class BizPresetComment extends BaseEntity {
@TableField("contest_id") @TableField("contest_id")

View File

@ -11,7 +11,7 @@ import lombok.EqualsAndHashCode;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("configs") @TableName("t_sys_config")
public class SysConfig extends BaseEntity { public class SysConfig extends BaseEntity {
/** 租户 ID */ /** 租户 ID */

View File

@ -13,7 +13,7 @@ import java.util.List;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("dicts") @TableName("t_sys_dict")
public class SysDict extends BaseEntity { public class SysDict extends BaseEntity {
/** 租户 ID */ /** 租户 ID */

View File

@ -11,7 +11,7 @@ import lombok.EqualsAndHashCode;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("dict_items") @TableName("t_sys_dict_item")
public class SysDictItem extends BaseEntity { public class SysDictItem extends BaseEntity {
/** 字典 ID */ /** 字典 ID */

View File

@ -10,7 +10,7 @@ import java.time.LocalDateTime;
* 系统日志实体不继承 BaseEntity字段结构不同 * 系统日志实体不继承 BaseEntity字段结构不同
*/ */
@Data @Data
@TableName("logs") @TableName("t_sys_log")
public class SysLog implements Serializable { public class SysLog implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -13,7 +13,7 @@ import java.util.List;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("menus") @TableName("t_sys_menu")
public class SysMenu extends BaseEntity { public class SysMenu extends BaseEntity {
/** 菜单名称 */ /** 菜单名称 */

View File

@ -11,7 +11,7 @@ import lombok.EqualsAndHashCode;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("permissions") @TableName("t_sys_permission")
public class SysPermission extends BaseEntity { public class SysPermission extends BaseEntity {
/** 租户 ID */ /** 租户 ID */

View File

@ -11,7 +11,7 @@ import lombok.EqualsAndHashCode;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("roles") @TableName("t_sys_role")
public class SysRole extends BaseEntity { public class SysRole extends BaseEntity {
/** 租户 ID */ /** 租户 ID */

View File

@ -9,7 +9,7 @@ import java.io.Serializable;
* 角色权限关联实体 * 角色权限关联实体
*/ */
@Data @Data
@TableName("role_permissions") @TableName("t_sys_role_permission")
public class SysRolePermission implements Serializable { public class SysRolePermission implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -11,7 +11,7 @@ import lombok.EqualsAndHashCode;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("tenants") @TableName("t_sys_tenant")
public class SysTenant extends BaseEntity { public class SysTenant extends BaseEntity {
/** 租户名称 */ /** 租户名称 */

View File

@ -9,7 +9,7 @@ import java.io.Serializable;
* 租户菜单关联实体 * 租户菜单关联实体
*/ */
@Data @Data
@TableName("tenant_menus") @TableName("t_sys_tenant_menu")
public class SysTenantMenu implements Serializable { public class SysTenantMenu implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -13,7 +13,7 @@ import java.time.LocalDate;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("users") @TableName("t_sys_user")
public class SysUser extends BaseEntity { public class SysUser extends BaseEntity {
/** 租户 ID */ /** 租户 ID */

View File

@ -9,7 +9,7 @@ import java.io.Serializable;
* 用户角色关联实体 * 用户角色关联实体
*/ */
@Data @Data
@TableName("user_roles") @TableName("t_sys_user_role")
public class SysUserRole implements Serializable { public class SysUserRole implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -14,10 +14,10 @@ import java.util.Map;
public interface SysLogMapper extends BaseMapper<SysLog> { public interface SysLogMapper extends BaseMapper<SysLog> {
/** 按操作类型统计Top 10 */ /** 按操作类型统计Top 10 */
@Select("SELECT action, COUNT(*) AS count FROM logs WHERE create_time >= #{since} GROUP BY action ORDER BY count DESC LIMIT 10") @Select("SELECT action, COUNT(*) AS count FROM t_sys_log WHERE create_time >= #{since} GROUP BY action ORDER BY count DESC LIMIT 10")
List<Map<String, Object>> selectActionStats(@Param("since") LocalDateTime since); List<Map<String, Object>> selectActionStats(@Param("since") LocalDateTime since);
/** 按日期统计 */ /** 按日期统计 */
@Select("SELECT DATE(create_time) AS date, COUNT(*) AS count FROM logs WHERE create_time >= #{since} GROUP BY DATE(create_time) ORDER BY date") @Select("SELECT DATE(create_time) AS date, COUNT(*) AS count FROM t_sys_log WHERE create_time >= #{since} GROUP BY DATE(create_time) ORDER BY date")
List<Map<String, Object>> selectDailyStats(@Param("since") LocalDateTime since); List<Map<String, Object>> selectDailyStats(@Param("since") LocalDateTime since);
} }

View File

@ -10,7 +10,7 @@ import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Data @Data
@TableName("content_review_logs") @TableName("t_ugc_review_log")
public class UgcReviewLog implements Serializable { public class UgcReviewLog implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -10,7 +10,7 @@ import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Data @Data
@TableName("work_tags") @TableName("t_ugc_tag")
public class UgcTag implements Serializable { public class UgcTag implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -11,7 +11,7 @@ import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Data @Data
@TableName(value = "user_works", autoResultMap = true) @TableName(value = "t_ugc_work", autoResultMap = true)
public class UgcWork implements Serializable { public class UgcWork implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -10,7 +10,7 @@ import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Data @Data
@TableName("user_work_comments") @TableName("t_ugc_work_comment")
public class UgcWorkComment implements Serializable { public class UgcWorkComment implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -10,7 +10,7 @@ import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Data @Data
@TableName("user_work_favorites") @TableName("t_ugc_work_favorite")
public class UgcWorkFavorite implements Serializable { public class UgcWorkFavorite implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -10,7 +10,7 @@ import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Data @Data
@TableName("user_work_likes") @TableName("t_ugc_work_like")
public class UgcWorkLike implements Serializable { public class UgcWorkLike implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -9,7 +9,7 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@TableName("user_work_pages") @TableName("t_ugc_work_page")
public class UgcWorkPage implements Serializable { public class UgcWorkPage implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -10,7 +10,7 @@ import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Data @Data
@TableName("user_work_reports") @TableName("t_ugc_work_report")
public class UgcWorkReport implements Serializable { public class UgcWorkReport implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -9,7 +9,7 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
@TableName("work_tag_relations") @TableName("t_ugc_work_tag")
public class UgcWorkTag implements Serializable { public class UgcWorkTag implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -11,7 +11,7 @@ import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Data @Data
@TableName("children") @TableName("t_user_child")
public class UserChild implements Serializable { public class UserChild implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -10,7 +10,7 @@ import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@Data @Data
@TableName("user_parent_child") @TableName("t_user_parent_child")
public class UserParentChild implements Serializable { public class UserParentChild implements Serializable {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)

View File

@ -13,9 +13,9 @@ spring:
time-zone: Asia/Shanghai time-zone: Asia/Shanghai
default-property-inclusion: non_null default-property-inclusion: non_null
# Flyway 数据库迁移(暂不启用,先用现有表名测试) # Flyway 数据库迁移
flyway: flyway:
enabled: false enabled: true
locations: classpath:db/migration locations: classpath:db/migration
baseline-on-migrate: true baseline-on-migrate: true
baseline-version: 0 baseline-version: 0
@ -35,10 +35,9 @@ mybatis-plus:
global-config: global-config:
db-config: db-config:
id-type: auto id-type: auto
# 逻辑删除暂不启用(待 Flyway V2 添加 deleted 列后启用) logic-delete-field: deleted
# logic-delete-field: deleted logic-delete-value: 1
# logic-delete-value: 1 logic-not-delete-value: 0
# logic-not-delete-value: 0
# JWT 配置 # JWT 配置
jwt: jwt:

File diff suppressed because one or more lines are too long

View File

@ -5,9 +5,9 @@
<!-- 查询用户的权限码列表 --> <!-- 查询用户的权限码列表 -->
<select id="selectPermissionsByUserId" resultType="java.lang.String"> <select id="selectPermissionsByUserId" resultType="java.lang.String">
SELECT DISTINCT p.code SELECT DISTINCT p.code
FROM permissions p FROM t_sys_permission p
JOIN role_permissions rp ON rp.permission_id = p.id JOIN t_sys_role_permission rp ON rp.permission_id = p.id
JOIN user_roles ur ON ur.role_id = rp.role_id JOIN t_sys_user_role ur ON ur.role_id = rp.role_id
WHERE ur.user_id = #{userId} WHERE ur.user_id = #{userId}
AND p.valid_state = 1 AND p.valid_state = 1
</select> </select>
@ -15,8 +15,8 @@
<!-- 查询用户的角色码列表 --> <!-- 查询用户的角色码列表 -->
<select id="selectRolesByUserId" resultType="java.lang.String"> <select id="selectRolesByUserId" resultType="java.lang.String">
SELECT DISTINCT r.code SELECT DISTINCT r.code
FROM roles r FROM t_sys_role r
JOIN user_roles ur ON ur.role_id = r.id JOIN t_sys_user_role ur ON ur.role_id = r.id
WHERE ur.user_id = #{userId} WHERE ur.user_id = #{userId}
AND r.valid_state = 1 AND r.valid_state = 1
</select> </select>
@ -29,8 +29,8 @@
u.city, u.birthday, u.gender, u.avatar, u.organization, u.status, u.city, u.birthday, u.gender, u.avatar, u.organization, u.status,
u.valid_state AS validState, u.create_time AS createTime, u.modify_time AS updateTime, u.valid_state AS validState, u.create_time AS createTime, u.modify_time AS updateTime,
t.name AS tenantName, t.code AS tenantCode, t.tenant_type AS tenantType, t.is_super AS tenantIsSuper t.name AS tenantName, t.code AS tenantCode, t.tenant_type AS tenantType, t.is_super AS tenantIsSuper
FROM users u FROM t_sys_user u
LEFT JOIN tenants t ON t.id = u.tenant_id LEFT JOIN t_sys_tenant t ON t.id = u.tenant_id
<where> <where>
u.valid_state = 1 AND (1=1) u.valid_state = 1 AND (1=1)
<if test="params.tenantId != null"> <if test="params.tenantId != null">
@ -71,8 +71,8 @@
u.valid_state AS validState, u.create_time AS createTime, u.modify_time AS updateTime, u.valid_state AS validState, u.create_time AS createTime, u.modify_time AS updateTime,
t.id AS tenantId, t.name AS tenantName, t.code AS tenantCode, t.id AS tenantId, t.name AS tenantName, t.code AS tenantCode,
t.tenant_type AS tenantType, t.is_super AS tenantIsSuper t.tenant_type AS tenantType, t.is_super AS tenantIsSuper
FROM users u FROM t_sys_user u
LEFT JOIN tenants t ON t.id = u.tenant_id LEFT JOIN t_sys_tenant t ON t.id = u.tenant_id
WHERE u.id = #{userId} WHERE u.id = #{userId}
AND u.valid_state = 1 AND u.valid_state = 1
AND (1=1) AND (1=1)
@ -86,7 +86,7 @@
SELECT SELECT
u.id, u.tenant_id AS tenantId, u.username, u.password, u.nickname, u.id, u.tenant_id AS tenantId, u.username, u.password, u.nickname,
u.email, u.avatar, u.status, u.valid_state AS validState u.email, u.avatar, u.status, u.valid_state AS validState
FROM users u FROM t_sys_user u
WHERE u.username = #{username} WHERE u.username = #{username}
AND u.valid_state = 1 AND u.valid_state = 1
AND (1=1) AND (1=1)