基于javaweb+mysql的springboot嘟嘟二手书商城系统(java+html+springboot+maven+mysql+ajax)

基于javaweb+mysql的springboot嘟嘟二手书商城系统(java+html+springboot+maven+mysql+ajax)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SpringBoot嘟嘟二手书商城系统(java+html+springboot+maven+mysql+ajax)

一、项目简述

功能: 主页显示商品; 所有二手书商品展示,可进行商品搜索; 点击商品进入商品详情页,具有立即购买和加入购物车功能,可增减购买商品数量亦可手动输入,热销商品展示。 立即购买进入确认订单页面,可选择已经添加的地址,亦可新增地址。 可选择购买哪些商品,可删除不需要的商品。 点击结算进入确认订单页面,确认后提交订单。后台管理:(修改密码等),商品管理(商品批量添加、上下架等),订单管理。

二、项目运行

环境配置:

Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

项目技术:

JSP +Springboot+ SpringMVC + MyBatis + ThymeLeaf + FTP+ JavaScript + JQuery + Ajax + maven等等


    /**
     * 我的中心数据统计
     * @return
     */
    @GetMapping("/mycount")
    public ResultResp UserList(@RequestParam String userName){
        return userService.myCount(userName);
    }

    /**
     * 通过用户名搜索
     */
    @GetMapping("/findusernamelist")
    public ResultResp finByUserNameAdminList(@RequestParam String userName,
                                             @RequestParam(required = false, defaultValue = "1") int pageIndex,
                                             @RequestParam(required = false, defaultValue = "8") int pageSize){
        return userService.findByUserNameList(userName, pageIndex, pageSize);
    }

    /**
     * 用户列表
     * @return
     */
    @GetMapping("/adminuserlist")
    public ResultResp adminUserList(@RequestParam(required = false, defaultValue = "1") int pageIndex,
                               @RequestParam(required = false, defaultValue = "8") int pageSize){
        return userService.adminUserList(pageIndex,pageSize);
    }

    /**
     * 通过用户名搜索
     */
    @GetMapping("/findbyadminusernamelist")
    public ResultResp findByAdminUserNameList(@RequestParam String userName,
                                             @RequestParam(required = false, defaultValue = "1") int pageIndex,
                                             @RequestParam(required = false, defaultValue = "8") int pageSize){
        return userService.findByAdminUserNameList(userName, pageIndex, pageSize);
    }

    /**
     * 通过用户编号查看详情
     */
    @GetMapping("/userdetail")
    public ResultResp findByUserId(@RequestParam String userName){
        return userService.findByUserName(userName);
    }

    /**
     * 删除用户
     */
    @DeleteMapping("/deleteuser")
        fileService.singleFile(file,userName);
        return Response.ok();
    }

    //上传图书
    @PostMapping("/morefile")
    public ResultResp moreFile(@RequestParam(value = "file", required = false) MultipartFile[] files,String userName,String bookName,
        String bookSynopsis, Double bookPrice,int bookCategoryId){
        if(files.length == 0){
            return Response.dataErr("未上传图片!");
        }else{
            fileService.moreFile(files, userName,bookName,bookSynopsis,bookPrice,bookCategoryId);
            return Response.ok();
        }
    }
}

@RestController
public class CollectionController {
    @Autowired
    CollectionService collectionService;

    /**
     * 取消收藏
     */
    @DeleteMapping("cancelstart")
    public ResultResp cancelStart(@RequestParam String  userName,
                                  @RequestParam int bookId){
        return collectionService.cancel(userName,bookId);
    }

    /**
     * 收藏图书
    //留言列表
    @GetMapping("/leavewordlist")
    public ResultResp bookCategoryList(@RequestParam(required = false, defaultValue = "1") int pageIndex,
                                       @RequestParam(required = false, defaultValue = "10") int pageSize) {
        return leaveWordService.leaveWordList(pageIndex, pageSize);
    }

    //按内容查找留言列表
    @GetMapping("/findleavewordlist")
    public ResultResp bookCategoryList(@RequestParam String leaveContant,
                                       @RequestParam(required = false, defaultValue = "1") int pageIndex,
                                       @RequestParam(required = false, defaultValue = "10") int pageSize) {
        return leaveWordService.findLeaveWordList(leaveContant,pageIndex, pageSize);
    }

    /**
     * 删除留言
     * @param leaveId
     * @return
     */
    @DeleteMapping("/deleteleaveword")
    public ResultResp deleteByBookCategoryName(@RequestParam int leaveId){
        return leaveWordService.deleteLeaveWord(leaveId);
    }
}

/**
 * @auther xinye
 * @create 2019 04 20
 */
@RestController
public class OrderController {
    @Resource
    OrderService orderService;

    /**
     * 生成订单
     * @param userName

/**
 * 记录接口信息
 */
@Aspect
@Component
public class HttpAspect {

    protected final Logger logger = LoggerFactory.getLogger(getClass());

    @Pointcut("execution(public * com.hq.secondhand_book.controller.*.*(..))")
    public void log() {
    }

    @Before("log()")
    public void doBefore(JoinPoint joinPoint) {
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();
        logger.info("url={}", request.getRequestURL());
        logger.info("method={}", request.getMethod());
        logger.info("class_method={}", joinPoint.getSignature().getDeclaringTypeName() + "."
                + joinPoint.getSignature().getName());

        StringBuilder sb = new StringBuilder();
        Enumeration<String> parameterNames = request.getParameterNames();
        while (parameterNames.hasMoreElements()) {
            String name = parameterNames.nextElement();
            String value = request.getParameter(name);
            sb.append(" ");
            sb.append(name);
            sb.append("=");
            sb.append(value);
        }

        logger.info("param={} ", sb.toString());

        if (request.getMethod().equals("POST") || request.getMethod().equals("PUT")) {
            MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
            Method method = methodSignature.getMethod();
            Parameter[] parameters = method.getParameters();
            for (int j = 0; j < parameters.length; j++) {
                Parameter parameter = parameters[j];
                Annotation[] annotations = parameter.getDeclaredAnnotations();
                for (int k = 0; k < annotations.length; k++) {
                    Annotation annotation = annotations[k];
                    if (annotation instanceof RequestBody) {
                        logger.info("body={}", JSON.toJSON(joinPoint.getArgs()[j]));
    @PostMapping(value = "/singlefile")
    public ResultResp headImg(@RequestParam(value="file",required=false) MultipartFile file, String userName) throws Exception {
        fileService.singleFile(file,userName);
        return Response.ok();
    }

    //上传图书
    @PostMapping("/morefile")
    public ResultResp moreFile(@RequestParam(value = "file", required = false) MultipartFile[] files,String userName,String bookName,
        String bookSynopsis, Double bookPrice,int bookCategoryId){
        if(files.length == 0){
            return Response.dataErr("未上传图片!");
        }else{
            fileService.moreFile(files, userName,bookName,bookSynopsis,bookPrice,bookCategoryId);
            return Response.ok();
        }
    }
}

@RestController
public class CollectionController {
    @Autowired
    CollectionService collectionService;

    /**
     * 取消收藏
     */
    @DeleteMapping("cancelstart")
    public ResultResp cancelStart(@RequestParam String  userName,
                                  @RequestParam int bookId){
        return collectionService.cancel(userName,bookId);
    }

    /**
     * 收藏图书
     */

/**
 * 记录接口信息
 */
@Aspect
@Component
public class HttpAspect {

    protected final Logger logger = LoggerFactory.getLogger(getClass());

    @Pointcut("execution(public * com.hq.secondhand_book.controller.*.*(..))")
    public void log() {
    }

    @Before("log()")
    public void doBefore(JoinPoint joinPoint) {
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();
        logger.info("url={}", request.getRequestURL());
        logger.info("method={}", request.getMethod());
        logger.info("class_method={}", joinPoint.getSignature().getDeclaringTypeName() + "."
                + joinPoint.getSignature().getName());

        StringBuilder sb = new StringBuilder();
        Enumeration<String> parameterNames = request.getParameterNames();
        while (parameterNames.hasMoreElements()) {
            String name = parameterNames.nextElement();
            String value = request.getParameter(name);
            sb.append(" ");
            sb.append(name);
            sb.append("=");
            sb.append(value);
        }

        logger.info("param={} ", sb.toString());

        if (request.getMethod().equals("POST") || request.getMethod().equals("PUT")) {
            MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
            Method method = methodSignature.getMethod();
            Parameter[] parameters = method.getParameters();
            for (int j = 0; j < parameters.length; j++) {
                Parameter parameter = parameters[j];
                Annotation[] annotations = parameter.getDeclaredAnnotations();
                for (int k = 0; k < annotations.length; k++) {
                    Annotation annotation = annotations[k];
                    if (annotation instanceof RequestBody) {
                        logger.info("body={}", JSON.toJSON(joinPoint.getArgs()[j]));
                    }
    /**
     * 更新类别
     * @param catergoryId
     * @param catergoryName
     * @param fatherCategoryName
     * @return
     */
    @PostMapping("/updatecategory")
    public ResultResp updateCategory(@RequestParam int catergoryId,
                                     @RequestParam String catergoryName,
                                     @RequestParam String fatherCategoryName){
        return bookCategoryService.updateCategory(catergoryId, catergoryName, fatherCategoryName);
    }

}

@RestController
public class PlaceTransactionController {
    @Autowired
    PlaceTransactionService placeTransactionService;

    /**
     * 交易地点下拉列表
     * @return
     */
    @GetMapping("/placelist")
    public ResultResp getPlace(){
        return placeTransactionService.getPlace();
    }

    //交易地点列表
    @GetMapping("/placepagelist")
    public ResultResp bookCategoryList(@RequestParam(required = false, defaultValue = "1") int pageIndex,
                                       @RequestParam(required = false, defaultValue = "10") int pageSize) {
        return placeTransactionService.placeList(pageIndex, pageSize);
    }

    //交易地点列表
    @GetMapping("/placepagebyplacenamelist")
    public ResultResp bookCategoryList(@RequestParam String placeName,
        StringBuilder sb = new StringBuilder();
        Enumeration<String> parameterNames = request.getParameterNames();
        while (parameterNames.hasMoreElements()) {
            String name = parameterNames.nextElement();
            String value = request.getParameter(name);
            sb.append(" ");
            sb.append(name);
            sb.append("=");
            sb.append(value);
        }

        logger.info("param={} ", sb.toString());

        if (request.getMethod().equals("POST") || request.getMethod().equals("PUT")) {
            MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
            Method method = methodSignature.getMethod();
            Parameter[] parameters = method.getParameters();
            for (int j = 0; j < parameters.length; j++) {
                Parameter parameter = parameters[j];
                Annotation[] annotations = parameter.getDeclaredAnnotations();
                for (int k = 0; k < annotations.length; k++) {
                    Annotation annotation = annotations[k];
                    if (annotation instanceof RequestBody) {
                        logger.info("body={}", JSON.toJSON(joinPoint.getArgs()[j]));
                    }
                }
            }
        }
    }

    @After("log()")
    public void doAfter() {
    }

    @AfterReturning(returning = "object", pointcut = "log()")
    public void doAfterReturning(Object object) {
        if (object != null) {
            logger.info("response: {}", JSON.toJSON(object));
        } else {
            logger.info("response={}", "object is null");
        }
    }
}


    @Pointcut("execution(public * com.hq.secondhand_book.controller.*.*(..))")
    public void log() {
    }

    @Before("log()")
    public void doBefore(JoinPoint joinPoint) {
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();
        logger.info("url={}", request.getRequestURL());
        logger.info("method={}", request.getMethod());
        logger.info("class_method={}", joinPoint.getSignature().getDeclaringTypeName() + "."
                + joinPoint.getSignature().getName());

        StringBuilder sb = new StringBuilder();
        Enumeration<String> parameterNames = request.getParameterNames();
        while (parameterNames.hasMoreElements()) {
            String name = parameterNames.nextElement();
            String value = request.getParameter(name);
            sb.append(" ");
            sb.append(name);
            sb.append("=");
            sb.append(value);
        }

        logger.info("param={} ", sb.toString());

        if (request.getMethod().equals("POST") || request.getMethod().equals("PUT")) {
            MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
            Method method = methodSignature.getMethod();
            Parameter[] parameters = method.getParameters();
            for (int j = 0; j < parameters.length; j++) {
                Parameter parameter = parameters[j];
                Annotation[] annotations = parameter.getDeclaredAnnotations();
                for (int k = 0; k < annotations.length; k++) {
                    Annotation annotation = annotations[k];
                    if (annotation instanceof RequestBody) {
                        logger.info("body={}", JSON.toJSON(joinPoint.getArgs()[j]));
                    }
                }
            }
        }
    }

     * @param catergoryName
     * @param fatherCategoryName
     * @return
     */
    @PostMapping("/updatecategory")
    public ResultResp updateCategory(@RequestParam int catergoryId,
                                     @RequestParam String catergoryName,
                                     @RequestParam String fatherCategoryName){
        return bookCategoryService.updateCategory(catergoryId, catergoryName, fatherCategoryName);
    }

}

@RestController
public class PlaceTransactionController {
    @Autowired
    PlaceTransactionService placeTransactionService;

    /**
     * 交易地点下拉列表
     * @return
     */
    @GetMapping("/placelist")
    public ResultResp getPlace(){
        return placeTransactionService.getPlace();
    }

    //交易地点列表
    @GetMapping("/placepagelist")
    public ResultResp bookCategoryList(@RequestParam(required = false, defaultValue = "1") int pageIndex,
                                       @RequestParam(required = false, defaultValue = "10") int pageSize) {
        return placeTransactionService.placeList(pageIndex, pageSize);
    }

    //交易地点列表

    /**
     * 收藏图书
     */
    @GetMapping("start")
    public ResultResp start(@RequestParam String  userName,
                                  @RequestParam int bookId){
        return collectionService.start(userName,bookId);
    }
    /**
     * 收藏图书列表
     */
    @GetMapping("startlist")
    public ResultResp startList(@RequestParam String  userName,
                            @RequestParam(required = false, defaultValue = "1") int pageIndex,
                            @RequestParam(required = false, defaultValue = "8") int pageSize){
        return collectionService.startList(userName,pageIndex,pageSize);
    }
}

@RestController
public class ReceiveAdressController {
    @Autowired
    ReceiveAdressService receiveAdressService;

    /**
     * 用户的收货地址列表
     * @param userName
     * @return
     */
    @GetMapping("/getreceiveadress")
    public ResultResp getReceiveAdress(String userName){
        return receiveAdressService.getRececiveAdress(userName);
    }
    @Resource
    LeaveWordService leaveWordService;

    /**
     * 用户跟针对图书发布留言
     * @param leaveWordDto
     * @return
     */
    @PostMapping("/addleaveword")
    public ResultResp addLeaveWord(@RequestBody LeaveWordDto leaveWordDto){
        System.out.println(leaveWordDto);
        if(leaveWordDto.getUserName().isEmpty()){
            Response.dataErr("请登录");
        }if(leaveWordDto.getBookId() == 0){
            Response.dataErr("图书不存在");
        }
        return leaveWordService.addLeaveWord(leaveWordDto);
    }

    //留言列表
    @GetMapping("/leavewordlist")
    public ResultResp bookCategoryList(@RequestParam(required = false, defaultValue = "1") int pageIndex,
                                       @RequestParam(required = false, defaultValue = "10") int pageSize) {
        return leaveWordService.leaveWordList(pageIndex, pageSize);
    }

    //按内容查找留言列表
    @GetMapping("/findleavewordlist")
    public ResultResp bookCategoryList(@RequestParam String leaveContant,
                                       @RequestParam(required = false, defaultValue = "1") int pageIndex,
                                       @RequestParam(required = false, defaultValue = "10") int pageSize) {
        return leaveWordService.findLeaveWordList(leaveContant,pageIndex, pageSize);
    }

    /**
     * 删除留言
     * @param leaveId
     * @return
     */
    @DeleteMapping("/deleteleaveword")
    public ResultResp deleteByBookCategoryName(@RequestParam int leaveId){
        return leaveWordService.deleteLeaveWord(leaveId);
    }
}

@RestController
public class FileController {

    @Autowired
    UserService userService;
    @Autowired
    FileService fileService;

    @PostMapping(value = "/singlefile")
    public ResultResp headImg(@RequestParam(value="file",required=false) MultipartFile file, String userName) throws Exception {
        fileService.singleFile(file,userName);
        return Response.ok();
    }

    //上传图书
    @PostMapping("/morefile")
    public ResultResp moreFile(@RequestParam(value = "file", required = false) MultipartFile[] files,String userName,String bookName,
        String bookSynopsis, Double bookPrice,int bookCategoryId){
        if(files.length == 0){
            return Response.dataErr("未上传图片!");
        }else{
            fileService.moreFile(files, userName,bookName,bookSynopsis,bookPrice,bookCategoryId);
            return Response.ok();
        }
    }
}

@RestController
public class CollectionController {
    @Autowired
    CollectionService collectionService;

    /**
     * 取消收藏

/**
 * @auther xinye
 * @create 2019 04 03
 */
@RestController
public class UserController {
    @Autowired
    UserService userService;

    /**
     * 用户登录
     */
    @PostMapping("/login")
    public ResultResp login(@RequestBody LoginVo loginVo){
        System.out.println(loginVo);
        return userService.login(loginVo);
    }

    /**
     * 根据用户名查找用户
     */
    @PostMapping("/userinfo")
    public ResultResp getUser(String userName){
        UserInfoVo vo = userService.getUser(userName);
        return Response.ok(vo);
    }

    @PostMapping("/updateuser")
    public ResultResp updateUser(UserDto userDto){
        return userService.updateUser(userDto);
    }

    /**
     * 用户列表
     * @return
     */
    @GetMapping("/userlist")
    public ResultResp UserList(@RequestParam(required = false, defaultValue = "1") int pageIndex,
                               @RequestParam(required = false, defaultValue = "8") int pageSize){
        return userService.userList(pageIndex,pageSize);
    }


/**
 * @auther xinye
 * @create 2019 04 09
 */
@RestController
public class FileController {

    @Autowired
    UserService userService;
    @Autowired
    FileService fileService;

    @PostMapping(value = "/singlefile")
    public ResultResp headImg(@RequestParam(value="file",required=false) MultipartFile file, String userName) throws Exception {
        fileService.singleFile(file,userName);
        return Response.ok();
    }

    //上传图书
    @PostMapping("/morefile")
    public ResultResp moreFile(@RequestParam(value = "file", required = false) MultipartFile[] files,String userName,String bookName,
        String bookSynopsis, Double bookPrice,int bookCategoryId){
        if(files.length == 0){
            return Response.dataErr("未上传图片!");
        }else{
            fileService.moreFile(files, userName,bookName,bookSynopsis,bookPrice,bookCategoryId);
            return Response.ok();
        }
    }
}


    /**
     * 通过用户名搜索
     */
    @GetMapping("/findbyadminusernamelist")
    public ResultResp findByAdminUserNameList(@RequestParam String userName,
                                             @RequestParam(required = false, defaultValue = "1") int pageIndex,
                                             @RequestParam(required = false, defaultValue = "8") int pageSize){
        return userService.findByAdminUserNameList(userName, pageIndex, pageSize);
    }

    /**
     * 通过用户编号查看详情
     */
    @GetMapping("/userdetail")
    public ResultResp findByUserId(@RequestParam String userName){
        return userService.findByUserName(userName);
    }

    /**
     * 删除用户
     */
    @DeleteMapping("/deleteuser")
    public ResultResp deleteUser(@RequestParam int userId){
        return userService.deleteUser(userId);
    }

    /**
     * 恢复用户
     */
    @GetMapping("/adduser")
    public ResultResp addUser(@RequestParam int userId){
        return userService.adminAddUser(userId);
    }

    /**
     * 重置密码
     */
    @PostMapping("/resetpwd")
    public ResultResp resetPwd(@RequestParam int userId){
        return userService.resetPwd(userId);
    }

    /**
     * 修改密码
     */
    @GetMapping("/repwd")
    public ResultResp rePwd(@RequestParam String userName,
        return userService.findByUserName(userName);
    }

    /**
     * 删除用户
     */
    @DeleteMapping("/deleteuser")
    public ResultResp deleteUser(@RequestParam int userId){
        return userService.deleteUser(userId);
    }

    /**
     * 恢复用户
     */
    @GetMapping("/adduser")
    public ResultResp addUser(@RequestParam int userId){
        return userService.adminAddUser(userId);
    }

    /**
     * 重置密码
     */
    @PostMapping("/resetpwd")
    public ResultResp resetPwd(@RequestParam int userId){
        return userService.resetPwd(userId);
    }

    /**
     * 修改密码
     */
    @GetMapping("/repwd")
    public ResultResp rePwd(@RequestParam String userName,
                            @RequestParam String userPwd,
                            @RequestParam String newPwd){
        return userService.rePwd(userName,userPwd,newPwd);
    }

    @PostMapping("/findName")
    public ResultResp findNmae(@RequestParam String userName){
        System.out.println(userName);
        return userService.isUsernameExist(userName);
    }

    /**
     * 添加用户
     */
    @GetMapping("/adduserName")

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值