目录
全栈码农以及毕业设计实战开发,CSDN平台Java领域新星创作者
一、前言
随着互联网社交媒体的蓬勃发展,微博已成为人们分享生活、交流思想的重要平台。然而,市面上的微博产品虽多,但真正能够贴合用户需求、提供卓越体验的产品却并不多见。因此,开发一个功能丰富、界面友好、交互流畅的微博网站显得尤为重要。本系统基于SSM(Spring+Spring MVC+MyBatis)框架,致力于打造一个集信息发布、浏览、评论、点赞、关注等多功能于一体的微博平台。通过引入先进的开发技术和设计理念,我们期望能够为用户提供一个更加个性化、社交化的微博使用体验。该平台将注重用户体验和信息安全,致力于打造一个健康、积极、向上的社交环境。本文将详细介绍系统的设计思路、实现过程及关键技术,以期为相关开发者提供参考和借鉴。
二、技术介绍
语言:Java
使用框架:Spring Boot
前端技术:JS、Vue 、css3
开发工具:IDEA/Eclipse
数据库:MySQL 5.7/8.0
数据库管理工具:phpstudy/Navicat
JDK版本:jdk1.8
Maven: apache-maven 3.8.1-bin
前端环境:Node.Js 12\14\16
三、系统实现
新闻信息管理
管理新闻是管理员的功能。其运行效果图如下。发布新闻,更新新闻信息,删除新闻都是在本页面完成。
微博信息管理
管理微博信息是管理员的功能。其运行效果图如下。管理员不能发布微博信息,但是可以在本页面修改,查询,批量删除用户发布的微博信息。
留言板管理
管理留言是管理员的功能。其运行效果图如下。用户与管理员之间进行信息交流是通过留言的形式进行,管理员查看用户留言,在当前页面可以回复用户的留言。
用户功能实现
新闻信息
查看新闻信息是用户的功能。其运行效果图如下。用户可以在当前页面搜索新闻,查看新闻的标题和图片,点击任意一个新闻标题就可以查看其对应的内容。
微博信息
查看微博信息是用户的功能。其运行效果图如下。用户查看微博的内容信息,查看微博的发布者信息,可以评论微博。
留言反馈
用户在当前模块发布留言反馈信息,其运行效果图如下。用户发布的留言反馈信息会得到管理员的查看和回复。
四、论文参考
五、核心代码
package com.controller;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;
/**
* 登录相关
*/
@RequestMapping("users")
@RestController
public class UserController{
@Autowired
private UserService userService;
@Autowired
private TokenService tokenService;
/**
* 登录
*/
@IgnoreAuth
@PostMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
if(user==null || !user.getPassword().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
return R.ok().put("token", token);
}
/**
* 注册
*/
@IgnoreAuth
@PostMapping(value = "/register")
public R register(@RequestBody UserEntity user){
// ValidatorUtils.validateEntity(user);
if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
return R.error("用户已存在");
}
userService.insert(user);
return R.ok();
}
/**
* 退出
*/
@GetMapping(value = "logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
* 密码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
if(user==null) {
return R.error("账号不存在");
}
user.setPassword("123456");
userService.update(user,null);
return R.ok("密码已重置为:123456");
}
/**
* 列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,UserEntity user){
EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/list")
public R list( UserEntity user){
EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
ew.allEq(MPUtil.allEQMapPre( user, "user"));
return R.ok().put("data", userService.selectListView(ew));
}
/**
* 信息
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id){
UserEntity user = userService.selectById(id);
return R.ok().put("data", user);
}
/**
* 获取用户的session用户信息
*/
@RequestMapping("/session")
public R getCurrUser(HttpServletRequest request){
Long id = (Long)request.getSession().getAttribute("userId");
UserEntity user = userService.selectById(id);
return R.ok().put("data", user);
}
/**
* 保存
*/
@PostMapping("/save")
public R save(@RequestBody UserEntity user){
// ValidatorUtils.validateEntity(user);
if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
return R.error("用户已存在");
}
userService.insert(user);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody UserEntity user){
// ValidatorUtils.validateEntity(user);
userService.updateById(user);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
userService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
}
六、源码获取
感谢大家点赞、收藏、关注、评论啦