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

主要实现技术: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("购物车查询失败");
        }
    }

}

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

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐