文末獲取源碼
開發語言:Java
框架:+vue
Node:node.js
JDK版本:JDK1.8
服務器:
數據庫:mysql 5.7/8.0
數據庫工具:
開發軟件:/idea,
Maven包:.3.9
瀏覽器:谷歌瀏覽器
目錄
一、前言介紹
校園閑置物品交易系統采用Java編程語言和框架閑置物品交易平臺,采用MySQL數據庫來建立數據之間的轉換,主要實現了首頁、站點管理(輪播圖、公告欄)用戶管理(管理員、注冊用戶、賣家)內容管理(留言交流、留言分類、閑置資訊、資訊分類)商城管理(閑置商城、分類列表、訂單列表)更多管理(訂單處理、數據統計)等功能,為買家和賣家建立了一套科學有效的管理流程,減少了傳統商品銷售出現的失誤,同時也方便了人們進行購物。本系統界面簡潔,使用人員可以迅速掌握,有效的提高了工作效率。
本系統前端框架采用了比較流行的漸進式框架Vue.js。使用Vue-和Vuex實現動態路由和全局狀態管理,Ajax實現前后端通信, UI組件庫使頁面快速成型。后端部分:采用作為開發框架,同時集成、Redis等相關技術。
二、系統功能 2.1前臺功能
1、用戶注冊登錄:用戶進行注冊,登錄。
2、商品瀏覽:以列表方式顯示商品信息或者可以查看熱門商品和優惠商品。
3、商品搜索:用戶可以通過關鍵字或者商品類目進行查詢,盡快的找到自己喜歡的商品。
4、購物車:這是校園閑置物品交易系統最根本組成。客戶在尋找自己喜歡的商品時,可以將其添加到購物車中,然后再次查詢其他商品。
5、個人訂單:客戶選擇要購買的商品,填寫收貨地址、收貨人、聯系電話,提交購買訂單,然后在線付款,付款可以通過支付寶、微信或者銀聯等方式付款。
6、評價:客戶確認收貨后,并可以查看需要評價的訂單,填寫評分、評價內容等,將訂單里包含的商品評價一遍。
2.2后臺功能
1、用戶管理:顯示所有注冊用戶的信息,并進行修改、刪除等操作。
2、商品管理:用戶下訂單購買商品,由管理員定期負責處理,根據訂單信息向用戶送貨,維護現有校園閑置物品交易系統中的所有商品詳情。
3、訂單管理系統:查看訂單狀態,升級訂單信息付款,升級交貨狀態并刪除訂單信息,并解決客戶訂單信息并交付給客戶閑置物品交易平臺,向用戶送貨。
4、評價管理:商家查看用戶對訂單和商品的評價,對不好的評價可以選擇刪除。
2.3功能模塊設計
三、系統詳細設計 3.1前臺首頁模塊
3.2閑置資訊模塊
3.3商品列表模塊
3.4商品詳情模塊
3.5我的購物車模塊
3.6我的訂單模塊
四、管理員功能模塊 4.1輪播圖模塊
4.2注冊用戶模塊
4.3閑置資訊模塊
4.4閑置商城模塊
4.5訂單處理模塊
五、部分核心代碼 5.1登錄系統主要代碼
/**
* 登錄
* @param data
* @param httpServletRequest
* @return
*/
@PostMapping("login")
public Map login(@RequestBody Map data, HttpServletRequest httpServletRequest) {
log.info("[執行登錄接口]");
String username = data.get("username");
String email = data.get("email");
String phone = data.get("phone");
String password = data.get("password");
List resultList = null;
Map map = new HashMap<>();
if(username != null && "".equals(username) == false){
map.put("username", username);
resultList = service.select(map, new HashMap<>()).getResultList();
}
else if(email != null && "".equals(email) == false){
map.put("email", email);
resultList = service.select(map, new HashMap<>()).getResultList();
}
else if(phone != null && "".equals(phone) == false){
map.put("phone", phone);
resultList = service.select(map, new HashMap<>()).getResultList();
}else{
return error(30000, "賬號或密碼不能為空");
}
if (resultList == null || password == null) {
return error(30000, "賬號或密碼不能為空");
}
//判斷是否有這個用戶
if (resultList.size()<=0){
return error(30000,"用戶不存在");
}
User byUsername = (User) resultList.get(0);
Map groupMap = new HashMap<>();
groupMap.put("name",byUsername.getUserGroup());
List groupList = userGroupService.select(groupMap, new HashMap<>()).getResultList();
if (groupList.size()<1){
return error(30000,"用戶組不存在");
}
UserGroup userGroup = (UserGroup) groupList.get(0);
//查詢用戶審核狀態
if (!StringUtils.isEmpty(userGroup.getSourceTable())){
String sql = "select examine_state from "+ userGroup.getSourceTable() +" WHERE user_id = " + byUsername.getUserId();
String res = String.valueOf(service.runCountSql(sql).getSingleResult());
if (res==null){
return error(30000,"用戶不存在");
}
if (!res.equals("已通過")){
return error(30000,"該用戶審核未通過");
}
}
//查詢用戶狀態
if (byUsername.getState()!=1){
return error(30000,"用戶非可用狀態,不能登錄");
}
String md5password = service.encryption(password);
if (byUsername.getPassword().equals(md5password)) {
// 存儲Token到數據庫
AccessToken accessToken = new AccessToken();
accessToken.setToken(UUID.randomUUID().toString().replaceAll("-", ""));
accessToken.setUser_id(byUsername.getUserId());
tokenService.save(accessToken);
// 返回用戶信息
JSONObject user = JSONObject.parseObject(JSONObject.toJSONString(byUsername));
user.put("token", accessToken.getToken());
JSONObject ret = new JSONObject();
ret.put("obj",user);
return success(ret);
} else {
return error(30000, "賬號或密碼不正確");
}
}
5.2商品展示主要代碼
@RequestMapping(value = "/del")
@Transactional
public Map del(HttpServletRequest request) {
service.delete(service.readQuery(request), service.readConfig(request));
return success(1);
}
@Transactional
public void delete(Map query,Map config){
StringBuffer sql = new StringBuffer("DELETE FROM ").append("`").append(table).append("`").append(" ");
sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.GROUP_BY))));
log.info("[{}] - 刪除操作:{}",table,sql);
Query query1 = runCountSql(sql.toString());
query1.executeUpdate();
}
5.3商品購買主要代碼
@RequestMapping("/get_obj")
public Map obj(HttpServletRequest request) {
Query select = service.select(service.readQuery(request), service.readConfig(request));
List resultList = select.getResultList();
if (resultList.size() > 0) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("obj",resultList.get(0));
return success(jsonObject);
} else {
return success(null);
}
}
public Query select(Map query,Map config){
StringBuffer sql = new StringBuffer("select ");
sql.append(config.get(FindConfig.FIELD) == null || "".equals(config.get(FindConfig.FIELD)) ? "*" : config.get(FindConfig.FIELD)).append(" ");
sql.append("from ").append("`").append(table).append("`").append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
if (config.get(FindConfig.GROUP_BY) != null && !"".equals(config.get(FindConfig.GROUP_BY))){
sql.append("group by ").append(config.get(FindConfig.GROUP_BY)).append(" ");
}
if (config.get(FindConfig.ORDER_BY) != null && !"".equals(config.get(FindConfig.ORDER_BY))){
sql.append("order by ").append(config.get(FindConfig.ORDER_BY)).append(" ");
}
if (config.get(FindConfig.PAGE) != null && !"".equals(config.get(FindConfig.PAGE))){
int page = config.get(FindConfig.PAGE) != null && !"".equals(config.get(FindConfig.PAGE)) ? Integer.parseInt(config.get(FindConfig.PAGE)) : 1;
int limit = config.get(FindConfig.SIZE) != null && !"".equals(config.get(FindConfig.SIZE)) ? Integer.parseInt(config.get(FindConfig.SIZE)) : 10;
sql.append(" limit ").append( (page-1)*limit ).append(" , ").append(limit);
}
log.info("[{}] - 查詢操作,sql: {}",table,sql);
return runEntitySql(sql.toString());
}
5.4在線留言主要代碼
@RequestMapping("/get_list")
public Map getList(HttpServletRequest request) {
Map map = service.selectToPage(service.readQuery(request), service.readConfig(request));
return success(map);
}
5.5商品管理主要代碼
@PostMapping("/upload")
public Map upload(@RequestParam("file") MultipartFile file) {
log.info("進入方法");
if (file.isEmpty()) {
return error(30000, "沒有選擇文件");
}
try {
//判斷有沒路徑,沒有則創建
String filePath = System.getProperty("user.dir") + "\\target\\classes\\static\\upload\\";
File targetDir = new File(filePath);
if (!targetDir.exists() && !targetDir.isDirectory()) {
if (targetDir.mkdirs()) {
log.info("創建目錄成功");
} else {
log.error("創建目錄失敗");
}
}
String fileName = file.getOriginalFilename();
File dest = new File(filePath + fileName);
log.info("文件路徑:{}", dest.getPath());
log.info("文件名:{}", dest.getName());
file.transferTo(dest);
JSONObject jsonObject = new JSONObject();
jsonObject.put("url", "/api/upload/" + fileName);
return success(jsonObject);
} catch (IOException e) {
log.info("上傳失敗:{}", e.getMessage());
}
return error(30000, "上傳失敗");
}
5.6訂單管理主要代碼
@RequestMapping("/get_obj")
public Map obj(HttpServletRequest request) {
Query select = service.select(service.readQuery(request), service.readConfig(request));
List resultList = select.getResultList();
if (resultList.size() > 0) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("obj",resultList.get(0));
return success(jsonObject);
} else {
return success(null);
}
}
public Query select(Map query,Map config){
StringBuffer sql = new StringBuffer("select ");
sql.append(config.get(FindConfig.FIELD) == null || "".equals(config.get(FindConfig.FIELD)) ? "*" : config.get(FindConfig.FIELD)).append(" ");
sql.append("from ").append("`").append(table).append("`").append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
if (config.get(FindConfig.GROUP_BY) != null && !"".equals(config.get(FindConfig.GROUP_BY))){
sql.append("group by ").append(config.get(FindConfig.GROUP_BY)).append(" ");
}
if (config.get(FindConfig.ORDER_BY) != null && !"".equals(config.get(FindConfig.ORDER_BY))){
sql.append("order by ").append(config.get(FindConfig.ORDER_BY)).append(" ");
}
if (config.get(FindConfig.PAGE) != null && !"".equals(config.get(FindConfig.PAGE))){
int page = config.get(FindConfig.PAGE) != null && !"".equals(config.get(FindConfig.PAGE)) ? Integer.parseInt(config.get(FindConfig.PAGE)) : 1;
int limit = config.get(FindConfig.SIZE) != null && !"".equals(config.get(FindConfig.SIZE)) ? Integer.parseInt(config.get(FindConfig.SIZE)) : 10;
sql.append(" limit ").append( (page-1)*limit ).append(" , ").append(limit);
}
log.info("[{}] - 查詢操作,sql: {}",table,sql);
return runEntitySql(sql.toString());
免責聲明:部分文章信息來源于網絡以及網友投稿,本站只負責對文章進行整理、排版、編輯,出于傳遞更多信息之目的,并不意味著贊同其觀點或證實其內容的真實性,如本站文章和轉稿涉及版權等問題,請作者在及時聯系本站,我們會盡快為您處理。