\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[space]{ctex}
\usepackage{geometry}
\geometry{left=2cm,right=2cm,top=2.5cm,bottom=2.5cm}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,shapes.geometric,positioning,calc}

\title{资产管理系统需求规格说明书/
资产管理系统架构设计说明书}
\author{文档编号: AMS-001 / 版本: 1.0 / 编制日期: 2026-05-25}
\date{}

\begin{document}

\maketitle
\thispagestyle{empty}
\newpage
\tableofcontents
\newpage

\section{资产管理系统需求规格说明书}
文档编号: SRS-001  版本: 1.0  编制日期: 2026-05-25

\subsection{引言}

\subsubsection{项目背景}
本项目是一个基于Java Swing的图形界面资产管理系统，旨在为企业提供资产从入库、分类、借用、报废全生命周期管理功能。系统采用Java语言开发，支持MySQL数据库存储，实现了资产管理、分类管理、借用管理、报废管理、用户管理及数据统计六大核心功能模块。

\subsubsection{术语定义}
\begin{itemize}
\item 资产(Asset): 企业拥有的具有价值的物品，包括设备、家具、电子产品等
\item 资产编号(AssetCode): 资产在系统中的唯一标识编码
\item 资产分类(Category): 按类型对资产进行分组，如办公设备、电子设备、家具等
\item 借用(Borrow): 资产从可用状态被借出的记录
\item 报废(Disposal): 资产因损坏、老旧等原因被处置的记录
\item 用户角色(Role): 系统用户分为管理员(admin)和普通用户(user)
\item 资产状态(Status): 资产当前状态，包括可用(available)、借出(borrowed)、已报废(disposed)
\end{itemize}

\subsection{总体描述}

\subsubsection{系统概述}
资产管理系统是一个图形界面应用软件，提供资产从入库到报废的全流程管理。系统采用典型的MVC三层架构，以Swing作为UI框架，MySQL作为数据存储，支持多用户并发操作。

\subsubsection{系统约束}
\begin{itemize}
\item 技术约束: JDK 8+ 环境运行，Java Swing图形界面，MySQL 8.0+数据库
\item 数据约束: 持久化存储，数据可跨会话保留
\item 功能约束: 支持资产、分类、借用、报废、用户、数据统计六大模块
\end{itemize}

\subsection{功能需求}

\subsubsection{功能列表}
\begin{enumerate}
    \item F01 用户登录: 用户输入用户名密码登录系统，密码使用MD5加密
    \item F02 用户注册: 新用户注册账号，设置用户名、密码、真实姓名
    \item F03 资产管理: 资产的增删改查，支持按名称、分类、状态、位置搜索
    \item F04 分类管理: 资产分类的增删改查，支持唯一性校验
    \item F05 借用申请: 用户申请借用可用状态的资产，设置预计归还日期和原因
    \item F06 借用审批: 管理员审批借用申请，同意或拒绝
    \item F07 资产归还: 批准借用后，用户可归还资产，系统恢复资产状态为可用
    \item F08 报废申请: 用户申请报废可用状态的资产
    \item F09 报废审批: 管理员审批报废申请，批准后资产状态变为已报废
    \item F10 用户管理: 管理员可修改用户角色和启用/禁用状态
    \item F11 修改密码: 用户修改自己的登录密码，需验证旧密码
    \item F12 数据统计: 统计资产分类分布、状态分布、借用频率、价值汇总
    \item F13 退出登录: 安全退出系统，返回登录界面
\end{enumerate}

\subsubsection{业务流程}
资产管理系统核心业务流程如下：

\begin{figure}[htbp]
\centering
\begin{tikzpicture}[node distance=0.8cm]

\tikzstyle{block} = [rectangle, draw, rounded corners, minimum width=2cm, minimum height=0.6cm, fill=blue!10]
\tikzstyle{start} = [rectangle, draw, rounded corners, minimum width=2cm, minimum height=0.6cm, fill=green!30, draw=green!60]
\tikzstyle{decision} = [diamond, aspect=2, draw]
\tikzstyle{module} = [rectangle, draw, rounded corners, minimum width=2cm, minimum height=0.6cm, fill=orange!20, draw=orange!50]
\tikzstyle{sub} = [rectangle, draw, rounded corners, minimum width=1.5cm, minimum height=0.4cm, fill=yellow!15]

\node (start) [start] {开始};
\node (login) [block, below=0.6cm of start] {用户登录};
\node (check) [decision, below=0.5cm of login] {登录成功?};

\node (main) [block, right=1.2cm of check] {进入主界面};
\node (logout) [block, below=0.6cm of check, fill=red!10, draw=red!40] {退出系统};

\node (module) [module, below=0.8cm of main] {主界面模块};
\node (asset) [block, below=0.4cm of module, fill=yellow!25] {资产管理};
\node (category) [block, below=0.3cm of asset, fill=yellow!25] {分类管理};
\node (borrow) [block, below=0.3cm of category, fill=yellow!25] {借用管理};
\node (disposal) [block, below=0.3cm of borrow, fill=yellow!25] {报废管理};
\node (stat) [block, below=0.3cm of disposal, fill=yellow!25] {数据统计};
\node (user) [block, below=0.3cm of stat, fill=yellow!25] {用户管理};

\node (assetSub) [sub, right=0.3cm of asset] {增/删/改/查};
\node (borrowSub) [sub, right=0.3cm of borrow] {申请/审批/归还};
\node (disposalSub) [sub, right=0.3cm of disposal] {申请/审批};

\draw[->,thick] (start) -- (login);
\draw[->,thick] (login) -- (check);
\draw[->,thick] (check) -- node[above] {是} (main);
\draw[->,thick] (check) -- node[left] {否} (logout);
\draw[->,thick] (main) -- (module);
\draw[->,thick] (module) -- (asset);
\draw[->,thick] (module) -- (category);
\draw[->,thick] (module) -- (borrow);
\draw[->,thick] (module) -- (disposal);
\draw[->,thick] (module) -- (stat);
\draw[->,thick] (module) -- (user);
\draw[->,dashed] (asset) -- (assetSub);
\draw[->,dashed] (borrow) -- (borrowSub);
\draw[->,dashed] (disposal) -- (disposalSub);
\draw[->,thick] (logout.west) -- ++(-0.5,0) -- ++(0,2.8) -- (login.west);

\end{tikzpicture}
\caption{图3-1 资产管理系统业务流程图}
\end{figure}

\subsection{资产状态说明}
资产状态流转规则：

\begin{figure}[htbp]
\centering
\begin{tikzpicture}[node distance=2.5cm]

\tikzstyle{state} = [circle, draw, minimum size=2cm]

\node (available) [state, fill=green!35, draw=green!60] {可用/available};
\node (borrowed) [state, right=3.5cm of available, fill=yellow!35, draw=yellow!60] {借出/borrowed};
\node (disposed) [state, below=2.5cm of borrowed, fill=red!35, draw=red!60] {已报废/disposed};

\draw[->,thick,>=stealth] (available) -- node[above, fill=white] {借用申请批准} (borrowed);
\draw[->,thick,>=stealth] (borrowed) -- node[right, fill=white] {归还} (available);
\draw[->,thick,>=stealth] (available) -- node[left, fill=white] {报废批准} (disposed);
\draw[->,thick,>=stealth] (borrowed.north) .. controls +(0,1.2) and +(1,1.2) .. node[above, fill=white] {报废申请} (disposed.north east);

\end{tikzpicture}
\caption{图3-2 资产状态流转图}
\end{figure}

\newpage
\section{资产管理系统架构设计说明书}
文档编号: SDS-001  版本: 1.0  编制日期: 2026-05-25

\subsection{系统概述}

\subsubsection{设计目标}
本设计文档详细描述资产管理系统(Mobile Asset Manager)的架构设计，包括系统架构、模块划分、数据结构、类图设计、流程设计等，确保开发团队对系统有统一的理解。

本系统采用经典的三层架构设计(表现层-业务逻辑层-数据访问层)，以OOP面向对象思想为指导，结合设计模式，实现一个高内聚、低耦合的资产管理应用。

\subsection{系统架构}

\subsubsection{整体架构}
本系统采用经典的三层架构设计：

\begin{figure}[htbp]
\centering
\begin{tikzpicture}[node distance=2cm, minimum width=4cm, minimum height=0.8cm]

\tikzstyle{layer} = [rectangle, draw, rounded corners, ultra thick]
\tikzstyle{desc} = [font=\small, text width=4cm, align=center]

\node (ui) [layer, fill=blue!15, draw=blue!50] {表现层 (View Layer)};
\node (uiDesc) [desc, below=0.2cm of ui] {LoginFrame, MainFrame/Panel, Dialog};

\node (service) [layer, below=2cm of ui, fill=green!15, draw=green!50] {业务逻辑层 (Service Layer)};
\node (serviceDesc) [desc, below=0.2cm of service] {UserService, AssetService/CategoryService, BorrowService/DisposalService, StatService};

\node (dao) [layer, below=2cm of service, fill=yellow!15, draw=yellow!50] {数据访问层 (DAO Layer)};
\node (daoDesc) [desc, below=0.2cm of dao] {BaseDAO, UserDAO, AssetDAO/CategoryDAO, BorrowDAO, DisposalDAO};

\node (db) [layer, below=2cm of dao, fill=red!15, draw=red!50] {数据层 (Data Layer)};
\node (dbDesc) [desc, below=0.2cm of db] {MySQL 8.0+/t\_user, t\_asset, t\_category/t\_borrow, t\_disposal};

\draw[->,thick,>=stealth,draw=purple!70] (ui) -- (service) node[midway, right] {调用};
\draw[->,thick,>=stealth,draw=purple!70] (service) -- (dao) node[midway, right] {调用};
\draw[->,thick,>=stealth,draw=purple!70] (dao) -- (db) node[midway, right] {SQL};

\end{tikzpicture}
\caption{图2-1 系统三层架构图}
\end{figure}

\subsubsection{层次说明}
\begin{itemize}
\item 表现层(View): 负责用户界面展示和交互，包括JFrame、JDialog、JPanel组件
\item 业务逻辑层(Service): 负责核心业务逻辑处理，校验规则、数据组装
\item 数据访问层(DAO): 负责数据库操作，SQL执行、结果映射
\item 数据层: MySQL数据库，负责数据持久化存储
\end{itemize}

\subsection{包结构设计}

\subsubsection{包划分}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[node distance=1cm, minimum width=2.5cm, minimum height=0.6cm]

\tikzstyle{pkg} = [rectangle, draw, rounded corners]
\tikzstyle{pkgname} = [font=\small]

\node (entity) [pkg, fill=blue!20, draw=blue!50] {com.asset.entity};
\node (dao) [pkg, right=1cm of entity, fill=green!20, draw=green!50] {com.asset.dao};
\node (service) [pkg, right=1cm of dao, fill=yellow!20, draw=yellow!50] {com.asset.service};
\node (exception) [pkg, right=1cm of service, fill=red!20, draw=red!50] {com.asset.exception};

\node (view) [pkg, below=1cm of entity, fill=purple!20, draw=purple!50] {com.asset.view};
\node (util) [pkg, below=1cm of exception, fill=orange!20, draw=orange!50] {com.asset.util};

\node (entityDesc) [pkgname, below=0.2cm of entity] {User, Asset, Category/Borrow, Disposal};
\node (daoDesc) [pkgname, below=0.2cm of dao] {BaseDAO, *DAO};
\node (serviceDesc) [pkgname, below=0.2cm of service] {*Service};
\node (viewDesc) [pkgname, below=0.2cm of view] {Frame, Dialog, Panel};
\node (utilDesc) [pkgname, below=0.2cm of util] {DBUtil, MD5Util/DateUtil, ValidatorUtil};
\node (exceptionDesc) [pkgname, below=0.2cm of exception] {BusinessException/DBException};

\draw[<->,thick] (entity) -- (dao);
\draw[<->,thick] (dao) -- (service);
\draw[<->,thick] (entity) -- (view);
\draw[<->,thick] (service) -- (view);
\draw[<->,thick] (exception) -- (service);
\draw[<->,thick] (util) -- (service);

\end{tikzpicture}
\caption{图3-1 包结构设计图}
\end{figure}

\subsection{类设计}

\subsubsection{核心类图}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[node distance=0.5cm, minimum width=1.4cm, minimum height=0.4cm]

\tikzstyle{vclass} = [rectangle, draw, rounded corners, fill=blue!25, draw=blue!60]
\tikzstyle{sclass} = [rectangle, draw, rounded corners, fill=green!25, draw=green!60]
\tikzstyle{dclass} = [rectangle, draw, rounded corners, fill=yellow!25, draw=yellow!60]
\tikzstyle{eclass} = [rectangle, draw, rounded corners, fill=red!25, draw=red!60]

% View Layer
\node (LoginFrame) [vclass] {LoginFrame};
\node (MainFrame) [vclass, below=0.6cm of LoginFrame] {MainFrame};
\node (RegisterDialog) [vclass, right=0.8cm of LoginFrame] {RegisterDialog};
\node (ChangePwd) [vclass, right=0.8cm of MainFrame] {ChangePwd};

% Panels
\node (AssetPanel) [vclass, below=0.8cm of MainFrame] {AssetPanel};
\node (CategoryPanel) [vclass, below=0.4cm of AssetPanel] {CategoryPanel};
\node (BorrowPanel) [vclass, below=0.4cm of CategoryPanel] {BorrowPanel};
\node (DisposalPanel) [vclass, below=0.4cm of BorrowPanel] {DisposalPanel};
\node (StatPanel) [vclass, below=0.4cm of DisposalPanel] {StatPanel};
\node (UserPanel) [vclass, below=0.4cm of StatPanel] {UserPanel};

% Dialogs
\node (AssetDialog) [vclass, right=0.8cm of AssetPanel] {AssetDialog};
\node (CategoryDialog) [vclass, right=0.8cm of CategoryPanel] {CategoryDialog};
\node (BorrowDialog) [vclass, right=0.8cm of BorrowPanel] {BorrowDialog};
\node (ApproveDialog) [vclass, right=0.8cm of DisposalPanel] {ApproveDialog};

% Service Layer
\node (UserService) [sclass, right=3cm of AssetDialog] {UserService};
\node (AssetService) [sclass, below=0.4cm of UserService] {AssetService};
\node (CategoryService) [sclass, below=0.4cm of AssetService] {CategoryService};
\node (BorrowService) [sclass, below=0.4cm of CategoryService] {BorrowService};
\node (DisposalService) [sclass, below=0.4cm of BorrowService] {DisposalService};
\node (StatService) [sclass, below=0.4cm of DisposalService] {StatService};

% DAO Layer
\node (UserDAO) [dclass, right=2.5cm of UserService] {UserDAO};
\node (AssetDAO) [dclass, below=0.4cm of UserDAO] {AssetDAO};
\node (CategoryDAO) [dclass, below=0.4cm of AssetDAO] {CategoryDAO};
\node (BorrowDAO) [dclass, below=0.4cm of CategoryDAO] {BorrowDAO};
\node (DisposalDAO) [dclass, below=0.4cm of BorrowDAO] {DisposalDAO};

% Entity Layer
\node (User) [eclass, above=0.6cm of UserDAO] {User};
\node (Asset) [eclass, right=0.6cm of User] {Asset};
\node (Category) [eclass, right=0.6cm of Asset] {Category};
\node (Borrow) [eclass, right=0.6cm of Category] {Borrow};
\node (Disposal) [eclass, right=0.6cm of Borrow] {Disposal};

% Connections - View internal
\draw[->,thick] (LoginFrame) -- (MainFrame);
\draw[->,thick] (MainFrame) -- (AssetPanel);
\draw[->,thick] (MainFrame) -- (CategoryPanel);
\draw[->,thick] (MainFrame) -- (BorrowPanel);
\draw[->,thick] (MainFrame) -- (DisposalPanel);
\draw[->,thick] (MainFrame) -- (StatPanel);
\draw[->,thick] (MainFrame) -- (UserPanel);

% View to Dialog
\draw[->,thick,dashed] (AssetPanel) -- (AssetDialog);
\draw[->,thick,dashed] (CategoryPanel) -- (CategoryDialog);
\draw[->,thick,dashed] (BorrowPanel) -- (BorrowDialog);
\draw[->,thick,dashed] (DisposalPanel) -- (ApproveDialog);

% View to Service
\draw[->,thick] (AssetPanel) -- (AssetService);
\draw[->,thick] (BorrowPanel) -- (BorrowService);
\draw[->,thick] (CategoryPanel) -- (CategoryService);
\draw[->,thick] (DisposalPanel) -- (DisposalService);
\draw[->,thick] (StatPanel) -- (StatService);
\draw[->,thick] (UserPanel) -- (UserService);

% Service to DAO
\draw[->,thick] (UserService) -- (UserDAO);
\draw[->,thick] (AssetService) -- (AssetDAO);
\draw[->,thick] (CategoryService) -- (CategoryDAO);
\draw[->,thick] (BorrowService) -- (BorrowDAO);
\draw[->,thick] (DisposalService) -- (DisposalDAO);

% DAO to Entity
\draw[->,thick,dashed] (UserDAO) -- (User);
\draw[->,thick,dashed] (AssetDAO) -- (Asset);
\draw[->,thick,dashed] (CategoryDAO) -- (Category);
\draw[->,thick,dashed] (BorrowDAO) -- (Borrow);
\draw[->,thick,dashed] (DisposalDAO) -- (Disposal);

% Legend
\node (legend) [below=1.2cm of DisposalPanel, font=\tiny, text width=9cm, align=center] {
View层 = 界面展示和用户交互  /  Service层 = 业务逻辑处理  /  DAO层 = 数据访问操作  /  Entity层 = 数据模型实体
};

\end{tikzpicture}
\caption{图4-1 系统核心类图}
\end{figure}

\subsubsection{核心类说明}
\begin{itemize}
\item App: 系统入口类，负责启动登录界面
\item LoginFrame: 登录窗口，处理用户登录和注册
\item MainFrame: 主窗口，包含导航菜单和内容切换
\item UserService: 用户业务逻辑，登录验证、注册、密码修改、角色管理
\item AssetService: 资产业务逻辑，资产增删改查、状态管理
\item CategoryService: 分类业务逻辑，分类增删改查
\item BorrowService: 借用业务逻辑，借用申请、审批、归还
\item DisposalService: 报废业务逻辑，报废申请、审批
\item StatService: 统计业务逻辑，资产统计、图表数据
\item BaseDAO: DAO基类，封装通用数据库操作(query, update, count)
\item User: 用户实体类(id, username, password, realName, role, status)
\item Asset: 资产实体类(id, assetCode, assetName, categoryId, status, value, ...)
\end{itemize}

\subsection{设计模式应用}

\subsubsection{DAO模式}
目的: 封装数据访问细节，提供统一的数据操作接口
实现: BaseDAO定义通用CRUD方法，各*DAO继承并实现特定实体操作

\subsubsection{业务代表模式}
目的: 隔离表现层和业务逻辑层，降低耦合度
实现: Service层处理所有业务逻辑，View层只负责展示和交互

\subsection{流程设计}

\subsubsection{登录流程顺序图}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[node distance=1.5cm, minimum width=1.8cm]

\tikzstyle{part} = [rectangle, draw, fill=blue!15]
\tikzstyle{life} = [-, dashed]

\node (actor) [part, fill=gray!20] {参与者};
\node (login) [part, right=2cm of actor] {LoginFrame};
\node (service) [part, right=2cm of login, fill=green!15] {UserService};
\node (dao) [part, right=2cm of service, fill=yellow!15] {UserDAO};
\node (db) [part, right=2cm of dao, fill=red!15] {MySQL};

\draw[life] (actor) -- ++(0,-6cm);
\draw[life] (login) -- ++(0,-6cm);
\draw[life] (service) -- ++(0,-6cm);
\draw[life] (dao) -- ++(0,-6cm);
\draw[life] (db) -- ++(0,-6cm);

\draw[->,thick] (actor) -- (login) node[midway, above, font=\tiny] {1. 输入用户名密码};
\draw[->,thick] (login) -- (service) node[midway, above, font=\tiny] {2. login()};
\draw[->,thick] (service) -- (dao) node[midway, above, font=\tiny] {3. findByUsername()};
\draw[->,thick] (dao) -- (db) node[midway, above, font=\tiny] {4. SELECT};
\draw[<-,thick] (dao) -- (db) node[midway, above, font=\tiny] {5. ResultSet};
\draw[->,thick] (dao) -- (service) node[midway, above, font=\tiny] {6. User};
\draw[->,thick] (service) -- (login) node[midway, above, font=\tiny] {7. Result};
\draw[<-,thick] (login) -- (actor) node[midway, above, font=\tiny] {8. Success/Fail};

\end{tikzpicture}
\caption{图6-1 登录流程顺序图}
\end{figure}

\subsubsection{借用申请流程顺序图}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[node distance=1cm, minimum width=1.6cm]

\tikzstyle{part} = [rectangle, draw]

\node (actor) [part, fill=gray!20] {用户};
\node (dialog) [part, right=1.5cm of actor, fill=blue!15] {BorrowDialog};
\node (service) [part, right=1.5cm of dialog, fill=green!15] {BorrowService};
\node (assetDAO) [part, right=1.5cm of service, fill=yellow!15] {AssetDAO};
\node (borrowDAO) [part, right=1.5cm of assetDAO, fill=yellow!15] {BorrowDAO};
\node (db) [part, right=1.5cm of borrowDAO, fill=red!15] {MySQL};

\draw[-, dashed] (actor) -- ++(0,-8cm);
\draw[-, dashed] (dialog) -- ++(0,-8cm);
\draw[-, dashed] (service) -- ++(0,-8cm);
\draw[-, dashed] (assetDAO) -- ++(0,-8cm);
\draw[-, dashed] (borrowDAO) -- ++(0,-8cm);
\draw[-, dashed] (db) -- ++(0,-8cm);

\draw[->,thick] (actor) -- (dialog) node[midway, above, font=\tiny] {选择资产};
\draw[->,thick] (dialog) -- (service) node[midway, above, font=\tiny] {applyBorrow()};
\draw[->,thick] (service) -- (assetDAO) node[midway, above, font=\tiny] {findById()};
\draw[->,thick] (assetDAO) -- (db) node[midway, above, font=\tiny] {SELECT};
\draw[<-,thick] (service) -- (assetDAO) node[midway, above, font=\tiny] {Asset};
\draw[->,thick] (service) -- (borrowDAO) node[midway, above, font=\tiny] {insert()};
\draw[->,thick] (borrowDAO) -- (db) node[midway, above, font=\tiny] {INSERT};
\draw[->,thick] (service) -- (assetDAO) node[midway, above, font=\tiny] {updateStatus()};
\draw[->,thick] (assetDAO) -- (db) node[midway, above, font=\tiny] {UPDATE};
\draw[<-,thick] (dialog) -- (service) node[midway, above, font=\tiny] {Success};
\draw[<-,thick] (actor) -- (dialog) node[midway, above, font=\tiny] {提示};

\end{tikzpicture}
\caption{图6-2 借用申请流程顺序图}
\end{figure}

\subsubsection{审批流程顺序图}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[node distance=1cm, minimum width=1.4cm]

\tikzstyle{part} = [rectangle, draw]

\node (admin) [part, fill=gray!20] {管理员};
\node (approve) [part, right=1.2cm of admin, fill=blue!15] {ApproveDialog};
\node (service) [part, right=1.2cm of approve, fill=green!15] {BorrowService/DisposalService};
\node (recordDAO) [part, right=1.2cm of service, fill=yellow!15] {BorrowDAO/DisposalDAO};
\node (assetDAO) [part, right=1.2cm of recordDAO, fill=yellow!15] {AssetDAO};
\node (db) [part, right=1.2cm of assetDAO, fill=red!15] {MySQL};

\draw[-, dashed] (admin) -- ++(0,-7cm);
\draw[-, dashed] (approve) -- ++(0,-7cm);
\draw[-, dashed] (service) -- ++(0,-7cm);
\draw[-, dashed] (recordDAO) -- ++(0,-7cm);
\draw[-, dashed] (assetDAO) -- ++(0,-7cm);
\draw[-, dashed] (db) -- ++(0,-7cm);

\draw[->,thick] (admin) -- (approve) node[midway, above, font=\tiny] {审批};
\draw[->,thick] (approve) -- (service) node[midway, above, font=\tiny] {approve()};
\draw[->,thick] (service) -- (recordDAO) node[midway, above, font=\tiny] {findById()};
\draw[->,thick] (recordDAO) -- (db) node[midway, above, font=\tiny] {SELECT};
\draw[<-,thick] (recordDAO) -- (db) node[midway, above, font=\tiny] {Record};
\draw[->,thick] (service) -- (recordDAO) node[midway, above, font=\tiny] {update()};
\draw[->,thick] (recordDAO) -- (db) node[midway, above, font=\tiny] {UPDATE};
\draw[->,thick] (service) -- (assetDAO) node[midway, above, font=\tiny] {updateStatus()};
\draw[->,thick] (assetDAO) -- (db) node[midway, above, font=\tiny] {UPDATE};

\end{tikzpicture}
\caption{图6-3 审批流程顺序图}
\end{figure}

\subsection{数据库设计}

\subsubsection{数据库ER图}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[node distance=2cm, minimum width=3cm, minimum height=1.5cm]

\tikzstyle{table} = [rectangle, draw, ultra thick]

\node (user) [table, fill=blue!15, draw=blue!50] {t\_user/用户表};
\node (category) [table, above=2.5cm of user, fill=yellow!15, draw=yellow!50] {t\_category/分类表};
\node (asset) [table, right=4cm of user, fill=green!15, draw=green!50] {t\_asset/资产表};
\node (borrow) [table, below=2.5cm of user, fill=purple!15, draw=purple!50] {t\_borrow/借用表};
\node (disposal) [table, right=4cm of borrow, fill=red!15, draw=red!50] {t\_disposal/报废表};

% Field descriptions
\node (userFields) [below=0.2cm of user, font=\tiny, text width=3cm, align=left] {
\begin{tabular}{l}
id (PK), username, password/real\_name, role, status
\end{tabular}
};

\node (categoryFields) [above=0.2cm of category, font=\tiny, text width=3cm, align=left] {
\begin{tabular}{l}
id (PK), category\_code/category\_name, description
\end{tabular}
};

\node (assetFields) [above=0.2cm of asset, font=\tiny, text width=3.5cm, align=left] {
\begin{tabular}{l}
id (PK), asset\_code, asset\_name/category\_id (FK), status, value/purchase\_date, location
\end{tabular}
};

\node (borrowFields) [below=0.2cm of borrow, font=\tiny, text width=3.5cm, align=left] {
\begin{tabular}{l}
id (PK), asset\_id (FK), user\_id (FK)/borrow\_date, expected\_return, actual\_return/reason, status, approver\_id
\end{tabular}
};

\node (disposalFields) [below=0.2cm of disposal, font=\tiny, text width=3cm, align=left] {
\begin{tabular}{l}
id (PK), asset\_id (FK), user\_id (FK)/reason, status, approver\_id, disposal\_date
\end{tabular}
};

% Relationships
\draw[->,thick,draw=green!60] (asset.north west) -- node[left, font=\tiny, fill=white] {N:1} (category.south west);
\draw[->,thick,draw=green!60] (borrow.north west) -- node[left, font=\tiny, fill=white] {N:1} (user.south east);
\draw[->,thick,draw=green!60] (borrow.north east) -- node[right, font=\tiny, fill=white] {N:1} (asset.south west);
\draw[->,thick,draw=red!60] (disposal.north west) -- node[left, font=\tiny, fill=white] {N:1} (user.north east);
\draw[->,thick,draw=red!60] (disposal.north) -- node[above, font=\tiny, fill=white] {N:1} (asset.south east);

% Legend
\node (legend) [below=1cm of borrow, font=\tiny, text width=10cm] {
PK = Primary Key (主键) \quad FK = Foreign Key (外键) \quad N:1 = 多对一关系
};

\end{tikzpicture}
\caption{图7-1 数据库ER图}
\end{figure}

\subsection{错误处理设计}
\begin{itemize}
\item 用户名不存在: 显示"用户名或密码错误"
\item 密码错误: 显示"用户名或密码错误"
\item 账户已禁用: 显示"账户已被禁用，请联系管理员"
\item 资产编号已存在: 显示"资产编号已存在"
\item 资产正在借用: 显示"该资产正在借用中，无法删除"
\item 分类下有资产: 显示"该分类下存在资产，禁止删除"
\item 数据库连接失败: 抛出DBException，提示"数据库连接失败"
\item 输入为空: 显示"xxx不能为空"
\end{itemize}

\subsection{扩展性设计}

\subsubsection{新增功能模块步骤}
\begin{enumerate}
\item 在entity包创建实体类
\item 在dao包创建DAO类(继承BaseDAO)
\item 在service包创建Service类
\item 在view包创建Panel或Dialog
\item 在MainFrame中添加导航
\end{enumerate}

\subsubsection{新增资产状态步骤}
\begin{enumerate}
\item 在Asset实体类中添加状态常量
\item 在AssetService中添加状态校验
\item 在AssetPanel中添加状态选项
\end{enumerate}

\subsection{部署与运行}

\subsubsection{环境要求}
\begin{itemize}
\item JDK 8+
\item MySQL 8.0+
\item Maven 3.6+ (用于项目构建)
\end{itemize}

\subsubsection{编译步骤}
\begin{verbatim}
mvn compile
mvn package
java -jar target/assetmanager-1.0-SNAPSHOT.jar
\end{verbatim}

\subsubsection{数据库初始化}
\begin{verbatim}
mysql -u root -p < docs/sql/init.sql
\end{verbatim}

\subsection{总结}
本系统采用三层架构+MVC设计模式，模块化程度高，职责划分清晰。表现层、业务逻辑层、数据访问层之间低耦合，便于维护和扩展。合理运用设计模式，使代码结构清晰，易于理解，满足当前功能需求，并具备良好的扩展性。

\end{document}