ssm学生宿舍管理系统源码和论文

ssm学生宿舍管理系统源码和论文094

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

  • 选题背景、意义

经过查阅资料和调查统计发现,高校学生宿舍管理工作变得越来越繁重和琐碎,如在学生住宿安排(特别是新生住宿安排)、宿舍大幅调换、公共设施统计维护、宿舍杂费统计收取、宿舍卫生管理统计、出入登记记录等各个方法存在着大量问题和漏洞,传统的人工材料统计出现了大量的混乱和偏差情况。

这种传统的人工材料管理模式不但耗费大量的人力物力、时间金钱,而且产生的资料数据准确性存在较大问题,对于统计分析查询都造成了大量的繁琐问题。当数据量逐渐增加时,这种统计与查询产生的问题将是灾难性的。

由上述问题可以看出,开发一套功能完备、性能优秀的学生宿舍管理系统来减轻人员的工作压力与精力,减少物力财力,提高宿舍管理的工作效率,填补相关管理漏洞已经十分迫切。

package com.controller;


import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;

import com.entity.SusheYonghuEntity;
import com.entity.ZichanEntity;
import com.service.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;

import com.utils.StringUtil;
import java.lang.reflect.InvocationTargetException;

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.SusheEntity;

import com.entity.view.SusheView;
import com.utils.PageUtils;
import com.utils.R;

/**
 * 宿舍信息
 * 后端接口
 * @author
 * @email
 * @date
*/
@RestController
@Controller
@RequestMapping("/sushe")
public class SusheController {
    private static final Logger logger = LoggerFactory.getLogger(SusheController.class);

    @Autowired
    private SusheService susheService;


    @Autowired
    private TokenService tokenService;
    @Autowired
    private DictionaryService dictionaryService;
    @Autowired
    private SusheYonghuService susheYonghuService;
    @Autowired
    private ZichanService zichanService;


    //级联表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)){
            EntityWrapper<SusheYonghuEntity> wrapper = new EntityWrapper<>();
            wrapper.eq("yonghu_id",request.getSession().getAttribute("userId"));
            SusheYonghuEntity susheYonghuEntity = susheYonghuService.selectOne(wrapper);
            if(susheYonghuEntity!= null){
                params.put("id",susheYonghuEntity.getSusheId());
            }else{
                params.put("id",-999);
            }
        }
        PageUtils page = susheService.queryPage(params);

        //字典表数据转换
        List<SusheView> list =(List<SusheView>)page.getList();
        for(SusheView 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);
        SusheEntity sushe = susheService.selectById(id);
        if(sushe !=null){
            //entity转view
            SusheView view = new SusheView();
            BeanUtils.copyProperties( sushe , view );//把实体数据重构到view中

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

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody SusheEntity sushe, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,sushe:{}",this.getClass().getName(),sushe.toString());
        String building = sushe.getBuilding();
        String unit = sushe.getUnit();
        String room = sushe.getRoom();
        Wrapper<SusheEntity> queryWrapper = new EntityWrapper<SusheEntity>()
            .eq("building", building)
            .eq("unit", unit)
            .eq("room",room);
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        SusheEntity susheEntity = susheService.selectOne(queryWrapper);
        if(susheEntity==null){
            Date date = new Date();
            sushe.setCreateTime(date);
            sushe.setSusheNumber(0);
            susheService.insert(sushe);

            Integer susheId = sushe.getId();

            List<ZichanEntity> zichanList = new ArrayList<>();

            ZichanEntity zhuoziZichan = new ZichanEntity();
            zhuoziZichan.setZichanName("桌子");
            zhuoziZichan.setZichanTypes(1);
            zhuoziZichan.setSusheId(susheId);
            zhuoziZichan.setCreateTime(date);
            zichanList.add(zhuoziZichan);

            ZichanEntity kongtiaoZichan = new ZichanEntity();
            kongtiaoZichan.setZichanName("空调");
            kongtiaoZichan.setZichanTypes(1);
            kongtiaoZichan.setSusheId(susheId);
            kongtiaoZichan.setCreateTime(date);
            zichanList.add(kongtiaoZichan);

            ZichanEntity bandengZichan = new ZichanEntity();
            bandengZichan.setZichanName("板凳");
            bandengZichan.setZichanTypes(1);
            bandengZichan.setSusheId(susheId);
            bandengZichan.setCreateTime(date);
            zichanList.add(bandengZichan);

            ZichanEntity chuangZichan = new ZichanEntity();
            chuangZichan.setZichanName("床");
            chuangZichan.setZichanTypes(1);
            chuangZichan.setSusheId(susheId);
            chuangZichan.setCreateTime(date);
            zichanList.add(chuangZichan);

            zichanService.insertBatch(zichanList);
            return R.ok();
        }else {
            return R.error(511,"表中已有公寓:"+building+",单元:"+unit+",房间号:"+room+"的房间");
        }
    }

    /**
    * 修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody SusheEntity sushe, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,sushe:{}",this.getClass().getName(),sushe.toString());
        String building = sushe.getBuilding();
        String unit = sushe.getUnit();
        String room = sushe.getRoom();
        Wrapper<SusheEntity> queryWrapper = new EntityWrapper<SusheEntity>()
            .notIn("id",sushe.getId())
            .eq("building", building)
            .eq("unit", unit)
            .eq("room", room);
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        SusheEntity susheEntity = susheService.selectOne(queryWrapper);
        if(susheEntity==null){
            susheService.updateById(sushe);//根据id更新
            return R.ok();
        }else {
            return R.error(511,"表中已有公寓:"+building+",单元:"+unit+",房间号:"+room+"的房间");
        }
    }


    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
        logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
        if(ids != null && ids.length>0){
            //删除宿舍
            susheService.deleteBatchIds(Arrays.asList(ids));
            //级联删除宿舍用户关系
            susheYonghuService.delete(new EntityWrapper<SusheYonghuEntity>().in("sushe_id", Arrays.asList(ids)));
            //级联删除宿舍资产
            zichanService.delete(new EntityWrapper<ZichanEntity>().in("sushe_id", Arrays.asList(ids)));
        }
        return R.ok();
    }


}

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.YonghuEntity;

import com.service.YonghuService;
import com.entity.view.YonghuView;
import com.utils.PageUtils;
import com.utils.R;

/**
 * 学生
 * 后端接口
 * @author
 * @email
 * @date 2021-03-20
*/
@RestController
@Controller
@RequestMapping("/yonghu")
public class YonghuController {
    private static final Logger logger = LoggerFactory.getLogger(YonghuController.class);

    @Autowired
    private YonghuService yonghuService;


    @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));
        PageUtils page = yonghuService.queryPage(params);

        //字典表数据转换
        List<YonghuView> list =(List<YonghuView>)page.getList();
        for(YonghuView 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);
        YonghuEntity yonghu = yonghuService.selectById(id);
        if(yonghu !=null){
            //entity转view
            YonghuView view = new YonghuView();
            BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中

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

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
        Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
            .eq("username", yonghu.getUsername())
            .eq("password", yonghu.getPassword())
            .eq("name", yonghu.getName())
            .eq("phone", yonghu.getPhone())
            .eq("id_number", yonghu.getIdNumber())
            .eq("sex_types", yonghu.getSexTypes())
            .eq("banji_types", yonghu.getBanjiTypes())
            .eq("nation", yonghu.getNation())
            .eq("politics_types", yonghu.getPoliticsTypes())
            .eq("birthplace", yonghu.getBirthplace())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
        if(yonghuEntity==null){
            yonghu.setCreateTime(new Date());
            yonghu.setPassword("123456");
        //  String role = String.valueOf(request.getSession().getAttribute("role"));
        //  if("".equals(role)){
        //      yonghu.set
        //  }
            yonghuService.insert(yonghu);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());
        //根据字段查询是否有相同数据
        Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
            .notIn("id",yonghu.getId())
            .eq("username", yonghu.getUsername())
            .eq("password", yonghu.getPassword())
            .eq("name", yonghu.getName())
            .eq("phone", yonghu.getPhone())
            .eq("id_number", yonghu.getIdNumber())
            .eq("sex_types", yonghu.getSexTypes())
            .eq("banji_types", yonghu.getBanjiTypes())
            .eq("nation", yonghu.getNation())
            .eq("politics_types", yonghu.getPoliticsTypes())
            .eq("birthplace", yonghu.getBirthplace())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
        if("".equals(yonghu.getMyPhoto()) || "null".equals(yonghu.getMyPhoto())){
                yonghu.setMyPhoto(null);
        }
        if(yonghuEntity==null){
            //  String role = String.valueOf(request.getSession().getAttribute("role"));
            //  if("".equals(role)){
            //      yonghu.set
            //  }
            yonghuService.updateById(yonghu);//根据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());
        yonghuService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }


    /**
    * 登录
    */
    @IgnoreAuth
    @PostMapping(value = "/login")
    public R login(String username, String password, String captcha, HttpServletRequest request) {
    YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));
        if(yonghu==null || !yonghu.getPassword().equals(password)) {
            return R.error("账号或密码不正确");
        }
        String token = tokenService.generateToken(yonghu.getId(),username, "yonghu", "用户");
        R r = R.ok();
        r.put("token", token);
        r.put("role","用户");
        r.put("userId",yonghu.getId());
        return r;
    }

    /**
    * 注册
    */
    @IgnoreAuth
    @PostMapping(value = "/register")
    public R register(@RequestBody YonghuEntity yonghu){
    //    	ValidatorUtils.validateEntity(user);
        if(yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", yonghu.getUsername()).orNew().eq("phone",yonghu.getPhone()).orNew().eq("id_number",yonghu.getIdNumber())) !=null) {
            return R.error("用户已存在或手机号身份证号已经被使用");
        }
        yonghuService.insert(yonghu);
        return R.ok();
    }

    /**
    * 获取用户的session用户信息
    */
    @RequestMapping("/session")
    public R getCurrYonghu(HttpServletRequest request){
        Integer id = (Integer)request.getSession().getAttribute("userId");
        YonghuEntity yonghu = yonghuService.selectById(id);
        return R.ok().put("data", yonghu);
    }


    /**
    * 退出
    */
    @GetMapping(value = "logout")
    public R logout(HttpServletRequest request) {
        request.getSession().invalidate();
        return R.ok("退出成功");
    }

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

程序猿毕业分享网

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

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

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

打赏作者

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

抵扣说明:

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

余额充值