家居建材商城|基于Springboot+Vue实现家居建材商城(三)

简介: 家居建材商城|基于Springboot+Vue实现家居建材商城

家居建材商城|基于Springboot+Vue实现家居建材商城(二)https://developer.aliyun.com/article/1423365


package com.qiu.controller;
import com.qiu.entity.Product;
import com.qiu.entity.Purchase;
import com.qiu.entity.StoreEntity;
import com.qiu.service.ProductService;
import com.qiu.service.PurchaseService;
import com.qiu.service.StoreService;
import com.qiu.util.general.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 *  商铺管理和商品入库
 */
@CrossOrigin
@RestController
public class StoreController {
    @Autowired
    private StoreService storeService;
    @Autowired
    private PurchaseService purchaseService;
    @Autowired
    private ProductService productService;
    /**
     * 查询商铺信息
     */
    @RequestMapping(value = "/store/findByStore")
    public CommonResult findByNumber(StoreEntity store) {
        StoreEntity storeEntity = storeService.selectByStore(store);
        if (storeEntity != null) {
            return CommonResult.success("商铺查询成功", storeEntity);
        }
        return CommonResult.error("商铺查询失败");
    }
    /**
     * 查询全部商铺
     */
    @RequestMapping(value = "/store/findAll")
    public CommonResult findAll() {
        List<StoreEntity> stores = storeService.selectAll();
        if (stores != null) {
            return CommonResult.success("商铺查询成功", stores);
        }
        return CommonResult.error("商铺查询失败");
    }
    /**
     * 商铺入驻申请
     * @param store 商铺信息
     */
    @RequestMapping(value = "/store/addStore")
    public CommonResult addStore(StoreEntity store) {
        if (store != null) {
            if (storeService.insertData(store)) {
                return CommonResult.success("店铺入驻申请已发送", store);
            }
            return CommonResult.error("申请发送失败");
        }
        return CommonResult.error("商铺注册数据不存在");
    }
    /**
     * 通过商铺编号更新商铺信息
     *
     * @param store 商铺信息
     */
    @RequestMapping(value = "/store/updateStore")
    public CommonResult updateStoreEntity(StoreEntity store) {
        if (store != null) {
            if (storeService.updateByStore(store)) {
                return CommonResult.success("更新成功", store);
            }
            return CommonResult.error("更新失败");
        }
        return CommonResult.error("商铺数据不存在");
    }
    /**
     * 更新商铺状态
     * @param store 商铺信息
     * @return
     */
    @RequestMapping(value = "/store/updateStoreStatus")
    public CommonResult updateStoreStatus(StoreEntity store) {
        if (store != null) {
            if (storeService.updateStoreStatus(store)) {
                return CommonResult.success("更新成功");
            }
            return CommonResult.error("更新失败");
        }
        return CommonResult.error("商铺数据不存在");
    }
    /**
     * 删除供应商
     * @param storeNumber 供应商编号
     */
    @RequestMapping(value = "/store/deleteStore")
    public CommonResult deleteStoreById(Integer storeNumber) {
        if (storeNumber != null) {
            if (storeService.deleteById(storeNumber)) {
                return CommonResult.success("删除成功", storeNumber);
            }
            return CommonResult.error("删除失败");
        }
        return CommonResult.error("商铺数据不存在");
    }
    //-------------------------------------------商品入库操作------------------------------------------------
    /**
     * 查询入库信息
     * @param purchaseId 入库编号
     */
    @RequestMapping(value = "/purchase/findPurchaseById")
    public CommonResult findPurchaseById(Integer purchaseId) {
        Purchase purchase = purchaseService.selectById(purchaseId);
        if (purchase != null) {
            return CommonResult.success("入库信息查询成功", purchase);
        }
        return CommonResult.error("入库信息查询失败");
    }
    /**
     * 查询全部入库信息
     */
    @RequestMapping(value = "/purchase/findPurchaseAll")
    public CommonResult findPurchaseAll(String accountNumber) {
        List<Purchase> purchases = purchaseService.selectAll(accountNumber);
        if (purchases != null) {
            return CommonResult.success("入库信息查询成功", purchases);
        }
        return CommonResult.error("入库信息查询失败");
    }
    /**
     * 添加入库记录
     * @param purchase 入库信息
     */
    @RequestMapping(value = "/purchase/addPurchase")
    public CommonResult addPurchase(Purchase purchase) {
        if (purchase != null) {
            //1.添加商品库存
            Integer productId = productService.selectIdByKey(purchase.getProductNo());
            Product product = productService.selectById(productId);
            Integer lowestStock = product.getLowestStock();
            Integer productStock = product.getProductStock();
            Integer purchaseNumber =Integer.parseInt(purchase.getPurchaseNumber());
            product.setProductStock(productStock + purchaseNumber);
            product.setIsStockOut(product.getProductStock() < lowestStock);
            if (productService.updateById(product)) {//库存信息更新成功
                purchaseService.insertData(purchase);//插入一条入库记录
                return CommonResult.success("商品入库成功", purchase);
            }
            return CommonResult.error("商品库存更新失败");
        }
        return CommonResult.error("系统繁忙,请稍后再试!");
    }
    /**
     * 删除入库记录
     *
     * @param purchaseId 入库id
     */
    @RequestMapping(value = "/purchase/deletePurchase")
    public CommonResult deletePurchase(Integer purchaseId) {
        if (purchaseId != null) {
            if (purchaseService.deleteById(purchaseId)) {
                return CommonResult.success("删除成功", purchaseId);
            }
            return CommonResult.error("删除失败");
        }
        return CommonResult.error("入库信息数据不存在,请刷新重试");
    }
}
package com.qiu.controller;
import com.qiu.constant.UserStatusEnum;
import com.qiu.entity.User;
import com.qiu.entity.UserRole;
import com.qiu.entity.Vip;
import com.qiu.service.UserRoleService;
import com.qiu.service.UserService;
import com.qiu.service.VipService;
import com.qiu.util.general.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
 *  用户相关业务
 */
@CrossOrigin
@RestController
public class UserController {
    @Autowired
    private UserService userService;
    @Autowired
    private UserRoleService userRoleService;
    @Autowired
    private VipService vipService;
    /**
     * 根据id查询用户
     *
     * @param id 用户编号
     */
    @RequestMapping(value = "/user/findById")
    public CommonResult findById(Integer id) {
        User user = userService.selectById(id);
        if (user != null) {
            return CommonResult.success("查询成功", user);
        } else {
            return CommonResult.error("查询失败");
        }
    }
    /**
     * 根据账号查询用户
     *
     * @param key 账号
     */
    @RequestMapping(value = "/user/findByKey")
    public CommonResult findByKey(String key) {
        User user = userService.selectByKey(key);
        if (user != null) {
            return CommonResult.success("查询成功", user);
        }
        return CommonResult.error("查询失败");
    }
    /**
     * 查询所有顾客
     */
    @RequestMapping(value = "/user/findAll/customer")
    public CommonResult findAllCustomer() {
        List<User> users = userService.queryAllByStatus(UserStatusEnum.CUSTOMER);
        if (users != null) {
            return CommonResult.success("查询成功", users);
        }
        return CommonResult.error("查询失败");
    }
    /**
     * 查询所有管理员
     */
    @RequestMapping(value = "/user/findAll/admin")
    public CommonResult findAllAdmin() {
        List<User> users = userService.queryAllByStatus(UserStatusEnum.ADMIN);
        if (users != null) {
            return CommonResult.success("查询成功", users);
        }
        return CommonResult.error("查询失败");
    }
//    /**
//     * 查询商家的商铺编号
//     */
//    @RequestMapping(value = "/user/storeNumber")
//    public CommonResult findStoreNumber(String accountNumber) {
//        String storeNumber= userService.selectStoreNumber(accountNumber);
//        if (storeNumber != null) {
//            return CommonResult.success("商铺编号查询成功", storeNumber);
//        }
//        return CommonResult.error("商铺编号查询失败");
//    }
    /**
     * 判断某个用户是否还存在
     *
     * @param key 账号
     */
    @RequestMapping(value = "/user/existKey")
    public CommonResult existKey(String key) {
        boolean exist = userService.existsWithPrimaryKey(key);
        return CommonResult.success("查询成功", exist);
    }
    /**
     * 查询用户状态
     *
     * @param accountNumber 用户账号
     */
    @RequestMapping(value = "/user/userState")
    public CommonResult userState(String accountNumber) {
        boolean state = userService.selectUserState(accountNumber);
        return CommonResult.success("查询成功", state);
    }
    /**
     * 查询用户记录的总个数
     */
    @RequestMapping(value = "/user/count")
    public CommonResult findCount() {
        int count = userService.selectCount();
        return CommonResult.success("查询成功", count);
    }
    /**
     * 通过用户账号查询用户ID
     *
     * @param key 用户账号
     */
    @RequestMapping(value = "/user/findIdByKey")
    public CommonResult findIdByKey(String key) {
        Integer id = userService.selectIdByKey(key);
        if (id != null) {
            return CommonResult.success("查询成功", id);
        }
        return CommonResult.error("未查询到");
    }
    /**
     * 删除用户
     *
     * @param userId 用户编号
     */
    @RequestMapping(value = "/user/delete")
    public CommonResult delete(Integer userId) {
        if (userService.deleteById(userId)) {
            return CommonResult.success("删除成功", userId);
        }
        return CommonResult.error("删除失败");
    }
    /**
     * 角色授权
     *
     * @param userId 用户编号
     * @param roleId 角色编号列表
     */
    @RequestMapping(value = "/user/author")
    public CommonResult author(Integer userId, @RequestParam List<Integer> roleId) {
        if (userId != null && roleId != null && !roleId.isEmpty()) {
            if (userRoleService.deleteById(userId)) {
                UserRole userRole = new UserRole();
                userRole.setUserId(userId);
                for (Integer id : roleId) {
                    userRole.setRoleId(id);
                    userRoleService.insertData(userRole);
                }
            }
            User user = new User();
            user.setUserId(userId);
            user.setStatus(UserStatusEnum.ADMIN);
            userService.updateById(user);
            return CommonResult.success("授权成功");
        } else {
            return CommonResult.error("角色授权数据不完整!");
        }
    }
    /**
     * 查询所有VIP用户
     */
    @RequestMapping(value = "/vip/findAllVip")
    public CommonResult findAllVip() {
        List<Vip> vips = vipService.selectAll();
        if (vips != null) {
            return CommonResult.success("查询成功", vips);
        }
        return CommonResult.error("查询失败");
    }
    /**
     * 查询VIP用户信息根据id
     *
     * @param vipId 会员编号
     */
    @RequestMapping(value = "/vip/findVipById")
    public CommonResult findVipById(Integer vipId) {
        Vip vip = vipService.selectById(vipId);
        if (vip != null) {
            return CommonResult.success("查询成功", vip);
        }
        return CommonResult.error("查询失败");
    }
    /**
     * 查询VIP用户信息根据id
     *
     * @param accountNumber 用户账号
     */
    @RequestMapping(value = "/vip/findVipByKey")
    public CommonResult findVipByKey(String accountNumber) {
        Vip vip = vipService.selectByKey(accountNumber);
        if (vip != null) {
            return CommonResult.success("查询成功", vip);
        }
        return CommonResult.error("查询失败");
    }
    /**
     * 判断用户信息是否存在
     *
     * @param accountNumber 用户账号
     */
    @RequestMapping(value = "/vip/existsVip")
    public CommonResult existsVip(String accountNumber) {
        boolean exist = vipService.existsVip(accountNumber);
        return CommonResult.success("查询成功", exist);
    }
    /**
     * 增加会员信息
     *
     * @param vip 会员信息
     */
    @RequestMapping(value = "/vip/addVip")
    public CommonResult addVip(Vip vip) {
        Date date = new Date();
        Calendar cal = Calendar.getInstance();
        //设置起时间
        cal.setTime(date);
        //增加一年
        cal.add(Calendar.YEAR, 1);
        vip.setOverdueTime(cal.getTime());
        if (vipService.insertData(vip)) {
            return CommonResult.success("会员信息添加成功", vip);
        }
        return CommonResult.error("会员信息添加失败");
    }
    /**
     * 更新会员信息
     *
     * @param vip 会员信息
     */
    @RequestMapping(value = "/vip/updateVip")
    public CommonResult updateVip(Vip vip) {
        if (vipService.updateById(vip)) {
            return CommonResult.success("会员信息更新成功", vip);
        }
        return CommonResult.error("会员信息更新失败");
    }
    /**
     * 清除信息
     *
     * @param vipId 会员编号
     */
    @RequestMapping(value = "/vip/deleteVip")
    public CommonResult deleteVip(Integer vipId) {
        if (vipService.deleteById(vipId)) {
            return CommonResult.success("删除成功", vipId);
        }
        return CommonResult.error("删除失败");
    }
}

五,项目总结

表结构及ER图

本系统用到了18张表存储数据,分别是banner(商品广告轮播图表)、

Logistics(物流表)、order(订单表)、product(商品表)、product_brand(商品品牌表)、product_review(商品评价表)、product_specs(商品规格表)、product_type(商品类型推荐表)、purchase(商品入库记录表)、return_goods(商品退货表)、return_reason(退货原因表)、role(角色表)、shopping_cart(购物车表)、specs(商品规格表)、store(商铺信息表)、sys_commodity_type(商品类型表)、user(用户表)、user_role(用户角色表)。

相关文章
基于springboot的家具商城销售系统
在数字化转型背景下,传统家具销售面临挑战。本研究基于Java、MySQL、Vue和Spring Boot技术,构建高效、智能的家具商城销售系统,推动行业线上线下融合,提升用户体验与企业竞争力,助力家具产业可持续发展。
|
前端开发 Java 关系型数据库
基于Java+Springboot+Vue开发的鲜花商城管理系统源码+运行
基于Java+Springboot+Vue开发的鲜花商城管理系统(前后端分离),这是一项为大学生课程设计作业而开发的项目。该系统旨在帮助大学生学习并掌握Java编程技能,同时锻炼他们的项目设计与开发能力。通过学习基于Java的鲜花商城管理系统项目,大学生可以在实践中学习和提升自己的能力,为以后的职业发展打下坚实基础。技术学习共同进步
1064 7
|
JavaScript 前端开发 Java
制造业ERP源码,工厂ERP管理系统,前端框架:Vue,后端框架:SpringBoot
这是一套基于SpringBoot+Vue技术栈开发的ERP企业管理系统,采用Java语言与vscode工具。系统涵盖采购/销售、出入库、生产、品质管理等功能,整合客户与供应商数据,支持在线协同和业务全流程管控。同时提供主数据管理、权限控制、工作流审批、报表自定义及打印、在线报表开发和自定义表单功能,助力企业实现高效自动化管理,并通过UniAPP实现移动端支持,满足多场景应用需求。
1554 1
|
前端开发 安全 Java
基于springboot+vue开发的会议预约管理系统
一个完整的会议预约管理系统,包含前端用户界面、管理后台和后端API服务。 ### 后端 - **框架**: Spring Boot 2.7.18 - **数据库**: MySQL 5.6+ - **ORM**: MyBatis Plus 3.5.3.1 - **安全**: Spring Security + JWT - **Java版本**: Java 11 ### 前端 - **框架**: Vue 3.3.4 - **UI组件**: Element Plus 2.3.8 - **构建工具**: Vite 4.4.5 - **状态管理**: Pinia 2.1.6 - **HTTP客户端
1902 4
基于springboot+vue开发的会议预约管理系统
|
前端开发 JavaScript Java
基于springboot+vue开发的校园食堂评价系统【源码+sql+可运行】【50809】
本系统基于SpringBoot与Vue3开发,实现校园食堂评价功能。前台支持用户注册登录、食堂浏览、菜品查看及评价发布;后台提供食堂、菜品与评价管理模块,支持权限控制与数据维护。技术栈涵盖SpringBoot、MyBatisPlus、Vue3、ElementUI等,适配响应式布局,提供完整源码与数据库脚本,可直接运行部署。
774 6
基于springboot+vue开发的校园食堂评价系统【源码+sql+可运行】【50809】
|
供应链 JavaScript BI
ERP系统源码,基于SpringBoot+Vue+ElementUI+UniAPP开发
这是一款专为小微企业打造的 SaaS ERP 管理系统,基于 SpringBoot+Vue+ElementUI+UniAPP 技术栈开发,帮助企业轻松上云。系统覆盖进销存、采购、销售、生产、财务、品质、OA 办公及 CRM 等核心功能,业务流程清晰且操作简便。支持二次开发与商用,提供自定义界面、审批流配置及灵活报表设计,助力企业高效管理与数字化转型。
1155 2
ERP系统源码,基于SpringBoot+Vue+ElementUI+UniAPP开发
|
监控 数据可视化 JavaScript
springboot + vue的MES系统生产计划管理源码
MES系统(制造执行系统)的生产计划管理功能是其核心模块之一,涵盖生产计划制定与优化、调度排程、进度监控反馈、资源管理调配及可视化报告五大方面。系统基于SpringBoot + Vue-Element-Plus-Admin技术栈开发,支持多端应用(App、小程序、H5、后台)。通过实时数据采集与分析,MES助力企业优化生产流程,适用于现代化智能制造场景。
849 1
|
JavaScript 前端开发 Java
Spring Boot 与 Vue.js 前后端分离中的数据交互机制
本文深入探讨了Spring Boot与Vue.js在前后端分离架构下的数据交互机制。通过对比传统`model.addAttribute()`方法与RESTful API的设计,分析了两者在耦合性、灵活性及可扩展性方面的差异。Spring Boot以RESTful API提供数据服务,Vue.js借助Axios消费API并动态渲染页面,实现了职责分明的解耦架构。该模式显著提升了系统的灵活性和维护性,适用于复杂应用场景如论坛、商城系统等,为现代Web开发提供了重要参考。
1837 0
|
JavaScript Java 关系型数据库
Springboot+vue打包部署到线上服务器
整合springboot+vue的项目,打包成jar包到线上服务器运行
Springboot+vue打包部署到线上服务器
|
JavaScript
Vue中如何实现兄弟组件之间的通信
在Vue中,兄弟组件可通过父组件中转、事件总线、Vuex/Pinia或provide/inject实现通信。小型项目推荐父组件中转或事件总线,大型项目建议使用Pinia等状态管理工具,确保数据流清晰可控,避免内存泄漏。
1076 2