Java项目:前后端分离网上商城项目设计和实现(java+ssm+springboot+vue+redis)

源码获取:博客首页 "资源" 里下载!

主要实现技术:Java、springmvc、springboot、mybatis、mysql、tomcat、shiro权限框架、vue、jquery、node.js 、redis数据库、邮箱相关等技术。

主要功能实现:


用户登录、注册、商城浏览、购买、订单、购物车、退货、用户、个人中心、修改密码、角色等管理


前端主页面:商品关键字搜索和分类搜索功能以及首页轮播图配置展示

首页个人中心主要功能:密码修改、订单、购物车、商品详情模块、可以购买、加入购物车

购买时需要填写用户手机号和收获地址等信息、注册时默认生成支付宝模拟账号密码:

后台管理员主要对商品数据进行管理、分类管理、订单管理以及用户管理扥。



商品列表数据管理、后台添加商品信息、商品基础数据的维护管理、商品订单详情管理:根据关键字查询以及查看每一个订单的详情信息

首页轮播图配置展示、用户角色和权限管理控制:

前后端源码结构:

数据库图:

用户授权类控制层:

=

/**
 * @description 用户授权类
 */

@RestController
@CrossOrigin
public class UserRoleController {

    final UserRoleService userRoleService;
    public UserRoleController(UserRoleService userRoleService) {
        this.userRoleService = userRoleService;
    }
    /*根据id查询用户*/
    @RequestMapping(value = "/userRole/findById")
    private CommonResult findById(Integer userId) {
        List<UserRole> userRoles = userRoleService.selectByUserId(userId);
        if(userRoles!=null){
            return CommonResult.success("查询成功",userRoles);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    @RequestMapping(value = "/userRole/findRoleById")
    private CommonResult findRoleById(Integer userId) {
        List<Map<String, Object>> maps = userRoleService.selectRoleByUserId(userId);
        if(maps!=null){
            return CommonResult.success("查询成功",maps);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    /*查询所有用户*/
    @RequestMapping(value = "/userRole/findAll")
    private CommonResult findAll() {
        List<UserRole> userRoles = userRoleService.selectAll();
        if(userRoles!=null){
            return CommonResult.success("查询成功",userRoles);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    /*查询所有用户*/
    @RequestMapping(value = "/userRole/existsRole")
    private CommonResult existsRole(Integer roleId) {
        Boolean isExist = userRoleService.existsRole(roleId);
        if(isExist!=null){
            return CommonResult.success("查询成功",isExist);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    @RequestMapping(value = "/userRole/add")
    private CommonResult add(UserRole userRole) {
        if(userRole!=null){
            if(userRoleService.insertData(userRole)){
                return CommonResult.success("添加成功",userRole);
            }else{
                return CommonResult.error("添加失败");
            }
        }
        return CommonResult.error("用户数据不存在");
    }

    @RequestMapping(value = "/userRole/delete")
    private CommonResult delete(Integer userId) {
        Boolean bool = userRoleService.deleteById(userId);
        System.out.println(bool);
        if(bool){
            return CommonResult.success("删除成功",userId);
        }else{
            return CommonResult.error("删除失败");
        }
    }


}

用户相关业务控制层:

/**
 * @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")
    private CommonResult findAll() {
        List<User> users = userService.selectAll();
        if(users!=null){
            return CommonResult.success("查询成功",users);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    /*判断某个用户是否还存在*/
    @RequestMapping(value = "/user/existKey")
    private CommonResult existKey(String key) {
        Boolean isExist = userService.existsWithPrimaryKey(key);
        if(isExist!=null){
            return CommonResult.success("查询成功",isExist);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    /*查询用户状态*/
    @RequestMapping(value = "/user/userState")
    private CommonResult userState(String accountNumber) {
        Boolean state = userService.selectUserState(accountNumber);
        if(state!=null){
            return CommonResult.success("查询成功",state);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    /*查询用户记录的总条数*/
    @RequestMapping(value = "/user/count")
    private CommonResult findCount() {
        Integer count = userService.selectCount();
        if(count!=null){
            if(count!=0){
                return CommonResult.success("查询成功",count);
            }else{
                return CommonResult.error("查询失败");
            }
        }else{
            return CommonResult.error("查询失败");
        }

    }

    //通过用户帐号去查询用户的id
    @RequestMapping(value = "/user/findIdByKey")
    private CommonResult findIdByKey(String key) {
        Integer id = userService.selectIdByKey(key);
        if(id!=null){
            if(id!=0){
                return CommonResult.success("查询成功","id: "+id);
            }else{
                return CommonResult.error("未查询到");
            }
        }else{
            return CommonResult.error("查询失败");
        }
    }

    //删除用户
    @RequestMapping(value = "/user/delete")
    private CommonResult delete(Integer userId) {
        if(userService.deleteById(userId)){
            return CommonResult.success("删除成功",userId);
        }else{
            return CommonResult.error("删除失败");
        }
    }

    @RequestMapping(value = "/user/author")
    private CommonResult author(Integer userId,@RequestParam List<Integer> roleId) {
        System.out.println(userId);
        System.out.println(roleId);
        if(userId!=null && roleId!=null && roleId.size()!=0){
            if(userRoleService.deleteById(userId)){
                UserRole userRole = new UserRole();
                userRole.setUserId(userId);
                for (Integer id : roleId) {
                    userRole.setRoleId(id);
                    userRoleService.insertData(userRole);
                }
            }
            return CommonResult.success("授权成功");
        }else{
            return CommonResult.error("角色授权数据不完整!");
        }
    }

    /*查询所有VIP用户*/
    @RequestMapping(value = "/vip/findAllVip")
    private CommonResult findAllVip() {
        List<Vip> vips = vipService.selectAll();
        if(vips!=null){
            return CommonResult.success("查询成功",vips);
        }else{
            return CommonResult.error("查询失败");
        }
    }
    /*查询VIP用户信息根据id*/
    @RequestMapping(value = "/vip/findVipById")
    private CommonResult findVipById(Integer vipId) {
        Vip vip = vipService.selectById(vipId);
        if(vip!=null){
            return CommonResult.success("查询成功",vip);
        }else{
            return CommonResult.error("查询失败");
        }
    }
    /*查询VIP用户信息根据id*/
    @RequestMapping(value = "/vip/findVipByKey")
    private CommonResult findVipByKey(String accountNumber) {
        Vip vip = vipService.selectByKey(accountNumber);
        if(vip!=null){
            return CommonResult.success("查询成功",vip);
        }else{
            return CommonResult.error("查询失败");
        }
    }
    /*判断用户信息是否存在*/
    @RequestMapping(value = "/vip/existsVip")
    private CommonResult existsVip(String accountNumber) {
        Boolean isExist = vipService.existsVip(accountNumber);
        if(isExist!=null){
            return CommonResult.success("查询成功",isExist);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    //创建vip信息
    @RequestMapping(value = "/vip/addVip")
    private 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信息插入成功",vip);
        }else{
            return CommonResult.error("vip信息插入失败");
        }
    }

    //更新vip信息
    @RequestMapping(value = "/vip/updateVip")
    private CommonResult updateVip(Vip vip) {
        if(vipService.updateById(vip)){
            return CommonResult.success("vip信息更新成功",vip);
        }else{
            return CommonResult.error("vip信息更新失败");
        }
    }

    //删除vip信息
    @RequestMapping(value = "/vip/deleteVip")
    private CommonResult deleteVip(Integer vipId) {
        if(vipService.deleteById(vipId)){
            return CommonResult.success("删除成功",vipId);
        }else{
            return CommonResult.error("删除失败");
        }
    }
}

购物车业务类控制层:

/**
 * @description 购物车业务类
 */
@RestController
@CrossOrigin
public class ShoppingCartController {
    final ShoppingCartService shoppingCartService;
    public ShoppingCartController(ShoppingCartService shoppingCartService){
        this.shoppingCartService = shoppingCartService;
    }


    /*商品类别*/
    @RequestMapping(value = "/shoppingCart/add")
    private CommonResult addShoppingCart(ShoppingCart shoppingCart) {
        if(shoppingCartService.insertData(shoppingCart)){
            return CommonResult.success("购物车添加成功",shoppingCart);
        }else{
            return CommonResult.error("购物车添加失败");
        }
    }

    @RequestMapping(value = "/shoppingCart/update")
    private CommonResult updateShoppingCart(ShoppingCart shoppingCart) {
        if(shoppingCartService.updateById(shoppingCart)){
            return CommonResult.success("购物车修改成功",shoppingCart);
        }else{
            return CommonResult.error("购物车修改失败");
        }
    }

    @RequestMapping(value = "/shoppingCart/deleteById")
    private CommonResult deleteShoppingCart(Integer cartId) {
        if(shoppingCartService.deleteById(cartId)){
            return CommonResult.success("购物车删除成功","cartId: "+cartId);
        }else{
            return CommonResult.error("购物车删除失败");
        }
    }
    @RequestMapping(value = "/shoppingCart/deleteByUser")
    private CommonResult deleteByUser(String accountNumber) {
        if(shoppingCartService.deleteByUser(accountNumber)){
            return CommonResult.success("购物车删除成功","accountNumber: "+accountNumber);
        }else{
            return CommonResult.error("购物车删除失败");
        }
    }


    @RequestMapping(value = "/shoppingCart/findAll")
    private CommonResult findAllShoppingCart(String accountNumber) {
        List<Map<String, Object>> shoppingInfo = shoppingCartService.selectAll(accountNumber);
        if(shoppingInfo!=null){
            return CommonResult.success("购物车查询成功",shoppingInfo);
        }else{
            return CommonResult.error("购物车查询失败");
        }
    }

    @RequestMapping(value = "/shoppingCart/findById")
    private CommonResult findById(Integer cartId) {
        ShoppingCart shoppingCart = shoppingCartService.selectById(cartId);
        if(shoppingCart!=null){
            return CommonResult.success("购物车查询成功",shoppingCart);
        }else{
            return CommonResult.error("购物车查询失败");
        }
    }

}

源码获取:博客首页 "资源" 里下载!

  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论
yshop基于当前流行技术组合的前后端分离商城系统: SpringBoot2+MybatisPlus+SpringSecurity+jwt+redis+Vue前后端分离商城系统, 包含商城、拼团、砍价、商户管理、 秒杀、优惠券、积分、分销、会员、充值、多门店等功能,更适合企业或个人二次开发。 功能: 一、商品模块:商品添加、规格设置,商品上下架等 二、订单模块:下单、购物车、支付,发货、收货、评价、退款等 三、营销模块:积分、优惠券、分销、砍价、拼团、秒杀、多门店等 四、微信模块:自定义菜单、自动回复、微信授权、图文管理、模板消息推送 五、配置模块:各种配置 六、用户模块:登陆、注册、会员卡、充值等 七、其他等 项目结构: 项目采用分模块开发方式 yshop-weixin 微信相关模块 yshop-common 公共模块 yshop-admin 后台模块 yshop-logging 日志模块 yshop-tools 第三方工具模块 yshop-generator 代码生成模块 yshop-shop 商城模块 yshop-mproot mybatisPlus docker部署: 1、创建一个存储第三方软件服务Docker Compose文件目录:      mkdir -p /yshop/soft 2、然后在该目录下新建一个docker-compose.yml文件:     vim /yshop/soft/docker-compose.yml 3、接着创建上面docker-compose.yml里定义的挂载目录:     mkdir -p /yshop/mysql/data /yshop/redis/data /yshop/redis/conf 4、创建Redis配置文件redis.conf:     touch /yshop/redis/conf/redis.conf 5、docker 部署参考根目录docker文件夹 6、以上创建好之后参考docker下文件,先执行软件安装:   cd /yshop/soft   docker-compose up -d  启动   docker ps -a 查看镜像 7、运行docker/applicatiion目录下 docker-compose,当然之前一定要打包jar包,构建镜像 切换到Dockerfile 文件下: docker build -t yshop-admin .   3.2.1版本已经正式发布啦!: 1、秒杀列表与详情页面UI优化 2、拼团商品详情UI优化 3、优惠券列表UI优化 4、修复小程序官方登陆升级调整的问题 5、放开商品详情必须要登陆才能查看的权限 6、拼团列表新增浏览数与访客数 6、修复收藏的问题 7、修复退款问题 8、修复Email配置问题 9、修复积分支付0的问题 10、修复APP充值问题 11、其他等修复优化,详情请看git commit提交记录
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qq1334611189

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值