博主主页:一季春秋
博主简介:专注Java技术领域和毕业设计项目实战、Java、微信小程序、安卓等技术开发,远程调试部署、代码讲解、文档指导、ppt制作等技术指导。
主要内容:SpringBoot、Vue、SSM、HLMT、Jsp、PHP、Python、小程序、安卓app、大数据等设计与开发精彩专栏推荐订阅👇🏻👇🏻 不然下次找不到哟
SpringBoot+Vue项目持续更新中
🍅文末获取联系🍅
目录
一、项目介绍
本系统适合选题:学习网站、知识网站、知识、前后端分离等。本系统采用了springboot+vue整合开发,前端框架主要使用了element-ui框架、数据层采用mybatis,功能齐全,界面美观。
二、项目主要技术
开发语言:Java
使用框架:spring boot
前端技术:Vue 、css、element-ui、js
开发工具:IDEA/MyEclipse/Eclipse、Visual Studio Code
数据库:MySQL 5.7/8.0
数据库管理工具:phpstudy/Navicat
JDK版本:jdk1.8
Maven: apache-maven 3.8.1-bin
三、系统功能
3.1 前台功能
诗词详情:用户可以在该功能模块中查看诗词名字、诗词出处、诗词译文、诗词的局解。
诗词大全:用户可以在该功能中筛选不同朝代、不同题材的诗词名句。用户可以选择自己喜欢的诗词点击进行查看详情
诗人大全:用户可以在该功能中通过对朝代的筛选进行选择诗人。并可以点击诗人查看详情。
个性推荐:用户可以在此功能中查看网站个性推荐的诗词然后点击查看详情。
学习资料:用户可以在此功能中查看网站推荐的学习资料进行学习。
课外赏析:用户可以在该功能中学习到书本以外的古诗。
在线学习:用户登录系统进行学习,然后记录一下时间,然后达到制定的时间送积分。
排名:系统可以根据用户在线学习的时间进行排名。
论坛:用户可以在该功能中进行发布帖子,评论帖子,以及可以查看我的发布。
兑换礼品:用户可以在该功能使用手里现有的积分进行礼品兑换。
会员注册:用户可以通过填写相关信息进行注册为网站的会员,会员在本网站上学习可以积累学习积分,然后到达一定数量后可以兑换相关礼品。
3.2 后台功能
诗词详情:后台管理员可以对诗词的内容进行管理。
古诗管理:最高管理员可以登入到后台管理系统后对古诗进行增删改查等操作。
角色管理:管理员可以对用户的角色进行管理。
赏析管理:后台管理员可以对赏析进行管理。
诗人管理:后台管理员可以对诗人等相关信息进行管理。
学习资料管理:后台管理员可以对学习资料等资料进行管理,后台管理员可以通过这个功能进行上传教学视频鉴赏音频等相关资料。
用户管理:管理员可以对整个系统的用户信息进行管理。
排名管理:管理员可以在后台管理系统中对用户学习排名进行管理。
学习时长管理:管理员用户可以针对某个用户的学习时长进行管理。
帖子管理:管理员可以在后台管理系统中对用户发布的帖子进行管理。
评论管理:管理员用户可以对帖子的评论进行管理。
兑换管理:管理员可以在该功能中对用户的兑换进行管理。
奖品管理:管理员可以在该功能中对奖品进行管理。
四、系统实现
诗词大全
礼品
兑换礼品
在线学习
个性推荐
诗词大全管理
在线学习管理
五、实现代码
在线学习
/**
* 在线学习
* 后端接口
*
* @author
* @email
*/
@RestController
@Controller
@RequestMapping("/zaixianxuexi")
public class ZaixianxuexiController {
private static final Logger logger = LoggerFactory.getLogger(ZaixianxuexiController.class);
private static final String TABLE_NAME = "zaixianxuexi";
@Autowired
private ZaixianxuexiService zaixianxuexiService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;
//级联表非注册的service
@Autowired
private ShicidaquanService shicidaquanService;
//注册表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"));
CommonUtil.checkMap(params);
PageUtils page = zaixianxuexiService.queryPage(params);
//字典表数据转换
List<ZaixianxuexiView> list = (List<ZaixianxuexiView>) page.getList();
for (ZaixianxuexiView 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);
ZaixianxuexiEntity zaixianxuexi = zaixianxuexiService.selectById(id);
if (zaixianxuexi != null) {
//entity转view
ZaixianxuexiView view = new ZaixianxuexiView();
BeanUtils.copyProperties(zaixianxuexi, view);//把实体数据重构到view中
//级联表 用户
//级联表
YonghuEntity yonghu = yonghuService.selectById(zaixianxuexi.getYonghuId());
if (yonghu != null) {
BeanUtils.copyProperties(yonghu, view, new String[]{"id", "createTime", "insertTime", "updateTime", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
view.setYonghuId(yonghu.getId());
}
//级联表 诗词大全
//级联表
ShicidaquanEntity shicidaquan = shicidaquanService.selectById(zaixianxuexi.getShicidaquanId());
if (shicidaquan != null) {
BeanUtils.copyProperties(shicidaquan, view, new String[]{"id", "createTime", "insertTime", "updateTime", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
view.setShicidaquanId(shicidaquan.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
} else {
return R.error(511, "查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody ZaixianxuexiEntity zaixianxuexi, HttpServletRequest request) {
logger.debug("save方法:,,Controller:{},,zaixianxuexi:{}", this.getClass().getName(), zaixianxuexi.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if (false)
return R.error(511, "永远不会进入");
else if ("用户".equals(role))
zaixianxuexi.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
Wrapper<ZaixianxuexiEntity> queryWrapper = new EntityWrapper<ZaixianxuexiEntity>()
.eq("yonghu_id", zaixianxuexi.getYonghuId())
.eq("shicidaquan_id", zaixianxuexi.getShicidaquanId())
.eq("xuexishichang", zaixianxuexi.getXuexishichang())
.eq("xuexizhuangtai_types", zaixianxuexi.getXuexizhuangtaiTypes());
logger.info("sql语句:" + queryWrapper.getSqlSegment());
ZaixianxuexiEntity zaixianxuexiEntity = zaixianxuexiService.selectOne(queryWrapper);
if (zaixianxuexiEntity == null) {
zaixianxuexi.setInsertTime(new Date());
zaixianxuexi.setCreateTime(new Date());
zaixianxuexiService.insert(zaixianxuexi);
return R.ok();
} else {
return R.error(511, "表中有相同数据");
}
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody ZaixianxuexiEntity zaixianxuexi, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,zaixianxuexi:{}", this.getClass().getName(), zaixianxuexi.toString());
ZaixianxuexiEntity oldZaixianxuexiEntity = zaixianxuexiService.selectById(zaixianxuexi.getId());//查询原先数据
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
// else if("用户".equals(role))
// zaixianxuexi.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
//根据字段查询是否有相同数据
Wrapper<ZaixianxuexiEntity> queryWrapper = new EntityWrapper<ZaixianxuexiEntity>()
.notIn("id", zaixianxuexi.getId())
.andNew()
.eq("yonghu_id", zaixianxuexi.getYonghuId())
.eq("shicidaquan_id", zaixianxuexi.getShicidaquanId())
.eq("xuexishichang", zaixianxuexi.getXuexishichang())
.eq("xuexizhuangtai_types", zaixianxuexi.getXuexizhuangtaiTypes());
logger.info("sql语句:" + queryWrapper.getSqlSegment());
ZaixianxuexiEntity zaixianxuexiEntity = zaixianxuexiService.selectOne(queryWrapper);
if (zaixianxuexiEntity == null) {
zaixianxuexiService.updateById(zaixianxuexi);//根据id更新
return R.ok();
} else {
return R.error(511, "表中有相同数据");
}
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request) {
logger.debug("delete:,,Controller:{},,ids:{}", this.getClass().getName(), ids.toString());
List<ZaixianxuexiEntity> oldZaixianxuexiList = zaixianxuexiService.selectBatchIds(Arrays.asList(ids));//要删除的数据
zaixianxuexiService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 批量上传
*/
@RequestMapping("/batchInsert")
public R save(String fileName, HttpServletRequest request) {
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}", this.getClass().getName(), fileName);
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
List<ZaixianxuexiEntity> zaixianxuexiList = 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) {
//循环
ZaixianxuexiEntity zaixianxuexiEntity = new ZaixianxuexiEntity();
// zaixianxuexiEntity.setYonghuId(Integer.valueOf(data.get(0))); //用户 要改的
// zaixianxuexiEntity.setShicidaquanId(Integer.valueOf(data.get(0))); //诗词大全 要改的
// zaixianxuexiEntity.setKaishiTime(sdf.parse(data.get(0))); //开始时间 要改的
// zaixianxuexiEntity.setJieshuTime(sdf.parse(data.get(0))); //结束时间 要改的
// zaixianxuexiEntity.setXuexishichang(Integer.valueOf(data.get(0))); //学习时长 (分钟) 要改的
// zaixianxuexiEntity.setXuexizhuangtaiTypes(Integer.valueOf(data.get(0))); //学习状态 要改的
// zaixianxuexiEntity.setInsertTime(date);//时间
// zaixianxuexiEntity.setCreateTime(date);//时间
zaixianxuexiList.add(zaixianxuexiEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
zaixianxuexiService.insertBatch(zaixianxuexiList);
return R.ok();
}
}
}
} catch (Exception e) {
e.printStackTrace();
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));
CommonUtil.checkMap(params);
PageUtils page = zaixianxuexiService.queryPage(params);
//字典表数据转换
List<ZaixianxuexiView> list = (List<ZaixianxuexiView>) page.getList();
for (ZaixianxuexiView 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);
ZaixianxuexiEntity zaixianxuexi = zaixianxuexiService.selectById(id);
if (zaixianxuexi != null) {
//entity转view
ZaixianxuexiView view = new ZaixianxuexiView();
BeanUtils.copyProperties(zaixianxuexi, view);//把实体数据重构到view中
//级联表
YonghuEntity yonghu = yonghuService.selectById(zaixianxuexi.getYonghuId());
if (yonghu != null) {
BeanUtils.copyProperties(yonghu, view, new String[]{"id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setYonghuId(yonghu.getId());
}
//级联表
ShicidaquanEntity shicidaquan = shicidaquanService.selectById(zaixianxuexi.getShicidaquanId());
if (shicidaquan != null) {
BeanUtils.copyProperties(shicidaquan, view, new String[]{"id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setShicidaquanId(shicidaquan.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
} else {
return R.error(511, "查不到数据");
}
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody ZaixianxuexiEntity zaixianxuexi, HttpServletRequest request) {
logger.debug("add方法:,,Controller:{},,zaixianxuexi:{}", this.getClass().getName(), zaixianxuexi.toString());
Wrapper<ZaixianxuexiEntity> chaxun = new EntityWrapper<ZaixianxuexiEntity>()
.eq("yonghu_id", zaixianxuexi.getYonghuId())
.eq("shicidaquan_id", zaixianxuexi.getShicidaquanId())
.eq("xuexizhuangtai_types", zaixianxuexi.getXuexizhuangtaiTypes());
ZaixianxuexiEntity zaixianxuexiEntity = zaixianxuexiService.selectOne(chaxun);
if (zaixianxuexiEntity != null) {
zaixianxuexiEntity.setXuexizhuangtaiTypes(3);
zaixianxuexiEntity.setXuexishichang(0);
zaixianxuexiService.updateById(zaixianxuexiEntity);
}
zaixianxuexi.setInsertTime(new Date());
zaixianxuexi.setCreateTime(new Date());
zaixianxuexiService.insert(zaixianxuexi);
//查询是否有未正常结束的记录,如果有 就关闭\
//调用selectOne查出来
// zaixianxuexiService.selectOne()
//判断 查出来对象是否为空 空代表没有未正常关闭的
//不为空 塞状态为未正常关闭的 时长0 执行updateByid方法更新
//新增一条新纪录
return R.ok();
}
@RequestMapping("/jieshu")
public R jeshu(Integer id, HttpServletRequest request) {
Date data = new Date();
Integer userId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
// 查询记录表 查出在学习的记录
Wrapper<ZaixianxuexiEntity> zaixianxuexiEntityEntityWrapper = new EntityWrapper<ZaixianxuexiEntity>()
.eq("yonghu_id", userId)
.eq("shicidaquan_id", id)
.eq("xuexizhuangtai_types", 1);
ZaixianxuexiEntity zaixianxuexiEntity = zaixianxuexiService.selectOne(zaixianxuexiEntityEntityWrapper);
if (zaixianxuexiEntity == null ) {
return R.error("查不到学习记录");
}
YonghuEntity yonghuEntity = yonghuService.selectById(userId);
if (yonghuEntity==null){
return R.error("查不到用户信息");
}
long nd = 1000 * 24 * 60 * 60;
long nh = 1000 * 60 * 60;
long nm = 1000 * 60;
// 获得两个时间的时间差异
long diff = data.getTime() - zaixianxuexiEntity.getKaishiTime().getTime();
// 计算差多少天
long day = diff / nd;
// 计算差多少小时
long hour = diff % nd / nh;
// 计算差多少分钟
long min = diff % nd % nh / nm;
// 输出结果\zaixianxuexiEntity
System.out.println("停车时长:" + hour + "小时" + min + "分钟");
Long l = day * 24 * 60 + hour * 60 + min;
zaixianxuexiEntity.setXuexizhuangtaiTypes(2);
zaixianxuexiEntity.setXuexishichang(Integer.valueOf(String.valueOf(l)));
zaixianxuexiEntity.setJieshuTime(data);
yonghuEntity.setNewMoney(Integer.valueOf(String.valueOf(l))+yonghuEntity.getNewMoney());
yonghuService.updateById(yonghuEntity);
zaixianxuexiService.updateById(zaixianxuexiEntity);
return R.ok();
}
}