基于javaweb+mysql的springboot在线服装销售商城系统(java+springboot+maven+vue+mysql)

基于javaweb+mysql的springboot在线服装销售商城系统(java+springboot+maven+vue+mysql)

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7、Node.js≥10

开发工具

后端:eclipse/idea/myeclipse/sts等均可配置运行

前端:WebStorm/VSCode/HBuilderX等均可

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb的SpringBoot在线服装销售商城系统(java+springboot+maven+vue+mysql)

一、项目运行 环境配置:

Jdk1.8 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。

项目技术:

Spring + SpringBoot+ mybatis + Maven + Vue 等等组成,B/S模式 + Maven管理等等。

//        }
        JwtUtils jwtUtils = new JwtUtils();
        String token = jwtUtils.sign(loginVo);
        return Result.success(token);
    }
}

/**
 */
@Api(tags = "用户端-主页服务接口列表")
@RestController
@RequestMapping("/home")
public class HomeController {

    private static final Logger logger = LoggerFactory.getLogger(HomeController.class);

    @Autowired
    private HomeService homeService;
    /**
     * @Param: keyWord
     * @Date
    public Result<Integer> managerRegister(@RequestBody LoginVo loginVo){
        return Result.success(managerService.managerRegister(loginVo));
    }

    /**
     * @methodDesc: 管理员信息管理
     * @Param: managerVo
     * @return: Result<ManagerVo>
     */
    @ApiOperation(value = "管理员信息管理", notes = "管理员端-管理员信息管理添加、修改")
    @PutMapping("/manager_info{managerId}")
    public Result<ManagerVo> managerInfo(@PathVariable int managerId,@RequestBody ManagerVo managerVo){
        return Result.success(managerService.managerInfo(managerId,managerVo));
    }

    /**
     * @Param: managerId
     * @Date
     */
    @ApiOperation(value = "显示管理员信息", notes = "管理员端-查询管理员信息")
    @GetMapping("/manager_show/{managerId}")
    public Result<ManagerVo> managerShow(HttpServletRequest request,@PathVariable int managerId){
        String token = request.getHeader("Authorization");
        logger.info("token:"+token);
        if (token == null){
            return Result.error(CodeMsg.NOT_YET_LOGIN);
        }
        String username = token.substring(0,token.indexOf("."));
        logger.info("username:"+username);
        Manager manager = managerService.getManagerByUname(username);
        logger.info(manager.toString());
        if (manager == null){
            return Result.error(CodeMsg.NOT_YET_LOGIN);
        }
        Integer result = MyShiro.checkToken(token,manager.getUsername(),manager.getPassword());
        //判断result是否为null
        if (result == null) {
            //为null返回错误信息和登录url
            return Result.error(CodeMsg.NOT_YET_LOGIN);
        }
        ManagerVo managerVo = managerService.managerShow(managerId);
    /**
     * @methodDesc: 用户登录
     * @Param: username.password
     * @return: Result<>
     */

    @ApiOperation(value = "用户登录", notes = "用户端-用户登录")
    @PostMapping("/user_login")
    public Result<TokenId> userLogin(@RequestBody LoginVo loginVo){

        System.out.println(loginVo.toString());
//        LoginVo loginVo = new LoginVo(username,password);
        return Result.success(userService.userLogin(loginVo));
    }

    /**
     * @methodDesc: 用户注册
     * @Param: username.password
     * @return: Result<> userId
     */
    @ApiOperation(value = "用户注册", notes = "用户端-用户注册")
    @PostMapping("/user_register")
    public Result<Integer> managerLogin(@RequestBody LoginVo loginVo){
        return Result.success(userService.userRegister(loginVo));
    }

    /**
     * @methodDesc: 用户登录 测试接口
     * @Param: username.password
     * @return: Result<>
     */

    @ApiOperation(value = "用户登录-测试", notes = "用户端-用户登录-测试")
    @PostMapping("/test_login")
    public Result<String> userLoginTest(@RequestBody LoginVo loginVo) throws UnsupportedEncodingException {
//        //获取当前用户
//        Subject subject = SecurityUtils.getSubject();
//        //封装用户的登录数据
//        UsernamePasswordToken token = new UsernamePasswordToken(loginVo.getUsername(),loginVo.getPassword());
//        try {
//            subject.login(token);//执行登录方法,如果没有异常就说明ok了
//            //生成返回的token
            JwtUtils jwtUtils = new JwtUtils();
            String jwtToken = jwtUtils.refreshToken(loginVo.getUsername());
        return Result.success(null);
    }

    @GetMapping("/list/{page}")
    public Result<PageInfo<User>> listUser(@PathVariable String page){
        Integer num = Integer.parseInt(page);
        PagesVo pagesVo = new PagesVo(num);
        return Result.success(userService.listUser(pagesVo));
    }
}

/**
 */
@Api(tags = "用户端-商品服务接口列表")
@RestController
@RequestMapping("goods")
@CrossOrigin
public class GoodsController {

    private static final Logger logger = LoggerFactory.getLogger(GoodsController.class);

/**
 */
@Api(tags = "用户端-用户服务接口列表")
@RestController
@RequestMapping("/user")
public class UserController {

    private static final Logger logger = LoggerFactory.getLogger(UserController.class);

    @Autowired
    private UserService userService;
//    @Autowired
//    private RedisService redisService;

    /**
     * @methodDesc: 用户信息管理
     * @Param: userVo
     * @return: Result<UserVo>
     */
    @ApiOperation(value = "修改用户信息管理", notes = "用户端-添加用户信息")
    @PutMapping("/user_info/{userId}")
    public Result<UserVo> insertUserInfo(@PathVariable int userId,@RequestBody UserVo userVo){
        logger.info(userId+userVo.toString());
        return Result.success(userService.insertUserInfo(userId,userVo));
    }

    /**
        goodsService.goodsDelete(goodsId);
        return Result.success(null);
    }

    /**
     * @methodDesc: 管理员上架某商品1:上传图片
     * @Param: MultipartFile
     * @return: Result<>
     */
    @ApiOperation(value = "上架商品-上传图片", notes = "管理员端-上架商品-上传图片")
    @PostMapping("/goods_upload")
    public Result<String> goodsInsert(@RequestParam("imge") MultipartFile picture) throws Exception {
        String pictureUrl = goodsService.goodsImgUpload(picture);
        return Result.success(pictureUrl);
    }

    /**
     * @methodDesc: 管理员上架某商品2:添加商品信息
     * @Param: GoodsUploadVo
     * @return: Result<>
     */
    @ApiOperation(value = "上架商品-添加商品信息", notes = "管理员端-上架商品-添加商品信息")
    @PostMapping("/goods_insert")
    public Result<Object> goodsInsert(@RequestBody GoodsUploadVo goodsUploadVo) {
        goodsService.goodsInsert(goodsUploadVo);
        return Result.success(null);
    }

    @GetMapping("/get_edit/{goodsId}")
    public Result<GoodsSizeDto> getGoodsAndSize(@PathVariable int goodsId){
        return Result.success(goodsService.getGoodsAndSize(goodsId));
    }

    @GetMapping("/wxin")
    public void testWechat(HttpServletRequest request, HttpServletResponse response)
    {
        System.out.println("get");
    }
}

@RequestMapping("orders")
public class OrdersController {
    @Autowired
    private OrdersService ordersService;
    @Autowired
    private UserService userService;
//    @Autowired
//    private MQReceiver mqReceiver;
//    @Autowired
//    private MQSender mqSender;
    /**
     * @methodDesc: 用户购买商品
     * @Param: ordersList
     * @return: Result<Orders>
     */
    @ApiOperation(value = "添加订单", notes = "用户端-通过页面传值把商品的信息提交到确认订单页面,点击提交订单把该订单信息存到order_list、order,并在order_log里记录下单时间。")
    @PostMapping("/orders_submit")
    public Result<Orders> ordersSubmit(HttpServletRequest request, @RequestBody OrdersListVo ordersListVo){
        String username = MyShiro.drawUsername(request);
        User user = userService.getUserByUname(username);
        if (user == null){
            return Result.error(CodeMsg.NOT_YET_LOGIN);
        }
        Integer result = MyShiro.checkToken(request.getHeader("Authorization"),user.getUsername(),user.getPassword());
        if (result == null) {
            //为null返回错误信息
            return Result.error(CodeMsg.NOT_YET_LOGIN);
        }
        //result不为null继续操作
        return Result.success(ordersService.ordersSubmit(ordersListVo));
    }

    /**
     * @methodDesc: 用户支付
     * @Param: orderId
     * @return: Result<Object>
     */
    @ApiOperation(value = "用户支付", notes = "用户端-提交订单后根据订单id,查询该订单的价钱,完成支付,在order_log中记录支付时间提示支付成功,返回首页")
    @PutMapping("/order_pay/{orderId}")
    public Result<Object> ordersPay(@PathVariable int orderId){
        ordersService.ordersPay(orderId);
        return Result.success(null);
    }

    /**
    /**
     * @methodDesc: 查询所有订单
     * @Param: userId
     * @return: Result<>
     */
    @ApiOperation(value = "查询所有订单", notes = "用户端-用户id查询所有订单")
    @GetMapping("/orders_show/{userId}")
    public Result<List<Orders>> ordersShow(@PathVariable int userId){
        return Result.success(ordersService.ordersShow(userId));
    }

    /**
     * @methodDesc: 查询某订单状态的订单
     * @Param: state,userId
     * @return: Result<List<Orders>>
     */
    @ApiOperation(value = "查询某状态订单", notes = "用户端-查询某订单状态的订单")
    @GetMapping("/orders_state")
    public Result<List<OrdersAndListGoodsDto>> ordersState(int state, int userId){
        return Result.success(ordersService.ordersState(state,userId));
    }

    /**
     * @methodDesc: 用户对某商品的评价
     * @Param: appraise,orderListId,userId
     * @return: Result<>
     */
    @ApiOperation(value = "添加评论", notes = "用户端-当订单查询到为待评论状态,点击待评论跳转到评论页面(携带该商品的订单列表信息),在评论页面提交评论,把评论和订单列表id传到后端,添加评论")
    @PutMapping("/orders_appraise/{orderListId}")
    public Result<Object> ordersAppraise(@PathVariable int orderListId, @RequestBody AppraiseVo appraiseVo){
        ordersService.goodsAppraise(orderListId,appraiseVo.getAppraise());
        return Result.success(null);
    }

    /**
     * @methodDesc: 管理员查询所有订单
     * @Param:
     * @return: Result<List<Orders>>
     */
    @ApiOperation(value = "查询所有订单", notes = "管理员端-获取用户下的所有订单")
@RequestMapping("goods")
@CrossOrigin
public class GoodsController {

    private static final Logger logger = LoggerFactory.getLogger(GoodsController.class);

    @Autowired
    private GoodsService goodsService;
    /**
     * @Param:
     * @return: Result<>
     */
    @ApiOperation(value = "显示所有商品", notes = "用户端-查询所有商品")
    @GetMapping("/goods_show_all")
    public Result<List<Goods>> goodsShowAll(){
        return Result.success(goodsService.goodsShowAll());
    }
    /**
     * @Param:goodsId
     * @return: Result<>
     */
    @ApiOperation(value = "某个商品的页面", notes = "用户端-查询某个商品")
    @GetMapping("/goods_show/{goodsId}")
    public Result<Goods> goodsShow(@PathVariable int goodsId){
        return Result.success(goodsService.goodsShow(goodsId));
    }

    /**
     * @Param:
     * @return: Result<>
     */
    @ApiOperation(value = "显示所有分类", notes = "用户端-查询所有分类")
    @GetMapping("/goods_type")
    public Result<List<GoodsType>> goodsType(){
        return Result.success(goodsService.goodsType());
    }
    /**
     * @Param:
     * @return: Result<>
        ordersService.ordersPay(orderId);
        return Result.success(null);
    }

    /**
     * @methodDesc: 查询所有订单
     * @Param: userId
     * @return: Result<>
     */
    @ApiOperation(value = "查询所有订单", notes = "用户端-用户id查询所有订单")
    @GetMapping("/orders_show/{userId}")
    public Result<List<Orders>> ordersShow(@PathVariable int userId){
        return Result.success(ordersService.ordersShow(userId));
    }

    /**
     * @methodDesc: 查询某订单状态的订单
     * @Param: state,userId
     * @return: Result<List<Orders>>
     */
    @ApiOperation(value = "查询某状态订单", notes = "用户端-查询某订单状态的订单")
    @GetMapping("/orders_state")
    public Result<List<OrdersAndListGoodsDto>> ordersState(int state, int userId){
        return Result.success(ordersService.ordersState(state,userId));
    }

    /**
     * @methodDesc: 用户对某商品的评价
     * @Param: appraise,orderListId,userId
     * @return: Result<>
     */
    @ApiOperation(value = "添加评论", notes = "用户端-当订单查询到为待评论状态,点击待评论跳转到评论页面(携带该商品的订单列表信息),在评论页面提交评论,把评论和订单列表id传到后端,添加评论")
    @PutMapping("/orders_appraise/{orderListId}")
    public Result<Object> ordersAppraise(@PathVariable int orderListId, @RequestBody AppraiseVo appraiseVo){
        ordersService.goodsAppraise(orderListId,appraiseVo.getAppraise());
        return Result.success(null);
    }

    /**
     * @methodDesc: 管理员查询所有订单
     * @Param:
     * @return: Result<List<Orders>>
     */
    @ApiOperation(value = "查询所有订单", notes = "管理员端-获取用户下的所有订单")
    @GetMapping("/orders_show_all")
    public Result<List<Orders>> ordersShowAll(){
        return Result.success(ordersService.ordersShowAll());

/**
 */
@Api(tags = "用户端-商品服务接口列表")
@RestController
@RequestMapping("goods")
@CrossOrigin
public class GoodsController {

    private static final Logger logger = LoggerFactory.getLogger(GoodsController.class);

    @Autowired
    private GoodsService goodsService;
    /**
     * @Param:
     * @return: Result<>
     */
    @ApiOperation(value = "显示所有商品", notes = "用户端-查询所有商品")
    @GetMapping("/goods_show_all")
    public Result<List<Goods>> goodsShowAll(){
        return Result.success(goodsService.goodsShowAll());
    }
    /**
     * @Param:goodsId
     * @return: Result<>
     */
    @ApiOperation(value = "某个商品的页面", notes = "用户端-查询某个商品")
    @GetMapping("/goods_show/{goodsId}")
    public Result<Goods> goodsShow(@PathVariable int goodsId){
        return Result.success(goodsService.goodsShow(goodsId));
    }

    /**
     * @Param:
     * @return: Result<>
     */

/**
 */
@Api(tags = "用户端-商品服务接口列表")
@RestController
@RequestMapping("goods")
@CrossOrigin
public class GoodsController {

    private static final Logger logger = LoggerFactory.getLogger(GoodsController.class);

    @Autowired
    private GoodsService goodsService;
    /**
     * @Param:
     * @return: Result<>
     */
    @ApiOperation(value = "显示所有商品", notes = "用户端-查询所有商品")
    @GetMapping("/goods_show_all")
    public Result<List<Goods>> goodsShowAll(){
        return Result.success(goodsService.goodsShowAll());
    }
    /**
     * @Param:goodsId
     * @return: Result<>
     */
    @ApiOperation(value = "某个商品的页面", notes = "用户端-查询某个商品")
    @GetMapping("/goods_show/{goodsId}")
    public Result<Goods> goodsShow(@PathVariable int goodsId){
        return Result.success(goodsService.goodsShow(goodsId));
    }

    /**
     * @Param:
     * @return: Result<>
     */
    @ApiOperation(value = "显示所有分类", notes = "用户端-查询所有分类")
//        //封装用户的登录数据
//        UsernamePasswordToken token = new UsernamePasswordToken(loginVo.getUsername(),loginVo.getPassword());
//        try {
//            subject.login(token);//执行登录方法,如果没有异常就说明ok了
//            //生成返回的token
            JwtUtils jwtUtils = new JwtUtils();
            String jwtToken = jwtUtils.refreshToken(loginVo.getUsername());
//            return Result.success(token.toString());
//        } catch (UnknownAccountException e) {
//            throw new GlobleException(CodeMsg.USERNAME_NOT_EXIST);
//        } catch (IncorrectCredentialsException e){
//            throw new GlobleException(CodeMsg.PASSWORD_ERROR);
//        }
        JwtUtils jwtUtils = new JwtUtils();
        String token = jwtUtils.sign(loginVo);
        return Result.success(token);
    }
}

/**
 */
@Api(tags = "用户端-主页服务接口列表")
@RestController
@RequestMapping("/home")
public class HomeController {
    @GetMapping("/goods_appraise/{goodsId}")
    public Result<List<String>> ordersAppraise(@PathVariable int goodsId){
        System.out.println(goodsId);
        return Result.success(ordersService.ordersAppraise(goodsId));
    }

    /**
     * @methodDesc: 获取所有订单(AllOrderDto)
     * @Param: userId
     * @return: Result<AllOrderDto>
     */
    @ApiOperation(value = "用户查询所有订单", notes = "用户端-用户查询所有订单")
    @GetMapping("/get_orders/{userId}")
    public Result<List<AllOrdersDto>> getOrders(@PathVariable int userId){
        System.out.println(userId);
        return Result.success(ordersService.getOrders(userId));
    }

    /**
     * @methodDesc: 查询某订单状态的订单
     * @Param: state,userId
     * @return: Result<List<AllOrdersDto>>
     */
    @ApiOperation(value = "查询某状态订单", notes = "用户端-查询某订单状态的订单")
    @GetMapping("/get_state")
    public Result<List<AllOrdersDto>> getStateOrder(int state,int userId){
        return Result.success(ordersService.getStateOrder(state,userId));
    }

    /**
     * @methodDesc: 确认收货
     * @Param: orderId
     * @return: Result<>
     */
    @ApiOperation(value = "修改订单状态2-->3", notes = "用户端-用户确认订单")
    @PutMapping("/confirm_goods/{orderId}")
    public Result<Object> confirmGoods(@PathVariable int orderId){
        ordersService.confirmGoods(orderId);
        return Result.success(null);
    }

//    @PostMapping("/mq")
//    public Result<String> mq(){
//        mqSender.send("hello,imooc");
//        return Result.success("Hello , world");
//    }
//
//    @PostMapping("/mq/topic")
//    public Result<String> topic(){
        if (user == null){
            return Result.error(CodeMsg.NOT_YET_LOGIN);
        }
        Integer result = MyShiro.checkToken(token,user.getUsername(),user.getPassword());
        //判断result是否为null
        if (result == null) {
            //为null返回错误信息和登录url
            return Result.error(CodeMsg.NOT_YET_LOGIN);
        }
        Double balance = userService.getBalance(user.getUserId());
        return Result.success(String.valueOf(balance));
    }

    @DeleteMapping("/delete/{userId}")
    public Result<Object> delUser(@PathVariable int userId){
        userService.delUser(userId);
        return Result.success(null);
    }

    @GetMapping("/list/{page}")
    public Result<PageInfo<User>> listUser(@PathVariable String page){
        Integer num = Integer.parseInt(page);
        PagesVo pagesVo = new PagesVo(num);
        return Result.success(userService.listUser(pagesVo));
    }
}

    @ApiOperation(value = "显示某商品所有评价", notes = "用户端-查询某商品的累计评价")
    @GetMapping("/goods_appraise/{goodsId}")
    public Result<List<String>> ordersAppraise(@PathVariable int goodsId){
        System.out.println(goodsId);
        return Result.success(ordersService.ordersAppraise(goodsId));
    }

    /**
     * @methodDesc: 获取所有订单(AllOrderDto)
     * @Param: userId
     * @return: Result<AllOrderDto>
     */
    @ApiOperation(value = "用户查询所有订单", notes = "用户端-用户查询所有订单")
    @GetMapping("/get_orders/{userId}")
    public Result<List<AllOrdersDto>> getOrders(@PathVariable int userId){
        System.out.println(userId);
        return Result.success(ordersService.getOrders(userId));
    }

    /**
     * @methodDesc: 查询某订单状态的订单
     * @Param: state,userId
     * @return: Result<List<AllOrdersDto>>
     */
    @ApiOperation(value = "查询某状态订单", notes = "用户端-查询某订单状态的订单")
    @GetMapping("/get_state")
    public Result<List<AllOrdersDto>> getStateOrder(int state,int userId){
        return Result.success(ordersService.getStateOrder(state,userId));
    }

    /**
     * @methodDesc: 确认收货
     * @Param: orderId
     * @return: Result<>
     */
    @ApiOperation(value = "修改订单状态2-->3", notes = "用户端-用户确认订单")
    @PutMapping("/confirm_goods/{orderId}")
    public Result<Object> confirmGoods(@PathVariable int orderId){
        ordersService.confirmGoods(orderId);
        return Result.success(null);
    }

/**
 */
@Api(tags = "用户端-商品服务接口列表")
@RestController
@RequestMapping("goods")
@CrossOrigin
public class GoodsController {

    private static final Logger logger = LoggerFactory.getLogger(GoodsController.class);

    @Autowired
    private GoodsService goodsService;
    /**
     * @Param:
     * @return: Result<>
     */
    @ApiOperation(value = "显示所有商品", notes = "用户端-查询所有商品")
    @GetMapping("/goods_show_all")
    public Result<List<Goods>> goodsShowAll(){
        return Result.success(goodsService.goodsShowAll());
    }
    /**
     * @Param:goodsId
     * @return: Result<>
     */

public class MyShiro {

    //盐,用于混交md5
    private static final String slat = "@gnihtolc#namoaix$";

    /**
     * @methodDesc 密码加密
     * @param password
     * @return String
     */
    public static String securityPassword(String password){
        String secPassword = "clot" + password + "hing";
        return secPassword;
    }

    /**
     * @methodDesc 生成token
     * @param loginVo
     * @return String
     */
    public static String createToken(LoginVo loginVo){
        String base = loginVo.getPassword() +"/"+slat;
        String md5 = DigestUtils.md5DigestAsHex(base.getBytes());
        String token = loginVo.getUsername()+"."+ md5 ;
        return token;
    }

    /**
     * @methodDesc token校验
     * @param token,password
     * @return String
     */

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值