博主介绍:专注于Java(springboot ssm 等开发框架) vue .net php phython node.js uniapp 微信小程序 等诸多技术领域和毕业项目实战、企业信息化系统建设,从业十五余年开发设计教学工作
☆☆☆ 精彩专栏推荐订阅☆☆☆☆☆不然下次找不到哟
我的博客空间发布了2000+毕设题目 方便大家学习使用
感兴趣的可以先收藏起来,还有大家在毕设选题,项目以及论文编写等相关问题都可以给我留言咨询,希望帮助更多的人
文末下方有源码获取地址
ssm590基于HTML5的交流论坛的设计与实现+vue录像
4.3功能结构设计
在管理员功能模块确定下来的基础上,对管理员各个功能进行设计,确定管理员功能的详细模块。绘制的管理员功能结构见下图。
图4.3 管理员功能结构图
4.4 数据库设计
开发一个系统也需要提前设计数据库。这里的数据库是相关数据的集合,存储在一起的这些数据也是按照一定的组织方式进行的。目前,数据库能够服务于多种应用程序,则是源于它存储方式最佳,具备数据冗余率低的优势。虽然数据库为程序提供信息存储服务,但它与程序之间也可以保持较高的独立性。总而言之,数据库经历了很长一段时间的发展,从最初的不为人知,到现在的人尽皆知,其相关技术也越发成熟,同时也拥有着坚实的理论基础。
4.4.1 数据库概念设计
这部分内容需要借助数据库关系图来完成,也需要使用专门绘制数据库关系图的工具,比如Visio工具就可以设计E-R图(数据库关系图)。设计数据库,也需要按照设计的流程进行,首先还是要根据需求完成实体的确定,分析实体具有的特征,还有对实体间的关联关系进行确定。最后才是使用E-R模型的表示方法,绘制本系统的E-R图。不管是使用亿图软件,还是Visio工具,对于E-R模型的表示符号都一样,通常矩形代表实体,实体间存在的关系用菱形符号表示,实体的属性也就是实体的特征用符号椭圆表示。最后使用直线将矩形,菱形和椭圆等符号连接起来。接下来就开始对本系统的E-R图进行绘制。
4.4.2 数据库表结构
在进行这部分设计之前,需要明白和掌握数据类型以及各个数据类型的长度范围等知识,因为在一张具体的数据表中,为了方便理解,这里就举个简单的例子。比如用户信息表,这个表格的字段就是用户这个实体具备的属性,这时就需要对字段进行数据类型,以及字段长度的设置,也要设置一个主键来作为用户信息表的唯一标识。这些都是数据库表结构设计需要完成的内容。根据交流论坛的功能设计以及数据库设计要求,展示该系统的数据表结构。
表4.1字典表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
dic_code |
String |
字段 |
是 |
3 |
dic_name |
String |
字段名 |
是 |
4 |
code_index |
Integer |
编码 |
是 |
5 |
index_name |
String |
编码名字 |
是 |
6 |
super_id |
Integer |
父字段id |
是 |
7 |
beizhu |
String |
备注 |
是 |
8 |
create_time |
Date |
创建时间 |
是 |
表4.2健身房表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
jianshenfang_name |
String |
健身房名称 |
是 |
3 |
jianshenfang_photo |
String |
健身房照片 |
是 |
4 |
jianshenfang_address |
String |
健身房位置 |
是 |
5 |
jianshenfang_content |
String |
健身房详细介绍 |
是 |
6 |
insert_time |
Date |
添加时间 |
是 |
7 |
create_time |
Date |
创建时间 |
是 |
表4.3教练表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
jiaolian_name |
String |
教练姓名 |
是 |
3 |
jiaolian_phone |
String |
教练手机号 |
是 |
4 |
jiaolian_photo |
String |
教练头像 |
是 |
5 |
sex_types |
Integer |
性别 |
是 |
6 |
rongyu_content |
String |
所获荣誉 |
是 |
7 |
jiaolian_content |
String |
教练详细介绍 |
是 |
8 |
create_time |
Date |
创建时间 |
是 |
表4.4课程表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
jiaolian_id |
Integer |
教练 |
是 |
3 |
jianshenfang_id |
Integer |
健身房 |
是 |
4 |
kecheng_name |
String |
课程名称 |
是 |
5 |
kecheng_types |
Integer |
课程类型 |
是 |
6 |
kecheng_kaike |
String |
上课时间 |
是 |
7 |
kecheng_content |
String |
课程介绍 |
是 |
8 |
insert_time |
Date |
添加时间 |
是 |
9 |
create_time |
Date |
创建时间 |
是 |
表4.5器材表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
qicai_name |
String |
器材名称 |
是 |
3 |
qicai_types |
Integer |
器材类型 |
是 |
4 |
qicai_photo |
String |
器材照片 |
是 |
5 |
qicai_number |
Integer |
器材数量 |
是 |
6 |
qicai_content |
String |
器材介绍 |
是 |
7 |
insert_time |
Date |
添加时间 |
是 |
8 |
create_time |
Date |
创建时间 |
是 |
表4.6用户表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
yonghu_name |
String |
用户姓名 |
是 |
3 |
yonghu_phone |
String |
用户手机号 |
是 |
4 |
yonghu_id_number |
String |
用户身份证号 |
是 |
5 |
yonghu_photo |
String |
用户头像 |
是 |
6 |
yonghu_email |
String |
电子邮箱 |
是 |
7 |
daoqi_time |
Date |
会员到期日期 |
是 |
8 |
insert_time |
Date |
注册时间 |
是 |
9 |
create_time |
Date |
创建时间 |
是 |
表4.7管理员表
序号 |
列名 |
数据类型 |
说明 |
允许空 |
1 |
Id |
Int |
id |
否 |
2 |
username |
String |
用户名 |
是 |
3 |
password |
String |
密码 |
是 |
4 |
role |
String |
角色 |
是 |
5 |
addtime |
Date |
新增时间 |
是 |
系统实现这个章节的内容主要还是展示系统的功能界面设计效果,在实现系统基本功能,比如修改,比如添加,比如删除等管理功能的同时,也显示出系统各个功能的界面实现效果,该部分内容一方面与前面提到的系统分析,系统设计的内容相呼应,另一方面也是一个实际成果的展示。
5.1管理员功能实现
5.1.1 论坛管理
此页面让管理员管理论坛的数据,论坛管理页面见下图。此页面主要实现论坛的增加、修改、删除、查看的功能。
图5-1 论坛管理页面
package com.controller;
import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
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.*;
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.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;
/**
* 论坛
* 后端接口
* @author
* @email
*/
@RestController
@Controller
@RequestMapping("/forum")
public class ForumController {
private static final Logger logger = LoggerFactory.getLogger(ForumController.class);
@Autowired
private ForumService forumService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;
//级联表service
@Autowired
private YonghuService yonghuService;
@Autowired
private UsersService usersService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
if(params.get("orderBy")==null || params.get("orderBy")==""){
params.put("orderBy","id");
}
PageUtils page = forumService.queryPage(params);
//字典表数据转换
List<ForumView> list =(List<ForumView>)page.getList();
for(ForumView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
}
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
ForumEntity forum = forumService.selectById(id);
if(forum !=null){
//entity转view
ForumView view = new ForumView();
BeanUtils.copyProperties( forum , view );//把实体数据重构到view中
//级联表
YonghuEntity yonghu = yonghuService.selectById(forum.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setYonghuId(yonghu.getId());
}
//管理员用户表做特殊处理,防止和用户表账户姓名字段冲突
UsersEntity users = usersService.selectById(forum.getUsersId());
if(users != null){
view.setUsersId(users.getId());
view.setUusername(users.getUsername());
view.setUpassword(users.getPassword());
view.setUrole(users.getRole());
view.setUaddtime(users.getAddtime());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody ForumEntity forum, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,forum:{}",this.getClass().getName(),forum.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
else if("用户".equals(role))
forum.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
else if("管理员".equals(role))
forum.setUsersId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
Wrapper<ForumEntity> queryWrapper = new EntityWrapper<ForumEntity>()
.eq("forum_name", forum.getForumName())
.eq("yonghu_id", forum.getYonghuId())
.eq("users_id", forum.getUsersId())
.eq("super_ids", forum.getSuperIds())
.eq("forum_types", forum.getForumTypes())
.eq("forum_state_types", forum.getForumStateTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
ForumEntity forumEntity = forumService.selectOne(queryWrapper);
if(forumEntity==null){
forum.setInsertTime(new Date());
forum.setCreateTime(new Date());
forumService.insert(forum);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody ForumEntity forum, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,forum:{}",this.getClass().getName(),forum.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
// else if("用户".equals(role))
// forum.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
// else if("管理员".equals(role))
// forum.setUsersId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
//根据字段查询是否有相同数据
Wrapper<ForumEntity> queryWrapper = new EntityWrapper<ForumEntity>()
.notIn("id",forum.getId())
.andNew()
.eq("forum_name", forum.getForumName())
.eq("yonghu_id", forum.getYonghuId())
.eq("users_id", forum.getUsersId())
.eq("super_ids", forum.getSuperIds())
.eq("forum_types", forum.getForumTypes())
.eq("forum_state_types", forum.getForumStateTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
ForumEntity forumEntity = forumService.selectOne(queryWrapper);
forum.setUpdateTime(new Date());
if(forumEntity==null){
forumService.updateById(forum);//根据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());
forumService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 批量上传
*/
@RequestMapping("/batchInsert")
public R save( String fileName){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
try {
List<ForumEntity> forumList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
Date date = new Date();
int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀");
}else{
String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){
return R.error(511,"只支持后缀为xls的excel文件");
}else{
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
File file = new File(resource.getFile());
if(!file.exists()){
return R.error(511,"找不到上传文件,请联系管理员");
}else{
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
dataList.remove(0);//删除第一行,因为第一行是提示
for(List<String> data:dataList){
//循环
ForumEntity forumEntity = new ForumEntity();
// forumEntity.setForumName(data.get(0)); //帖子标题 要改的
// forumEntity.setYonghuId(Integer.valueOf(data.get(0))); //用户 要改的
// forumEntity.setUsersId(Integer.valueOf(data.get(0))); //管理员 要改的
// forumEntity.setForumContent("");//照片
// forumEntity.setSuperIds(Integer.valueOf(data.get(0))); //父id 要改的
// forumEntity.setForumTypes(Integer.valueOf(data.get(0))); //帖子类型 要改的
// forumEntity.setForumStateTypes(Integer.valueOf(data.get(0))); //帖子状态 要改的
// forumEntity.setInsertTime(date);//时间
// forumEntity.setUpdateTime(new Date(data.get(0))); //修改时间 要改的
// forumEntity.setCreateTime(date);//时间
forumList.add(forumEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
forumService.insertBatch(forumList);
return R.ok();
}
}
}
}catch (Exception e){
return R.error(511,"批量插入数据异常,请联系管理员");
}
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
// 没有指定排序字段就默认id倒序
if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
params.put("orderBy","id");
}
PageUtils page = forumService.queryPage(params);
//字典表数据转换
List<ForumView> list =(List<ForumView>)page.getList();
for(ForumView c:list)
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
return R.ok().put("data", page);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
ForumEntity forum = forumService.selectById(id);
if(forum !=null){
//entity转view
ForumView view = new ForumView();
BeanUtils.copyProperties( forum , view );//把实体数据重构到view中
//级联表
YonghuEntity yonghu = yonghuService.selectById(forum.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setYonghuId(yonghu.getId());
}
UsersEntity users = usersService.selectById(forum.getUsersId());
if(users != null){
view.setUsersId(users.getId());
view.setUusername(users.getUsername());
view.setUpassword(users.getPassword());
view.setUrole(users.getRole());
view.setUaddtime(users.getAddtime());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody ForumEntity forum, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,forum:{}",this.getClass().getName(),forum.toString());
Wrapper<ForumEntity> queryWrapper = new EntityWrapper<ForumEntity>()
.eq("forum_name", forum.getForumName())
.eq("yonghu_id", forum.getYonghuId())
.eq("users_id", forum.getUsersId())
.eq("super_ids", forum.getSuperIds())
.eq("forum_types", forum.getForumTypes())
.eq("forum_state_types", forum.getForumStateTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
ForumEntity forumEntity = forumService.selectOne(queryWrapper);
if(forumEntity==null){
forum.setInsertTime(new Date());
forum.setCreateTime(new Date());
forumService.insert(forum);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
}
5.1.2 公告信息管理
公告信息管理页面提供的功能操作有:新增公告,修改公告,删除公告操作。下图就是公告信息管理页面。
图5.3 公告信息管理页面
5.1.3公告类型管理
公告类型管理页面显示所有公告类型,在此页面既可以让管理员添加新的公告信息类型,也能对已有的公告类型信息执行编辑更新,失效的公告类型信息也能让管理员快速删除。下图就是公告类型管理页面。
图5.4 公告类型列表页面
大家点赞、收藏、关注、评论啦 其他的定制服务 商务合作 下方联系卡片↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 或者私信作者