java中的接口是类吗
399
2022-09-15
Java 实战项目之仓库管理系统的实现流程
一、项目简述
功能包括: 仓库管理,出入库管理,仓库人员管理,基本信息管理, 供应商信息,系统管理等等。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: jsP +Spring + SpringMVC + MyBatis + html+ css + javascript + jquery + Ajax + layui+ maven等等。
客户信息管理请求:
/**
* 客户信息管理请求 Handler
*/
@RequestMapping(value = "/**/customerManage")
@Controller
public class CustomerManageHandler {
@Autowired
private CustomerManageService customerManageService;
private static final String SEARCH_BY_ID = "searchByID";
private static final String SEARCH_BY_NAME = "searchByName";
private static final String SEARCH_ALL = "searchAll";
/**
* 通用的结果查询方法
*
* @param searchType 查询方式
* @param keyWord 查询关键字
* @param offset 分页偏移值
* @param limit 分页大小
* @return 返回指定条件查询的结果
*/
private Map
Map
switch (searchType) {
case SEARCH_BY_ID:
if (StringUtils.isNumeric(keyWord))
queryResult = customerManageService.selectById(Integer.valueOf(keyWord));
break;
case SEARCH_BY_NAME:
queryResult = customerManageService.selectByName(offset, limit, keyWord);
break;
case SEARCH_ALL:
queryResult = customerManageService.selectAll(offset, limit);
break;
default:
// do other thing
break;
}
return queryResult;
}
/**
* 搜索客户信息
*
* @param searchType 搜索类型
* @param offset 如有多条记录时分页的偏移值
* @param limit 如有多条记录时分页的大小
* @param keyWord 搜索的关键字
* @return 返回查询的结果,其中键值为 rows 的代表查询到的每一记录,若有分页则为分页大小的记录;键值为 total 代表查询到的符合要求的记录总条数
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "getCustomerList", method = RequestMethod.GET)
public
@ResponseBody
Map
@RequestParam("offset") int offset,
@RequestParam("limit") int limit,
@RequestParam("keyWord") String keyWord) throws CustomerManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
List
long total = 0;
Map
if (queryResult != null) {
rows = (List
total = (long) queryResult.get("total");
}
// 设置 Response
responseContent.setCustomerInfo("rows", rows);
responseContent.setResponseTotal(total);
responseContent.setResponseResult(Response.RESPONSE_RESULT_SUCCESS);
return responseContent.generateResponse();
}
/**
* 添加一条客户信息
*
* @param customer 客户信息
* @return 返回一个map,其中:key 为 result表示操作的结果,包括:success 与 error
*/
@RequestMapping(value = "addCustomer", method = RequestMethod.POST)
public
@ResponseBody
Map
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 添加记录
String result = customerManageService.addCustomer(customer) ? Response.RESPONSE_RESULT_SUCCESS : Response.Rhttp://ESPONSE_RESULT_ERROR;
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
* 查询指定 customer ID 客户的信息
*
* @param customerID 客户ID
* @return 返回一个map,其中:key 为 result 的值为操作的结果,包括:success 与 error;key 为 data
* 的值为客户信息
*/
@RequestMapping(value = "getCustomerInfo", method = RequestMethod.GET)
public
@ResponseBody
Map
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
// 获取客户信息
Customer customer = null;
Map
if (queryResult != null) {
customer = (Customer) queryResult.get("data");
if (customer != null) {
result = Response.RESPONSE_RESULT_SUCCESS;
}
}
// 设置 Response
responseContent.setResponseResult(result);
responseContent.setResponseData(customer);
return responseContent.generateResponse();
}
/**
* 更新客户信息
*
* @param customer 客户信息
* @return 返回一个map,其中:key 为 result表示操作的结果,包括:success 与 error
*/
@RequestMapping(value = "updateCustomer", method = RequestMethod.POST)
public
@ResponseBody
Map
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 更新
String result = customerManageService.updateCustomer(customer) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
* 删除客户记录
*
* @param customerIDStr 客户ID
* @return 返回一个map,其中:key 为 result表示操作的结果,包括:success 与 error
*/
@RequestMapping(value = "deleteCustomer", method = RequestMethod.GET)
public
@ResponseBody
Map
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 参数检查
if (StringUtils.isNumeric(customerIDStr)) {
// 转换为 Integer
Integer customerID = Integer.valueOf(customerIDStr);
// 刪除
String result = customerManageService.deleteCustomer(customerID) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
responseContent.setResponseResult(result);
} else
responseContent.setResponseResult(Response.RESPONSE_RESULT_ERROR);
return responseContent.generateResponse();
}
/**
* 导入客户信息
*
* @param file 保存有客户信息的文件
* @return 返回一个map,其中:key 为 result表示操作的结果,包括:success 与
* error;key为total表示导入的总条数;key为available表示有效的条数
*/
@RequestMapping(value = "importCustomer", method = RequestMethod.POST)
public
@ResponseBody
Map
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_SUCCESS;
// 读取文件内容
int total = 0;
int available = 0;
if (file == null)
result = Response.RESPONSE_RESULT_ERROR;
Map
if (importInfo != null) {
total = (int) importInfo.get("total");
available = (int) importInfo.get("available");
}
responseContent.setResponseResult(result);
responseContent.setResponseTotal(total);
responseContent.setCustomerInfo("available", available);
return responseContent.generateResponse();
}
/**
* 导出客户信息
*
* @param searchType 查找类型
* @param keyWord 查找关键字
* @param response HttpServletResponse
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "exportCustomer", method = RequestMethod.GET)
public void exportCustomer(@RequestParam("searchType") String searchType, @RequestParam("keyWord") String keyWord,
HttpServletResponse response) throws CustomerManageServiceException, IOException {
String fileName = "customerInfo.xlsx";
List
Map
if (queryResult != null) {
customers = (List
}
// 获取生成的文件
File file = customerManageService.exportCustomer(customers);
// 写出文件
if (file != null) {
// 设置响应头
response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
FileInputStream inputStream = new FileInputStream(file);
OutputStream outputStream = response.getOutputStream();
byte[] buffer = new byte[8192];
int len;
while ((len = inputStream.read(buffer, 0, buffer.length)) > 0) {
outputStream.write(buffer, 0, len);
outputStream.flush();
}
inputStream.close();
outputStream.close();
}
}
}
库存管理请求处理:
/**
* 库存管理请求处理
*/
@Controller
@RequestMapping(value = "/**/storageManage")
public class StorageManageHandler {
@Autowired
private StorageManageService storageManageService;
@Autowired
private StockRecordManageService stockRecordManageService;
private static final String SEARCH_BY_GOODS_ID = "searchByGoodsID";
private static final String SEARCH_BY_GOODS_NAME = "searchByGoodsName";
private static final String SEARCH_BY_GOODS_TYPE = "searchByGoodsType";
private static final String SEARCH_ALL = "searchAll";
/**
* 查询库存信息
*
* @param searchType 查询类型
* @param keyword 查询关键字
* @param repositoryBelong 查询仓库
* @param offset 分页偏移值
* @param limit 分页大小
* @return 结果的一个Map,其中: key为 data 的代表记录数据;key 为 total 代表结果记录的数量
*/
private Map
int limit) throws StorageManageServiceException {
Map
switch (searchType) {
case SEARCH_ALL:
if (StringUtils.isNumeric(repositoryBelong)) {
Integer repositoryID = Integer.valueOf(repositoryBelong);
queryResult = storageManageService.selectAll(repositoryID, offset, limit);
http:// } else {
queryResult = storageManageService.selectAll(-1, offset, limit);
}
break;
case SEARCH_BY_GOODS_ID:
if (StringUtils.isNumeric(keyword)) {
Integer goodsID = Integer.valueOf(keyword);
if (StringUtils.isNumeric(repositoryBelong)) {
Integer repositoryID = Integer.valueOf(repositoryBelong);
queryResult = storageManageService.selectByGoodsID(goodsID, repositoryID, offset, limit);
} else
queryResult = storageManageService.selectByGoodsID(goodsID, -1, offset, limit);
}
break;
case SEARCH_BY_GOODS_TYPE:
if (StringUtils.isNumeric(repositoryBelong)) {
Integer repositoryID = Integer.valueOf(repositoryBelong);
queryResult = storageManageService.selectByGoodsType(keyword, repositoryID, offset, limit);
} else
queryResult = storageManageService.selectByGoodsType(keyword, -1, offset, limit);
break;
case SEARCH_BY_GOODS_NAME:
if (StringUtils.isNumeric(repositoryBelong)) {
Integer repositoryID = Integer.valueOf(repositoryBelong);
queryResult = storageManageService.selectByGoodsName(keyword, repositoryID, offset, limit);
} else
queryResult = storageManageService.selectByGoodsName(keyword, -1, offset, limit);
break;
default:
// do other thing
break;
}
return queryResult;
}
/**
* 可指定仓库对库存信息查询
*
* @param keyword 查询关键字
* @param searchType 查询类型
* @param repositoryBelong 查询所属的仓库
* @param offset 分页偏移值
* @param limit 分页大小
* @return 结果的一个Map,其中: key为 rows 的代表记录数据;key 为 total 代表结果记录的数量
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "getStorageListWithRepository", method = RequestMethod.GET)
public
@ResponseBody
Map
@RequestParam("searchType") String searchType, @RequestParam("repositoryBelong") String repositoryBelong,
@RequestParam("offset") int offset, @RequestParam("limit") int limit) throws StorageManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
List
long total = 0;
// query
Map
if (queryResult != null) {
rows = (List
total = (long) queryResult.get("total");
} else
rows = new ArrayList<>();
// 设置 Response
responseContent.setCustomerInfo("rows", rows);
responseContent.setResponseTotal(total);
return responseContent.generateResponse();
}
/**
* 查询库存信息,查询所属的仓库为session保存的信息
*
* @param keyword 查询关键字
* @param searchType 查询类型
* @param offset 分页偏移值
* @param limit 分页大小
* @param request 请求
* @return 结果的一个Map,其中: key为 rows 的代表记录数据;key 为 total 代表结果记录的数量
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "getStorageList", method = RequestMethod.GET)
public
@ResponseBody
Map
@RequestParam("searchType") String searchType, @RequestParam("offset") int offset,
@RequestParam("limit") int limit, HttpServletRequest request) throws StorageManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
List
long total = 0;
HttpSession session = request.getSession();
UserInfoDTO userInfo = (UserInfoDTO) session.getAttribute("userInfo");
Integer repositoryID = userInfo.getRepositoryBelong();
if (repositoryID > 0) {
Map
if (queryResult != null) {
rows = (List
total = (long) queryResult.get("total");
}
}
if (rows == null)
rows = new ArrayList<>();
// 设置 Response
responseContent.setCustomerInfo("rows", rows);
responseContent.setResponseTotal(total);
return responseContent.generateResponse();
}
/**
* 添加一条库存信息
*
* @return 返回一个map,其中:key 为 result表示操作的结果,包括:success 与 error
*/
@RequestMapping(value = "addStorageRecord", method = RequestMethod.POST)
public
@ResponseBody
Map
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String isSuccess = Response.RESPONSE_RESULT_ERROR;
boolean isAvailable = true;
String goodsID = (String) params.get("goodsID");
String repositoryID = (String) params.get("repositoryID");
String number = (String) params.get("number");
if (StringUtils.isBlank(goodsID) || !StringUtils.isNumeric(goodsID))
isAvailable = false;
if (StringUtils.isBlank(repositoryID) || !StringUtils.isNumeric(repositoryID))
isAvailable = false;
if (StringUtils.isBlank(number) || !StringUtils.isNumeric(number))
isAvailable = false;
if (isAvailable) {
isSuccess = storageManageService.addNewStorage(Integer.valueOf(goodsID), Integer.valueOf(repositoryID),
Integer.valueOf(number)) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
}
// 设置 Response
responseContent.setResponseResult(isSuccess);
return responseContent.generateResponse();
}
/**
* 更新库存信息
*
* @return 返回一个map,其中:key 为 result表示操作的结果,包括:success 与 error
*/
@RequestMapping(value = "updateStorageRecord", method = RequestMethod.POST)
public
@ResponseBody
Map
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
boolean isAvailable = true;
String result = Response.RESPONSE_RESULT_ERROR;
String goodsID = (String) params.get("goodsID");
String repositoryID = (String) params.get("repositoryID");
String number = (String) params.get("number");
if (StringUtils.isBlank(goodsID) || !StringUtils.isNumeric(goodsID))
isAvailable = false;
if (StringUtils.isBlank(repositoryID) || !StringUtils.isNumeric(repositoryID))
isAvailable = false;
if (StringUtils.isBlank(number) || !StringUtils.isNumeric(number))
isAvailable = false;
if (isAvailable) {
result = storageManageService.updateStorage(Integer.valueOf(goodsID), Integer.valueOf(repositoryID),
Integer.valueOf(number)) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
}
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
* 删除一条库存信息
*
* @param goodsID 货物ID
* @param repositoryID 仓库ID
* @return 返回一个map,其中:key 为 result表示操作的结果,包括:success 与 error
*/
@RequestMapping(value = "deleteStorageRecord", method = RequestMethod.GET)
public
@ResponseBody
Map
@RequestParam("repositoryID") String repositoryID) throws StorageManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
boolean isAvailable = true;
if (StringUtils.isBlank(goodsID) || !StringUtils.isNumeric(goodsID))
isAvailable = false;
if (StringUtils.isBlank(repositoryID) || !StringUtils.isNumeric(repositoryID))
isAvailable = false;
if (isAvailable) {
result = storageManageService.deleteStorage(Integer.valueOf(goodsID), Integer.valueOf(repositoryID))
? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
}
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
* 导入库存信息
*
* @param file 保存有库存信息的文件
* @return 返回一个map,其中:key 为 result表示操作的结果,包括:success 与
* error;key为total表示导入的总条数;key为available表示有效的条数
*/
@RequestMapping(value = "importStorageRecord", method = RequestMethod.POST)
public
@ResponseBody
Map
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
int total = 0;
int available = 0;
if (file != null) {
Map
if (importInfo != null) {
total = (int) importInfo.get("total");
available = (int) importInfo.get("available");
result = Response.RESPONSE_RESULT_SUCCESS;
}
}
// 设置 Response
responseContent.setResponseResult(result);
responseContent.setResponseTotal(total);
responseContent.setCustomerInfo("available", available);
return responseContent.generateResponse();
}
/**
* 导出库存信息
*
* @param searchType 查询类型
* @param keyword 查询关键字
* @param repositoryBelong 查询所属仓库
* @param request 请求
* @param response 响应
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "exportStorageRecord", method = RequestMethod.GET)
public void exportStorageRecord(@RequestParam("searchType") String searchType,
@RequestParam("keyword") String keyword,
@RequestParam(value = "repositoryBelong", required = false) String repositoryBelong,
HttpServletRequest request, HttpServletResponse response) throws StorageManageServiceException, IOException {
String fileName = "storageRecord.xlsx";
HttpSession session = request.getSession();
UserInfoDTO userInfo = (UserInfoDTO) session.getAttribute("userInfo");
Integer sessionRepositoryBelong = userInfo.getRepositoryBelong();
if (sessionRepositoryBelong > 0)
repositoryBelong = sessionRepositoryBelong.toString();
List
Map
if (queryResult != null)
storageList = (List
File file = storageManageService.exportStorage(storageList);
if (file != null) {
// 设置响应头
response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
FileInputStream inputStream = new FileInputStream(file);
OutputStream outputStream = response.getOutputStream();
byte[] buffer = new byte[8192];
int len;
while ((len = inputStream.read(buffer, 0, buffer.length)) > 0) {
outputStream.write(buffer, 0, len);
outputStream.flush();
}
inputStream.close();
outputStream.close();
}
}
}
供应商信息管理请求:
/**
* 供应商信息管理请求 Handler
*
*/
@RequestMapping(value = "/**/supplierManage")
@Controller
public class SupplierManageHandler {
@Autowired
private SupplierManageService supplierManageService;
private static final String SEARCH_BY_ID = "searchByID";
private static final String SEARCH_BY_NAME = "searchByName";
private static final String SEARCH_ALL = "searchAll";
/**
* 通用的记录查询
*
* @param searchType 查询类型
* @param keyWord 查询关键字
* @param offset 分页偏移值
* @param limit 分页大小
* @return 返回所有符合条件的记录
*/
private Map
Map
switch (searchType) {
case SEARCH_BY_ID:
if (StringUtils.isNumeric(keyWord)) {
queryResult = supplierManageService.selectById(Integer.valueOf(keyWord));
}
break;
case SEARCH_BY_NAME:
queryResult = supplierManageService.selectByName(offset, limit, keyWord);
break;
case SEARCH_ALL:
queryResult = supplierManageService.selectAll(offset, limit);
break;
default:
// do other thing
break;
}
return queryResult;
}
/**
* 搜索供应商信息
*
* @param searchType 搜索类型
* @param offset 如有多条记录时分页的偏移值
* @param limit 如有多条记录时分页的大小
* @param keyWord 搜索的关键字
* @return
*/
@RequestMapping(value = "getSupplierList", method = RequestMethod.GET)
@ResponseBody
public Map
@RequestParam("offset") int offset, @RequestParam("limit") int limit,
@RequestParam("keyWord") String keyWord) throws SupplierManageServiceException {
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
List
long total = 0;
Map
// 结果转换
if (queryResult != null) {
rows = (List
total = (long) queryResult.get("total");
}
responseContent.setCustomerInfo("rows", rows);
responseContent.setResponseTotal(total);
return responseContent.generateResponse();
}
/**
* 添加一条供应商信息
*
* @param supplier 供应商信息
* @return 返回一个map,其中:key 为 result表示操作的结果,包括:success 与 error
*/
@RequestMapping(value = "addSupplier", method = RequestMethod.POST)
public
@ResponseBody
Map
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 添加记录
String result = supplierManageService.addSupplier(supplier) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
* 查询指定 supplierID 供应商的信息
*
* @param supplierID 供应商ID
* @return 返回一个map,其中:key 为 result 的值为操作的结果,包括:success 与 error;key 为 data
* 的值为供应商信息
*/
@RequestMapping(value = "getSupplierInfo", method = RequestMethod.GET)
public
@ResponseBody
Map
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_ERROR;
// 获取供应点信息
Supplier supplier = null;
Map
if (queryResult != null) {
supplier = (Supplier) queryResult.get("data");
if (supplier != null)
result = Response.RESPONSE_RESULT_SUCCESS;
}
// 设置 Response
responseContent.setResponseResult(result);
responseContent.setResponseData(supplier);
return responseContent.generateResponse();
}
/**
* 更新供应商信息
*
* @param supplier 供应商信息
* @return 返回一个map,其中:key 为 result表示操作的结果,包括:success 与 error
*/
@RequestMapping(value = "updateSupplier", method = RequestMethod.POST)
public
@ResponseBody
Map
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 更新
String result = supplierManageService.updateSupplier(supplier) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
* 删除供应商记录
*
* @param supplierID 供应商ID
* @return 返回一个map,其中:key 为 result表示操作的结果,包括:success 与 error
*/
@RequestMapping(value = "deleteSupplier", method = RequestMethod.GET)
public
@ResponseBody
Map
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
// 刪除
String result = supplierManageService.deleteSupplier(supplierID) ? Response.RESPONSE_RESULT_SUCCESS : Response.RESPONSE_RESULT_ERROR;
// 设置 Response
responseContent.setResponseResult(result);
return responseContent.generateResponse();
}
/**
* 导入供应商信息
*
* @param file 保存有供应商信息的文件
* @return 返回一个map,其中:key 为 result表示操作的结果,包括:success 与
* error;key为total表示导入的总条数;key为available表示有效的条数
*/
@RequestMapping(value = "importSupplier", method = RequestMethod.POST)
public
@ResponseBody
Map
// 初始化 Response
Response responseContent = ResponseFactory.newInstance();
String result = Response.RESPONSE_RESULT_SUCCESS;
// 读取文件内容
int total = 0;
int available = 0;
if (file == null)
result = Response.RESPONSE_RESULT_ERROR;
Map
if (importInfo != null) {
total = (int) importInfo.get("total");
available = (int) importInfo.get("available");
}
// 设置 Response
responseContent.setResponseResult(result);
responseContent.setResponseTotal(total);
responseContent.setCustomerInfo("available", available);
return responseContent.generateResponse();
}
/**
* 导出供应商信息
*
* @param searchType 查找类型
* @param keyWord 查找关键字
* @param response HttpServletResponse
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "exportSupplier", method = RequestMethod.GET)
public void exportSupplier(@RequestParam("searchType") String searchType, @RequestParam("keyWord") String keyWord,
HttpServletResponse response) throws SupplierManageServiceException, IOException {
String fileName = "supplierInfo.xlsx";
// 根据查询类型进行查询
List
Map
queryResult = query(searchType, keyWord, -1, -1);
if (queryResult != null) {
suppliers = (List
}
// 获取生成的文件
File file = supplierManageService.exportSupplier(suppliers);
// 写出文件
if (file != null) {
// 设置响应头
response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
FileInputStream inputStream = new FileInputStream(file);
OutputStream outputStream = response.getOutputStream();
byte[] buffer = new byte[8192];
int len;
while ((len = inputStream.read(buffer, 0, buffer.length)) > 0) {
outputStream.write(buffer, 0, len);
outputStream.flush();
}
inputStream.close();
outputStream.close();
}
}
}
系统操作日志请求:
/**
* 系统操作日志请求 Handler
*/
@Controller
@RequestMapping(value = "/systemLog")
public class SystemLogHandler {
@Autowired
private SystemLogService systemLogService;
/**
* 查询系统的登入登出日志
*
* @param userIDStr 用户ID
* @param accessType 记录类型(登入、登出或全部)
* @param startDateStr 记录的起始日期
* @param endDateStr 记录的结束日期
* @param offset 分页的偏移值
* @param limit 分页的大小
* @return 返回 JSON 数据 其中:Key为rows的值代表所有记录数据,Key为total的值代表记录的总条数
* @throws SystemLogServiceException SystemLogServiceException
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "getAccessRecords", method = RequestMethod.GET)
public @ResponseBody
Map
@RequestParam("accessType") String accessType,
@RequestParam("startDate") String startDateStr,
@RequestParam("endDate") String endDateStr,
@RequestParam("offset") int offset,
@RequestParam("limit") int limit) throws SystemLogServiceException {
// 创建 Response 对象
Response response = ResponseFactory.newInstance();
List
long total = 0;
// 检查参数
String regex = "([0-9]{4})-([0-9]{2})-([0-9]{2})";
boolean startDateFormatCheck = (StringUtils.isEmpty(startDateStr) || startDateStr.matches(regex));
boolean endDateFormatCheck = (StringUtils.isEmpty(endDateStr) || endDateStr.matches(regex));
boolean userIDCheck = (StringUtils.isEmpty(userIDStr) || StringUtils.isNumeric(userIDStr));
if (startDateFormatCheck && endDateFormatCheck && userIDCheck) {
// 转到 Service 执行查询
Integer userID = -1;
if (StringUtils.isNumeric(userIDStr))
userID = Integer.valueOf(userIDStr);
Map
if (queryResult != null) {
rows = (List
total = (long) queryResult.get("total");
}
} else
response.setResponseMsg("Request VWatPhArgument Error");
if (rows == null)
rows = new ArrayList<>(0);
// 返回 Response
response.setCustomerInfo("rows", rows);
response.setResponseTotal(total);
return response.generateResponse();
}
/**
* 查询系统的操作日志
*
* @param userIDStr 用户ID
* @param startDateStr 记录的起始日期
* @param endDateStr 记录的结束日期
* @param offset 分页的偏移值
* @param limit 分页的大小
* @return 返回 JSON 数据 其中:Key为rows的值代表所有记录数据,Key为total的值代表记录的总条数
* @throws SystemLogServiceException SystemLogServiceException
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "getUserOperationRecords")
public @ResponseBody
Map
@RequestParam("startDate") String startDateStr,
@RequestParam("endDate") String endDateStr,
@RequestParam("offset") int offset,
@RequestParam("limit") int limit) throws SystemLogServiceException {
// 创建 Response
Response response = ResponseFactory.newInstance();
List
long total = 0;
// 检查参数
String regex = "([0-9]{4})-([0-9]{2})-([0-9]{2})";
boolean startDateFormatCheck = (StringUtils.isEmpty(startDateStr) || startDateStr.matches(regex));
boolean endDateFormatCheck = (StringUtils.isEmpty(endDateStr) || endDateStr.matches(regex));
boolean userIDCheck = (StringUtils.isEmpty(userIDStr) || StringUtils.isNumeric(userIDStr));
if (startDateFormatCheck && endDateFormatCheck && userIDCheck) {
// 转到 Service 进行查询
Integer userID = -1;
if (StringUtils.isNumeric(userIDStr))
userID = Integer.valueOf(userIDStr);
Map
if (queryResult != null) {
rows = (List
total = (long) queryResult.get("total");
}
} else
response.setResponseMsg("Request argument error");
if (rows == null)
rows = new ArrayList<>(0);
response.setCustomerInfo("rows", rows);
response.setResponseTotal(total);
return response.generateResponse();
}
}
以上就是java 实战项目之仓库管理系统的实现流程的详细内容,更多关于Java 仓库管理系统的资料请关注我们其它相关文章!
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~