This project is a flight entry and exit management system built using Java and SpringBoot framework. The system can be opened and run in both Eclipse and IDE. The recommended environment includes Eclipse/IDE, JDK 1.8, Maven, and MySQL.
Technical Stack
Frontend technologies include Vue.js, Ajax, and JSON for dynamic user interfaces. Backend implementation utilizes SpringBoot with MyBatis for database operations. The system supports two user roles: administrators and regular users.
Key Features
Administrator Module: Authentication, dashboard, user management, flight information management, tower command management, announcement management, and carousel information management.
User Module: Registration and login, homepage display, announcement listings, flight information listings, takeoff and landing requests, and personal center.
Code Implementation
Controller Layer Example
The following controller demonstrates querying login user information based on session data:
@RequestMapping("/retrieveFlightRecords")
public JsonObject retrieveFlightRecords(FlightRecord record, HttpServletRequest request,
@RequestParam(defaultValue = "1") Integer currentPage,
@RequestParam(defaultValue = "15") Integer pageSize
){
// Retrieve current logged-in user
UserAccount currentUser = (UserAccount) request.getSession().getAttribute("user");
String username = currentUser.getUsername();
// Get operator ID based on username
Operator operator = operatorService.findOperatorByUsername(username);
record.setOperatorId(operator.getId());
PageInfo<FlightRecord> pageInfo = flightRecordService.getFlightRecords(currentPage, pageSize, record);
return new JsonObject(0, "success", pageInfo.getTotal(), pageInfo.getList());
}
Service Interface
The service interface defines the contract for flight record operations:
package com.aviation.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.github.pagehelper.PageInfo;
import com.aviation.model.FlightRecord;
import java.util.Date;
/**
* Flight Record Service Interface
*/
public interface IFlightRecordService extends IService<FlightRecord> {
PageInfo<FlightRecord> getFlightRecords(int pageNum, int pageSize, FlightRecord record);
/**
* Query paginated data
* @param page Page number
* @param pageCount Items per page
* @return IPage<FlightRecord>
*/
IPage<FlightRecord> findRecordsByPage(Integer page, Integer pageCount);
/**
* Add new flight record
* @param record Flight record to add
* @return Number of affected rows
*/
int addRecord(FlightRecord record);
/**
* Delete flight record
* @param id Primary key
* @return Number of affected rows
*/
int deleteRecord(Long id);
/**
* Update flight record
* @param record Flight record to update
* @return Number of affected rows
*/
int updateRecord(FlightRecord record);
/**
* Find record by ID
* @param id Record ID
* @return FlightRecord
*/
FlightRecord findRecordById(Long id);
Date getLastUpdateTimeByOperatorId(Integer operatorId);
}
Authentication Implemantation
The login process uses Apache Shiro with MD5 password encryption:
@RequestMapping(value="/authenticate",method= RequestMethod.POST)
public String authenticate(Model model, String username, String password){
Subject subject = SecurityUtils.getSubject();
UsernamePasswordToken token = new UsernamePasswordToken(username, password);
try {
subject.login(token);
User user = userService.getUserByUsername(username);
String previousLoginTime = "";
if(user != null){
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// Previous login time
Date loginTime = user.getLastLoginTime();
previousLoginTime = dateFormat.format(loginTime);
// Current time
String currentTime = dateFormat.format(new Date());
// Convert string to date
ParsePosition position = new ParsePosition(0);
Date currentDate = dateFormat.parse(currentTime, position);
user.setLastLoginTime(currentDate);
userService.updateUser(user);
}
if (user.getAccountStatus() == 1){
Session session = subject.getSession();
session.setAttribute("subject", subject);
session.setAttribute("previousLoginTime", previousLoginTime);
return "redirect:dashboard";
} else {
model.addAttribute("error", "Account has been disabled!");
return "/login";
}
} catch (AuthenticationException e) {
model.addAttribute("error", "Authentication failed!");
return "/login";
}
}
Data Access Layer
The DAO implementation uses MyBatis with example-based queries:
@Override
public User getUserByUsername(String username) {
UserExample example = new UserExample();
example.createCriteria().andUsernameEqualTo(username);
List<User> users = userMapper.selectByExample(example);
if (users.isEmpty()) return null;
return users.get(0);
}
Mapper Interface
package com.aviation.dao;
import com.aviation.pojo.User;
import com.aviation.pojo.UserExample;
import java.util.List;
public interface UserMapper extends BaseDao<User>{
List<User> selectByExample(UserExample example);
/**
* Disable user account
* @param username Username
*/
void disableAccount(String username);
/**
* Enable user account
* @param username Username
*/
void enableAccount(String username);
}
Mapper XML
<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.aviation.pojo.UserExample" >
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
from user
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null" >
order by ${orderByClause}
</if>
</select>
Design Considerations
During development, several key aspects were addressed:
- User Interface Design: While the current interface meets basic operational requirements, future enhancements could incorporate more diverse design structures to improve user experience.
- Security Optimization: System security requires further improvements, particularly in session management and concurrent access handling to align with industry standards.
- Performance Optimization: Data structures and code should be optimized to ensure stible operation, efficient transaction processing, and reduced server resource consumption.
The primary objective of this system is to provide a user-friendly solution with robust logical design and comprehensive functionality for flight management operasions.