Java實(shí)戰(zhàn)項(xiàng)目之校園跑腿管理系統(tǒng)的實(shí)現(xiàn)
前端使用的是vue+elementui,這款系統(tǒng)只適合學(xué)習(xí)鞏固SpringBoot+VUE,后面還要在這上面加校園公告、校園零食等功能,后期代碼我也會(huì)持續(xù)更新上去。系統(tǒng)分為管理員和學(xué)生、學(xué)生是管理員后臺(tái)添加的兩種角色。
運(yùn)行環(huán)境:
后端 jdk1.8、maven3.5/3.6 mysql5.7 idea/eclipse
前端 idea vue-cli node.js 搭建vue環(huán)境 webpack3.6.0指定版本





管理員控制層:
@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);
}
}用戶(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("原密碼輸入不正確!");
}
}
}類(lèi)型控制層:
@Controller
@RequestMapping("type")
public class TypeController {
private final TypeService typeService;
private final GoodService goodService;
@Autowired
public TypeController(TypeService typeService, GoodService goodService) {
this.typeService = typeService;
this.goodService = goodService;
}
@RequestMapping(value = "/secondType/{firstTypeId}", method = RequestMethod.GET)
public ResponseEntity getSecondTypeId(@PathVariable Integer firstTypeId) {
List<SecondType> secondTypes = typeService
.getSecondTypeByFirstTypeId(firstTypeId);
if (secondTypes == null) {
return ResponseEntity.ok("isNull");
}
return ResponseEntity.ok(secondTypes);
}
@RequestMapping(value = "/secondType/delete/{secondTypeId}", method = RequestMethod.GET)
public ResponseEntity deleteSecondType(@PathVariable Integer secondTypeId) {
Boolean success = goodService.getGoodsAdminByType(secondTypeId)
.isEmpty();
System.out.println(goodService.getGoodsAdminByType(secondTypeId));
if (success) {
Integer thisFirstTypeId = typeService.getSecondTypeById(
secondTypeId).getFirstTypeId();
success = typeService.deleteSecondType(secondTypeId);
if (success) {
List<SecondType> secondTypeList = typeService
.getSecondTypeByFirstTypeId(thisFirstTypeId);
if (secondTypeList == null) {
return ResponseEntity.ok("isNull");
}
return ResponseEntity.ok(secondTypeList);
}
}
return ResponseEntity.ok(success);
}
@RequestMapping(value = "/firstType/delete/{firstTypeId}", method = RequestMethod.GET)
public ResponseEntity deleteFirstType(@PathVariable Integer firstTypeId) {
Boolean success = typeService.getSecondTypeByFirstTypeId(firstTypeId)
.isEmpty();
if (success) {
success = typeService.deleteFirstType(firstTypeId);
if (success) {
List<FirstType> firstTypeList = typeService.getAllFirstType();
if (firstTypeList == null) {
return ResponseEntity.ok("isNull");
}
return ResponseEntity.ok(firstTypeList);
}
}
return ResponseEntity.ok(success);
}
@RequestMapping(value = "/secondType/create", method = RequestMethod.POST)
public ResponseEntity createSecondType(@RequestBody SecondType secondType) {
Integer thisFirstTypeId = secondType.getFirstTypeId();
Boolean success = typeService.createSecondType(secondType);
if (success) {
List<SecondType> secondTypeList = typeService
.getSecondTypeByFirstTypeId(thisFirstTypeId);
return ResponseEntity.ok(secondTypeList);
}
return ResponseEntity.ok(success);
}
@RequestMapping(value = "/firstType/create", method = RequestMethod.POST)
public ResponseEntity createSecondType(@RequestBody FirstType firstType) {
Boolean success = typeService.createFirstType(firstType);
if (success) {
List<FirstType> firstTypeList = typeService.getAllFirstType();
return ResponseEntity.ok(firstTypeList);
}
return ResponseEntity.ok(success);
}
}到此這篇關(guān)于Java實(shí)戰(zhàn)項(xiàng)目之校園跑腿管理系統(tǒng)的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Java 校園跑腿管理系統(tǒng)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Java畢業(yè)設(shè)計(jì)實(shí)戰(zhàn)之校園一卡通系統(tǒng)的實(shí)現(xiàn)
- Java?實(shí)戰(zhàn)范例之校園二手市場(chǎng)系統(tǒng)的實(shí)現(xiàn)
- Java 實(shí)戰(zhàn)練手項(xiàng)目之校園超市管理系統(tǒng)的實(shí)現(xiàn)流程
- Java 實(shí)戰(zhàn)項(xiàng)目錘煉之校園宿舍管理系統(tǒng)的實(shí)現(xiàn)流程
- Java實(shí)現(xiàn)的具有GUI的校園導(dǎo)航系統(tǒng)的完整代碼
- JavaWeb開(kāi)發(fā)基于ssm的校園服務(wù)系統(tǒng)(實(shí)例詳解)
- Java模擬HTTP Get Post請(qǐng)求 輕松實(shí)現(xiàn)校園BBS自動(dòng)回帖
- Java基于Dijkstra算法實(shí)現(xiàn)校園導(dǎo)游程序
相關(guān)文章
SpringMVC事件監(jiān)聽(tīng)ApplicationListener實(shí)例解析
這篇文章主要介紹了SpringMVC事件監(jiān)聽(tīng)ApplicationListener實(shí)例解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-11-11
IDEA2022中部署Tomcat Web項(xiàng)目的流程分析
這篇文章主要介紹了IDEA2022中部署Tomcat Web項(xiàng)目,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-03-03
logback的FileAppender文件追加模式和沖突檢測(cè)解讀
這篇文章主要為大家介紹了logback的FileAppender文件追加模式和沖突檢測(cè)解讀,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-10-10
SpringCloud使用Feign實(shí)現(xiàn)動(dòng)態(tài)路由操作
這篇文章主要介紹了SpringCloud使用Feign實(shí)現(xiàn)動(dòng)態(tài)路由操作,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-06-06
SpringBoot使用JavaCV處理rtsp流的示例代碼
這篇文章主要為大家詳細(xì)介紹了SpringBoot使用JavaCV處理rtsp流,文中的示例代碼講解詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴可以跟隨小編一起了解一下2024-02-02
解決idea爆紅 cant resolve symbol String的問(wèn)題解析
連著出差幾個(gè)禮拜沒(méi)有使用idea開(kāi)發(fā)工具,突然一天打開(kāi)電腦發(fā)現(xiàn)idea里的代碼全部爆紅,懵逼不如所措,很多朋友建議我按住Alt+回車(chē)設(shè)置jdk就能解決,但是仍然報(bào)錯(cuò),經(jīng)過(guò)幾個(gè)小時(shí)的倒騰最終解決,遇到此問(wèn)題的朋友參考下本文吧2021-06-06

