ssm学生请假系统源码和论文

ssm学生请假系统034


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

摘  要

现代经济快节奏发展以及不断完善升级的信息化技术,让传统数据信息的管理升级为软件存储,归纳,集中处理数据信息的管理方式。本学生请假系统就是在这样的大环境下诞生,其可以帮助管理者在短时间内处理完毕庞大的数据信息,使用这种软件工具可以帮助管理人员提高事务处理效率,达到事半功倍的效果。此学生请假系统利用当下成熟完善的SSM框架,使用跨平台的可开发大型商业网站的Java语言,以及最受欢迎的RDBMS应用软件之一的Mysql数据库进行程序开发。实现了学的请假的一个申请功能,老师和管理员可以对学生的请求做出处理,学生请假系统的开发根据操作人员需要设计的界面简洁美观,在功能模块布局上跟同类型网站保持一致,程序在实现基本要求功能时,也为数据信息面临的安全问题提供了一些实用的解决方案。可以说该程序在帮助管理者高效率地处理工作事务的同时,也实现了数据信息的整体化,规范化与自动化。

关键词:学生请假系统;SSM框架;Mysql;自动化

ssm学生请假系统源码和论文_第1张图片ssm学生请假系统源码和论文_第2张图片ssm学生请假系统源码和论文_第3张图片ssm学生请假系统源码和论文_第4张图片ssm学生请假系统源码和论文_第5张图片ssm学生请假系统源码和论文_第6张图片ssm学生请假系统源码和论文_第7张图片ssm学生请假系统源码和论文_第8张图片ssm学生请假系统源码和论文_第9张图片ssm学生请假系统源码和论文_第10张图片ssm学生请假系统源码和论文_第11张图片ssm学生请假系统源码和论文_第12张图片

package com.controller;


import java.text.DateFormat;
import java.text.ParseException;
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 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.ChuqinEntity;

import com.service.ChuqinService;
import com.entity.view.ChuqinView;
import com.service.YonghuService;
import com.entity.YonghuEntity;
import com.utils.PageUtils;
import com.utils.R;

/**
 * 考勤
 * 后端接口
 * @author
 * @email
 * @date 2021-02-25
*/
@RestController
@Controller
@RequestMapping("/chuqin")
public class ChuqinController {
    private static final Logger logger = LoggerFactory.getLogger(ChuqinController.class);

    @Autowired
    private ChuqinService chuqinService;


    @Autowired
    private TokenService tokenService;


    //级联表service
    @Autowired
    private YonghuService yonghuService;

    //字典表map
    Map> dictionaryMap;

    /**
    * 后端列表
    */
    @RequestMapping("/page")
    public R page(@RequestParam Map 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"));
        }
        PageUtils page = chuqinService.queryPage(params);

        //字典表数据转换
        List list =(List)page.getList();
        ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
        dictionaryMap = (Map>) servletContext.getAttribute("dictionaryMap");
        for(ChuqinView c:list){
            this.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);
        ChuqinEntity chuqin = chuqinService.selectById(id);
        if(chuqin !=null){
            //entity转view
            ChuqinView view = new ChuqinView();
            BeanUtils.copyProperties( chuqin , view );//把实体数据重构到view中

            //级联表
            YonghuEntity yonghu = yonghuService.selectById(chuqin.getYonghuId());
            if(yonghu != null){
                BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
            }
            //字典表字典转换
            ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
            dictionaryMap = (Map>) servletContext.getAttribute("dictionaryMap");
            this.dictionaryConvert(view);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }



    /**
    * 打卡
    */
    @RequestMapping("/clockIn")
    public R clockIn(String flag, HttpServletRequest request){
        logger.debug("clockIn方法:,,Controller:{},,flag:{}",this.getClass().getName(),flag);
        try {
            Integer id = (Integer)request.getSession().getAttribute("userId");
            String role = String.valueOf(request.getSession().getAttribute("role"));
            if(StringUtil.isEmpty(role) || "管理员".equals(role)){
                return R.error(511,"没有打卡权限");
            }
            Date d = new Date();
            SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
            String date = format1.format(d);
            List chuqinList = new ArrayList();//要生成的list数据
            List s = new ArrayList<>();
            s.add("yonghu_id+0");
            Wrapper queryWrapper3 = new EntityWrapper().eq("yonghu_id",id).orderDesc(s);
            List oldChuqinList = chuqinService.selectList(queryWrapper3);
            if("1".equals(flag)){
                //上班卡
                Date date1 = new Date();
                date1.setHours(8);
                date1.setMinutes(0);
                date1.setSeconds(0);
                //上班打卡
                //新增前先查看当前用户最大打卡时间

                if(oldChuqinList != null && oldChuqinList.size()>0){
                    ChuqinEntity entity = oldChuqinList.get(0);
                    String today = entity.getToday();//获取出勤表最大出勤
                    //把日期加一天
                    Date todayTime = format1.parse(today);
                    Calendar   calendar = new GregorianCalendar();
                    calendar.setTime(todayTime);
                    calendar.add(calendar.DATE,1);
                    String newToday = format1.format(calendar.getTime());
                    if(date.equals(today)){
                        return R.error(511,"已经打过上班卡了");
                    }else if(!date.equals(newToday)){//当天日期 不是出勤最大日期加一天的话   就是补充缺勤日期
                        chuqinList = this.getQueQin(d, format1, today, id);
                    }

                    if(chuqinList !=null && chuqinList.size() >0){
                        chuqinService.insertBatch(chuqinList);
                    }


                    //插入当天的上班卡
                    ChuqinEntity chuqin = new ChuqinEntity();
                    chuqin.setOnTime(d);
                    if(d.compareTo(date1)>0){//当前时间d 大于规定时间date1
                        chuqin.setChuqinTypes(6);//设置为迟到
                    }else if(d.compareTo(date1)<=0){//当前时间d 小于等于规定时间date1
                        chuqin.setChuqinTypes(3);//设置为未打下班卡
                    }
                    chuqin.setCreateTime(d);
                    chuqin.setToday(date);
                    chuqin.setYonghuId(id);
                    chuqinService.insert(chuqin);
                }else{
                    //第一次打卡
                    ChuqinEntity chuqin = new ChuqinEntity();
                    chuqin.setOnTime(d);
                    if(d.compareTo(date1)>0){//当前时间d 大于规定时间date1
                        chuqin.setChuqinTypes(6);//设置为迟到
                    }else if(d.compareTo(date1)<=0){//当前时间d 小于等于规定时间date1
                        chuqin.setChuqinTypes(3);//设置为未打下班卡
                    }
                    chuqin.setCreateTime(d);
                    chuqin.setToday(date);
                    chuqin.setYonghuId(id);
                    chuqinService.insert(chuqin);
                }

            }else if("2".equals(flag)){
                //下班卡
                Date date1 = new Date();
                date1.setHours(19);
                date1.setMinutes(00);
                date1.setSeconds(0);
                Date date2 = new Date();
                date2.setHours(18);
                date2.setMinutes(00);
                date2.setSeconds(0);
                //下班打卡
                if(oldChuqinList!=null){//不是第一次打卡
                    //查询当前用户是否生成了上班打卡
                    Wrapper queryWrapper = new EntityWrapper().eq("yonghu_id",id).eq("today",date).orderDesc(s);
                    ChuqinEntity chuqinEntity = chuqinService.selectOne(queryWrapper);
                    if(chuqinEntity !=null){//生成了上班打卡
                        chuqinEntity.setDownTime(d);
                        if("6".equals(String.valueOf(chuqinEntity.getChuqinTypes()))){
                        }else if(d.compareTo(date1)>0){//当前时间d 大于规定时间   加班
                            int hours = d.getHours();
                            int i = hours - 19+1;
                            if(i>0){
                                chuqinEntity.setOvertimeNumber(i);
                            }
                            chuqinEntity.setChuqinTypes(5);//设置为迟到
                        }else if(d.compareTo(date2)<0){//当前时间d 小于等于规定时间 早退
                            chuqinEntity.setChuqinTypes(7);//设置为未打下班卡
                        }else{
                            chuqinEntity.setChuqinTypes(1);
                        }
                        chuqinService.updateById(chuqinEntity);
                    }else{
                        //当天上午没有生成上班打卡,要防止用户昨天及之前没有生成打卡记录
                        Wrapper queryWrapper1 = new EntityWrapper().eq("yonghu_id",id).orderDesc(s);
                        List list = chuqinService.selectList(queryWrapper1);
                        if(list != null && list.size()>0){
                            ChuqinEntity entity = list.get(0);
                            String today = entity.getToday();//获取出勤表最大出勤
                            Date todayTime = format1.parse(today);
                            Calendar calendar = new GregorianCalendar();
                            calendar.setTime(todayTime);
                            calendar.add(calendar.DATE,1);
                            String newToday = format1.format(calendar.getTime());
                            if(date.equals(today)){
                                //昨天id+1  等于今天的话  就是直接新增下午打卡
                                ChuqinEntity chuqin = new ChuqinEntity();
                                chuqin.setDownTime(d);
                                chuqin.setChuqinTypes(2);
                                chuqinService.insert(chuqin);
                            }else if(!date.equals(newToday)){//当天日期 不是出勤最大日期加一天的话   就是补充缺勤日期
                                chuqinList = this.getQueQin(d, format1, today, id);
                            }

                            if(chuqinList !=null && chuqinList.size() >0){
                                chuqinService.insertBatch(chuqinList);
                            }
                        }
                    }
                }else{
                    //第一次打卡
                    ChuqinEntity chuqin = new ChuqinEntity();
                    chuqin.setDownTime(d);
                    chuqin.setChuqinTypes(2);
                    chuqinService.insert(chuqin);
                }
            }else {
                return R.error(511,"未知错误");
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }catch (Exception e) {
            e.printStackTrace();
        }
        return R.ok();
    }
//
//
//
// /**
//    * 后端保存
//    */
//    @RequestMapping("/save")
//    public R save(@RequestBody ChuqinEntity chuqin, HttpServletRequest request){
//        logger.debug("save方法:,,Controller:{},,chuqin:{}",this.getClass().getName(),chuqin.toString());
//        Wrapper queryWrapper = new EntityWrapper()
//            .eq("yonghu_id", chuqin.getYonghuId())
//            .eq("today", chuqin.getToday())
//            .eq("chuqin_types", chuqin.getChuqinTypes())
//            .eq("overtimeNumber", chuqin.getOvertimeNumber())
//            ;
//        logger.info("sql语句:"+queryWrapper.getSqlSegment());
//        ChuqinEntity chuqinEntity = chuqinService.selectOne(queryWrapper);
//        if(chuqinEntity==null){
//            chuqin.setCreateTime(new Date());
//        //  String role = String.valueOf(request.getSession().getAttribute("role"));
//        //  if("".equals(role)){
//        //      chuqin.set
//        //  }
//            chuqinService.insert(chuqin);
//            return R.ok();
//        }else {
//            return R.error(511,"表中有相同数据");
//        }
//    }
//
//    /**
//    * 修改
//    */
//    @RequestMapping("/update")
//    public R update(@RequestBody ChuqinEntity chuqin, HttpServletRequest request){
//        logger.debug("update方法:,,Controller:{},,chuqin:{}",this.getClass().getName(),chuqin.toString());
//        //根据字段查询是否有相同数据
//        Wrapper queryWrapper = new EntityWrapper()
//            .notIn("id",chuqin.getId())
//            .eq("yonghu_id", chuqin.getYonghuId())
//            .eq("today", chuqin.getToday())
//            .eq("chuqin_types", chuqin.getChuqinTypes())
//            .eq("overtimeNumber", chuqin.getOvertimeNumber())
//            ;
//        logger.info("sql语句:"+queryWrapper.getSqlSegment());
//        ChuqinEntity chuqinEntity = chuqinService.selectOne(queryWrapper);
//                chuqin.setOnTime(new Date());
//                chuqin.setDownTime(new Date());
//        if(chuqinEntity==null){
//            //  String role = String.valueOf(request.getSession().getAttribute("role"));
//            //  if("".equals(role)){
//            //      chuqin.set
//            //  }
//            chuqinService.updateById(chuqin);//根据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());
        chuqinService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }

    /**
    *字典表数据转换
    */
    public void dictionaryConvert(ChuqinView chuqinView){
        //当前表的字典字段
        if(StringUtil.isNotEmpty(String.valueOf(chuqinView.getChuqinTypes()))){
            chuqinView.setChuqinValue(dictionaryMap.get("chuqin_types").get(chuqinView.getChuqinTypes()));
        }

        //级联表的字典字段
        if(StringUtil.isNotEmpty(String.valueOf(chuqinView.getZhiwuTypes()))){
            chuqinView.setZhiwuValue(dictionaryMap.get("zhiwu_types").get(chuqinView.getZhiwuTypes()));
        }
        if(StringUtil.isNotEmpty(String.valueOf(chuqinView.getZhichengTypes()))){
            chuqinView.setZhichengValue(dictionaryMap.get("zhicheng_types").get(chuqinView.getZhichengTypes()));
        }
        if(StringUtil.isNotEmpty(String.valueOf(chuqinView.getSexTypes()))){
            chuqinView.setSexValue(dictionaryMap.get("sex_types").get(chuqinView.getSexTypes()));
        }
        if(StringUtil.isNotEmpty(String.valueOf(chuqinView.getPoliticsTypes()))){
            chuqinView.setPoliticsValue(dictionaryMap.get("politics_types").get(chuqinView.getPoliticsTypes()));
        }
        if(StringUtil.isNotEmpty(String.valueOf(chuqinView.getMarriageTypes()))){
            chuqinView.setMarriageValue(dictionaryMap.get("marriage_types").get(chuqinView.getMarriageTypes()));
        }
        if(StringUtil.isNotEmpty(String.valueOf(chuqinView.getEducationTypes()))){
            chuqinView.setEducationValue(dictionaryMap.get("education_types").get(chuqinView.getEducationTypes()));
        }
    }


    /**
     *
     * @param d   当前日期
     * @param format1 "yyyy-MM-dd"
     * @param newToday 数据库存的最大打卡日期 加一天
     * @param id    打卡人id
     * @return
     * @throws ParseException
     */
    public static  List getQueQin(Date d,SimpleDateFormat format1,String newToday,Integer id) throws ParseException {
        List list = new ArrayList<>();
        // 返回的日期集合
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date start = dateFormat.parse(newToday);
        Calendar   calendar = new GregorianCalendar();
        calendar.setTime(d);
        calendar.add(calendar.DATE,-1); //当前时间减去一天,即一天前的时间
        Date end = dateFormat.parse(format1.format(calendar.getTime()));

        Calendar tempStart = Calendar.getInstance();
        tempStart.setTime(start);

        Calendar tempEnd = Calendar.getInstance();
        tempEnd.setTime(end);
        tempEnd.add(Calendar.DATE, +1);// 日期加1(包含结束)
        while (tempStart.before(tempEnd)) {
            ChuqinEntity chuqinEntity = new ChuqinEntity();
            chuqinEntity.setYonghuId(id);
            chuqinEntity.setToday(dateFormat.format(tempStart.getTime()));
            chuqinEntity.setCreateTime(d);
            chuqinEntity.setChuqinTypes(4);
            list.add(chuqinEntity);
            tempStart.add(Calendar.DAY_OF_YEAR, 1);
        }
        return list;
    }

}

package com.controller;

import java.text.SimpleDateFormat;
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.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.ShequyonghuEntity;
import com.entity.view.ShequyonghuView;

import com.service.ShequyonghuService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.CommonUtil;


/**
 * 社区用户
 * 后端接口
 * @author 
 * @email 
 * @date 2021-02-27 15:35:54
 */
@RestController
@RequestMapping("/shequyonghu")
public class ShequyonghuController {
    @Autowired
    private ShequyonghuService shequyonghuService;
    
	@Autowired
	private TokenService tokenService;
	
	/**
	 * 登录
	 */
	@IgnoreAuth
	@RequestMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		ShequyonghuEntity user = shequyonghuService.selectOne(new EntityWrapper().eq("yonghuzhanghao", username));
		if(user==null || !user.getMima().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(), username,"shequyonghu",  "社区用户" );
		return R.ok().put("token", token);
	}
	
	/**
     * 注册
     */
	@IgnoreAuth
    @RequestMapping("/register")
    public R register(@RequestBody ShequyonghuEntity shequyonghu){
    	//ValidatorUtils.validateEntity(shequyonghu);
    	ShequyonghuEntity user = shequyonghuService.selectOne(new EntityWrapper().eq("yonghuzhanghao", shequyonghu.getYonghuzhanghao()));
		if(user!=null) {
			return R.error("注册用户已存在");
		}
		Long uId = new Date().getTime();
		shequyonghu.setId(uId);
        shequyonghuService.insert(shequyonghu);
        return R.ok();
    }
	
	/**
	 * 退出
	 */
	@RequestMapping("/logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        ShequyonghuEntity user = shequyonghuService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	ShequyonghuEntity user = shequyonghuService.selectOne(new EntityWrapper().eq("yonghuzhanghao", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
        user.setMima("123456");
        shequyonghuService.updateById(user);
        return R.ok("密码已重置为:123456");
    }


    /**
     * 后端列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map params,ShequyonghuEntity shequyonghu, HttpServletRequest request){

        EntityWrapper ew = new EntityWrapper();
    	PageUtils page = shequyonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shequyonghu), params), params));
		request.setAttribute("data", page);
        return R.ok().put("data", page);
    }
    
    /**
     * 前端列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map params,ShequyonghuEntity shequyonghu, HttpServletRequest request){
        EntityWrapper ew = new EntityWrapper();
    	PageUtils page = shequyonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, shequyonghu), params), params));
		request.setAttribute("data", page);
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/lists")
    public R list( ShequyonghuEntity shequyonghu){
       	EntityWrapper ew = new EntityWrapper();
      	ew.allEq(MPUtil.allEQMapPre( shequyonghu, "shequyonghu")); 
        return R.ok().put("data", shequyonghuService.selectListView(ew));
    }

	 /**
     * 查询
     */
    @RequestMapping("/query")
    public R query(ShequyonghuEntity shequyonghu){
        EntityWrapper< ShequyonghuEntity> ew = new EntityWrapper< ShequyonghuEntity>();
 		ew.allEq(MPUtil.allEQMapPre( shequyonghu, "shequyonghu")); 
		ShequyonghuView shequyonghuView =  shequyonghuService.selectView(ew);
		return R.ok("查询社区用户成功").put("data", shequyonghuView);
    }
	
    /**
     * 后端详情
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        ShequyonghuEntity shequyonghu = shequyonghuService.selectById(id);
        return R.ok().put("data", shequyonghu);
    }

    /**
     * 前端详情
     */
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id){
        ShequyonghuEntity shequyonghu = shequyonghuService.selectById(id);
        return R.ok().put("data", shequyonghu);
    }
    



    /**
     * 后端保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody ShequyonghuEntity shequyonghu, HttpServletRequest request){
    	shequyonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(shequyonghu);
    	ShequyonghuEntity user = shequyonghuService.selectOne(new EntityWrapper().eq("yonghuzhanghao", shequyonghu.getYonghuzhanghao()));
		if(user!=null) {
			return R.error("用户已存在");
		}

		shequyonghu.setId(new Date().getTime());
        shequyonghuService.insert(shequyonghu);
        return R.ok();
    }
    
    /**
     * 前端保存
     */
    @RequestMapping("/add")
    public R add(@RequestBody ShequyonghuEntity shequyonghu, HttpServletRequest request){
    	shequyonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(shequyonghu);
    	ShequyonghuEntity user = shequyonghuService.selectOne(new EntityWrapper().eq("yonghuzhanghao", shequyonghu.getYonghuzhanghao()));
		if(user!=null) {
			return R.error("用户已存在");
		}

		shequyonghu.setId(new Date().getTime());
        shequyonghuService.insert(shequyonghu);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody ShequyonghuEntity shequyonghu, HttpServletRequest request){
        //ValidatorUtils.validateEntity(shequyonghu);
        shequyonghuService.updateById(shequyonghu);//全部更新
        return R.ok();
    }
    

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        shequyonghuService.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 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 wrapper = new EntityWrapper();
		if(map.get("remindstart")!=null) {
			wrapper.ge(columnName, map.get("remindstart"));
		}
		if(map.get("remindend")!=null) {
			wrapper.le(columnName, map.get("remindend"));
		}


		int count = shequyonghuService.selectCount(wrapper);
		return R.ok().put("count", count);
	}
	
	


}

你可能感兴趣的:(数据库,开发语言,ssm,java)