refactor: layered model (dto/vo/bo/po), MyBatis-Plus migration and unified audit fields - #156
Merged
Merged
Conversation
…elds - relocate ErrorCode from common to exception package and update all imports - add model package scaffold (po/vo): BasePo carrying the five audit fields, SysUserPo extending it, BaseVo and ResultVo; deprecate entity.SysUser - implement JsonUtil on Jackson ObjectMapper with typed (de)serialization - add creator_id/updater_id/is_deleted to sys_user and replace unique key uk_idp with non-unique index idx_idp so soft-deleted users can be recreated - add idempotent sys_user audit-column migrations to migration_compatibility.sql
- turn BaseVo into a marker interface; make ResultVo Serializable with success()/success(data)/error() factories - add BaseVoResponseAdvice (ResponseBodyAdvice) to wrap controller responses whose declared return type implements BaseVo - migrate global exception handling to ResultVo with null data, except field validation which keeps the legacy Result payload during the gray migration - mark common.Result as deprecated
- delete common.UserContext (static ThreadLocal) and replace it with a Spring-managed UserContextHolder implementing ThreadLocalHolder<> - add model.bo.UserContextBo as the user-context projection; make SysUserService.selectAuthProjection return it - inject UserContextHolder into AuthInterceptor, AgentController, AuthController and TableExportController instead of static accessors - add model.converter.UserConverter MapStruct placeholder - mark legacy dto/entity packages deprecated via package-info; drop the class-level @deprecated on entity.SysUser - note holder/converter as auxiliary model packages - AGENTS.md: prefer official Spring Boot starters; route new data entities to io.github.malonetalk.model
- replace mybatis-spring-boot-starter with mybatis-plus-spring-boot4-starter 3.5.17; swap the pagehelper starter for pagehelper core and register PageInterceptor manually - enable MP pagination via PaginationInnerInterceptor(MYSQL); it coexists with PageHelper (IPage-param vs ThreadLocal triggers) - route jsqlparser through mybatis-plus-jsqlparser (5.2, pinned via dependencyManagement); adapt SqlExecutor to the 5.2 WithItem API - annotate BasePo audit fields with @TableField(fill=...) and @TableLogic; add BasePoConstants for the field names - add AuditMetaObjectHandler to fill creator/updater ids and timestamps (null-only, tolerant of missing user context) - make SysUserPo an MP entity (@TableName, @TableId(AUTO), is_super_admin) - rename mybatis.* config to mybatis-plus.* and widen type-aliases-package - add model.bo.SysUserBo and a mapper package note; apply spotless license headers/formatting; ignore local agents/ notes
- add AuditableMapper<T extends BasePo> as the project base mapper; SysUserMapper extends it and exposes CRUD through BaseMapper, keeping only the two shared default helpers (selectLocalByUsername, updatePassword) - move user requests to model.dto (*Dto) and responses to model.vo (*Vo); controllers now take Dto and return BaseVo, wrapped by BaseVoResponseAdvice - service works on SysUserBo; UserConverter maps PO<->BO, BO->VO and UserContextBo->UserInfoVo; BatchQueryConverter maps MP IPage to BatchQueryVo - move initial-admin bootstrap from AdminBootstrapRunner into SysUserService.bootstrapInitialAdmin; AuthController no longer uses the mapper - route writes through entity-based insert/updateById so AuditMetaObjectHandler fills creator/updater/timestamps (updatePassword and updateStatus included) - replace listAll with a paged query (BaseBatchQueryDto -> BatchQueryVo<UserVo>) - delete entity.SysUser and mapper/SysUserMapper.xml; deprecate the legacy convertor package in favour of model.converter
- listUsers now takes page/pageSize/sortOrder and returns PageResponse - UserManage adds el-pagination and reads items/total from the paged result - add BooleanVo to api types; resetPassword/updateStatus/changePassword now typed against BooleanVo
- update(Wrapper) delegates to update(newEntityInstance(), wrapper) so the MetaObjectHandler fills the audit fields - delete(Wrapper) selects the matching primary keys first and delegates to deleteByIds, which MyBatis-Plus audits natively; deleteByMap inherits this path - resolve T via ReflectionKit and instantiate through TableInfo.newInstance()
|
Thank you for your contribution! We will review your request as soon as possible. Please review the code yourself using ponytail https://github.com/DietrichGebert/ponytail. |
Member
Author
|
@mengnankkkk ptal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
related #155 #144 #38
io.github.malonetalk.model.{dto,vo,bo,po}分层模型,逐步替代旧的dto/entity包;旧包标记废弃,确认无引用后再删除。BaseVo+ResultVo,Controller 直接返回 VO,由BaseVoResponseAdvice自动包装,异常也返回同一格式。SysUser链为试点,实体用SysUserPo、Service 用 BO、Controller 入参 Dto / 出参 Vo,转换交给 MapStruct。BasePo上的审计字段由MetaObjectHandler自动填充,项目级AuditableMapper补齐了 wrapper-only 的 update/delete 审计。