基于javaweb+mysql的springboot前后端分离网上手机商城平台系统设计和实现(java+vue+redis+springboot+mysql+ssm)
运行环境
Java≥8、MySQL≥5.7、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot前后端分离网上手机商城平台系统设计和实现(java+vue+redis+springboot+mysql+ssm)
主要模块设计如下: 前后端主要技术:Java springboot springMVC mybatis mysql vue jquery node.js redis
-
用户注册和登录功能:。
-
用户信息的管理以及角色的管理、不同用户角色具有不同的功能权限操作。
-
商品的操作、包括商品列表信息、商品的分离、商品的详情、品牌和规格等操作。
-
购物车的管理操作:
-
订单管理操作:
6)用户退货管理
7)手机商品类型的管理
8)手机商品信息的预览、查看、搜索
9)修改密码、退出登录等功能
/**
* @email qiudb.top@aliyun.com
* @description 用户相关业务
*/
@RestController
@CrossOrigin
public class UserController {
final RoleService roleService;
final UserService userService;
final UserRoleService userRoleService;
final VipService vipService;
public UserController(UserService userService, RoleService roleService,VipService vipService, UserRoleService userRoleService) {
this.userService = userService;
this.roleService = roleService;
this.userRoleService = userRoleService;
this.vipService = vipService;
}
/*根据id查询用户*/
@RequestMapping(value = "/user/findById")
private CommonResult findById(Integer id) {
User user = userService.selectById(id);
if(user!=null){
return CommonResult.success("查询成功",user);
}else{
return CommonResult.error("查询失败");
}
}
/*根据帐号查询用户*/
@RequestMapping(value = "/user/findByKey")
private CommonResult findByKey(String key) {
User user = userService.selectByKey(key);
if(user!=null){
return CommonResult.success("查询成功",user);
}else{
return CommonResult.error("查询失败");
}
}
/*查询所有用户*/
@RequestMapping(value = "/user/findAll")
* @description 用户授权等相关业务
*/
@RestController
@CrossOrigin
public class RoleController {
final RoleService roleService;
public RoleController(RoleService roleService) {
this.roleService = roleService;
}
/*根据id查询用户*/
@RequestMapping(value = "/role/findById")
private CommonResult findById(Integer roleId) {
Role role = roleService.selectById(roleId);
if(role!=null){
return CommonResult.success("查询成功",role);
}else{
return CommonResult.error("查询失败");
}
}
/*根据角色名称查询角色*/
@RequestMapping(value = "/role/findByKey")
private CommonResult findByKey(String roleName) {
Role role = roleService.selectByKey(roleName);
if(role!=null){
return CommonResult.success("查询成功",role);
}else{
return CommonResult.error("查询失败");
}
}
/*根据key查询用户*/
@RequestMapping(value = "/role/existRoleName")
private CommonResult existRoleName(Integer roleId,String roleName) {
Boolean isExist = roleService.existsRoleName(roleId,roleName);
if(isExist!=null){
return CommonResult.success("查询成功",isExist);
}else{
return CommonResult.error("查询失败");
}
}
/*查询所有角色信息*/
@RequestMapping(value = "/role/findAll")
private CommonResult findAll() {
List<Role> roles = roleService.selectAll();
if(roles!=null){
return CommonResult.success("查询成功",roles);
}else{
if(supplier!=null){
if(supplierService.updateById(supplier)){
return CommonResult.success("更新成功",supplier);
}else{
return CommonResult.error("更新失败");
}
}
return CommonResult.error("供应商数据不存在");
}
/*删除供应商*/
@RequestMapping(value = "/supplier/deleteSupplier")
private CommonResult deleteSupplier(Integer supplierId) {
if(supplierId!=null){
if(supplierService.deleteById(supplierId)){
return CommonResult.success("删除成功",supplierId);
}else{
return CommonResult.error("删除失败");
}
}
return CommonResult.error("供应商数据不存在");
}
/*查询采购信息*/
@RequestMapping(value = "/purchase/findPurchaseById")
private CommonResult findPurchaseById(Integer purchaseId) {
Purchase purchase = purchaseService.selectById(purchaseId);
if(purchase!=null){
return CommonResult.success("采购信息查询成功",purchase);
}else{
return CommonResult.error("采购信息查询失败");
}
}
/*查询全部采购信息*/
@RequestMapping(value = "/purchase/findPurchaseAll")
private CommonResult findPurchaseAll() {
List<Purchase> purchases = purchaseService.selectAll();
if(purchases!=null){
return CommonResult.success("采购信息查询成功",purchases);
}else{
return CommonResult.error("采购信息查询失败");
}
}
/*查询采购编号是否存在*/
@RequestMapping(value = "/purchase/existPurchase")
private CommonResult existPurchase(String purchaseNo) {
Boolean isExist = purchaseService.existsWithPrimaryKey(purchaseNo);
if(isExist!=null){
}
/*根据角色名称查询角色*/
@RequestMapping(value = "/role/findByKey")
private CommonResult findByKey(String roleName) {
Role role = roleService.selectByKey(roleName);
if(role!=null){
return CommonResult.success("查询成功",role);
}else{
return CommonResult.error("查询失败");
}
}
/*根据key查询用户*/
@RequestMapping(value = "/role/existRoleName")
private CommonResult existRoleName(Integer roleId,String roleName) {
Boolean isExist = roleService.existsRoleName(roleId,roleName);
if(isExist!=null){
return CommonResult.success("查询成功",isExist);
}else{
return CommonResult.error("查询失败");
}
}
/*查询所有角色信息*/
@RequestMapping(value = "/role/findAll")
private CommonResult findAll() {
List<Role> roles = roleService.selectAll();
if(roles!=null){
return CommonResult.success("查询成功",roles);
}else{
return CommonResult.error("查询失败");
}
}
/*查询所有用户*/
@RequestMapping(value = "/role/findAllUsable")
private CommonResult findAllUsable() {
List<Role> roles = roleService.selectAllUsable();
if(roles!=null){
return CommonResult.success("查询成功",roles);
}else{
return CommonResult.error("查询失败");
}
}
@RequestMapping(value = "/role/count")
private CommonResult findCount() {
Integer count = roleService.selectCount();
if(count!=null){
return CommonResult.success("查询成功",count);
/**
* @email qiudb.top@aliyun.com
* @description 商品退回 业务控制层
*/
@RestController
@CrossOrigin
public class ReturnProductController {
final ReturnReasonService returnReasonService;
final ReturnGoodsService returnGoodsService;
final LogisticsService logisticsService;
final OrderService orderService;
final ProductService productService;
public ReturnProductController(ProductService productService,OrderService orderService,ReturnReasonService returnReasonService,ReturnGoodsService returnGoodsService,LogisticsService logisticsService){
this.returnReasonService = returnReasonService;
this.returnGoodsService = returnGoodsService;
this.logisticsService = logisticsService;
this.orderService = orderService;
this.productService = productService;
}
/*退货原因*/
@RequestMapping(value = "/returnReason/findReasonById")
private CommonResult findReasonById(Integer reasonId) {
ReturnReason returnReason = returnReasonService.selectById(reasonId);
if(returnReason!=null){
return CommonResult.success("退货原因查询成功",returnReason);
}else{
return CommonResult.error("退货原因查询失败");
}
}
/*查询全部退货原因*/
@RequestMapping(value = "/returnReason/findAllReason")
private CommonResult findAllReason() {
List<ReturnReason> returnReasons = returnReasonService.selectAll();
if(returnReasons!=null){
}
}
@RequestMapping(value = "/product/findAllLikeType")
private CommonResult findAllLikeType(String keyWord) {
List<Product> products = productService.selectAllLikeType(keyWord);
if(products!=null){
return CommonResult.success("全部商品信息查询成功",products);
}else{
return CommonResult.error("全部商品信息查询失败");
}
}
@RequestMapping(value = "/product/findAllLikeBrand")
private CommonResult findAllLikeBrand(String keyWord) {
List<Product> products = productService.selectAllLikeBrand(keyWord);
if(products!=null){
return CommonResult.success("全部商品信息查询成功",products);
}else{
return CommonResult.error("全部商品信息查询失败");
}
}
@RequestMapping(value = "/product/findAllByType")
private CommonResult findAllByType() {
List<Map<String, Object>> maps = productService.selectAllByType();
if(maps!=null){
return CommonResult.success("商品分类信息查询成功",maps);
}else{
return CommonResult.error("商品分类信息查询失败");
}
}
@RequestMapping(value = "/product/add")
private CommonResult add(Product product) {
System.out.println(product);
if(productService.insertData(product)){
return CommonResult.success("添加商品成功",product);
}else{
return CommonResult.error("添加商品失败");
}
}
@RequestMapping(value = "/product/update")
private CommonResult update(Product product) {
if(product.getIsNew()!=null && product.getIsNew()){
/**
* @email qiudb.top@aliyun.com
* @description 商品规格、商品与商品规格的关联
*/
@RestController
@CrossOrigin
public class SpecsController {
final SpecsService specsService;
final ProductSpecsService productSpecsService;
public SpecsController(SpecsService specsService,ProductSpecsService productSpecsService) {
this.specsService = specsService;
this.productSpecsService = productSpecsService;
}
/*根据id查询规格*/
@RequestMapping(value = "/specs/findById")
private CommonResult findById(Integer specsId) {
Specs specs = specsService.selectById(specsId);
if(specs!=null){
return CommonResult.success("查询成功",specs);
}else{
return CommonResult.error("查询失败");
}
}
/*查询所有规格信息*/
@RequestMapping(value = "/specs/findAll")
private CommonResult findAllSpecs() {
List<Specs> specs = specsService.selectAll();
if(specs!=null){
return CommonResult.success("查询成功",specs);
}else{
return CommonResult.error("查询失败");
}
}
@RequestMapping(value = "/specs/existsSpecsName")
private CommonResult existsSpecsName(Integer specsId, String specsName, String productType) {
Boolean isExist = specsService.existsWithSpecsName(specsId,specsName,productType);
if(isExist!=null){
return CommonResult.success("查询成功",isExist);
}else{
final ReturnGoodsService returnGoodsService;
final LogisticsService logisticsService;
final OrderService orderService;
final ProductService productService;
public ReturnProductController(ProductService productService,OrderService orderService,ReturnReasonService returnReasonService,ReturnGoodsService returnGoodsService,LogisticsService logisticsService){
this.returnReasonService = returnReasonService;
this.returnGoodsService = returnGoodsService;
this.logisticsService = logisticsService;
this.orderService = orderService;
this.productService = productService;
}
/*退货原因*/
@RequestMapping(value = "/returnReason/findReasonById")
private CommonResult findReasonById(Integer reasonId) {
ReturnReason returnReason = returnReasonService.selectById(reasonId);
if(returnReason!=null){
return CommonResult.success("退货原因查询成功",returnReason);
}else{
return CommonResult.error("退货原因查询失败");
}
}
/*查询全部退货原因*/
@RequestMapping(value = "/returnReason/findAllReason")
private CommonResult findAllReason() {
List<ReturnReason> returnReasons = returnReasonService.selectAll();
if(returnReasons!=null){
return CommonResult.success("退货原因查询成功",returnReasons);
}else{
return CommonResult.error("退货原因查询失败");
}
}
/*查询全部退货原因名称*/
@RequestMapping(value = "/returnReason/findReasonName")
private CommonResult findReasonName() {
List<String> names = returnReasonService.selectAllName();
if(names!=null){
return CommonResult.success("退货原因查询成功",names);
}else{
return CommonResult.error("退货原因查询失败");
}
}
/*查询退货原因是否存在*/
@RequestMapping(value = "/returnReason/existReasonName")
private CommonResult existReasonName(Integer reasonId,String reasonName) {
Boolean isExist = returnReasonService.existsWithReasonName(reasonId,reasonName);
Product newProduct = new Product();
newProduct.setProductId(product.getProductId());
int newStock = productStock - payAmount;
newProduct.setProductStock(newStock);
newProduct.setIsStockOut(newStock<product.getLowestStock());
// 如果库存小于等于0,自动下架
newProduct.setIsSale(newStock>0);
if(productService.updateById(newProduct)){
if(orderService.insertData(order)){
redisTemplate.opsForValue().set(order.getOrderNo(),order.getOrderNo(),24, TimeUnit.HOURS);
return CommonResult.success("创建订单成功",order);
}else{
return CommonResult.error("创建订单失败");
}
}else{
return CommonResult.error("创建订单失败");
}
}else{
return CommonResult.error("商品库存不足");
}
}
}else{
return CommonResult.error("订单数据不完整");
}
}
@RequestMapping(value = "/order/cartOrder")
private CommonResult cartOrder(String orderNo,String ordersInfo) {
JSONArray jsonArray = JSON.parseArray(ordersInfo);
List<Order> orders = JSONObject.parseArray(jsonArray.toJSONString(), Order.class);
if(orders!=null){
ArrayList<String> orderInfo = new ArrayList<>();
ArrayList<String> productInfo = new ArrayList<>();
for (Order order : orders) {
Product product = productService.selectByKey(order.getProductNo());
Integer productStock = product.getProductStock();
Integer payAmount = order.getPayAmount();
boolean isOk =productStock >= payAmount;
if(isOk){
Product newProduct = new Product();
newProduct.setProductId(product.getProductId());
int newStock = productStock - payAmount;
newProduct.setProductStock(newStock);
newProduct.setIsStockOut(newStock<product.getLowestStock());
// 如果库存小于等于0,自动下架
newProduct.setIsSale(newStock>0);
if(productService.updateById(newProduct)){
if(orderService.insertData(order)){
orderInfo.add(order.getOrderNo());
/**
* @email qiudb.top@aliyun.com
* @description 登录、退出、修改个人信息等业务操作
*/
@RestController
@CrossOrigin
public class OperateController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
final RoleService roleService;
final UserService userService;
final UserRoleService userRoleService;
public OperateController(UserService userService, RoleService roleService, UserRoleService userRoleService) {
this.userService = userService;
this.roleService = roleService;
this.userRoleService = userRoleService;
}
}else{
return CommonResult.error("添加失败");
}
}
return CommonResult.error("数据不存在");
}
@RequestMapping(value = "/productSpecs/update")
private CommonResult update(ProductSpecs productSpecs) {
if(productSpecsService.updateById(productSpecs)){
return CommonResult.success("更新成功",productSpecs);
}else{
return CommonResult.error("更新失败");
}
}
@RequestMapping(value = "/productSpecs/delete")
private CommonResult delete(ProductSpecs productSpecs) {
if(productSpecsService.deleteById(productSpecs)){
return CommonResult.success("删除成功",productSpecs);
}else{
return CommonResult.error("删除失败");
}
}
}
package com.qiu.controller;
/**
* @email qiudb.top@aliyun.com
* @description 用户授权等相关业务
*/
@RestController
@CrossOrigin
public class RoleController {
final RoleService roleService;
public RoleController(RoleService roleService) {
}
}
package com.qiu.controller;
@CrossOrigin
@RequestMapping("/alipay")
@Slf4j
@Controller
public class AlipayController {
private final AlipayService alipayService;
private final OrderService orderService;
private final RedisTemplate<String,String> redisTemplate;
private final String hostAddress;
public AlipayController(AlipayService alipayService,OrderService orderService,RedisTemplate<String,String> redisTemplate) {
this.alipayService = alipayService;
this.orderService = orderService;
this.redisTemplate = redisTemplate;
this.hostAddress= PropertiesUtil.getServerHost() +":"+PropertiesUtil.getPort();
}
@RequestMapping("/")
private String index(){
return "index.html";
}
}
@RequestMapping(value = "/productType/deleteById")
private CommonResult deleteTypeById(Integer typeId) {
if(productTypeService.deleteById(typeId)){
return CommonResult.success("商品分类删除成功","typeId: "+typeId);
}else{
return CommonResult.error("商品分类删除失败");
}
}
@RequestMapping(value = "/productType/deleteByName")
private CommonResult deleteTypeByName(String typeName) {
if(productTypeService.deleteByName(typeName)){
return CommonResult.success("商品分类删除成功","typeName: "+typeName);
}else{
return CommonResult.error("商品分类删除失败");
}
}
@RequestMapping(value = "/productType/existsTypeName")
private CommonResult existsTypeName(Integer typeId,String typeName) {
Boolean isExist = productTypeService.existsWithTypeName(typeId,typeName);
if(isExist!=null){
return CommonResult.success("查询成功",isExist);
}else{
return CommonResult.error("查询失败");
}
}
@RequestMapping(value = "/productType/findAll")
private CommonResult findAllType() {
List<ProductType> productTypes = productTypeService.selectAll();
if(productTypes!=null){
return CommonResult.success("商品分类查询成功",productTypes);
}else{
return CommonResult.error("商品分类查询失败");
}
}
@RequestMapping(value = "/productType/findAllName")
private CommonResult findAllTypeName() {
List<String> names = productTypeService.selectAllName();
if(names!=null){
return CommonResult.success("商品分类名称查询成功",names);
return CommonResult.error("商品分类删除失败");
}
}
@RequestMapping(value = "/productType/existsTypeName")
private CommonResult existsTypeName(Integer typeId,String typeName) {
Boolean isExist = productTypeService.existsWithTypeName(typeId,typeName);
if(isExist!=null){
return CommonResult.success("查询成功",isExist);
}else{
return CommonResult.error("查询失败");
}
}
@RequestMapping(value = "/productType/findAll")
private CommonResult findAllType() {
List<ProductType> productTypes = productTypeService.selectAll();
if(productTypes!=null){
return CommonResult.success("商品分类查询成功",productTypes);
}else{
return CommonResult.error("商品分类查询失败");
}
}
@RequestMapping(value = "/productType/findAllName")
private CommonResult findAllTypeName() {
List<String> names = productTypeService.selectAllName();
if(names!=null){
return CommonResult.success("商品分类名称查询成功",names);
}else{
return CommonResult.error("商品分类名称查询失败");
}
}
/*商品品牌*/
@RequestMapping(value = "/productBrand/add")
private CommonResult addBrand(ProductBrand productBrand) {
if(productBrandService.insertData(productBrand)){
return CommonResult.success("商品品牌添加成功",productBrand);
}else{
return CommonResult.error("商品品牌添加失败");
}
}
@RequestMapping(value = "/productBrand/update")
private CommonResult updateBrand(ProductBrand productBrand) {
if(productBrandService.updateById(productBrand)){
return CommonResult.success("商品品牌修改成功",productBrand);
}else{
return CommonResult.error("商品品牌修改失败");
}
}
@RequestMapping(value = "/productBrand/deleteById")
}
if(orderInfo.size()!=0){
String orderNoInfo = StringUtils.join(orderInfo, ",");
String productNoInfo = StringUtils.join(productInfo, ",");
redisTemplate.opsForValue().set(orderNo,orderNoInfo,24, TimeUnit.HOURS);
return CommonResult.success("创建订单成功",productNoInfo);
}else{
return CommonResult.success("创建订单失败");
}
}else{
return CommonResult.error("订单数据不完整");
}
}
@RequestMapping(value = "/order/update")
private CommonResult updateOrder(Order order) {
if(orderService.updateById(order)){
return CommonResult.success("修改订单成功",order);
}else{
return CommonResult.error("修改订单失败");
}
}
@RequestMapping(value = "/order/delete")
private CommonResult deleteOrder(Integer orderId) {
if(orderService.deleteById(orderId)){
return CommonResult.success("删除订单成功","订单id:"+orderId);
}else{
return CommonResult.error("删除订单失败");
}
}
@RequestMapping(value = "/order/receipt")
private CommonResult updateOrder(Integer orderId) {
Order order = new Order();
order.setOrderId(orderId);
order.setOrderState("已收货");
if(orderService.updateById(order)){
return CommonResult.success("商品收货成功",order);
}else{
return CommonResult.error("商品收货失败");
}
}
@RequestMapping(value = "/orderDetail/orderInfo")
private CommonResult orderInfo(String orderNo) {
return CommonResult.success("查询成功","id: "+id);
}else{
return CommonResult.error("查询失败");
}
}
@RequestMapping(value = "/role/add")
private CommonResult add(Role role) {
if(role!=null){
if(roleService.insertData(role)){
return CommonResult.success("添加成功",role);
}else{
return CommonResult.error("添加失败");
}
}
return CommonResult.error("用户数据不存在");
}
@RequestMapping(value = "/role/update")
private CommonResult update(Role role) {
System.out.println(role);
if(roleService.updateById(role)){
return CommonResult.success("更新成功",role);
}else{
return CommonResult.error("更新失败");
}
}
@RequestMapping(value = "/role/delete")
private CommonResult delete(Integer roleId) {
if(roleService.deleteById(roleId)){
return CommonResult.success("删除成功",roleId);
}else{
return CommonResult.error("删除失败");
}
}
}
package com.qiu.controller;
}else{
return CommonResult.error("查询失败");
}
}
/*根据key查询用户*/
@RequestMapping(value = "/role/existRoleName")
private CommonResult existRoleName(Integer roleId,String roleName) {
Boolean isExist = roleService.existsRoleName(roleId,roleName);
if(isExist!=null){
return CommonResult.success("查询成功",isExist);
}else{
return CommonResult.error("查询失败");
}
}
/*查询所有角色信息*/
@RequestMapping(value = "/role/findAll")
private CommonResult findAll() {
List<Role> roles = roleService.selectAll();
if(roles!=null){
return CommonResult.success("查询成功",roles);
}else{
return CommonResult.error("查询失败");
}
}
/*查询所有用户*/
@RequestMapping(value = "/role/findAllUsable")
private CommonResult findAllUsable() {
List<Role> roles = roleService.selectAllUsable();
if(roles!=null){
return CommonResult.success("查询成功",roles);
}else{
return CommonResult.error("查询失败");
}
}
@RequestMapping(value = "/role/count")
private CommonResult findCount() {
Integer count = roleService.selectCount();
return CommonResult.success("物流信息查询成功",logistics);
}else{
return CommonResult.error("物流信息查询失败");
}
}
@RequestMapping(value = "/logistics/addInfo")
private CommonResult addInfo(Logistics logistics) {
if(logistics!=null){
if(logisticsService.insertData(logistics)){
return CommonResult.success("物流信息添加成功",logistics);
}else{
return CommonResult.error("物流信息添加失败");
}
}
return CommonResult.error("物流信息数据不存在");
}
@RequestMapping(value = "/logistics/deleteInfo")
private CommonResult deleteInfo(Integer logisticId) {
if(logisticId!=null){
if(logisticsService.deleteById(logisticId)){
return CommonResult.success("物流信息删除成功",logisticId);
}else{
return CommonResult.error("物流信息删除失败");
}
}
return CommonResult.error("物流信息数据不存在");
}
@RequestMapping(value = "/orderDetail/returnInfo")
private CommonResult returnInfo(String orderNo) {
ArrayList<Object> resultList = new ArrayList<>();
Map<String, Object> returnGoods = returnGoodsService.selectOrderNo(orderNo);
Logistics logistics = logisticsService.selectOrderNo(orderNo);
if(returnGoods!=null){
resultList.add(returnGoods);
}
if(logistics!=null){
resultList.add(logistics);
}
if(resultList.size()!=0){
return CommonResult.success("退货订单详情查询成功",resultList);
}else{
return CommonResult.error("退货订单详情查询失败");
}
}
}
package com.qiu.controller;