Backend Expert Skill (Spring Boot + MyBatis)
This skill provides specialized knowledge for developing and debugging backend services in the RuoYi-Vue ecosystem.
🏗️ Core Principles
-
Layered Architecture: Controller -> Service -> Mapper -> XML -> DB.
-
RuoYi Conventions:
-
Use @PreAuthorize for permission control.
-
Use SecurityUtils.getUserId() to get current user securely.
-
Use AjaxResult for all Controller returns.
-
Use TableDataInfo for pagination returns.
-
MyBatis Strictness: XML SQL columns usually use snake_case , Java entities use camelCase . ResultMaps are mandatory for complex queries.
🛠️ Common Workflows
- Debugging Data Loss (The "Silent Fail")
Context: Frontend sends data, but backend receives null . Checklist:
-
JSON Body: Is the Controller method using @RequestBody ?
-
Getter/Setters: Does the Domain class have getters/setters for new fields?
-
Compilation: CRITICAL. Did the code actually compile? Check for "symbol not found" errors that might be hidden in log files.
-
Mapper XML: explicitly map column="user_name" to property="userName" .
- Controller Pattern
@PreAuthorize("@ss.hasPermi('module:business:add')") @PostMapping public AjaxResult add(@RequestBody MyObject obj) { obj.setCreateBy(SecurityUtils.getUsername()); return toAjax(myService.insert(obj)); }
- Service Pattern
-
Business logic goes here, NOT in Controller.
-
Handle transactional logic with @Transactional .
-
Verify data uniqueness or integrity before calling Mapper.
How to use
Invoke this skill when adding new API endpoints or Entity fields. It forces you to:
-
Verify resultMap in XML.
-
Check SecurityUtils usage.
-
Confirm strict Data Binding.