博主介绍:专注于Java(springboot ssm 等开发框架) vue .net php phython node.js uniapp 微信小程序 等诸多技术领域和毕业项目实战、企业信息化系统建设,从业十五余年开发设计教学工作
☆☆☆ 精彩专栏推荐订阅☆☆☆☆☆不然下次找不到哟
我的博客空间发布了2000+毕设题目 方便大家学习使用
感兴趣的可以先收藏起来,还有大家在毕设选题,项目以及论文编写等相关问题都可以给我留言咨询,希望帮助更多的人
更多项目地址 介绍
文末下方有源码获取地址
ssm535基于SSM的游戏资源管理系统+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 | forum_name | String | 帖子标题 | 是 |
3 | yonghu_id | Integer | 用户 | 是 |
4 | users_id | Integer | 管理员 | 是 |
5 | forum_content | String | 发布内容 | 是 |
6 | super_ids | Integer | 父id | 是 |
7 | forum_types | Integer | 帖子类型 | 是 |
8 | forum_state_types | Integer | 帖子状态 | 是 |
9 | insert_time | Date | 发帖时间 | 是 |
10 | update_time | Date | 修改时间 | 是 |
11 | create_time | Date | 创建时间 | 是 |
表4.3攻略表
序号 | 列名 | 数据类型 | 说明 | 允许空 |
1 | Id | Int | id | 否 |
2 | yonghu_id | Integer | 用户 | 是 |
3 | gonglve_name | String | 攻略名称 | 是 |
4 | gonglve_photo | String | 攻略图片 | 是 |
5 | youxi_types | Integer | 游戏 | 是 |
6 | gonglve_types | Integer | 攻略类型 | 是 |
7 | gonglve_content | String | 攻略详情 | 是 |
8 | insert_time | Date | 攻略发布时间 | 是 |
9 | shangxia_types | Integer | 是否上架 | 是 |
10 | create_time | Date | 创建时间 | 是 |
表4.4留言版表
序号 | 列名 | 数据类型 | 说明 | 允许空 |
1 | Id | Int | id | 否 |
2 | yonghu_id | Integer | 用户 | 是 |
3 | liuyan_name | String | 留言标题 | 是 |
4 | liuyan_text | String | 留言内容 | 是 |
5 | reply_text | String | 回复内容 | 是 |
6 | insert_time | Date | 留言时间 | 是 |
7 | update_time | Date | 回复时间 | 是 |
8 | create_time | Date | 创建时间 | 是 |
表4.5物品表
序号 | 列名 | 数据类型 | 说明 | 允许空 |
1 | Id | Int | id | 否 |
2 | yonghu_id | Integer | 用户 | 是 |
3 | wupin_name | String | 物品名称 | 是 |
4 | wupin_photo | String | 物品照片 | 是 |
5 | youxi_types | Integer | 所属游戏 | 是 |
6 | wupin_types | Integer | 物品类型 | 是 |
7 | shuliang_number | Integer | 数量 | 是 |
8 | wupin_content | String | 物品详情 | 是 |
9 | huoqu_text | String | 获取方式 | 是 |
10 | peiyang_text | String | 培养方式 | 是 |
11 | shiyong_text | String | 使用方式 | 是 |
12 | insert_time | Date | 物品添加时间 | 是 |
13 | update_time | Date | 最后更新时间 | 是 |
14 | 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 | create_time | Date | 创建时间 | 是 |
表4.7资讯信息表
序号 | 列名 | 数据类型 | 说明 | 允许空 |
1 | Id | Int | id | 否 |
2 | zixun_name | String | 资讯名称 | 是 |
3 | zixun_photo | String | 资讯图片 | 是 |
4 | youxi_types | Integer | 游戏 | 是 |
5 | zixun_types | Integer | 资讯类型 | 是 |
6 | zixun_content | String | 资讯详情 | 是 |
7 | insert_time | Date | 资讯发布时间 | 是 |
8 | create_time | Date | 创建时间 | 是 |
表4.8管理员表
序号 | 列名 | 数据类型 | 说明 | 允许空 |
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("/wupin")
public class WupinController {
private static final Logger logger = LoggerFactory.getLogger(WupinController.class);
@Autowired
private WupinService wupinService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;
//级联表service
@Autowired
private YonghuService yonghuService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永不会进入");
else if("用户".equals(role))
params.put("yonghuId",request.getSession().getAttribute("userId"));
if(params.get("orderBy")==null || params.get("orderBy")==""){
params.put("orderBy","id");
}
PageUtils page = wupinService.queryPage(params);
//字典表数据转换
List<WupinView> list =(List<WupinView>)page.getList();
for(WupinView 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);
WupinEntity wupin = wupinService.selectById(id);
if(wupin !=null){
//entity转view
WupinView view = new WupinView();
BeanUtils.copyProperties( wupin , view );//把实体数据重构到view中
//级联表
YonghuEntity yonghu = yonghuService.selectById(wupin.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setYonghuId(yonghu.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody WupinEntity wupin, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,wupin:{}",this.getClass().getName(),wupin.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
else if("用户".equals(role))
wupin.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
Wrapper<WupinEntity> queryWrapper = new EntityWrapper<WupinEntity>()
.eq("yonghu_id", wupin.getYonghuId())
.eq("wupin_name", wupin.getWupinName())
.eq("youxi_types", wupin.getYouxiTypes())
.eq("wupin_types", wupin.getWupinTypes())
.eq("shuliang_number", wupin.getShuliangNumber())
.eq("huoqu_text", wupin.getHuoquText())
.eq("peiyang_text", wupin.getPeiyangText())
.eq("shiyong_text", wupin.getShiyongText())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
WupinEntity wupinEntity = wupinService.selectOne(queryWrapper);
if(wupinEntity==null){
wupin.setInsertTime(new Date());
wupin.setCreateTime(new Date());
wupinService.insert(wupin);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody WupinEntity wupin, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,wupin:{}",this.getClass().getName(),wupin.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
// else if("用户".equals(role))
// wupin.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
//根据字段查询是否有相同数据
Wrapper<WupinEntity> queryWrapper = new EntityWrapper<WupinEntity>()
.notIn("id",wupin.getId())
.andNew()
.eq("yonghu_id", wupin.getYonghuId())
.eq("wupin_name", wupin.getWupinName())
.eq("youxi_types", wupin.getYouxiTypes())
.eq("wupin_types", wupin.getWupinTypes())
.eq("shuliang_number", wupin.getShuliangNumber())
.eq("huoqu_text", wupin.getHuoquText())
.eq("peiyang_text", wupin.getPeiyangText())
.eq("shiyong_text", wupin.getShiyongText())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
WupinEntity wupinEntity = wupinService.selectOne(queryWrapper);
if("".equals(wupin.getWupinPhoto()) || "null".equals(wupin.getWupinPhoto())){
wupin.setWupinPhoto(null);
}
wupin.setUpdateTime(new Date());
if(wupinEntity==null){
wupinService.updateById(wupin);//根据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());
wupinService.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<WupinEntity> wupinList = 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){
//循环
WupinEntity wupinEntity = new WupinEntity();
// wupinEntity.setYonghuId(Integer.valueOf(data.get(0))); //用户 要改的
// wupinEntity.setWupinName(data.get(0)); //物品名称 要改的
// wupinEntity.setWupinPhoto("");//照片
// wupinEntity.setYouxiTypes(Integer.valueOf(data.get(0))); //所属游戏 要改的
// wupinEntity.setWupinTypes(Integer.valueOf(data.get(0))); //物品类型 要改的
// wupinEntity.setShuliangNumber(Integer.valueOf(data.get(0))); //数量 要改的
// wupinEntity.setWupinContent("");//照片
// wupinEntity.setHuoquText(data.get(0)); //获取方式 要改的
// wupinEntity.setPeiyangText(data.get(0)); //培养方式 要改的
// wupinEntity.setShiyongText(data.get(0)); //使用方式 要改的
// wupinEntity.setInsertTime(date);//时间
// wupinEntity.setUpdateTime(new Date(data.get(0))); //最后更新时间 要改的
// wupinEntity.setCreateTime(date);//时间
wupinList.add(wupinEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
wupinService.insertBatch(wupinList);
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 = wupinService.queryPage(params);
//字典表数据转换
List<WupinView> list =(List<WupinView>)page.getList();
for(WupinView 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);
WupinEntity wupin = wupinService.selectById(id);
if(wupin !=null){
//entity转view
WupinView view = new WupinView();
BeanUtils.copyProperties( wupin , view );//把实体数据重构到view中
//级联表
YonghuEntity yonghu = yonghuService.selectById(wupin.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setYonghuId(yonghu.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody WupinEntity wupin, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,wupin:{}",this.getClass().getName(),wupin.toString());
Wrapper<WupinEntity> queryWrapper = new EntityWrapper<WupinEntity>()
.eq("yonghu_id", wupin.getYonghuId())
.eq("wupin_name", wupin.getWupinName())
.eq("youxi_types", wupin.getYouxiTypes())
.eq("wupin_types", wupin.getWupinTypes())
.eq("shuliang_number", wupin.getShuliangNumber())
.eq("huoqu_text", wupin.getHuoquText())
.eq("peiyang_text", wupin.getPeiyangText())
.eq("shiyong_text", wupin.getShiyongText())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
WupinEntity wupinEntity = wupinService.selectOne(queryWrapper);
if(wupinEntity==null){
wupin.setInsertTime(new Date());
wupin.setCreateTime(new Date());
wupinService.insert(wupin);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
}
5.1.2 资讯信息管理
资讯信息管理页面提供的功能操作有:新增资讯信息,修改资讯信息,删除资讯信息操作。下图就是资讯信息管理页面。
图5.3 资讯信息管理页面
5.1.3资讯信息类型管理
资讯信息类型管理页面显示所有资讯信息类型,在此页面既可以让管理员添加新的资讯信息类型,也能对已有的资讯信息类型信息执行编辑更新,失效的资讯信息类型信息也能让管理员快速删除。下图就是资讯信息类型管理页面。
图5.4 资讯信息类型列表页面
大家点赞、收藏、关注、评论啦 其他的定制服务 商务合作 下方联系卡片↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 或者私信作者