最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Java?實(shí)戰(zhàn)范例之校園二手市場(chǎng)系統(tǒng)的實(shí)現(xiàn)

 更新時(shí)間:2021年11月23日 08:37:58   作者:qq_1334611189  
讀萬(wàn)卷書(shū)不如行萬(wàn)里路,只學(xué)書(shū)上的理論是遠(yuǎn)遠(yuǎn)不夠的,只有在實(shí)戰(zhàn)中才能獲得能力的提升,本篇文章手把手帶你用java+SSM+mysql+maven+tomcat實(shí)現(xiàn)一個(gè)校園二手市場(chǎng)系統(tǒng),大家可以在過(guò)程中查缺補(bǔ)漏,提升水平

一、項(xiàng)目簡(jiǎn)述( +IW文檔)

功能:本系統(tǒng)分用戶(hù)前臺(tái)和管理員后臺(tái)。 本系統(tǒng)用例模型有三種,分別是游客、注冊(cè)用戶(hù)和系統(tǒng)管 理員。下面分別對(duì)這三個(gè)角色的功能進(jìn)行描述: 1) 誕 游客是未注冊(cè)的用戶(hù),他們可以瀏覽物物品,可以搜索物 品,如需購(gòu)買(mǎi)物品,必須先注冊(cè)成為網(wǎng)站用戶(hù)。游客主要 功觸嚇: a.瀏覽物品 b.搜索物品 c.注冊(cè)成為網(wǎng)站用戶(hù) 2) 注冊(cè)用戶(hù) 注冊(cè)用戶(hù)是經(jīng)過(guò)網(wǎng)站合法認(rèn)證的用戶(hù),登錄網(wǎng)站后可以瀏 覽物品、搜索物品、發(fā)布物品、關(guān)注物品、購(gòu)買(mǎi)物品和查 看個(gè)人中心。 3) 系統(tǒng)管理員 系統(tǒng)管理員主要負(fù)責(zé)系統(tǒng)的后臺(tái)管理工作,主要功能如 下: 用戶(hù)管理,商品管理等等。

二、項(xiàng)目運(yùn)行

環(huán)境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe ( IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)

項(xiàng)目技術(shù): JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等。

用戶(hù)信息管理控制器:

@Controller
@RequestMapping(value = "user")
public class UserController {
	private final GoodService goodService;
	private final OrderService orderService;
	private final ReviewService reviewService;
	private final UserService userService;
	private final CollectService collectService;
 
	@Autowired
	public UserController(GoodService goodService, OrderService orderService,
			ReviewService reviewService, UserService userService,
			CollectService collectService) {
		this.goodService = goodService;
		this.orderService = orderService;
		this.reviewService = reviewService;
		this.userService = userService;
		this.collectService = collectService;
	}
 
	@RequestMapping(value = "userProfile", method = RequestMethod.GET)
	public String getMyProfile(ModelMap model, HttpSession session) {
		User user = (User) session.getAttribute("user");
		if (user == null) {
			return "redirect:/";
		}
		List<Collect> collects = collectService
				.getCollectByUserId(user.getId());
		for (Collect collect : collects) {
			collect.setGood(goodService.getGoodById(collect.getGoodId()));
		}
		List<Good> goods = goodService.getGoodByUserId(user.getId());
		List<Order> orders = orderService.getOrderByCustomerId(user.getId());
		List<Review> reviews = reviewService.gerReviewByToUserId(user.getId());
		List<Reply> replies = reviewService.gerReplyByToUserId(user.getId());
		List<Order> sellGoods = orderService.getOrderBySellerId(user.getId());
		model.addAttribute("collects", collects);
		model.addAttribute("goods", goods);
		model.addAttribute("orders", orders);
		model.addAttribute("reviews", reviews);
		model.addAttribute("replies", replies);
		model.addAttribute("sellGoods", sellGoods);
		return "user/userProfile";
	}
 
	@RequestMapping(value = "/review", method = RequestMethod.GET)
	public String getReviewInfo(@RequestParam(required = false) Integer goodId,
			@RequestParam(required = false) Integer reviewId) {
		System.out.println("reviewId" + reviewId);
		if (reviewId != null) {
			System.out.println("reviewId" + reviewId);
			if (reviewService.updateReviewStatus(1, reviewId) == 1) {
				return "redirect:/goods/goodInfo?goodId=" + goodId;
			}
		}
		return "redirect:/user/userProfile";
	}
 
	@RequestMapping(value = "/reply", method = RequestMethod.GET)
	public String getReplyInfo(
			@RequestParam(required = false) Integer reviewId,
			@RequestParam(required = false) Integer replyId) {
		if (replyId != null) {
			if (reviewService.updateReplyStatus(1, replyId) == 1) {
				Integer goodId = reviewService.getGoodIdByReviewId(reviewId);
				return "redirect:/goods/goodInfo?goodId=" + goodId;
			}
		}
		return "redirect:/user/userProfile";
	}
 
	@RequestMapping(value = "/userEdit", method = RequestMethod.GET)
	public String getUserEdit(ModelMap model,
			@RequestParam(value = "userId", required = false) Integer userId,
			HttpSession session) {
		User sessionUser = (User) session.getAttribute("user");
		if (sessionUser == null) {
			return "redirect:/";
		}
		User user = userService.getUserById(userId);
		List<Order> sellGoods = orderService.getOrderBySellerId(user.getId());
		List<Review> reviews = reviewService.gerReviewByToUserId(user.getId());
		List<Reply> replies = reviewService.gerReplyByToUserId(user.getId());
		model.addAttribute("user", user);
		model.addAttribute("sellGoods", sellGoods);
		model.addAttribute("reviews", reviews);
		model.addAttribute("replies", replies);
		return "user/userEdit";
	}
 
	@RequestMapping(value = "/userEdit", method = RequestMethod.POST)
	public String postUserEdit(ModelMap model, @Valid User user,
			HttpSession session,
			@RequestParam(value = "photo", required = false) MultipartFile photo)
			throws IOException {
		String status;
		Boolean insertSuccess;
		User sessionUser = (User) session.getAttribute("user");
		user.setId(sessionUser.getId());
		InfoCheck infoCheck = new InfoCheck();
		if (!infoCheck.isMobile(user.getMobile())) {
			status = "請(qǐng)輸入正確的手機(jī)號(hào)!";
		} else if (!infoCheck.isEmail(user.getEmail())) {
			status = "請(qǐng)輸入正確的郵箱!";
		} else if (userService.getUserByMobile(user.getMobile()).getId() != user
				.getId()) {
			System.out.println(userService.getUserByMobile(user.getMobile())
					.getId() + " " + user.getId());
			status = "此手機(jī)號(hào)碼已使用!";
		} else if (userService.getUserByEmail(user.getEmail()).getId() != user
				.getId()) {
			status = "此郵箱已使用!";
		} else {
			if (!photo.isEmpty()) {
				RandomString randomString = new RandomString();
				FileCheck fileCheck = new FileCheck();
				String filePath = "/statics/image/photos/" + user.getId();
				String pathRoot = fileCheck.checkGoodFolderExist(filePath);
				String fileName = user.getId()
						+ randomString.getRandomString(10);
				String contentType = photo.getContentType();
				String imageName = contentType.substring(contentType
						.indexOf("/") + 1);
				String name = fileName + "." + imageName;
				photo.transferTo(new File(pathRoot + name));
				String photoUrl = filePath + "/" + name;
				user.setPhotoUrl(photoUrl);
			} else {
				String photoUrl = userService.getUserById(user.getId())
						.getPhotoUrl();
				user.setPhotoUrl(photoUrl);
			}
			insertSuccess = userService.updateUser(user);
			if (insertSuccess) {
				session.removeAttribute("user");
				session.setAttribute("user", user);
				return "redirect:/user/userProfile";
			} else {
				status = "修改失敗!";
				model.addAttribute("user", user);
				model.addAttribute("status", status);
				return "user/userEdit";
			}
		}
		System.out.println(user.getMobile());
		System.out.println(status);
		model.addAttribute("user", user);
		model.addAttribute("status", status);
		return "user/userEdit";
	}
 
	@RequestMapping(value = "/password/edit", method = RequestMethod.POST)
	public ResponseEntity editPassword(@RequestBody Password password) {
		User user = userService.getUserById(password.getUserId());
		String oldPass = DigestUtils
				.md5DigestAsHex((password.getOldPassword() + user.getCode())
						.getBytes());
		if (oldPass.equals(user.getPassword())) {
			RandomString randomString = new RandomString();
			String code = (randomString.getRandomString(5));
			String md5Pass = DigestUtils.md5DigestAsHex((password
					.getNewPassword() + code).getBytes());
			Boolean success = userService.updatePassword(md5Pass, code,
					password.getUserId());
			if (success) {
				return ResponseEntity.ok(true);
			} else {
				return ResponseEntity.ok("密碼修改失敗!");
			}
		} else {
			return ResponseEntity.ok("原密碼輸入不正確!");
		}
	}
 
}

訂單控制器:

@Controller
public class OrderController {
	private final GoodService goodService;
	private final OrderService orderService;
 
	@Autowired
	public OrderController(GoodService goodService, OrderService orderService) {
		this.goodService = goodService;
		this.orderService = orderService;
	}
 
	@RequestMapping(value = "/user/orderInfo", method = RequestMethod.GET)
	public String getOrderInfo(ModelMap model,
			@RequestParam(value = "orderId", required = false) Integer orderId,
			HttpSession session) {
		User sessionUser = (User) session.getAttribute("user");
		if (sessionUser == null) {
			return "redirect:/";
		}
		Order orderInfo = orderService.getOrderById(orderId);
		List<Order> orders = orderService.getOtherOrderByCustomerId(
				sessionUser.getId(), orderId);
		model.addAttribute("orderInfo", orderInfo);
		model.addAttribute("orders", orders);
		return "user/orderInfo";
	}
 
	@RequestMapping(value = "/user/sellerInfo", method = RequestMethod.GET)
	public String getSellerInfo(ModelMap model,
			@RequestParam(value = "orderId", required = false) Integer orderId,
			HttpSession session) {
		User sessionUser = (User) session.getAttribute("user");
		if (sessionUser == null) {
			return "redirect:/";
		}
		Order orderInfo = orderService.getOrderById(orderId);
		List<Order> orders = orderService.getOtherOrderBySellerId(
				sessionUser.getId(), orderId);
		model.addAttribute("orderInfo", orderInfo);
		model.addAttribute("orders", orders);
		System.out.println("sellerInfo.size:" + orders.size());
		return "user/sellerInfo";
	}
 
	@RequestMapping(value = "/user/order/delete/{orderId}", method = RequestMethod.GET)
	public ResponseEntity deleteOrderById(@PathVariable Integer orderId) {
		Boolean success;
		success = orderService.deleteOrderById(orderId) > 0;
		return ResponseEntity.ok(success);
	}
 
	@RequestMapping(value = "/user/sellerOrder/delete/{orderId}&{goodId}", method = RequestMethod.GET)
	public ResponseEntity deleteSellerOrderById(@PathVariable Integer orderId,
			@PathVariable Integer goodId) {
		Boolean success;
		success = goodService.updateGoodStatusId(1, goodId) > 0;
		if (success) {
			success = orderService.deleteOrderById(orderId) > 0;
		}
		return ResponseEntity.ok(success);
	}
 
	@RequestMapping(value = "/user/order/update/status/{orderId}&{statusId}", method = RequestMethod.GET)
	public ResponseEntity updateOrderStatus(@PathVariable Integer orderId,
			@PathVariable Integer statusId) {
		Boolean success = orderService.updateStatus(statusId, orderId) > 0;
		if (success) {
			Order order = orderService.getOrderById(orderId);
			return ResponseEntity.ok(order);
		}
		return ResponseEntity.ok(success);
	}
 
	@RequestMapping(value = "/user/order/create", method = RequestMethod.POST)
	public ResponseEntity createOrder(@RequestBody Order order) {
		Boolean success = orderService.insertOrder(order) > 0;
		if (success) {
			success = goodService.updateGoodStatusId(0, order.getGoodId()) > 0;
			if (success) {
				return ResponseEntity.ok(order.getId());
			} else {
				orderService.deleteOrderById(order.getId());
				return ResponseEntity.ok(success);
			}
		}
		return ResponseEntity.ok(success);
	}
 
	@RequestMapping(value = "/user/order/allOrder", method = RequestMethod.GET)
	public ResponseEntity getAllOrders() {
		List<Order> orderList = orderService.getOrderList();
		return ResponseEntity.ok(orderList);
	}
}

后臺(tái)用戶(hù)管理控制器:

@Controller
@RequestMapping(value = "admin")
public class AdminController {
 
    private final UserService userService;
    private final GoodService goodService;
    private final TypeService typeService;
    private final OrderService orderService;
 
    @Autowired
    public AdminController(UserService userService, GoodService goodService, TypeService typeService, OrderService orderService) {
        this.userService = userService;
        this.goodService = goodService;
        this.typeService = typeService;
        this.orderService = orderService;
    }
 
    @RequestMapping(value = "/adminLogin", method = RequestMethod.GET)
    public String getAdminLogin(){
        return "admin/adminLogin";
    }
 
    @RequestMapping(value = "/adminLogin", method = RequestMethod.POST)
    public String postAdminLogin(ModelMap model,
                                 @RequestParam(value = "email", required = false) String email,
                                 @RequestParam(value = "password", required = false) String password,
                                 HttpSession session) {
        User admin = userService.getUserByEmail(email);
        String message;
        if (admin != null){
            String mdsPass = DigestUtils.md5DigestAsHex((password + admin.getCode()).getBytes());
//            if (!mdsPass .equals(admin.getPassword())){
//                message = "用戶(hù)密碼錯(cuò)誤!";
//            }
            if (!password .equals(admin.getPassword())){
                message = "用戶(hù)密碼錯(cuò)誤!";
            } else if (admin.getRoleId() != 101){
                message = "用戶(hù)沒(méi)有權(quán)限訪問(wèn)!";
            } else {
                session.setAttribute("admin",admin);
                return "redirect:/admin/adminPage";
            }
        } else {
            message = "用戶(hù)不存在!";
        }
        model.addAttribute("message", message);
        return "admin/adminLogin";
    }
 
    @RequestMapping(value = "/adminLogout", method = RequestMethod.GET)
    public String adminLogout(@RequestParam(required = false, defaultValue = "false" )String adminLogout, HttpSession session){
        if (adminLogout.equals("true")){
            session.removeAttribute("admin");
        }
//        adminLogout = "false";
        return "redirect:/";
    }
 
    @RequestMapping(value = "/adminPage", method = RequestMethod.GET)
    public String getAdminPage(ModelMap model,
                               HttpSession session){
        User admin = (User) session.getAttribute("admin");
        if (admin == null){
            return "redirect:/admin/adminLogin";
        }
        List<Good> goodList = goodService.getAllGoodList();
        for (Good good : goodList) {
            good.setGoodUser(userService.getUserById(good.getUserId()));
            good.setGoodSecondType(typeService.getSecondTypeById(good.getSecondTypeId()));
        }
        List<User> userList = userService.getAllUser();
        List<FirstType> firstTypeList = typeService.getAllFirstType();
        List<Order> orderList = orderService.getOrderList();
        model.addAttribute("goodList", goodList);
        model.addAttribute("userList", userList);
        model.addAttribute("firstTypeList", firstTypeList);
        model.addAttribute("orderList", orderList);
        return "admin/adminPage";
    }
    @RequestMapping(value = "/user/update/status/{statusId}&{userId}", method = RequestMethod.GET)
    public ResponseEntity updateUserStatus(@PathVariable Integer statusId,
                                            @PathVariable Integer userId){
        Boolean success = userService.updateUserStatus(statusId, userId);
        if (success){
            List<User> userList = userService.getAllUser();
            return ResponseEntity.ok(userList);
        }
        return ResponseEntity.ok(success);
    }
 
    @RequestMapping(value = "/user/delete/{userId}", method = RequestMethod.GET)
    public ResponseEntity deleteUser(@PathVariable Integer userId){
        Boolean success = userService.deleteUser(userId);
        if (success){
            List<User> userList = userService.getAllUser();
            return ResponseEntity.ok(userList);
        }
        return ResponseEntity.ok(success);
    }
 
}

到此這篇關(guān)于Java?實(shí)戰(zhàn)范例之校園二手市場(chǎng)系統(tǒng)的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Java?二手市場(chǎng)系統(tǒng)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • java獲取反射機(jī)制的3種方法總結(jié)

    java獲取反射機(jī)制的3種方法總結(jié)

    這篇文章主要給大家介紹了關(guān)于java獲取反射機(jī)制的3種方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用java具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-06-06
  • IDEA2020.1創(chuàng)建springboot項(xiàng)目(國(guó)內(nèi)腳手架)安裝lombok

    IDEA2020.1創(chuàng)建springboot項(xiàng)目(國(guó)內(nèi)腳手架)安裝lombok

    這篇文章主要介紹了IDEA2020.1創(chuàng)建springboot項(xiàng)目(國(guó)內(nèi)腳手架)安裝lombok,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-06-06
  • springboot整合httpClient代碼實(shí)例

    springboot整合httpClient代碼實(shí)例

    這篇文章主要介紹了springboot整合httpClient代碼實(shí)例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-12-12
  • IDEA SpringBoot:Cannot resolve configuration property配置文件問(wèn)題

    IDEA SpringBoot:Cannot resolve configuration&

    這篇文章主要介紹了IDEA SpringBoot:Cannot resolve configuration property配置文件問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-07-07
  • 如何在Spring Boot中建立連接及測(cè)試

    如何在Spring Boot中建立連接及測(cè)試

    對(duì)于剛接觸MQTT的開(kāi)發(fā)者來(lái)說(shuō),了解如何在Spring Boot項(xiàng)目中集成MQTT客戶(hù)端并建立連接是邁向?qū)嶋H應(yīng)用的重要一步,今天,我將分享一個(gè)詳細(xì)的入門(mén)指南,帶你一步步在Spring Boot中建立MQTT連接,并通過(guò)JUnit進(jìn)行簡(jiǎn)單的單元測(cè)試,感興趣的朋友一起看看吧
    2024-12-12
  • java讀取文件內(nèi)容,解析Json格式數(shù)據(jù)方式

    java讀取文件內(nèi)容,解析Json格式數(shù)據(jù)方式

    這篇文章主要介紹了java讀取文件內(nèi)容,解析Json格式數(shù)據(jù)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-09-09
  • JavaWeb之Filter與Listener使用解析

    JavaWeb之Filter與Listener使用解析

    這篇文章主要介紹了JavaWeb之Filter與Listener使用解析,Filter表示過(guò)濾器,是JavaWeb三大組件(Servlet、Filter、Listener)之一,過(guò)濾器可以把對(duì)資源的請(qǐng)求攔截下來(lái),從而實(shí)現(xiàn)一些特殊的功能,需要的朋友可以參考下
    2024-01-01
  • JAVA實(shí)現(xiàn)掃描線算法(超詳細(xì))

    JAVA實(shí)現(xiàn)掃描線算法(超詳細(xì))

    掃描線算法就是從Ymin開(kāi)始掃描,然后構(gòu)建出NET,之后根據(jù)NET建立AET。接下來(lái)本文通過(guò)代碼給大家介紹JAVA實(shí)現(xiàn)掃描線算法,感興趣的朋友一起看看吧
    2019-10-10
  • Mybatis攔截器實(shí)現(xiàn)分頁(yè)

    Mybatis攔截器實(shí)現(xiàn)分頁(yè)

    本文介紹使用Mybatis攔截器,實(shí)現(xiàn)分頁(yè);并且在dao層,直接返回自定義的分頁(yè)對(duì)象。具有很好的參考價(jià)值,下面跟著小編一起來(lái)看下吧
    2017-01-01
  • Java進(jìn)程cpu占用過(guò)高問(wèn)題解決

    Java進(jìn)程cpu占用過(guò)高問(wèn)題解決

    這篇文章主要介紹了Java進(jìn)程cpu占用過(guò)高問(wèn)題解決,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-04-04

最新評(píng)論

台州市| 河北省| 龙里县| 屯门区| 前郭尔| 绍兴县| 梓潼县| 县级市| 长武县| 绥滨县| 友谊县| 柞水县| 天等县| 利辛县| 拜城县| 新竹县| 深水埗区| 寻甸| 顺昌县| 浙江省| 得荣县| 寿阳县| 浪卡子县| 大埔区| 平顶山市| 靖江市| 阿拉尔市| 泸水县| 华容县| 九寨沟县| 崇礼县| 尉犁县| 石狮市| 延川县| 临海市| 云和县| 宜春市| 武胜县| 聂拉木县| 玉龙| 崇文区|