一、前言
二十一世纪我们的社会进入了信息时代,信息管理系统的建立,大大提高了人们信息化水平。传统的管理方式对时间、地点的限制太多,而在线管理系统刚好能满足这些需求,在线管理系统突破了传统管理方式的局限性。于是本文针对这一需求设计并实现了一个基于springboot动漫周边商城,为了简捷并有效的解决动漫商品各方面的问题。
本文讲述了动漫周边商城。结合电子管理系统的特点,分析了动漫周边商城的背景,给出了动漫周边商城实现的设计方案。
本论文主要完成不同用户的权限划分,不同用户具有不同权限的操作功能,在用户模块,主要有用户进行注册和登录,用户可以实现查看文章资讯、动漫活动、动漫商品,还能修改个人信息等;在管理员模块,管理员可以对用户信息、文章资讯、动漫活动、动漫商品等进行相应的操作。
二、开发环境
开发语言:Java
框架:springboot
JDK版本:JDK1.8
服务器:tomcat7
数据库:mysql 5.7(一定要5.7版本)
数据库工具:Navicat11
开发软件:eclipse/myeclipse/idea
Maven包:Maven3.3.9
浏览器:谷歌浏览器
三、系统功能设计
动漫周边商城可以将功能划分为用户的使用功能和管理员功能。
(1)用户关键功能包含用户注册登录,系统首页、个人中心、文章资讯管理等有关信息,并进行详细操作。用户用例如下:
(2)管理员的权限是最高的,可以对系统所在功能进行查看,修改和删除,包括用户功能。管理员用例如下:
动漫周边商城分为二个模块,分别是管理员功能模块和用户功能模块。管理员功能模块包括:文章资讯、文章类型、动漫活动、动漫商品功能,用户功能模块包括:文章资讯、动漫活动、动漫商品、购物车,网站总体功能如下图所示。
四、系统数据库设计
概念模型是对现实中的问题出现的事物的进行描述,ER图是由实体及其关系构成的图,通过E-R图可以清楚地描述系统涉及到的实体之间的相互关系。
五、系统效果
六、核心代码
package com.controller;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.text.ParseException;
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.transaction.annotation.Transactional;
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.DiscussdongmanshangpinEntity;
import com.entity.view.DiscussdongmanshangpinView;
import com.service.DiscussdongmanshangpinService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
import java.io.IOException;
/**
* 动漫商品评论表
* 后端接口
* @author
* @email
* @date 2023-03-12 09:15:48
*/
@RestController
@RequestMapping("/discussdongmanshangpin")
public class DiscussdongmanshangpinController {
@Autowired
private DiscussdongmanshangpinService discussdongmanshangpinService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,DiscussdongmanshangpinEntity discussdongmanshangpin,
HttpServletRequest request){
EntityWrapper<DiscussdongmanshangpinEntity> ew = new EntityWrapper<DiscussdongmanshangpinEntity>();
PageUtils page = discussdongmanshangpinService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discussdongmanshangpin), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,DiscussdongmanshangpinEntity discussdongmanshangpin,
HttpServletRequest request){
EntityWrapper<DiscussdongmanshangpinEntity> ew = new EntityWrapper<DiscussdongmanshangpinEntity>();
PageUtils page = discussdongmanshangpinService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discussdongmanshangpin), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( DiscussdongmanshangpinEntity discussdongmanshangpin){
EntityWrapper<DiscussdongmanshangpinEntity> ew = new EntityWrapper<DiscussdongmanshangpinEntity>();
ew.allEq(MPUtil.allEQMapPre( discussdongmanshangpin, "discussdongmanshangpin"));
return R.ok().put("data", discussdongmanshangpinService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(DiscussdongmanshangpinEntity discussdongmanshangpin){
EntityWrapper< DiscussdongmanshangpinEntity> ew = new EntityWrapper< DiscussdongmanshangpinEntity>();
ew.allEq(MPUtil.allEQMapPre( discussdongmanshangpin, "discussdongmanshangpin"));
DiscussdongmanshangpinView discussdongmanshangpinView = discussdongmanshangpinService.selectView(ew);
return R.ok("查询动漫商品评论表成功").put("data", discussdongmanshangpinView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
DiscussdongmanshangpinEntity discussdongmanshangpin = discussdongmanshangpinService.selectById(id);
return R.ok().put("data", discussdongmanshangpin);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
DiscussdongmanshangpinEntity discussdongmanshangpin = discussdongmanshangpinService.selectById(id);
return R.ok().put("data", discussdongmanshangpin);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody DiscussdongmanshangpinEntity discussdongmanshangpin, HttpServletRequest request){
discussdongmanshangpin.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(discussdongmanshangpin);
discussdongmanshangpinService.insert(discussdongmanshangpin);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody DiscussdongmanshangpinEntity discussdongmanshangpin, HttpServletRequest request){
discussdongmanshangpin.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(discussdongmanshangpin);
discussdongmanshangpinService.insert(discussdongmanshangpin);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody DiscussdongmanshangpinEntity discussdongmanshangpin, HttpServletRequest request){
//ValidatorUtils.validateEntity(discussdongmanshangpin);
discussdongmanshangpinService.updateById(discussdongmanshangpin);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
discussdongmanshangpinService.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<DiscussdongmanshangpinEntity> wrapper = new EntityWrapper<DiscussdongmanshangpinEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = discussdongmanshangpinService.selectCount(wrapper);
return R.ok().put("count", count);
}
}
package com.controller;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.text.ParseException;
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.transaction.annotation.Transactional;
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.WenzhangzixunEntity;
import com.entity.view.WenzhangzixunView;
import com.service.WenzhangzixunService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;
import java.io.IOException;
import com.service.StoreupService;
import com.entity.StoreupEntity;
/**
* 文章资讯
* 后端接口
* @author
* @email
* @date 2023-03-12 09:15:47
*/
@RestController
@RequestMapping("/wenzhangzixun")
public class WenzhangzixunController {
@Autowired
private WenzhangzixunService wenzhangzixunService;
@Autowired
private StoreupService storeupService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,WenzhangzixunEntity wenzhangzixun,
HttpServletRequest request){
String tableName = request.getSession().getAttribute("tableName").toString();
if(tableName.equals("yonghu")) {
wenzhangzixun.setZhanghao((String)request.getSession().getAttribute("username"));
}
EntityWrapper<WenzhangzixunEntity> ew = new EntityWrapper<WenzhangzixunEntity>();
PageUtils page = wenzhangzixunService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenzhangzixun), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,WenzhangzixunEntity wenzhangzixun,
HttpServletRequest request){
EntityWrapper<WenzhangzixunEntity> ew = new EntityWrapper<WenzhangzixunEntity>();
PageUtils page = wenzhangzixunService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, wenzhangzixun), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( WenzhangzixunEntity wenzhangzixun){
EntityWrapper<WenzhangzixunEntity> ew = new EntityWrapper<WenzhangzixunEntity>();
ew.allEq(MPUtil.allEQMapPre( wenzhangzixun, "wenzhangzixun"));
return R.ok().put("data", wenzhangzixunService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(WenzhangzixunEntity wenzhangzixun){
EntityWrapper< WenzhangzixunEntity> ew = new EntityWrapper< WenzhangzixunEntity>();
ew.allEq(MPUtil.allEQMapPre( wenzhangzixun, "wenzhangzixun"));
WenzhangzixunView wenzhangzixunView = wenzhangzixunService.selectView(ew);
return R.ok("查询文章资讯成功").put("data", wenzhangzixunView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
WenzhangzixunEntity wenzhangzixun = wenzhangzixunService.selectById(id);
return R.ok().put("data", wenzhangzixun);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
WenzhangzixunEntity wenzhangzixun = wenzhangzixunService.selectById(id);
return R.ok().put("data", wenzhangzixun);
}
/**
* 赞或踩
*/
@RequestMapping("/thumbsup/{id}")
public R vote(@PathVariable("id") String id,String type){
WenzhangzixunEntity wenzhangzixun = wenzhangzixunService.selectById(id);
if(type.equals("1")) {
wenzhangzixun.setThumbsupnum(wenzhangzixun.getThumbsupnum()+1);
} else {
wenzhangzixun.setCrazilynum(wenzhangzixun.getCrazilynum()+1);
}
wenzhangzixunService.updateById(wenzhangzixun);
return R.ok("投票成功");
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody WenzhangzixunEntity wenzhangzixun, HttpServletRequest request){
wenzhangzixun.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(wenzhangzixun);
wenzhangzixunService.insert(wenzhangzixun);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody WenzhangzixunEntity wenzhangzixun, HttpServletRequest request){
wenzhangzixun.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(wenzhangzixun);
wenzhangzixunService.insert(wenzhangzixun);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@Transactional
public R update(@RequestBody WenzhangzixunEntity wenzhangzixun, HttpServletRequest request){
//ValidatorUtils.validateEntity(wenzhangzixun);
wenzhangzixunService.updateById(wenzhangzixun);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
wenzhangzixunService.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<WenzhangzixunEntity> wrapper = new EntityWrapper<WenzhangzixunEntity>();
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("zhanghao", (String)request.getSession().getAttribute("username"));
}
int count = wenzhangzixunService.selectCount(wrapper);
return R.ok().put("count", count);
}
}