当前位置:首页 » 《随便一记》 » 正文

基于SpringBoot开发的美食系统分享【十分肝货】【建议收藏】_开发小小强的博客

3 人参与  2022年02月19日 09:10  分类 : 《随便一记》  评论

点击全文阅读


最近开发了一个系统是用SpringBoot进行开发的,非常的不错。今天一生哥和大家分享一下。

希望一起交流学习哈!

一,简介

一个系统的开发需要经过以下步骤:

需求调研、需求分析、需求制定、系统开发、系统测试,最终才会走向市场!

今天开发了一个小系统,看完需求,我直接就进行了系统的开发。

当然系统前端的技术采用最主流的技术Vue。

二, 系统的界面介绍

 

 系统的后台介绍:

 

 

 

 

三,系统核心代码介绍:


    @PutMapping("/updatePassword")
    public Result updatePassword(@RequestBody Account info, HttpServletRequest request) {
        Account account = (Account) request.getSession().getAttribute("user");
        if (account == null) {
            return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
        }

    //技术交流:javapandeng

        String oldPassword = SecureUtil.md5(info.getPassword());
        if (!oldPassword.equals(account.getPassword())) {
            return Result.error(ResultCode.PARAM_PASSWORD_ERROR.code, ResultCode.PARAM_PASSWORD_ERROR.msg);
        }
        info.setPassword(SecureUtil.md5(info.getNewPassword()));
        Integer level = account.getLevel();
		if (1 == level) {
			AdminInfo adminInfo = new AdminInfo();
			BeanUtils.copyProperties(info, adminInfo);
			adminInfoService.update(adminInfo);
		}
		if (2 == level) {
			UserInfo userInfo = new UserInfo();
			BeanUtils.copyProperties(info, userInfo);
			userInfoService.update(userInfo);
		}

        info.setLevel(level);
        info.setName(account.getName());
        // 清空session,让用户重新登录
        request.getSession().setAttribute("user", null);
        return Result.success();
    }

    @PostMapping("/resetPassword")
    public Result resetPassword(@RequestBody Account account) {
        Integer level = account.getLevel();
		if (1 == level) {
			AdminInfo info = adminInfoService.findByUserName(account.getName());
			if (info == null) {
				return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
			}
			info.setPassword(SecureUtil.md5("123456"));
			adminInfoService.update(info);
		}
		if (2 == level) {
			UserInfo info = userInfoService.findByUserName(account.getName());
			if (info == null) {
				return Result.error(ResultCode.USER_NOT_EXIST_ERROR.code, ResultCode.USER_NOT_EXIST_ERROR.msg);
			}
			info.setPassword(SecureUtil.md5("123456"));
			userInfoService.update(info);
		}

        return Result.success();
    }

    private String getProperties(String key) {
        Props props = new Props("classpath:config.properties", "UTF-8");
        return props.getStr(key);
    }
}
 @PutMapping
    public Result update(@RequestBody FileInfo info, HttpServletRequest request) {
        Account account = (Account) request.getSession().getAttribute("user");
        if (!account.getLevel().equals(info.getLevel()) || !account.getId().equals(info.getUploadUserId())) {
            return Result.error("1001", "不能修改他人的记录");
        }
        fileInfoService.update(info);
        return Result.success();
    }

//技术交流:javapandeng
    @GetMapping("/{id}")
    public Result<FileInfoVo> detail(@PathVariable Long id) {
        FileInfoVo info = fileInfoService.findById(id);
        return Result.success(info);
    }

    @GetMapping
    public Result<List<FileInfoVo>> all() {
        return Result.success(fileInfoService.findAll());
    }

    @GetMapping("/page/{name}")
    public Result<PageInfo<FileInfoVo>> page(@PathVariable String name,
                                             @RequestParam(defaultValue = "1") Integer pageNum,
                                             @RequestParam(defaultValue = "5") Integer pageSize,
                                             HttpServletRequest request) {
        return Result.success(fileInfoService.findPage(name, pageNum, pageSize));
    }

}
 /**
    * 批量通过excel添加信息
    * @param file excel文件
    * @throws IOException
    */
    @PostMapping("/upload")
    public Result upload(MultipartFile file) throws IOException {

        List<LinkInfo> infoList = ExcelUtil.getReader(file.getInputStream()).readAll(LinkInfo.class);
        if (!CollectionUtil.isEmpty(infoList)) {
            // 处理一下空数据
            List<LinkInfo> resultList = infoList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getName())).collect(Collectors.toList());
            for (LinkInfo info : resultList) {
                linkInfoService.add(info);
            }
        }
        return Result.success();
    }

    @GetMapping("/getExcelModel")
    public void getExcelModel(HttpServletResponse response) throws IOException {
        // 1. 生成excel
        Map<String, Object> row = new LinkedHashMap<>();
		row.put("name", "百度");
		row.put("url", "www.baidu.com");

        List<Map<String, Object>> list = CollUtil.newArrayList(row);

        // 2. 写excel
        ExcelWriter writer = ExcelUtil.getWriter(true);
        writer.write(list, true);

        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
        response.setHeader("Content-Disposition","attachment;filename=linkInfoModel.xlsx");

        ServletOutputStream out = response.getOutputStream();
        writer.flush(out, true);
        writer.close();
        IoUtil.close(System.out);
    }

四,系统数据库介绍:

系统的数据库采用的是Mysql,数据加密方式采用的是MD5,保证了系统的安全!

- ----------------------------
-- Table structure for admin_info
-- ----------------------------
DROP TABLE IF EXISTS `admin_info`;
CREATE TABLE `admin_info` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '姓名',
  `password` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '密码',
  `nickName` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '昵称',
  `sex` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '性别',
  `age` int(10) DEFAULT NULL COMMENT '年龄',
  `birthday` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '生日',
  `phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手机号',
  `address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址',
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '编号',
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '邮箱',
  `cardId` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '身份证',
  `level` int(10) NOT NULL DEFAULT '1' COMMENT '权限等级',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `uk_name` (`name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='管理员信息表';

-- ----------------------------
-- Records of admin_info
-- ----------------------------
INSERT INTO `admin_info` VALUES ('1', 'admin', 'e10adc3949ba59abbe56e057f20f883e', '管理员', '男', '28', '2020-11-06 18:44:21', '18843232356', '上海市', '111', 'aa@163.com', '342425199001116372', '1');
INSERT INTO `admin_info` VALUES ('2', 'admin2', 'e10adc3949ba59abbe56e057f20f883e', '管理员', '男', '23', '2020-11-06 18:44:21', '18843232356', '北京市', '222', 'bb@163.com', '342425199001116376', '1');
INSERT INTO `admin_info` VALUES ('3', 'admin3', 'e10adc3949ba59abbe56e057f20f883e', '管理员', '女', '32', '2020-11-06 18:44:21', '18843232356', '合肥市', '333', 'cc@163.com', '342425199001116323', '1');
INSERT INTO `admin_info` VALUES ('4', 'admin4', 'e10adc3949ba59abbe56e057f20f883e', '管理员', '女', '24', '2020-11-06 18:44:21', '18843232356', '北京市', '444', 'hahaha@126.com', '342425199001116837', '1');
INSERT INTO `admin_info` VALUES ('5', 'admin5', 'e10adc3949ba59abbe56e057f20f883e', '管理员', '男', '25', '2020-11-06 18:44:21', '18843232356', '合肥市', '555', 'hello@126.com', '342425199001116309', '1');
INSERT INTO `admin_info` VALUES ('6', 'admin6', 'e10adc3949ba59abbe56e057f20f883e', '管理员', '男', '26', '2020-11-06 18:44:21', '18843232356', '北京市', '666', '1212@qq.com', '342425199001116984', '1');
INSERT INTO `admin_info` VALUES ('7', 'admin7', 'e10adc3949ba59abbe56e057f20f883e', '管理员', '男', '21', '2020-11-06 18:44:21', '18843232356', '合肥市', '777', '8765@qq.com', '342425199001116303', '1');
INSERT INTO `admin_info` VALUES ('8', 'admin8', 'e10adc3949ba59abbe56e057f20f883e', '管理员', '男', '31', '2020-11-06 18:44:21', '18843232356', '北京市', '888', '9080@qq.com', '342425199001116910', '1');
INSERT INTO `admin_info` VALUES ('9', 'admin9', 'e10adc3949ba59abbe56e057f20f883e', '管理员', '男', '34', '2020-11-06 18:44:21', '18843232356', '合肥市', '999', 'shjs@126.com', '342425199001116345', '1');
INSERT INTO `admin_info` VALUES ('10', 'admin10', 'e10adc3949ba59abbe56e057f20f883e', '管理员', '女', '33', '2020-11-06 18:44:21', '18843232356', '深圳市', '000', '666@qq.com', '342425199001116234', '1');

-- ----------------------------
-- Table structure for advertiser_info
-- ----------------------------
DROP TABLE IF EXISTS `advertiser_info`;
CREATE TABLE `advertiser_info` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '公告名称',
  `content` longtext COLLATE utf8mb4_unicode_ci COMMENT '公告内容',
  `time` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '公告时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='公告信息表';

-- ----------------------------
-- Records of advertiser_info
-- ----------------------------
INSERT INTO `advertiser_info` VALUES ('1', '系统公告', '这是系统公告,管理员可以在后台修改', '2020-11-06 18:44:21');
INSERT INTO `advertiser_info` VALUES ('2', '系统公告', '这是系统公告,管理员可以在后台修改', '2020-11-06 18:44:21');
INSERT INTO `advertiser_info` VALUES ('3', '系统公告', '这是系统公告,管理员可以在后台修改', '2020-11-06 18:44:21');
INSERT INTO `advertiser_info` VALUES ('4', '系统公告', '这是系统公告,管理员可以在后台修改', '2020-11-06 18:44:21');
INSERT INTO `advertiser_info` VALUES ('5', '系统公告', '这是系统公告,管理员可以在后台修改', '2020-11-06 18:44:21');
INSERT INTO `advertiser_info` VALUES ('6', '系统公告', '这是系统公告,管理员可以在后台修改', '2020-11-06 18:44:21');
INSERT INTO `advertiser_info` VALUES ('7', '系统公告', '这是系统公告,管理员可以在后台修改', '2020-11-06 18:44:21');
INSERT INTO `advertiser_info` VALUES ('8', '系统公告', '这是系统公告,管理员可以在后台修改', '2020-11-06 18:44:21');
INSERT INTO `advertiser_info` VALUES ('9', '系统公告', '这是系统公告,管理员可以在后台修改', '2020-11-06 18:44:21');
INSERT INTO `advertiser_info` VALUES ('10', '系统公告', '这是系统公告,管理员可以在后台修改', '2020-11-06 18:44:21');

-- ----------------------------
-- Table structure for file_info
-- ----------------------------
DROP TABLE IF EXISTS `file_info`;
CREATE TABLE `file_info` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '名称',
  `fileId` bigint(20) DEFAULT NULL COMMENT '文件id',
  `fileName` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '文件名',
  `userName` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '上传人',
  `level` int(10) DEFAULT NULL COMMENT '用户等级',
  `uploadUserId` bigint(20) DEFAULT NULL COMMENT '用户id',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='文件信息表';

-- ----------------------------
-- Records of file_info
-- ----------------------------
INSERT INTO `file_info` VALUES ('1', '红烧排骨', '12', '排骨.jpeg', 'admin', '1', '1');
INSERT INTO `file_info` VALUES ('2', '美味大虾', '13', '大虾.jpeg', 'admin', '1', '1');
INSERT INTO `file_info` VALUES ('3', '滋补老鸭汤', '14', '老鸭汤.jpg', 'admin', '1', '1');
INSERT INTO `file_info` VALUES ('4', '金针菇汤', '15', '金针菇肉汤.jpeg', 'admin', '1', '1');

-- ----------------------------
-- Table structure for link_info
-- ----------------------------
DROP TABLE IF EXISTS `link_info`;
CREATE TABLE `link_info` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '留言名称',
  `url` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '链接地址',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='友情链接信息表';

-- ----------------------------
-- Records of link_info
-- ----------------------------
INSERT INTO `link_info` VALUES ('1', '百度', 'www.baidu.com');
INSERT INTO `link_info` VALUES ('2', '谷歌', 'www.google.com');
INSERT INTO `link_info` VALUES ('3', '百度', 'www.baidu.com');
INSERT INTO `link_info` VALUES ('4', '谷歌', 'www.google.com');
INSERT INTO `link_info` VALUES ('5', '百度', 'www.baidu.com');
INSERT INTO `link_info` VALUES ('6', '谷歌', 'www.google.com');
INSERT INTO `link_info` VALUES ('7', '百度', 'www.baidu.com');
INSERT INTO `link_info` VALUES ('8', '谷歌', 'www.google.com');
INSERT INTO `link_info` VALUES ('9', '百度', 'www.baidu.com');
INSERT INTO `link_info` VALUES ('10', '谷歌', 'www.google.com');

-- ----------------------------
-- Table structure for message_info
-- ----------------------------
DROP TABLE IF EXISTS `message_info`;
CREATE TABLE `message_info` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '留言名称',
  `content` text COLLATE utf8mb4_unicode_ci COMMENT '留言内容',
  `time` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '留言时间',
  `parentId` bigint(20) DEFAULT '0' COMMENT '父id',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='留言信息表';

-- ----------------------------
-- Records of message_info
-- ----------------------------
INSERT INTO `message_info` VALUES ('1', 'admin', '哈哈,好开心', '2020-11-06 20:56:48', '0');
INSERT INTO `message_info` VALUES ('2', 'admin', '呼呼', '2020-11-06 20:57:29', '1');
INSERT INTO `message_info` VALUES ('3', 'admin', '好', '2020-11-06 20:58:58', '0');
INSERT INTO `message_info` VALUES ('4', 'admin', '非常好', '2020-11-06 20:59:06', '3');

-- ----------------------------
-- Table structure for nx_system_file_info
-- ----------------------------
DROP TABLE IF EXISTS `nx_system_file_info`;
CREATE TABLE `nx_system_file_info` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `originName` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '原始文件名',
  `fileName` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '存储文件名',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='文件信息表';

-- ----------------------------
-- Records of nx_system_file_info
-- ----------------------------
INSERT INTO `nx_system_file_info` VALUES ('12', '排骨.jpeg', '排骨1604667302844.jpeg');
INSERT INTO `nx_system_file_info` VALUES ('13', '大虾.jpeg', '大虾1604667318371.jpeg');
INSERT INTO `nx_system_file_info` VALUES ('14', '老鸭汤.jpg', '老鸭汤1604667330730.jpg');
INSERT INTO `nx_system_file_info` VALUES ('15', '金针菇肉汤.jpeg', '金针菇肉汤1604667349671.jpeg');

-- ----------------------------
-- Table structure for richtext_info
-- ----------------------------
DROP TABLE IF EXISTS `richtext_info`;
CREATE TABLE `richtext_info` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '名称',
  `content` longtext COLLATE utf8mb4_unicode_ci COMMENT '公告内容',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='美食日记信息表';

我是java相伴一生,java老兵,致力于研究java研究多年。

欢迎点赞,收藏!

希望能和你成为好朋友,加油奥利给!

 


点击全文阅读


本文链接:http://zhangshiyu.com/post/34970.html

系统  公告  这是  
<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1