基于java springboot钢材管理系统源码和论文

【522】基于java springboot钢材管理系统

摘 要

随着信息技术和互联网的发展,材行业也逐渐改变企业的经营模式和管理模式,从传统的人工管理体制向信息化自动化管理体制过度。在这样的大背景下, 加工和销售管理系统在众多钢材企业得到了广泛应用。

首先,对锋新钢材企业目前的管理和经营现状进行了分析,然后了解当前主流的软件开发平台、开发工具和技术、数据库等基础上,提出了基于web技术,使用SpringBoot+MyBatis框架开发,前端采用基于BootStrap框架开发的界面,使用MySQL数据库完成锋新钢材加工与销售管理系统的开发方案,并运用UML面向对象分析和设计技术完成了系统的建模,最后实现了一个具有销售和加工管理功能的锋新钢材加工与销售管理系统。该系统可以很好的为锋新钢材企业进行有效的管理,代替人工完成传统工作中大量的繁琐事务,减少企业管理员的工作量,减少人为因素产生的错误,提高企业管理效能。

关键词:钢材;加工与销售;SpringBoot;MyBatis;BootStrap;MySQL

【522】基于java springboot钢材管理系统

Abstract

With the development of information technology and Internet, the steel industry has gradually changed the business model and management mode of enterprises, from the traditional manual management system to the information automation management system. Under such a background, processing and sales management system has been widely used in many steel enterprises.

On the basis of understanding the current mainstream software development platform, development tools and technology, database and so on, this paper puts forward the development based on web technology, using SpringBoot MyBatis framework, using interface based on BootStrap framework development, using MySQL database to complete the development scheme of Fengxin steel processing and sales management system, and using object-oriented analysis and design technology to complete the modeling of the system, and finally realizing a Fengxin steel processing sales and processing management functions with sales management system. The system can effectively manage Fengxin steel enterprises, replace manual completion of a large number of tedious tasks in traditional work, reduce the workload of enterprise administrators, reduce the errors caused by human factors, and improve the efficiency of enterprise management.

Keywords: Steel; Processing and Sales; SpringBoot;MyBatis;BootStrap;MySQL

package com.lgf.demo.controller;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lgf.demo.domain.*;

import com.lgf.demo.service.CustomerService;
import com.lgf.demo.utils.CommonsUtils;
import com.lgf.demo.utils.MailUtils;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.mail.MessagingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/customer")
public class CustomerController {
    @Autowired
    private CustomerService customerService;

    @RequestMapping(
            value="/contact",
            produces= {"text/html;charset=utf-8"}
    )
    public String contact(){
        return "html/contact";
    }

    @RequestMapping(
            value="/login",
            produces= {"text/html;charset=utf-8"}
    )
    public String login( HttpServletRequest request){

        HttpSession session = request.getSession();
        List<Category> caList = customerService.getCategory();
        session.setAttribute("caList", caList);
        return "html/login";
    }

    @RequestMapping(
            value="/checkout",
            produces= {"text/html;charset=utf-8"}
    )
    public String checkout(){
        return "html/checkout";
    }

    //用户登录
    @RequestMapping(
            value="/testlogin",
            produces= {"text/html;charset=utf-8"}
    )
    public void testlogin(Customer customer, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        HttpSession session = request.getSession();

        Customer ct = customerService.testlogin(customer);
        if(ct != null){
            //将user对象存到session中


            if(ct.getCustomer_state() == 1){
                session.setAttribute("customer", ct);
                //return "redirect:/html/index.html";
                response.sendRedirect(request.getContextPath()+"/customer/index");
            }else {
                request.setAttribute("loginError", "用户未激活,请登录邮箱激活");
                //return "html/login";
                request.getRequestDispatcher("/customer/login").forward(request, response);
            }
        }else{
            request.setAttribute("loginError", "用户名或密码错误");
            //return "html/login";
            request.getRequestDispatcher("/customer/login").forward(request, response);
        }


    }

    //客户注销
    @RequestMapping(
            value="/loginout",
            produces= {"text/html;charset=utf-8"}
    )
    public void loginout(HttpServletRequest request, HttpServletResponse response) throws IOException {
        HttpSession session = request.getSession();
        //注销
        session.invalidate();
        response.sendRedirect(request.getContextPath() +"/customer/index");
        //return "html/login";
    }

    @RequestMapping(
            value="/cart",
            produces= {"text/html;charset=utf-8"}
    )
    public String shop(){
        return "html/cart";
    }


    @RequestMapping(
            value="/re",
            produces= {"text/html;charset=utf-8"}
    )
    public String register1(){
        return "html/register";
    }

    //注册
    @RequestMapping(
            value="/register",
            produces= {"text/html;charset=utf-8"}
    )

    public String register( HttpServletRequest request,Model model){
        HttpSession session = request.getSession();

        Map<String, String[]> properties = request.getParameterMap();
        Customer customer = new Customer();

        try {
            BeanUtils.populate(customer,properties);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }

        customer.setCustomer_id(CommonsUtils.getUUID());
        customer.setCustomer_state(1);
        String activeCode = CommonsUtils.getUUID();
        customer.setCustomer_code(activeCode);

        int isRegisterSuccess = customerService.register(customer);

//        int flag = 0;
//        if(isRegisterSuccess == 1){
//            String emailMsg = "恭喜您注册成功,请点击下面的连接进行激活账户"
//                    + "<a href='http://localhost:8080/customer/active?activeCode="+activeCode+"'>"
//                    + "http://localhost:8080/customer/active?activeCode="+activeCode+"</a>";
//            try {
//                MailUtils.sendMail(customer.getCustomer_email(),emailMsg);
//            } catch (MessagingException e) {
//                e.printStackTrace();
//            }
            model.addAttribute("succ",1);

           return  "html/login";

    }

    @RequestMapping(
            value="/active",
            produces= {"text/html;charset=utf-8"}
    )
    public String active(HttpServletRequest request){
        //获得激活码

        String activeCode = request.getParameter("activeCode");
        int active = customerService.active(activeCode);
        return "html/login";
    }

    @RequestMapping(
            value="/checkUsername",
            produces= {"text/html;charset=utf-8"}
    )
    @ResponseBody
    public String checkUsername(HttpServletRequest request){
        String customer_name = request.getParameter("customer_name");
        Integer exist = customerService.checkUsername(customer_name);

    System.out.println(exist);
        boolean isExist = exist>0?true:false;
        JSONObject jsObj = new JSONObject();
        jsObj.put("isExist",isExist );
        return jsObj.toString();
    }

    public void cat(ModelMap model){
        //List<Category> caList = customerService.getCategory();
        //model.put("caList",caList);
    }

    //主页
    @RequestMapping(
            value="/index",
            produces= {"text/html;charset=utf-8"}
    )
    public String index(HttpServletRequest request, ModelMap model,HttpServletResponse response){
        HttpSession session = request.getSession();
        List<Category> caList = customerService.getCategory();
        session.setAttribute("caList", caList);
        List<Goods> hotProductList = customerService.findHotProductList();
        List<Category> categoryList = customerService.getCategory();

        model.put("hotProductList",hotProductList);
        model.put("categoryList",categoryList);
        return "html/index";
    }


    //菜单栏
    @RequestMapping(
            value="/caList",
            produces= {"text/html;charset=utf-8"}
    )
    @ResponseBody
    public String caList(){
        List<Category> caList = customerService.getCategory();
        JSONObject jsObj = new JSONObject();
        jsObj.put("caList",caList );
        return jsObj.toString();
    }

    //根据菜单选择相应的页面
    @RequestMapping(
            value="/productListByCid",
            produces= {"text/html;charset=utf-8"}
    )
    public String ProductListByCid(HttpServletRequest request, ModelMap model, Goods goods, @RequestParam(defaultValue = "0",value = "category_id") int category_id){
        HttpSession session = request.getSession();
        List<Category> caList = customerService.getCategory();
        session.setAttribute("caList", caList);
        //获得category_id
        int id = category_id;
        String name = request.getParameter("goods_name");
        goods.setGoods_name(name);
        if(id !=0 && goods.getCategory_id() != 0){
            int c_id = id;
            goods.setCategory_id(category_id);
            Category category = customerService.getCategoryByid(c_id);
            model.put("category_id", c_id);
            model.put("category", category.getCategory_name());
        }else{
            model.put("category", "商品");
        }

        String currentPageStr = request.getParameter("currentPage");
        if(currentPageStr==null) currentPageStr="1";
        int currentPage = Integer.parseInt(currentPageStr);
        int currentCount = 8;
        goods.setCurrentPage(currentPage);
        goods.setCurrentCount(currentCount);
        PageBean pageBean = customerService.findProductByPage(goods);
        model.put("pageBean", pageBean);
        model.put("g",goods);
        if(pageBean.getList().size() == 0){
           return "html/error";
        }
        return "html/shop";
    }




    //商品详细页面
    @RequestMapping(
            value="/productInfo",
            produces= {"text/html;charset=utf-8"}
    )
    public String productInfo(HttpServletRequest request, ModelMap model){
        HttpSession session = request.getSession();
        List<Category> caList = customerService.getCategory();
        session.setAttribute("caList", caList);
        //获得当前页
       // String currentPage = request.getParameter("currentPage");
        //获得商品类别
        String cid = request.getParameter("category_id");

        //获得要查询的商品的pid
        String goods_id = request.getParameter("goods_id");
        Goods goods = customerService.findProductByPid(goods_id);
        System.out.println(goods);

        String[] arr = goods.getGoods_images().split(",");
        for(String s :arr){
            System.out.println(s);
        }
        model.put("arr", arr);
        model.put("goods", goods);
       // model.put("currentPage", currentPage);
        model.put("cid", cid);

        return "html/product-layout3";
    }

    //将商品添加到购物车------------------------------
    @RequestMapping(
            value="/addProductToCart",
            produces= {"text/html;charset=utf-8"}
    )
    public String addProductToCart(HttpServletRequest request, ModelMap model){
        HttpSession session = request.getSession();
        List<Category> caList = customerService.getCategory();
        session.setAttribute("caList", caList);
        //获得要放到购物车的商品的goods_id
        String goods_id = request.getParameter("goods_id");
        //获得该商品的购买数量
        int buyNum = Integer.parseInt(request.getParameter("buyNum"));
        //获得goods对象
        Goods goods = customerService.findProductByPid(goods_id);
        System.out.println(goods);
        //计算小计
        double subtotal = goods.getGoods_price()*buyNum;
        //封装CartItem
        CartItem item = new CartItem();
        item.setGoods(goods);
        item.setBuyNum(buyNum);
        item.setSubtotal(subtotal);
        //获得购物车---判断是否在session中已经存在购物车
        Cart cart = (Cart) session.getAttribute("cart");
        if(cart==null){
            cart = new Cart();
        }
        //将购物项放到车中---key是goods_id
        //先判断购物车中是否已将包含此购物项了 ----- 判断key是否已经存在
        //如果购物车中已经存在该商品----将现在买的数量与原有的数量进行相加操作
        Map<String, CartItem> cartItems = cart.getCartItems();
        double newsubtotal = 0.0;
        if(cartItems.containsKey(goods_id)){
            //取出原有商品的数量
            CartItem cartItem = cartItems.get(goods_id);
            int oldBuyNum = cartItem.getBuyNum();
            oldBuyNum+=buyNum;
            cartItem.setBuyNum(oldBuyNum);
            cart.setCartItems(cartItems);
            //修改小计
            //原来该商品的小计
            double oldsubtotal = cartItem.getSubtotal();
            //新买的商品的小计
            newsubtotal = buyNum*goods.getGoods_price();
            cartItem.setSubtotal(oldsubtotal+newsubtotal);
        }else{
            //如果车中没有该商品
            cart.getCartItems().put(goods.getGoods_id(), item);
            newsubtotal = buyNum*goods.getGoods_price();
        }
        //计算总计
        double total = cart.getTotal()+newsubtotal;
        cart.setTotal(total);
        //将车再次访问session
        session.setAttribute("cart", cart);

        return "html/cart";
    }

    //购物车里更新----------------------------------------------------------------
    @RequestMapping(
            value="/upCart",
            produces= {"text/html;charset=utf-8"}
    )
    @ResponseBody
    public String upCart(HttpServletRequest request, ModelMap model){
        HttpSession session = request.getSession();
        //获得要放到购物车的商品的goods_id
        String goods_id = request.getParameter("goods_id");
        //获得该商品的购买数量
        int buyNum = Integer.parseInt(request.getParameter("buyNum"));
        //获得goods对象
        Goods goods = customerService.findProductByPid(goods_id);
        //计算小计
        double subtotal = goods.getGoods_price()*buyNum;
        //封装CartItem
        CartItem item = new CartItem();
        item.setGoods(goods);
        item.setBuyNum(buyNum);
        item.setSubtotal(subtotal);
        boolean flag = false;

        Cart cart = (Cart) session.getAttribute("cart");
        if(cart==null){
            cart = new Cart();
        }
        double total = cart.getTotal();
        Map<String, CartItem> cartItems = cart.getCartItems();
        double newsubtotal = 0.0;
        if(cartItems.containsKey(goods_id)){
            //取出原有商品的数量
            CartItem cartItem = cartItems.get(goods_id);
//            int oldBuyNum = cartItem.getBuyNum();
//            oldBuyNum+=buyNum;
            cartItem.setBuyNum(buyNum);
            cart.setCartItems(cartItems);
            //修改小计
            //原来该商品的小计
            double oldsubtotal = cartItem.getSubtotal();
            //新买的商品的小计
//            newsubtotal = buyNum*goods.getGoods_price();
            cartItem.setSubtotal(subtotal);
            total = total-oldsubtotal+subtotal;
            flag = true;
        }else{
            //如果车中没有该商品
            cart.getCartItems().put(goods.getGoods_id(), item);
            newsubtotal = buyNum*goods.getGoods_price();
            total = total+newsubtotal;
            flag = true;
        }
        cart.setTotal(total);
        //将车再次访问session
        session.setAttribute("cart", cart);
        JSONObject jsObj = new JSONObject();
        jsObj.put("flag",flag );
        jsObj.put("total",total );
        return jsObj.toString();
    }

    //删除单一商品
    @RequestMapping(
            value="/delProFromCart",
            produces= {"text/html;charset=utf-8"}
    )
    public String delProFromCart(HttpServletRequest request, ModelMap model){
        //获得要删除的item的pid
        String goods_id = request.getParameter("goods_id");
        //删除session中的购物车中的购物项集合中的item
        HttpSession session = request.getSession();
        Cart cart = (Cart) session.getAttribute("cart");
        if(cart!=null){
            Map<String, CartItem> cartItems = cart.getCartItems();
            //需要修改总价
            cart.setTotal(cart.getTotal()-cartItems.get(goods_id).getSubtotal());
            //删除
            cartItems.remove(goods_id);
            cart.setCartItems(cartItems);

        }

        session.setAttribute("cart", cart);
        return "html/cart";
    }

    //清空购物车
    @RequestMapping(
            value="/clearCart",
            produces= {"text/html;charset=utf-8"}
    )
    public String clearCart(HttpServletRequest request, ModelMap model){
        HttpSession session = request.getSession();
        session.removeAttribute("cart");

        return "html/cart";
    }

    //提交订单
    @RequestMapping(
            value="/submitOrder",
            produces= {"text/html;charset=utf-8"}
    )

    public void submitOrder(HttpServletRequest request, ModelMap model,HttpServletResponse response) throws IOException, ServletException {
        HttpSession session = request.getSession();

        //判断用户是否已经登录 未登录下面代码不执行
        Customer user = (Customer) session.getAttribute("customer");

        if(user==null){
            //没有登录

            //return "/customer/login";
            response.sendRedirect(request.getContextPath()+"/customer/login");
        }else {
            sales sales = new sales();
            sales.setSale_date(new Date());
            Calendar cal = Calendar.getInstance();
            int day = cal.get(Calendar.DATE);
            int month = cal.get(Calendar.MONTH) + 1;
            int year = cal.get(Calendar.YEAR);
            String m;
            String y;
            if(month <10){
                m = "0"+ String.valueOf(month);
            }else{
                m = String.valueOf(month);
            }

            if(day <10){
                y = "0" + String.valueOf(day);
            }else{
                y = String.valueOf(day);
            }
            String randStr = "";
            String times = String.valueOf(year) +m+y;
            for(int i = 0 ;i < 6 ;i ++ ){
                String randItem =String.valueOf((int)(Math.random() * 10));
                randStr += randItem;

            }
            String saleid = "FXGC" + times + randStr;
            System.out.println(saleid);
            sales.setSale_id(saleid);
            Cart cart = (Cart) session.getAttribute("cart");
            double total = cart.getTotal();
            sales.setSale_total(total);
            sales.setSale_pay(0);
            sales.setSale_address(null);
            sales.setSale_phone(null);
            sales.setSale_state(0);
            sales.setCustomer(user);
            Map<String,CartItem> cartItems = cart.getCartItems();
            int i =1;
            String imformation = "";
            for(Map.Entry<String,CartItem> entry: cartItems.entrySet()){
                CartItem cartItem = entry.getValue();
                SalesDetailed salesDetailed = new SalesDetailed();
                salesDetailed.setGoods_id(cartItem.getGoods().getGoods_id());
                salesDetailed.setQuantity(cartItem.getBuyNum());
                salesDetailed.setTotal(cartItem.getSubtotal());
                salesDetailed.setGoods(cartItem.getGoods());
                salesDetailed.setSale_id(saleid);
                salesDetailed.setId(i);
                salesDetailed.setCommodity_name(salesDetailed.getGoods().getGoods_name());
                salesDetailed.setPrice(salesDetailed.getGoods().getGoods_price());
                salesDetailed.setCompany(salesDetailed.getGoods().getUnit().getUnit_name());
                i++;
                imformation = imformation +"  "+ salesDetailed.getGoods().getGoods_name();

                sales.getSalesDetaileds().add(salesDetailed);

            }
            sales.setSale_information(imformation.trim());
            customerService.submitSales(sales);
            session.setAttribute("sales",sales);
            //return "";

            response.sendRedirect(request.getContextPath()+"/customer/checkout");
            //request.getRequestDispatcher("/customer/checkout").forward(request, response);
        }

    }

    //完成付款
    @RequestMapping(
            value="/confirmSale",
            produces= {"text/html;charset=utf-8"}
    )
    public String confirmSale(HttpServletRequest request, ModelMap model,HttpServletResponse response){
        String id = request.getParameter("out_trade_no");
        System.out.println(id);
        sales sales = new sales();
        sales.setSale_id(id);
        int i = customerService.upPay(sales);
        HttpSession session = request.getSession();
        session.removeAttribute("cart");
        return "redirect:/customer/mysale";
    }

    @RequestMapping(
            value="/salelist",
            produces= {"text/html;charset=utf-8"}
    )
    public String salelist(HttpServletRequest request, ModelMap model,HttpServletResponse response){

        model.addAttribute("pageInfo",request.getAttribute("pageInfo"));


        return "html/salelist";
    }

    @RequestMapping(
            value="/mysale",
            produces= {"text/html;charset=utf-8"}
    )
    public void mysale(HttpServletRequest request, ModelMap model,HttpServletResponse response, @RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum) throws IOException, ServletException {
        HttpSession session = request.getSession();
        //判断用户是否已经登录 未登录下面代码不执行
        Customer user = (Customer) session.getAttribute("customer");
        if(user==null){
            //没有登录
            response.sendRedirect(request.getContextPath()+"/customer/login");
        }else{
            PageHelper.startPage(pageNum,5);
            List<sales> salesList = customerService.findAllSales(user.getCustomer_id());
            if(salesList !=null){
                for(sales sales :salesList){
                    //获得每一个订单的oid
                    String sale_id = sales.getSale_id();
                    List<SalesDetailed> salesDetailedsList = customerService.findAllSalesDetailedBysid(sale_id);
                    sales.setSalesDetaileds(salesDetailedsList);
                }
            }


            PageInfo<sales> pageInfo = new PageInfo<>(salesList);
            request.setAttribute("pageInfo",pageInfo);
           // request.setAttribute("salesList",salesList);
            request.getRequestDispatcher("/customer/salelist").forward(request, response);
        }
    }

    //我的订单----去付款
    @RequestMapping(
            value="/gopay",
            produces= {"text/html;charset=utf-8"}
    )
    public void gopay(HttpServletRequest request, ModelMap model,HttpServletResponse response) throws IOException {
        HttpSession session = request.getSession();
        String sale_id = request.getParameter("sale_id");
        sales sales = customerService.findSaleBysaleid(sale_id);
        List<SalesDetailed> salesDetailedList = customerService.findAllSalesDetailedBysid(sale_id);
        sales.setSalesDetaileds(salesDetailedList);
        session.setAttribute("sales",sales);
        response.sendRedirect(request.getContextPath()+"/customer/checkout");

    }

    //我的订单----删除订单
    @RequestMapping(
            value="/godelete",
            produces= {"text/html;charset=utf-8"}
    )
    public void godelete(HttpServletRequest request, ModelMap model,HttpServletResponse response) throws IOException, ServletException {
        HttpSession session = request.getSession();

        //判断用户是否已经登录 未登录下面代码不执行
        Customer user = (Customer) session.getAttribute("customer");
        if(user==null){
            //没有登录
            response.sendRedirect(request.getContextPath()+"/customer/login");
        }else{
            String id = request.getParameter("sale_id");
            customerService.deleteSaleBysaleid(id);
            List<sales> salesList = customerService.findAllSales(user.getCustomer_id());
            if(salesList !=null){
                for(sales sales :salesList){
                    //获得每一个订单的oid
                    String sale_id = sales.getSale_id();
                    List<SalesDetailed> salesDetailedsList = customerService.findAllSalesDetailedBysid(sale_id);
                    sales.setSalesDetaileds(salesDetailedsList);
                }
            }
            request.setAttribute("salesList",salesList);
            request.getRequestDispatcher("/customer/salelist").forward(request, response);
        }

    }

    //获取订单状态
    @RequestMapping(
            value="/getstate",
            produces= {"text/html;charset=utf-8"}
    )
    @ResponseBody
    public String getstate(HttpServletRequest request){
        String s_id =request.getParameter("s_id");
        State state = customerService.getstate(s_id);

        if(state.getState() == null){
            state.setState(0);
        }
        JSONObject jsObj = new JSONObject();
        jsObj.put("data",state);

        return jsObj.toString();
    }

    //收藏
    @RequestMapping(
            value="/collect",
            produces= {"text/html;charset=utf-8"}
    )

    public String collect(HttpServletRequest request, ModelMap model,HttpServletResponse response){

        model.addAttribute("pageInfo",request.getAttribute("pageInfo"));

        return "html/collect";
    }

    @RequestMapping(
            value="/getcollect",
            produces= {"text/html;charset=utf-8"}
    )
    public void getcollect(HttpServletRequest request, Model model, @RequestParam(defaultValue = "1",value = "pageNum") Integer pageNum,HttpServletResponse response) throws IOException, ServletException {
        HttpSession session = request.getSession();

        //判断用户是否已经登录 未登录下面代码不执行
        Customer user = (Customer) session.getAttribute("customer");
        if(user==null){
            //没有登录
            response.sendRedirect(request.getContextPath()+"/customer/login");
        }else{
            PageHelper.startPage(pageNum,5);
            List<Collect> collectList = customerService.getcollect(user.getCustomer_id());
            //System.out.println(collectList);
            PageInfo<Collect> pageInfo = new PageInfo<>(collectList);
            request.setAttribute("pageInfo",pageInfo);
            request.getRequestDispatcher("/customer/collect").forward(request, response);
        }
    }

    @RequestMapping(
            value="/delco",
            produces= {"text/html;charset=utf-8"}
    )
    public void delco(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
        String cid = request.getParameter("customer_id");
        String goods_id =  request.getParameter("goods_id");
        Collect collect = new Collect();
        collect.setCustomer_id(cid);
        collect.setGoods_id(goods_id);
        //System.out.println(collect);
        int i = customerService.delco(collect);
        response.sendRedirect(request.getContextPath()+"/customer/getcollect");
    }

    @RequestMapping(
            value="/addco",
            produces= {"text/html;charset=utf-8"}
    )
    @ResponseBody
    public String addco(HttpServletRequest request){
        JSONObject jsObj = new JSONObject();
        int flag = 0;
        HttpSession session = request.getSession();

        //判断用户是否已经登录 未登录下面代码不执行
        Customer user = (Customer) session.getAttribute("customer");
        if(user==null){
            //没有登录
            flag = 1;
        }else {
            String goods_id =  request.getParameter("goods_id");

            Collect collect = new Collect();
            collect.setCustomer_id(user.getCustomer_id());
            collect.setGoods_id(goods_id);
            int j = customerService.sco(collect);
            if(j==1){
                flag = 3;
            }else {
                int i = customerService.addco(collect);
                if(i == 1){
                    flag = 2;
                }
            }
        }
        jsObj.put("data",flag );
        return jsObj.toString();
    }

    @RequestMapping(
            value="/gofinish",
            produces= {"text/html;charset=utf-8"}
    )
    @ResponseBody
    public String gofinish(HttpServletRequest request){
        JSONObject jsObj = new JSONObject();
        String sid = request.getParameter("s_id");
        int flag = 0;
        flag = customerService.upstate7(sid);
        jsObj.put("data",flag );
        return jsObj.toString();
    }

    @RequestMapping(
            value="/upinfo",
            produces= {"text/html;charset=utf-8"}
    )
    public String upinfo(Customer customer,HttpServletRequest request,Model model){
        HttpSession session = request.getSession();
        System.out.println(customer);
        int flag =0;
        flag = customerService.upinfo(customer);
        if(flag == 1){
            model.addAttribute("succ",flag);
            session.setAttribute("customer", customer);
        }else{
            model.addAttribute("succ",flag);
        }
        return "html/contact";
    }

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

程序猿毕业分享网

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

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

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

打赏作者

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

抵扣说明:

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

余额充值