基于Java的ssm在线教育平台设计与实现

基于Java的ssm在线教育平台设计与实现189

 开发工具:idea 或eclipse
 数据库mysql5.7+
 数据库链接工具:navcat,小海豚等
  技术:ssm 

  • 选题依据及意义(不少于300字)

随着电子技术和网络信息的迅速发展,互联网正在政治、经济、文化各个领域引发着一场影响广泛而深远的革命。利用互联网展开的网上教育,已经越来越成为衡量一个地方教育综合发展的重要指标之一。

21世纪是一个网络平台的信息时代,随着网络应用的普及和深入,目前网络正以一种前所未有的冲击力影响着人类的生活。网络教育也成为了一种潮流,我们可以通过网络教育,更好的了解教育动态,也可以不受地理位置的限制,查询到所需资料,分享知识。因此,我们通过网络教育网站来实现。

信息自动化处理以及网络式信息交互方式已经普及并且被人们广泛应用,现在我们信息管理都是在网上进行的,这个对于学生来说更加的自主、便捷。现在利用web来设计建设我们的小型教育网站更加容易,并且在这个网站上学生可以各家发便快捷的学习到知识,能和老师更好的沟通交流。网站学习模块多种多样,比如老师教学模块和学生学习模块等。其中最有趣的是娱乐天地模块,让学生在学习之余也能放松一下心情,更加有效率的学习。

package com.controller;


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.StringUtil;
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.KechngCollectionEntity;

import com.service.KechngCollectionService;
import com.entity.view.KechngCollectionView;
import com.service.KechngService;
import com.entity.KechngEntity;
import com.service.YonghuService;
import com.entity.YonghuEntity;

import com.utils.PageUtils;
import com.utils.R;

/**
 * 课程收藏
 * 后端接口
 * @author
 * @email
 * @date 2021-04-15
*/
@RestController
@Controller
@RequestMapping("/kechngCollection")
public class KechngCollectionController {
    private static final Logger logger = LoggerFactory.getLogger(KechngCollectionController.class);

    @Autowired
    private KechngCollectionService kechngCollectionService;


    @Autowired
    private TokenService tokenService;
    @Autowired
    private DictionaryService dictionaryService;



    //级联表service
    @Autowired
    private KechngService kechngService;
    @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(StringUtil.isNotEmpty(role) && "学生".equals(role)){
            params.put("yonghuId",request.getSession().getAttribute("userId"));
        } if(StringUtil.isNotEmpty(role) && "教师".equals(role)){
            params.put("jiaoshiId",request.getSession().getAttribute("userId"));
        }
        params.put("orderBy","id");
        PageUtils page = kechngCollectionService.queryPage(params);

        //字典表数据转换
        List<KechngCollectionView> list =(List<KechngCollectionView>)page.getList();
        for(KechngCollectionView c:list){
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(c);
        }
        return R.ok().put("data", page);
    }

    /**
    * 后端详情
    */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        KechngCollectionEntity kechngCollection = kechngCollectionService.selectById(id);
        if(kechngCollection !=null){
            //entity转view
            KechngCollectionView view = new KechngCollectionView();
            BeanUtils.copyProperties( kechngCollection , view );//把实体数据重构到view中

            //级联表
            KechngEntity kechng = kechngService.selectById(kechngCollection.getKechngId());
            if(kechng != null){
                BeanUtils.copyProperties( kechng , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                view.setKechngId(kechng.getId());
            }
            //级联表
            YonghuEntity yonghu = yonghuService.selectById(kechngCollection.getYonghuId());
            if(yonghu != null){
                BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                view.setYonghuId(yonghu.getId());
            }
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody KechngCollectionEntity kechngCollection, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,kechngCollection:{}",this.getClass().getName(),kechngCollection.toString());
        Wrapper<KechngCollectionEntity> queryWrapper = new EntityWrapper<KechngCollectionEntity>()
            .eq("kechng_id", kechngCollection.getKechngId())
            .eq("yonghu_id", kechngCollection.getYonghuId())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        KechngCollectionEntity kechngCollectionEntity = kechngCollectionService.selectOne(queryWrapper);
        if(kechngCollectionEntity==null){
            kechngCollection.setInsertTime(new Date());
            kechngCollection.setCreateTime(new Date());
        //  String role = String.valueOf(request.getSession().getAttribute("role"));
        //  if("".equals(role)){
        //      kechngCollection.set
        //  }
            kechngCollectionService.insert(kechngCollection);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody KechngCollectionEntity kechngCollection, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,kechngCollection:{}",this.getClass().getName(),kechngCollection.toString());
        //根据字段查询是否有相同数据
        Wrapper<KechngCollectionEntity> queryWrapper = new EntityWrapper<KechngCollectionEntity>()
            .notIn("id",kechngCollection.getId())
            .andNew()
            .eq("kechng_id", kechngCollection.getKechngId())
            .eq("yonghu_id", kechngCollection.getYonghuId())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        KechngCollectionEntity kechngCollectionEntity = kechngCollectionService.selectOne(queryWrapper);
        if(kechngCollectionEntity==null){
            //  String role = String.valueOf(request.getSession().getAttribute("role"));
            //  if("".equals(role)){
            //      kechngCollection.set
            //  }
            kechngCollectionService.updateById(kechngCollection);//根据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());
        kechngCollectionService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }



    /**
    * 前端列表
    */
    @RequestMapping("/list")
    public R list(@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(StringUtil.isNotEmpty(role) && "学生".equals(role)){
            params.put("yonghuId",request.getSession().getAttribute("userId"));
        } if(StringUtil.isNotEmpty(role) && "教师".equals(role)){
            params.put("jiaoshiId",request.getSession().getAttribute("userId"));
        }
        // 没有指定排序字段就默认id倒序
        if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
            params.put("orderBy","id");
        }
        PageUtils page = kechngCollectionService.queryPage(params);

        //字典表数据转换
        List<KechngCollectionView> list =(List<KechngCollectionView>)page.getList();
        for(KechngCollectionView c:list){
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(c);
        }
        return R.ok().put("data", page);
    }

    /**
    * 前端详情
    */
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id){
        logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        KechngCollectionEntity kechngCollection = kechngCollectionService.selectById(id);
            if(kechngCollection !=null){
                //entity转view
        KechngCollectionView view = new KechngCollectionView();
                BeanUtils.copyProperties( kechngCollection , view );//把实体数据重构到view中

                //级联表
                    KechngEntity kechng = kechngService.selectById(kechngCollection.getKechngId());
                if(kechng != null){
                    BeanUtils.copyProperties( kechng , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setKechngId(kechng.getId());
                }
                //级联表
                    YonghuEntity yonghu = yonghuService.selectById(kechngCollection.getYonghuId());
                if(yonghu != null){
                    BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setYonghuId(yonghu.getId());
                }
                //修改对应字典表字段
                dictionaryService.dictionaryConvert(view);
                return R.ok().put("data", view);
            }else {
                return R.error(511,"查不到数据");
            }
    }


    /**
    * 前端保存
    */
    @RequestMapping("/add")
    public R add(@RequestBody KechngCollectionEntity kechngCollection, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,kechngCollection:{}",this.getClass().getName(),kechngCollection.toString());
        Wrapper<KechngCollectionEntity> queryWrapper = new EntityWrapper<KechngCollectionEntity>()
            .eq("kechng_id", kechngCollection.getKechngId())
            .eq("yonghu_id", kechngCollection.getYonghuId())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
    KechngCollectionEntity kechngCollectionEntity = kechngCollectionService.selectOne(queryWrapper);
        if(kechngCollectionEntity==null){
            kechngCollection.setInsertTime(new Date());
            kechngCollection.setCreateTime(new Date());
        //  String role = String.valueOf(request.getSession().getAttribute("role"));
        //  if("".equals(role)){
        //      kechngCollection.set
        //  }
        kechngCollectionService.insert(kechngCollection);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }


}

 

package com.controller;


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.StringUtil;
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.KechngEntity;

import com.service.KechngService;
import com.entity.view.KechngView;

import com.utils.PageUtils;
import com.utils.R;

/**
 * 课程
 * 后端接口
 * @author
 * @email
 * @date 2021-04-15
*/
@RestController
@Controller
@RequestMapping("/kechng")
public class KechngController {
    private static final Logger logger = LoggerFactory.getLogger(KechngController.class);

    @Autowired
    private KechngService kechngService;


    @Autowired
    private TokenService tokenService;
    @Autowired
    private DictionaryService dictionaryService;



    //级联表service


    /**
    * 后端列表
    */
    @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(StringUtil.isNotEmpty(role) && "学生".equals(role)){
            params.put("yonghuId",request.getSession().getAttribute("userId"));
        } if(StringUtil.isNotEmpty(role) && "教师".equals(role)){
            params.put("jiaoshiId",request.getSession().getAttribute("userId"));
        }
        params.put("orderBy","id");
        PageUtils page = kechngService.queryPage(params);

        //字典表数据转换
        List<KechngView> list =(List<KechngView>)page.getList();
        for(KechngView c:list){
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(c);
        }
        return R.ok().put("data", page);
    }

    /**
    * 后端详情
    */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        KechngEntity kechng = kechngService.selectById(id);
        if(kechng !=null){
            //entity转view
            KechngView view = new KechngView();
            BeanUtils.copyProperties( kechng , view );//把实体数据重构到view中

            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody KechngEntity kechng, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,kechng:{}",this.getClass().getName(),kechng.toString());
        Wrapper<KechngEntity> queryWrapper = new EntityWrapper<KechngEntity>()
            .eq("kechng_name", kechng.getKechngName())
            .eq("kechng_types", kechng.getKechngTypes())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        KechngEntity kechngEntity = kechngService.selectOne(queryWrapper);
        if(kechngEntity==null){
            kechng.setCreateTime(new Date());
        //  String role = String.valueOf(request.getSession().getAttribute("role"));
        //  if("".equals(role)){
        //      kechng.set
        //  }
            kechngService.insert(kechng);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody KechngEntity kechng, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,kechng:{}",this.getClass().getName(),kechng.toString());
        //根据字段查询是否有相同数据
        Wrapper<KechngEntity> queryWrapper = new EntityWrapper<KechngEntity>()
            .notIn("id",kechng.getId())
            .andNew()
            .eq("kechng_name", kechng.getKechngName())
            .eq("kechng_types", kechng.getKechngTypes())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        KechngEntity kechngEntity = kechngService.selectOne(queryWrapper);
        if("".equals(kechng.getKechngPhoto()) || "null".equals(kechng.getKechngPhoto())){
                kechng.setKechngPhoto(null);
        }
        if(kechngEntity==null){
            //  String role = String.valueOf(request.getSession().getAttribute("role"));
            //  if("".equals(role)){
            //      kechng.set
            //  }
            kechngService.updateById(kechng);//根据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());
        kechngService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }



    /**
    * 前端列表
    */
    @RequestMapping("/list")
    public R list(@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(StringUtil.isNotEmpty(role) && "学生".equals(role)){
            params.put("yonghuId",request.getSession().getAttribute("userId"));
        } if(StringUtil.isNotEmpty(role) && "教师".equals(role)){
            params.put("jiaoshiId",request.getSession().getAttribute("userId"));
        }
        // 没有指定排序字段就默认id倒序
        if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
            params.put("orderBy","id");
        }
        PageUtils page = kechngService.queryPage(params);

        //字典表数据转换
        List<KechngView> list =(List<KechngView>)page.getList();
        for(KechngView c:list){
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(c);
        }
        return R.ok().put("data", page);
    }

    /**
    * 前端详情
    */
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id){
        logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        KechngEntity kechng = kechngService.selectById(id);
            if(kechng !=null){
                //entity转view
        KechngView view = new KechngView();
                BeanUtils.copyProperties( kechng , view );//把实体数据重构到view中

                //修改对应字典表字段
                dictionaryService.dictionaryConvert(view);
                return R.ok().put("data", view);
            }else {
                return R.error(511,"查不到数据");
            }
    }


    /**
    * 前端保存
    */
    @RequestMapping("/add")
    public R add(@RequestBody KechngEntity kechng, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,kechng:{}",this.getClass().getName(),kechng.toString());
        Wrapper<KechngEntity> queryWrapper = new EntityWrapper<KechngEntity>()
            .eq("kechng_name", kechng.getKechngName())
            .eq("kechng_types", kechng.getKechngTypes())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
    KechngEntity kechngEntity = kechngService.selectOne(queryWrapper);
        if(kechngEntity==null){
            kechng.setCreateTime(new Date());
        //  String role = String.valueOf(request.getSession().getAttribute("role"));
        //  if("".equals(role)){
        //      kechng.set
        //  }
        kechngService.insert(kechng);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }


}

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序猿毕业分享网

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值