• Java项目:药品商城系统(java+SSM+JSP+jQuery+Mysql)


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

    项目介绍

    本系统分为前后台,分为管理员与普通用户两种角色,前台由普通用户登录,后台由管理员登录;

    管理员:
    登录,修改个人资料,用户管理,公告管理,教室管理,科目管理,听课记录管理等功能。

    用户角色包含以下功能:
    用户登录,修改个人资料,查看公告,查看听课记录等功能。

    环境需要

    1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
    2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
    3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
    4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 
    5.数据库:MySql 5.7版本;
    6.是否Maven项目:否;


    技术栈

    1. 后端:Spring+SpringMVC+Mybatis
    2. 前端:JSP+jQuery+Ajax


    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
    2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
    若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
    3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置;
    4. 运行项目,http://localhost:8080/
    用户账号/密码: user/123456
    管理员账号/密码:admin/admin
     

     

     

     

     

     

    订单管理控制层: 

    1. @Controller
    2. public class orderController {
    3. @Autowired
    4. private OrderService orderService;
    5. @RequestMapping("/toOrder")
    6. public String toOrder(HttpServletRequest request,Model model) throws Exception {
    7. Orders orders = new Orders();
    8. Cart cart = (Cart) request.getSession().getAttribute("cart");
    9. User loginUser = (User) request.getSession().getAttribute("loginUser");
    10. if(loginUser==null){
    11. model.addAttribute("message", "对不起您还没有登录");
    12. return "msg";
    13. }
    14. // 0表示没有付款、1表示已付款即将发货 2表示确认收货 3表示交易成功
    15. orders.setState(0);
    16. orders.setOrderTime(new Date());
    17. orders.setUid(loginUser.getUid());
    18. orders.setMoney(cart.getTotale());
    19. orderService.toOrder(orders);
    20. Map<Integer, CartItem> cartItems = cart.getCartItem();
    21. for (Entry<Integer, CartItem> entry : cartItems.entrySet()) {
    22. CartItem cartItem = entry.getValue();
    23. Orderitem orderitem = new Orderitem();
    24. orderitem.setProduct(cartItem.getProduct());
    25. orderitem.setCount(cartItem.getCount());
    26. orderitem.setPid(cartItem.getProduct().getPid());
    27. orderitem.setSubtotal(cartItem.getSubtotle());
    28. orderitem.setOid(orders.getOid());
    29. orders.getOiList().add(orderitem);
    30. orderService.toOrderItem(orderitem);
    31. }
    32. cart.clearCart();
    33. request.getSession().setAttribute("orders", orders);
    34. return "order";
    35. }
    36. // 为定单付款
    37. @RequestMapping("/payOrder")
    38. public String payOrder(Orders orders,@RequestParam String receiveInfo,@RequestParam String phoNum,@RequestParam String accepter) throws Exception {
    39. orders.setReceiveinfo(receiveInfo);
    40. orders.setPhonum(phoNum);
    41. orders.setAccepter(accepter);
    42. orderService.payOrder(orders);
    43. return "redirect:myOrder.action?page=1";
    44. }
    45. //payOrderAganin
    46. @RequestMapping("/payOrderAganin")
    47. public String payOrderAganin(@RequestParam int oid,HttpServletRequest request){
    48. Orders noPayOrder = orderService.findOrderByOid(oid);
    49. request.getSession().setAttribute("orders", noPayOrder);
    50. return "order";
    51. }
    52. // 查询myOrder
    53. @RequestMapping("/myOrder")
    54. public String myOrder(@RequestParam int page, Model model,
    55. HttpServletRequest request) throws Exception {
    56. User loginUser = (User) request.getSession().getAttribute("loginUser");
    57. PageBean<Orders> pageBean = orderService.findOrderByUidAndPage(page,loginUser.getUid());
    58. model.addAttribute("pageBean", pageBean);
    59. return "orderList";
    60. }
    61. // 确认收货
    62. @RequestMapping("/updateState")
    63. public String updateState(@RequestParam int oid ) throws Exception {
    64. orderService.updateOrderStatus(oid, 3);
    65. return "redirect:myOrder.action?page=1";
    66. }
    67. }

    登录管理控制层:

    1. @Controller
    2. public class loginController {
    3. @Autowired
    4. private UserService userService;
    5. @RequestMapping("login")
    6. public String login() {
    7. return "login";
    8. }
    9. // 用户登录
    10. @RequestMapping("/userLogin")
    11. public String userLogin(HttpServletRequest request,
    12. @RequestParam String checkImg, User user, Model model)
    13. throws zdyException, Exception {
    14. String sessionCode = (String) request.getSession().getAttribute(
    15. "checkcode");
    16. if (!sessionCode.equalsIgnoreCase(checkImg)) {
    17. //model.addAttribute("message", "验证码输入错误请重新注册");
    18. //throw new zdyException("验证码输入错误请重新注册");
    19. request.getSession().setAttribute("message", "验证码输入错误请重新注册");
    20. return "redirect:login.action";
    21. }
    22. User loginUser = userService.loginFindByUnameAndPwd(user.getUsername(),
    23. user.getPassword());
    24. if (loginUser == null) {
    25. //model.addAttribute("message", "密码输入错误请重新登陆");
    26. request.getSession().setAttribute("message", "密码输入错误请重新登陆");
    27. //throw new zdyException("密码输入错误请重新登陆");
    28. return "redirect:login.action";
    29. }
    30. request.getSession().setAttribute("loginUser", loginUser);
    31. request.getSession().removeAttribute("message");
    32. return "redirect:index.action";
    33. }
    34. // 用户退出
    35. @RequestMapping("userLogout")
    36. public String userLogout(HttpServletRequest request,
    37. HttpServletResponse response, Model model) {
    38. request.getSession().removeAttribute("loginUser");
    39. response.setHeader("content-type", "text/html;charset=UTF-8");
    40. response.setHeader("refresh", "5;url=/shop/index.action");
    41. model.addAttribute("message", "退出成功,系统将在5秒之后跳转到首页......");
    42. return "msg";
    43. }
    44. //进入管理员页面
    45. @RequestMapping("/admin")
    46. public String AdminIndex(){
    47. return "admin/index";
    48. }
    49. //admin/adminUser_login.action
    50. //adminUser_login管理员登录
    51. @RequestMapping("/admin/adminUser_login")
    52. public String adminUser_login(HttpServletRequest request,Model model,@RequestParam String username,@RequestParam String password) throws Exception{
    53. Adminuser adminuserLogin = userService.adminUser_login(username,password);
    54. System.out.println(username);
    55. System.out.println(password);
    56. if(adminuserLogin == null){
    57. model.addAttribute("message", "改用户未被授予管理员身份!");
    58. return "admin/index";
    59. }
    60. request.getSession().setAttribute("adminuserLogin", adminuserLogin);
    61. // model.addAttribute("adminuserLogin", adminuserLogin);
    62. return "admin/home";
    63. }
    64. }

    购物车管理控制层:

    1. @Controller
    2. public class cartController {
    3. @Autowired
    4. private ProductService productService;
    5. // 添加到购物车
    6. @RequestMapping("/addCart")
    7. public String addCart(HttpServletRequest request,@RequestParam int pid,@RequestParam int count ,Model model){
    8. Product product = productService.finbProductByPid(pid);
    9. // 存进一个购物项
    10. CartItem cartItem = new CartItem();
    11. cartItem.setCount(count);
    12. cartItem.setProduct(product);
    13. cartItem.setSubtotle(count*product.getShopPrice());
    14. // 存进购物车
    15. Cart cart=getCart(request);
    16. cart.addCart(cartItem);
    17. return "cart";
    18. }
    19. // 查看我的购物车
    20. @RequestMapping("/myCart")
    21. public String myCart(HttpServletRequest request,Model model){
    22. User loginUser = (User) request.getSession().getAttribute("loginUser");
    23. if (loginUser == null) {
    24. model.addAttribute("message","您还没有登录!");
    25. return "msg";
    26. }
    27. return "cart";
    28. }
    29. // 清空购物车
    30. @RequestMapping("/clearCart")
    31. public String clearCart(HttpServletRequest request){
    32. Cart cart=getCart(request);
    33. cart.clearCart();
    34. return "redirect:myCart.action";
    35. }
    36. // 删除某个购物项
    37. @RequestMapping("/delProFromCart")
    38. public String delProFromCart(@RequestParam int pid,HttpServletRequest request){
    39. Cart cart=getCart(request);
    40. cart.delProFromCart(pid);
    41. return "redirect:myCart.action";
    42. }
    43. public Cart getCart(HttpServletRequest request) {
    44. Cart cart = (Cart) request.getSession().getAttribute("cart");
    45. if (cart == null) {
    46. cart = new Cart();
    47. request.getSession().setAttribute("cart", cart);
    48. }
    49. return cart;
    50. }
    51. }

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

  • 相关阅读:
    Java面试笔记:CopyOnWriteArrayList是怎么保证线程安全的?
    SpringCloud——消息总线——Bus
    我的数学学习回忆录——一个数学爱好者的反思(一)
    【数据结构与算法】二分查找算法
    一周净赚一套房,“羊了个羊”爆火的产品逻辑可复制吗?
    java常见锁策略与CAS
    学习笔记-TLS
    测试用例的设计
    Android 学习 鸿蒙HarmonyOS 4.0 第一天
    未来的大模型发展
  • 原文地址:https://blog.csdn.net/m0_66863468/article/details/125551541