基于javaweb+mysql的springboot前台后台玩具商城系统(java+ssm+springboot+html+maven+mysql+redis)

基于javaweb+mysql的springboot前台后台玩具商城系统(java+ssm+springboot+html+maven+mysql+redis)

运行环境

Java≥8、MySQL≥5.7

开发工具

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

适用

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

功能说明

基于javaweb+mysql的SpringBoot前台后台玩具商城系统(java+ssm+springboot+html+maven+mysql+redis)

一、项目简述本系统主要实现的功能有: 网上商城系统,前台+后台管理,用户注册,登录,商品展示,分组展示,搜索,收货地址管理,购物车管理,添加,购买,个人信息修改。订单查询等等,后台商品管理,分类管理,库存管理,订单管理,用户管理,信息修改等等。

二、项目运行 环境配置:

Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

项目技术:

Springboot+ SpringMVC + MyBatis + Html+ JavaScript + JQuery + Ajax + maven等等

     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping("shouhuo.do")
    @ResponseBody
    public Result shouhuo(String id) throws Exception {
        OrderEntity orderEntity = orderService.selectById(id);
        orderEntity.setStatus(3);
        orderService.updateById(orderEntity);
        return Result.success("欢迎下次光临");
    }

    /**
     * 退货收货
     *
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping("tuihuo.do")
    @ResponseBody
    public Result tuihuo(String id) throws Exception {
        orderService.deleteById(id);
        return Result.success("下次再买 - -");
    }

    /**
     * @param model
     * @return
     * @throws Exception
     */
    @RequestMapping("list.do")
    public String list(Model model) throws Exception {
        CustomerEntity userEntity = Contants.getCustomer();
        EntityWrapper wrapper = new EntityWrapper();
        wrapper.eq(OrderTable.CUSTOMER_ID, userEntity.getId()).orderBy("time", false);
        List<OrderEntity> orders = orderService.selectList(wrapper);
        if (orders != null) {
            for (OrderEntity order : orders) {
                wrapper = new EntityWrapper();
                wrapper.eq("order_id", order.getId());
                List<OrderShopEntity> orderShops = orderShopService.selectList(wrapper);
                order.setOrderShops(orderShops);
            }
        }
        model.addAttribute("orders", orders);

/**
 * Created by Wsy
 */
@Controller
@RequestMapping("fileNoCos")
public class ImgController {
//    //secretId
//    public static final String secretId = "";
//    //secretKey
//    public static final String secretKey = "";
//    //COS桶的根路径
//    public static final String BASEURL = "";
//    //桶的名称
//    public static final String BUCKETNAME = "";
//    //桶的key(文件夹名称)
//    public static final String KEY = "";
//    //你的REGION
//    public static final String REGION = "";
//    /**
//     * MultipartFile-->File
//     * @param multipartFile
//     * @return
//     */
//    private static File transferToFile(MultipartFile multipartFile) {
//        File file = null;
//        try {
//            String originalFilename = multipartFile.getOriginalFilename();
//            System.out.println(originalFilename);
//            String[] filename = originalFilename.split("\\.");
//            file = File.createTempFile(filename[0], filename[1]);
//            multipartFile.transferTo(file);
//            file.deleteOnExit();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        return file;
//    }
//
//    /**
//     * 文件上传返回code为200
//     *
//     * @param file
//     * @return
//     * @throws Exception
//     */
//    @PostMapping("/upload")
//    @ResponseBody
//    //secretKey
//    public static final String secretKey = "";
//    //COS桶的根路径
//    public static final String BASEURL = "";
//    //桶的名称
//    public static final String BUCKETNAME = "";
//    //桶的key(文件夹名称)
//    public static final String KEY = "";
//    //你的REGION
//    public static final String REGION = "";
//    /**
//     * MultipartFile-->File
//     * @param multipartFile
//     * @return
//     */
//    private static File transferToFile(MultipartFile multipartFile) {
//        File file = null;
//        try {
//            String originalFilename = multipartFile.getOriginalFilename();
//            System.out.println(originalFilename);
//            String[] filename = originalFilename.split("\\.");
//            file = File.createTempFile(filename[0], filename[1]);
//            multipartFile.transferTo(file);
//            file.deleteOnExit();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        return file;
//    }
//
//    /**
//     * 文件上传返回code为200
//     *
//     * @param file
//     * @return
//     * @throws Exception
//     */
//    @PostMapping("/upload")
//    @ResponseBody
//    public Result uplaod(@RequestParam("file") MultipartFile file) throws Exception {
//        //用来检测程序运行时间
//        String fileName = IdWorker.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
//        try {
//            File file1 = transferToFile(file);
//            // 1 初始化用户身份信息(secretId, secretKey)。
//            COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
//            // 2 设置 bucket 的地域, COS 地域的简称请参照 https://cloud.tencent.com/document/product/436/6224
 clientConfig 中包含了设置 region, https(默认 http), 超时, 代理等 set 方法, 使用可参见源码或者常见问题 Java SDK 部分。
//            Region region = new Region(REGION);
//            ClientConfig clientConfig = new ClientConfig(region);
 这里建议设置使用 https 协议
//            clientConfig.setHttpProtocol(HttpProtocol.https);
     */
    @RequestMapping("saveData.do")
    @ResponseBody
    public Result save(Model model, CustomerAddressEntity entity)throws Exception{
        CustomerEntity customerEntity = Contants.getCustomer();
        entity.setCustomerId(customerEntity.getId());
        if(StringUtils.isEmpty(entity.getId())){
            entity.setId(IdWorkerUtil.getId());
            service.insert(entity);
        }else{
            service.updateById(entity);
        }
        return Result.success("保存成功");
    }

    /**
     * 删除
     * @param id
     * @return
     * @throws Exception
     */
    @PostMapping("del.do")
    @ResponseBody
    public Result del(String id)throws Exception{
        service.deleteById(id);
        return Result.success("保存成功");
    }
}
package com.wsy.controller.mobile;


/**
 * 普通用户管理
 */
@Controller
@RequestMapping("childType")
public class ChildTypeController {

    @Autowired
    private ChildTypeService childTypeService  ;

    /**
     * 根据1级分类查询2级分类
     * @param type
     * @return
     */
    @PostMapping("childList.htm")
    @ResponseBody
    public Result childList(Integer type){
        EntityWrapper entityWrapper = new EntityWrapper();
        List<ChildTypeEntity> list =  childTypeService.selectList(entityWrapper);
        return Result.success(list);
    }

    /**
     * 根据1级分类查询2级分类
     * @param type
     * @return
     */
    @PostMapping("childList.do")
    @ResponseBody
    public Result childListdo(Integer type){
        EntityWrapper entityWrapper = new EntityWrapper();
        List<ChildTypeEntity> list =  childTypeService.selectList(entityWrapper);
        return Result.success(list);
    }

    /**
     * 列表
     * @param model
     * @return
     * @return
     * @throws Exception
     */
    @RequestMapping("stock.htm")
    @ResponseBody
    public Result stock(Model model, Integer stock,String id ,Integer type)throws Exception{
        ShopEntity entity = service.selectById(id);
        if(entity.getStock()==null){
            entity.setStock(0);
        }
        if(type==1){ //添加库存
            entity.setStock(entity.getStock()+stock);
        }else{ //减少库存
            if(entity.getStock()-stock<0){
                return Result.error("库存不够");
            }
            entity.setStock(entity.getStock()-stock);
        }
        service.updateById(entity);
        return Result.success("保存成功");
    }

}
package com.wsy.controller.admin;

/**
 * 普通用户管理
 */
@Controller
@RequestMapping("childType")
public class ChildTypeController {

    @Autowired
    private ChildTypeService childTypeService  ;

	    @PostMapping("/upload")
	    @ResponseBody
	    public Result uplaod(@RequestParam("file") MultipartFile file)throws Exception {
	        //用来检测程序运行时间
	        String fileName =  IdWorker.get32UUID() +file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
	        try {
	            File file1 = new File(FILE_PATH+"\\"+fileName);
	            file1.createNewFile();
	            //获取输出流
	            OutputStream os=new FileOutputStream(file1.getPath());
	            //获取输入流 CommonsMultipartFile 中可以直接得到文件的流
	            InputStream is=file.getInputStream();
	            int temp;
	            //一个一个字节的读取并写入
	            while((temp=is.read())!=(-1))
	            {
	                os.write(temp);
	            }
	            os.flush();
	            os.close();
	            is.close();
	            InputStream inputStream = new FileInputStream(file1.getPath());
	            byte[] b = new byte[inputStream.available()];
	            inputStream.read(b);
	        } catch (FileNotFoundException e) {
	            e.printStackTrace();
	            return Result.error("上传文件失败");
	        }
	        return Result.success("/file/pic?pictureName="+fileName,"文件上传成功");
	    }

	    /**
	     * 获取本地图片
	     * @param pictureName //文件名
	     * @return
	     */
	    @RequestMapping("/pic")
	    public void ShowImg(String pictureName, HttpServletRequest request, HttpServletResponse response) throws IOException {
	        //这里是存放图片的文件夹地址
	        FileInputStream fileIs=null;
}
package com.wsy.controller.mobile;

/**
 * 文章
 */
@Controller
@RequestMapping("article")
public class MobileArticleController {

    @Autowired
    private ArticleService articleService;

    @Autowired
    private CustomerService customerService;

    @Autowired
    private ChildTypeService childTypeService;

@Controller
@RequestMapping("role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @Autowired
    private MenuService menuService;

    @Autowired
    private RoleMenuService roleMenuService;

    /**
     * 角色界面
     * @param model
     * @return
     * @throws Exception
     */
    @GetMapping("list.htm")
    public String list(Model model)throws Exception{
        List<RoleEntity> list = roleService.selectList(new EntityWrapper<>());
        model.addAttribute("list",list);
        return "role/list";
    }

    /**
     * 保存
     * @param id
     * @param name
     * @return
     * @throws Exception
     */
    @PostMapping("save.htm")
    @ResponseBody
    @ImLog(type = "角色",mark = "保存角色 {id} {name} {status}")
    public Result save(String id,String name,Boolean status)throws Exception{
        RoleEntity roleEntity = new RoleEntity();
        roleEntity.setName(name);
        roleEntity.setStatus(status);
        if(StringUtils.isEmpty(id)){
            roleEntity.setId(IdWorker.get32UUID());
            roleEntity.setTime(new Date());
            roleService.insert(roleEntity);
        }else{
            roleEntity.setId(id);
            roleService.updateById(roleEntity);

@Controller
@RequestMapping("royalty")
public class RoyaltyController {

    @Autowired
    private RoyaltyService royaltyService;

    @Autowired
    private CustomerService customerService;
    /**
     * 列表界面
     * @param model
     * @return
     * @throws Exception
     */
    @RequestMapping("list.do")
    public String list(Model model)throws Exception{
        EntityWrapper entityWrapper = new EntityWrapper();
        entityWrapper.eq("customer",Contants.getCustomer().getId());
        entityWrapper.orderBy("time",false);
        List<RoyaltyEntity> list = royaltyService.selectList(entityWrapper);
        model.addAttribute("list",list);
        BigDecimal all = new BigDecimal(0);
        if(list!=null){
            for (RoyaltyEntity royaltyEntity : list) {
                all =  all.add(royaltyEntity.getMoney());
            }
        }
        model.addAttribute("all",all);
        return "mobile/royalty";
    }

    /**
     * 用户提取佣金
     * @param money
     * @return
     * @throws Exception
     */
    @RequestMapping("tiqu.do")

@Controller
public class PayController {
    @Autowired
    @Qualifier("alipayService")
    private AlipayService alipayService;
    @Autowired
    CustomerService customerService;
    @Autowired
    private ShoppingGatService shoppingGatService;
    @Autowired
    private OrderService orderService;
    @Autowired
    public Jedis jedis;

    @RequestMapping("/useIntegral")
    public void useIntegral() {
        System.out.println("true");
        jedis.set("WSY-INTEGRALFLAG", "true");
    }

    @RequestMapping("/unUseIntegral")
    public void unUseIntegral() {
        System.out.println("false");
        jedis.set("WSY-INTEGRALFLAG", "false");
    }

    @RequestMapping("/pay")
    @ResponseBody
    public String payController(@RequestParam("ids") String ids[], @RequestParam("amount") String amount) throws Exception {
        String name = jedis.get("WSY-SHOPID");
        jedis.del("WSY-IDS");
        for (String id : ids) {
            jedis.lpush("WSY-IDS", id);
        }
        double s = Double.parseDouble(amount);
        Integer pay = (int) s;
        Integer flag = (int) s;
        CustomerEntity customer = Contants.getCustomer();
        CustomerEntity customerEntity = customerService.selectById(customer.getId());
        Integer integral = customerEntity.getIntegral();
        String INTEGRALFLA = jedis.get("WSY-INTEGRALFLAG");
    /**
     * 收货
     *
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping("shouhuo.do")
    @ResponseBody
    public Result shouhuo(String id) throws Exception {
        OrderEntity orderEntity = orderService.selectById(id);
        orderEntity.setStatus(3);
        orderService.updateById(orderEntity);
        return Result.success("欢迎下次光临");
    }

    /**
     * 退货收货
     *
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping("tuihuo.do")
    @ResponseBody
    public Result tuihuo(String id) throws Exception {
        orderService.deleteById(id);
        return Result.success("下次再买 - -");
    }

    /**
     * @param model
     * @return
     * @throws Exception
     */
    @RequestMapping("list.do")
    public String list(Model model) throws Exception {
        CustomerEntity userEntity = Contants.getCustomer();
        EntityWrapper wrapper = new EntityWrapper();
        wrapper.eq(OrderTable.CUSTOMER_ID, userEntity.getId()).orderBy("time", false);
        List<OrderEntity> orders = orderService.selectList(wrapper);
        if (orders != null) {
            for (OrderEntity order : orders) {
                wrapper = new EntityWrapper();
                wrapper.eq("order_id", order.getId());
                List<OrderShopEntity> orderShops = orderShopService.selectList(wrapper);
                order.setOrderShops(orderShops);
            }
        }
        model.addAttribute("orders", orders);
        return "mobile/orderList";

}
package com.wsy.controller.mobile;

/**
 * 文章
 */
@Controller
@RequestMapping("article")
public class MobileArticleController {

    @Autowired
    private ArticleService articleService;

    @Autowired
    private CustomerService customerService;

    @Autowired
    private ChildTypeService childTypeService;

    @Autowired
    private ShopService shopService;

    /**
     * 界面
     * @return

@Controller
public class PayController {
    @Autowired
    @Qualifier("alipayService")
    private AlipayService alipayService;
    @Autowired
    CustomerService customerService;
    @Autowired
    private ShoppingGatService shoppingGatService;
    @Autowired
    private OrderService orderService;
    @Autowired
    public Jedis jedis;

    @RequestMapping("/useIntegral")
    public void useIntegral() {
        System.out.println("true");
        jedis.set("WSY-INTEGRALFLAG", "true");
    }

    @RequestMapping("/unUseIntegral")
    public void unUseIntegral() {
        System.out.println("false");
        jedis.set("WSY-INTEGRALFLAG", "false");
    }

    @RequestMapping("/pay")
    @ResponseBody
    public String payController(@RequestParam("ids") String ids[], @RequestParam("amount") String amount) throws Exception {

@Controller
@RequestMapping("role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @Autowired
    private MenuService menuService;

    @Autowired
    private RoleMenuService roleMenuService;

    /**
     * 角色界面
     * @param model
     * @return
     * @throws Exception
     */
    @GetMapping("list.htm")
    public String list(Model model)throws Exception{
        List<RoleEntity> list = roleService.selectList(new EntityWrapper<>());
        model.addAttribute("list",list);
        return "role/list";
    }


@Controller
@RequestMapping("order")
public class SpOrderController {
    public static final String PAYURL = "http://localhost:8080/pay?id=%s&name=%s&amount=%s";
    @Autowired
    private ShoppingGatService shoppingGatService;

    @Autowired
    private ShopService shopService;

    @Autowired
    private OrderShopService orderShopService;

    @Autowired
    private OrderService orderService;

    @Autowired
    private CustomerAddressService customerAddressService;

    @Autowired
    private OrderShopDao orderShopDao;
    @Autowired
    private RoyaltyService royaltyService;
    @Autowired
    @Qualifier("alipayService")
    private AlipayService alipayService;
    @Autowired
    public Jedis jedis;

        CustomerEntity userEntity = Contants.getCustomer();
        if(StringUtils.isEmpty(id)){
            EntityWrapper entityWrapper = new EntityWrapper();
            entityWrapper.eq(ShoppingGatTable.CUSTOMER_ID,userEntity.getId());
            shoppingGatService.delete(entityWrapper);
        }else{
            shoppingGatService.deleteById(id);
        }
        return Result.success("成功");
    }

    /**
     * 添加到购物车
     * @param shopId
     * @return
     * @throws Exception
     */
    @RequestMapping("add.do")
    @ResponseBody
    public Result add(String shopId,Integer num,String customerId)throws Exception{
        CustomerEntity userEntity = Contants.getCustomer();
        EntityWrapper entityWrapper = new EntityWrapper();
        entityWrapper.eq(ShoppingGatTable.CUSTOMER_ID,userEntity.getId())
                .eq(ShoppingGatTable.SHOP_ID,shopId);
        ShoppingGatEntity gatEntity = shoppingGatService.selectOne(entityWrapper);
        if(gatEntity!=null){
            gatEntity.setNum(gatEntity.getNum()+num);
            shoppingGatService.updateById(gatEntity);
        }else{
            gatEntity = new ShoppingGatEntity();
            gatEntity.setId(IdWorker.get32UUID());
            gatEntity.setNum(num);
            gatEntity.setShopId(shopId);
            gatEntity.setCustomerId(userEntity.getId());
            gatEntity.setCid(customerId);
            shoppingGatService.insert(gatEntity);
        }
        return Result.success("成功");
    }

}

请添加图片描述

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值