<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
環境設定:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支援)
專案技術:
JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等。
@CrossOrigin @RestController @RequestMapping("carts") public class CartController { @Autowired private RegLogServiceImp regLogServiceImp; @Autowired private GoodServiceImp goodServiceImp; @Autowired private CartServiceImp cartServiceImp; @PostMapping("/push") public CartResult putShop(@RequestBody pushCart pushcart) throws IOException { CartResult cartResult = new CartResult(); boolean success = TokenUtil.verify(pushcart.getToken()); if (success) { cartResult.setStatus(0); User user = regLogServiceImp.getUserByUserName(pushcart.getUsername().trim()); String userid = user.getUserid(); CartGood cartGood = goodServiceImp.getGoodByid(userid, pushcart.getProductId()); if (cartGood == null) { int goodcount = 1; CartGoodInsert goodByidinsert = goodServiceImp.getGoodByidinsert(pushcart.getProductId()); goodServiceImp.insCartGood(userid, pushcart.getProductId(), goodByidinsert.getName(), goodByidinsert.getPrice(), goodcount, goodByidinsert.getSubtitle(), goodByidinsert.getProductStock(), goodByidinsert.getStatus(), true); } else { goodServiceImp.updateCartGood(userid, cartGood.getCount() + 1, pushcart.getProductId(), (cartGood.getCount() + 1) * cartGood.getPrice()); } cartProductVoList cartProductVoList = cartServiceImp.getCartProduct(userid); int cartTotalPrice = 0; boolean selectedAll = true; int cartTotalQuantity = 0; for (cartProduct cartProduct : cartProductVoList.getList()) { cartTotalPrice += cartProduct.getProductTotalPrice(); if (!cartProduct.isProductSelected()) { selectedAll = false; } cartTotalQuantity += cartProduct.getCount(); } cartResult.setStatus(0); cartResult.setCartTotalPrice(cartTotalPrice); cartResult.setCartTotalQuantity(cartTotalQuantity); cartResult.setData(cartProductVoList); cartResult.setImageHost("www.mi.com"); cartResult.setSelectedAll(selectedAll); } else { cartResult.setStatus(10); } return cartResult; } @GetMapping("/sum") public CartResult getCartSum(@RequestParam("username") String username) throws IOException { CartResult cartResult = new CartResult(); User user = regLogServiceImp.getUserByUserName(username); String userid = user.getUserid(); cartProductVoList cartProductVoList = cartServiceImp.getCartProduct(userid); if(cartProductVoList==null){ cartResult.setStatus(0); cartResult.setCartTotalQuantity(0); } else { int cartTotalQuantity=0; for(cartProduct cartProduct:cartProductVoList.getList()){ cartTotalQuantity+=cartProduct.getCount(); } cartResult.setStatus(0); cartResult.setCartTotalQuantity(cartTotalQuantity); } return cartResult; } @RequestMapping("/del") public CartResult delCarts(@RequestParam("id") int goodid, @RequestParam("username") String username) throws IOException { User user = regLogServiceImp.getUserByUserName(username); String userid = user.getUserid(); goodServiceImp.delGoodByid(userid,goodid); CartResult cartResult = getCarts(username); return cartResult; } @RequestMapping("/getcarts") public CartResult getCarts (@RequestParam("username") String username) throws IOException { CartResult cartResult = new CartResult(); User user = regLogServiceImp.getUserByUserName(username); String userid = user.getUserid(); cartProductVoList cartProductVoList = cartServiceImp.getCartProduct(userid); if(cartProductVoList==null){ cartResult.setStatus(0); cartResult.setCartTotalQuantity(0); cartResult.setSelectedAll(false); cartResult.setImageHost("www.mi.com"); cartResult.setCartTotalQuantity(0); } else { int carttotalPrice=0; boolean selectedall=true; int carttotalQuantity=0; for(cartProduct cartProduct:cartProductVoList.getList()){ if(cartProduct.isProductSelected()) carttotalPrice+=cartProduct.getProductTotalPrice(); if(!cartProduct.isProductSelected()){ selectedall=false; } carttotalQuantity+=cartProduct.getCount(); } cartResult.setStatus(0); cartResult.setCartTotalPrice(carttotalPrice); cartResult.setCartTotalQuantity(carttotalQuantity); cartResult.setData(cartProductVoList); cartResult.setImageHost("www.mi.com"); cartResult.setSelectedAll(selectedall); } return cartResult; } @GetMapping("/updatecart") public CartResult getCarts ( @RequestParam("goodid") int goodid, @RequestParam("username") String username, @RequestParam("quantity") int count, @RequestParam("selected") boolean selected ) throws IOException { User user = regLogServiceImp.getUserByUserName(username); String userid = user.getUserid(); CartGood goodByid = goodServiceImp.getGoodByid(userid, goodid); goodServiceImp.updaCartNumSel(userid,goodid,count,selected,goodByid.getPrice()*count); CartResult carts = getCarts(username); return carts; } @GetMapping("/selectAll") public CartResult SelectAllCart(@RequestParam("username") String username) throws IOException { User user = regLogServiceImp.getUserByUserName(username); String userid = user.getUserid(); goodServiceImp.updaCartSelect(userid); CartResult cartResult = getCarts(username); return cartResult; } @GetMapping("/unSelectAll") public CartResult unSelectAllCart(@RequestParam("username") String username) throws IOException { User user = regLogServiceImp.getUserByUserName(username); String userid = user.getUserid(); goodServiceImp.updaCartunSelect(userid); CartResult cartResult = getCarts(username); cartResult.setCartTotalQuantity(0); cartResult.setCartTotalPrice(0); return cartResult; } }
@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; } }
@CrossOrigin @RestController @RequestMapping("Good") public class GoodController { @Autowired private GoodServiceImp goodServiceImp; @GetMapping("/getGood") private GoodResult getGood(@RequestParam("pageIndex") int pageIndex, @RequestParam("pageSize") int pageSize, @RequestParam("name") String goodname ) throws IOException { GoodResult goodResult = goodServiceImp.getGood(pageIndex,pageSize,goodname); return goodResult; } @GetMapping("/getGoodById") private GoodResult getGoodById(@RequestParam("category") int pageIndex, @RequestParam("pageSize") int pageSize ) throws IOException { GoodResult goodResult = goodServiceImp.getGoodById(pageIndex,pageSize); return goodResult; } @RequestMapping("/getGoodByName") private GoodResult getGoodByName(@RequestParam("name") String goodname) throws IOException { GoodResult goodResult = goodServiceImp.getGoodByName(goodname); return goodResult; } @RequestMapping("/updGood") private GoodResult getGoodByName(@RequestParam("good_id") int goodid, @RequestParam("name") String goodname, @RequestParam("newhot") int newhot) throws IOException { GoodResult goodResult = goodServiceImp.updGood(goodid,goodname,newhot); return goodResult; } @GetMapping("/getGoodPicById") private GoodPicResult getGoodPicById(@RequestParam("category") int pageIndex, @RequestParam("pageSize") int pageSize ) throws IOException { GoodPicResult goodpicResult = goodServiceImp.getGoodPic(pageIndex,pageSize); return goodpicResult; } @RequestMapping("/getGoodPicByName") private GoodPicResult getGoodPicByName(@RequestParam("name") String goodname) throws IOException { // int categor = Integer.parseInt(category); GoodPicResult goodResult = goodServiceImp.getGoodPicByName(goodname); return goodResult; } @PostMapping("/pushGood") private GoodPushResult pushGood(@RequestBody good good) throws IOException { GoodPushResult goodPushResult = goodServiceImp.getGoodPush(good); return goodPushResult; } @PostMapping("/delGood") private void delGood(@RequestBody good good) throws IOException { goodServiceImp.delGood(good); } @PostMapping("/delMulGood") private void delMulGood(@RequestBody List<good> goods) throws IOException { goodServiceImp.delMulGood(goods); } @GetMapping("/getGoodPic") private GoodPicResult getGoodPic(@RequestParam("pageIndex") int pageIndex, @RequestParam("pageSize") int pageSize) throws IOException { GoodPicResult goodPicResult = goodServiceImp.getGoodPic(pageIndex,pageSize); return goodPicResult; } @PostMapping("/updGoodPic") private void upGoodPic(@RequestBody GoodPic goodPic) throws IOException { int goodid= goodPic.getGood_id(); String icon= goodPic.getIcon(); String imageHead = goodPic.getImageHead(); String imageFoot = goodPic.getImageFoot(); goodServiceImp.updGoodPic(goodid,icon,1); goodServiceImp.updGoodPic(goodid,imageHead,2); goodServiceImp.updGoodPic(goodid,imageFoot,3); } }
@CrossOrigin @RestController @RequestMapping("category") public class CategoryController { @Autowired private CategServiceImp categServiceImp; @GetMapping("/getCategory") private CateResult getCategory(@RequestParam("pageIndex") int pageIndex, @RequestParam("pageSize") int pageSize) throws IOException { CateResult cateResult = categServiceImp.getCategory(pageIndex, pageSize); return cateResult; } @PostMapping("/updateCategory") private void updateCategory(@RequestBody Category category) throws IOException { categServiceImp.updCategory(category.getName(),category.getCategoryId()); } }
以上就是Java實戰之小米交易商城系統的實現的詳細內容,更多關於Java交易商城系統的資料請關注it145.com其它相關文章!
相關文章
<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
综合看Anker超能充系列的性价比很高,并且与不仅和iPhone12/苹果<em>Mac</em>Book很配,而且适合多设备充电需求的日常使用或差旅场景,不管是安卓还是Switch同样也能用得上它,希望这次分享能给准备购入充电器的小伙伴们有所
2021-06-01 09:31:42
除了L4WUDU与吴亦凡已经多次共事,成为了明面上的厂牌成员,吴亦凡还曾带领20XXCLUB全队参加2020年的一场音乐节,这也是20XXCLUB首次全员合照,王嗣尧Turbo、陈彦希Regi、<em>Mac</em> Ova Seas、林渝植等人全部出场。然而让
2021-06-01 09:31:34
目前应用IPFS的机构:1 谷歌<em>浏览器</em>支持IPFS分布式协议 2 万维网 (历史档案博物馆)数据库 3 火狐<em>浏览器</em>支持 IPFS分布式协议 4 EOS 等数字货币数据存储 5 美国国会图书馆,历史资料永久保存在 IPFS 6 加
2021-06-01 09:31:24
开拓者的车机是兼容苹果和<em>安卓</em>,虽然我不怎么用,但确实兼顾了我家人的很多需求:副驾的门板还配有解锁开关,有的时候老婆开车,下车的时候偶尔会忘记解锁,我在副驾驶可以自己开门:第二排设计很好,不仅配置了一个很大的
2021-06-01 09:30:48
不仅是<em>安卓</em>手机,苹果手机的降价力度也是前所未有了,iPhone12也“跳水价”了,发布价是6799元,如今已经跌至5308元,降价幅度超过1400元,最新定价确认了。iPhone12是苹果首款5G手机,同时也是全球首款5nm芯片的智能机,它
2021-06-01 09:30:45