Backend Development
Framework Architecture Overview:
- Client sends HTTP request to Controller layer
- Controller receives the request and passes data to Service layer
- Service layer handles business logic, may interact with DAO layer for database operations or Client layer for remote service calls
- DAO layer executes database operations and returns results to Service layer
- Service layer returns processed results (or remote service responses) to Controller
- Controller wraps results in to HTTP response and sends back to client
1. Git Access Setup
Configure SSH key authentication for repository access:
Generate SSH key pair:
ssh-keygen -o -t rsa -b 4096 -C "your_email@example.com"
Navigate to SSH directory and retrieve public key:
cd ~/.ssh/
cat id_rsa.pub
Add the public key content to Git repository Settings under SSH Keys section.
2. Branch Management
Create local branch:
git checkout -b branchname
Create corresponding remote branch and link them:
git branch --set-upstream-to=origin/branch branchname
git push -u
Remove remote branch:
git push origin --delete branchname
Remove local brench:
git branch -d branchname
3. Configuring Git User Information
View current configuration:
git config --global --list
git config --global user.name
git config --global user.email
Modify configuration:
git config --global user.name developer_name
git config --global user.email developer@company.com
4. Maven Configuration
Configure company-specific settings.xml in IDEA:
- Navigate to Settings → Build, Execution, Deployment → Build Tools → Maven
- Update "User settings file" to point to the company's settings.xml
- Verify local repository path (Default: ${user.home}/.m2/repository)
- Reload Maven after configuration changes
5. Starting Spring Boot Application
Locate the main application class:
/Users/developer/workspace/project/src/main/java/com/company/app/Application.java
Monitor console output for successful port binding (typically 8090).
6. System Configuration
Review application configuration:
/Users/developer/workspace/project/src/main/resources/application.yaml
Check API endpoint definitions in contorllers:
/Users/developer/workspace/project/src/main/java/com/company/app/controller/TrackController.java
API endpoint format: projectname (servlet context-path) + commonname + urlpath
Access in browser:
http://127.0.0.1:8090/projectname/urlpath?pageNum=1&pageSize=10
7. Code Implementation Flow
Step 1 - Controller DefinitionDefine QA-designed endpoints with request/response models in /model/request/.
Step 2 - Service DefinitionDefine service methods, handle response data validation. Use invokeSilent() when data exists, metaResponse() for null data scenarios.
Step 3 - Client DefinitionDefine remote service integrations with domain, endpoint paths, parameters, and return types.
Step 4 - Application StartupRun the main Application class. Console output displays server status indicating successful port binding.
Step 5 - TestingAccess endpoint in browser:
http://127.0.0.1:8090/project/v1/user/token/invalid?userId=xxx&oauthType=all
8. Refactoring
Rename methods with automatic reference updates:
- Right-click method name → Refactor → Rename
- Select all references when prompted
9. Coding Standards
Controller Layer:
import org.springframework.web.bind.annotation.*;
// Endpoint 1: Force logout
@GetMapping(Apis.API_USERFORCELOGOUT)
public MetaResponse forceLogout(ForceLogoutRequest request) {
return MetaResponse.success();
}
// Endpoint 2: Account binding history
@GetMapping(Apis.API_USERACCOUNTBH)
public MetaResponse accountHistory(AccountHistoryRequest request) {
return userService.getAccountHistory(request);
}
// Endpoint 3: User center phone query
// GET parameters merge with POST body
@PostMapping(Apis.API_USERPHONEQUERY)
public MetaResponse<UserCenterResp> phoneQuery(
@RequestParam("opId") Long operatorId,
@RequestParam(required = false) Long userId,
@Valid @RequestBody PhoneQueryRequest request) {
return userService.queryPhone(operatorId, userId, request);
}
Service Layer:
// User management - account ban status (GET)
public MetaResponse getBanStatus(BanStatusRequest request) {
Util.check(NumberUtil.isPositive(request.getUserId()), "userId is required");
log.info("Processing user id: {}", request.getUserId());
try {
MetaResponse<JSONObject> response = userClient.getBanStatus(request.getUserId())
.execute().body();
return response;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
// Account ban - update review result (POST)
// Standalone POST without GET parameters, requires IOException
public void updateReviewResult(ReviewResultRequest request) throws IOException {
Util.check(StringUtils.isNotBlank(request.getDecisionRemarks()), "Decision remarks required");
Util.check(NumberUtil.isPositive(request.getReviewResult()), "Review result required");
log.info("Decision remarks: {}", request.getDecisionRemarks());
log.info("Review result: {}", request.getReviewResult());
}