开发工具:IDEA
服务器:Tomcat9.0, jdk1.8
项目构建:maven
数据库:mysql5.7
系统用户前台和管理后台两部分,项目采用前后端分离
前端技术:vue +elementUI
服务端技术:springboot+mybatis
项目功能描述:
一、前台功能
1、登录、注册、搜索商品、首页、商品详情
2、发送留言、回复留言、发布闲置、留言消息
3、下架闲置、收藏商品,取消收藏、立即购买
4、取消订单、立即支付、发货、确认收货
5、个人中心:修改头像、编辑个人信息、修改密码
6、我的发布、我的下架、我的收藏、我的卖出、我买到的
7、收货地址:添加、修改、删除、设置默认
退出登录等功能
二、后台功能
登录、闲置管理、订单管理、用户管理
前台截图:
后台截图:
package com.second.hand.trading.server.service.impl;import com.second.hand.trading.server.dao.IdleItemDao;
import com.second.hand.trading.server.dao.MessageDao;
import com.second.hand.trading.server.dao.UserDao;
import com.second.hand.trading.server.model.IdleItemModel;
import com.second.hand.trading.server.model.MessageModel;
import com.second.hand.trading.server.model.UserModel;
import com.second.hand.trading.server.service.MessageService;
import org.springframework.stereotype.Service;import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;@Service
public class MessageServiceImpl implements MessageService {@Resourceprivate MessageDao messageDao;@Resourceprivate UserDao userDao;@Resourceprivate IdleItemDao idleItemDao;/*** 增加一条留言* @param messageModel* @return*/public boolean addMessage(MessageModel messageModel){return messageDao.insert(messageModel)==1;}/*** 删除一条留言,未做用户身份验证* @param id* @return*/public boolean deleteMessage(Long id){return messageDao.deleteByPrimaryKey(id)==1;}/*** 获取一条留言* @param id* @return*/public MessageModel getMessage(Long id){return messageDao.selectByPrimaryKey(id);}/*** 获取一个用户收到的所有留言,未做分页查询* 同时查询出用户的信息和闲置的信息* userId建索引* @param userId* @return*/public List<MessageModel> getAllMyMessage(Long userId){List<MessageModel> list=messageDao.getMyMessage(userId);if(list.size()>0){List<Long> idList=new ArrayList<>();for(MessageModel i:list){idList.add(i.getUserId());}List<UserModel> userList=userDao.findUserByList(idList);Map<Long,UserModel> map=new HashMap<>();for(UserModel user:userList){map.put(user.getId(),user);}for(MessageModel i:list){i.setFromU(map.get(i.getUserId()));}List<Long> idleIdList=new ArrayList<>();for(MessageModel i:list){idleIdList.add(i.getIdleId());}List<IdleItemModel> idleList=idleItemDao.findIdleByList(idleIdList);Map<Long,IdleItemModel> idleMap=new HashMap<>();for(IdleItemModel idle:idleList){idleMap.put(idle.getId(),idle);}for(MessageModel i:list){i.setIdle(idleMap.get(i.getIdleId()));}}return list;}/*** 查询一个闲置下的所有留言,未做分页* 同时查出发送者和接收者的信息* idleId建索引* @param idleId* @return*/public List<MessageModel> getAllIdleMessage(Long idleId){List<MessageModel> list=messageDao.getIdleMessage(idleId);if(list.size()>0){List<Long> idList=new ArrayList<>();for(MessageModel i:list){idList.add(i.getUserId());}List<UserModel> userList=userDao.findUserByList(idList);Map<Long,UserModel> map=new HashMap<>();for(UserModel user:userList){map.put(user.getId(),user);}for(MessageModel i:list){i.setFromU(map.get(i.getUserId()));}Map<Long,MessageModel> mesMap=new HashMap<>();for(MessageModel i:list){mesMap.put(i.getId(),i);}for(MessageModel i:list){MessageModel toM=new MessageModel();UserModel toU=new UserModel();if(i.getToMessage()!=null){toM.setContent(mesMap.get(i.getToMessage()).getContent());toU.setNickname(map.get(i.getToUser()).getNickname());}i.setToM(toM);i.setToU(toU);}}return list;}
}
package com.second.hand.trading.server.service.impl;
import com.second.hand.trading.server.dao.OrderAddressDao;
import com.second.hand.trading.server.model.OrderAddressModel;
import com.second.hand.trading.server.service.OrderAddressService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class OrderAddressServiceImpl implements OrderAddressService {
@Resource
private OrderAddressDao orderAddressDao;
/**
* 为订单新增地址信息
* @param orderAddressModel
* @return
*/
public boolean addOrderAddress(OrderAddressModel orderAddressModel){
return orderAddressDao.insert(orderAddressModel)==1;
}
/**
* 更新订单的地址信息,未验证用户身份
* @param orderAddressModel
* @return
*/
public boolean updateOrderAddress(OrderAddressModel orderAddressModel){
orderAddressModel.setOrderId(null);
return orderAddressDao.updateByPrimaryKeySelective(orderAddressModel)==1;
}
/**
* 获取订单的地址信息
* orderId建索引
* @param orderId
* @return
*/
public OrderAddressModel getOrderAddress(Long orderId){
return orderAddressDao.selectByOrderId(orderId);
}
}