作者主页:源码空间站2022
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
角色:管理员、学生,项目分为前后台
学生登陆系统后,可以查看首页,学校介绍、领导架构、联系我们、留言板,新闻资讯信息、师资力量、校园风光、我的、后台管理等功能
管理员登陆系统后,可以查看个人中心,轮播图信息,基础数据管理(班级管理、新闻资讯类型管理、生源地管理、所教专业管理、校园风光类型管理、院系管理),留言板管理,新闻资讯信息管理,师资力量管理(师资力量管理、师资力量留言管理、师资力量收藏管理)、单页数据管理、校园风光管理(校园风光管理、校园风光留言管理、校园风光收藏管理)、学生管理等功能,还能对每个功能逐一进行相应操作
由于本程序规模不大,可供课程设计,毕业设计学习演示之用
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 是;
6.数据库:MySql 5.7/8.0等版本均可;
技术栈
后端:SSM(Spring+SpringMVC+Mybatis)
前端:JSP+CSS+JS+JQUERY+Layui+elementUI
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中config.properties配置文件中的数据库配置改为自己的配置,然后运行;
4. 运行项目,在浏览器中输入项目地址:
前台页面
http://localhost:8080/xueyuanwangzhan/front/
学生账户:a1 密码:123456
后台登录页面
http://localhost:8080/xueyuanwangzhan/jsp/login.jsp
管理员账户:admin 密码:admin
学生账户:a1 密码:123456
运行截图
论文截图
前台界面
后台界面
相关代码
ShizililiangCollectionController
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("/shizililiangCollection")
public class ShizililiangCollectionController {
private static final Logger logger = LoggerFactory.getLogger(ShizililiangCollectionController.class);
@Autowired
private ShizililiangCollectionService shizililiangCollectionService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;
//级联表service
@Autowired
private ShizililiangService shizililiangService;
@Autowired
private XueshengService xueshengService;
/**
* 后端列表
*/
@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("xueshengId",request.getSession().getAttribute("userId"));
if(params.get("orderBy")==null || params.get("orderBy")==""){
params.put("orderBy","id");
}
PageUtils page = shizililiangCollectionService.queryPage(params);
//字典表数据转换
List<ShizililiangCollectionView> list =(List<ShizililiangCollectionView>)page.getList();
for(ShizililiangCollectionView 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);
ShizililiangCollectionEntity shizililiangCollection = shizililiangCollectionService.selectById(id);
if(shizililiangCollection !=null){
//entity转view
ShizililiangCollectionView view = new ShizililiangCollectionView();
BeanUtils.copyProperties( shizililiangCollection , view );//把实体数据重构到view中
//级联表
ShizililiangEntity shizililiang = shizililiangService.selectById(shizililiangCollection.getShizililiangId());
if(shizililiang != null){
BeanUtils.copyProperties( shizililiang , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setShizililiangId(shizililiang.getId());
}
//级联表
XueshengEntity xuesheng = xueshengService.selectById(shizililiangCollection.getXueshengId());
if(xuesheng != null){
BeanUtils.copyProperties( xuesheng , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setXueshengId(xuesheng.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody ShizililiangCollectionEntity shizililiangCollection, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,shizililiangCollection:{}",this.getClass().getName(),shizililiangCollection.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
else if("学生".equals(role))
shizililiangCollection.setXueshengId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
Wrapper<ShizililiangCollectionEntity> queryWrapper = new EntityWrapper<ShizililiangCollectionEntity>()
.eq("shizililiang_id", shizililiangCollection.getShizililiangId())
.eq("xuesheng_id", shizililiangCollection.getXueshengId())
.eq("shizililiang_collection_types", shizililiangCollection.getShizililiangCollectionTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
ShizililiangCollectionEntity shizililiangCollectionEntity = shizililiangCollectionService.selectOne(queryWrapper);
if(shizililiangCollectionEntity==null){
shizililiangCollection.setInsertTime(new Date());
shizililiangCollection.setCreateTime(new Date());
shizililiangCollectionService.insert(shizililiangCollection);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody ShizililiangCollectionEntity shizililiangCollection, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,shizililiangCollection:{}",this.getClass().getName(),shizililiangCollection.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
// else if("学生".equals(role))
// shizililiangCollection.setXueshengId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
//根据字段查询是否有相同数据
Wrapper<ShizililiangCollectionEntity> queryWrapper = new EntityWrapper<ShizililiangCollectionEntity>()
.notIn("id",shizililiangCollection.getId())
.andNew()
.eq("shizililiang_id", shizililiangCollection.getShizililiangId())
.eq("xuesheng_id", shizililiangCollection.getXueshengId())
.eq("shizililiang_collection_types", shizililiangCollection.getShizililiangCollectionTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
ShizililiangCollectionEntity shizililiangCollectionEntity = shizililiangCollectionService.selectOne(queryWrapper);
if(shizililiangCollectionEntity==null){
shizililiangCollectionService.updateById(shizililiangCollection);//根据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());
shizililiangCollectionService.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<ShizililiangCollectionEntity> shizililiangCollectionList = 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("../../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){
//循环
ShizililiangCollectionEntity shizililiangCollectionEntity = new ShizililiangCollectionEntity();
// shizililiangCollectionEntity.setShizililiangId(Integer.valueOf(data.get(0))); //师资力量 要改的
// shizililiangCollectionEntity.setXueshengId(Integer.valueOf(data.get(0))); //学生 要改的
// shizililiangCollectionEntity.setShizililiangCollectionTypes(Integer.valueOf(data.get(0))); //类型 要改的
// shizililiangCollectionEntity.setInsertTime(date);//时间
// shizililiangCollectionEntity.setCreateTime(date);//时间
shizililiangCollectionList.add(shizililiangCollectionEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
shizililiangCollectionService.insertBatch(shizililiangCollectionList);
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));
// 没有指定排序字段就默认id倒序
if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
params.put("orderBy","id");
}
PageUtils page = shizililiangCollectionService.queryPage(params);
//字典表数据转换
List<ShizililiangCollectionView> list =(List<ShizililiangCollectionView>)page.getList();
for(ShizililiangCollectionView 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);
ShizililiangCollectionEntity shizililiangCollection = shizililiangCollectionService.selectById(id);
if(shizililiangCollection !=null){
//entity转view
ShizililiangCollectionView view = new ShizililiangCollectionView();
BeanUtils.copyProperties( shizililiangCollection , view );//把实体数据重构到view中
//级联表
ShizililiangEntity shizililiang = shizililiangService.selectById(shizililiangCollection.getShizililiangId());
if(shizililiang != null){
BeanUtils.copyProperties( shizililiang , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setShizililiangId(shizililiang.getId());
}
//级联表
XueshengEntity xuesheng = xueshengService.selectById(shizililiangCollection.getXueshengId());
if(xuesheng != null){
BeanUtils.copyProperties( xuesheng , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setXueshengId(xuesheng.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody ShizililiangCollectionEntity shizililiangCollection, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,shizililiangCollection:{}",this.getClass().getName(),shizililiangCollection.toString());
Wrapper<ShizililiangCollectionEntity> queryWrapper = new EntityWrapper<ShizililiangCollectionEntity>()
.eq("shizililiang_id", shizililiangCollection.getShizililiangId())
.eq("xuesheng_id", shizililiangCollection.getXueshengId())
.eq("shizililiang_collection_types", shizililiangCollection.getShizililiangCollectionTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
ShizililiangCollectionEntity shizililiangCollectionEntity = shizililiangCollectionService.selectOne(queryWrapper);
if(shizililiangCollectionEntity==null){
shizililiangCollection.setInsertTime(new Date());
shizililiangCollection.setCreateTime(new Date());
shizililiangCollectionService.insert(shizililiangCollection);
return R.ok();
}else {
return R.error(511,"您已经收藏过了");
}
}
}
如果也想学习本系统,下面领取。关注并回复:332ssm
标签:Java,332SSM,校园,new,return,shizililiangCollection,import,id,view From: https://blog.csdn.net/m0_74967853/article/details/136989891