Java畢業設計實戰之仿小米電子產品售賣商城系統的實現

項目描述:這是一個基於SpringBoot+Vue框架開發的仿小米電子產品售賣商城系統。首先,這是一個前後端分離的項目,代碼簡潔規范,註釋說明詳細。其次,這項目功能豐富,具有一個電子產品售賣商城系統該有的所有功能。

項目功能:此項目分為兩個角色:普通用戶和管理員。普通用戶有登錄註冊、瀏覽商品信息、添加購物車、結算訂單、查看個人信息、查看個人訂單詳情等等功能。管理員有管理所有商品信息、管理所有訂單信息、管理所有用戶信息、查看收益數據圖表等等功能。

應用技術:SpringBoot + VueCli + MySQL + MyBatis + Redis + ElementUI

運行環境:IntelliJ IDEA2019.3.5+ MySQL5.7+ Redis5.0.5 + JDK1.8 + Maven3.6.3+ Node14.16.1

後臺管理員訂單管理:

@CrossOrigin
@RestController
@RequestMapping("orders")
public class OrderController {
 
    @Autowired
    private OrderServiceImp orderServiceImp;
 
    @Autowired
    private RegLogServiceImp regLogServiceImp;
 
    @PostMapping("/createorder")
    public OrderResult createOrder(@RequestBody OrdCreaParm ordCreaParm) throws IOException {
        OrderResult orderResult = new OrderResult();
        orderResult.setStatus(0);
        OrderList orderList = orderServiceImp.creatOrder(ordCreaParm);
        orderResult.setData(orderList);
        return orderResult;
    }
 
    @RequestMapping("/getorderlist")
    public UserOrdListResult getUserOrdList(String username) throws IOException {
 
        UserOrdListResult userOrdListResult = new UserOrdListResult();
        User user = regLogServiceImp.getUserByUserName(username);
        String userid = user.getUserid();
 
        List<UserOrdList> orderList = orderServiceImp.getOrderList(userid);
 
        for(UserOrdList userOrdList:orderList){
            int orderNo = userOrdList.getOrderNo();
            List<UserOrdItemList> orderListItems = orderServiceImp.getOrderListItems(orderNo);
            userOrdList.setItems(orderListItems);
        }
 
        userOrdListResult.setStatus(0);
        userOrdListResult.setTotal(orderList.size());
        userOrdListResult.setList(orderList);
 
        return userOrdListResult;
 
    }
 
 
 
    //下單成功後調用下面兩個方法
    @RequestMapping("/getorder")
    public OrdFinaResult getOrder(@RequestParam("id") int id) throws IOException{
        OrdFinaResult orderResult = new OrdFinaResult();
        orderResult.setStatus(0);
        OrdFina orderList = orderServiceImp.getOrderById(id);
        orderResult.setOrdFina(orderList);
        return orderResult;
    }
 
    @RequestMapping("/getorderdetail")
    public OrdFinaResult getOrderDetail(@RequestParam("username") String username) throws IOException{
        User user = regLogServiceImp.getUserByUserName(username);
        String userid = user.getUserid();
        List<orderItemVoList> orderItems = orderServiceImp.getOrderItems(userid);
        OrdFinaResult orderResult = new OrdFinaResult();
        orderResult.setStatus(0);
        orderResult.setLists(orderItems);
        return orderResult;
    }
}

後臺商品信息管理:

@CrossOrigin
@RestController
@RequestMapping("goods")
public class GoodController {
        @Autowired
        private GoodServiceImp goodServiceImp;
 
        @RequestMapping("getGoodsAll")
        private GoodsAll getGoodByCategory() {
                GoodsAll goodsAll = new GoodsAll();
                ArrayList<GoodAll> goodAlls = new ArrayList<>();
                for (int i = 1; i <= 9; i++) {
                        List<Good> good = goodServiceImp.getGood(i);
                        GoodCategory goodCategory = goodServiceImp.getGoodCategory(i);
                        GoodAll goodAll = new GoodAll();
                        goodAll.setName(goodCategory.getName());
                        goodAll.setFoods(good);
                        goodAlls.add(goodAll);
                }
                goodsAll.setData(goodAlls);
                return goodsAll;
        }
}

用戶信息控制層:

 
 
import java.io.IOException;
 
@CrossOrigin
@RestController
@RequestMapping("User")
public class UserController {
 
    @Autowired
    private UserServiceImp userServiceImp;
 
    @RequestMapping("/getUsers")
    public UserResult getUsers() throws IOException {
        UserResult userResult = userServiceImp.getUsers();
        return userResult;
    }
}

登錄控制層:

@CrossOrigin
@RestController
@RequestMapping("Login")
public class LoginController {
 
    @Autowired
    private LoginServiceImp loginServiceImp;
 
    Map<String, String> keyMap = RSAUtils.createKeys(512);
//    String  publicKey = keyMap.get("publicKey");
//    String  privateKey = keyMap.get("privateKey");
//    private String publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAIS-9P6aiWK-mNIJxz0R_XXIbHM21pS_ZncpQcE8T5Mu6P6sJfoi5Cw6S4jcSqxNbRs5FSUc59GAkU1Ek9onrz8CAwEAAQ";
    private String privateKey = "MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAhL70_pqJYr6Y0gnHPRH9dchsczbWlL9mdylBwTxPky7o_qwl-iLkLDpLiNxKrE1tGzkVJRzn0YCRTUST2ievPwIDAQABAkAviOHaOiRwQ6gdrnq2F7cXcknDiCOW6GMc0J1HQP2Nyn52HKtc9E9Ailm-eQesTw6P-qTsvHMyfuVYz8fLhfkhAiEAvhvoG2Dz6qSN6IHeuPboJP7YHK9zTt6M_NGCJKAenasCIQCywU7eStITcHFTRDjjShH0CfO-vR6q-zgWQPjtNI_YvQIgY8UNiODW4bu-ZdlSY8vghRnhnRxO7YNKhpwFKueFacUCIQCZ-P65ZVNs4ScMZTBnP48VWVk2S-rVto0KRi7lC6h4NQIgEa_GhBO6U2p6G5cGAR25ZiQVH9dFnrMVyPxY7P7-WsA";
 
    @PostMapping("/login")
    public LoginResult Login(@RequestBody User adminUser) throws IOException, InvalidKeySpecException, NoSuchAlgorithmException {
        User user = loginServiceImp.getUserByUserName(adminUser.getUsername());
        LoginResult result = new LoginResult();
        LoginData loginData = new LoginData();
 
        if (user == null) {
            result.setMsg("無此用戶,請重新輸入正確用戶名");
            result.setStatus(2008);
        } else {
            if (RSAUtils.privateDecrypt(user.getPwd(), RSAUtils.getPrivateKey(privateKey)).equals(adminUser.getPwd())){
                result.setStatus(0);
                String token = TokenUtil.token(user.getId().trim());
                loginData.setToken(token);
                result.setMsg("登錄成功");
                result.setStatus(1010);
                result.setData(loginData);
            }else{
                result.setStatus(2007);
                result.setMsg("密碼錯誤");
            }
        }
        return result;
    }
}

到此這篇關於Java畢業設計實戰之仿小米電子產品售賣商城系統的實現的文章就介紹到這瞭,更多相關Java 仿小米商城系統內容請搜索WalkonNet以前的文章或繼續瀏覽下面的相關文章希望大傢以後多多支持WalkonNet!

推薦閱讀: