文末获取联系
开发语言: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
一、前言介绍
使用旧方法对足球社区管理系统的信息进行系统化管理已经不再让人们信赖了,把现在的网络信息技术运用在足球社区管理系统的管理上面可以解决许多信息管理上面的难题,比如处理数据时间很长,数据存在错误不能及时纠正等问题。这次开发的足球社区管理系统对场地管理、场地收藏管理、场地留言管理、场地预约管理、字典管理、论坛管理、教练管理、足球资讯管理、球队管理、球队收藏管理、球队留言管理、训练打卡管理、用户管理、管理员管理等进行集中化处理。经过前面自己查阅的网络知识,加上自己在学校课堂上学习的知识,决定开发系统选择小程序模式这种高效率的模式完成系统功能开发。这种模式让操作员基于浏览器的方式进行网站访问,采用的主流的Java语言这种面向对象的语言进行足球社区管理系统程序的开发,在数据库的选择上面,选择功能强大的Mysql数据库进行数据的存放操作。足球社区管理系统的开发让用户查看球队信息变得容易,让管理员高效管理球队信息。
二、系统实现
用户功能
首页
场地
个人中心
管理员功能
球队管理页面
场地信息管理页面
场地类型列表页面
三、部分核心代码
/**
* 球队
* 后端接口
* @author
* @email
*/
@RestController
@Controller
@RequestMapping("/qiudui")
public class QiuduiController {
private static final Logger logger = LoggerFactory.getLogger(QiuduiController.class);
private static final String TABLE_NAME = "qiudui";
@Autowired
private QiuduiService qiuduiService;
@Autowired
private TokenService tokenService;
@Autowired
private ChangdiService changdiService;//场地
@Autowired
private ChangdiCollectionService changdiCollectionService;//场地收藏
@Autowired
private ChangdiLiuyanService changdiLiuyanService;//场地留言
@Autowired
private ChangdiYuyueService changdiYuyueService;//场地预约
@Autowired
private DictionaryService dictionaryService;//字典
@Autowired
private ForumService forumService;//论坛
@Autowired
private JiaolianService jiaolianService;//教练
@Autowired
private NewsService newsService;//足球资讯
@Autowired
private QiuduiCollectionService qiuduiCollectionService;//球队收藏
@Autowired
private QiuduiLiuyanService qiuduiLiuyanService;//球队留言
@Autowired
private XunliandakaService xunliandakaService;//训练打卡
@Autowired
private YonghuService yonghuService;//用户
@Autowired
private UsersService usersService;//管理员
/**
* 后端列表
*/
@IgnoreAuth
@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"));
else if("教练".equals(role))
params.put("jiaolianId",request.getSession().getAttribute("userId"));
params.put("qiuduiDeleteStart",1);params.put("qiuduiDeleteEnd",1);
CommonUtil.checkMap(params);
PageUtils page = qiuduiService.queryPage(params);
//字典表数据转换
List<QiuduiView> list =(List<QiuduiView>)page.getList();
for(QiuduiView 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);
QiuduiEntity qiudui = qiuduiService.selectById(id);
if(qiudui !=null){
//entity转view
QiuduiView view = new QiuduiView();
BeanUtils.copyProperties( qiudui , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody QiuduiEntity qiudui, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,qiudui:{}",this.getClass().getName(),qiudui.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
Wrapper<QiuduiEntity> queryWrapper = new EntityWrapper<QiuduiEntity>()
.eq("qiudui_name", qiudui.getQiuduiName())
.eq("qiudui_address", qiudui.getQiuduiAddress())
.eq("qiudui_types", qiudui.getQiuduiTypes())
.eq("fenqu_types", qiudui.getFenquTypes())
.eq("cai_number", qiudui.getCaiNumber())
.eq("zan_number", qiudui.getZanNumber())
.eq("qiudui_delete", qiudui.getQiuduiDelete())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
QiuduiEntity qiuduiEntity = qiuduiService.selectOne(queryWrapper);
if(qiuduiEntity==null){
qiudui.setQiuduiClicknum(1);
qiudui.setQiuduiDelete(1);
qiudui.setInsertTime(new Date());
qiudui.setCreateTime(new Date());
qiuduiService.insert(qiudui);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody QiuduiEntity qiudui, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,qiudui:{}",this.getClass().getName(),qiudui.toString());
QiuduiEntity oldQiuduiEntity = qiuduiService.selectById(qiudui.getId());//查询原先数据
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
if("".equals(qiudui.getQiuduiPhoto()) || "null".equals(qiudui.getQiuduiPhoto())){
qiudui.setQiuduiPhoto(null);
}
qiuduiService.updateById(qiudui);//根据id更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<QiuduiEntity> oldQiuduiList =qiuduiService.selectBatchIds(Arrays.asList(ids));//要删除的数据
ArrayList<QiuduiEntity> list = new ArrayList<>();
for(Integer id:ids){
QiuduiEntity qiuduiEntity = new QiuduiEntity();
qiuduiEntity.setId(id);
qiuduiEntity.setQiuduiDelete(2);
list.add(qiuduiEntity);
}
if(list != null && list.size() >0){
qiuduiService.updateBatchById(list);
}
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<QiuduiEntity> qiuduiList = 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){
//循环
QiuduiEntity qiuduiEntity = new QiuduiEntity();
// qiuduiEntity.setQiuduiName(data.get(0)); //球队名称 要改的
// qiuduiEntity.setQiuduiUuidNumber(data.get(0)); //球队编号 要改的
// qiuduiEntity.setQiuduiPhoto("");//详情和图片
// qiuduiEntity.setQiuduiAddress(data.get(0)); //主场 要改的
// qiuduiEntity.setQiuduiTypes(Integer.valueOf(data.get(0))); //球队类型 要改的
// qiuduiEntity.setFenquTypes(Integer.valueOf(data.get(0))); //分区 要改的
// qiuduiEntity.setQiuduiClicknum(Integer.valueOf(data.get(0))); //球队热度 要改的
// qiuduiEntity.setCaiNumber(Integer.valueOf(data.get(0))); //踩 要改的
// qiuduiEntity.setZanNumber(Integer.valueOf(data.get(0))); //赞 要改的
// qiuduiEntity.setQiuduiContent("");//详情和图片
// qiuduiEntity.setQiuduiDelete(1);//逻辑删除字段
// qiuduiEntity.setInsertTime(date);//时间
// qiuduiEntity.setCreateTime(date);//时间
qiuduiList.add(qiuduiEntity);
//把要查询是否重复的字段放入map中
//球队编号
if(seachFields.containsKey("qiuduiUuidNumber")){
List<String> qiuduiUuidNumber = seachFields.get("qiuduiUuidNumber");
qiuduiUuidNumber.add(data.get(0));//要改的
}else{
List<String> qiuduiUuidNumber = new ArrayList<>();
qiuduiUuidNumber.add(data.get(0));//要改的
seachFields.put("qiuduiUuidNumber",qiuduiUuidNumber);
}
}
//查询是否重复
//球队编号
List<QiuduiEntity> qiuduiEntities_qiuduiUuidNumber = qiuduiService.selectList(new EntityWrapper<QiuduiEntity>().in("qiudui_uuid_number", seachFields.get("qiuduiUuidNumber")).eq("qiudui_delete", 1));
if(qiuduiEntities_qiuduiUuidNumber.size() >0 ){
ArrayList<String> repeatFields = new ArrayList<>();
for(QiuduiEntity s:qiuduiEntities_qiuduiUuidNumber){
repeatFields.add(s.getQiuduiUuidNumber());
}
return R.error(511,"数据库的该表中的 [球队编号] 字段已经存在 存在数据为:"+repeatFields.toString());
}
qiuduiService.insertBatch(qiuduiList);
return R.ok();
}
}
}
}catch (Exception e){
e.printStackTrace();
return R.error(511,"批量插入数据异常,请联系管理员");
}
}
/**
* 个性推荐
*/
@IgnoreAuth
@RequestMapping("/gexingtuijian")
public R gexingtuijian(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("gexingtuijian方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
CommonUtil.checkMap(params);
List<QiuduiView> returnQiuduiViewList = new ArrayList<>();
//查看收藏
Map<String, Object> params1 = new HashMap<>(params);params1.put("sort","id");params1.put("yonghuId",request.getSession().getAttribute("userId"));
PageUtils pageUtils = qiuduiCollectionService.queryPage(params1);
List<QiuduiCollectionView> collectionViewsList =(List<QiuduiCollectionView>)pageUtils.getList();
Map<Integer,Integer> typeMap=new HashMap<>();//购买的类型list
for(QiuduiCollectionView collectionView:collectionViewsList){
Integer qiuduiTypes = collectionView.getQiuduiTypes();
if(typeMap.containsKey(qiuduiTypes)){
typeMap.put(qiuduiTypes,typeMap.get(qiuduiTypes)+1);
}else{
typeMap.put(qiuduiTypes,1);
}
}
List<Integer> typeList = new ArrayList<>();//排序后的有序的类型 按最多到最少
typeMap.entrySet().stream().sorted((o1, o2) -> o2.getValue() - o1.getValue()).forEach(e -> typeList.add(e.getKey()));//排序
Integer limit = Integer.valueOf(String.valueOf(params.get("limit")));
for(Integer type:typeList){
Map<String, Object> params2 = new HashMap<>(params);params2.put("qiuduiTypes",type);
PageUtils pageUtils1 = qiuduiService.queryPage(params2);
List<QiuduiView> qiuduiViewList =(List<QiuduiView>)pageUtils1.getList();
returnQiuduiViewList.addAll(qiuduiViewList);
if(returnQiuduiViewList.size()>= limit) break;//返回的推荐数量大于要的数量 跳出循环
}
//正常查询出来商品,用于补全推荐缺少的数据
PageUtils page = qiuduiService.queryPage(params);
if(returnQiuduiViewList.size()<limit){//返回数量还是小于要求数量
int toAddNum = limit - returnQiuduiViewList.size();//要添加的数量
List<QiuduiView> qiuduiViewList =(List<QiuduiView>)page.getList();
for(QiuduiView qiuduiView:qiuduiViewList){
Boolean addFlag = true;
for(QiuduiView returnQiuduiView:returnQiuduiViewList){
if(returnQiuduiView.getId().intValue() ==qiuduiView.getId().intValue()) addFlag=false;//返回的数据中已存在此商品
}
if(addFlag){
toAddNum=toAddNum-1;
returnQiuduiViewList.add(qiuduiView);
if(toAddNum==0) break;//够数量了
}
}
}else {
returnQiuduiViewList = returnQiuduiViewList.subList(0, limit);
}
for(QiuduiView c:returnQiuduiViewList)
dictionaryService.dictionaryConvert(c, request);
page.setList(returnQiuduiViewList);
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@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 = qiuduiService.queryPage(params);
//字典表数据转换
List<QiuduiView> list =(List<QiuduiView>)page.getList();
for(QiuduiView 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);
QiuduiEntity qiudui = qiuduiService.selectById(id);
if(qiudui !=null){
//点击数量加1
qiudui.setQiuduiClicknum(qiudui.getQiuduiClicknum()+1);
qiuduiService.updateById(qiudui);
//entity转view
QiuduiView view = new QiuduiView();
BeanUtils.copyProperties( qiudui , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody QiuduiEntity qiudui, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,qiudui:{}",this.getClass().getName(),qiudui.toString());
Wrapper<QiuduiEntity> queryWrapper = new EntityWrapper<QiuduiEntity>()
.eq("qiudui_name", qiudui.getQiuduiName())
.eq("qiudui_uuid_number", qiudui.getQiuduiUuidNumber())
.eq("qiudui_address", qiudui.getQiuduiAddress())
.eq("qiudui_types", qiudui.getQiuduiTypes())
.eq("fenqu_types", qiudui.getFenquTypes())
.eq("qiudui_clicknum", qiudui.getQiuduiClicknum())
.eq("cai_number", qiudui.getCaiNumber())
.eq("zan_number", qiudui.getZanNumber())
.eq("qiudui_delete", qiudui.getQiuduiDelete())
// .notIn("qiudui_types", new Integer[]{102})
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
QiuduiEntity qiuduiEntity = qiuduiService.selectOne(queryWrapper);
if(qiuduiEntity==null){
qiudui.setQiuduiClicknum(1);
qiudui.setCaiNumber(1);
qiudui.setZanNumber(1);
qiudui.setQiuduiDelete(1);
qiudui.setInsertTime(new Date());
qiudui.setCreateTime(new Date());
qiuduiService.insert(qiudui);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
}