CampusIdleItemTradingPlatform — server
Build & dev
./mvnw spring-boot:run # start dev server on :8080
./mvnw compile # compile
./mvnw test # run tests (none exist yet)
Prerequisites
- Java 17+, Maven wrapper included (
./mvnw)
- MySQL at
localhost:3306 — execute src/main/resources/init.sql to init DB
- DB:
campus_idle_item_trading_platform, user: root / root
- App uses MySQL HikariCP connection pool (max 20)
Architecture
- Package:
com.campus.trade.* — not the old space.anyi... namespace
- Entrypoint:
com.campus.trade.ServerApplication (scanBasePackages = "com.campus.trade")
- Layered:
controller → service[/admin] → mapper → entity, with DTO/VO at boundaries
- Auth: Session-based (
HttpSession). AuthInterceptor guards all paths; whitelist for /auth/register, /auth/login, /items(/**) GET, /upload/, /v3/api-docs, /swagger-ui
- Session attributes:
userId (Long), role (String)
- Controller reads user via
session.getAttribute("userId")
- Context-path:
/ (plain), not /api
- OpenAPI docs:
http://localhost:8080/swagger-ui.html / /v3/api-docs
- Password: MD5 via
org.springframework.util.DigestUtils
- File upload: to
./upload/ (created at runtime), served at /upload/
- Multipart requests:
consumes = MediaType.MULTIPART_FORM_DATA_VALUE
- Pagination: PageHelper (
PageHelper.startPage(pageNum, pageSize) in Service layer)
Coding conventions
- OpenAPI annotations on every controller API —
@Operation, @Parameter, @Schema from io.swagger.v3.oas.annotations; class-level @Tag
- DTO / VO for params/responses — never expose entities in controller signatures
- Business logic in Service layer — Controller only delegates; Service methods with
@Transactional
- Entity field comments — every field gets a
// inline comment
- Business logic comments — inline comments at key steps explaining the approach
- MyBatis XML —
#{} parameter binding; resultType uses type-alias (com.campus.trade.entity)
- Status enums as plain strings: e.g.
"PENDING", "ON_SALE", "AUTHENTICATED", "ENABLED"
- Order status machine in
OrderStatusMachine validates all transitions