基于ssm+vue微博系统源码和论文137
开发工具:idea 或eclipse
数据库mysql5.7+
数据库链接工具:navcat,小海豚等
技术:ssm
摘 要
网络技术和计算机技术发展至今,已经拥有了深厚的理论基础,并在现实中进行了充分运用,尤其是基于计算机运行的软件更是受到各界的关注。加上现在人们已经步入信息时代,所以对于信息的宣传和管理就很关键。因此分享与交流信息的管理计算机化,系统化是必要的。设计开发微博系统网站不仅会节约人力和管理成本,还会安全保存庞大的数据量,对于分享与交流信息的维护和检索也不需要花费很多时间,非常的便利。
微博系统网站是在MySQL中建立数据表保存信息,运用SSM框架和Java语言编写。并按照软件设计开发流程进行设计实现。系统具备友好性且功能完善。管理员管理微博类型和微博信息,发布微博资讯,管理论坛帖子信息,管理用户。用户收藏微博,评论微博,查看微博资讯,在论坛交流模块发布帖子,评论帖子。
微博系统网站在让分享与交流信息规范化的同时,也能及时通过数据输入的有效性规则检测出错误数据,让数据的录入达到准确性的目的,进而提升微博系统网站提供的数据的可靠性,让系统数据的错误率降至最低。
关键词:微博系统网站;MySQL;SSM框架
Abstract
Network technology and computer technology have developed so far, they already have a solid theoretical foundation and have been fully used in reality, especially the software based on computer operation has attracted the attention of all walks of life. In addition, now that people have entered the information age, the promotion and management of information is very important. Therefore, the computerization and systematization of the management of sharing and exchanging information is necessary. Designing and developing a Weibo system website will not only save manpower and management costs, but also store a huge amount of data safely. It does not take a lot of time to maintain and retrieve shared and exchanged information, which is very convenient.
The Weibo system website is to build a data table in MySQL to save information, and it is written using the SSM framework and Java language. And in accordance with the software design and development process for design and implementation. The system is friendly and fully functional. The administrator manages Weibo types and Weibo information, publishes Weibo information, manages forum post information, and manages users. Users bookmark Weibo, comment on Weibo, view Weibo information, post posts in the forum communication module, and comment on posts.
The Weibo system website not only standardizes the sharing and exchange of information, it can also detect incorrect data in time through the validity rules of data input, so that the data entry can achieve the purpose of accuracy, thereby improving the reliability of the data provided by the Weibo system website. Performance, so that the error rate of system data is reduced to a minimum.
Key Words:Weibo system website; MySQL; SSM framework
package com.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
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.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
import com.entity.WeiboxinxiEntity;
import com.entity.view.WeiboxinxiView;
import com.service.WeiboxinxiService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
/**
* 微博信息
* 后端接口
* @author
* @email
* @date 2021-03-24 20:24:34
*/
@RestController
@RequestMapping("/weiboxinxi")
public class WeiboxinxiController {
@Autowired
private WeiboxinxiService weiboxinxiService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,WeiboxinxiEntity weiboxinxi,
HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("yonghu")) {
weiboxinxi.setYonghuming((String)request.getSession().getAttribute("username"));
}
EntityWrapper<WeiboxinxiEntity> ew = new EntityWrapper<WeiboxinxiEntity>();
PageUtils page = weiboxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, weiboxinxi), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,WeiboxinxiEntity weiboxinxi, HttpServletRequest request){
EntityWrapper<WeiboxinxiEntity> ew = new EntityWrapper<WeiboxinxiEntity>();
PageUtils page = weiboxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, weiboxinxi), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( WeiboxinxiEntity weiboxinxi){
EntityWrapper<WeiboxinxiEntity> ew = new EntityWrapper<WeiboxinxiEntity>();
ew.allEq(MPUtil.allEQMapPre( weiboxinxi, "weiboxinxi"));
return R.ok().put("data", weiboxinxiService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(WeiboxinxiEntity weiboxinxi){
EntityWrapper< WeiboxinxiEntity> ew = new EntityWrapper< WeiboxinxiEntity>();
ew.allEq(MPUtil.allEQMapPre( weiboxinxi, "weiboxinxi"));
WeiboxinxiView weiboxinxiView = weiboxinxiService.selectView(ew);
return R.ok("查询微博信息成功").put("data", weiboxinxiView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
WeiboxinxiEntity weiboxinxi = weiboxinxiService.selectById(id);
weiboxinxi.setClicknum(weiboxinxi.getClicknum()+1);
weiboxinxi.setClicktime(new Date());
weiboxinxiService.updateById(weiboxinxi);
return R.ok().put("data", weiboxinxi);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
WeiboxinxiEntity weiboxinxi = weiboxinxiService.selectById(id);
weiboxinxi.setClicknum(weiboxinxi.getClicknum()+1);
weiboxinxi.setClicktime(new Date());
weiboxinxiService.updateById(weiboxinxi);
return R.ok().put("data", weiboxinxi);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody WeiboxinxiEntity weiboxinxi, HttpServletRequest request){
weiboxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(weiboxinxi);
weiboxinxiService.insert(weiboxinxi);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody WeiboxinxiEntity weiboxinxi, HttpServletRequest request){
weiboxinxi.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(weiboxinxi);
weiboxinxiService.insert(weiboxinxi);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody WeiboxinxiEntity weiboxinxi, HttpServletRequest request){
//ValidatorUtils.validateEntity(weiboxinxi);
weiboxinxiService.updateById(weiboxinxi);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
weiboxinxiService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 提醒接口
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<WeiboxinxiEntity> wrapper = new EntityWrapper<WeiboxinxiEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("yonghu")) {
wrapper.eq("yonghuming", (String)request.getSession().getAttribute("username"));
}
int count = weiboxinxiService.selectCount(wrapper);
return R.ok().put("count", count);
}
/**
* 前端智能排序
*/
@IgnoreAuth
@RequestMapping("/autoSort")
public R autoSort(@RequestParam Map<String, Object> params,WeiboxinxiEntity weiboxinxi, HttpServletRequest request,String pre){
EntityWrapper<WeiboxinxiEntity> ew = new EntityWrapper<WeiboxinxiEntity>();
Map<String, Object> newMap = new HashMap<String, Object>();
Map<String, Object> param = new HashMap<String, Object>();
Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Object> entry = it.next();
String key = entry.getKey();
String newKey = entry.getKey();
if (pre.endsWith(".")) {
newMap.put(pre + newKey, entry.getValue());
} else if (StringUtils.isEmpty(pre)) {
newMap.put(newKey, entry.getValue());
} else {
newMap.put(pre + "." + newKey, entry.getValue());
}
}
params.put("sort", "clicknum");
params.put("order", "desc");
PageUtils page = weiboxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, weiboxinxi), params), params));
return R.ok().put("data", page);
}
}
package com.controller;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.StringUtil;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.YonghuEntity;
import com.service.YonghuService;
import com.entity.view.YonghuView;
import com.utils.PageUtils;
import com.utils.R;
/**
* 员工表
* 后端接口
* @author
* @email
* @date 2021-03-24
*/
@RestController
@Controller
@RequestMapping("/yonghu")
public class YonghuController {
private static final Logger logger = LoggerFactory.getLogger(YonghuController.class);
@Autowired
private YonghuService yonghuService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;
//级联表service
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
PageUtils page = yonghuService.queryPage(params);
//字典表数据转换
List<YonghuView> list =(List<YonghuView>)page.getList();
for(YonghuView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c);
}
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
YonghuEntity yonghu = yonghuService.selectById(id);
if(yonghu !=null){
//entity转view
YonghuView view = new YonghuView();
BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
.eq("username", yonghu.getUsername())
.or()
.eq("phone", yonghu.getPhone())
.or()
.eq("id_number", yonghu.getIdNumber());
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
if(yonghuEntity==null){
yonghu.setPassword("123456");
// String role = String.valueOf(request.getSession().getAttribute("role"));
// if("".equals(role)){
// yonghu.set
// }
yonghuService.insert(yonghu);
return R.ok();
}else {
return R.error(511,"账户或者身份证号或者手机号已经被使用");
}
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
//根据字段查询是否有相同数据
Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
.notIn("id",yonghu.getId())
.andNew()
.eq("username", yonghu.getUsername())
.or()
.eq("phone", yonghu.getPhone())
.or()
.eq("id_number", yonghu.getIdNumber());
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
if("".equals(yonghu.getImgPhoto()) || "null".equals(yonghu.getImgPhoto())){
yonghu.setImgPhoto(null);
}
if(yonghuEntity==null){
// String role = String.valueOf(request.getSession().getAttribute("role"));
// if("".equals(role)){
// yonghu.set
// }
yonghuService.updateById(yonghu);//根据id更新
return R.ok();
}else {
return R.error(511,"账户或者身份证号或者手机号已经被使用");
}
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
yonghuService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 登录
*/
@IgnoreAuth
@PostMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));
if(yonghu==null || !yonghu.getPassword().equals(password)) {
return R.error("账号或密码不正确");
}
String token = tokenService.generateToken(yonghu.getId(),username, "yonghu", "员工");
R r = R.ok();
r.put("token", token);
r.put("role","员工");
r.put("username",yonghu.getName());
r.put("tableName","yonghu");
r.put("userId",yonghu.getId());
return r;
}
/**
* 注册
*/
@IgnoreAuth
@PostMapping(value = "/register")
public R register(@RequestBody YonghuEntity yonghu){
// ValidatorUtils.validateEntity(user);
if(yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", yonghu.getUsername()).orNew().eq("phone",yonghu.getPhone()).orNew().eq("id_number",yonghu.getIdNumber())) !=null) {
return R.error("员工已存在或手机号身份证号已经被使用");
}
yonghuService.insert(yonghu);
return R.ok();
}
/**
* 重置密码
*/
@GetMapping(value = "/resetPassword")
public R resetPassword(Integer yonghuId){
YonghuEntity yonghu = new YonghuEntity();
yonghu.setPassword("123456");
yonghu.setId(yonghuId);
yonghuService.updateById(yonghu);
return R.ok();
}
/**
* 获取员工的session员工信息
*/
@RequestMapping("/session")
public R getCurrYonghu(HttpServletRequest request){
Integer id = (Integer)request.getSession().getAttribute("userId");
YonghuEntity yonghu = yonghuService.selectById(id);
return R.ok().put("data", yonghu);
}
/**
* 退出
*/
@GetMapping(value = "logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
}